Allows the decorations to specify which border sizes they support.
Also added GUI for the border size, not perfect, but it's there. svn path=/trunk/kdebase/kwin/; revision=253572
This commit is contained in:
parent
bfcadaa3de
commit
cefae8f1e4
11 changed files with 177 additions and 29 deletions
|
@ -64,16 +64,16 @@ Decoration::MousePosition Decoration::mousePosition( const QPoint& p ) const
|
||||||
|
|
||||||
void Decoration::borders( int& left, int& right, int& top, int& bottom ) const
|
void Decoration::borders( int& left, int& right, int& top, int& bottom ) const
|
||||||
{
|
{
|
||||||
if( options()->preferredBorderSize() == BorderTiny )
|
if( options()->preferredBorderSize( factory()) == BorderTiny )
|
||||||
{
|
{
|
||||||
left = right = bottom = 1;
|
left = right = bottom = 1;
|
||||||
top = 5;
|
top = 5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
left = right = options()->preferredBorderSize() * 5;
|
left = right = options()->preferredBorderSize( factory()) * 5;
|
||||||
top = options()->preferredBorderSize() * 10;
|
top = options()->preferredBorderSize( factory()) * 10;
|
||||||
bottom = options()->preferredBorderSize() * 2;
|
bottom = options()->preferredBorderSize( factory()) * 2;
|
||||||
}
|
}
|
||||||
if( isShade())
|
if( isShade())
|
||||||
bottom = 0;
|
bottom = 0;
|
||||||
|
|
|
@ -69,7 +69,7 @@ WebClient::init()
|
||||||
QFontMetrics fm(options()->font(isActive(), isTool()));
|
QFontMetrics fm(options()->font(isActive(), isTool()));
|
||||||
|
|
||||||
// border size
|
// border size
|
||||||
switch(options()->preferredBorderSize()) {
|
switch(options()->preferredBorderSize( factory())) {
|
||||||
case BorderLarge:
|
case BorderLarge:
|
||||||
borderSize_ = 8;
|
borderSize_ = 8;
|
||||||
break;
|
break;
|
||||||
|
@ -85,7 +85,6 @@ WebClient::init()
|
||||||
case BorderOversized:
|
case BorderOversized:
|
||||||
borderSize_ = 40;
|
borderSize_ = 40;
|
||||||
break;
|
break;
|
||||||
case BorderTiny:
|
|
||||||
case BorderNormal:
|
case BorderNormal:
|
||||||
default:
|
default:
|
||||||
borderSize_ = 4;
|
borderSize_ = 4;
|
||||||
|
@ -605,6 +604,12 @@ bool WebFactory::reset(unsigned long changed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QValueList< WebFactory::BorderSize > WebFactory::borderSizes() const
|
||||||
|
{ // the list must be sorted
|
||||||
|
return QValueList< BorderSize >() << BorderNormal << BorderLarge <<
|
||||||
|
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "Web.moc"
|
#include "Web.moc"
|
||||||
|
|
|
@ -120,6 +120,7 @@ namespace Web
|
||||||
virtual ~WebFactory() {};
|
virtual ~WebFactory() {};
|
||||||
virtual KDecoration* createDecoration( KDecorationBridge* );
|
virtual KDecoration* createDecoration( KDecorationBridge* );
|
||||||
virtual bool reset( unsigned long changed );
|
virtual bool reset( unsigned long changed );
|
||||||
|
virtual QValueList< BorderSize > borderSizes() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#include <qvbox.h>
|
#include <qvbox.h>
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
|
#include <qslider.h>
|
||||||
|
|
||||||
#include <kapplication.h>
|
#include <kapplication.h>
|
||||||
#include <kcombobox.h>
|
#include <kcombobox.h>
|
||||||
|
@ -55,6 +57,7 @@
|
||||||
#include "kwindecoration.h"
|
#include "kwindecoration.h"
|
||||||
#include "preview.h"
|
#include "preview.h"
|
||||||
#include <kdecoration_plugins_p.h>
|
#include <kdecoration_plugins_p.h>
|
||||||
|
#include <kdecorationfactory.h>
|
||||||
|
|
||||||
// KCModule plugin interface
|
// KCModule plugin interface
|
||||||
// =========================
|
// =========================
|
||||||
|
@ -121,6 +124,13 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const char* name, co
|
||||||
i18n( "Enabling this checkbox will show window button tooltips. "
|
i18n( "Enabling this checkbox will show window button tooltips. "
|
||||||
"If this checkbox is off, no window button tooltips will be shown."));
|
"If this checkbox is off, no window button tooltips will be shown."));
|
||||||
|
|
||||||
|
lBorder = new QLabel( buttonPage );
|
||||||
|
slBorder = new QSlider( Horizontal, buttonPage );
|
||||||
|
QWhatsThis::add( slBorder, i18n( "This slider shows all border sizes supported by this decoration." ));
|
||||||
|
lBorder->setBuddy( slBorder );
|
||||||
|
lBorder->hide();
|
||||||
|
slBorder->hide();
|
||||||
|
|
||||||
cbUseCustomButtonPositions = new QCheckBox(
|
cbUseCustomButtonPositions = new QCheckBox(
|
||||||
i18n("Use custom titlebar button &positions"), buttonPage );
|
i18n("Use custom titlebar button &positions"), buttonPage );
|
||||||
QWhatsThis::add( cbUseCustomButtonPositions,
|
QWhatsThis::add( cbUseCustomButtonPositions,
|
||||||
|
@ -159,6 +169,7 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const char* name, co
|
||||||
connect( cbUseCustomButtonPositions, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
connect( cbUseCustomButtonPositions, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
||||||
connect(cbUseCustomButtonPositions, SIGNAL(toggled(bool)), buttonBox, SLOT(setEnabled(bool)));
|
connect(cbUseCustomButtonPositions, SIGNAL(toggled(bool)), buttonBox, SLOT(setEnabled(bool)));
|
||||||
connect( cbShowToolTips, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
connect( cbShowToolTips, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
||||||
|
connect( slBorder, SIGNAL( valueChanged( int )), SLOT( slotBorderChanged( int )));
|
||||||
// connect( cbUseMiniWindows, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
// connect( cbUseMiniWindows, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
|
||||||
|
|
||||||
// Allow kwin dcop signal to update our selection list
|
// Allow kwin dcop signal to update our selection list
|
||||||
|
@ -239,6 +250,52 @@ void KWinDecorationModule::slotSelectionChanged()
|
||||||
setChanged(true);
|
setChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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" )
|
||||||
|
};
|
||||||
|
|
||||||
|
int KWinDecorationModule::borderSizeToIndex( BorderSize size, QValueList< BorderSize > sizes )
|
||||||
|
{
|
||||||
|
int pos = 0;
|
||||||
|
for( QValueList< BorderSize >::ConstIterator it = sizes.begin();
|
||||||
|
it != sizes.end();
|
||||||
|
++it, ++pos )
|
||||||
|
if( size <= *it )
|
||||||
|
break;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
KDecorationDefines::BorderSize KWinDecorationModule::indexToBorderSize( int index,
|
||||||
|
QValueList< BorderSize > sizes )
|
||||||
|
{
|
||||||
|
QValueList< BorderSize >::ConstIterator it = sizes.begin();
|
||||||
|
for(;
|
||||||
|
it != sizes.end();
|
||||||
|
++it, --index )
|
||||||
|
if( index == 0 )
|
||||||
|
break;
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KWinDecorationModule::slotBorderChanged( int size )
|
||||||
|
{
|
||||||
|
if( lBorder->isHidden())
|
||||||
|
return;
|
||||||
|
setChanged( true );
|
||||||
|
QValueList< BorderSize > sizes;
|
||||||
|
if( plugins->factory() != NULL )
|
||||||
|
sizes = plugins->factory()->borderSizes();
|
||||||
|
assert( sizes.count() >= 2 );
|
||||||
|
border_size = indexToBorderSize( size, sizes );
|
||||||
|
lBorder->setText( i18n( border_names[ border_size ] ));
|
||||||
|
}
|
||||||
|
|
||||||
QString KWinDecorationModule::decorationName( QString& libName )
|
QString KWinDecorationModule::decorationName( QString& libName )
|
||||||
{
|
{
|
||||||
|
@ -298,7 +355,9 @@ void KWinDecorationModule::resetPlugin( KConfig* conf, const QString& currentDec
|
||||||
else
|
else
|
||||||
preview->disablePreview();
|
preview->disablePreview();
|
||||||
plugins->destroyPreviousPlugin();
|
plugins->destroyPreviousPlugin();
|
||||||
|
|
||||||
|
checkSupportedBorderSizes();
|
||||||
|
|
||||||
currentName = styleToConfigLib( currentName );
|
currentName = styleToConfigLib( currentName );
|
||||||
|
|
||||||
// Delete old plugin widget if it exists
|
// Delete old plugin widget if it exists
|
||||||
|
@ -392,6 +451,13 @@ void KWinDecorationModule::readConfig( KConfig* conf )
|
||||||
for(i = 0; i < dropSite->buttonsRight.length(); i++)
|
for(i = 0; i < dropSite->buttonsRight.length(); i++)
|
||||||
buttonSource->hideButton( dropSite->buttonsRight[i].latin1() );
|
buttonSource->hideButton( dropSite->buttonsRight[i].latin1() );
|
||||||
|
|
||||||
|
int bsize = conf->readNumEntry( "BorderSize", BorderNormal );
|
||||||
|
if( bsize >= BorderTiny && bsize < BordersCount )
|
||||||
|
border_size = static_cast< BorderSize >( bsize );
|
||||||
|
else
|
||||||
|
border_size = BorderNormal;
|
||||||
|
checkSupportedBorderSizes();
|
||||||
|
|
||||||
setChanged(false);
|
setChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,6 +480,7 @@ void KWinDecorationModule::writeConfig( KConfig* conf )
|
||||||
// Button settings
|
// Button settings
|
||||||
conf->writeEntry("ButtonsOnLeft", dropSite->buttonsLeft );
|
conf->writeEntry("ButtonsOnLeft", dropSite->buttonsLeft );
|
||||||
conf->writeEntry("ButtonsOnRight", dropSite->buttonsRight );
|
conf->writeEntry("ButtonsOnRight", dropSite->buttonsRight );
|
||||||
|
conf->writeEntry("BorderSize", border_size );
|
||||||
|
|
||||||
oldLibraryName = currentLibraryName;
|
oldLibraryName = currentLibraryName;
|
||||||
currentLibraryName = libName;
|
currentLibraryName = libName;
|
||||||
|
@ -484,11 +551,31 @@ void KWinDecorationModule::defaults()
|
||||||
buttonSource->hideButton('I');
|
buttonSource->hideButton('I');
|
||||||
buttonSource->hideButton('A');
|
buttonSource->hideButton('A');
|
||||||
buttonSource->hideButton('X');
|
buttonSource->hideButton('X');
|
||||||
|
|
||||||
|
border_size = BorderNormal;
|
||||||
|
checkSupportedBorderSizes();
|
||||||
|
|
||||||
// Set plugin defaults
|
// Set plugin defaults
|
||||||
emit pluginDefaults();
|
emit pluginDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
QString KWinDecorationModule::styleToConfigLib( QString& styleLib )
|
QString KWinDecorationModule::styleToConfigLib( QString& styleLib )
|
||||||
{
|
{
|
||||||
if( styleLib.startsWith( "kwin3_" ))
|
if( styleLib.startsWith( "kwin3_" ))
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <klibloader.h>
|
#include <klibloader.h>
|
||||||
|
|
||||||
|
#include <kdecoration.h>
|
||||||
|
|
||||||
#include "kwindecorationIface.h"
|
#include "kwindecorationIface.h"
|
||||||
|
|
||||||
class KComboBox;
|
class KComboBox;
|
||||||
|
@ -45,6 +47,7 @@ class QCheckBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
class QVBox;
|
class QVBox;
|
||||||
|
class QSlider;
|
||||||
|
|
||||||
class KDecorationPlugins;
|
class KDecorationPlugins;
|
||||||
class KDecorationPreview;
|
class KDecorationPreview;
|
||||||
|
@ -57,7 +60,7 @@ struct DecorationInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface
|
class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface, public KDecorationDefines
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -83,6 +86,7 @@ class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface
|
||||||
// Allows us to turn "save" on
|
// Allows us to turn "save" on
|
||||||
void slotSelectionChanged();
|
void slotSelectionChanged();
|
||||||
void slotChangeDecoration( const QString & );
|
void slotChangeDecoration( const QString & );
|
||||||
|
void slotBorderChanged( int );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readConfig( KConfig* conf );
|
void readConfig( KConfig* conf );
|
||||||
|
@ -95,6 +99,9 @@ class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface
|
||||||
static QString styleToConfigLib( QString& styleLib );
|
static QString styleToConfigLib( QString& styleLib );
|
||||||
void resetPlugin( KConfig* conf, const QString& currentDecoName = QString::null );
|
void resetPlugin( KConfig* conf, const QString& currentDecoName = QString::null );
|
||||||
void resetKWin();
|
void resetKWin();
|
||||||
|
void checkSupportedBorderSizes();
|
||||||
|
static int borderSizeToIndex( BorderSize size, QValueList< BorderSize > sizes );
|
||||||
|
static BorderSize indexToBorderSize( int index, QValueList< BorderSize > sizes );
|
||||||
|
|
||||||
QTabWidget* tabWidget;
|
QTabWidget* tabWidget;
|
||||||
|
|
||||||
|
@ -109,6 +116,9 @@ class KWinDecorationModule : public KCModule, virtual public KWinDecorationIface
|
||||||
QCheckBox* cbUseCustomButtonPositions;
|
QCheckBox* cbUseCustomButtonPositions;
|
||||||
// QCheckBox* cbUseMiniWindows;
|
// QCheckBox* cbUseMiniWindows;
|
||||||
QCheckBox* cbShowToolTips;
|
QCheckBox* cbShowToolTips;
|
||||||
|
QLabel* lBorder;
|
||||||
|
QSlider* slBorder;
|
||||||
|
BorderSize border_size;
|
||||||
|
|
||||||
QObject* pluginObject;
|
QObject* pluginObject;
|
||||||
QLabel* pluginSettingsLbl;
|
QLabel* pluginSettingsLbl;
|
||||||
|
|
|
@ -370,9 +370,13 @@ bool KDecorationOptions::showTooltips() const
|
||||||
return d->show_tooltips;
|
return d->show_tooltips;
|
||||||
}
|
}
|
||||||
|
|
||||||
KDecorationOptions::BorderSize KDecorationOptions::preferredBorderSize() const
|
KDecorationOptions::BorderSize KDecorationOptions::preferredBorderSize( KDecorationFactory* factory ) const
|
||||||
{
|
{
|
||||||
return d->border_size;
|
assert( factory != NULL );
|
||||||
|
if( d->cached_border_size == BordersCount ) // invalid
|
||||||
|
d->cached_border_size = d->findPreferredBorderSize( d->border_size,
|
||||||
|
factory->borderSizes());
|
||||||
|
return d->cached_border_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KDecorationOptions::moveResizeMaximizedWindows() const
|
bool KDecorationOptions::moveResizeMaximizedWindows() const
|
||||||
|
|
|
@ -122,7 +122,8 @@ public:
|
||||||
BorderVeryLarge, ///< Very large borders
|
BorderVeryLarge, ///< Very large borders
|
||||||
BorderHuge, ///< Huge borders
|
BorderHuge, ///< Huge borders
|
||||||
BorderVeryHuge, ///< Very huge borders
|
BorderVeryHuge, ///< Very huge borders
|
||||||
BorderOversized ///< Oversized borders
|
BorderOversized, ///< Oversized borders
|
||||||
|
BordersCount ///< @internal
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -208,9 +209,13 @@ public:
|
||||||
* The preferred border size selected by the user, e.g. for accessibility
|
* The preferred border size selected by the user, e.g. for accessibility
|
||||||
* reasons, or when using high resolution displays. It's up to the decoration
|
* reasons, or when using high resolution displays. It's up to the decoration
|
||||||
* to decide which borders or if any borders at all will obey this setting.
|
* to decide which borders or if any borders at all will obey this setting.
|
||||||
|
* It is guaranteed that the returned value will be one of those
|
||||||
|
* returned by KDecorationFactory::borderSizes(), so if that one hasn't been
|
||||||
|
* reimplemented, BorderNormal is always returned.
|
||||||
* The changed flags for this setting is SettingBorder.
|
* The changed flags for this setting is SettingBorder.
|
||||||
|
* @param factory the decoration factory used
|
||||||
*/
|
*/
|
||||||
BorderSize preferredBorderSize() const;
|
BorderSize preferredBorderSize( KDecorationFactory* factory ) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When this functions returns false, moving and resizing of maximized windows
|
* When this functions returns false, moving and resizing of maximized windows
|
||||||
|
|
|
@ -27,23 +27,26 @@ DEALINGS IN THE SOFTWARE.
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <qpalette.h>
|
#include <qpalette.h>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
KDecorationOptionsPrivate::KDecorationOptionsPrivate()
|
KDecorationOptionsPrivate::KDecorationOptionsPrivate()
|
||||||
{
|
{
|
||||||
for(int i=0; i < NUM_COLORS*2; ++i)
|
for(int i=0; i < NUM_COLORS*2; ++i)
|
||||||
cg[i] = NULL;
|
cg[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
KDecorationOptionsPrivate::~KDecorationOptionsPrivate()
|
KDecorationOptionsPrivate::~KDecorationOptionsPrivate()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i < NUM_COLORS*2; ++i){
|
for(i=0; i < NUM_COLORS*2; ++i)
|
||||||
if(cg[i]){
|
{
|
||||||
|
if(cg[i])
|
||||||
|
{
|
||||||
delete cg[i];
|
delete cg[i];
|
||||||
cg[i] = NULL;
|
cg[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void KDecorationOptionsPrivate::defaultKWinSettings()
|
void KDecorationOptionsPrivate::defaultKWinSettings()
|
||||||
{
|
{
|
||||||
|
@ -52,11 +55,12 @@ void KDecorationOptionsPrivate::defaultKWinSettings()
|
||||||
custom_button_positions = false;
|
custom_button_positions = false;
|
||||||
show_tooltips = true;
|
show_tooltips = true;
|
||||||
border_size = BorderNormal;
|
border_size = BorderNormal;
|
||||||
|
cached_border_size = BordersCount; // invalid
|
||||||
move_resize_maximized_windows = true;
|
move_resize_maximized_windows = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
|
unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
|
||||||
{
|
{
|
||||||
unsigned long changed = 0;
|
unsigned long changed = 0;
|
||||||
QString old_group = config->group();
|
QString old_group = config->group();
|
||||||
config->setGroup( "WM" );
|
config->setGroup( "WM" );
|
||||||
|
@ -161,14 +165,16 @@ unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
|
||||||
QString old_title_buttons_right = title_buttons_right;
|
QString old_title_buttons_right = title_buttons_right;
|
||||||
bool old_custom_button_positions = custom_button_positions;
|
bool old_custom_button_positions = custom_button_positions;
|
||||||
custom_button_positions = config->readBoolEntry("CustomButtonPositions", false);
|
custom_button_positions = config->readBoolEntry("CustomButtonPositions", false);
|
||||||
if (custom_button_positions) {
|
if (custom_button_positions)
|
||||||
|
{
|
||||||
title_buttons_left = config->readEntry("ButtonsOnLeft", "MS");
|
title_buttons_left = config->readEntry("ButtonsOnLeft", "MS");
|
||||||
title_buttons_right = config->readEntry("ButtonsOnRight", "HIAX");
|
title_buttons_right = config->readEntry("ButtonsOnRight", "HIAX");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
title_buttons_left = "MS";
|
title_buttons_left = "MS";
|
||||||
title_buttons_right = "HIAX";
|
title_buttons_right = "HIAX";
|
||||||
}
|
}
|
||||||
if( old_custom_button_positions != custom_button_positions
|
if( old_custom_button_positions != custom_button_positions
|
||||||
|| ( custom_button_positions &&
|
|| ( custom_button_positions &&
|
||||||
( old_title_buttons_left != title_buttons_left
|
( old_title_buttons_left != title_buttons_left
|
||||||
|
@ -185,12 +191,13 @@ unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
|
||||||
|
|
||||||
BorderSize old_border_size = border_size;
|
BorderSize old_border_size = border_size;
|
||||||
int border_size_num = config->readNumEntry( "BorderSize", BorderNormal );
|
int border_size_num = config->readNumEntry( "BorderSize", BorderNormal );
|
||||||
if( border_size_num >= BorderTiny && border_size_num <= BorderOversized )
|
if( border_size_num >= 0 && border_size_num < BordersCount )
|
||||||
border_size = static_cast< BorderSize >( border_size_num );
|
border_size = static_cast< BorderSize >( border_size_num );
|
||||||
else
|
else
|
||||||
border_size = BorderNormal;
|
border_size = BorderNormal;
|
||||||
if( old_border_size != border_size )
|
if( old_border_size != border_size )
|
||||||
changed |= SettingBorder;
|
changed |= SettingBorder;
|
||||||
|
cached_border_size = BordersCount; // invalid
|
||||||
|
|
||||||
config->setGroup( "Windows" );
|
config->setGroup( "Windows" );
|
||||||
bool old_move_resize_maximized_windows = move_resize_maximized_windows;
|
bool old_move_resize_maximized_windows = move_resize_maximized_windows;
|
||||||
|
@ -200,14 +207,27 @@ unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
|
||||||
|
|
||||||
// destroy cached values
|
// destroy cached values
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i < NUM_COLORS*2; ++i){
|
for(i=0; i < NUM_COLORS*2; ++i)
|
||||||
if(cg[i]){
|
{
|
||||||
|
if(cg[i])
|
||||||
|
{
|
||||||
delete cg[i];
|
delete cg[i];
|
||||||
cg[i] = NULL;
|
cg[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
config->setGroup( old_group );
|
config->setGroup( old_group );
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KDecorationDefines::BorderSize KDecorationOptionsPrivate::findPreferredBorderSize( BorderSize size,
|
||||||
|
QValueList< BorderSize > sizes ) const
|
||||||
|
{
|
||||||
|
for( QValueList< BorderSize >::ConstIterator it = sizes.begin();
|
||||||
|
it != sizes.end();
|
||||||
|
++it )
|
||||||
|
if( size <= *it ) // size is either a supported size, or *it is the closest larger supported
|
||||||
|
return *it;
|
||||||
|
return sizes.last(); // size is larger than all supported ones, return largest
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include "kdecoration.h"
|
#include "kdecoration.h"
|
||||||
#include <qwidget.h>
|
#include <qwidget.h>
|
||||||
|
#include <qvaluelist.h>
|
||||||
|
|
||||||
class KConfig;
|
class KConfig;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ class KDecorationOptionsPrivate : public KDecorationDefines
|
||||||
virtual ~KDecorationOptionsPrivate();
|
virtual ~KDecorationOptionsPrivate();
|
||||||
void defaultKWinSettings(); // shared implementation
|
void defaultKWinSettings(); // shared implementation
|
||||||
unsigned long updateKWinSettings( KConfig* ); // shared implementation
|
unsigned long updateKWinSettings( KConfig* ); // shared implementation
|
||||||
|
BorderSize findPreferredBorderSize( BorderSize size, QValueList< BorderSize > ) const; // shared implementation
|
||||||
|
|
||||||
QColor colors[NUM_COLORS*2];
|
QColor colors[NUM_COLORS*2];
|
||||||
QColorGroup *cg[NUM_COLORS*2];
|
QColorGroup *cg[NUM_COLORS*2];
|
||||||
|
@ -49,7 +51,7 @@ class KDecorationOptionsPrivate : public KDecorationDefines
|
||||||
QString title_buttons_right;
|
QString title_buttons_right;
|
||||||
bool custom_button_positions;
|
bool custom_button_positions;
|
||||||
bool show_tooltips;
|
bool show_tooltips;
|
||||||
BorderSize border_size;
|
BorderSize border_size, cached_border_size;
|
||||||
bool move_resize_maximized_windows;
|
bool move_resize_maximized_windows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,11 @@ bool KDecorationFactory::supports( Ability )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QValueList< KDecorationDefines::BorderSize > KDecorationFactory::borderSizes() const
|
||||||
|
{
|
||||||
|
return QValueList< BorderSize >() << BorderNormal;
|
||||||
|
}
|
||||||
|
|
||||||
void KDecorationFactory::addDecoration( KDecoration* deco )
|
void KDecorationFactory::addDecoration( KDecoration* deco )
|
||||||
{
|
{
|
||||||
_decorations.append( deco );
|
_decorations.append( deco );
|
||||||
|
|
|
@ -62,6 +62,15 @@ class KDecorationFactory
|
||||||
* Note that true should be returned only when really necessary.
|
* Note that true should be returned only when really necessary.
|
||||||
*/
|
*/
|
||||||
virtual bool reset( unsigned long changed ); // returns true if the decoration needs to be recreated
|
virtual bool reset( unsigned long changed ); // returns true if the decoration needs to be recreated
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reimplement this function if your decoration supports more border sizes than
|
||||||
|
* the default one (BorderNormal). The returned list must contain all supported
|
||||||
|
* sizes, ordered from the smallest to the largest one. By default, only
|
||||||
|
* BorderNormal is returned.
|
||||||
|
*/
|
||||||
|
virtual QValueList< BorderSize > borderSizes() const;
|
||||||
|
|
||||||
virtual bool supports( Ability ability );
|
virtual bool supports( Ability ability );
|
||||||
/**
|
/**
|
||||||
* Returns the KDecorationOptions object, which is used to access
|
* Returns the KDecorationOptions object, which is used to access
|
||||||
|
|
Loading…
Reference in a new issue