EditProfileDialog.h 5.82 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 24
/*
    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
#include <QAbstractItemDelegate>
25
#include <QPair>
26
#include <QHash>
27
#include <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
 *
 * TODO: More documentation
 */
49
class EditProfileDialog : public KDialog
50 51 52 53 54
{
Q_OBJECT

public:
    /** Constructs a new dialog with the specified parent. */
55 56
    EditProfileDialog(QWidget* parent = 0);
    virtual ~EditProfileDialog();
57 58 59 60 61

    /**
     * Initialises the dialog with the settings for the specified session
     * type.
     *
62 63 64
     * When the dialog closes, the profile will be updated in the SessionManager
     * with the altered settings.
     *
65 66
     * @param key The key for the session type provided by the SessionManager instance
     */
67
    void setProfile(const QString& key);
68

69 70
public slots:
    virtual void accept();
71
    virtual void reject();
72

73 74 75
protected:
    virtual bool eventFilter(QObject* watched , QEvent* event);

76
private slots:
77 78 79
    // saves changes to profile
    void save();

80 81
    // general page
    void selectInitialDir();
82 83 84 85 86 87 88
    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);
89

90 91 92
    void editTabTitle();
    void editRemoteTabTitle();

93 94 95 96 97
    void showMenuBar(bool);
    void alwaysHideTabBar();
    void alwaysShowTabBar();
    void showTabBarAsNeeded();

98 99 100
    // appearence page
    void setFontSize(int pointSize);
    void showFontDialog();
101 102 103
    void newColorScheme();
    void editColorScheme();
    void removeColorScheme();
104
    void colorSchemeSelected();
105
    void previewColorScheme(const QModelIndex& index);
106
    void fontSelected(const QFont&);
107
    //void previewFont(const QFont&);
108

109 110 111 112 113 114 115 116 117 118 119
    // scrolling page
    void noScrollBack();
    void fixedScrollBack();
    void unlimitedScrollBack();
   
    void scrollBackLinesChanged(int);

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

120 121 122 123 124 125
    // keyboard page
    void editKeyBinding();
    void newKeyBinding();
    void keyBindingSelected();
    void removeKeyBinding();

126 127 128 129
    // advanced page
    void toggleBlinkingText(bool);
    void toggleFlowControl(bool);
    void toggleResizeWindow(bool);
130
    void toggleBlinkingCursor(bool);
131

132 133 134 135 136 137
    void setCursorShape(int);
    void autoCursorColor();
    void customCursorColor();
    void customCursorColorChanged(const QColor&);
    void wordCharactersChanged(const QString&);

138

139 140
private:
    // initialize various pages of the dialog
141 142 143 144 145
    void setupGeneralPage(const Profile* info);
    void setupAppearencePage(const Profile* info);
    void setupKeyboardPage(const Profile* info);
    void setupScrollingPage(const Profile* info);
    void setupAdvancedPage(const Profile* info);
146

147 148 149
    void updateColorSchemeList();
    void updateKeyBindingsList();

150
    void showColorSchemeEditor(bool newScheme);
151 152 153
    void showKeyBindingEditor(bool newTranslator);

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

155 156
    void preview(int property , QVariant value);
    void unpreview(int property);
157
    void unpreviewAll();
158

Robert Knight's avatar
Robert Knight committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172
    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);
173

174
    Ui::EditProfileDialog* _ui;
175
    Profile* _tempProfile;
176
    QString _profileKey;
177 178

    QHash<int,QVariant> _previewedProperties;
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
};

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

195 196
   // virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, 
   //                               const QModelIndex& index) const;
197 198
   // virtual bool editorEvent(QEvent* event,QAbstractItemModel* model,
   //                          const QStyleOptionViewItem& option, const QModelIndex& index);
199

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
};

/**
 * 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
218
}
219 220
#endif // EDITSESSIONDIALOG_H