add more spacing
[personal-kdebase.git] / apps / konsole / src / EditProfileDialog.h
blobc2fa6c88263bf192b9c6b39985f52750675b5c68
1 /*
2 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301 USA.
20 #ifndef EDITPROFILEDIALOG_H
21 #define EDITPROFILEDIALOG_H
23 // Qt
24 #include <QtGui/QAbstractItemDelegate>
25 #include <QtCore/QPair>
26 #include <QtCore/QHash>
27 #include <QtCore/QSet>
28 #include <QtCore/QPointer>
30 // KDE
31 #include <KDialog>
33 // Local
34 #include "Profile.h"
36 class QAbstractButton;
37 class QItemSelectionModel;
38 class QTextCodec;
39 class QTimeLine;
41 namespace Ui
43 class EditProfileDialog;
46 namespace Konsole
49 class Profile;
51 /**
52 * A dialog which allows the user to edit a profile.
53 * After the dialog is created, it can be initialised with the settings
54 * for a profile using setProfile(). When the user makes changes to the
55 * dialog and accepts the changes, the dialog will update the
56 * profile in the SessionManager by calling the SessionManager's
57 * changeProfile() method.
59 * Some changes made in the dialog are preview-only changes which cause
60 * the SessionManager's changeProfile() method to be called with
61 * the persistant argument set to false. These changes are then
62 * un-done when the dialog is closed.
64 class EditProfileDialog : public KDialog
66 Q_OBJECT
68 public:
69 /** Constructs a new dialog with the specified parent. */
70 EditProfileDialog(QWidget* parent = 0);
71 virtual ~EditProfileDialog();
73 /**
74 * Initialises the dialog with the settings for the specified session
75 * type.
77 * When the dialog closes, the profile will be updated in the SessionManager
78 * with the altered settings.
80 * @param key The key for the session type provided by the SessionManager instance
82 void setProfile(Profile::Ptr profile);
84 /**
85 * Selects the text in the profile name edit area.
86 * When the dialog is being used to create a new profile,
87 * this can be used to draw the user's attention to the profile name
88 * and make it easy for them to change it.
90 void selectProfileName();
92 public slots:
93 // reimplemented
94 virtual void accept();
95 // reimplemented
96 virtual void reject();
98 protected:
99 virtual bool eventFilter(QObject* watched , QEvent* event);
101 private slots:
102 // sets up the specified tab page if necessary
103 void preparePage(int);
105 // saves changes to profile
106 void save();
108 // general page
109 void selectInitialDir();
110 void selectIcon();
112 void profileNameChanged(const QString& text);
113 void initialDirChanged(const QString& text);
114 void startInSameDir(bool);
115 void commandChanged(const QString& text);
116 void tabTitleFormatChanged(const QString& text);
117 void remoteTabTitleFormatChanged(const QString& text);
119 void insertTabTitleText(const QString& text);
120 void insertRemoteTabTitleText(const QString& text);
122 void showMenuBar(bool);
123 void showEnvironmentEditor();
124 void tabBarVisibilityChanged(int);
125 void tabBarPositionChanged(int);
126 void showNewTabButton(bool);
128 // appearance page
129 void setFontSize(int pointSize);
130 void setAntialiasText(bool enable);
131 void showFontDialog();
132 void newColorScheme();
133 void editColorScheme();
134 void removeColorScheme();
135 void colorSchemeSelected();
136 void previewColorScheme(const QModelIndex& index);
137 void fontSelected(const QFont&);
139 void colorSchemeAnimationUpdate();
141 // scrolling page
142 void noScrollBack();
143 void fixedScrollBack();
144 void unlimitedScrollBack();
146 void scrollBackLinesChanged(int);
148 void hideScrollBar();
149 void showScrollBarLeft();
150 void showScrollBarRight();
152 // keyboard page
153 void editKeyBinding();
154 void newKeyBinding();
155 void keyBindingSelected();
156 void removeKeyBinding();
158 // advanced page
159 void toggleBlinkingText(bool);
160 void toggleFlowControl(bool);
161 void toggleResizeWindow(bool);
162 void togglebidiRendering(bool);
163 void toggleBlinkingCursor(bool);
165 void setCursorShape(int);
166 void autoCursorColor();
167 void customCursorColor();
168 void customCursorColorChanged(const QColor&);
169 void wordCharactersChanged(const QString&);
170 void setDefaultCodec(QTextCodec*);
172 // apply the first previewed changes stored up by delayedPreview()
173 void delayedPreviewActivate();
175 private:
176 // initialize various pages of the dialog
177 void setupGeneralPage(const Profile::Ptr info);
178 void setupTabsPage(const Profile::Ptr info);
179 void setupAppearancePage(const Profile::Ptr info);
180 void setupKeyboardPage(const Profile::Ptr info);
181 void setupScrollingPage(const Profile::Ptr info);
182 void setupAdvancedPage(const Profile::Ptr info);
184 void updateColorSchemeList(bool selectCurrentScheme = false);
185 void updateColorSchemeButtons();
186 void updateKeyBindingsList(bool selectCurrentTranslator = false);
187 void updateKeyBindingsButtons();
189 void showColorSchemeEditor(bool newScheme);
190 void showKeyBindingEditor(bool newTranslator);
192 void changeCheckedItem( QAbstractItemModel* mode, const QModelIndex& to );
194 void preview(int property , const QVariant& value);
195 void delayedPreview(int property , const QVariant& value);
196 void unpreview(int property);
197 void unpreviewAll();
198 void enableIfNonEmptySelection(QWidget* widget,QItemSelectionModel* selectionModel);
200 void updateCaption(const Profile::Ptr profile);
201 void updateTransparencyWarning();
203 static QString groupProfileNames(const ProfileGroup::Ptr group, int maxLength = -1);
205 struct RadioOption
207 QAbstractButton* button;
208 int property;
209 const char* slot;
211 void setupRadio(RadioOption* possible,int actual);
212 struct ComboOption
214 QAbstractButton* button;
215 int property;
216 const char* slot;
218 void setupCombo(ComboOption* options , const Profile::Ptr profile);
220 const Profile::Ptr lookupProfile() const;
222 Ui::EditProfileDialog* _ui;
223 Profile::Ptr _tempProfile;
224 Profile::Ptr _profile;
226 // keeps track of pages which need to be updated to match the current
227 // profile. all elements in this vector are set to true when the
228 // profile is changed and individual elements are set to false
229 // after an update by a call to ensurePageLoaded()
230 QVector<bool> _pageNeedsUpdate;
231 QHash<int,QVariant> _previewedProperties;
233 QTimeLine* _colorSchemeAnimationTimeLine;
235 QHash<int,QVariant> _delayedPreviewProperties;
236 QTimer* _delayedPreviewTimer;
240 * A delegate which can display and edit color schemes in a view.
242 class ColorSchemeViewDelegate : public QAbstractItemDelegate
244 Q_OBJECT
246 public:
247 ColorSchemeViewDelegate(QObject* parent = 0);
249 // reimplemented
250 virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
251 const QModelIndex& index) const;
252 virtual QSize sizeHint( const QStyleOptionViewItem& option,
253 const QModelIndex& index) const;
255 /**
256 * Sets the timeline used to control the entry animation
257 * for this delegate.
259 * During a call to paint(), the value of the timeLine is used to
260 * determine how to render the item ( with 0 being the beginning
261 * of the animation and 1.0 being the end )
263 void setEntryTimeLine( QTimeLine* timeLine );
265 private:
266 QPointer<QTimeLine> _entryTimeLine;
272 #endif // EDITPROFILEDIALOG_H