Extend KDecorationPreview to allow setting temporary decoration border size and button layout.
svn path=/trunk/kdebase/kwin/; revision=361796
This commit is contained in:
parent
2fd9ce3a64
commit
ec9b2155ee
2 changed files with 72 additions and 3 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
|
|
||||||
|
#include <kdecorationfactory.h>
|
||||||
#include <kdecoration_plugins_p.h>
|
#include <kdecoration_plugins_p.h>
|
||||||
|
|
||||||
// FRAME the preview doesn't update to reflect the changes done in the kcm
|
// FRAME the preview doesn't update to reflect the changes done in the kcm
|
||||||
|
@ -174,6 +175,36 @@ QRect KDecorationPreview::windowGeometry( bool active ) const
|
||||||
return widget->geometry();
|
return widget->geometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KDecorationPreview::setTempBorderSize(KDecorationPlugins* plugin, KDecorationDefines::BorderSize size)
|
||||||
|
{
|
||||||
|
options->setCustomBorderSize(size);
|
||||||
|
if (plugin->factory()->reset(KDecorationDefines::SettingBorder) )
|
||||||
|
{
|
||||||
|
// can't handle the change, recreate decorations then
|
||||||
|
recreateDecoration(plugin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// handles the update, only update position...
|
||||||
|
positionPreviews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDecorationPreview::setTempButtons(KDecorationPlugins* plugin, const QString &left, const QString &right)
|
||||||
|
{
|
||||||
|
options->setCustomTitleButtons(left, right);
|
||||||
|
if (plugin->factory()->reset(KDecorationDefines::SettingButtons) )
|
||||||
|
{
|
||||||
|
// can't handle the change, recreate decorations then
|
||||||
|
recreateDecoration(plugin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// handles the update, only update position...
|
||||||
|
positionPreviews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QRegion KDecorationPreview::unobscuredRegion( bool active, const QRegion& r ) const
|
QRegion KDecorationPreview::unobscuredRegion( bool active, const QRegion& r ) const
|
||||||
{
|
{
|
||||||
if( active ) // this one is not obscured
|
if( active ) // this one is not obscured
|
||||||
|
@ -394,6 +425,10 @@ void KDecorationPreviewBridge::grabXServer( bool )
|
||||||
|
|
||||||
KDecorationPreviewOptions::KDecorationPreviewOptions()
|
KDecorationPreviewOptions::KDecorationPreviewOptions()
|
||||||
{
|
{
|
||||||
|
customBorderSize = BordersCount; // invalid
|
||||||
|
customTitleButtonsLeft = QString::null; // invalid
|
||||||
|
customTitleButtonsRight = QString::null; // invalid
|
||||||
|
|
||||||
d = new KDecorationOptionsPrivate;
|
d = new KDecorationOptionsPrivate;
|
||||||
d->defaultKWinSettings();
|
d->defaultKWinSettings();
|
||||||
updateSettings();
|
updateSettings();
|
||||||
|
@ -409,12 +444,36 @@ unsigned long KDecorationPreviewOptions::updateSettings()
|
||||||
KConfig cfg( "kwinrc", true );
|
KConfig cfg( "kwinrc", true );
|
||||||
unsigned long changed = 0;
|
unsigned long changed = 0;
|
||||||
changed |= d->updateKWinSettings( &cfg );
|
changed |= d->updateKWinSettings( &cfg );
|
||||||
|
|
||||||
|
// set custom border size/buttons
|
||||||
|
if (customBorderSize != BordersCount)
|
||||||
|
d->border_size = customBorderSize;
|
||||||
|
if (!customTitleButtonsLeft.isNull() )
|
||||||
|
d->title_buttons_left = customTitleButtonsLeft;
|
||||||
|
if (!customTitleButtonsRight.isNull() )
|
||||||
|
d->title_buttons_right = customTitleButtonsRight;
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KDecorationPreviewOptions::setCustomBorderSize(BorderSize size)
|
||||||
|
{
|
||||||
|
customBorderSize = size;
|
||||||
|
|
||||||
|
updateSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KDecorationPreviewOptions::setCustomTitleButtons(const QString &left, const QString &right)
|
||||||
|
{
|
||||||
|
customTitleButtonsLeft = left;
|
||||||
|
customTitleButtonsRight = right;
|
||||||
|
|
||||||
|
updateSettings();
|
||||||
|
}
|
||||||
|
|
||||||
bool KDecorationPreviewPlugins::provides( Requirement )
|
bool KDecorationPreviewPlugins::provides( Requirement )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "preview.moc"
|
#include "preview.moc"
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
|
||||||
class KDecorationPreviewBridge;
|
class KDecorationPreviewBridge;
|
||||||
class KDecorationOptions;
|
class KDecorationPreviewOptions;
|
||||||
|
|
||||||
class KDecorationPreview
|
class KDecorationPreview
|
||||||
: public QWidget
|
: public QWidget
|
||||||
|
@ -47,11 +47,13 @@ class KDecorationPreview
|
||||||
void setPreviewMask( const QRegion&, int, bool );
|
void setPreviewMask( const QRegion&, int, bool );
|
||||||
QRegion unobscuredRegion( bool, const QRegion& ) const;
|
QRegion unobscuredRegion( bool, const QRegion& ) const;
|
||||||
QRect windowGeometry( bool ) const;
|
QRect windowGeometry( bool ) const;
|
||||||
|
void setTempBorderSize(KDecorationPlugins* plugin, KDecorationDefines::BorderSize size);
|
||||||
|
void setTempButtons(KDecorationPlugins* plugin, const QString &left, const QString &right);
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent( QResizeEvent* );
|
virtual void resizeEvent( QResizeEvent* );
|
||||||
private:
|
private:
|
||||||
void positionPreviews();
|
void positionPreviews();
|
||||||
KDecorationOptions* options;
|
KDecorationPreviewOptions* options;
|
||||||
KDecorationPreviewBridge* bridge[NumWindows];
|
KDecorationPreviewBridge* bridge[NumWindows];
|
||||||
KDecoration* deco[NumWindows];
|
KDecoration* deco[NumWindows];
|
||||||
QLabel* no_preview;
|
QLabel* no_preview;
|
||||||
|
@ -117,6 +119,14 @@ class KDecorationPreviewOptions
|
||||||
KDecorationPreviewOptions();
|
KDecorationPreviewOptions();
|
||||||
virtual ~KDecorationPreviewOptions();
|
virtual ~KDecorationPreviewOptions();
|
||||||
virtual unsigned long updateSettings();
|
virtual unsigned long updateSettings();
|
||||||
|
|
||||||
|
void setCustomBorderSize(BorderSize size);
|
||||||
|
void setCustomTitleButtons(const QString &left, const QString &right);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BorderSize customBorderSize;
|
||||||
|
QString customTitleButtonsLeft;
|
||||||
|
QString customTitleButtonsRight;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KDecorationPreviewPlugins
|
class KDecorationPreviewPlugins
|
||||||
|
|
Loading…
Reference in a new issue