summaryrefslogtreecommitdiffstats
path: root/kpf/src/Applet.h
blob: 5b7e9e8c035dc73af89da49d6ced87cebfe12006 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
  KPF - Public fileserver for KDE

  Copyright 2001 Rik Hemsley (rikkus) <rik@kde.org>

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to
  deal in the Software without restriction, including without limitation the
  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  sell copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef KPF_APPLET_H
#define KPF_APPLET_H

#include <tqptrlist.h>
#include <kpanelapplet.h>

class TQPopupMenu;
class TQPainter;
class DCOPClient;

namespace KPF
{
  class AppletItem;
  class ServerWizard;
  class WebServer;

  /**
   * Main `application' class, providing an implementation of KPanelApplet
   * and managing AppletItem objects. Also provides a popup (context) menu of
   * its own, to allow the user to add WebServer (and therefore AppletItem)
   * objects.
   */
  class Applet : public KPanelApplet
  {
    Q_OBJECT
  TQ_OBJECT

    public:

      Applet
        (
         const TQString  & configFile,
         Type         = Normal,
         int          = 0,
         TQWidget    * = 0,
         const char * = 0
        );

      ~Applet();

      /**
       * Overridden to give correct sizing according to orientation and number
       * of contains AppletItem objects.
       */
      virtual int widthForHeight(int h) const;

      /**
       * Overridden to give correct sizing according to orientation and number
       * of contains AppletItem objects.
       */
      virtual int heightForWidth(int w) const;

    protected slots:

      /**
       * Called to create a new server when the path to the server is already
       * known.
       */
      void slotNewServerAtLocation(const TQString &);

      /**
       * Called to create a new server when the path to the server is unknown.
       */
      void slotNewServer();

      /**
       * Called when a ServerWizard is about to close.
       */
      void slotWizardDying(ServerWizard *);

      /**
       * Called when a WebServer object has been created. Creates an
       * AppletItem, associates it with the former, and updates the layout.
       */
      void slotServerCreated(WebServer *);

      /**
       * Called when a WebServer object has been disabled. 
       * Deletes the associated AppletItem and updates the layout.
       */
      void slotServerDisabled(WebServer *);

      /**
       * Called when user asks for quit (via popup menu).
       */
      void slotQuit();

    protected:

      /**
       * Overridden to display help window
       */
      virtual void help();

      /**
       * Overridden to provide an `about' dialog.
       */
      virtual void about();

      /**
       * Overridden to keep track of orientation change and update layout
       * accordingly.
       */
      virtual void orientationChange(Qt::Orientation);

      /**
       * Overridden to update layout accordingly.
       */
      virtual void moveEvent(TQMoveEvent *);
      virtual void resizeEvent(TQResizeEvent *);

      /**
       * Overridden to provide a context menu.
       */
      virtual void mousePressEvent(TQMouseEvent *);

      /**
       * Updates the layout, moving AppletItem objects into proper positions.
       */
      virtual void resetLayout();

      /**
       * Overridden to provide something other than a blank display when there
       * are no existing AppletItem objects contained.
       */
      virtual void drawContents(TQPainter *);

      /**
       * Overridden to allow testing whether the dragged object points to a
       * local directory.
       */
      virtual void dragEnterEvent(TQDragEnterEvent *);

      /**
       * Overridden to allow creating a new WebServer when the dropped object
       * points to a local directory.
       */
      virtual void dropEvent(TQDropEvent *);

    private:

      enum
      {
        NewServer,
        Quit
      };

      ServerWizard      * wizard_;
      TQPopupMenu        * popup_;
      DCOPClient        * dcopClient_;

      TQPtrList<AppletItem>   itemList_;
  };
}

#endif // KPF_APPLET_H

// vim:ts=2:sw=2:tw=78:et