Make it possible to use KDecorationOptions without private headers.
svn path=/trunk/KDE/kdebase/workspace/; revision=768271
This commit is contained in:
parent
4b792d000e
commit
685e1d2361
12 changed files with 132 additions and 74 deletions
|
@ -436,36 +436,32 @@ KDecorationPreviewOptions::KDecorationPreviewOptions()
|
|||
customButtons = true;
|
||||
customTitleButtonsLeft.clear(); // invalid
|
||||
customTitleButtonsRight.clear(); // invalid
|
||||
|
||||
d = new KDecorationOptionsPrivate;
|
||||
d->defaultKWinSettings();
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
KDecorationPreviewOptions::~KDecorationPreviewOptions()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
unsigned long KDecorationPreviewOptions::updateSettings()
|
||||
{
|
||||
KConfig cfg( "kwinrc" );
|
||||
unsigned long changed = 0;
|
||||
changed |= d->updateKWinSettings( &cfg );
|
||||
changed |= KDecorationOptions::updateSettings( &cfg );
|
||||
|
||||
// set custom border size/buttons
|
||||
if (customBorderSize != BordersCount)
|
||||
d->border_size = customBorderSize;
|
||||
setBorderSize( customBorderSize );
|
||||
if (customButtonsChanged)
|
||||
d->custom_button_positions = customButtons;
|
||||
setCustomButtonPositions( customButtons );
|
||||
if (customButtons) {
|
||||
if (!customTitleButtonsLeft.isNull() )
|
||||
d->title_buttons_left = customTitleButtonsLeft;
|
||||
setTitleButtonsLeft( customTitleButtonsLeft );
|
||||
if (!customTitleButtonsRight.isNull() )
|
||||
d->title_buttons_right = customTitleButtonsRight;
|
||||
setTitleButtonsRight( customTitleButtonsRight );
|
||||
} else {
|
||||
d->title_buttons_left = KDecorationOptions::defaultTitleButtonsLeft();
|
||||
d->title_buttons_right = KDecorationOptions::defaultTitleButtonsRight();
|
||||
setTitleButtonsLeft( KDecorationOptions::defaultTitleButtonsLeft());
|
||||
setTitleButtonsRight( KDecorationOptions::defaultTitleButtonsRight());
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QLabel>
|
||||
#include <QResizeEvent>
|
||||
#include <kdecoration_p.h>
|
||||
#include <kdecoration.h>
|
||||
#include <kdecorationbridge.h>
|
||||
#include <kdecoration_plugins_p.h>
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
#include "kdecoration.h"
|
||||
|
||||
//
|
||||
// This header file is internal. I mean it.
|
||||
//
|
||||
|
||||
class KCommonDecoration;
|
||||
class KDecorationBridge;
|
||||
class KDecorationFactory;
|
||||
|
|
|
@ -381,6 +381,7 @@ KDecoration::Position KDecoration::mousePosition( const QPoint& p ) const
|
|||
}
|
||||
|
||||
KDecorationOptions::KDecorationOptions()
|
||||
: d( new KDecorationOptionsPrivate )
|
||||
{
|
||||
assert( KDecoration::options_ == NULL );
|
||||
KDecoration::options_ = this;
|
||||
|
@ -390,6 +391,7 @@ KDecorationOptions::~KDecorationOptions()
|
|||
{
|
||||
assert( KDecoration::options_ == this );
|
||||
KDecoration::options_ = NULL;
|
||||
delete d;
|
||||
}
|
||||
|
||||
QColor KDecorationOptions::color(ColorType type, bool active) const
|
||||
|
@ -422,6 +424,11 @@ QPalette KDecorationOptions::palette(ColorType type, bool active) const
|
|||
return(*d->pal[idx]);
|
||||
}
|
||||
|
||||
unsigned long KDecorationOptions::updateSettings( KConfig* config )
|
||||
{
|
||||
return d->updateSettings( config );
|
||||
}
|
||||
|
||||
bool KDecorationOptions::customButtonPositions() const
|
||||
{
|
||||
return d->custom_button_positions;
|
||||
|
@ -468,8 +475,45 @@ bool KDecorationOptions::moveResizeMaximizedWindows() const
|
|||
|
||||
KDecorationDefines::WindowOperation KDecorationOptions::operationMaxButtonClick( Qt::MouseButtons button ) const
|
||||
{
|
||||
return button == Qt::RightButton? d->OpMaxButtonRightClick :
|
||||
button == Qt::MidButton? d->OpMaxButtonMiddleClick :
|
||||
d->OpMaxButtonLeftClick;
|
||||
return button == Qt::RightButton? d->opMaxButtonRightClick :
|
||||
button == Qt::MidButton? d->opMaxButtonMiddleClick :
|
||||
d->opMaxButtonLeftClick;
|
||||
}
|
||||
|
||||
void KDecorationOptions::setOpMaxButtonLeftClick( WindowOperation op )
|
||||
{
|
||||
d->opMaxButtonLeftClick = op;
|
||||
}
|
||||
|
||||
void KDecorationOptions::setOpMaxButtonRightClick( WindowOperation op )
|
||||
{
|
||||
d->opMaxButtonRightClick = op;
|
||||
}
|
||||
|
||||
void KDecorationOptions::setOpMaxButtonMiddleClick( WindowOperation op )
|
||||
{
|
||||
d->opMaxButtonMiddleClick = op;
|
||||
}
|
||||
|
||||
void KDecorationOptions::setBorderSize( BorderSize bs )
|
||||
{
|
||||
d->border_size = bs;
|
||||
d->cached_border_size = BordersCount; // invalid
|
||||
}
|
||||
|
||||
void KDecorationOptions::setCustomButtonPositions( bool b )
|
||||
{
|
||||
d->custom_button_positions = b;
|
||||
}
|
||||
|
||||
void KDecorationOptions::setTitleButtonsLeft( const QString& b )
|
||||
{
|
||||
d->title_buttons_left = b;
|
||||
}
|
||||
|
||||
void KDecorationOptions::setTitleButtonsRight( const QString& b )
|
||||
{
|
||||
d->title_buttons_right = b;
|
||||
}
|
||||
|
||||
#include "kdecoration.moc"
|
||||
|
|
|
@ -34,6 +34,8 @@ DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#define KWIN_EXPORT KDE_EXPORT
|
||||
|
||||
class KConfig;
|
||||
|
||||
/** @defgroup kdecoration KWin decorations library */
|
||||
|
||||
/** @addtogroup kdecoration */
|
||||
|
@ -205,6 +207,12 @@ class KWIN_EXPORT KDecorationOptions : public KDecorationDefines
|
|||
public:
|
||||
KDecorationOptions();
|
||||
virtual ~KDecorationOptions();
|
||||
/**
|
||||
* Call to update settings when the config changes. Return value is
|
||||
* a combination of Setting* (SettingColors, etc.) that have changed.
|
||||
* @since 4.0.1
|
||||
*/
|
||||
unsigned long updateSettings( KConfig* config );
|
||||
/**
|
||||
* Returns the color that should be used for the given part of the decoration.
|
||||
* The changed flags for this setting is SettingColors.
|
||||
|
@ -316,6 +324,21 @@ public:
|
|||
virtual unsigned long updateSettings() = 0; // returns SettingXYZ mask
|
||||
|
||||
protected:
|
||||
/** @internal */
|
||||
void setOpMaxButtonLeftClick( WindowOperation op );
|
||||
/** @internal */
|
||||
void setOpMaxButtonRightClick( WindowOperation op );
|
||||
/** @internal */
|
||||
void setOpMaxButtonMiddleClick( WindowOperation op );
|
||||
/** @internal */
|
||||
void setBorderSize( BorderSize bs );
|
||||
/** @internal */
|
||||
void setCustomButtonPositions( bool b );
|
||||
/** @internal */
|
||||
void setTitleButtonsLeft( const QString& b );
|
||||
/** @internal */
|
||||
void setTitleButtonsRight( const QString& b );
|
||||
private:
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,16 @@ DEALINGS IN THE SOFTWARE.
|
|||
#include <assert.h>
|
||||
|
||||
KDecorationOptionsPrivate::KDecorationOptionsPrivate()
|
||||
: title_buttons_left( KDecorationOptions::defaultTitleButtonsLeft())
|
||||
, title_buttons_right( KDecorationOptions::defaultTitleButtonsRight())
|
||||
, custom_button_positions( false )
|
||||
, show_tooltips( true )
|
||||
, border_size( BorderNormal )
|
||||
, cached_border_size( BordersCount ) // invalid
|
||||
, move_resize_maximized_windows( true )
|
||||
, opMaxButtonRightClick( MaximizeOp )
|
||||
, opMaxButtonMiddleClick( VMaximizeOp )
|
||||
, opMaxButtonLeftClick( HMaximizeOp )
|
||||
{
|
||||
for(int i=0; i < NUM_COLORS*2; ++i)
|
||||
pal[i] = NULL;
|
||||
|
@ -50,21 +60,7 @@ KDecorationOptionsPrivate::~KDecorationOptionsPrivate()
|
|||
}
|
||||
}
|
||||
|
||||
void KDecorationOptionsPrivate::defaultKWinSettings()
|
||||
{
|
||||
title_buttons_left = KDecorationOptions::defaultTitleButtonsLeft();
|
||||
title_buttons_right = KDecorationOptions::defaultTitleButtonsRight();
|
||||
custom_button_positions = false;
|
||||
show_tooltips = true;
|
||||
border_size = BorderNormal;
|
||||
cached_border_size = BordersCount; // invalid
|
||||
move_resize_maximized_windows = true;
|
||||
OpMaxButtonRightClick = MaximizeOp;
|
||||
OpMaxButtonMiddleClick = VMaximizeOp;
|
||||
OpMaxButtonLeftClick = HMaximizeOp;
|
||||
}
|
||||
|
||||
unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
|
||||
unsigned long KDecorationOptionsPrivate::updateSettings( KConfig* config )
|
||||
{
|
||||
unsigned long changed = 0;
|
||||
KConfigGroup wmConfig(config, "WM");
|
||||
|
|
|
@ -34,13 +34,12 @@ DEALINGS IN THE SOFTWARE.
|
|||
|
||||
class KConfig;
|
||||
|
||||
class KWIN_EXPORT KDecorationOptionsPrivate : public KDecorationDefines
|
||||
class KDecorationOptionsPrivate : public KDecorationDefines
|
||||
{
|
||||
public:
|
||||
KDecorationOptionsPrivate();
|
||||
virtual ~KDecorationOptionsPrivate();
|
||||
void defaultKWinSettings(); // shared implementation
|
||||
unsigned long updateKWinSettings( KConfig* ); // shared implementation
|
||||
~KDecorationOptionsPrivate();
|
||||
unsigned long updateSettings( KConfig* ); // shared implementation
|
||||
BorderSize findPreferredBorderSize( BorderSize size, QList< BorderSize > ) const; // shared implementation
|
||||
|
||||
QColor colors[NUM_COLORS*2];
|
||||
|
@ -52,9 +51,9 @@ class KWIN_EXPORT KDecorationOptionsPrivate : public KDecorationDefines
|
|||
bool show_tooltips;
|
||||
BorderSize border_size, cached_border_size;
|
||||
bool move_resize_maximized_windows;
|
||||
WindowOperation OpMaxButtonRightClick;
|
||||
WindowOperation OpMaxButtonMiddleClick;
|
||||
WindowOperation OpMaxButtonLeftClick;
|
||||
WindowOperation opMaxButtonRightClick;
|
||||
WindowOperation opMaxButtonMiddleClick;
|
||||
WindowOperation opMaxButtonLeftClick;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
// This header file is internal. I mean it.
|
||||
//
|
||||
|
||||
// This private header is used by KWin core.
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <ksharedconfig.h>
|
||||
|
|
11
options.cpp
11
options.cpp
|
@ -46,21 +46,18 @@ Options::Options()
|
|||
: electric_borders( 0 ),
|
||||
electric_border_delay(0)
|
||||
{
|
||||
d = new KDecorationOptionsPrivate;
|
||||
d->defaultKWinSettings();
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
Options::~Options()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
unsigned long Options::updateSettings()
|
||||
{
|
||||
KSharedConfig::Ptr _config = KGlobal::config();
|
||||
unsigned long changed = 0;
|
||||
changed |= d->updateKWinSettings( _config.data() ); // read decoration settings
|
||||
changed |= KDecorationOptions::updateSettings( _config.data() ); // read decoration settings
|
||||
|
||||
KConfigGroup config(_config, "Windows");
|
||||
moveMode = stringToMoveResizeMode( config.readEntry("MoveMode", "Opaque" ));
|
||||
|
@ -145,9 +142,9 @@ unsigned long Options::updateSettings()
|
|||
electric_border_delay = config.readEntry("ElectricBorderDelay", 150);
|
||||
|
||||
OpTitlebarDblClick = windowOperation( config.readEntry("TitlebarDoubleClickCommand", "Shade"), true );
|
||||
d->OpMaxButtonLeftClick = windowOperation( config.readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true );
|
||||
d->OpMaxButtonMiddleClick = windowOperation( config.readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true );
|
||||
d->OpMaxButtonRightClick = windowOperation( config.readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true );
|
||||
setOpMaxButtonLeftClick( windowOperation( config.readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true ));
|
||||
setOpMaxButtonMiddleClick( windowOperation( config.readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true ));
|
||||
setOpMaxButtonRightClick( windowOperation( config.readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true ));
|
||||
|
||||
ignorePositionClasses = config.readEntry("IgnorePositionClasses",QStringList());
|
||||
ignoreFocusStealingClasses = config.readEntry("IgnoreFocusStealingClasses",QStringList());
|
||||
|
|
|
@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QObject>
|
||||
#include <QFont>
|
||||
#include <QPalette>
|
||||
#include <kdecoration_p.h>
|
||||
#include <kdecoration.h>
|
||||
|
||||
#include "placement.h"
|
||||
#include "utils.h"
|
||||
|
|
|
@ -384,21 +384,19 @@ void KDecorationPreviewBridge::grabXServer( bool )
|
|||
|
||||
KDecorationPreviewOptions::KDecorationPreviewOptions()
|
||||
{
|
||||
d = new KDecorationOptionsPrivate;
|
||||
d->defaultKWinSettings();
|
||||
defaultKWinSettings();
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
KDecorationPreviewOptions::~KDecorationPreviewOptions()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
unsigned long KDecorationPreviewOptions::updateSettings()
|
||||
{
|
||||
KConfig cfg( "kwinrc", true );
|
||||
unsigned long changed = 0;
|
||||
changed |= d->updateKWinSettings( &cfg );
|
||||
changed |= KDecorationOptions::updateKWinSettings( &cfg );
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define KWINDECORATION_PREVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <kdecoration_p.h>
|
||||
#include <kdecoration.h>
|
||||
#include <kdecoration_plugins_p.h>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue