00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TOPLEVEL_H_
00022 #define _TOPLEVEL_H_
00023
00024 #include <kapplication.h>
00025 #include <kglobalaccel.h>
00026 #include <kpopupmenu.h>
00027 #include <tqmap.h>
00028 #include <tqpixmap.h>
00029 #include <dcopobject.h>
00030 #include <tqtimer.h>
00031
00032 class QClipboard;
00033 class KToggleAction;
00034 class KAboutData;
00035 class URLGrabber;
00036 class ClipboardPoll;
00037 class TQTime;
00038 class History;
00039 class KAction;
00040 class TQMimeSource;
00041 class HistoryItem;
00042 class KlipperSessionManaged;
00043
00044 class KlipperWidget : public TQWidget, public DCOPObject
00045 {
00046 Q_OBJECT
00047 K_DCOP
00048
00049 k_dcop:
00050 TQString getClipboardContents();
00051 void setClipboardContents(TQString s);
00052 void clearClipboardContents();
00053 void clearClipboardHistory();
00054 TQStringList getClipboardHistoryMenu();
00055 TQString getClipboardHistoryItem(int i);
00056
00057 public:
00058 KlipperWidget( TQWidget *parent, KConfig* config );
00059 ~KlipperWidget();
00060
00061 virtual void adjustSize();
00062 KGlobalAccel *globalKeys;
00063
00067 History* history() { return m_history; }
00068
00069 static void updateTimestamp();
00070 static void createAboutData();
00071 static void destroyAboutData();
00072 static KAboutData* aboutData();
00073
00074 public slots:
00075 void saveSession();
00076 void slotSettingsChanged( int category );
00077 void slotHistoryTopChanged();
00078 void slotConfigure();
00079
00080 protected:
00087 enum SelectionMode { Clipboard = 2, Selection = 4 };
00088
00089 void paintEvent(TQPaintEvent *);
00090 void mousePressEvent(TQMouseEvent *);
00091 void readProperties(KConfig *);
00092 void readConfiguration(KConfig *);
00093
00097 bool loadHistory();
00098
00102 void saveHistory();
00103
00104 void writeConfiguration(KConfig *);
00109 TQString clipboardContents( bool *isSelection = 0L );
00110
00111 void removeFromHistory( const TQString& text );
00112 void setEmptyClipboard();
00113
00114 void clipboardSignalArrived( bool selectionMode );
00115
00120 void checkClipData( bool selectionMode );
00121
00125 void applyClipChanges( const TQMimeSource& data );
00126
00127 void setClipboard( const HistoryItem& item, int mode );
00128 bool ignoreClipboardChanges() const;
00129
00130 KConfig* config() const { return m_config; }
00131 bool isApplet() const { return m_config != kapp->config(); }
00132
00133 protected slots:
00134 void slotPopupMenu();
00135 void showPopupMenu( TQPopupMenu * );
00136 void slotRepeatAction();
00137 void setURLGrabberEnabled( bool );
00138 void toggleURLGrabber();
00139 void disableURLGrabber();
00140
00141 private slots:
00142 void newClipData( bool selectionMode );
00143 void slotClearClipboard();
00144
00145 void slotSelectionChanged() {
00146 clipboardSignalArrived( true );
00147 }
00148 void slotClipboardChanged() {
00149 clipboardSignalArrived( false );
00150 }
00151
00152 void slotQuit();
00153 void slotStartHideTimer();
00154 void slotStartShowTimer();
00155
00156 void slotClearOverflow();
00157 void slotCheckPending();
00158
00159 private:
00160
00161 QClipboard *clip;
00162
00163 TQTime *hideTimer;
00164 TQTime *showTimer;
00165
00166 TQMimeSource* m_lastClipdata;
00167 int m_lastClipboard;
00168 int m_lastSelection;
00169 History* m_history;
00170 int m_overflowCounter;
00171 KToggleAction *toggleURLGrabAction;
00172 KAction* clearHistoryAction;
00173 KAction* configureAction;
00174 KAction* quitAction;
00175 TQPixmap m_pixmap;
00176 TQPixmap m_scaledpixmap;
00177 int m_iconOrigWidth;
00178 int m_iconOrigHeight;
00179 bool bPopupAtMouse :1;
00180 bool bKeepContents :1;
00181 bool bURLGrabber :1;
00182 bool bReplayActionInHistory :1;
00183 bool bUseGUIRegExpEditor :1;
00184 bool bNoNullClipboard :1;
00185 bool bTearOffHandle :1;
00186 bool bIgnoreSelection :1;
00187 bool bSynchronize :1;
00188 bool bSelectionTextOnly :1;
00189 bool bIgnoreImages :1;
00190
00197 int locklevel;
00198
00199 URLGrabber *myURLGrabber;
00200 TQString m_lastURLGrabberTextSelection;
00201 TQString m_lastURLGrabberTextClipboard;
00202 KConfig* m_config;
00203 TQTimer m_overflowClearTimer;
00204 TQTimer m_pendingCheckTimer;
00205 bool m_pendingContentsCheck;
00206 ClipboardPoll* poll;
00207 static KAboutData* about_data;
00208
00209 bool blockFetchingNewData();
00210 KlipperSessionManaged* session_managed;
00211 };
00212
00213 class Klipper : public KlipperWidget
00214 {
00215 Q_OBJECT
00216 K_DCOP
00217 k_dcop:
00218 int newInstance();
00219 void quitProcess();
00220 public:
00221 Klipper( TQWidget* parent = NULL );
00222 };
00223
00224 #endif