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
;
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 actionWidget
->actionList(); }
124 bool keepContents() const {
125 return generalWidget
->cbSaveContents
->isChecked();
127 bool popupAtMousePos() const {
128 return generalWidget
->cbMousePos
->isChecked();
130 bool trimmed() const {
131 return generalWidget
->cbStripWhitespace
->isChecked();
133 bool replayActionInHistory() const {
134 return generalWidget
->cbReplayAIH
->isChecked();
136 bool noNullClipboard() const {
137 return generalWidget
->cbNoNull
->isChecked();
140 int popupTimeout() const {
141 return generalWidget
->popupTimeout
->value();
143 int maxItems() const {
144 return generalWidget
->maxItems
->value();
146 bool ignoreSelection() const
148 return generalWidget
->cbIgnoreSelection
->isChecked();
150 QStringList
noActionsFor() const {
151 return actionWidget
->wmClasses();
153 bool useGUIRegExpEditor() const
155 return actionWidget
->cbUseGUIRegExpEditor
->isChecked();
158 bool synchronize() const {
159 return generalWidget
->cbSynchronize
->isChecked();
161 bool implicitSelection() const {
162 return generalWidget
->cbImplicitSelection
->isChecked();
165 void setKeepContents( bool enable
) {
166 generalWidget
->cbSaveContents
->setChecked( enable
);
168 void setPopupAtMousePos( bool enable
) {
169 generalWidget
->cbMousePos
->setChecked( enable
);
171 void setStripWhiteSpace( bool enable
) {
172 generalWidget
->cbStripWhitespace
->setChecked( enable
);
174 void setReplayActionInHistory( bool enable
) {
175 generalWidget
->cbReplayAIH
->setChecked( enable
);
177 void setNoNullClipboard( bool enable
) {
178 generalWidget
->cbNoNull
->setChecked( enable
);
180 void setPopupTimeout( int timeout
) {
181 generalWidget
->popupTimeout
->setValue( timeout
);
183 void setMaxItems( int items
) {
184 generalWidget
->maxItems
->setValue( items
);
186 void setIgnoreSelection( bool ignore
) {
187 generalWidget
->cbIgnoreSelection
->setChecked( ignore
);
189 void setSynchronize( bool synchronize
) {
190 generalWidget
->cbSynchronize
->setChecked( synchronize
);
192 void setNoActionsFor( const QStringList
& items
) {
193 actionWidget
->setWMClasses( items
);
195 void setUseGUIRegExpEditor( bool enabled
)
197 // the checkbox is only hidden explicitly when there's no
198 // regexp editor component available.
199 if ( !actionWidget
->cbUseGUIRegExpEditor
->isHidden() )
200 actionWidget
->cbUseGUIRegExpEditor
->setChecked( enabled
);
203 void commitShortcuts();
206 GeneralWidget
*generalWidget
;
207 ActionWidget
*actionWidget
;
208 KShortcutsEditor
*shortcutsWidget
;
212 #endif // CONFIGDIALOG_H