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) 2000 by Carsten Pfeiffer <pfeiffer@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
20 #ifndef CONFIGDIALOG_H
21 #define CONFIGDIALOG_H
24 #include <QRadioButton>
25 #include <QTreeWidget>
27 #include <keditlistbox.h>
28 #include <knuminput.h>
29 #include <KConfigDialog>
31 #include "urlgrabber.h"
33 class KConfigSkeleton
;
34 class KShortcutsEditor
;
39 class GeneralWidget
: public QWidget
43 friend class ConfigDialog
;
46 GeneralWidget( QWidget
*parent
);
50 void historySizeChanged( int value
);
51 void slotClipConfigChanged();
54 QCheckBox
*cbMousePos
, *cbSaveContents
, *cbReplayAIH
, *cbNoNull
;
55 QCheckBox
*cbIgnoreSelection
, *cbStripWhitespace
, *cbIgnoreImages
;
56 QRadioButton
*cbSynchronize
, *cbImplicitSelection
, *cbSeparate
;
57 KIntNumInput
*popupTimeout
, *maxItems
;
62 // only for use inside ActionWidget
63 class AdvancedWidget
: public QWidget
68 explicit AdvancedWidget( QWidget
*parent
= 0L );
71 void setWMClasses( const QStringList
& items
);
72 QStringList
wmClasses() const { return editListBox
->items(); }
75 KEditListBox
*editListBox
;
78 class ActionWidget
: public QWidget
82 friend class ConfigDialog
;
85 ActionWidget( const ActionList
*list
, QWidget
*parent
);
89 * Creates a list of actions from the listView and returns a pointer to
91 * Make sure to free that pointer when you don't need it anymore.
93 ActionList
* actionList();
95 void setWMClasses( const QStringList
& items
) { m_wmClasses
= items
; }
96 QStringList
wmClasses() const { return m_wmClasses
; }
100 void slotDeleteAction();
101 void slotItemChanged(QTreeWidgetItem
*item
, int column
);
103 void slotContextMenu(const QPoint
& pos
);
104 void selectionChanged();
107 QTreeWidget
*treeWidget
;
108 QStringList m_wmClasses
;
109 AdvancedWidget
*advancedWidget
;
110 QPushButton
*delActionButton
;
111 QCheckBox
*cbUseGUIRegExpEditor
;
114 class ConfigDialog
: public KConfigDialog
119 ConfigDialog( QWidget
*parent
, KConfigSkeleton
*config
, const ActionList
*list
, KActionCollection
*collection
, bool isApplet
);
122 ActionList
* actionList() const { return m_actionWidget
->actionList(); }
124 bool keepContents() const {
125 return m_generalWidget
->cbSaveContents
->isChecked();
127 bool popupAtMousePos() const {
128 return m_generalWidget
->cbMousePos
->isChecked();
130 bool trimmed() const {
131 return m_generalWidget
->cbStripWhitespace
->isChecked();
133 bool replayActionInHistory() const {
134 return m_generalWidget
->cbReplayAIH
->isChecked();
136 bool noNullClipboard() const {
137 return m_generalWidget
->cbNoNull
->isChecked();
140 int popupTimeout() const {
141 return m_generalWidget
->popupTimeout
->value();
143 int maxItems() const {
144 return m_generalWidget
->maxItems
->value();
146 bool ignoreSelection() const
148 return m_generalWidget
->cbIgnoreSelection
->isChecked();
150 bool ignoreImages() const
152 return m_generalWidget
->cbIgnoreImages
->isChecked();
154 QStringList
noActionsFor() const {
155 return m_actionWidget
->wmClasses();
157 bool useGUIRegExpEditor() const
159 return m_actionWidget
->cbUseGUIRegExpEditor
->isChecked();
162 bool synchronize() const {
163 return m_generalWidget
->cbSynchronize
->isChecked();
165 bool implicitSelection() const {
166 return m_generalWidget
->cbImplicitSelection
->isChecked();
169 void setKeepContents( bool enable
) {
170 m_generalWidget
->cbSaveContents
->setChecked( enable
);
172 void setPopupAtMousePos( bool enable
) {
173 m_generalWidget
->cbMousePos
->setChecked( enable
);
175 void setStripWhiteSpace( bool enable
) {
176 m_generalWidget
->cbStripWhitespace
->setChecked( enable
);
178 void setReplayActionInHistory( bool enable
) {
179 m_generalWidget
->cbReplayAIH
->setChecked( enable
);
181 void setNoNullClipboard( bool enable
) {
182 m_generalWidget
->cbNoNull
->setChecked( enable
);
184 void setPopupTimeout( int timeout
) {
185 m_generalWidget
->popupTimeout
->setValue( timeout
);
187 void setMaxItems( int items
) {
188 m_generalWidget
->maxItems
->setValue( items
);
190 void setIgnoreSelection( bool ignore
) {
191 m_generalWidget
->cbIgnoreSelection
->setChecked( ignore
);
193 void setIgnoreImages( bool ignore
) {
194 m_generalWidget
->cbIgnoreImages
->setChecked( ignore
);
196 void setSynchronize( bool synchronize
) {
197 m_generalWidget
->cbSynchronize
->setChecked( synchronize
);
199 void setNoActionsFor( const QStringList
& items
) {
200 m_actionWidget
->setWMClasses( items
);
202 void setUseGUIRegExpEditor( bool enabled
)
204 // the checkbox is only hidden explicitly when there's no
205 // regexp editor component available.
206 if ( !m_actionWidget
->cbUseGUIRegExpEditor
->isHidden() )
207 m_actionWidget
->cbUseGUIRegExpEditor
->setChecked( enabled
);
210 void commitShortcuts();
213 GeneralWidget
*m_generalWidget
;
214 ActionWidget
*m_actionWidget
;
215 KShortcutsEditor
*m_shortcutsWidget
;
219 #endif // CONFIGDIALOG_H