EditProfileDialog.h 6.42 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 104
    void editTabTitle();
    void editRemoteTabTitle();

105 106 107 108 109
    void showMenuBar(bool);
    void alwaysHideTabBar();
    void alwaysShowTabBar();
    void showTabBarAsNeeded();

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

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

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

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

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

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

150

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

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

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

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

167 168
    void preview(int property , QVariant value);
    void unpreview(int property);
169
    void unpreviewAll();
170

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

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

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

/**
 * 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;

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

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

/**
 * 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
230
}
231 232
#endif // EDITSESSIONDIALOG_H