1 // -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
2 /* This file is part of the KDE project
3 Copyright (C) by Andrew Stanley-Jones
4 Copyright (C) 2004 Esben Mose Hansen <kde@mosehansen.dk>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
28 #include <KApplication>
34 class KActionCollection
;
42 class KlipperSessionManager
;
44 class Klipper
: public QObject
47 Q_CLASSINFO("D-Bus Interface", "org.kde.klipper.klipper")
50 Q_SCRIPTABLE QString
getClipboardContents();
51 Q_SCRIPTABLE
void setClipboardContents(QString s
);
52 Q_SCRIPTABLE
void clearClipboardContents();
53 Q_SCRIPTABLE
void clearClipboardHistory();
54 Q_SCRIPTABLE QStringList
getClipboardHistoryMenu();
55 Q_SCRIPTABLE QString
getClipboardHistoryItem(int i
);
56 Q_SCRIPTABLE
void showKlipperPopupMenu();
57 Q_SCRIPTABLE
void showKlipperManuallyInvokeActionMenu();
60 Klipper(QObject
*parent
, const KSharedConfigPtr
&config
);
64 * Get clipboard history (the "document")
66 History
* history() { return m_history
; }
68 static void updateTimestamp();
69 static void createAboutData();
70 static void destroyAboutData();
71 static KAboutData
* aboutData();
75 void slotSettingsChanged( int category
);
76 void slotHistoryTopChanged();
83 * Don't use 1, as I use that as a guard against passing
84 * a boolean true as a mode.
86 enum SelectionMode
{ Clipboard
= 2, Selection
= 4 };
88 void readProperties(KConfig
*);
89 void readConfiguration(KConfig
*);
92 * Loads history from disk.
97 * Save history to disk
101 void writeConfiguration(KConfig
*);
103 * @returns the contents of the selection or, if empty, the contents of
106 QString
clipboardContents( bool *isSelection
= 0L );
108 void removeFromHistory( const QString
& text
);
109 void setEmptyClipboard();
111 void clipboardSignalArrived( bool selectionMode
);
114 * Check data in clipboard, and if it passes these checks,
115 * store the data in the clipboard history.
117 void checkClipData( bool selectionMode
);
120 * Enter clipboard data in the history.
122 void applyClipChanges( const QMimeData
* data
);
124 void setClipboard( const HistoryItem
& item
, int mode
);
125 bool ignoreClipboardChanges() const;
127 KSharedConfigPtr
config() const { return m_config
; }
128 bool isApplet() const { return m_config
!= KGlobal::config(); }
131 void slotPopupMenu();
134 void showPopupMenu( QMenu
* );
135 void slotRepeatAction();
136 void setURLGrabberEnabled( bool );
137 void toggleURLGrabber();
138 void disableURLGrabber();
141 void newClipData( bool selectionMode
);
142 void slotClearClipboard();
144 void slotSelectionChanged() {
145 clipboardSignalArrived( true );
147 void slotClipboardChanged() {
148 clipboardSignalArrived( false );
152 void slotStartHideTimer();
153 void slotStartShowTimer();
155 void slotClearOverflow();
156 void slotCheckPending();
168 int m_overflowCounter
;
169 KToggleAction
*m_toggleURLGrabAction
;
170 QAction
* m_clearHistoryAction
;
171 QAction
* m_configureAction
;
172 QAction
* m_quitAction
;
174 bool m_bPopupAtMouse
:1;
175 bool m_bKeepContents
:1;
176 bool m_bURLGrabber
:1;
177 bool m_bReplayActionInHistory
:1;
178 bool m_bUseGUIRegExpEditor
:1;
179 bool m_bNoNullClipboard
:1;
180 bool m_bTearOffHandle
:1;
181 bool m_bIgnoreSelection
:1;
182 bool m_bSynchronize
:1;
183 bool m_bSelectionTextOnly
:1;
184 bool m_bIgnoreImages
:1;
187 * Avoid reacting to our own changes, using this
189 * Don't manupulate this object directly... use the Ignore struct
194 URLGrabber
*m_myURLGrabber
;
195 QString m_lastURLGrabberTextSelection
;
196 QString m_lastURLGrabberTextClipboard
;
197 KSharedConfigPtr m_config
;
198 QTimer m_overflowClearTimer
;
199 QTimer m_pendingCheckTimer
;
200 bool m_pendingContentsCheck
;
201 ClipboardPoll
* m_poll
;
202 static KAboutData
* m_about_data
;
204 bool blockFetchingNewData();
205 KlipperSessionManager
* m_session_managed
;
206 KActionCollection
*m_collection
;