~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/EditProfileDialog.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <cmath>
25
25
 
26
26
// Qt
27
 
#include <QtGui/QKeyEvent>
28
27
#include <QtGui/QBrush>
29
28
#include <QtGui/QPainter>
30
29
#include <QtGui/QStandardItem>
36
35
 
37
36
// KDE
38
37
#include <kcodecaction.h>
39
 
#include <KDebug>
40
38
#include <KFontDialog>
41
39
#include <KIcon>
42
40
#include <KIconDialog>
48
46
 
49
47
// Konsole
50
48
#include "ColorScheme.h"
 
49
#include "ColorSchemeManager.h"
51
50
#include "ColorSchemeEditor.h"
52
51
#include "ui_EditProfileDialog.h"
53
52
#include "KeyBindingEditor.h"
54
53
#include "KeyboardTranslator.h"
55
 
#include "SessionManager.h"
 
54
#include "KeyboardTranslatorManager.h"
 
55
#include "ProfileManager.h"
56
56
#include "ShellCommand.h"
57
 
#include "TabTitleFormatAction.h"
58
 
 
59
 
// FIXME: it feels bad to include a big header file just
60
 
// in order to use one of its static members.
61
 
#include "TerminalDisplay.h"
 
57
#include "WindowSystemInfo.h"
 
58
#include "Enumeration.h"
62
59
 
63
60
using namespace Konsole;
64
61
 
65
 
EditProfileDialog::EditProfileDialog(QWidget* parent)
66
 
    : KDialog(parent)
 
62
EditProfileDialog::EditProfileDialog(QWidget* aParent)
 
63
    : KDialog(aParent)
67
64
    , _colorSchemeAnimationTimeLine(0)
68
65
    , _delayedPreviewTimer(new QTimer(this))
69
66
{
70
67
    setCaption(i18n("Edit Profile"));
71
 
    setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );
 
68
    setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
72
69
 
73
70
    // disable the apply button , since no modification has been made
74
71
    enableButtonApply(false);
75
72
 
76
 
    connect( this , SIGNAL(applyClicked()) , this , SLOT(save()) );
 
73
    connect(this, SIGNAL(applyClicked()), this, SLOT(save()));
77
74
 
78
 
    connect( _delayedPreviewTimer , SIGNAL(timeout()) , this , SLOT(delayedPreviewActivate()) );
 
75
    connect(_delayedPreviewTimer, SIGNAL(timeout()), this, SLOT(delayedPreviewActivate()));
79
76
 
80
77
    _ui = new Ui::EditProfileDialog();
81
78
    _ui->setupUi(mainWidget());
82
79
 
83
 
    // TODO: Re-enable in a later KDE 4.x release when this feature works again
84
 
    _ui->enableResizeWindowButton->setVisible(false);
85
 
 
86
80
    // there are various setupXYZPage() methods to load the items
87
81
    // for each page and update their states to match the profile
88
82
    // being edited.
93
87
    // the _pageNeedsUpdate vector keeps track of the pages that have
94
88
    // not been updated since the last profile change and will need
95
89
    // to be refreshed when the user switches to them
96
 
    _pageNeedsUpdate.resize( _ui->tabWidget->count() );
97
 
    connect( _ui->tabWidget , SIGNAL(currentChanged(int)) , this , 
98
 
            SLOT(preparePage(int)) );
 
90
    _pageNeedsUpdate.resize(_ui->tabWidget->count());
 
91
    connect(_ui->tabWidget, SIGNAL(currentChanged(int)), this,
 
92
            SLOT(preparePage(int)));
99
93
 
100
94
    createTempProfile();
101
95
}
105
99
}
106
100
void EditProfileDialog::save()
107
101
{
108
 
    if ( _tempProfile->isEmpty() )
 
102
    if (_tempProfile->isEmpty())
109
103
        return;
110
104
 
111
 
    SessionManager::instance()->changeProfile(_profile,_tempProfile->setProperties());
 
105
    ProfileManager::instance()->changeProfile(_profile, _tempProfile->setProperties());
112
106
 
113
107
    // ensure that these settings are not undone by a call
114
108
    // to unpreview()
115
 
    QHashIterator<Profile::Property,QVariant> iter(_tempProfile->setProperties());
116
 
    while ( iter.hasNext() )
117
 
    {
 
109
    QHashIterator<Profile::Property, QVariant> iter(_tempProfile->setProperties());
 
110
    while (iter.hasNext()) {
118
111
        iter.next();
119
112
        _previewedProperties.remove(iter.key());
120
113
    }
130
123
}
131
124
void EditProfileDialog::accept()
132
125
{
133
 
    Q_ASSERT( _profile );
134
 
    Q_ASSERT( _tempProfile );
 
126
    Q_ASSERT(_profile);
 
127
    Q_ASSERT(_tempProfile);
135
128
 
136
 
    if (   ( _tempProfile->isPropertySet(Profile::Name) &&
137
 
             _tempProfile->name().isEmpty() )
138
 
        || ( _profile->name().isEmpty() && _tempProfile->name().isEmpty() ) )
139
 
    {
 
129
    if ((_tempProfile->isPropertySet(Profile::Name) &&
 
130
            _tempProfile->name().isEmpty())
 
131
            || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) {
140
132
        KMessageBox::sorry(this,
141
 
                i18n("<p>Each profile must have a name before it can be saved "
142
 
                     "into disk.</p>"));
 
133
                           i18n("<p>Each profile must have a name before it can be saved "
 
134
                                "into disk.</p>"));
143
135
        return;
144
136
    }
145
137
    save();
146
138
    unpreviewAll();
147
 
    KDialog::accept(); 
 
139
    KDialog::accept();
148
140
}
149
141
QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr group, int maxLength)
150
142
{
151
143
    QString caption;
152
144
    int count = group->profiles().count();
153
 
    for (int i=0;i < count;i++)
154
 
    {
 
145
    for (int i = 0; i < count; i++) {
155
146
        caption += group->profiles()[i]->name();
156
 
        if (i < (count-1)) 
157
 
        {
 
147
        if (i < (count - 1)) {
158
148
            caption += ',';
159
149
            // limit caption length to prevent very long window titles
160
 
            if (maxLength > 0 && caption.length() > maxLength)
161
 
            {
 
150
            if (maxLength > 0 && caption.length() > maxLength) {
162
151
                caption += "...";
163
152
                break;
164
153
            }
169
158
void EditProfileDialog::updateCaption(const Profile::Ptr profile)
170
159
{
171
160
    const int MAX_GROUP_CAPTION_LENGTH = 25;
172
 
    ProfileGroup::Ptr group = profile->asGroup(); 
173
 
    if ( group && group->profiles().count() > 1 )
174
 
    {
175
 
        QString caption = groupProfileNames(group,MAX_GROUP_CAPTION_LENGTH); 
176
 
        setCaption( i18np( "Editing profile: %2",
177
 
                           "Editing %1 profiles: %2",
178
 
                           group->profiles().count(),
179
 
                           caption ) );
180
 
    }
181
 
    else
182
 
    {
183
 
        setCaption( i18n("Edit Profile \"%1\"",profile->name()) );
 
161
    ProfileGroup::Ptr group = profile->asGroup();
 
162
    if (group && group->profiles().count() > 1) {
 
163
        QString caption = groupProfileNames(group, MAX_GROUP_CAPTION_LENGTH);
 
164
        setCaption(i18np("Editing profile: %2",
 
165
                         "Editing %1 profiles: %2",
 
166
                         group->profiles().count(),
 
167
                         caption));
 
168
    } else {
 
169
        setCaption(i18n("Edit Profile \"%1\"", profile->name()));
184
170
    }
185
171
}
186
172
void EditProfileDialog::setProfile(Profile::Ptr profile)
187
173
{
188
 
    Q_ASSERT( profile );
 
174
    Q_ASSERT(profile);
189
175
 
190
176
    _profile = profile;
191
177
 
197
183
    //
198
184
    // the other pages will be updated as necessary
199
185
    _pageNeedsUpdate.fill(true);
200
 
    preparePage( _ui->tabWidget->currentIndex() );
 
186
    preparePage(_ui->tabWidget->currentIndex());
201
187
 
202
 
    if ( _tempProfile )
203
 
    {
 
188
    if (_tempProfile) {
204
189
        createTempProfile();
205
190
    }
206
191
}
207
192
const Profile::Ptr EditProfileDialog::lookupProfile() const
208
193
{
209
 
    return _profile; 
 
194
    return _profile;
210
195
}
211
196
void EditProfileDialog::preparePage(int page)
212
197
{
213
 
    const Profile::Ptr info = lookupProfile();
 
198
    const Profile::Ptr profile = lookupProfile();
214
199
 
215
 
    Q_ASSERT( _pageNeedsUpdate.count() > page );
216
 
    Q_ASSERT( info );
 
200
    Q_ASSERT(_pageNeedsUpdate.count() > page);
 
201
    Q_ASSERT(profile);
217
202
 
218
203
    QWidget* pageWidget = _ui->tabWidget->widget(page);
219
204
 
220
 
    if ( _pageNeedsUpdate[page] )
221
 
    {
222
 
       if ( pageWidget == _ui->generalTab )
223
 
            setupGeneralPage(info);
224
 
       else if ( pageWidget == _ui->tabsTab )
225
 
            setupTabsPage(info);
226
 
       else if ( pageWidget == _ui->appearanceTab )
227
 
            setupAppearancePage(info);
228
 
       else if ( pageWidget == _ui->scrollingTab )
229
 
            setupScrollingPage(info);
230
 
       else if ( pageWidget == _ui->keyboardTab )
231
 
            setupKeyboardPage(info);
232
 
       else if ( pageWidget == _ui->advancedTab )
233
 
            setupAdvancedPage(info);
234
 
       else
235
 
           Q_ASSERT(false);
 
205
    if (_pageNeedsUpdate[page]) {
 
206
        if (pageWidget == _ui->generalTab)
 
207
            setupGeneralPage(profile);
 
208
        else if (pageWidget == _ui->tabsTab)
 
209
            setupTabsPage(profile);
 
210
        else if (pageWidget == _ui->appearanceTab)
 
211
            setupAppearancePage(profile);
 
212
        else if (pageWidget == _ui->scrollingTab)
 
213
            setupScrollingPage(profile);
 
214
        else if (pageWidget == _ui->keyboardTab)
 
215
            setupKeyboardPage(profile);
 
216
        else if (pageWidget == _ui->mouseTab)
 
217
            setupMousePage(profile);
 
218
        else if (pageWidget == _ui->advancedTab)
 
219
            setupAdvancedPage(profile);
 
220
        else
 
221
            Q_ASSERT(false);
236
222
 
237
223
        _pageNeedsUpdate[page] = false;
238
224
    }
239
225
 
240
226
    // start page entry animation for color schemes
241
 
    if ( pageWidget == _ui->appearanceTab )
242
 
            _colorSchemeAnimationTimeLine->start();
 
227
    if (pageWidget == _ui->appearanceTab)
 
228
        _colorSchemeAnimationTimeLine->start();
243
229
}
244
230
void EditProfileDialog::selectProfileName()
245
231
{
246
232
    _ui->profileNameEdit->setFocus();
247
233
    _ui->profileNameEdit->selectAll();
248
234
}
249
 
void EditProfileDialog::setupGeneralPage(const Profile::Ptr info)
 
235
void EditProfileDialog::setupGeneralPage(const Profile::Ptr profile)
250
236
{
251
237
    // basic profile options
252
238
    {
253
 
        ProfileGroup::Ptr group = info->asGroup(); 
254
 
        if ( !group || group->profiles().count() < 2)
255
 
        {
256
 
            _ui->profileNameEdit->setText( info->name() );
 
239
        _ui->emptyNameWarningWidget->setWordWrap(false);
 
240
        _ui->emptyNameWarningWidget->setCloseButtonVisible(false);
 
241
        _ui->emptyNameWarningWidget->setMessageType(KMessageWidget::Warning);
 
242
 
 
243
        ProfileGroup::Ptr group = profile->asGroup();
 
244
        if (!group || group->profiles().count() < 2) {
 
245
            _ui->profileNameEdit->setText(profile->name());
257
246
            _ui->profileNameEdit->setClearButtonShown(true);
258
247
 
259
 
            _ui->emptyNameWarningWidget->setVisible( info->name().isEmpty() );
 
248
            _ui->emptyNameWarningWidget->setVisible(profile->name().isEmpty());
260
249
            _ui->emptyNameWarningWidget->setText(i18n("Profile name is empty."));
261
 
        }
262
 
        else 
263
 
        {
264
 
            _ui->profileNameEdit->setText( groupProfileNames(group,-1) );
 
250
        } else {
 
251
            _ui->profileNameEdit->setText(groupProfileNames(group, -1));
265
252
            _ui->profileNameEdit->setEnabled(false);
266
253
            _ui->profileNameLabel->setEnabled(false);
267
254
 
269
256
        }
270
257
    }
271
258
 
272
 
 
273
 
    ShellCommand command( info->command() , info->arguments() );
274
 
    _ui->commandEdit->setText( command.fullCommand() );
 
259
    ShellCommand command(profile->command() , profile->arguments());
 
260
    _ui->commandEdit->setText(command.fullCommand());
275
261
    KUrlCompletion* exeCompletion = new KUrlCompletion(KUrlCompletion::ExeCompletion);
276
262
    exeCompletion->setParent(this);
277
263
    exeCompletion->setDir(QString());
278
 
    _ui->commandEdit->setCompletionObject( exeCompletion );
 
264
    _ui->commandEdit->setCompletionObject(exeCompletion);
279
265
 
280
 
    _ui->initialDirEdit->setText( info->defaultWorkingDirectory() );
 
266
    _ui->initialDirEdit->setText(profile->defaultWorkingDirectory());
281
267
    KUrlCompletion* dirCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion);
282
268
    dirCompletion->setParent(this);
283
 
    _ui->initialDirEdit->setCompletionObject( dirCompletion );
 
269
    _ui->initialDirEdit->setCompletionObject(dirCompletion);
284
270
    _ui->initialDirEdit->setClearButtonShown(true);
285
271
 
286
 
    _ui->dirSelectButton->setIcon( KIcon("folder-open") );
287
 
    _ui->iconSelectButton->setIcon( KIcon(info->icon()) );
288
 
    _ui->startInSameDirButton->setChecked(info->property<bool>(Profile::StartInCurrentSessionDir));
 
272
    _ui->dirSelectButton->setIcon(KIcon("folder-open"));
 
273
    _ui->iconSelectButton->setIcon(KIcon(profile->icon()));
 
274
    _ui->startInSameDirButton->setChecked(profile->startInCurrentSessionDir());
289
275
 
290
276
    // window options
291
 
    _ui->showMenuBarButton->setChecked( info->property<bool>(Profile::ShowMenuBar) );
292
 
    _ui->showTerminalSizeHintButton->setChecked( info->property<bool>(Profile::ShowTerminalSizeHint) );
293
 
    _ui->saveGeometryOnExitButton->setChecked( info->property<bool>(Profile::SaveGeometryOnExit) );
 
277
    _ui->showTerminalSizeHintButton->setChecked(profile->showTerminalSizeHint());
 
278
    _ui->saveGeometryOnExitButton->setChecked(profile->saveGeometryOnExit());
294
279
 
295
280
    // signals and slots
296
 
    connect( _ui->dirSelectButton , SIGNAL(clicked()) , this , SLOT(selectInitialDir()) );
297
 
    connect( _ui->iconSelectButton , SIGNAL(clicked()) , this , SLOT(selectIcon()) );
298
 
    connect( _ui->startInSameDirButton , SIGNAL(toggled(bool)) , this , 
 
281
    connect(_ui->dirSelectButton, SIGNAL(clicked()), this, SLOT(selectInitialDir()));
 
282
    connect(_ui->iconSelectButton, SIGNAL(clicked()), this, SLOT(selectIcon()));
 
283
    connect(_ui->startInSameDirButton, SIGNAL(toggled(bool)), this ,
299
284
            SLOT(startInSameDir(bool)));
300
 
    connect( _ui->profileNameEdit , SIGNAL(textChanged(QString)) , this ,
301
 
            SLOT(profileNameChanged(QString)) );
302
 
    connect( _ui->initialDirEdit , SIGNAL(textChanged(QString)) , this , 
303
 
            SLOT(initialDirChanged(QString)) );
304
 
    connect(_ui->commandEdit , SIGNAL(textChanged(QString)) , this ,
305
 
            SLOT(commandChanged(QString)) ); 
306
 
    connect(_ui->environmentEditButton , SIGNAL(clicked()) , this , 
307
 
            SLOT(showEnvironmentEditor()) );
 
285
    connect(_ui->profileNameEdit, SIGNAL(textChanged(QString)), this,
 
286
            SLOT(profileNameChanged(QString)));
 
287
    connect(_ui->initialDirEdit, SIGNAL(textChanged(QString)), this,
 
288
            SLOT(initialDirChanged(QString)));
 
289
    connect(_ui->commandEdit, SIGNAL(textChanged(QString)), this,
 
290
            SLOT(commandChanged(QString)));
 
291
    connect(_ui->environmentEditButton , SIGNAL(clicked()), this,
 
292
            SLOT(showEnvironmentEditor()));
308
293
 
309
 
    connect(_ui->showMenuBarButton , SIGNAL(toggled(bool)) , this , 
310
 
            SLOT(showMenuBar(bool)) );
311
 
    connect(_ui->saveGeometryOnExitButton , SIGNAL(toggled(bool)) , this ,
312
 
            SLOT(saveGeometryOnExit(bool)) );
313
 
    connect(_ui->showTerminalSizeHintButton , SIGNAL(toggled(bool)) , this ,
314
 
            SLOT(showTerminalSizeHint(bool)) );
 
294
    connect(_ui->saveGeometryOnExitButton, SIGNAL(toggled(bool)), this,
 
295
            SLOT(saveGeometryOnExit(bool)));
 
296
    connect(_ui->showTerminalSizeHintButton, SIGNAL(toggled(bool)), this,
 
297
            SLOT(showTerminalSizeHint(bool)));
315
298
}
316
299
void EditProfileDialog::showEnvironmentEditor()
317
300
{
318
 
    const Profile::Ptr info = lookupProfile();
319
 
 
320
 
    KDialog* dialog = new KDialog(this);
321
 
    KTextEdit* edit = new KTextEdit(dialog);
322
 
 
323
 
    QStringList currentEnvironment = info->property<QStringList>(Profile::Environment);
324
 
 
325
 
    edit->setPlainText( currentEnvironment.join("\n") );
326
 
    edit->setToolTip( i18n("One environment variable per line" ) );
327
 
 
328
 
    dialog->setPlainCaption(i18n("Edit Environment"));
329
 
    dialog->setMainWidget(edit);
330
 
 
331
 
    if ( dialog->exec() == QDialog::Accepted )
332
 
    {
 
301
    const Profile::Ptr profile = lookupProfile();
 
302
 
 
303
    QWeakPointer<KDialog> dialog = new KDialog(this);
 
304
    KTextEdit* edit = new KTextEdit(dialog.data());
 
305
 
 
306
    QStringList currentEnvironment = profile->environment();
 
307
 
 
308
    edit->setPlainText(currentEnvironment.join("\n"));
 
309
    edit->setToolTip(i18n("One environment variable per line"));
 
310
 
 
311
    dialog.data()->setPlainCaption(i18n("Edit Environment"));
 
312
    dialog.data()->setMainWidget(edit);
 
313
 
 
314
    if (dialog.data()->exec() == QDialog::Accepted) {
333
315
        QStringList newEnvironment = edit->toPlainText().split('\n');
334
 
        updateTempProfileProperty(Profile::Environment,newEnvironment);
 
316
        updateTempProfileProperty(Profile::Environment, newEnvironment);
335
317
    }
336
318
 
337
 
    dialog->deleteLater();
 
319
    delete dialog.data();
338
320
}
339
 
void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
 
321
void EditProfileDialog::setupTabsPage(const Profile::Ptr profile)
340
322
{
341
323
    // tab title format
342
 
    _ui->tabTitleEdit->setClearButtonShown(true);
343
 
    _ui->remoteTabTitleEdit->setClearButtonShown(true);
344
 
    _ui->tabTitleEdit->setText( info->property<QString>(Profile::LocalTabTitleFormat) );
345
 
    _ui->remoteTabTitleEdit->setText( 
346
 
            info->property<QString>(Profile::RemoteTabTitleFormat));
347
 
 
348
 
    // tab bar options
349
 
    int tabBarMode = info->property<int>(Profile::TabBarMode);
350
 
    int tabBarPosition = info->property<int>(Profile::TabBarPosition);
351
 
    int newTabBehavior = info->property<int>(Profile::NewTabBehavior);
352
 
 
353
 
    // note: Items should be in the same order as the 
354
 
    // Profile::TabBarModeEnum enum
355
 
    _ui->tabBarVisibilityCombo->addItems( QStringList() << i18n("Always Hide Tab Bar")
356
 
                                                        << i18n("Show Tab Bar When Needed") 
357
 
                                                        << i18n("Always Show Tab Bar") );
358
 
    _ui->tabBarVisibilityCombo->setCurrentIndex(tabBarMode);
359
 
 
360
 
    // note: Items should be in the same order as the
361
 
    // Profile::TabBarPositionEnum enum
362
 
    _ui->tabBarPositionCombo->addItems( QStringList() << i18n("Below Terminal Displays")
363
 
                                                      << i18n("Above Terminal Displays") );
364
 
    _ui->tabBarPositionCombo->setCurrentIndex(tabBarPosition);
365
 
 
366
 
    // note: Items should be in the same order as the
367
 
    // Profile::NewTabBehaviorEnum enum
368
 
    _ui->newTabBehaviorCombo->addItems( QStringList() << i18n("Put New Tab At The End")
369
 
                                                      << i18n("Put New Tab After Current Tab") );
370
 
    _ui->newTabBehaviorCombo->setCurrentIndex(newTabBehavior);
371
 
 
372
 
    _ui->newTabButton->setChecked(info->property<bool>(Profile::ShowNewAndCloseTabButtons));
 
324
    _ui->renameTabWidget->setTabTitleText(profile->localTabTitleFormat());
 
325
    _ui->renameTabWidget->setRemoteTabTitleText(profile->remoteTabTitleFormat());
 
326
 
 
327
    connect(_ui->renameTabWidget, SIGNAL(tabTitleFormatChanged(QString)), this,
 
328
            SLOT(tabTitleFormatChanged(QString)));
 
329
    connect(_ui->renameTabWidget, SIGNAL(remoteTabTitleFormatChanged(QString)), this,
 
330
            SLOT(remoteTabTitleFormatChanged(QString)));
373
331
 
374
332
    // tab monitoring
375
 
    int silenceSeconds = info->property<int>(Profile::SilenceSeconds);
 
333
    const int silenceSeconds = profile->silenceSeconds();
376
334
    _ui->silenceSecondsSpinner->setValue(silenceSeconds);
377
 
 
378
 
    // signals and slots
379
 
    connect( _ui->tabBarVisibilityCombo , SIGNAL(activated(int)) , this , 
380
 
             SLOT(tabBarVisibilityChanged(int)) );
381
 
    connect( _ui->tabBarPositionCombo , SIGNAL(activated(int)) , this ,
382
 
             SLOT(tabBarPositionChanged(int)) );
383
 
    connect( _ui->newTabBehaviorCombo , SIGNAL(activated(int)) , this ,
384
 
             SLOT(newTabBehaviorChanged(int)) );
385
 
    connect( _ui->newTabButton , SIGNAL(toggled(bool)) , this ,
386
 
             SLOT(showNewTabButton(bool)) );
387
 
 
388
 
    connect(_ui->tabTitleEdit , SIGNAL(textChanged(QString)) , this ,
389
 
            SLOT(tabTitleFormatChanged(QString)) );
390
 
    connect(_ui->remoteTabTitleEdit , SIGNAL(textChanged(QString)) , this ,
391
 
            SLOT(remoteTabTitleFormatChanged(QString)));
392
 
 
393
 
    connect( _ui->silenceSecondsSpinner , SIGNAL(valueChanged(int)) ,
394
 
             this , SLOT(silenceSecondsChanged(int)) );
395
 
 
396
 
    // menus for local and remote tab title dynamic elements
397
 
    TabTitleFormatAction* localTabTitleAction = new TabTitleFormatAction(this);
398
 
    localTabTitleAction->setContext(Session::LocalTabTitle);
399
 
    _ui->tabTitleEditButton->setMenu(localTabTitleAction->menu());
400
 
    connect( localTabTitleAction , SIGNAL(dynamicElementSelected(QString)) , 
401
 
            this , SLOT(insertTabTitleText(QString)) );
402
 
 
403
 
    TabTitleFormatAction* remoteTabTitleAction = new TabTitleFormatAction(this);
404
 
    remoteTabTitleAction->setContext(Session::RemoteTabTitle);
405
 
    _ui->remoteTabTitleEditButton->setMenu(remoteTabTitleAction->menu());
406
 
    connect( remoteTabTitleAction , SIGNAL(dynamicElementSelected(QString)) ,
407
 
           this , SLOT(insertRemoteTabTitleText(QString)) ); 
408
 
}
409
 
void EditProfileDialog::showNewTabButton(bool show)
410
 
{
411
 
    updateTempProfileProperty(Profile::ShowNewAndCloseTabButtons,show);
412
 
}
413
 
void EditProfileDialog::tabBarVisibilityChanged(int newValue)
414
 
{
415
 
    updateTempProfileProperty( Profile::TabBarMode , newValue );
416
 
}
417
 
void EditProfileDialog::tabBarPositionChanged(int newValue)
418
 
{
419
 
    updateTempProfileProperty( Profile::TabBarPosition , newValue );
420
 
}
421
 
void EditProfileDialog::newTabBehaviorChanged(int newValue)
422
 
{
423
 
    updateTempProfileProperty( Profile::NewTabBehavior , newValue );
424
 
}
425
 
void EditProfileDialog::insertTabTitleText(const QString& text)
426
 
{
427
 
    _ui->tabTitleEdit->insert(text);
428
 
}
429
 
void EditProfileDialog::insertRemoteTabTitleText(const QString& text)
430
 
{
431
 
    _ui->remoteTabTitleEdit->insert(text);
432
 
}
433
 
void EditProfileDialog::showMenuBar(bool show)
434
 
{
435
 
    updateTempProfileProperty(Profile::ShowMenuBar,show);
436
 
}
437
 
void EditProfileDialog::saveGeometryOnExit(bool save)
438
 
{
439
 
    updateTempProfileProperty(Profile::SaveGeometryOnExit,save);
440
 
}
441
 
void EditProfileDialog::showTerminalSizeHint(bool show)
442
 
{
443
 
    updateTempProfileProperty(Profile::ShowTerminalSizeHint,show);
 
335
    _ui->silenceSecondsSpinner->setSuffix(ki18ncp("Unit of time", " second", " seconds"));
 
336
 
 
337
    connect(_ui->silenceSecondsSpinner, SIGNAL(valueChanged(int)),
 
338
            this, SLOT(silenceSecondsChanged(int)));
 
339
}
 
340
 
 
341
void EditProfileDialog::saveGeometryOnExit(bool value)
 
342
{
 
343
    updateTempProfileProperty(Profile::SaveGeometryOnExit, value);
 
344
}
 
345
void EditProfileDialog::showTerminalSizeHint(bool value)
 
346
{
 
347
    updateTempProfileProperty(Profile::ShowTerminalSizeHint, value);
444
348
}
445
349
void EditProfileDialog::tabTitleFormatChanged(const QString& format)
446
350
{
447
 
    updateTempProfileProperty(Profile::LocalTabTitleFormat,format);
 
351
    updateTempProfileProperty(Profile::LocalTabTitleFormat, format);
448
352
}
449
353
void EditProfileDialog::remoteTabTitleFormatChanged(const QString& format)
450
354
{
451
 
    updateTempProfileProperty(Profile::RemoteTabTitleFormat,format);
 
355
    updateTempProfileProperty(Profile::RemoteTabTitleFormat, format);
452
356
}
453
357
 
454
358
void EditProfileDialog::silenceSecondsChanged(int seconds)
459
363
void EditProfileDialog::selectIcon()
460
364
{
461
365
    const QString& icon = KIconDialog::getIcon(KIconLoader::Desktop, KIconLoader::Application,
462
 
                                               false, 0, false, this);
463
 
    if (!icon.isEmpty())
464
 
    {
465
 
        _ui->iconSelectButton->setIcon( KIcon(icon) );
466
 
        updateTempProfileProperty(Profile::Icon,icon);
 
366
                          false, 0, false, this);
 
367
    if (!icon.isEmpty()) {
 
368
        _ui->iconSelectButton->setIcon(KIcon(icon));
 
369
        updateTempProfileProperty(Profile::Icon, icon);
467
370
    }
468
371
}
469
372
void EditProfileDialog::profileNameChanged(const QString& text)
470
373
{
471
374
    _ui->emptyNameWarningWidget->setVisible(text.isEmpty());
472
375
 
473
 
    updateTempProfileProperty(Profile::Name,text);
 
376
    updateTempProfileProperty(Profile::Name, text);
474
377
    updateCaption(_tempProfile);
475
378
}
476
379
void EditProfileDialog::startInSameDir(bool sameDir)
477
380
{
478
 
    updateTempProfileProperty(Profile::StartInCurrentSessionDir,sameDir);
 
381
    updateTempProfileProperty(Profile::StartInCurrentSessionDir, sameDir);
479
382
}
480
383
void EditProfileDialog::initialDirChanged(const QString& dir)
481
384
{
482
 
    updateTempProfileProperty(Profile::Directory,dir);
 
385
    updateTempProfileProperty(Profile::Directory, dir);
483
386
}
484
387
void EditProfileDialog::commandChanged(const QString& command)
485
388
{
486
389
    ShellCommand shellCommand(command);
487
390
 
488
 
    updateTempProfileProperty(Profile::Command,shellCommand.command());
489
 
    updateTempProfileProperty(Profile::Arguments,shellCommand.arguments());
 
391
    updateTempProfileProperty(Profile::Command, shellCommand.command());
 
392
    updateTempProfileProperty(Profile::Arguments, shellCommand.arguments());
490
393
}
491
394
void EditProfileDialog::selectInitialDir()
492
395
{
493
396
    const KUrl url = KFileDialog::getExistingDirectoryUrl(_ui->initialDirEdit->text(),
494
 
                                                          this,
495
 
                                                          i18n("Select Initial Directory"));
 
397
                     this,
 
398
                     i18n("Select Initial Directory"));
496
399
 
497
 
    if ( !url.isEmpty() )
 
400
    if (!url.isEmpty())
498
401
        _ui->initialDirEdit->setText(url.path());
499
402
}
500
 
void EditProfileDialog::setupAppearancePage(const Profile::Ptr info)
 
403
void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
501
404
{
502
405
    ColorSchemeViewDelegate* delegate = new ColorSchemeViewDelegate(this);
503
406
    _ui->colorSchemeList->setItemDelegate(delegate);
504
407
 
505
 
    _colorSchemeAnimationTimeLine = new QTimeLine( 500 , this );
 
408
    _colorSchemeAnimationTimeLine = new QTimeLine(500 , this);
506
409
    delegate->setEntryTimeLine(_colorSchemeAnimationTimeLine);
507
410
 
508
 
    connect( _colorSchemeAnimationTimeLine , SIGNAL(valueChanged(qreal)) , this ,
509
 
             SLOT(colorSchemeAnimationUpdate()) );
 
411
    connect(_colorSchemeAnimationTimeLine, SIGNAL(valueChanged(qreal)), this,
 
412
            SLOT(colorSchemeAnimationUpdate()));
510
413
 
511
414
    _ui->transparencyWarningWidget->setVisible(false);
 
415
    _ui->transparencyWarningWidget->setWordWrap(true);
 
416
    _ui->transparencyWarningWidget->setCloseButtonVisible(false);
 
417
    _ui->transparencyWarningWidget->setMessageType(KMessageWidget::Warning);
512
418
 
513
419
    _ui->editColorSchemeButton->setEnabled(false);
514
420
    _ui->removeColorSchemeButton->setEnabled(false);
518
424
 
519
425
    _ui->colorSchemeList->setMouseTracking(true);
520
426
    _ui->colorSchemeList->installEventFilter(this);
521
 
    _ui->colorSchemeList->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
 
427
    _ui->colorSchemeList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
522
428
 
523
 
    connect( _ui->colorSchemeList->selectionModel() , 
524
 
            SIGNAL(selectionChanged(QItemSelection,QItemSelection)) 
525
 
            , this , SLOT(colorSchemeSelected()) );
526
 
    connect( _ui->colorSchemeList , SIGNAL(entered(QModelIndex)) , this , 
527
 
            SLOT(previewColorScheme(QModelIndex)) );
 
429
    connect(_ui->colorSchemeList->selectionModel(),
 
430
            SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
 
431
            this, SLOT(colorSchemeSelected()));
 
432
    connect(_ui->colorSchemeList, SIGNAL(entered(QModelIndex)), this,
 
433
            SLOT(previewColorScheme(QModelIndex)));
528
434
 
529
435
    updateColorSchemeButtons();
530
436
 
531
 
    connect( _ui->editColorSchemeButton , SIGNAL(clicked()) , this , 
532
 
            SLOT(editColorScheme()) );
533
 
    connect( _ui->removeColorSchemeButton , SIGNAL(clicked()) , this ,
534
 
            SLOT(removeColorScheme()) );
535
 
    connect( _ui->newColorSchemeButton , SIGNAL(clicked()) , this , 
536
 
            SLOT(newColorScheme()) );
 
437
    connect(_ui->editColorSchemeButton, SIGNAL(clicked()), this,
 
438
            SLOT(editColorScheme()));
 
439
    connect(_ui->removeColorSchemeButton, SIGNAL(clicked()), this,
 
440
            SLOT(removeColorScheme()));
 
441
    connect(_ui->newColorSchemeButton, SIGNAL(clicked()), this,
 
442
            SLOT(newColorScheme()));
537
443
 
538
444
    // setup font preview
539
 
    bool antialias = info->property<bool>(Profile::AntiAliasFonts);
 
445
    const bool antialias = profile->antiAliasFonts();
540
446
 
541
 
    QFont font = info->font();
542
 
    font.setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias);
 
447
    QFont profileFont = profile->font();
 
448
    profileFont.setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias);
543
449
 
544
450
    _ui->fontPreviewLabel->installEventFilter(this);
545
 
    _ui->fontPreviewLabel->setFont(font);
546
 
    setFontSliderRange(font);
547
 
    setFontSliderValue(font);
548
 
 
549
 
    connect( _ui->fontSizeSlider , SIGNAL(valueChanged(int)) , this ,
550
 
             SLOT(setFontSize(int)) );
551
 
    connect( _ui->editFontButton , SIGNAL(clicked()) , this ,
552
 
             SLOT(showFontDialog()) );
553
 
 
554
 
    // setup font smoothing 
 
451
    _ui->fontPreviewLabel->setFont(profileFont);
 
452
    setFontSliderRange(profileFont);
 
453
    setFontSliderValue(profileFont);
 
454
 
 
455
    connect(_ui->fontSizeSlider, SIGNAL(valueChanged(int)), this,
 
456
            SLOT(setFontSize(int)));
 
457
    connect(_ui->selectFontButton, SIGNAL(clicked()), this,
 
458
            SLOT(showFontDialog()));
 
459
 
 
460
    // setup font smoothing
555
461
    _ui->antialiasTextButton->setChecked(antialias);
556
 
    connect( _ui->antialiasTextButton , SIGNAL(toggled(bool)) , this , 
557
 
             SLOT(setAntialiasText(bool)) );
 
462
    connect(_ui->antialiasTextButton, SIGNAL(toggled(bool)), this,
 
463
            SLOT(setAntialiasText(bool)));
558
464
 
559
 
    bool boldIntense = info->property<bool>(Profile::BoldIntense);
560
 
    _ui->boldIntenseButton->setChecked(boldIntense);
561
 
    connect( _ui->boldIntenseButton , SIGNAL(toggled(bool)) , this ,
562
 
             SLOT(setBoldIntense(bool)));
 
465
    _ui->boldIntenseButton->setChecked(profile->boldIntense());
 
466
    connect(_ui->boldIntenseButton, SIGNAL(toggled(bool)), this,
 
467
            SLOT(setBoldIntense(bool)));
563
468
}
564
469
void EditProfileDialog::setAntialiasText(bool enable)
565
470
{
566
 
    QFont font = _ui->fontPreviewLabel->font();
567
 
    font.setStyleStrategy(enable ? QFont::PreferAntialias : QFont::NoAntialias);
 
471
    QFont profileFont = _ui->fontPreviewLabel->font();
 
472
    profileFont.setStyleStrategy(enable ? QFont::PreferAntialias : QFont::NoAntialias);
568
473
 
569
474
    // update preview to reflect text smoothing state
570
 
    fontSelected(font);
571
 
    updateTempProfileProperty(Profile::AntiAliasFonts,enable);
 
475
    fontSelected(profileFont);
 
476
    updateTempProfileProperty(Profile::AntiAliasFonts, enable);
572
477
}
573
478
void EditProfileDialog::setBoldIntense(bool enable)
574
479
{
575
 
    preview(Profile::BoldIntense,enable);
576
 
    updateTempProfileProperty(Profile::BoldIntense,enable);
 
480
    preview(Profile::BoldIntense, enable);
 
481
    updateTempProfileProperty(Profile::BoldIntense, enable);
577
482
}
578
483
void EditProfileDialog::colorSchemeAnimationUpdate()
579
484
{
580
485
    QAbstractItemModel* model = _ui->colorSchemeList->model();
581
486
 
582
 
    for ( int i = model->rowCount() ; i >= 0 ; i-- )
583
 
        _ui->colorSchemeList->update( model->index(i,0) );
 
487
    for (int i = model->rowCount() ; i >= 0 ; i--)
 
488
        _ui->colorSchemeList->update(model->index(i, 0));
584
489
}
585
490
void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
586
491
{
596
501
 
597
502
    model->clear();
598
503
 
 
504
    QStandardItem* selectedItem = 0;
 
505
 
599
506
    QList<const ColorScheme*> schemeList = ColorSchemeManager::instance()->allColorSchemes();
600
 
    QListIterator<const ColorScheme*> schemeIter(schemeList);
601
 
 
602
 
    QStandardItem* selectedItem = 0;
603
 
 
604
 
    while (schemeIter.hasNext())
605
 
    {
606
 
        const ColorScheme* colors = schemeIter.next();
607
 
        QStandardItem* item = new QStandardItem(colors->description());
608
 
        item->setData( QVariant::fromValue(colors) ,  Qt::UserRole + 1);
609
 
        item->setFlags( item->flags() );
610
 
 
611
 
        if ( currentScheme == colors ) 
612
 
            selectedItem = item;  
 
507
 
 
508
    foreach(const ColorScheme* scheme, schemeList) {
 
509
        QStandardItem* item = new QStandardItem(scheme->description());
 
510
        item->setData(QVariant::fromValue(scheme) ,  Qt::UserRole + 1);
 
511
        item->setFlags(item->flags());
 
512
 
 
513
        if (currentScheme == scheme)
 
514
            selectedItem = item;
613
515
 
614
516
        model->appendRow(item);
615
517
    }
616
518
 
617
519
    model->sort(0);
618
520
 
619
 
    if ( selectCurrentScheme && selectedItem )
620
 
    {
 
521
    if (selectCurrentScheme && selectedItem) {
621
522
        _ui->colorSchemeList->updateGeometry();
622
 
        _ui->colorSchemeList->selectionModel()->setCurrentIndex( selectedItem->index() , 
623
 
                                                                 QItemSelectionModel::Select );
 
523
        _ui->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->index() ,
 
524
                QItemSelectionModel::Select);
624
525
 
625
526
        // update transparency warning label
626
527
        updateTransparencyWarning();
631
532
    if (!_ui->keyBindingList->model())
632
533
        _ui->keyBindingList->setModel(new QStandardItemModel(this));
633
534
 
634
 
    const QString& name = lookupProfile()
635
 
                                    ->property<QString>(Profile::KeyBindings);
 
535
    const QString& name = lookupProfile()->keyBindings();
636
536
 
637
537
    KeyboardTranslatorManager* keyManager = KeyboardTranslatorManager::instance();
638
538
    const KeyboardTranslator* currentTranslator = keyManager->findTranslator(name);
645
545
 
646
546
    QStandardItem* selectedItem = 0;
647
547
 
648
 
    QList<QString> translatorNames = keyManager->allTranslators();
649
 
    QListIterator<QString> iter(translatorNames);
650
 
    while (iter.hasNext())
651
 
    {
652
 
        const QString& name = iter.next();
653
 
 
654
 
        const KeyboardTranslator* translator = keyManager->findTranslator(name);
 
548
    QStringList translatorNames = keyManager->allTranslators();
 
549
    foreach(const QString& translatorName, translatorNames) {
 
550
        const KeyboardTranslator* translator = keyManager->findTranslator(translatorName);
655
551
 
656
552
        QStandardItem* item = new QStandardItem(translator->description());
657
 
        item->setData(QVariant::fromValue(translator),Qt::UserRole+1);
658
 
        item->setIcon( KIcon("preferences-desktop-keyboard") );
 
553
        item->setData(QVariant::fromValue(translator), Qt::UserRole + 1);
 
554
        item->setIcon(KIcon("preferences-desktop-keyboard"));
659
555
 
660
 
        if ( translator == currentTranslator )
 
556
        if (translator == currentTranslator)
661
557
            selectedItem = item;
662
558
 
663
559
        model->appendRow(item);
665
561
 
666
562
    model->sort(0);
667
563
 
668
 
    if ( selectCurrentTranslator && selectedItem )
669
 
    {
670
 
        _ui->keyBindingList->selectionModel()->setCurrentIndex( selectedItem->index() , 
671
 
                                                                  QItemSelectionModel::Select );
 
564
    if (selectCurrentTranslator && selectedItem) {
 
565
        _ui->keyBindingList->selectionModel()->setCurrentIndex(selectedItem->index() ,
 
566
                QItemSelectionModel::Select);
672
567
    }
673
568
}
674
 
bool EditProfileDialog::eventFilter( QObject* watched , QEvent* event )
 
569
bool EditProfileDialog::eventFilter(QObject* watched , QEvent* aEvent)
675
570
{
676
 
    if ( watched == _ui->colorSchemeList && event->type() == QEvent::Leave )
677
 
    {
678
 
        if ( _tempProfile->isPropertySet(Profile::ColorScheme) )
679
 
            preview(Profile::ColorScheme,_tempProfile->colorScheme());
 
571
    if (watched == _ui->colorSchemeList && aEvent->type() == QEvent::Leave) {
 
572
        if (_tempProfile->isPropertySet(Profile::ColorScheme))
 
573
            preview(Profile::ColorScheme, _tempProfile->colorScheme());
680
574
        else
681
575
            unpreview(Profile::ColorScheme);
682
576
    }
683
 
    if ( watched == _ui->fontPreviewLabel && event->type() == QEvent::FontChange )
684
 
    {
 
577
    if (watched == _ui->fontPreviewLabel && aEvent->type() == QEvent::FontChange) {
685
578
        const QFont& labelFont = _ui->fontPreviewLabel->font();
686
 
        qreal size = labelFont.pointSizeF();
687
 
        QString fontSize  = KGlobal::locale()->formatNumber(size, size == floor(size) ? 0 : 1);
 
579
        qreal fontSizeF = labelFont.pointSizeF();
 
580
        QString fontSize  = KGlobal::locale()->formatNumber(fontSizeF, fontSizeF == floor(fontSizeF) ? 0 : 1);
688
581
        _ui->fontPreviewLabel->setText(i18n("%1, size %2", labelFont.family(), fontSize));
689
582
    }
690
583
 
691
 
    return KDialog::eventFilter(watched,event);
 
584
    return KDialog::eventFilter(watched, aEvent);
692
585
}
693
586
void EditProfileDialog::unpreviewAll()
694
587
{
695
588
    _delayedPreviewTimer->stop();
696
589
    _delayedPreviewProperties.clear();
697
590
 
698
 
    QHash<Profile::Property,QVariant> map;
699
 
    QHashIterator<int,QVariant> iter(_previewedProperties);
700
 
    while ( iter.hasNext() )
701
 
    {
 
591
    QHash<Profile::Property, QVariant> map;
 
592
    QHashIterator<int, QVariant> iter(_previewedProperties);
 
593
    while (iter.hasNext()) {
702
594
        iter.next();
703
 
        map.insert((Profile::Property)iter.key(),iter.value());
 
595
        map.insert((Profile::Property)iter.key(), iter.value());
704
596
    }
705
597
 
706
598
    // undo any preview changes
707
 
    if ( !map.isEmpty() )
708
 
        SessionManager::instance()->changeProfile(_profile,map,false);
 
599
    if (!map.isEmpty())
 
600
        ProfileManager::instance()->changeProfile(_profile, map, false);
709
601
}
710
 
void EditProfileDialog::unpreview(int property)
 
602
void EditProfileDialog::unpreview(int aProperty)
711
603
{
712
 
    _delayedPreviewProperties.remove(property);
 
604
    _delayedPreviewProperties.remove(aProperty);
713
605
 
714
 
    if (!_previewedProperties.contains(property))
 
606
    if (!_previewedProperties.contains(aProperty))
715
607
        return;
716
608
 
717
 
    QHash<Profile::Property,QVariant> map;
718
 
    map.insert((Profile::Property)property,_previewedProperties[property]);
719
 
    SessionManager::instance()->changeProfile(_profile,map,false); 
 
609
    QHash<Profile::Property, QVariant> map;
 
610
    map.insert((Profile::Property)aProperty, _previewedProperties[aProperty]);
 
611
    ProfileManager::instance()->changeProfile(_profile, map, false);
720
612
 
721
 
    _previewedProperties.remove(property);
 
613
    _previewedProperties.remove(aProperty);
722
614
}
723
 
void EditProfileDialog::delayedPreview(int property , const QVariant& value)
 
615
void EditProfileDialog::delayedPreview(int aProperty , const QVariant& value)
724
616
{
725
 
    _delayedPreviewProperties.insert(property,value); 
 
617
    _delayedPreviewProperties.insert(aProperty, value);
726
618
 
727
619
    _delayedPreviewTimer->stop();
728
620
    _delayedPreviewTimer->start(300);
729
621
}
730
622
void EditProfileDialog::delayedPreviewActivate()
731
623
{
732
 
    Q_ASSERT( qobject_cast<QTimer*>(sender()) );
 
624
    Q_ASSERT(qobject_cast<QTimer*>(sender()));
733
625
 
734
 
    QMutableHashIterator<int,QVariant> iter(_delayedPreviewProperties);
735
 
    if ( iter.hasNext() ) 
736
 
    {
 
626
    QMutableHashIterator<int, QVariant> iter(_delayedPreviewProperties);
 
627
    if (iter.hasNext()) {
737
628
        iter.next();
738
 
        preview(iter.key(),iter.value());
 
629
        preview(iter.key(), iter.value());
739
630
    }
740
631
}
741
 
void EditProfileDialog::preview(int property , const QVariant& value)
 
632
void EditProfileDialog::preview(int aProperty , const QVariant& value)
742
633
{
743
 
    QHash<Profile::Property,QVariant> map;
744
 
    map.insert((Profile::Property)property,value);
 
634
    QHash<Profile::Property, QVariant> map;
 
635
    map.insert((Profile::Property)aProperty, value);
745
636
 
746
 
    _delayedPreviewProperties.remove(property);
 
637
    _delayedPreviewProperties.remove(aProperty);
747
638
 
748
639
    const Profile::Ptr original = lookupProfile();
749
640
 
753
644
    // TODO - Save the original values for each profile and use to unpreview properties
754
645
    ProfileGroup::Ptr group = original->asGroup();
755
646
    if (group && group->profiles().count() > 1 &&
756
 
        original->property<QVariant>((Profile::Property)property).isNull())
 
647
            original->property<QVariant>((Profile::Property)aProperty).isNull())
757
648
        return;
758
649
 
759
 
    if (!_previewedProperties.contains(property))   
760
 
    {
761
 
        _previewedProperties.insert(property , original->property<QVariant>((Profile::Property)property) );
 
650
    if (!_previewedProperties.contains(aProperty)) {
 
651
        _previewedProperties.insert(aProperty , original->property<QVariant>((Profile::Property)aProperty));
762
652
    }
763
653
 
764
654
    // temporary change to color scheme
765
 
    SessionManager::instance()->changeProfile( _profile , map , false);
 
655
    ProfileManager::instance()->changeProfile(_profile , map , false);
766
656
}
767
657
void EditProfileDialog::previewColorScheme(const QModelIndex& index)
768
658
{
769
 
    const QString& name = index.data(Qt::UserRole+1).value<const ColorScheme*>()->name();
 
659
    const QString& name = index.data(Qt::UserRole + 1).value<const ColorScheme*>()->name();
770
660
 
771
 
    delayedPreview( Profile::ColorScheme , name );
 
661
    delayedPreview(Profile::ColorScheme , name);
772
662
}
773
663
void EditProfileDialog::removeColorScheme()
774
664
{
775
665
    QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
776
666
 
777
 
    if ( !selected.isEmpty() )
778
 
    {
779
 
        const QString& name = selected.first().data(Qt::UserRole+1).value<const ColorScheme*>()->name();
 
667
    if (!selected.isEmpty()) {
 
668
        const QString& name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme*>()->name();
780
669
 
781
 
        if (ColorSchemeManager::instance()->deleteColorScheme(name))    
 
670
        if (ColorSchemeManager::instance()->deleteColorScheme(name))
782
671
            _ui->colorSchemeList->model()->removeRow(selected.first().row());
783
672
    }
784
673
}
785
674
void EditProfileDialog::showColorSchemeEditor(bool isNewScheme)
786
 
{    
 
675
{
787
676
    QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
788
677
 
789
678
    QAbstractItemModel* model = _ui->colorSchemeList->model();
790
679
    const ColorScheme* colors = 0;
791
 
    if ( !selected.isEmpty() )
792
 
        colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
 
680
    if (!selected.isEmpty())
 
681
        colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme*>();
793
682
    else
794
683
        colors = ColorSchemeManager::instance()->defaultColorScheme();
795
684
 
796
685
    Q_ASSERT(colors);
797
686
 
798
 
    KDialog* dialog = new KDialog(this);
 
687
    QWeakPointer<KDialog> dialog = new KDialog(this);
799
688
 
800
 
    if ( isNewScheme )
801
 
        dialog->setCaption(i18n("New Color Scheme"));
 
689
    if (isNewScheme)
 
690
        dialog.data()->setCaption(i18n("New Color Scheme"));
802
691
    else
803
 
        dialog->setCaption(i18n("Edit Color Scheme"));
 
692
        dialog.data()->setCaption(i18n("Edit Color Scheme"));
804
693
 
805
694
    ColorSchemeEditor* editor = new ColorSchemeEditor;
806
 
    dialog->setMainWidget(editor);
 
695
    dialog.data()->setMainWidget(editor);
807
696
    editor->setup(colors);
808
697
 
809
 
    if ( isNewScheme )
 
698
    if (isNewScheme)
810
699
        editor->setDescription(i18n("New Color Scheme"));
811
700
 
812
 
    if ( dialog->exec() == QDialog::Accepted )
813
 
    {
 
701
    if (dialog.data()->exec() == QDialog::Accepted) {
814
702
        ColorScheme* newScheme = new ColorScheme(*editor->colorScheme());
815
703
 
816
704
        // if this is a new color scheme, pick a name based on the description
817
 
        if ( isNewScheme )
 
705
        if (isNewScheme)
818
706
            newScheme->setName(newScheme->description());
819
707
 
820
 
        ColorSchemeManager::instance()->addColorScheme( newScheme );
 
708
        ColorSchemeManager::instance()->addColorScheme(newScheme);
821
709
 
822
710
        updateColorSchemeList(true);
823
711
 
824
 
        preview(Profile::ColorScheme,newScheme->name());
 
712
        preview(Profile::ColorScheme, newScheme->name());
825
713
    }
 
714
    delete dialog.data();
826
715
}
827
716
void EditProfileDialog::newColorScheme()
828
717
{
829
 
    showColorSchemeEditor(true);    
 
718
    showColorSchemeEditor(true);
830
719
}
831
720
void EditProfileDialog::editColorScheme()
832
721
{
836
725
{
837
726
    QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
838
727
 
839
 
    if ( !selected.isEmpty() )
840
 
    {
 
728
    if (!selected.isEmpty()) {
841
729
        QAbstractItemModel* model = _ui->colorSchemeList->model();
842
 
        const ColorScheme* colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
 
730
        const ColorScheme* colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme*>();
843
731
 
844
 
        updateTempProfileProperty(Profile::ColorScheme,colors->name());
 
732
        updateTempProfileProperty(Profile::ColorScheme, colors->name());
845
733
        previewColorScheme(selected.first());
846
734
 
847
735
        updateTransparencyWarning();
851
739
}
852
740
void EditProfileDialog::updateColorSchemeButtons()
853
741
{
854
 
    enableIfNonEmptySelection(_ui->editColorSchemeButton,_ui->colorSchemeList->selectionModel());
855
 
    enableIfNonEmptySelection(_ui->removeColorSchemeButton,_ui->colorSchemeList->selectionModel());
 
742
    enableIfNonEmptySelection(_ui->editColorSchemeButton, _ui->colorSchemeList->selectionModel());
 
743
    enableIfNonEmptySelection(_ui->removeColorSchemeButton, _ui->colorSchemeList->selectionModel());
856
744
}
857
745
void EditProfileDialog::updateKeyBindingsButtons()
858
 
{    
859
 
    enableIfNonEmptySelection(_ui->editKeyBindingsButton,_ui->keyBindingList->selectionModel());
860
 
    enableIfNonEmptySelection(_ui->removeKeyBindingsButton,_ui->keyBindingList->selectionModel());
 
746
{
 
747
    enableIfNonEmptySelection(_ui->editKeyBindingsButton, _ui->keyBindingList->selectionModel());
 
748
    enableIfNonEmptySelection(_ui->removeKeyBindingsButton, _ui->keyBindingList->selectionModel());
861
749
}
862
 
void EditProfileDialog::enableIfNonEmptySelection(QWidget* widget,QItemSelectionModel* selectionModel)
 
750
void EditProfileDialog::enableIfNonEmptySelection(QWidget* widget, QItemSelectionModel* selectionModel)
863
751
{
864
752
    widget->setEnabled(selectionModel->hasSelection());
865
753
}
866
 
void EditProfileDialog::updateTransparencyWarning() 
 
754
void EditProfileDialog::updateTransparencyWarning()
867
755
{
868
756
    // zero or one indexes can be selected
869
 
    foreach( const QModelIndex& index , _ui->colorSchemeList->selectionModel()->selectedIndexes() ) 
870
 
    {
871
 
        bool needTransparency = index.data(Qt::UserRole+1).value<const ColorScheme*>()->opacity() < 1.0;
 
757
    foreach(const QModelIndex & index , _ui->colorSchemeList->selectionModel()->selectedIndexes()) {
 
758
        bool needTransparency = index.data(Qt::UserRole + 1).value<const ColorScheme*>()->opacity() < 1.0;
872
759
 
873
 
        if ( ! needTransparency )
874
 
        {
 
760
        if (!needTransparency) {
875
761
            _ui->transparencyWarningWidget->setHidden(true);
876
 
        }
877
 
        else if ( ! KWindowSystem::compositingActive() )
878
 
        {
 
762
        } else if (!KWindowSystem::compositingActive()) {
879
763
            _ui->transparencyWarningWidget->setText(i18n("This color scheme uses a transparent background"
880
 
                        " which does not appear to be supported on your"
881
 
                        " desktop"));
 
764
                                                    " which does not appear to be supported on your"
 
765
                                                    " desktop"));
882
766
            _ui->transparencyWarningWidget->setHidden(false);
883
 
        }
884
 
        else if ( ! TerminalDisplay::HAVE_TRANSPARENCY )
885
 
        {
 
767
        } else if (!WindowSystemInfo::HAVE_TRANSPARENCY) {
886
768
            _ui->transparencyWarningWidget->setText(i18n("Konsole was started before desktop effects were enabled."
887
 
                        " You need to restart Konsole to see transparent background."));
 
769
                                                    " You need to restart Konsole to see transparent background."));
888
770
            _ui->transparencyWarningWidget->setHidden(false);
889
771
        }
890
 
 
891
772
    }
892
773
}
893
774
 
897
778
    _tempProfile->setHidden(true);
898
779
}
899
780
 
900
 
void EditProfileDialog::updateTempProfileProperty(Profile::Property property, const QVariant & value)
 
781
void EditProfileDialog::updateTempProfileProperty(Profile::Property aProperty, const QVariant & value)
901
782
{
902
 
    _tempProfile->setProperty(property, value);
 
783
    _tempProfile->setProperty(aProperty, value);
903
784
    updateButtonApply();
904
785
}
905
786
 
906
 
void EditProfileDialog::updateButtonApply( )
 
787
void EditProfileDialog::updateButtonApply()
907
788
{
908
789
    bool userModified = false;
909
790
 
910
 
    QHashIterator<Profile::Property,QVariant> iter(_tempProfile->setProperties());
911
 
    while ( iter.hasNext() )
912
 
    {
 
791
    QHashIterator<Profile::Property, QVariant> iter(_tempProfile->setProperties());
 
792
    while (iter.hasNext()) {
913
793
        iter.next();
914
794
 
915
 
        Profile::Property property = iter.key();
916
 
        QVariant value = iter.value() ;
 
795
        Profile::Property aProperty = iter.key();
 
796
        QVariant value = iter.value();
917
797
 
918
798
        // for previewed property
919
 
        if( _previewedProperties.contains(int(property)) )
920
 
        {
921
 
           if ( value != _previewedProperties.value(int(property)))
922
 
           {
923
 
                userModified = true ;
924
 
                break ;
925
 
           }
926
 
        }
927
 
        // for not-previewed property
928
 
        else if ( (value != _profile->property<QVariant>(property)) )
929
 
        {
930
 
            userModified = true ;
931
 
            break ;
 
799
        if (_previewedProperties.contains(int(aProperty))) {
 
800
            if (value != _previewedProperties.value(int(aProperty))) {
 
801
                userModified = true;
 
802
                break;
 
803
            }
 
804
            // for not-previewed property
 
805
        } else if ((value != _profile->property<QVariant>(aProperty))) {
 
806
            userModified = true;
 
807
            break;
932
808
        }
933
809
    }
934
810
 
935
811
    enableButtonApply(userModified);
936
812
}
937
813
 
938
 
void EditProfileDialog::setupKeyboardPage(const Profile::Ptr /* info */)
 
814
void EditProfileDialog::setupKeyboardPage(const Profile::Ptr /* profile */)
939
815
{
940
816
    // setup translator list
941
 
    updateKeyBindingsList(true); 
 
817
    updateKeyBindingsList(true);
942
818
 
943
 
    connect( _ui->keyBindingList->selectionModel() , 
944
 
                SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
945
 
                SLOT(keyBindingSelected()) );
946
 
    connect( _ui->newKeyBindingsButton , SIGNAL(clicked()) , this ,
947
 
            SLOT(newKeyBinding()) );
 
819
    connect(_ui->keyBindingList->selectionModel(),
 
820
            SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
 
821
            SLOT(keyBindingSelected()));
 
822
    connect(_ui->newKeyBindingsButton, SIGNAL(clicked()), this,
 
823
            SLOT(newKeyBinding()));
948
824
 
949
825
    updateKeyBindingsButtons();
950
826
 
951
 
    connect( _ui->editKeyBindingsButton , SIGNAL(clicked()) , this , 
952
 
          SLOT(editKeyBinding()) );  
953
 
    connect( _ui->removeKeyBindingsButton , SIGNAL(clicked()) , this ,
954
 
            SLOT(removeKeyBinding()) );
 
827
    connect(_ui->editKeyBindingsButton, SIGNAL(clicked()), this,
 
828
            SLOT(editKeyBinding()));
 
829
    connect(_ui->removeKeyBindingsButton, SIGNAL(clicked()), this,
 
830
            SLOT(removeKeyBinding()));
955
831
}
956
832
void EditProfileDialog::keyBindingSelected()
957
833
{
958
834
    QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
959
835
 
960
 
    if ( !selected.isEmpty() )
961
 
    {
 
836
    if (!selected.isEmpty()) {
962
837
        QAbstractItemModel* model = _ui->keyBindingList->model();
963
 
        const KeyboardTranslator* translator = model->data(selected.first(),Qt::UserRole+1)
964
 
                                                .value<const KeyboardTranslator*>();
965
 
        updateTempProfileProperty(Profile::KeyBindings,translator->name());
 
838
        const KeyboardTranslator* translator = model->data(selected.first(), Qt::UserRole + 1)
 
839
                                               .value<const KeyboardTranslator*>();
 
840
        updateTempProfileProperty(Profile::KeyBindings, translator->name());
966
841
    }
967
842
 
968
843
    updateKeyBindingsButtons();
971
846
{
972
847
    QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
973
848
 
974
 
    if ( !selected.isEmpty() )
975
 
    {
976
 
        const QString& name = selected.first().data(Qt::UserRole+1).value<const KeyboardTranslator*>()->name();
 
849
    if (!selected.isEmpty()) {
 
850
        const QString& name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator*>()->name();
977
851
        if (KeyboardTranslatorManager::instance()->deleteTranslator(name))
978
 
            _ui->keyBindingList->model()->removeRow(selected.first().row());   
 
852
            _ui->keyBindingList->model()->removeRow(selected.first().row());
979
853
    }
980
854
}
981
855
void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
984
858
    QAbstractItemModel* model = _ui->keyBindingList->model();
985
859
 
986
860
    const KeyboardTranslator* translator = 0;
987
 
    if ( !selected.isEmpty() )
988
 
        translator = model->data(selected.first(),Qt::UserRole+1).value<const KeyboardTranslator*>();
 
861
    if (!selected.isEmpty())
 
862
        translator = model->data(selected.first(), Qt::UserRole + 1).value<const KeyboardTranslator*>();
989
863
    else
990
864
        translator = KeyboardTranslatorManager::instance()->defaultTranslator();
991
865
 
992
866
    Q_ASSERT(translator);
993
867
 
994
 
    KDialog* dialog = new KDialog(this);
 
868
    QWeakPointer<KDialog> dialog = new KDialog(this);
995
869
 
996
 
    if ( isNewTranslator )
997
 
        dialog->setCaption(i18n("New Key Binding List"));
 
870
    if (isNewTranslator)
 
871
        dialog.data()->setCaption(i18n("New Key Binding List"));
998
872
    else
999
 
        dialog->setCaption(i18n("Edit Key Binding List"));
 
873
        dialog.data()->setCaption(i18n("Edit Key Binding List"));
1000
874
 
1001
875
    KeyBindingEditor* editor = new KeyBindingEditor;
1002
 
    dialog->setMainWidget(editor);
 
876
    dialog.data()->setMainWidget(editor);
1003
877
 
1004
 
    if ( translator )
 
878
    if (translator)
1005
879
        editor->setup(translator);
1006
880
 
1007
 
    if ( isNewTranslator )
 
881
    if (isNewTranslator)
1008
882
        editor->setDescription(i18n("New Key Binding List"));
1009
883
 
1010
 
    if ( dialog->exec() == QDialog::Accepted )
1011
 
    {
 
884
    if (dialog.data()->exec() == QDialog::Accepted) {
1012
885
        KeyboardTranslator* newTranslator = new KeyboardTranslator(*editor->translator());
1013
886
 
1014
 
        if ( isNewTranslator )
 
887
        if (isNewTranslator)
1015
888
            newTranslator->setName(newTranslator->description());
1016
889
 
1017
 
        KeyboardTranslatorManager::instance()->addTranslator( newTranslator );
 
890
        KeyboardTranslatorManager::instance()->addTranslator(newTranslator);
1018
891
 
1019
892
        updateKeyBindingsList();
1020
893
 
1021
894
        const QString& currentTranslator = lookupProfile()
1022
 
                                        ->property<QString>(Profile::KeyBindings);
 
895
                                           ->property<QString>(Profile::KeyBindings);
1023
896
 
1024
 
        if ( newTranslator->name() == currentTranslator )
1025
 
        {
1026
 
            updateTempProfileProperty(Profile::KeyBindings,newTranslator->name());
 
897
        if (newTranslator->name() == currentTranslator) {
 
898
            updateTempProfileProperty(Profile::KeyBindings, newTranslator->name());
1027
899
        }
1028
900
    }
 
901
    delete dialog.data();
1029
902
}
1030
903
void EditProfileDialog::newKeyBinding()
1031
904
{
1035
908
{
1036
909
    showKeyBindingEditor(false);
1037
910
}
1038
 
void EditProfileDialog::setupCheckBoxes( BooleanOption* options , const Profile::Ptr profile )
 
911
void EditProfileDialog::setupCheckBoxes(BooleanOption* options , const Profile::Ptr profile)
1039
912
{
1040
 
    while ( options->button != 0 )
1041
 
    {
 
913
    while (options->button != 0) {
1042
914
        options->button->setChecked(profile->property<bool>(options->property));
1043
 
        connect( options->button , SIGNAL(toggled(bool)) , this , options->slot );
 
915
        connect(options->button, SIGNAL(toggled(bool)), this, options->slot);
1044
916
 
1045
917
        ++options;
1046
918
    }
1047
919
}
1048
 
void EditProfileDialog::setupRadio( RadioOption* possibilities , int actual )
 
920
void EditProfileDialog::setupRadio(RadioOption* possibilities , int actual)
1049
921
{
1050
 
    while (possibilities->button != 0)
1051
 
    {
1052
 
        if ( possibilities->value == actual )
 
922
    while (possibilities->button != 0) {
 
923
        if (possibilities->value == actual)
1053
924
            possibilities->button->setChecked(true);
1054
925
        else
1055
926
            possibilities->button->setChecked(false);
1056
927
 
1057
 
        connect( possibilities->button , SIGNAL(clicked()) , this , possibilities->slot );
 
928
        connect(possibilities->button, SIGNAL(clicked()), this, possibilities->slot);
1058
929
 
1059
930
        ++possibilities;
1060
931
    }
1065
936
    // setup scrollbar radio
1066
937
    int scrollBarPosition = profile->property<int>(Profile::ScrollBarPosition);
1067
938
 
1068
 
    RadioOption positions[] = { {_ui->scrollBarHiddenButton,Profile::ScrollBarHidden,SLOT(hideScrollBar())},
1069
 
                                {_ui->scrollBarLeftButton,Profile::ScrollBarLeft,SLOT(showScrollBarLeft())},
1070
 
                                {_ui->scrollBarRightButton,Profile::ScrollBarRight,SLOT(showScrollBarRight())},
1071
 
                                {0,0,0} 
1072
 
                              }; 
 
939
    RadioOption positions[] = { {_ui->scrollBarHiddenButton, Enum::ScrollBarHidden, SLOT(hideScrollBar())},
 
940
        {_ui->scrollBarLeftButton, Enum::ScrollBarLeft, SLOT(showScrollBarLeft())},
 
941
        {_ui->scrollBarRightButton, Enum::ScrollBarRight, SLOT(showScrollBarRight())},
 
942
        {0, 0, 0}
 
943
    };
1073
944
 
1074
 
    setupRadio( positions , scrollBarPosition );
 
945
    setupRadio(positions , scrollBarPosition);
1075
946
 
1076
947
    // setup scrollback type radio
1077
948
    int scrollBackType = profile->property<int>(Profile::HistoryMode);
1078
 
 
1079
 
    RadioOption types[] = { {_ui->disableScrollbackButton,Profile::DisableHistory,SLOT(noScrollBack())},
1080
 
                            {_ui->fixedScrollbackButton,Profile::FixedSizeHistory,SLOT(fixedScrollBack())},
1081
 
                            {_ui->unlimitedScrollbackButton,Profile::UnlimitedHistory,SLOT(unlimitedScrollBack())},
1082
 
                            {0,0,0} };
1083
 
    setupRadio( types , scrollBackType ); 
 
949
    _ui->historySizeWidget->setMode(Enum::HistoryModeEnum(scrollBackType));
 
950
    connect(_ui->historySizeWidget, SIGNAL(historyModeChanged(Enum::HistoryModeEnum)),
 
951
            this, SLOT(historyModeChanged(Enum::HistoryModeEnum)));
1084
952
 
1085
953
    // setup scrollback line count spinner
1086
 
    int historySize = profile->property<int>(Profile::HistorySize);
1087
 
    _ui->scrollBackLinesSpinner->setValue( historySize );
1088
 
    _ui->scrollBackLinesSpinner->setSingleStep( historySize / 10 );
1089
 
 
 
954
    const int historySize = profile->historySize();
 
955
    _ui->historySizeWidget->setLineCount(historySize);
1090
956
 
1091
957
    // signals and slots
1092
 
    connect( _ui->scrollBackLinesSpinner , SIGNAL(valueChanged(int)) , this , 
1093
 
            SLOT(scrollBackLinesChanged(int)) );
 
958
    connect(_ui->historySizeWidget, SIGNAL(historySizeChanged(int)),
 
959
            this, SLOT(historySizeChanged(int)));
1094
960
}
1095
961
 
1096
 
void EditProfileDialog::scrollBackLinesChanged(int lineCount)
 
962
void EditProfileDialog::historySizeChanged(int lineCount)
1097
963
{
1098
964
    updateTempProfileProperty(Profile::HistorySize , lineCount);
1099
965
}
1100
 
void EditProfileDialog::noScrollBack()
1101
 
{
1102
 
    updateTempProfileProperty(Profile::HistoryMode , Profile::DisableHistory);
1103
 
}
1104
 
void EditProfileDialog::fixedScrollBack()
1105
 
{
1106
 
    updateTempProfileProperty(Profile::HistoryMode , Profile::FixedSizeHistory);
1107
 
}
1108
 
void EditProfileDialog::unlimitedScrollBack()
1109
 
{
1110
 
    updateTempProfileProperty(Profile::HistoryMode , Profile::UnlimitedHistory );
 
966
void EditProfileDialog::historyModeChanged(Enum::HistoryModeEnum mode)
 
967
{
 
968
    updateTempProfileProperty(Profile::HistoryMode, mode);
1111
969
}
1112
970
void EditProfileDialog::hideScrollBar()
1113
971
{
1114
 
    updateTempProfileProperty(Profile::ScrollBarPosition , Profile::ScrollBarHidden );
 
972
    updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarHidden);
1115
973
}
1116
974
void EditProfileDialog::showScrollBarLeft()
1117
975
{
1118
 
    updateTempProfileProperty(Profile::ScrollBarPosition , Profile::ScrollBarLeft );
 
976
    updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarLeft);
1119
977
}
1120
978
void EditProfileDialog::showScrollBarRight()
1121
979
{
1122
 
    updateTempProfileProperty(Profile::ScrollBarPosition , Profile::ScrollBarRight );
 
980
    updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarRight);
1123
981
}
1124
 
void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
 
982
void EditProfileDialog::setupMousePage(const Profile::Ptr profile)
1125
983
{
1126
 
    BooleanOption  options[] = { { _ui->enableBlinkingTextButton , Profile::BlinkingTextEnabled , 
1127
 
                                 SLOT(toggleBlinkingText(bool)) },
1128
 
                               { _ui->enableFlowControlButton , Profile::FlowControlEnabled ,
1129
 
                                 SLOT(toggleFlowControl(bool)) },
1130
 
                               { _ui->enableResizeWindowButton , Profile::AllowProgramsToResizeWindow ,
1131
 
                                 SLOT(toggleResizeWindow(bool)) },
1132
 
                               { _ui->enableBlinkingCursorButton , Profile::BlinkingCursorEnabled ,
1133
 
                                 SLOT(toggleBlinkingCursor(bool)) },
1134
 
                               { _ui->underlineLinksButton , Profile::UnderlineLinksEnabled,
1135
 
                                 SLOT(toggleUnderlineLinks(bool)) },
1136
 
                               { _ui->enableBidiRenderingButton , Profile::BidiRenderingEnabled ,
1137
 
                                 SLOT(togglebidiRendering(bool)) },
1138
 
                               { 0 , Profile::Property(0) , 0 }
1139
 
                             };
1140
 
    setupCheckBoxes( options , profile );
 
984
    BooleanOption  options[] = { {
 
985
            _ui->underlineLinksButton , Profile::UnderlineLinksEnabled,
 
986
            SLOT(toggleUnderlineLinks(bool))
 
987
        },
 
988
        {
 
989
            _ui->copyTextToClipboardButton , Profile::AutoCopySelectedText,
 
990
            SLOT(toggleCopyTextToClipboard(bool))
 
991
        },
 
992
        { 0 , Profile::Property(0) , 0 }
 
993
    };
 
994
    setupCheckBoxes(options , profile);
 
995
 
 
996
    // setup middle click paste mode
 
997
    const int middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode);
 
998
    RadioOption pasteModes[] = {
 
999
        {_ui->pasteFromX11SelectionButton, Enum::PasteFromX11Selection, SLOT(pasteFromX11Selection())},
 
1000
        {_ui->pasteFromClipboardButton, Enum::PasteFromClipboard, SLOT(pasteFromClipboard())},
 
1001
        {0, 0, 0}
 
1002
    };
 
1003
    setupRadio(pasteModes , middleClickPasteMode);
1141
1004
 
1142
1005
    // interaction options
1143
 
    _ui->wordCharacterEdit->setText( profile->property<QString>(Profile::WordCharacters) );
 
1006
    _ui->wordCharacterEdit->setText(profile->wordCharacters());
1144
1007
 
1145
 
    connect( _ui->wordCharacterEdit , SIGNAL(textChanged(QString)) , this , 
1146
 
            SLOT(wordCharactersChanged(QString)) );
 
1008
    connect(_ui->wordCharacterEdit, SIGNAL(textChanged(QString)), this,
 
1009
            SLOT(wordCharactersChanged(QString)));
1147
1010
 
1148
1011
    int tripleClickMode = profile->property<int>(Profile::TripleClickMode);
1149
1012
    _ui->tripleClickModeCombo->setCurrentIndex(tripleClickMode);
1150
1013
 
1151
 
    connect( _ui->tripleClickModeCombo , SIGNAL(activated(int)) , this ,
1152
 
             SLOT(TripleClickModeChanged(int)) );
 
1014
    connect(_ui->tripleClickModeCombo, SIGNAL(activated(int)), this,
 
1015
            SLOT(TripleClickModeChanged(int)));
 
1016
}
 
1017
void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
 
1018
{
 
1019
    BooleanOption  options[] = { {
 
1020
            _ui->enableBlinkingTextButton , Profile::BlinkingTextEnabled ,
 
1021
            SLOT(toggleBlinkingText(bool))
 
1022
        },
 
1023
        {
 
1024
            _ui->enableFlowControlButton , Profile::FlowControlEnabled ,
 
1025
            SLOT(toggleFlowControl(bool))
 
1026
        },
 
1027
        {
 
1028
            _ui->enableBlinkingCursorButton , Profile::BlinkingCursorEnabled ,
 
1029
            SLOT(toggleBlinkingCursor(bool))
 
1030
        },
 
1031
        {
 
1032
            _ui->enableBidiRenderingButton , Profile::BidiRenderingEnabled ,
 
1033
            SLOT(togglebidiRendering(bool))
 
1034
        },
 
1035
        { 0 , Profile::Property(0) , 0 }
 
1036
    };
 
1037
    setupCheckBoxes(options , profile);
1153
1038
 
1154
1039
    // cursor options
1155
 
    if ( profile->property<bool>(Profile::UseCustomCursorColor) )
 
1040
    if (profile->useCustomCursorColor())
1156
1041
        _ui->customCursorColorButton->setChecked(true);
1157
1042
    else
1158
1043
        _ui->autoCursorColorButton->setChecked(true);
1159
1044
 
1160
 
    _ui->customColorSelectButton->setColor( profile->property<QColor>(Profile::CustomCursorColor) );
 
1045
    _ui->customColorSelectButton->setColor(profile->customCursorColor());
1161
1046
 
1162
 
    connect( _ui->customCursorColorButton , SIGNAL(clicked()) , this , SLOT(customCursorColor()) );
1163
 
    connect( _ui->autoCursorColorButton , SIGNAL(clicked()) , this , SLOT(autoCursorColor()) );
1164
 
    connect( _ui->customColorSelectButton , SIGNAL(changed(QColor)) , 
1165
 
            SLOT(customCursorColorChanged(QColor)) );
 
1047
    connect(_ui->customCursorColorButton, SIGNAL(clicked()), this, SLOT(customCursorColor()));
 
1048
    connect(_ui->autoCursorColorButton, SIGNAL(clicked()), this, SLOT(autoCursorColor()));
 
1049
    connect(_ui->customColorSelectButton, SIGNAL(changed(QColor)),
 
1050
            SLOT(customCursorColorChanged(QColor)));
1166
1051
 
1167
1052
    int shape = profile->property<int>(Profile::CursorShape);
1168
1053
    _ui->cursorShapeCombo->setCurrentIndex(shape);
1169
1054
 
1170
 
    connect( _ui->cursorShapeCombo , SIGNAL(activated(int)) , this , SLOT(setCursorShape(int)) ); 
 
1055
    connect(_ui->cursorShapeCombo, SIGNAL(activated(int)), this, SLOT(setCursorShape(int)));
1171
1056
 
1172
1057
    // encoding options
1173
1058
    QAction* codecAction = new KCodecAction(this);
1174
 
    _ui->selectEncodingButton->setMenu( codecAction->menu() );
1175
 
    connect( codecAction , SIGNAL(triggered(QTextCodec*)) , this , SLOT(setDefaultCodec(QTextCodec*)) );
1176
 
 
1177
 
    _ui->characterEncodingLabel->setText( profile->property<QString>(Profile::DefaultEncoding) );
1178
 
 
 
1059
    _ui->selectEncodingButton->setMenu(codecAction->menu());
 
1060
    connect(codecAction, SIGNAL(triggered(QTextCodec*)), this, SLOT(setDefaultCodec(QTextCodec*)));
 
1061
 
 
1062
    _ui->characterEncodingLabel->setText(profile->defaultEncoding());
1179
1063
}
1180
1064
void EditProfileDialog::setDefaultCodec(QTextCodec* codec)
1181
1065
{
1182
1066
    QString name = QString(codec->name());
1183
1067
 
1184
 
    updateTempProfileProperty(Profile::DefaultEncoding,name);
 
1068
    updateTempProfileProperty(Profile::DefaultEncoding, name);
1185
1069
    _ui->characterEncodingLabel->setText(codec->name());
1186
1070
}
1187
1071
void EditProfileDialog::customCursorColorChanged(const QColor& color)
1188
1072
{
1189
 
    updateTempProfileProperty(Profile::CustomCursorColor,color);
 
1073
    updateTempProfileProperty(Profile::CustomCursorColor, color);
1190
1074
 
1191
1075
    // ensure that custom cursor colors are enabled
1192
1076
    _ui->customCursorColorButton->click();
1193
1077
}
1194
1078
void EditProfileDialog::wordCharactersChanged(const QString& text)
1195
1079
{
1196
 
    updateTempProfileProperty(Profile::WordCharacters,text);
 
1080
    updateTempProfileProperty(Profile::WordCharacters, text);
1197
1081
}
1198
1082
void EditProfileDialog::autoCursorColor()
1199
1083
{
1200
 
    updateTempProfileProperty(Profile::UseCustomCursorColor,false);
 
1084
    updateTempProfileProperty(Profile::UseCustomCursorColor, false);
1201
1085
}
1202
1086
void EditProfileDialog::customCursorColor()
1203
1087
{
1204
 
    updateTempProfileProperty(Profile::UseCustomCursorColor,true);
 
1088
    updateTempProfileProperty(Profile::UseCustomCursorColor, true);
1205
1089
}
1206
1090
void EditProfileDialog::setCursorShape(int index)
1207
1091
{
1208
 
    updateTempProfileProperty(Profile::CursorShape,index);
 
1092
    updateTempProfileProperty(Profile::CursorShape, index);
1209
1093
}
1210
1094
void EditProfileDialog::togglebidiRendering(bool enable)
1211
1095
{
1212
 
    updateTempProfileProperty(Profile::BidiRenderingEnabled,enable);
 
1096
    updateTempProfileProperty(Profile::BidiRenderingEnabled, enable);
1213
1097
}
1214
1098
void EditProfileDialog::toggleBlinkingCursor(bool enable)
1215
1099
{
1216
 
    updateTempProfileProperty(Profile::BlinkingCursorEnabled,enable);
 
1100
    updateTempProfileProperty(Profile::BlinkingCursorEnabled, enable);
1217
1101
}
1218
1102
void EditProfileDialog::toggleUnderlineLinks(bool enable)
1219
1103
{
1220
 
    updateTempProfileProperty(Profile::UnderlineLinksEnabled,enable);
 
1104
    updateTempProfileProperty(Profile::UnderlineLinksEnabled, enable);
 
1105
}
 
1106
void EditProfileDialog::toggleCopyTextToClipboard(bool enable)
 
1107
{
 
1108
    updateTempProfileProperty(Profile::AutoCopySelectedText, enable);
 
1109
}
 
1110
void EditProfileDialog::pasteFromX11Selection()
 
1111
{
 
1112
    updateTempProfileProperty(Profile::MiddleClickPasteMode, Enum::PasteFromX11Selection);
 
1113
}
 
1114
void EditProfileDialog::pasteFromClipboard()
 
1115
{
 
1116
    updateTempProfileProperty(Profile::MiddleClickPasteMode, Enum::PasteFromClipboard);
1221
1117
}
1222
1118
void EditProfileDialog::TripleClickModeChanged(int newValue)
1223
1119
{
1224
 
    updateTempProfileProperty(Profile::TripleClickMode,newValue);
 
1120
    updateTempProfileProperty(Profile::TripleClickMode, newValue);
1225
1121
}
1226
1122
void EditProfileDialog::toggleBlinkingText(bool enable)
1227
1123
{
1228
 
    updateTempProfileProperty(Profile::BlinkingTextEnabled,enable);
 
1124
    updateTempProfileProperty(Profile::BlinkingTextEnabled, enable);
1229
1125
}
1230
1126
void EditProfileDialog::toggleFlowControl(bool enable)
1231
1127
{
1232
 
    updateTempProfileProperty(Profile::FlowControlEnabled,enable);
1233
 
}
1234
 
void EditProfileDialog::toggleResizeWindow(bool enable)
1235
 
{
1236
 
    updateTempProfileProperty(Profile::AllowProgramsToResizeWindow,enable);
1237
 
}
1238
 
void EditProfileDialog::fontSelected(const QFont& font)
1239
 
{
1240
 
    QFont previewFont = font;
1241
 
 
1242
 
   setFontSliderRange(font);
1243
 
   setFontSliderValue(font);
1244
 
 
1245
 
   _ui->fontPreviewLabel->setFont(previewFont);
1246
 
 
1247
 
   preview(Profile::Font,font);
1248
 
   updateTempProfileProperty(Profile::Font,font);
1249
 
 
 
1128
    updateTempProfileProperty(Profile::FlowControlEnabled, enable);
 
1129
}
 
1130
void EditProfileDialog::fontSelected(const QFont& aFont)
 
1131
{
 
1132
    QFont previewFont = aFont;
 
1133
 
 
1134
    setFontSliderRange(aFont);
 
1135
    setFontSliderValue(aFont);
 
1136
 
 
1137
    _ui->fontPreviewLabel->setFont(previewFont);
 
1138
 
 
1139
    preview(Profile::Font, aFont);
 
1140
    updateTempProfileProperty(Profile::Font, aFont);
1250
1141
}
1251
1142
void EditProfileDialog::showFontDialog()
1252
1143
{
 
1144
    QString sampleText = QString("ell 'lL', one '1', little eye 'i', big eye");
 
1145
    sampleText += QString("'I', lL1iI, Zero '0', little oh 'o', big oh 'O', 0oO");
 
1146
    sampleText += QString("`~!@#$%^&*()_+-=[]\\{}|:\";'<>?,./");
 
1147
    sampleText += QString("0123456789");
 
1148
    sampleText += QString("\nThe Quick Brown Fox Jumps Over The Lazy Dog\n");
 
1149
    sampleText += i18n("--- Type anything in this box ---");
1253
1150
    QFont currentFont = _ui->fontPreviewLabel->font();
1254
1151
 
1255
 
    KFontDialog* dialog = new KFontDialog(this, KFontChooser::FixedFontsOnly);
1256
 
    dialog->setFont(currentFont, true);
1257
 
 
1258
 
    connect( dialog , SIGNAL(fontSelected(QFont)) , this , SLOT(fontSelected(QFont)) );
1259
 
 
1260
 
    if (dialog->exec() == QDialog::Rejected)
 
1152
    QWeakPointer<KFontDialog> dialog = new KFontDialog(this, KFontChooser::FixedFontsOnly);
 
1153
    dialog.data()->setCaption(i18n("Select Fixed Width Font"));
 
1154
    dialog.data()->setFont(currentFont, true);
 
1155
 
 
1156
    // TODO (hindenburg): When https://git.reviewboard.kde.org/r/103357 is
 
1157
    // committed, change the below.
 
1158
    // Use text more fitting to show font differences in a terminal
 
1159
    QList<KFontChooser*> chooserList = dialog.data()->findChildren<KFontChooser*>();
 
1160
    if (!chooserList.isEmpty())
 
1161
        chooserList.at(0)->setSampleText(sampleText);
 
1162
 
 
1163
    connect(dialog.data(), SIGNAL(fontSelected(QFont)), this, SLOT(fontSelected(QFont)));
 
1164
 
 
1165
    if (dialog.data()->exec() == QDialog::Rejected)
1261
1166
        fontSelected(currentFont);
 
1167
    delete dialog.data();
1262
1168
}
1263
1169
void EditProfileDialog::setFontSize(int pointSize)
1264
1170
{
1266
1172
    newFont.setPointSizeF(pointSize / 10.0);
1267
1173
    _ui->fontPreviewLabel->setFont(newFont);
1268
1174
 
1269
 
    preview(Profile::Font,newFont);
1270
 
    updateTempProfileProperty(Profile::Font,newFont);
 
1175
    preview(Profile::Font, newFont);
 
1176
    updateTempProfileProperty(Profile::Font, newFont);
1271
1177
}
1272
1178
 
1273
 
void EditProfileDialog::setFontSliderRange(const QFont& font)
 
1179
void EditProfileDialog::setFontSliderRange(const QFont& aFont)
1274
1180
{
1275
1181
    QSlider* slider = _ui->fontSizeSlider;
1276
 
    // Minimum on the slider is 4, 
 
1182
    // Minimum on the slider is 4,
1277
1183
    // Maximum is the greater of 2 times the current size and 14
1278
 
    slider->setRange( qMin(4 * 10, qRound(font.pointSizeF() * 10)),
1279
 
                      qMax(14 * 10, 2 * qRound(font.pointSize() * 10)) );
1280
 
 
1281
 
}
1282
 
 
1283
 
void EditProfileDialog::setFontSliderValue(const QFont& font)
1284
 
{
1285
 
   _ui->fontSizeSlider->setValue(qRound(font.pointSize() * 10));
1286
 
}
1287
 
 
1288
 
ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject* parent)
1289
 
 : QAbstractItemDelegate(parent)
1290
 
{
1291
 
 
 
1184
    slider->setRange(qMin(4 * 10, qRound(aFont.pointSizeF() * 10)),
 
1185
                     qMax(14 * 10, 2 * qRound(aFont.pointSize() * 10)));
 
1186
}
 
1187
 
 
1188
void EditProfileDialog::setFontSliderValue(const QFont& aFont)
 
1189
{
 
1190
    _ui->fontSizeSlider->setValue(qRound(aFont.pointSize() * 10));
 
1191
}
 
1192
 
 
1193
ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject* aParent)
 
1194
    : QAbstractItemDelegate(aParent)
 
1195
{
1292
1196
}
1293
1197
 
1294
1198
void ColorSchemeViewDelegate::setEntryTimeLine(QTimeLine* timeLine)
1297
1201
}
1298
1202
 
1299
1203
void ColorSchemeViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
1300
 
                       const QModelIndex& index) const
 
1204
                                    const QModelIndex& index) const
1301
1205
{
1302
1206
    // entry animation
1303
1207
    //
1304
 
    // note that the translation occurs for each item drawn, but the 
 
1208
    // note that the translation occurs for each item drawn, but the
1305
1209
    // painter is not reset between painting items.  this means that when
1306
1210
    // the items are painted in order ( as occurs when the list is first
1307
1211
    // shown ), there is a visually pleasing staggering of items as they
1308
1212
    // enter.
1309
 
    if ( _entryTimeLine != 0 )
1310
 
    {
1311
 
        qreal value = 1.0-_entryTimeLine->currentValue();
1312
 
        painter->translate(  value * 
1313
 
                             option.rect.width() , 0 );
 
1213
    if (_entryTimeLine != 0) {
 
1214
        qreal value = 1.0 - _entryTimeLine->currentValue();
 
1215
        painter->translate(value *
 
1216
                           option.rect.width() , 0);
1314
1217
 
1315
 
        painter->setOpacity( _entryTimeLine->currentValue() );
 
1218
        painter->setOpacity(_entryTimeLine->currentValue());
1316
1219
    }
1317
1220
 
1318
1221
    const ColorScheme* scheme = index.data(Qt::UserRole + 1).value<const ColorScheme*>();
1321
1224
 
1322
1225
    bool transparencyAvailable = KWindowSystem::compositingActive();
1323
1226
 
1324
 
    painter->setRenderHint( QPainter::Antialiasing );
 
1227
    painter->setRenderHint(QPainter::Antialiasing);
1325
1228
 
1326
1229
    // draw background
1327
 
    painter->setPen( QPen(scheme->foregroundColor() , 1) );
 
1230
    painter->setPen(QPen(scheme->foregroundColor() , 1));
1328
1231
 
1329
1232
    // radial gradient for background
1330
1233
    // from a lightened version of the scheme's background color in the center to
1331
1234
    // a darker version at the outer edge
1332
1235
    QColor color = scheme->backgroundColor();
1333
 
    QRectF backgroundRect = QRectF(option.rect).adjusted(1.5,1.5,-1.5,-1.5);
 
1236
    QRectF backgroundRect = QRectF(option.rect).adjusted(1.5, 1.5, -1.5, -1.5);
1334
1237
 
1335
1238
    QRadialGradient backgroundGradient(backgroundRect.center() , backgroundRect.width() / 2);
1336
 
    backgroundGradient.setColorAt( 0 , color.lighter(105) );
1337
 
    backgroundGradient.setColorAt( 1 , color.darker(115) );
 
1239
    backgroundGradient.setColorAt(0 , color.lighter(105));
 
1240
    backgroundGradient.setColorAt(1 , color.darker(115));
1338
1241
 
1339
1242
    const int backgroundRectXRoundness = 4;
1340
1243
    const int backgroundRectYRoundness = 30;
1341
1244
 
1342
1245
    QPainterPath backgroundRectPath(backgroundRect.topLeft());
1343
 
    backgroundRectPath.addRoundRect( backgroundRect , backgroundRectXRoundness , backgroundRectYRoundness );
 
1246
    backgroundRectPath.addRoundRect(backgroundRect , backgroundRectXRoundness , backgroundRectYRoundness);
1344
1247
 
1345
 
    if ( transparencyAvailable )
1346
 
    {
 
1248
    if (transparencyAvailable) {
1347
1249
        painter->save();
1348
1250
        color.setAlphaF(scheme->opacity());
1349
 
        painter->setCompositionMode( QPainter::CompositionMode_Source );
 
1251
        painter->setCompositionMode(QPainter::CompositionMode_Source);
1350
1252
        painter->setBrush(backgroundGradient);
1351
1253
 
1352
1254
        painter->drawPath(backgroundRectPath);
1353
1255
        painter->restore();
1354
 
    }
1355
 
    else
1356
 
    {
 
1256
    } else {
1357
1257
        painter->setBrush(backgroundGradient);
1358
1258
        painter->drawPath(backgroundRectPath);
1359
1259
    }
1360
1260
 
1361
1261
    // draw stripe at the side using scheme's foreground color
1362
 
    painter->setPen( QPen(Qt::NoPen) );
1363
 
    QPainterPath path( option.rect.topLeft() );
1364
 
    path.lineTo( option.rect.width() / 10.0 , option.rect.top() );
1365
 
    path.lineTo( option.rect.bottomLeft() );
1366
 
    path.lineTo( option.rect.topLeft() );
1367
 
    painter->setBrush( scheme->foregroundColor() );
 
1262
    painter->setPen(QPen(Qt::NoPen));
 
1263
    QPainterPath path(option.rect.topLeft());
 
1264
    path.lineTo(option.rect.width() / 10.0 , option.rect.top());
 
1265
    path.lineTo(option.rect.bottomLeft());
 
1266
    path.lineTo(option.rect.topLeft());
 
1267
    painter->setBrush(scheme->foregroundColor());
1368
1268
    painter->drawPath(path.intersected(backgroundRectPath));
1369
1269
 
1370
 
    // draw highlight 
 
1270
    // draw highlight
1371
1271
    // with a linear gradient going from translucent white to transparent
1372
 
    QLinearGradient gradient( option.rect.topLeft() , option.rect.bottomLeft() );
1373
 
    gradient.setColorAt( 0 , QColor(255,255,255,90) );
1374
 
    gradient.setColorAt( 1 , Qt::transparent );
 
1272
    QLinearGradient gradient(option.rect.topLeft() , option.rect.bottomLeft());
 
1273
    gradient.setColorAt(0 , QColor(255, 255, 255, 90));
 
1274
    gradient.setColorAt(1 , Qt::transparent);
1375
1275
    painter->setBrush(gradient);
1376
 
    painter->drawRoundRect( backgroundRect , 4 , 30 );
 
1276
    painter->drawRoundRect(backgroundRect , 4 , 30);
1377
1277
 
1378
1278
    //const bool isChecked = index.data(Qt::CheckStateRole) == Qt::Checked;
1379
1279
    const bool isSelected = option.state & QStyle::State_Selected;
1380
1280
 
1381
1281
    // draw border on selected items
1382
 
    if ( isSelected ) //|| isChecked )
1383
 
    {
 
1282
    if (isSelected) { //|| isChecked )
1384
1283
        static const int selectedBorderWidth = 6;
1385
1284
 
1386
 
 
1387
 
        painter->setBrush( QBrush(Qt::NoBrush) );
 
1285
        painter->setBrush(QBrush(Qt::NoBrush));
1388
1286
        QPen pen;
1389
1287
 
1390
1288
        QColor highlightColor = option.palette.highlight().color();
1391
1289
 
1392
 
        if ( isSelected )
 
1290
        if (isSelected)
1393
1291
            highlightColor.setAlphaF(1.0);
1394
1292
        else
1395
1293
            highlightColor.setAlphaF(0.7);
1400
1298
 
1401
1299
        painter->setPen(pen);
1402
1300
 
1403
 
 
1404
 
        painter->drawRect( option.rect.adjusted(selectedBorderWidth/2,
1405
 
                                                selectedBorderWidth/2,
1406
 
                                                -selectedBorderWidth/2,
1407
 
                                                -selectedBorderWidth/2) );
 
1301
        painter->drawRect(option.rect.adjusted(selectedBorderWidth / 2,
 
1302
                                               selectedBorderWidth / 2,
 
1303
                                               -selectedBorderWidth / 2,
 
1304
                                               -selectedBorderWidth / 2));
1408
1305
    }
1409
1306
 
1410
1307
    // draw color scheme name using scheme's foreground color
1411
1308
    QPen pen(scheme->foregroundColor());
1412
1309
    painter->setPen(pen);
1413
1310
 
1414
 
    painter->drawText( option.rect , Qt::AlignCenter , 
1415
 
                        index.data(Qt::DisplayRole).value<QString>() );
1416
 
 
 
1311
    painter->drawText(option.rect , Qt::AlignCenter ,
 
1312
                      index.data(Qt::DisplayRole).value<QString>());
1417
1313
}
1418
1314
 
1419
 
QSize ColorSchemeViewDelegate::sizeHint( const QStyleOptionViewItem& option,
1420
 
                       const QModelIndex& /*index*/) const
 
1315
QSize ColorSchemeViewDelegate::sizeHint(const QStyleOptionViewItem& option,
 
1316
                                        const QModelIndex& /*index*/) const
1421
1317
{
1422
1318
    const int width = 200;
1423
1319
    qreal colorWidth = (qreal)width / TABLE_COLORS;
1424
1320
    int margin = 5;
1425
 
    qreal heightForWidth = ( colorWidth * 2 ) + option.fontMetrics.height() + margin;
 
1321
    qreal heightForWidth = (colorWidth * 2) + option.fontMetrics.height() + margin;
1426
1322
 
1427
1323
    // temporary
1428
 
    return QSize(width,(int)heightForWidth);
 
1324
    return QSize(width, (int)heightForWidth);
1429
1325
}
1430
1326
 
1431
1327
#include "EditProfileDialog.moc"