00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "EditProfileDialog.h"
00022
00023
00024 #include <QtGui/QKeyEvent>
00025 #include <QtGui/QBrush>
00026 #include <QtGui/QPainter>
00027 #include <QtGui/QStandardItem>
00028 #include <QtCore/QTextCodec>
00029 #include <QtGui/QTextEdit>
00030 #include <QtGui/QLinearGradient>
00031 #include <QtGui/QRadialGradient>
00032
00033 #include <QtCore/QTimer>
00034 #include <QtCore/QTimeLine>
00035
00036
00037 #include <kcodecaction.h>
00038 #include <KDebug>
00039 #include <KFontDialog>
00040 #include <KIcon>
00041 #include <KIconDialog>
00042 #include <KFileDialog>
00043 #include <KUrlCompletion>
00044 #include <KWindowSystem>
00045
00046
00047 #include "ColorScheme.h"
00048 #include "ColorSchemeEditor.h"
00049 #include "ui_EditProfileDialog.h"
00050 #include "KeyBindingEditor.h"
00051 #include "KeyboardTranslator.h"
00052 #include "SessionManager.h"
00053 #include "ShellCommand.h"
00054 #include "TabTitleFormatAction.h"
00055
00056 using namespace Konsole;
00057
00058 EditProfileDialog::EditProfileDialog(QWidget* parent)
00059 : KDialog(parent)
00060 , _colorSchemeAnimationTimeLine(0)
00061 , _delayedPreviewTimer(new QTimer(this))
00062 {
00063 setCaption(i18n("Edit Profile"));
00064 setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );
00065
00066 connect( this , SIGNAL(applyClicked()) , this , SLOT(save()) );
00067 connect( _delayedPreviewTimer , SIGNAL(timeout()) , this , SLOT(delayedPreviewActivate()) );
00068 _ui = new Ui::EditProfileDialog();
00069 _ui->setupUi(mainWidget());
00070
00071
00072 _ui->enableResizeWindowButton->setVisible(false);
00073
00074 #warning "Re-enable when flow control is working again - bug in KDE 4.1"
00075 _ui->enableFlowControlButton->setEnabled(false);
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 _pageNeedsUpdate.resize( _ui->tabWidget->count() );
00088 connect( _ui->tabWidget , SIGNAL(currentChanged(int)) , this ,
00089 SLOT(preparePage(int)) );
00090
00091 _tempProfile = new Profile;
00092 _tempProfile->setHidden(true);
00093 }
00094 EditProfileDialog::~EditProfileDialog()
00095 {
00096 delete _ui;
00097 }
00098 void EditProfileDialog::save()
00099 {
00100 if ( _tempProfile->isEmpty() )
00101 return;
00102
00103 SessionManager::instance()->changeProfile(_profile,_tempProfile->setProperties());
00104
00105
00106
00107 QHashIterator<Profile::Property,QVariant> iter(_tempProfile->setProperties());
00108 while ( iter.hasNext() )
00109 {
00110 iter.next();
00111 _previewedProperties.remove(iter.key());
00112 }
00113 }
00114 void EditProfileDialog::reject()
00115 {
00116 unpreviewAll();
00117 KDialog::reject();
00118 }
00119 void EditProfileDialog::accept()
00120 {
00121 save();
00122 unpreviewAll();
00123 KDialog::accept();
00124 }
00125 QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr group, int maxLength)
00126 {
00127 QString caption;
00128 int count = group->profiles().count();
00129 for (int i=0;i < count;i++)
00130 {
00131 caption += group->profiles()[i]->name();
00132 if (i < (count-1))
00133 {
00134 caption += ',';
00135
00136 if (maxLength > 0 && caption.length() > maxLength)
00137 {
00138 caption += "...";
00139 break;
00140 }
00141 }
00142 }
00143 return caption;
00144 }
00145 void EditProfileDialog::updateCaption(const Profile::Ptr profile)
00146 {
00147 const int MAX_GROUP_CAPTION_LENGTH = 25;
00148 ProfileGroup::Ptr group = profile->asGroup();
00149 if (group && group->profiles().count() > 1)
00150 {
00151 QString caption = groupProfileNames(group,MAX_GROUP_CAPTION_LENGTH);
00152 setCaption( i18n("Edit Profile \"%1\"",caption) );
00153
00154
00155 }
00156 else
00157 setCaption( i18n("Edit Profile \"%1\"",profile->name()) );
00158 }
00159 void EditProfileDialog::setProfile(Profile::Ptr profile)
00160 {
00161 _profile = profile;
00162
00163 Q_ASSERT( profile );
00164
00165
00166 updateCaption(profile);
00167
00168
00169
00170
00171
00172 _pageNeedsUpdate.fill(true);
00173 preparePage( _ui->tabWidget->currentIndex() );
00174
00175 if ( _tempProfile )
00176 {
00177 _tempProfile = new Profile;
00178 }
00179 }
00180 const Profile::Ptr EditProfileDialog::lookupProfile() const
00181 {
00182 return _profile;
00183 }
00184 void EditProfileDialog::preparePage(int page)
00185 {
00186 const Profile::Ptr info = lookupProfile();
00187
00188 Q_ASSERT( _pageNeedsUpdate.count() > page );
00189 Q_ASSERT( info );
00190
00191 QWidget* pageWidget = _ui->tabWidget->widget(page);
00192
00193 if ( _pageNeedsUpdate[page] )
00194 {
00195 if ( pageWidget == _ui->generalTab )
00196 setupGeneralPage(info);
00197 else if ( pageWidget == _ui->tabsTab )
00198 setupTabsPage(info);
00199 else if ( pageWidget == _ui->appearanceTab )
00200 setupAppearancePage(info);
00201 else if ( pageWidget == _ui->scrollingTab )
00202 setupScrollingPage(info);
00203 else if ( pageWidget == _ui->keyboardTab )
00204 setupKeyboardPage(info);
00205 else if ( pageWidget == _ui->advancedTab )
00206 setupAdvancedPage(info);
00207 else
00208 Q_ASSERT(false);
00209
00210 _pageNeedsUpdate[page] = false;
00211 }
00212
00213
00214 if ( pageWidget == _ui->appearanceTab )
00215 _colorSchemeAnimationTimeLine->start();
00216 }
00217 void EditProfileDialog::selectProfileName()
00218 {
00219 _ui->profileNameEdit->selectAll();
00220 _ui->profileNameEdit->setFocus();
00221 }
00222 void EditProfileDialog::setupGeneralPage(const Profile::Ptr info)
00223 {
00224
00225 {
00226 ProfileGroup::Ptr group = info->asGroup();
00227 if (!group || group->profiles().count() < 2)
00228 _ui->profileNameEdit->setText( info->name() );
00229 else
00230 {
00231 _ui->profileNameEdit->setText( groupProfileNames(group,-1) );
00232 _ui->profileNameLabel->setEnabled(false);
00233 _ui->profileNameEdit->setEnabled(false);
00234 }
00235 }
00236
00237 ShellCommand command( info->command() , info->arguments() );
00238 _ui->commandEdit->setText( command.fullCommand() );
00239
00240 KUrlCompletion* exeCompletion = new KUrlCompletion(KUrlCompletion::ExeCompletion);
00241 exeCompletion->setParent(this);
00242 exeCompletion->setDir(QString());
00243 _ui->commandEdit->setCompletionObject( exeCompletion );
00244 _ui->initialDirEdit->setText( info->defaultWorkingDirectory() );
00245
00246 KUrlCompletion* dirCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion);
00247 dirCompletion->setParent(this);
00248 _ui->initialDirEdit->setCompletionObject( dirCompletion );
00249 _ui->initialDirEdit->setClearButtonShown(true);
00250 _ui->dirSelectButton->setIcon( KIcon("folder-open") );
00251 _ui->iconSelectButton->setIcon( KIcon(info->icon()) );
00252 _ui->startInSameDirButton->setChecked(info->property<bool>(Profile::StartInCurrentSessionDir));
00253
00254
00255 _ui->showMenuBarButton->setChecked( info->property<bool>(Profile::ShowMenuBar) );
00256
00257
00258 connect( _ui->dirSelectButton , SIGNAL(clicked()) , this , SLOT(selectInitialDir()) );
00259 connect( _ui->iconSelectButton , SIGNAL(clicked()) , this , SLOT(selectIcon()) );
00260 connect( _ui->startInSameDirButton , SIGNAL(toggled(bool)) , this ,
00261 SLOT(startInSameDir(bool)));
00262 connect( _ui->profileNameEdit , SIGNAL(textChanged(const QString&)) , this ,
00263 SLOT(profileNameChanged(const QString&)) );
00264 connect( _ui->initialDirEdit , SIGNAL(textChanged(const QString&)) , this ,
00265 SLOT(initialDirChanged(const QString&)) );
00266 connect(_ui->commandEdit , SIGNAL(textChanged(const QString&)) , this ,
00267 SLOT(commandChanged(const QString&)) );
00268
00269 connect(_ui->showMenuBarButton , SIGNAL(toggled(bool)) , this ,
00270 SLOT(showMenuBar(bool)) );
00271
00272 connect(_ui->environmentEditButton , SIGNAL(clicked()) , this ,
00273 SLOT(showEnvironmentEditor()) );
00274 }
00275 void EditProfileDialog::showEnvironmentEditor()
00276 {
00277 const Profile::Ptr info = lookupProfile();
00278
00279 KDialog* dialog = new KDialog(this);
00280 QTextEdit* edit = new QTextEdit(dialog);
00281
00282 QStringList currentEnvironment = info->property<QStringList>(Profile::Environment);
00283
00284 edit->setPlainText( currentEnvironment.join("\n") );
00285 dialog->setPlainCaption(i18n("Edit Environment"));
00286 dialog->setMainWidget(edit);
00287
00288 if ( dialog->exec() == QDialog::Accepted )
00289 {
00290 QStringList newEnvironment = edit->toPlainText().split('\n');
00291 _tempProfile->setProperty(Profile::Environment,newEnvironment);
00292 }
00293
00294 dialog->deleteLater();
00295 }
00296 void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
00297 {
00298
00299 _ui->tabTitleEdit->setClearButtonShown(true);
00300 _ui->remoteTabTitleEdit->setClearButtonShown(true);
00301 _ui->tabTitleEdit->setText( info->property<QString>(Profile::LocalTabTitleFormat) );
00302 _ui->remoteTabTitleEdit->setText(
00303 info->property<QString>(Profile::RemoteTabTitleFormat));
00304
00305
00306 int tabMode = info->property<int>(Profile::TabBarMode);
00307 int tabPosition = info->property<int>(Profile::TabBarPosition);
00308
00309
00310
00311 _ui->tabBarVisibilityCombo->addItems( QStringList() << i18n("Always Hide Tab Bar")
00312 << i18n("Show Tab Bar When Needed")
00313 << i18n("Always Show Tab Bar") );
00314 _ui->tabBarVisibilityCombo->setCurrentIndex(tabMode);
00315
00316
00317
00318 _ui->tabBarPositionCombo->addItems( QStringList() << i18n("Below Terminal Displays")
00319 << i18n("Above Terminal Displays") );
00320
00321 _ui->tabBarPositionCombo->setCurrentIndex(tabPosition);
00322 _ui->newTabButton->setChecked(info->property<bool>(Profile::ShowNewAndCloseTabButtons));
00323
00324
00325 connect( _ui->tabBarVisibilityCombo , SIGNAL(activated(int)) , this ,
00326 SLOT(tabBarVisibilityChanged(int)) );
00327 connect( _ui->tabBarPositionCombo , SIGNAL(activated(int)) , this ,
00328 SLOT(tabBarPositionChanged(int)) );
00329 connect( _ui->newTabButton , SIGNAL(toggled(bool)) , this ,
00330 SLOT(showNewTabButton(bool)) );
00331
00332 connect(_ui->tabTitleEdit , SIGNAL(textChanged(const QString&)) , this ,
00333 SLOT(tabTitleFormatChanged(const QString&)) );
00334 connect(_ui->remoteTabTitleEdit , SIGNAL(textChanged(const QString&)) , this ,
00335 SLOT(remoteTabTitleFormatChanged(const QString&)));
00336
00337
00338 TabTitleFormatAction* localTabTitleAction = new TabTitleFormatAction(this);
00339 localTabTitleAction->setContext(Session::LocalTabTitle);
00340 _ui->tabTitleEditButton->setMenu(localTabTitleAction->menu());
00341 connect( localTabTitleAction , SIGNAL(dynamicElementSelected(const QString&)) ,
00342 this , SLOT(insertTabTitleText(const QString&)) );
00343
00344 TabTitleFormatAction* remoteTabTitleAction = new TabTitleFormatAction(this);
00345 remoteTabTitleAction->setContext(Session::RemoteTabTitle);
00346 _ui->remoteTabTitleEditButton->setMenu(remoteTabTitleAction->menu());
00347 connect( remoteTabTitleAction , SIGNAL(dynamicElementSelected(const QString&)) ,
00348 this , SLOT(insertRemoteTabTitleText(const QString&)) );
00349 }
00350 void EditProfileDialog::showNewTabButton(bool show)
00351 { _tempProfile->setProperty(Profile::ShowNewAndCloseTabButtons,show); }
00352 void EditProfileDialog::tabBarVisibilityChanged(int newValue)
00353 {
00354 _tempProfile->setProperty( Profile::TabBarMode , newValue );
00355 }
00356 void EditProfileDialog::tabBarPositionChanged(int newValue)
00357 {
00358 _tempProfile->setProperty( Profile::TabBarPosition , newValue );
00359 }
00360 void EditProfileDialog::insertTabTitleText(const QString& text)
00361 {
00362 _ui->tabTitleEdit->insert(text);
00363 }
00364 void EditProfileDialog::insertRemoteTabTitleText(const QString& text)
00365 {
00366 _ui->remoteTabTitleEdit->insert(text);
00367 }
00368 void EditProfileDialog::showMenuBar(bool show)
00369 {
00370 _tempProfile->setProperty(Profile::ShowMenuBar,show);
00371 }
00372 void EditProfileDialog::tabTitleFormatChanged(const QString& format)
00373 {
00374 _tempProfile->setProperty(Profile::LocalTabTitleFormat,format);
00375 }
00376 void EditProfileDialog::remoteTabTitleFormatChanged(const QString& format)
00377 {
00378 _tempProfile->setProperty(Profile::RemoteTabTitleFormat,format);
00379 }
00380
00381 void EditProfileDialog::selectIcon()
00382 {
00383 const QString& icon = KIconDialog::getIcon(KIconLoader::Desktop, KIconLoader::Application,
00384 false, 0, false, this);
00385 if (!icon.isEmpty())
00386 {
00387 _ui->iconSelectButton->setIcon( KIcon(icon) );
00388 _tempProfile->setProperty(Profile::Icon,icon);
00389 }
00390 }
00391 void EditProfileDialog::profileNameChanged(const QString& text)
00392 {
00393 _tempProfile->setProperty(Profile::Name,text);
00394 updateCaption(_tempProfile);
00395 }
00396 void EditProfileDialog::startInSameDir(bool sameDir)
00397 {
00398 _tempProfile->setProperty(Profile::StartInCurrentSessionDir,sameDir);
00399 }
00400 void EditProfileDialog::initialDirChanged(const QString& dir)
00401 {
00402 _tempProfile->setProperty(Profile::Directory,dir);
00403 }
00404 void EditProfileDialog::commandChanged(const QString& command)
00405 {
00406 ShellCommand shellCommand(command);
00407
00408 _tempProfile->setProperty(Profile::Command,shellCommand.command());
00409 _tempProfile->setProperty(Profile::Arguments,shellCommand.arguments());
00410 }
00411 void EditProfileDialog::selectInitialDir()
00412 {
00413 const KUrl url = KFileDialog::getExistingDirectoryUrl(_ui->initialDirEdit->text(),
00414 this,
00415 i18n("Select Initial Directory"));
00416
00417 if ( !url.isEmpty() )
00418 _ui->initialDirEdit->setText(url.path());
00419 }
00420 void EditProfileDialog::setupAppearancePage(const Profile::Ptr info)
00421 {
00422 ColorSchemeViewDelegate* delegate = new ColorSchemeViewDelegate(this);
00423 _ui->colorSchemeList->setItemDelegate(delegate);
00424
00425 _colorSchemeAnimationTimeLine = new QTimeLine( 500 , this );
00426 delegate->setEntryTimeLine(_colorSchemeAnimationTimeLine);
00427
00428 connect( _colorSchemeAnimationTimeLine , SIGNAL(valueChanged(qreal)) , this ,
00429 SLOT(colorSchemeAnimationUpdate()) );
00430
00431 _ui->transparencyWarningWidget->setVisible(false);
00432 _ui->transparencyWarningWidget->setText(i18n("This color scheme uses a transparent background"
00433 " which does not appear to be supported on your"
00434 " desktop"));
00435 _ui->editColorSchemeButton->setEnabled(false);
00436 _ui->removeColorSchemeButton->setEnabled(false);
00437
00438
00439 updateColorSchemeList(true);
00440
00441 _ui->colorSchemeList->setMouseTracking(true);
00442 _ui->colorSchemeList->installEventFilter(this);
00443 _ui->colorSchemeList->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
00444
00445 connect( _ui->colorSchemeList->selectionModel() ,
00446 SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&))
00447 , this , SLOT(colorSchemeSelected()) );
00448 connect( _ui->colorSchemeList , SIGNAL(entered(const QModelIndex&)) , this ,
00449 SLOT(previewColorScheme(const QModelIndex&)) );
00450
00451 updateColorSchemeButtons();
00452
00453 connect( _ui->editColorSchemeButton , SIGNAL(clicked()) , this ,
00454 SLOT(editColorScheme()) );
00455 connect( _ui->removeColorSchemeButton , SIGNAL(clicked()) , this ,
00456 SLOT(removeColorScheme()) );
00457 connect( _ui->newColorSchemeButton , SIGNAL(clicked()) , this ,
00458 SLOT(newColorScheme()) );
00459
00460
00461 bool antialias = info->property<bool>(Profile::AntiAliasFonts);
00462
00463 QFont font = info->font();
00464 if (!antialias)
00465 font.setStyleStrategy(QFont::NoAntialias);
00466
00467 _ui->fontPreviewLabel->installEventFilter(this);
00468 _ui->fontPreviewLabel->setFont(font);
00469 _ui->fontSizeSlider->setValue( font.pointSize() );
00470 _ui->fontSizeSlider->setMinimum( KGlobalSettings::smallestReadableFont().pointSize() );
00471
00472 connect( _ui->fontSizeSlider , SIGNAL(valueChanged(int)) , this ,
00473 SLOT(setFontSize(int)) );
00474 connect( _ui->editFontButton , SIGNAL(clicked()) , this ,
00475 SLOT(showFontDialog()) );
00476
00477
00478 _ui->antialiasTextButton->setChecked(antialias);
00479 connect( _ui->antialiasTextButton , SIGNAL(toggled(bool)) , this ,
00480 SLOT(setAntialiasText(bool)) );
00481 }
00482 void EditProfileDialog::setAntialiasText(bool enable)
00483 {
00484 _tempProfile->setProperty(Profile::AntiAliasFonts,enable);
00485
00486
00487 fontSelected(_ui->fontPreviewLabel->font());
00488 }
00489 void EditProfileDialog::colorSchemeAnimationUpdate()
00490 {
00491 QAbstractItemModel* model = _ui->colorSchemeList->model();
00492
00493 for ( int i = model->rowCount() ; i >= 0 ; i-- )
00494 _ui->colorSchemeList->update( model->index(i,0) );
00495 }
00496 void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
00497 {
00498 if (!_ui->colorSchemeList->model())
00499 _ui->colorSchemeList->setModel(new QStandardItemModel(this));
00500
00501 const QString& name = lookupProfile()->colorScheme();
00502 const ColorScheme* currentScheme = ColorSchemeManager::instance()->findColorScheme(name);
00503
00504 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_ui->colorSchemeList->model());
00505
00506 Q_ASSERT(model);
00507
00508 model->clear();
00509
00510 QList<const ColorScheme*> schemeList = ColorSchemeManager::instance()->allColorSchemes();
00511 QListIterator<const ColorScheme*> schemeIter(schemeList);
00512
00513 QStandardItem* selectedItem = 0;
00514
00515 while (schemeIter.hasNext())
00516 {
00517 const ColorScheme* colors = schemeIter.next();
00518 QStandardItem* item = new QStandardItem(colors->description());
00519 item->setData( QVariant::fromValue(colors) , Qt::UserRole + 1);
00520 item->setFlags( item->flags() );
00521
00522 if ( currentScheme == colors )
00523 selectedItem = item;
00524
00525 model->appendRow(item);
00526 }
00527
00528 model->sort(0);
00529
00530 if ( selectCurrentScheme && selectedItem )
00531 {
00532 _ui->colorSchemeList->updateGeometry();
00533 _ui->colorSchemeList->selectionModel()->setCurrentIndex( selectedItem->index() ,
00534 QItemSelectionModel::Select );
00535
00536
00537 updateTransparencyWarning();
00538 }
00539 }
00540 void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator)
00541 {
00542 if (!_ui->keyBindingList->model())
00543 _ui->keyBindingList->setModel(new QStandardItemModel(this));
00544
00545 KeyboardTranslatorManager* keyManager = KeyboardTranslatorManager::instance();
00546
00547 const QString& name = lookupProfile()
00548 ->property<QString>(Profile::KeyBindings);
00549
00550 const KeyboardTranslator* currentTranslator = keyManager->findTranslator(name);
00551
00552 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(_ui->keyBindingList->model());
00553
00554 Q_ASSERT(model);
00555
00556 model->clear();
00557
00558 QStandardItem* selectedItem = 0;
00559
00560 QList<QString> translatorNames = keyManager->allTranslators();
00561 QListIterator<QString> iter(translatorNames);
00562 while (iter.hasNext())
00563 {
00564 const QString& name = iter.next();
00565
00566 const KeyboardTranslator* translator = keyManager->findTranslator(name);
00567
00568 QStandardItem* item = new QStandardItem(translator->description());
00569 item->setData(QVariant::fromValue(translator),Qt::UserRole+1);
00570 item->setIcon( KIcon("preferences-desktop-keyboard") );
00571
00572 if ( translator == currentTranslator )
00573 selectedItem = item;
00574
00575 model->appendRow(item);
00576 }
00577
00578 model->sort(0);
00579
00580 if ( selectCurrentTranslator && selectedItem )
00581 {
00582 _ui->keyBindingList->selectionModel()->setCurrentIndex( selectedItem->index() ,
00583 QItemSelectionModel::Select );
00584 }
00585 }
00586 bool EditProfileDialog::eventFilter( QObject* watched , QEvent* event )
00587 {
00588 if ( watched == _ui->colorSchemeList && event->type() == QEvent::Leave )
00589 {
00590 if ( _tempProfile->isPropertySet(Profile::ColorScheme) )
00591 preview(Profile::ColorScheme,_tempProfile->colorScheme());
00592 else
00593 unpreview(Profile::ColorScheme);
00594 }
00595 if ( watched == _ui->fontPreviewLabel && event->type() == QEvent::FontChange )
00596 {
00597 const QFont& labelFont = _ui->fontPreviewLabel->font();
00598 _ui->fontPreviewLabel->setText(i18n("%1, size %2",labelFont.family(),labelFont.pointSize()));
00599 }
00600
00601 return KDialog::eventFilter(watched,event);
00602 }
00603 void EditProfileDialog::unpreviewAll()
00604 {
00605 _delayedPreviewTimer->stop();
00606 _delayedPreviewProperties.clear();
00607
00608 QHash<Profile::Property,QVariant> map;
00609 QHashIterator<int,QVariant> iter(_previewedProperties);
00610 while ( iter.hasNext() )
00611 {
00612 iter.next();
00613 map.insert((Profile::Property)iter.key(),iter.value());
00614 }
00615
00616
00617 if ( !map.isEmpty() )
00618 SessionManager::instance()->changeProfile(_profile,map,false);
00619 }
00620 void EditProfileDialog::unpreview(int property)
00621 {
00622 _delayedPreviewProperties.remove(property);
00623
00624 if (!_previewedProperties.contains(property))
00625 return;
00626
00627 QHash<Profile::Property,QVariant> map;
00628 map.insert((Profile::Property)property,_previewedProperties[property]);
00629 SessionManager::instance()->changeProfile(_profile,map,false);
00630
00631 _previewedProperties.remove(property);
00632 }
00633 void EditProfileDialog::delayedPreview(int property , const QVariant& value)
00634 {
00635 _delayedPreviewProperties.insert(property,value);
00636
00637 _delayedPreviewTimer->stop();
00638 _delayedPreviewTimer->start(300);
00639 }
00640 void EditProfileDialog::delayedPreviewActivate()
00641 {
00642 Q_ASSERT( qobject_cast<QTimer*>(sender()) );
00643
00644 QMutableHashIterator<int,QVariant> iter(_delayedPreviewProperties);
00645 if ( iter.hasNext() )
00646 {
00647 iter.next();
00648 preview(iter.key(),iter.value());
00649 }
00650 }
00651 void EditProfileDialog::preview(int property , const QVariant& value)
00652 {
00653 QHash<Profile::Property,QVariant> map;
00654 map.insert((Profile::Property)property,value);
00655
00656 _delayedPreviewProperties.remove(property);
00657
00658 const Profile::Ptr original = lookupProfile();
00659
00660
00661
00662
00663
00664 ProfileGroup::Ptr group = original->asGroup();
00665 if (group && group->profiles().count() > 1 &&
00666 original->property<QVariant>((Profile::Property)property).isNull())
00667 return;
00668
00669 if (!_previewedProperties.contains(property))
00670 {
00671 _previewedProperties.insert(property , original->property<QVariant>((Profile::Property)property) );
00672 }
00673
00674
00675 SessionManager::instance()->changeProfile( _profile , map , false);
00676 }
00677 void EditProfileDialog::previewColorScheme(const QModelIndex& index)
00678 {
00679 const QString& name = index.data(Qt::UserRole+1).value<const ColorScheme*>()->name();
00680
00681 delayedPreview( Profile::ColorScheme , name );
00682 }
00683 void EditProfileDialog::removeColorScheme()
00684 {
00685 QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
00686
00687 if ( !selected.isEmpty() )
00688 {
00689 const QString& name = selected.first().data(Qt::UserRole+1).value<const ColorScheme*>()->name();
00690
00691 if (ColorSchemeManager::instance()->deleteColorScheme(name))
00692 _ui->colorSchemeList->model()->removeRow(selected.first().row());
00693 }
00694 }
00695 void EditProfileDialog::showColorSchemeEditor(bool isNewScheme)
00696 {
00697 QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
00698
00699 QAbstractItemModel* model = _ui->colorSchemeList->model();
00700 const ColorScheme* colors = 0;
00701 if ( !selected.isEmpty() )
00702 colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
00703 else
00704 colors = ColorSchemeManager::instance()->defaultColorScheme();
00705
00706 Q_ASSERT(colors);
00707
00708 KDialog* dialog = new KDialog(this);
00709
00710 if ( isNewScheme )
00711 dialog->setCaption(i18n("New Color Scheme"));
00712 else
00713 dialog->setCaption(i18n("Edit Color Scheme"));
00714
00715 ColorSchemeEditor* editor = new ColorSchemeEditor;
00716 dialog->setMainWidget(editor);
00717 editor->setup(colors);
00718
00719 if ( isNewScheme )
00720 editor->setDescription(i18n("New Color Scheme"));
00721
00722 if ( dialog->exec() == QDialog::Accepted )
00723 {
00724 ColorScheme* newScheme = new ColorScheme(*editor->colorScheme());
00725
00726
00727 if ( isNewScheme )
00728 newScheme->setName(newScheme->description());
00729
00730 ColorSchemeManager::instance()->addColorScheme( newScheme );
00731
00732 updateColorSchemeList(true);
00733
00734 preview(Profile::ColorScheme,newScheme->name());
00735 }
00736 }
00737 void EditProfileDialog::newColorScheme()
00738 {
00739 showColorSchemeEditor(true);
00740 }
00741 void EditProfileDialog::editColorScheme()
00742 {
00743 showColorSchemeEditor(false);
00744 }
00745 void EditProfileDialog::colorSchemeSelected()
00746 {
00747 QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
00748
00749 if ( !selected.isEmpty() )
00750 {
00751 QAbstractItemModel* model = _ui->colorSchemeList->model();
00752 const ColorScheme* colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
00753
00754 kDebug() << "Setting temp profile color to" << colors->name();
00755
00756 previewColorScheme(selected.first());
00757 _tempProfile->setProperty(Profile::ColorScheme,colors->name());
00758
00759 updateTransparencyWarning();
00760 }
00761
00762 updateColorSchemeButtons();
00763 }
00764 void EditProfileDialog::updateColorSchemeButtons()
00765 {
00766 enableIfNonEmptySelection(_ui->editColorSchemeButton,_ui->colorSchemeList->selectionModel());
00767 enableIfNonEmptySelection(_ui->removeColorSchemeButton,_ui->colorSchemeList->selectionModel());
00768 }
00769 void EditProfileDialog::updateKeyBindingsButtons()
00770 {
00771 enableIfNonEmptySelection(_ui->editKeyBindingsButton,_ui->keyBindingList->selectionModel());
00772 enableIfNonEmptySelection(_ui->removeKeyBindingsButton,_ui->keyBindingList->selectionModel());
00773 }
00774 void EditProfileDialog::enableIfNonEmptySelection(QWidget* widget,QItemSelectionModel* selectionModel)
00775 {
00776 widget->setEnabled(selectionModel->hasSelection());
00777 }
00778 void EditProfileDialog::updateTransparencyWarning()
00779 {
00780
00781 foreach( const QModelIndex& index , _ui->colorSchemeList->selectionModel()->selectedIndexes() )
00782 {
00783 bool hasTransparency = index.data(Qt::UserRole+1).value<const ColorScheme*>()->opacity() < 1.0;
00784 _ui->transparencyWarningWidget->setHidden(KWindowSystem::compositingActive() || !hasTransparency);
00785 }
00786 }
00787 void EditProfileDialog::setupKeyboardPage(const Profile::Ptr )
00788 {
00789
00790 updateKeyBindingsList(true);
00791
00792 connect( _ui->keyBindingList->selectionModel() ,
00793 SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
00794 SLOT(keyBindingSelected()) );
00795 connect( _ui->newKeyBindingsButton , SIGNAL(clicked()) , this ,
00796 SLOT(newKeyBinding()) );
00797
00798 updateKeyBindingsButtons();
00799
00800 connect( _ui->editKeyBindingsButton , SIGNAL(clicked()) , this ,
00801 SLOT(editKeyBinding()) );
00802 connect( _ui->removeKeyBindingsButton , SIGNAL(clicked()) , this ,
00803 SLOT(removeKeyBinding()) );
00804 }
00805 void EditProfileDialog::keyBindingSelected()
00806 {
00807 QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
00808
00809 if ( !selected.isEmpty() )
00810 {
00811 QAbstractItemModel* model = _ui->keyBindingList->model();
00812 const KeyboardTranslator* translator = model->data(selected.first(),Qt::UserRole+1)
00813 .value<const KeyboardTranslator*>();
00814 _tempProfile->setProperty(Profile::KeyBindings,translator->name());
00815 }
00816
00817 updateKeyBindingsButtons();
00818 }
00819 void EditProfileDialog::removeKeyBinding()
00820 {
00821 QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
00822
00823 if ( !selected.isEmpty() )
00824 {
00825 const QString& name = selected.first().data(Qt::UserRole+1).value<const KeyboardTranslator*>()->name();
00826 if (KeyboardTranslatorManager::instance()->deleteTranslator(name))
00827 _ui->keyBindingList->model()->removeRow(selected.first().row());
00828 }
00829 }
00830 void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
00831 {
00832 QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
00833 QAbstractItemModel* model = _ui->keyBindingList->model();
00834
00835 const KeyboardTranslator* translator = 0;
00836 if ( !selected.isEmpty() )
00837 translator = model->data(selected.first(),Qt::UserRole+1).value<const KeyboardTranslator*>();
00838 else
00839 translator = KeyboardTranslatorManager::instance()->defaultTranslator();
00840
00841 Q_ASSERT(translator);
00842
00843 KDialog* dialog = new KDialog(this);
00844
00845 if ( isNewTranslator )
00846 dialog->setCaption(i18n("New Key Binding List"));
00847 else
00848 dialog->setCaption(i18n("Edit Key Binding List"));
00849
00850 KeyBindingEditor* editor = new KeyBindingEditor;
00851 dialog->setMainWidget(editor);
00852
00853 if ( translator )
00854 editor->setup(translator);
00855
00856 if ( isNewTranslator )
00857 editor->setDescription(i18n("New Key Binding List"));
00858
00859 if ( dialog->exec() == QDialog::Accepted )
00860 {
00861 KeyboardTranslator* newTranslator = new KeyboardTranslator(*editor->translator());
00862
00863 if ( isNewTranslator )
00864 newTranslator->setName(newTranslator->description());
00865
00866 KeyboardTranslatorManager::instance()->addTranslator( newTranslator );
00867
00868 updateKeyBindingsList();
00869
00870 const QString& currentTranslator = lookupProfile()
00871 ->property<QString>(Profile::KeyBindings);
00872
00873 if ( newTranslator->name() == currentTranslator )
00874 {
00875 _tempProfile->setProperty(Profile::KeyBindings,newTranslator->name());
00876 }
00877 }
00878 }
00879 void EditProfileDialog::newKeyBinding()
00880 {
00881 showKeyBindingEditor(true);
00882 }
00883 void EditProfileDialog::editKeyBinding()
00884 {
00885 showKeyBindingEditor(false);
00886 }
00887 void EditProfileDialog::setupCombo( ComboOption* options , const Profile::Ptr profile )
00888 {
00889 while ( options->button != 0 )
00890 {
00891 options->button->setChecked(profile->property<bool>((Profile::Property)options->property));
00892 connect( options->button , SIGNAL(toggled(bool)) , this , options->slot );
00893
00894 ++options;
00895 }
00896 }
00897 void EditProfileDialog::setupRadio( RadioOption* possible , int actual )
00898 {
00899 while (possible->button != 0)
00900 {
00901 if ( possible->property == actual )
00902 possible->button->setChecked(true);
00903 else
00904 possible->button->setChecked(false);
00905
00906 connect( possible->button , SIGNAL(clicked()) , this , possible->slot );
00907
00908 ++possible;
00909 }
00910 }
00911
00912 void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile)
00913 {
00914
00915 int scrollBarPosition = profile->property<int>(Profile::ScrollBarPosition);
00916
00917 RadioOption positions[] = { {_ui->scrollBarHiddenButton,Profile::ScrollBarHidden,SLOT(hideScrollBar())},
00918 {_ui->scrollBarLeftButton,Profile::ScrollBarLeft,SLOT(showScrollBarLeft())},
00919 {_ui->scrollBarRightButton,Profile::ScrollBarRight,SLOT(showScrollBarRight())},
00920 {0,0,0}
00921 };
00922
00923 setupRadio( positions , scrollBarPosition );
00924
00925
00926 int scrollBackType = profile->property<int>(Profile::HistoryMode);
00927
00928 RadioOption types[] = { {_ui->disableScrollbackButton,Profile::DisableHistory,SLOT(noScrollBack())},
00929 {_ui->fixedScrollbackButton,Profile::FixedSizeHistory,SLOT(fixedScrollBack())},
00930 {_ui->unlimitedScrollbackButton,Profile::UnlimitedHistory,SLOT(unlimitedScrollBack())},
00931 {0,0,0} };
00932 setupRadio( types , scrollBackType );
00933
00934
00935 _ui->scrollBackLinesSpinner->setValue( profile->property<int>(Profile::HistorySize) );
00936
00937
00938 connect( _ui->scrollBackLinesSpinner , SIGNAL(valueChanged(int)) , this ,
00939 SLOT(scrollBackLinesChanged(int)) );
00940 }
00941
00942 void EditProfileDialog::scrollBackLinesChanged(int lineCount)
00943 {
00944 _tempProfile->setProperty(Profile::HistorySize , lineCount);
00945 }
00946 void EditProfileDialog::noScrollBack()
00947 {
00948 _tempProfile->setProperty(Profile::HistoryMode , Profile::DisableHistory);
00949 }
00950 void EditProfileDialog::fixedScrollBack()
00951 {
00952 _tempProfile->setProperty(Profile::HistoryMode , Profile::FixedSizeHistory);
00953 }
00954 void EditProfileDialog::unlimitedScrollBack()
00955 {
00956 _tempProfile->setProperty(Profile::HistoryMode , Profile::UnlimitedHistory );
00957 }
00958 void EditProfileDialog::hideScrollBar()
00959 {
00960 _tempProfile->setProperty(Profile::ScrollBarPosition , Profile::ScrollBarHidden );
00961 }
00962 void EditProfileDialog::showScrollBarLeft()
00963 {
00964 _tempProfile->setProperty(Profile::ScrollBarPosition , Profile::ScrollBarLeft );
00965 }
00966 void EditProfileDialog::showScrollBarRight()
00967 {
00968 _tempProfile->setProperty(Profile::ScrollBarPosition , Profile::ScrollBarRight );
00969 }
00970 void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
00971 {
00972 ComboOption options[] = { { _ui->enableBlinkingTextButton , Profile::BlinkingTextEnabled ,
00973 SLOT(toggleBlinkingText(bool)) },
00974 { _ui->enableFlowControlButton , Profile::FlowControlEnabled ,
00975 SLOT(toggleFlowControl(bool)) },
00976 { _ui->enableResizeWindowButton , Profile::AllowProgramsToResizeWindow ,
00977 SLOT(toggleResizeWindow(bool)) },
00978 { _ui->enableBlinkingCursorButton , Profile::BlinkingCursorEnabled ,
00979 SLOT(toggleBlinkingCursor(bool)) },
00980 { _ui->enableBidiRenderingButton , Profile::BidiRenderingEnabled ,
00981 SLOT(togglebidiRendering(bool)) },
00982 { 0 , 0 , 0 }
00983 };
00984 setupCombo( options , profile );
00985
00986
00987 _ui->wordCharacterEdit->setText( profile->property<QString>(Profile::WordCharacters) );
00988
00989 connect( _ui->wordCharacterEdit , SIGNAL(textChanged(const QString&)) , this ,
00990 SLOT(wordCharactersChanged(const QString&)) );
00991
00992
00993 if ( profile->property<bool>(Profile::UseCustomCursorColor) )
00994 _ui->customCursorColorButton->setChecked(true);
00995 else
00996 _ui->autoCursorColorButton->setChecked(true);
00997
00998 _ui->customColorSelectButton->setColor( profile->property<QColor>(Profile::CustomCursorColor) );
00999
01000 connect( _ui->customCursorColorButton , SIGNAL(clicked()) , this , SLOT(customCursorColor()) );
01001 connect( _ui->autoCursorColorButton , SIGNAL(clicked()) , this , SLOT(autoCursorColor()) );
01002 connect( _ui->customColorSelectButton , SIGNAL(changed(const QColor&)) ,
01003 SLOT(customCursorColorChanged(const QColor&)) );
01004
01005 int shape = profile->property<int>(Profile::CursorShape);
01006 _ui->cursorShapeCombo->setCurrentIndex(shape);
01007
01008 connect( _ui->cursorShapeCombo , SIGNAL(activated(int)) , this , SLOT(setCursorShape(int)) );
01009
01010
01011 QAction* codecAction = new KCodecAction(this);
01012 _ui->selectEncodingButton->setMenu( codecAction->menu() );
01013 connect( codecAction , SIGNAL(triggered(QTextCodec*)) , this , SLOT(setDefaultCodec(QTextCodec*)) );
01014
01015 _ui->characterEncodingLabel->setText( profile->property<QString>(Profile::DefaultEncoding) );
01016
01017 }
01018 void EditProfileDialog::setDefaultCodec(QTextCodec* codec)
01019 {
01020 QString name = QString(codec->name());
01021
01022 _tempProfile->setProperty(Profile::DefaultEncoding,name);
01023 _ui->characterEncodingLabel->setText(codec->name());
01024 }
01025 void EditProfileDialog::customCursorColorChanged(const QColor& color)
01026 {
01027 _tempProfile->setProperty(Profile::CustomCursorColor,color);
01028
01029
01030 _ui->customCursorColorButton->click();
01031 }
01032 void EditProfileDialog::wordCharactersChanged(const QString& text)
01033 {
01034 _tempProfile->setProperty(Profile::WordCharacters,text);
01035 }
01036 void EditProfileDialog::autoCursorColor()
01037 {
01038 _tempProfile->setProperty(Profile::UseCustomCursorColor,false);
01039 }
01040 void EditProfileDialog::customCursorColor()
01041 {
01042 _tempProfile->setProperty(Profile::UseCustomCursorColor,true);
01043 }
01044 void EditProfileDialog::setCursorShape(int index)
01045 {
01046 _tempProfile->setProperty(Profile::CursorShape,index);
01047 }
01048 void EditProfileDialog::togglebidiRendering(bool enable)
01049 {
01050 _tempProfile->setProperty(Profile::BidiRenderingEnabled,enable);
01051 }
01052 void EditProfileDialog::toggleBlinkingCursor(bool enable)
01053 {
01054 _tempProfile->setProperty(Profile::BlinkingCursorEnabled,enable);
01055 }
01056 void EditProfileDialog::toggleBlinkingText(bool enable)
01057 {
01058 _tempProfile->setProperty(Profile::BlinkingTextEnabled,enable);
01059 }
01060 void EditProfileDialog::toggleFlowControl(bool enable)
01061 {
01062 _tempProfile->setProperty(Profile::FlowControlEnabled,enable);
01063 }
01064 void EditProfileDialog::toggleResizeWindow(bool enable)
01065 {
01066 _tempProfile->setProperty(Profile::AllowProgramsToResizeWindow,enable);
01067 }
01068 void EditProfileDialog::fontSelected(const QFont& font)
01069 {
01070 QFont previewFont = font;
01071
01072 QSlider* slider = _ui->fontSizeSlider;
01073 _ui->fontSizeSlider->setRange( qMin(slider->minimum(),font.pointSize()) ,
01074 qMax(slider->maximum(),font.pointSize()) );
01075 _ui->fontSizeSlider->setValue(font.pointSize());
01076
01077
01078 QFont::StyleStrategy strategy;
01079 if (_tempProfile->property<bool>(Profile::AntiAliasFonts))
01080 strategy = QFont::PreferAntialias;
01081 else
01082 strategy = QFont::NoAntialias;
01083
01084 previewFont.setStyleStrategy(strategy);
01085
01086 _ui->fontPreviewLabel->setFont(previewFont);
01087
01088 _tempProfile->setProperty(Profile::Font,font);
01089
01090 preview(Profile::Font,font);
01091 }
01092 void EditProfileDialog::showFontDialog()
01093 {
01094 QFont currentFont = _ui->fontPreviewLabel->font();
01095
01096 KFontDialog* dialog = new KFontDialog(this, KFontChooser::FixedFontsOnly);
01097 dialog->setFont(currentFont, true);
01098
01099 connect( dialog , SIGNAL(fontSelected(const QFont&)) , this , SLOT(fontSelected(const QFont&)) );
01100
01101 if (dialog->exec() == QDialog::Rejected)
01102 fontSelected(currentFont);
01103 }
01104 void EditProfileDialog::setFontSize(int pointSize)
01105 {
01106 QFont newFont = _ui->fontPreviewLabel->font();
01107 newFont.setPointSize(pointSize);
01108 _ui->fontPreviewLabel->setFont(newFont);
01109
01110 _tempProfile->setProperty(Profile::Font,newFont);
01111
01112 preview(Profile::Font,newFont);
01113 }
01114 ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject* parent)
01115 : QAbstractItemDelegate(parent)
01116 {
01117
01118 }
01119
01120 void ColorSchemeViewDelegate::setEntryTimeLine(QTimeLine* timeLine)
01121 {
01122 _entryTimeLine = timeLine;
01123 }
01124
01125 void ColorSchemeViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
01126 const QModelIndex& index) const
01127 {
01128
01129
01130
01131
01132
01133
01134
01135 if ( _entryTimeLine != 0 )
01136 {
01137 qreal value = 1.0-_entryTimeLine->currentValue();
01138 painter->translate( value *
01139 option.rect.width() , 0 );
01140
01141 painter->setOpacity( _entryTimeLine->currentValue() );
01142 }
01143
01144 const ColorScheme* scheme = index.data(Qt::UserRole + 1).value<const ColorScheme*>();
01145
01146 Q_ASSERT(scheme);
01147
01148 bool transparencyAvailable = KWindowSystem::compositingActive();
01149
01150 painter->setRenderHint( QPainter::Antialiasing );
01151
01152
01153 painter->setPen( QPen(scheme->foregroundColor() , 1) );
01154
01155
01156
01157
01158 QColor color = scheme->backgroundColor();
01159 QRectF backgroundRect = QRectF(option.rect).adjusted(1.5,1.5,-1.5,-1.5);
01160
01161 QRadialGradient backgroundGradient(backgroundRect.center() , backgroundRect.width() / 2);
01162 backgroundGradient.setColorAt( 0 , color.lighter(105) );
01163 backgroundGradient.setColorAt( 1 , color.darker(115) );
01164
01165 const int backgroundRectXRoundness = 4;
01166 const int backgroundRectYRoundness = 30;
01167
01168 QPainterPath backgroundRectPath(backgroundRect.topLeft());
01169 backgroundRectPath.addRoundRect( backgroundRect , backgroundRectXRoundness , backgroundRectYRoundness );
01170
01171 if ( transparencyAvailable )
01172 {
01173 painter->save();
01174 color.setAlphaF(scheme->opacity());
01175 painter->setCompositionMode( QPainter::CompositionMode_Source );
01176 painter->setBrush(backgroundGradient);
01177
01178 painter->drawPath(backgroundRectPath);
01179 painter->restore();
01180 }
01181 else
01182 {
01183 painter->setBrush(backgroundGradient);
01184 painter->drawPath(backgroundRectPath);
01185 }
01186
01187
01188 painter->setPen( QPen(Qt::NoPen) );
01189 QPainterPath path( option.rect.topLeft() );
01190 path.lineTo( option.rect.width() / 10.0 , option.rect.top() );
01191 path.lineTo( option.rect.bottomLeft() );
01192 path.lineTo( option.rect.topLeft() );
01193 painter->setBrush( scheme->foregroundColor() );
01194 painter->drawPath(path.intersected(backgroundRectPath));
01195
01196
01197
01198 QLinearGradient gradient( option.rect.topLeft() , option.rect.bottomLeft() );
01199 gradient.setColorAt( 0 , QColor(255,255,255,90) );
01200 gradient.setColorAt( 1 , Qt::transparent );
01201 painter->setBrush(gradient);
01202 painter->drawRoundRect( backgroundRect , 4 , 30 );
01203
01204
01205 const bool isSelected = option.state & QStyle::State_Selected;
01206
01207
01208 if ( isSelected )
01209 {
01210 static const int selectedBorderWidth = 6;
01211
01212
01213 painter->setBrush( QBrush(Qt::NoBrush) );
01214 QPen pen;
01215
01216 QColor highlightColor = option.palette.highlight().color();
01217
01218 if ( isSelected )
01219 highlightColor.setAlphaF(1.0);
01220 else
01221 highlightColor.setAlphaF(0.7);
01222
01223 pen.setBrush(highlightColor);
01224 pen.setWidth(selectedBorderWidth);
01225 pen.setJoinStyle(Qt::MiterJoin);
01226
01227 painter->setPen(pen);
01228
01229
01230 painter->drawRect( option.rect.adjusted(selectedBorderWidth/2,
01231 selectedBorderWidth/2,
01232 -selectedBorderWidth/2,
01233 -selectedBorderWidth/2) );
01234 }
01235
01236
01237 QPen pen(scheme->foregroundColor());
01238 painter->setPen(pen);
01239
01240 painter->drawText( option.rect , Qt::AlignCenter ,
01241 index.data(Qt::DisplayRole).value<QString>() );
01242
01243 }
01244
01245 QSize ColorSchemeViewDelegate::sizeHint( const QStyleOptionViewItem& option,
01246 const QModelIndex& ) const
01247 {
01248 const int width = 200;
01249 qreal colorWidth = (qreal)width / TABLE_COLORS;
01250 int margin = 5;
01251 qreal heightForWidth = ( colorWidth * 2 ) + option.fontMetrics.height() + margin;
01252
01253
01254 return QSize(width,(int)heightForWidth);
01255 }
01256
01257 #include "EditProfileDialog.moc"