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
20 #ifndef EDITPROFILEDIALOG_H
21 #define EDITPROFILEDIALOG_H
24 #include <QtGui/QAbstractItemDelegate>
25 #include <QtCore/QPair>
26 #include <QtCore/QHash>
27 #include <QtCore/QSet>
28 #include <QtCore/QPointer>
36 class QAbstractButton
;
37 class QItemSelectionModel
;
43 class EditProfileDialog
;
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
69 /** Constructs a new dialog with the specified parent. */
70 EditProfileDialog(QWidget
* parent
= 0);
71 virtual ~EditProfileDialog();
74 * Initialises the dialog with the settings for the specified session
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
);
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();
94 virtual void accept();
96 virtual void reject();
99 virtual bool eventFilter(QObject
* watched
, QEvent
* event
);
102 // sets up the specified tab page if necessary
103 void preparePage(int);
105 // saves changes to profile
109 void selectInitialDir();
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);
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();
143 void fixedScrollBack();
144 void unlimitedScrollBack();
146 void scrollBackLinesChanged(int);
148 void hideScrollBar();
149 void showScrollBarLeft();
150 void showScrollBarRight();
153 void editKeyBinding();
154 void newKeyBinding();
155 void keyBindingSelected();
156 void removeKeyBinding();
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();
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
);
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);
207 QAbstractButton
* button
;
211 void setupRadio(RadioOption
* possible
,int actual
);
214 QAbstractButton
* button
;
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
247 ColorSchemeViewDelegate(QObject
* parent
= 0);
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;
256 * Sets the timeline used to control the entry animation
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
);
266 QPointer
<QTimeLine
> _entryTimeLine
;
272 #endif // EDITPROFILEDIALOG_H