EditProfileDialog.h 6.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
    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.
*/

#ifndef EDITSESSIONDIALOG_H
#define EDITSESSIONDIALOG_H

// 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 29 30 31

// KDE
#include <KDialog>

32
class QAbstractButton;
33

34 35
namespace Ui
{
36
    class EditProfileDialog;
Stephan Binner's avatar
Stephan Binner committed
37
}
38 39 40 41

namespace Konsole
{

42
class Profile;
43 44

/**
45
 * A dialog which allows the user to edit a profile.
46 47 48 49 50 51 52 53 54 55
 * 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.
56 57 58
 *
 * TODO: More documentation
 */
59
class EditProfileDialog : public KDialog
60 61 62 63 64
{
Q_OBJECT

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

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

79
public slots:
80
    // reimplemented
81
    virtual void accept();
82
    // reimplemented 
83
    virtual void reject();
84

85 86 87
protected:
    virtual bool eventFilter(QObject* watched , QEvent* event);

88
private slots:
89 90 91
    // saves changes to profile
    void save();

92 93
    // general page
    void selectInitialDir();
94 95 96 97 98 99 100
    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);
101

102 103
    void insertTabTitleText(const QString& text);
    void insertRemoteTabTitleText(const QString& text);
104

105
    void showMenuBar(bool);
106 107
    void tabBarVisibilityChanged(int);
    void tabBarPositionChanged(int);
108

109
    // appearance page
110 111
    void setFontSize(int pointSize);
    void showFontDialog();
112 113 114
    void newColorScheme();
    void editColorScheme();
    void removeColorScheme();
115
    void colorSchemeSelected();
116
    void previewColorScheme(const QModelIndex& index);
117
    void fontSelected(const QFont&);
118
    //void previewFont(const QFont&);
119

120 121 122 123 124 125 126 127 128 129 130
    // scrolling page
    void noScrollBack();
    void fixedScrollBack();
    void unlimitedScrollBack();
   
    void scrollBackLinesChanged(int);

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

131 132 133 134 135 136
    // keyboard page
    void editKeyBinding();
    void newKeyBinding();
    void keyBindingSelected();
    void removeKeyBinding();

137 138 139 140
    // advanced page
    void toggleBlinkingText(bool);
    void toggleFlowControl(bool);
    void toggleResizeWindow(bool);
141
    void toggleBlinkingCursor(bool);
142

143 144 145 146 147 148
    void setCursorShape(int);
    void autoCursorColor();
    void customCursorColor();
    void customCursorColorChanged(const QColor&);
    void wordCharactersChanged(const QString&);

149

150 151
private:
    // initialize various pages of the dialog
152
    void setupGeneralPage(const Profile* info);
153
    void setupAppearancePage(const Profile* info);
154 155 156
    void setupKeyboardPage(const Profile* info);
    void setupScrollingPage(const Profile* info);
    void setupAdvancedPage(const Profile* info);
157

158 159 160
    void updateColorSchemeList();
    void updateKeyBindingsList();

161
    void showColorSchemeEditor(bool newScheme);
162 163 164
    void showKeyBindingEditor(bool newTranslator);

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

Robert Knight's avatar
Robert Knight committed
166
    void preview(int property , const QVariant& value);
167
    void unpreview(int property);
168
    void unpreviewAll();
169

Robert Knight's avatar
Robert Knight committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183
    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);
184

185
    Ui::EditProfileDialog* _ui;
186
    Profile* _tempProfile;
187
    QString _profileKey;
188 189

    QHash<int,QVariant> _previewedProperties;
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
};

/**
 * A delegate which can display and edit color schemes in a view.
 */
class ColorSchemeViewDelegate : public QAbstractItemDelegate
{
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;

206 207
   // virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, 
   //                               const QModelIndex& index) const;
208 209
   // virtual bool editorEvent(QEvent* event,QAbstractItemModel* model,
   //                          const QStyleOptionViewItem& option, const QModelIndex& index);
210

211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
};

/**
 * A delegate which can display and edit key bindings in a view.
 */
class KeyBindingViewDelegate : public QAbstractItemDelegate
{
public:
    KeyBindingViewDelegate(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;

};

Stephan Binner's avatar
Stephan Binner committed
229
}
230 231
#endif // EDITSESSIONDIALOG_H