Declarative extension plugin for window decorations

The generic QML components from Aurorae are split out into an
own declarative plugin. In addition two new helper classes are
added to this plugin:
* A ColorHelper to map a few function of KColorSheme and making
  it possible to actually work with colors in QML. The need
  emerged from trying to port Plastik to QML which makes strong
  use of color shading.
* A DecorationOptions class which is a wrapper around KWin's
  KDecorationOptions but in a more useable way for QML. The
  various options are provided as properties and the value of
  the properties changes automatically depending on whether the
  decoration is active or inactive.

Aurorae itself is not yet adjusted to these changes, but it
should also be adjusted as some of the options are currently
exported in the factory and the factory is injected into the
Aurorae QML decoration.
icc-effect-5.14.5
Martin Gräßlin 2012-07-27 10:03:22 +02:00
parent 5923086d1f
commit 673dcd6ad3
11 changed files with 753 additions and 4 deletions

View File

@ -1,5 +1,9 @@
########### decoration ###############
include_directories( ./lib )
include_directories(
./lib
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
set(kwin3_aurorae_PART_SRCS
aurorae.cpp
@ -13,6 +17,18 @@ target_link_libraries(kwin3_aurorae ${KDE4_KDEUI_LIBS} ${QT_QTDECLARATIVE_LIBRAR
install(TARGETS kwin3_aurorae DESTINATION ${PLUGIN_INSTALL_DIR} )
set(decoration_plugin_SRCS
decorationplugin.cpp
decorationoptions.cpp
colorhelper.cpp
)
qt4_automoc(${decoration_plugin_SRCS})
add_library(decorationplugin SHARED ${decoration_plugin_SRCS})
target_link_libraries(decorationplugin ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${KDE4_KDEUI_LIBRARY} kdecorations)
install(TARGETS decorationplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/kwin/decoration)
########### install files ###############
install( FILES aurorae.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin )
@ -26,4 +42,11 @@ install( FILES
qml/DecorationButton.qml
qml/MenuButton.qml
DESTINATION ${DATA_INSTALL_DIR}/kwin/aurorae )
install( FILES
qml/Decoration.qml
qml/DecorationButton.qml
qml/MenuButton.qml
qml/ButtonGroup.qml
qml/qmldir
DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/kwin/decoration )
install( FILES kwindecoration.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )

View File

@ -116,9 +116,6 @@ void AuroraeFactory::initQML(const KConfigGroup &group)
foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
m_engine->addImportPath(importPath);
}
foreach (const QString &importPath, KGlobal::dirs()->findDirs("data", QLatin1String(KWIN_NAME) + "/aurorae/")) {
m_engine->addImportPath(importPath);
}
m_component->loadUrl(QUrl::fromLocalFile(file));
}
@ -244,6 +241,7 @@ AuroraeClient::AuroraeClient(KDecorationBridge *bridge, KDecorationFactory *fact
{
connect(this, SIGNAL(keepAboveChanged(bool)), SIGNAL(keepAboveChangedWrapper()));
connect(this, SIGNAL(keepBelowChanged(bool)), SIGNAL(keepBelowChangedWrapper()));
connect(AuroraeFactory::instance(), SIGNAL(buttonsChanged()), SIGNAL(buttonsChanged()));
}
AuroraeClient::~AuroraeClient()

View File

@ -147,6 +147,7 @@ Q_SIGNALS:
void shadeChanged();
void keepAboveChangedWrapper();
void keepBelowChangedWrapper();
void buttonsChanged();
public slots:
void menuClicked();

View File

@ -0,0 +1,65 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "colorhelper.h"
#include <KDE/KGlobalSettings>
#include <KDE/KColorScheme>
ColorHelper::ColorHelper(QObject *parent)
: QObject(parent)
{
}
ColorHelper::~ColorHelper()
{
}
QColor ColorHelper::shade(const QColor &color, ColorHelper::ShadeRole role)
{
return KColorScheme::shade(color, static_cast<KColorScheme::ShadeRole>(role));
}
QColor ColorHelper::shade(const QColor &color, ColorHelper::ShadeRole role, qreal contrast)
{
return KColorScheme::shade(color, static_cast<KColorScheme::ShadeRole>(role), contrast);
}
qreal ColorHelper::contrast() const
{
return KGlobalSettings::contrastF();
}
QColor ColorHelper::multiplyAlpha(const QColor &color, qreal alpha)
{
QColor retCol(color);
retCol.setAlphaF(color.alphaF() * alpha);
return retCol;
}
QColor ColorHelper::background(bool active, ColorHelper::BackgroundRole role) const
{
KColorScheme kcs(active ? QPalette::Active : QPalette::Inactive, KColorScheme::Button);
return kcs.background(static_cast<KColorScheme::BackgroundRole>(role)).color();
}
QColor ColorHelper::foreground(bool active, ColorHelper::ForegroundRole role) const
{
KColorScheme kcs(active ? QPalette::Active : QPalette::Inactive, KColorScheme::Button);
return kcs.foreground(static_cast<KColorScheme::ForegroundRole>(role)).color();
}
#include "colorhelper.moc"

View File

@ -0,0 +1,240 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef COLOR_HELPER_H
#define COLOR_HELPER_H
#include <QObject>
#include <QColor>
/**
* @short Helper to manipulate colors.
*
* Exports a few functions from KColorScheme.
**/
class ColorHelper : public QObject
{
Q_OBJECT
Q_ENUMS(ShadeRole)
Q_ENUMS(ForegroundRole)
Q_ENUMS(BackgroundRole)
/**
* Same as KGlobalSettings::contrastF.
**/
Q_PROPERTY(qreal contrast READ contrast CONSTANT)
public:
ColorHelper(QObject *parent = 0);
~ColorHelper();
/**
* This enumeration describes the color shade being selected from the given
* set.
*
* Color shades are used to draw "3d" elements, such as frames and bevels.
* They are neither foreground nor background colors. Text should not be
* painted over a shade, and shades should not be used to draw text.
*/
enum ShadeRole {
/**
* The light color is lighter than dark() or shadow() and contrasts
* with the base color.
*/
LightShade,
/**
* The midlight color is in between base() and light().
*/
MidlightShade,
/**
* The mid color is in between base() and dark().
*/
MidShade,
/**
* The dark color is in between mid() and shadow().
*/
DarkShade,
/**
* The shadow color is darker than light() or midlight() and contrasts
* the base color.
*/
ShadowShade
};
/**
* This enumeration describes the background color being selected from the
* given set.
*
* Background colors are suitable for drawing under text, and should never
* be used to draw text. In combination with one of the overloads of
* KColorScheme::shade, they may be used to generate colors for drawing
* frames, bevels, and similar decorations.
*/
enum BackgroundRole {
/**
* Normal background.
*/
NormalBackground = 0,
/**
* Alternate background; for example, for use in lists.
*
* This color may be the same as BackgroundNormal, especially in sets
* other than View and Window.
*/
AlternateBackground = 1,
/**
* Third color; for example, items which are new, active, requesting
* attention, etc.
*
* Alerting the user that a certain field must be filled out would be a
* good usage (although NegativeBackground could be used to the same
* effect, depending on what you are trying to achieve). Unlike
* ActiveText, this should not be used for mouseover effects.
*/
ActiveBackground = 2,
/**
* Fourth color; corresponds to (unvisited) links.
*
* Exactly what this might be used for is somewhat harder to qualify;
* it might be used for bookmarks, as a 'you can click here' indicator,
* or to highlight recent content (i.e. in a most-recently-accessed
* list).
*/
LinkBackground = 3,
/**
* Fifth color; corresponds to visited links.
*
* This can also be used to indicate "not recent" content, especially
* when a color is needed to denote content which is "old" or
* "archival".
*/
VisitedBackground = 4,
/**
* Sixth color; for example, errors, untrusted content, etc.
*/
NegativeBackground = 5,
/**
* Seventh color; for example, warnings, secure/encrypted content.
*/
NeutralBackground = 6,
/**
* Eigth color; for example, success messages, trusted content.
*/
PositiveBackground = 7
};
/**
* This enumeration describes the foreground color being selected from the
* given set.
*
* Foreground colors are suitable for drawing text or glyphs (such as the
* symbols on window decoration buttons, assuming a suitable background
* brush is used), and should never be used to draw backgrounds.
*
* For window decorations, the following is suggested, but not set in
* stone:
* @li Maximize - PositiveText
* @li Minimize - NeutralText
* @li Close - NegativeText
* @li WhatsThis - LinkText
* @li Sticky - ActiveText
*/
enum ForegroundRole {
/**
* Normal foreground.
*/
NormalText = 0,
/**
* Second color; for example, comments, items which are old, inactive
* or disabled. Generally used for things that are meant to be "less
* important". InactiveText is not the same role as NormalText in the
* inactive state.
*/
InactiveText = 1,
/**
* Third color; for example items which are new, active, requesting
* attention, etc. May be used as a hover color for clickable items.
*/
ActiveText = 2,
/**
* Fourth color; use for (unvisited) links. May also be used for other
* clickable items or content that indicates relationships, items that
* indicate somewhere the user can visit, etc.
*/
LinkText = 3,
/**
* Fifth color; used for (visited) links. As with LinkText, may be used
* for items that have already been "visited" or accessed. May also be
* used to indicate "historical" (i.e. "old") items or information,
* especially if InactiveText is being used in the same context to
* express something different.
*/
VisitedText = 4,
/**
* Sixth color; for example, errors, untrusted content, deletions,
* etc.
*/
NegativeText = 5,
/**
* Seventh color; for example, warnings, secure/encrypted content.
*/
NeutralText = 6,
/**
* Eigth color; for example, additions, success messages, trusted
* content.
*/
PositiveText = 7
};
/**
* Retrieve the requested shade color, using the specified color as the
* base color and the system contrast setting.
*
* @note Shades are chosen such that all shades would contrast with the
* base color. This means that if base is very dark, the 'dark' shades will
* be lighter than the base color, with midlight() == shadow().
* Conversely, if the base color is very light, the 'light' shades will be
* darker than the base color, with light() == mid().
*/
Q_INVOKABLE QColor shade(const QColor& color, ShadeRole role);
Q_INVOKABLE QColor shade(const QColor& color, ShadeRole role, qreal contrast); /**
* Retrieve the requested shade color, using the specified color as the
* base color and the specified contrast.
*
* @param contrast Amount roughly specifying the contrast by which to
* adjust the base color, between -1.0 and 1.0 (values between 0.0 and 1.0
* correspond to the value from KGlobalSettings::contrastF)
*
* @note Shades are chosen such that all shades would contrast with the
* base color. This means that if base is very dark, the 'dark' shades will
* be lighter than the base color, with midlight() == shadow().
* Conversely, if the base color is very light, the 'light' shades will be
* darker than the base color, with light() == mid().
*
* @see KColorUtils::shade
*/
Q_INVOKABLE QColor multiplyAlpha(const QColor& color, qreal alpha);
/**
* Retrieve the requested background brush's color for the @p active button.
* @param active Whether the active or inactive palette should be used.
*/
Q_INVOKABLE QColor background(bool active, BackgroundRole role = NormalBackground) const;
/**
* Retrieve the requested foreground brush's color for the @p active button.
* @param active Whether the active or inactive palette should be used.
*/
Q_INVOKABLE QColor foreground(bool active, ForegroundRole role = NormalText) const;
qreal contrast() const;
};
#endif

View File

@ -0,0 +1,126 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "decorationoptions.h"
#include <kdecoration.h>
namespace KWin
{
DecorationOptions::DecorationOptions(QObject *parent)
: QObject(parent)
, m_active(true)
, m_decoration(NULL)
{
connect(this, SIGNAL(decorationChanged()), SLOT(slotActiveChanged()));
connect(this, SIGNAL(decorationChanged()), SIGNAL(colorsChanged()));
connect(this, SIGNAL(decorationChanged()), SIGNAL(fontChanged()));
}
DecorationOptions::~DecorationOptions()
{
}
QColor DecorationOptions::borderColor() const
{
return KDecoration::options()->color(KDecorationDefines::ColorFrame, m_active);
}
QColor DecorationOptions::buttonColor() const
{
return KDecoration::options()->color(KDecorationDefines::ColorButtonBg, m_active);
}
QColor DecorationOptions::fontColor() const
{
return KDecoration::options()->color(KDecorationDefines::ColorFont, m_active);
}
QColor DecorationOptions::resizeHandleColor() const
{
return KDecoration::options()->color(KDecorationDefines::ColorHandle, m_active);
}
QColor DecorationOptions::titleBarBlendColor() const
{
return KDecoration::options()->color(KDecorationDefines::ColorTitleBlend, m_active);
}
QColor DecorationOptions::titleBarColor() const
{
return KDecoration::options()->color(KDecorationDefines::ColorTitleBar, m_active);
}
QFont DecorationOptions::titleFont() const
{
return KDecoration::options()->font(m_active);
}
QString DecorationOptions::titleButtonsLeft() const
{
if (KDecoration::options()->customButtonPositions()) {
return KDecoration::options()->titleButtonsLeft();
} else {
return KDecorationOptions::defaultTitleButtonsLeft();
}
}
QString DecorationOptions::titleButtonsRight() const
{
if (KDecoration::options()->customButtonPositions()) {
return KDecoration::options()->titleButtonsRight();
} else {
return KDecorationOptions::defaultTitleButtonsRight();
}
}
QObject *DecorationOptions::decoration() const
{
return m_decoration;
}
void DecorationOptions::setDecoration(QObject *decoration)
{
if (m_decoration == decoration) {
return;
}
if (m_decoration) {
// disconnect from existing decoration
disconnect(m_decoration, SIGNAL(activeChanged()), this, SLOT(slotActiveChanged()));
disconnect(m_decoration, SIGNAL(buttonsChanged()), this, SIGNAL(titleButtonsChanged()));
}
m_decoration = decoration;
connect(m_decoration, SIGNAL(activeChanged()), SLOT(slotActiveChanged()));
connect(m_decoration, SIGNAL(buttonsChanged()), SIGNAL(titleButtonsChanged()));
emit decorationChanged();
}
void DecorationOptions::slotActiveChanged()
{
if (!m_decoration) {
return;
}
if (m_active == m_decoration->property("active").toBool()) {
return;
}
m_active = m_decoration->property("active").toBool();
emit colorsChanged();
emit fontChanged();
}
} // namespace
#include "decorationoptions.moc"

View File

@ -0,0 +1,144 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_DECORATION_OPTIONS_H
#define KWIN_DECORATION_OPTIONS_H
#include <QObject>
#include <QColor>
#include <QFont>
namespace KWin
{
/**
* @short Common Window Decoration Options.
*
* This Class provides common window decoration options which can be used, but do not have to
* be used by a window decoration. The class provides properties for global settings such as
* color, font and decoration button position.
*
* If a window decoration wants to follow the global color scheme it should honor the values
* provided by the properties.
*
* In any case it makes sense to respect the font settings for the decoration as this is also
* an accessibility feature.
*
* In order to use the options in a QML based window decoration an instance of this object needs
* to be created and the as a context property available "decoration" needs to be passed to the
* DecorationOptions instance:
*
* @code
* DecorationOptions {
* id: options
* deco: decoration
* }
* @endcode
**/
class DecorationOptions : public QObject
{
Q_OBJECT
/**
* The decoration Object for which this set of options should be used. The decoration is
* required to get the correct colors and fonts depending on whether the decoration represents
* an active or inactive window.
*
* Best pass the decoration object available as a context property to this property.
**/
Q_PROPERTY(QObject *deco READ decoration WRITE setDecoration NOTIFY decorationChanged)
/**
* The color for the titlebar depending on the decoration's active state.
**/
Q_PROPERTY(QColor titleBarColor READ titleBarColor NOTIFY colorsChanged)
/**
* The blend color for the titlebar depending on the decoration's active state.
**/
Q_PROPERTY(QColor titleBarBlendColor READ titleBarBlendColor NOTIFY colorsChanged)
/**
* The titlebar text color depending on the decoration's active state.
**/
Q_PROPERTY(QColor fontColor READ fontColor NOTIFY colorsChanged)
/**
* The color to use for titlebar buttons depending on the decoration's active state.
**/
Q_PROPERTY(QColor buttonColor READ buttonColor NOTIFY colorsChanged)
/**
* The color for the window frame (border) depending on the decoration's active state.
**/
Q_PROPERTY(QColor borderColor READ borderColor NOTIFY colorsChanged)
/**
* The color for the resize handle depending on the decoration's active state.
**/
Q_PROPERTY(QColor resizeHandleColor READ resizeHandleColor NOTIFY colorsChanged)
/**
* The font to be used for the decoration caption depending on the decoration's active state.
**/
Q_PROPERTY(QFont titleFont READ titleFont NOTIFY fontChanged)
/**
* The buttons to be positioned on the left side of the titlebar from left to right.
*
* Characters in the returned string have the following meaning:
* <ul>
* <li>'M' menu button</li>
* <li>'S' on all desktops button</li>
* <li>'H' quickhelp button</li>
* <li>'I' minimize button</li>
* <li>'A' maximize button</li>
* <li>'X' close button</li>
* <li>'F' keep above button</li>
* <li>'B' keep below button</li>
* <li>'L' shade button</li>
* <li>'_' explicit spacer</li>
* </ul>
* @todo: make this a list of enum values
**/
Q_PROPERTY(QString titleButtonsLeft READ titleButtonsLeft NOTIFY titleButtonsChanged)
/**
* The buttons to be positioned on the right side of the titlebar from left to right.
* @see titleButtonsRight
**/
Q_PROPERTY(QString titleButtonsRight READ titleButtonsRight NOTIFY titleButtonsChanged)
public:
explicit DecorationOptions(QObject *parent = 0);
virtual ~DecorationOptions();
QColor titleBarColor() const;
QColor titleBarBlendColor() const;
QColor fontColor() const;
QColor buttonColor() const;
QColor borderColor() const;
QColor resizeHandleColor() const;
QFont titleFont() const;
QString titleButtonsLeft() const;
QString titleButtonsRight() const;
QObject *decoration() const;
void setDecoration(QObject *decoration);
signals:
void colorsChanged();
void fontChanged();
void decorationChanged();
void titleButtonsChanged();
private slots:
void slotActiveChanged();
private:
bool m_active;
QObject *m_decoration;
};
} // namespace
#endif // KWIN_DECORATION_OPTIONS_H

View File

@ -0,0 +1,30 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "decorationplugin.h"
#include "colorhelper.h"
#include "decorationoptions.h"
#include <qdeclarative.h>
Q_EXPORT_PLUGIN2(decorationplugin, DecorationPlugin)
void DecorationPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.kwin.decoration"));
qmlRegisterType<ColorHelper>(uri, 0, 1, "ColorHelper");
qmlRegisterType<KWin::DecorationOptions>(uri, 0, 1, "DecorationOptions");
}
#include "decorationplugin.moc"

View File

@ -0,0 +1,28 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef DECORATION_PLUGIN_H
#define DECORATION_PLUGIN_H
#include <QDeclarativeExtensionPlugin>
class DecorationPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
public:
void registerTypes(const char *uri);
};
#endif

View File

@ -0,0 +1,88 @@
/********************************************************************
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 1.1
Item {
function createButtons() {
for (var i=0; i<buttons.length; i++) {
var component = undefined;
switch (buttons.charAt(i)) {
case "_":
var button = Qt.createQmlObject("import QtQuick 1.1; Item{ width: " + group.explicitSpacer + "; height: parent.height}", groupRow, "dynamicGroup_" + buttons + i);
break;
case "A":
component = group.maximizeButton;
break;
case "B":
component = group.keepBelowButton;
break;
case "F":
component = group.keepAboveButton;
break;
case "H":
component = group.helpButton;
break;
case "I":
component = group.minimizeButton;
break;
case "L":
component = group.shadeButton;
break;
case "M":
component = group.menuButton;
break;
case "S":
component = group.allDesktopsButton;
break;
case "X":
component = group.closeButton;
break;
}
if (!component) {
continue;
}
var button = Qt.createQmlObject("import QtQuick 1.1; Loader{}", groupRow, "dynamicGroup_" + buttons + i);
button.sourceComponent = component;
}
}
id: group
property string buttons
property int explicitSpacer
property alias spacing: groupRow.spacing
property variant closeButton
property variant helpButton
property variant keepAboveButton
property variant keepBelowButton
property variant maximizeButton
property variant menuButton
property variant minimizeButton
property variant allDesktopsButton
property variant shadeButton
width: childrenRect.width
Row {
id: groupRow
}
onButtonsChanged: {
for (var i = 0; i < groupRow.children.length; i++) {
groupRow.children[i].destroy();
}
createButtons();
}
}

View File

@ -0,0 +1,6 @@
plugin decorationplugin
Decoration 0.1 Decoration.qml
DecorationButton 0.1 DecorationButton.qml
MenuButton 0.1 MenuButton.qml
ButtonGroup 0.1 ButtonGroup.qml