Extend KDecorationPreview to allow setting temporary decoration border size and button layout.

svn path=/trunk/kdebase/kwin/; revision=361796
This commit is contained in:
Sandro Giessl 2004-11-09 19:27:21 +00:00
parent 2fd9ce3a64
commit ec9b2155ee
2 changed files with 72 additions and 3 deletions

View file

@ -30,6 +30,7 @@
#include <X11/Xlib.h>
#include <X11/extensions/shape.h>
#include <kdecorationfactory.h>
#include <kdecoration_plugins_p.h>
// 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();
}
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
{
if( active ) // this one is not obscured
@ -394,6 +425,10 @@ void KDecorationPreviewBridge::grabXServer( bool )
KDecorationPreviewOptions::KDecorationPreviewOptions()
{
customBorderSize = BordersCount; // invalid
customTitleButtonsLeft = QString::null; // invalid
customTitleButtonsRight = QString::null; // invalid
d = new KDecorationOptionsPrivate;
d->defaultKWinSettings();
updateSettings();
@ -409,12 +444,36 @@ unsigned long KDecorationPreviewOptions::updateSettings()
KConfig cfg( "kwinrc", true );
unsigned long changed = 0;
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;
}
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 )
{
return false;
}
#include "preview.moc"

View file

@ -27,7 +27,7 @@
class QLabel;
class KDecorationPreviewBridge;
class KDecorationOptions;
class KDecorationPreviewOptions;
class KDecorationPreview
: public QWidget
@ -47,11 +47,13 @@ class KDecorationPreview
void setPreviewMask( const QRegion&, int, bool );
QRegion unobscuredRegion( bool, const QRegion& ) const;
QRect windowGeometry( bool ) const;
void setTempBorderSize(KDecorationPlugins* plugin, KDecorationDefines::BorderSize size);
void setTempButtons(KDecorationPlugins* plugin, const QString &left, const QString &right);
protected:
virtual void resizeEvent( QResizeEvent* );
private:
void positionPreviews();
KDecorationOptions* options;
KDecorationPreviewOptions* options;
KDecorationPreviewBridge* bridge[NumWindows];
KDecoration* deco[NumWindows];
QLabel* no_preview;
@ -117,6 +119,14 @@ class KDecorationPreviewOptions
KDecorationPreviewOptions();
virtual ~KDecorationPreviewOptions();
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