Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

EditProfileDialog.h 8.54 KB
Newer Older
1
/*
2
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA.
*/

20 21
#ifndef EDITPROFILEDIALOG_H
#define EDITPROFILEDIALOG_H
22 23

// Qt
Dirk Mueller's avatar
Dirk Mueller committed
24 25
#include <QtGui/QAbstractItemDelegate>
#include <QtCore/QHash>
26
#include <QtCore/QPointer>
27 28 29 30

// KDE
#include <KDialog>

Jekyll Wu's avatar
Jekyll Wu committed
31
// Konsole
32
#include "Profile.h"
33
#include "Enumeration.h"
34

35
class QAbstractButton;
Robert Knight's avatar
 
Robert Knight committed
36
class QItemSelectionModel;
37
class QTextCodec;
38
class QTimeLine;
39

40 41
namespace Ui
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
42
class EditProfileDialog;
Stephan Binner's avatar
Stephan Binner committed
43
}
44 45 46 47

namespace Konsole
{
/**
48
 * A dialog which allows the user to edit a profile.
Jekyll Wu's avatar
Jekyll Wu committed
49
 * After the dialog is created, it can be initialized with the settings
Jekyll Wu's avatar
Jekyll Wu committed
50
 * for a profile using setProfile().  When the user makes changes to the
51
 * dialog and accepts the changes, the dialog will update the
Jekyll Wu's avatar
Jekyll Wu committed
52
 * profile in the SessionManager by calling the SessionManager's
53 54 55 56
 * changeProfile() method.
 *
 * Some changes made in the dialog are preview-only changes which cause
 * the SessionManager's changeProfile() method to be called with
57
 * the persistent argument set to false.  These changes are then
58
 * un-done when the dialog is closed.
59
 */
60
class KONSOLEPRIVATE_EXPORT EditProfileDialog : public KDialog
61
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
62
    Q_OBJECT
63 64 65

public:
    /** Constructs a new dialog with the specified parent. */
66
    explicit EditProfileDialog(QWidget* parent = 0);
67
    virtual ~EditProfileDialog();
68 69

    /**
Jekyll Wu's avatar
Jekyll Wu committed
70
     * Initializes the dialog with the settings for the specified session
71 72
     * type.
     *
73 74 75
     * When the dialog closes, the profile will be updated in the SessionManager
     * with the altered settings.
     *
76
     * @param profile The profile to be edited
77
     */
78
    void setProfile(Profile::Ptr profile);
79

Jekyll Wu's avatar
Jekyll Wu committed
80 81
    /**
     * Selects the text in the profile name edit area.
Robert Knight's avatar
 
Robert Knight committed
82 83 84 85 86 87
     * When the dialog is being used to create a new profile,
     * this can be used to draw the user's attention to the profile name
     * and make it easy for them to change it.
     */
    void selectProfileName();

88
public slots:
89
    // reimplemented
90
    virtual void accept();
Jekyll Wu's avatar
Jekyll Wu committed
91
    // reimplemented
92
    virtual void reject();
93

94 95 96
protected:
    virtual bool eventFilter(QObject* watched , QEvent* event);

97
private slots:
98
    // sets up the specified tab page if necessary
Robert Knight's avatar
 
Robert Knight committed
99
    void preparePage(int);
100

101 102 103
    // saves changes to profile
    void save();

104 105
    // general page
    void selectInitialDir();
106 107 108 109
    void selectIcon();

    void profileNameChanged(const QString& text);
    void initialDirChanged(const QString& text);
110
    void startInSameDir(bool);
111 112 113
    void commandChanged(const QString& text);
    void tabTitleFormatChanged(const QString& text);
    void remoteTabTitleFormatChanged(const QString& text);
114

115
    void showTerminalSizeHint(bool);
116
    void saveGeometryOnExit(bool);
117
    void showEnvironmentEditor();
118
    void silenceSecondsChanged(int);
119

120
    // appearance page
121
    void setFontSize(int pointSize);
122 123
    void setFontSliderRange(const QFont&);
    void setFontSliderValue(const QFont&);
124
    void setAntialiasText(bool enable);
125
    void setBoldIntense(bool enable);
126
    void showFontDialog();
127 128 129
    void newColorScheme();
    void editColorScheme();
    void removeColorScheme();
130
    void colorSchemeSelected();
131
    void previewColorScheme(const QModelIndex& index);
132
    void fontSelected(const QFont&);
133

134 135
    void colorSchemeAnimationUpdate();

136
    // scrolling page
137
    void historyModeChanged(Enum::HistoryModeEnum mode);
138

139
    void historySizeChanged(int);
140 141 142 143 144

    void hideScrollBar();
    void showScrollBarLeft();
    void showScrollBarRight();

145 146 147 148 149 150
    // keyboard page
    void editKeyBinding();
    void newKeyBinding();
    void keyBindingSelected();
    void removeKeyBinding();

151 152
    // mouse page
    void toggleUnderlineLinks(bool);
153
    void toggleCtrlRequiredForDrag(bool);
154 155 156 157 158 159 160
    void toggleCopyTextToClipboard(bool);
    void pasteFromX11Selection();
    void pasteFromClipboard();

    void TripleClickModeChanged(int);
    void wordCharactersChanged(const QString&);

161 162 163
    // advanced page
    void toggleBlinkingText(bool);
    void toggleFlowControl(bool);
164
    void togglebidiRendering(bool);
165
    void lineSpacingChanged(int);
166
    void toggleBlinkingCursor(bool);
167

168 169 170 171
    void setCursorShape(int);
    void autoCursorColor();
    void customCursorColor();
    void customCursorColorChanged(const QColor&);
172
    void setDefaultCodec(QTextCodec*);
173

174 175 176
    // apply the first previewed changes stored up by delayedPreview()
    void delayedPreviewActivate();

177 178
private:
    // initialize various pages of the dialog
Jekyll Wu's avatar
Jekyll Wu committed
179 180 181 182 183 184
    void setupGeneralPage(const Profile::Ptr profile);
    void setupTabsPage(const Profile::Ptr profile);
    void setupAppearancePage(const Profile::Ptr profile);
    void setupKeyboardPage(const Profile::Ptr profile);
    void setupScrollingPage(const Profile::Ptr profile);
    void setupAdvancedPage(const Profile::Ptr profile);
185
    void setupMousePage(const Profile::Ptr info);
186

187
    void updateColorSchemeList(bool selectCurrentScheme = false);
Robert Knight's avatar
 
Robert Knight committed
188
    void updateColorSchemeButtons();
189
    void updateKeyBindingsList(bool selectCurrentTranslator = false);
Robert Knight's avatar
 
Robert Knight committed
190
    void updateKeyBindingsButtons();
191

192
    void showColorSchemeEditor(bool newScheme);
193 194
    void showKeyBindingEditor(bool newTranslator);

Robert Knight's avatar
Robert Knight committed
195
    void preview(int property , const QVariant& value);
196
    void delayedPreview(int property , const QVariant& value);
197
    void unpreview(int property);
198
    void unpreviewAll();
Kurt Hindenburg's avatar
Kurt Hindenburg committed
199
    void enableIfNonEmptySelection(QWidget* widget, QItemSelectionModel* selectionModel);
200

201
    void updateCaption(const Profile::Ptr profile);
Robert Knight's avatar
 
Robert Knight committed
202 203
    void updateTransparencyWarning();

204 205 206 207 208
    // Update _tempProfile in a way of respecting the apply button.
    // When used with some previewed property, this method should
    // always come after the preview operation.
    void updateTempProfileProperty(Profile::Property, const QVariant& value);

209 210 211 212
    // helper method for creating an empty & hidden profile and assigning
    // it to _tempProfile.
    void createTempProfile();

Jekyll Wu's avatar
Jekyll Wu committed
213
    // Enable or disable apply button, used only within
214 215 216
    // updateTempProfileProperty().
    void updateButtonApply();

217 218
    static QString groupProfileNames(const ProfileGroup::Ptr group, int maxLength = -1);

Kurt Hindenburg's avatar
Kurt Hindenburg committed
219 220 221 222
    struct RadioOption {
        QAbstractButton* button;
        int value;
        const char* slot;
Robert Knight's avatar
Robert Knight committed
223
    };
224
    void setupRadio(RadioOption* possibilities, int actual);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
225 226 227 228
    struct BooleanOption {
        QAbstractButton* button;
        Profile::Property property;
        const char* slot;
Robert Knight's avatar
Robert Knight committed
229
    };
230
    void setupCheckBoxes(BooleanOption* options , const Profile::Ptr profile);
231

232
    const Profile::Ptr lookupProfile() const;
233

234
    Ui::EditProfileDialog* _ui;
235
    Profile::Ptr _tempProfile;
236
    Profile::Ptr _profile;
237

238
    // keeps track of pages which need to be updated to match the current
Jekyll Wu's avatar
Jekyll Wu committed
239 240
    // profile.  all elements in this vector are set to true when the
    // profile is changed and individual elements are set to false
241 242
    // after an update by a call to ensurePageLoaded()
    QVector<bool> _pageNeedsUpdate;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
243
    QHash<int, QVariant> _previewedProperties;
244

Robert Knight's avatar
 
Robert Knight committed
245
    QTimeLine* _colorSchemeAnimationTimeLine;
246

Kurt Hindenburg's avatar
Kurt Hindenburg committed
247
    QHash<int, QVariant> _delayedPreviewProperties;
248
    QTimer* _delayedPreviewTimer;
249 250 251 252 253 254 255
};

/**
 * A delegate which can display and edit color schemes in a view.
 */
class ColorSchemeViewDelegate : public QAbstractItemDelegate
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
256
    Q_OBJECT
257

258
public:
259
    explicit ColorSchemeViewDelegate(QObject* parent = 0);
260 261 262 263

    // reimplemented
    virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
                       const QModelIndex& index) const;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
264 265
    virtual QSize sizeHint(const QStyleOptionViewItem& option,
                           const QModelIndex& index) const;
266

Jekyll Wu's avatar
Jekyll Wu committed
267
    /**
268 269 270 271
     * Sets the timeline used to control the entry animation
     * for this delegate.
     *
     * During a call to paint(), the value of the timeLine is used to
Jekyll Wu's avatar
Jekyll Wu committed
272
     * determine how to render the item ( with 0 being the beginning
273 274
     * of the animation and 1.0 being the end )
     */
Kurt Hindenburg's avatar
Kurt Hindenburg committed
275
    void setEntryTimeLine(QTimeLine* timeLine);
276 277 278

private:
    QPointer<QTimeLine> _entryTimeLine;
279
};
Stephan Binner's avatar
Stephan Binner committed
280
}
281

282
#endif // EDITPROFILEDIALOG_H