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 7.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
    Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>

    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 26 27
#include <QtGui/QAbstractItemDelegate>
#include <QtCore/QPair>
#include <QtCore/QHash>
#include <QtCore/QSet>
28
#include <QtCore/QPointer>
29 30 31 32

// KDE
#include <KDialog>

33
class QAbstractButton;
34
class QTextCodec;
35
class QTimeLine;
36

37 38
namespace Ui
{
39
    class EditProfileDialog;
Stephan Binner's avatar
Stephan Binner committed
40
}
41 42 43 44

namespace Konsole
{

45
class Profile;
46 47

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

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

    /**
     * Initialises the dialog with the settings for the specified session
     * type.
     *
73 74 75
     * When the dialog closes, the profile will be updated in the SessionManager
     * with the altered settings.
     *
76 77
     * @param key The key for the session type provided by the SessionManager instance
     */
78
    void setProfile(const QString& key);
79

Robert Knight's avatar
 
Robert Knight committed
80 81 82 83 84 85 86 87
    /** 
     * Selects the text in the profile name edit area. 
     * 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();
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 110 111 112
    void selectIcon();

    void profileNameChanged(const QString& text);
    void initialDirChanged(const QString& text);
    void commandChanged(const QString& text);
    void tabTitleFormatChanged(const QString& text);
    void remoteTabTitleFormatChanged(const QString& text);
113

114 115
    void insertTabTitleText(const QString& text);
    void insertRemoteTabTitleText(const QString& text);
116

117
    void showMenuBar(bool);
118
    void showEnvironmentEditor();
119 120
    void tabBarVisibilityChanged(int);
    void tabBarPositionChanged(int);
121

122
    // appearance page
123 124
    void setFontSize(int pointSize);
    void showFontDialog();
125 126 127
    void newColorScheme();
    void editColorScheme();
    void removeColorScheme();
128
    void colorSchemeSelected();
129
    void previewColorScheme(const QModelIndex& index);
130
    void fontSelected(const QFont&);
131
    //void previewFont(const QFont&);
132

133 134
    void colorSchemeAnimationUpdate();

135 136 137 138 139 140 141 142 143 144 145
    // scrolling page
    void noScrollBack();
    void fixedScrollBack();
    void unlimitedScrollBack();
   
    void scrollBackLinesChanged(int);

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

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

152 153 154 155
    // advanced page
    void toggleBlinkingText(bool);
    void toggleFlowControl(bool);
    void toggleResizeWindow(bool);
156
    void toggleBlinkingCursor(bool);
157

158 159 160 161 162
    void setCursorShape(int);
    void autoCursorColor();
    void customCursorColor();
    void customCursorColorChanged(const QColor&);
    void wordCharactersChanged(const QString&);
163
    void setDefaultCodec(QTextCodec*);
164

165 166 167
    // apply the first previewed changes stored up by delayedPreview()
    void delayedPreviewActivate();

168 169
private:
    // initialize various pages of the dialog
170
    void setupGeneralPage(const Profile* info);
171
    void setupTabsPage(const Profile* info);
172
    void setupAppearancePage(const Profile* info);
173 174 175
    void setupKeyboardPage(const Profile* info);
    void setupScrollingPage(const Profile* info);
    void setupAdvancedPage(const Profile* info);
176

177
    void updateColorSchemeList(bool selectCurrentScheme = false);
178
    void updateKeyBindingsList(bool selectCurrentTranslator = false);
179
    void updateFontPreviewLabel(const QFont& font);
180

181
    void showColorSchemeEditor(bool newScheme);
182 183 184
    void showKeyBindingEditor(bool newTranslator);

    void changeCheckedItem( QAbstractItemModel* mode,  const QModelIndex& to );
185

Robert Knight's avatar
Robert Knight committed
186
    void preview(int property , const QVariant& value);
187
    void delayedPreview(int property , const QVariant& value);
188
    void unpreview(int property);
189
    void unpreviewAll();
190

Robert Knight's avatar
 
Robert Knight committed
191 192
    void updateCaption(const QString& profileName);

Robert Knight's avatar
 
Robert Knight committed
193 194
    void updateTransparencyWarning();

Robert Knight's avatar
Robert Knight committed
195 196 197 198 199 200 201 202 203 204 205 206 207 208
    struct RadioOption
    {
       QAbstractButton* button;
       int property;
       char* slot; 
    };
    void setupRadio(RadioOption* possible,int actual);
    struct ComboOption
    {
       QAbstractButton* button;
       int property;
       char* slot;
    };
    void setupCombo(ComboOption* options , const Profile* profile);
209

210 211
    const Profile* lookupProfile() const;

212
    Ui::EditProfileDialog* _ui;
213
    Profile* _tempProfile;
214
    QString _profileKey;
215

216 217 218 219 220
    // keeps track of pages which need to be updated to match the current
    // profile.  all elements in this vector are set to true when the 
    // profile is changed and individual elements are set to false 
    // after an update by a call to ensurePageLoaded()
    QVector<bool> _pageNeedsUpdate;
221
    QHash<int,QVariant> _previewedProperties;
222
    
Robert Knight's avatar
 
Robert Knight committed
223
    QTimeLine* _colorSchemeAnimationTimeLine;
224 225 226

    QHash<int,QVariant> _delayedPreviewProperties;
    QTimer* _delayedPreviewTimer;
227 228 229 230 231 232 233
};

/**
 * A delegate which can display and edit color schemes in a view.
 */
class ColorSchemeViewDelegate : public QAbstractItemDelegate
{
234 235
Q_OBJECT

236 237 238 239 240 241 242 243 244
public:
    ColorSchemeViewDelegate(QObject* parent = 0);

    // reimplemented
    virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
                       const QModelIndex& index) const;
    virtual QSize sizeHint( const QStyleOptionViewItem& option,
                       const QModelIndex& index) const;

245 246 247 248 249 250 251 252 253 254 255 256 257
    /** 
     * 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
     * determine how to render the item ( with 0 being the beginning 
     * of the animation and 1.0 being the end )
     */
    void setEntryTimeLine( QTimeLine* timeLine );

private:
    QPointer<QTimeLine> _entryTimeLine;

258 259
};

Stephan Binner's avatar
Stephan Binner committed
260
}
261

262
#endif // EDITPROFILEDIALOG_H