From db5bbc67eee45704cd3f7e4a87ce03deba39bc07 Mon Sep 17 00:00:00 2001 From: Sandro Giessl Date: Fri, 3 Dec 2004 19:32:35 +0000 Subject: [PATCH] Replace the border size slider with a combobox. svn path=/trunk/kdebase/kwin/; revision=368162 --- kcmkwin/kwindecoration/kwindecoration.cpp | 61 ++++++++++++----------- kcmkwin/kwindecoration/kwindecoration.h | 2 +- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/kcmkwin/kwindecoration/kwindecoration.cpp b/kcmkwin/kwindecoration/kwindecoration.cpp index d63a915525..21f668a1e2 100644 --- a/kcmkwin/kwindecoration/kwindecoration.cpp +++ b/kcmkwin/kwindecoration/kwindecoration.cpp @@ -102,17 +102,16 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const char* name, co pluginLayout->addStretch(); // Border size chooser - lBorder = new QLabel( pluginSettingsGrp ); - slBorder = new QSlider( Horizontal, pluginSettingsGrp ); - slBorder->setPageStep(1); - QWhatsThis::add( slBorder, i18n( "This slider shows all border sizes supported by this decoration." )); - lBorder->setBuddy( slBorder ); + lBorder = new QLabel (i18n("B&order size:"), pluginSettingsGrp); + cBorder = new QComboBox(pluginSettingsGrp); + lBorder->setBuddy(cBorder); + QWhatsThis::add( cBorder, i18n( "Use this combobox to change the border size of the decoration." )); lBorder->hide(); - slBorder->hide(); - pluginSettingsGrp->layout()->add(lBorder); - QHBoxLayout *sliderIndentLayout = new QHBoxLayout(pluginSettingsGrp->layout() ); - sliderIndentLayout->addSpacing(20); - sliderIndentLayout->addWidget(slBorder); + cBorder->hide(); + QHBoxLayout *borderSizeLayout = new QHBoxLayout(pluginSettingsGrp->layout() ); + borderSizeLayout->addWidget(lBorder); + borderSizeLayout->addWidget(cBorder); + borderSizeLayout->addStretch(); pluginConfigWidget = new QVBox(pluginSettingsGrp); pluginSettingsGrp->layout()->add( pluginConfigWidget ); @@ -186,7 +185,7 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const char* name, co connect(cbUseCustomButtonPositions, SIGNAL(toggled(bool)), buttonBox, SLOT(setEnabled(bool))); connect(cbUseCustomButtonPositions, SIGNAL(toggled(bool)), this, SLOT(slotButtonsChanged()) ); connect( cbShowToolTips, SIGNAL(clicked()), SLOT(slotSelectionChanged()) ); - connect( slBorder, SIGNAL( valueChanged( int )), SLOT( slotBorderChanged( int ))); + connect( cBorder, SIGNAL( activated( int )), SLOT( slotBorderChanged( int ))); // connect( cbUseMiniWindows, SIGNAL(clicked()), SLOT(slotSelectionChanged()) ); // Allow kwin dcop signal to update our selection list @@ -277,13 +276,13 @@ void KWinDecorationModule::slotSelectionChanged() static const char* const border_names[ KDecorationDefines::BordersCount ] = { - I18N_NOOP( "Border size: Tiny" ), - I18N_NOOP( "Border size: Normal" ), - I18N_NOOP( "Border size: Large" ), - I18N_NOOP( "Border size: Very Large" ), - I18N_NOOP( "Border size: Huge" ), - I18N_NOOP( "Border size: Very Huge" ), - I18N_NOOP( "Border size: Oversized" ) + I18N_NOOP( "Tiny" ), + I18N_NOOP( "Normal" ), + I18N_NOOP( "Large" ), + I18N_NOOP( "Very Large" ), + I18N_NOOP( "Huge" ), + I18N_NOOP( "Very Huge" ), + I18N_NOOP( "Oversized" ) }; int KWinDecorationModule::borderSizeToIndex( BorderSize size, QValueList< BorderSize > sizes ) @@ -319,7 +318,6 @@ void KWinDecorationModule::slotBorderChanged( int size ) sizes = plugins->factory()->borderSizes(); assert( sizes.count() >= 2 ); border_size = indexToBorderSize( size, sizes ); - lBorder->setText( i18n( border_names[ border_size ] )); // update preview preview->setTempBorderSize(plugins, border_size); @@ -590,18 +588,23 @@ void KWinDecorationModule::defaults() void KWinDecorationModule::checkSupportedBorderSizes() { QValueList< BorderSize > sizes; - slBorder->hide(); - lBorder->hide(); if( plugins->factory() != NULL ) sizes = plugins->factory()->borderSizes(); - if( sizes.count() < 2 ) - return; - slBorder->setRange( 0, sizes.count() - 1 ); - int pos = borderSizeToIndex( border_size, sizes ); - lBorder->show(); - slBorder->show(); - slBorder->setValue( pos ); - slotBorderChanged( pos ); + if( sizes.count() < 2 ) { + lBorder->hide(); + cBorder->hide(); + } else { + cBorder->clear(); + for (QValueList::const_iterator it = sizes.begin(); it != sizes.end(); ++it) { + BorderSize size = *it; + cBorder->insertItem(border_names[size], borderSizeToIndex(size,sizes) ); + } + int pos = borderSizeToIndex( border_size, sizes ); + lBorder->show(); + cBorder->show(); + cBorder->setCurrentItem(pos); + slotBorderChanged( pos ); + } } QString KWinDecorationModule::styleToConfigLib( QString& styleLib ) diff --git a/kcmkwin/kwindecoration/kwindecoration.h b/kcmkwin/kwindecoration/kwindecoration.h index 0c7a7e9931..7a123059f1 100644 --- a/kcmkwin/kwindecoration/kwindecoration.h +++ b/kcmkwin/kwindecoration/kwindecoration.h @@ -115,7 +115,7 @@ class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface // QCheckBox* cbUseMiniWindows; QCheckBox* cbShowToolTips; QLabel* lBorder; - QSlider* slBorder; + QComboBox* cBorder; BorderSize border_size; QObject* pluginObject;