[kcmdeco] Use new DecorationButton types for describing the buttons
Rather heavy change to get the kcm to no longer use the string based definition of the buttons on the left and right.
This commit is contained in:
parent
b73d90cf78
commit
07294b49f2
10 changed files with 115 additions and 111 deletions
|
@ -64,7 +64,7 @@ ButtonDrag::ButtonDrag(Button btn)
|
||||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||||
stream << btn.name;
|
stream << btn.name;
|
||||||
stream << btn.icon;
|
stream << btn.icon;
|
||||||
stream << btn.type.unicode();
|
stream << btn.type;
|
||||||
stream << (int) btn.duplicate;
|
stream << (int) btn.duplicate;
|
||||||
stream << (int) btn.supported;
|
stream << (int) btn.supported;
|
||||||
setData(BUTTONDRAGMIMETYPE, data);
|
setData(BUTTONDRAGMIMETYPE, data);
|
||||||
|
@ -84,9 +84,9 @@ bool ButtonDrag::decode(QDropEvent* e, Button& btn)
|
||||||
QDataStream stream(data);
|
QDataStream stream(data);
|
||||||
stream >> btn.name;
|
stream >> btn.name;
|
||||||
stream >> btn.icon;
|
stream >> btn.icon;
|
||||||
ushort type;
|
int type;
|
||||||
stream >> type;
|
stream >> type;
|
||||||
btn.type = QChar(type);
|
btn.type = KDecorationDefines::DecorationButton(type);
|
||||||
int duplicate;
|
int duplicate;
|
||||||
stream >> duplicate;
|
stream >> duplicate;
|
||||||
btn.duplicate = duplicate;
|
btn.duplicate = duplicate;
|
||||||
|
@ -103,7 +103,7 @@ Button::Button()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button(const QString& n, const QBitmap& i, QChar t, bool d, bool s)
|
Button::Button(const QString& n, const QBitmap& i, KDecorationDefines::DecorationButton t, bool d, bool s)
|
||||||
: name(n),
|
: name(n),
|
||||||
icon(i),
|
icon(i),
|
||||||
type(t),
|
type(t),
|
||||||
|
@ -696,115 +696,126 @@ ButtonPositionWidget::ButtonPositionWidget(QWidget *parent)
|
||||||
|
|
||||||
if (style == "ButtonVertical") {
|
if (style == "ButtonVertical") {
|
||||||
m_supportedButtons = "MNSHIAX_FBLR"; // support all buttons
|
m_supportedButtons = "MNSHIAX_FBLR"; // support all buttons
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('N', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonApplicationMenu, dummy));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('R', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonResize, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('L', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonShade, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('B', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonKeepBelow, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('F', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonKeepAbove, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('X', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonClose, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('A', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonMaximizeRestore, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('I', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonMinimize, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('H', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonQuickHelp, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('S', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonOnAllDesktops, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('M', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonMenu, dummy));
|
||||||
new ButtonSourceItem(m_buttonSource, getButton('_', dummy));
|
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonExplicitSpacer, dummy));
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonPositionWidget::~ButtonPositionWidget()
|
ButtonPositionWidget::~ButtonPositionWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Button ButtonPositionWidget::getButton(QChar type, bool& success)
|
Button ButtonPositionWidget::getButton(KDecorationDefines::DecorationButton type, bool& success)
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
if (type == 'R') {
|
switch (type) {
|
||||||
|
case KDecorationDefines::DecorationButtonResize: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(resize_width, resize_height), resize_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(resize_width, resize_height), resize_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Resize"), bmp, 'R', false, m_supportedButtons.contains('R'));
|
return Button(i18n("Resize"), bmp, type, false, m_supportedButtons.contains('R'));
|
||||||
} else if (type == 'L') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonShade: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(shade_width, shade_height), shade_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(shade_width, shade_height), shade_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Shade"), bmp, 'L', false, m_supportedButtons.contains('L'));
|
return Button(i18n("Shade"), bmp, type, false, m_supportedButtons.contains('L'));
|
||||||
} else if (type == 'B') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonKeepBelow: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(keepbelowothers_width, keepbelowothers_height), keepbelowothers_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(keepbelowothers_width, keepbelowothers_height), keepbelowothers_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Keep Below Others"), bmp, 'B', false, m_supportedButtons.contains('B'));
|
return Button(i18n("Keep Below Others"), bmp, type, false, m_supportedButtons.contains('B'));
|
||||||
} else if (type == 'F') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonKeepAbove: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(keepaboveothers_width, keepaboveothers_height), keepaboveothers_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(keepaboveothers_width, keepaboveothers_height), keepaboveothers_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Keep Above Others"), bmp, 'F', false, m_supportedButtons.contains('F'));
|
return Button(i18n("Keep Above Others"), bmp, type, false, m_supportedButtons.contains('F'));
|
||||||
} else if (type == 'X') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonClose: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(close_width, close_height), close_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(close_width, close_height), close_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Close"), bmp, 'X', false, m_supportedButtons.contains('X'));
|
return Button(i18n("Close"), bmp, type, false, m_supportedButtons.contains('X'));
|
||||||
} else if (type == 'A') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonMaximizeRestore: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(maximize_width, maximize_height), maximize_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(maximize_width, maximize_height), maximize_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Maximize"), bmp, 'A', false, m_supportedButtons.contains('A'));
|
return Button(i18n("Maximize"), bmp, type, false, m_supportedButtons.contains('A'));
|
||||||
} else if (type == 'I') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonMinimize: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(minimize_width, minimize_height), minimize_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(minimize_width, minimize_height), minimize_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Minimize"), bmp, 'I', false, m_supportedButtons.contains('I'));
|
return Button(i18n("Minimize"), bmp, type, false, m_supportedButtons.contains('I'));
|
||||||
} else if (type == 'H') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonQuickHelp: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(help_width, help_height), help_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(help_width, help_height), help_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("Help"), bmp, 'H', false, m_supportedButtons.contains('H'));
|
return Button(i18n("Help"), bmp, type, false, m_supportedButtons.contains('H'));
|
||||||
} else if (type == 'S') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonOnAllDesktops: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(onalldesktops_width, onalldesktops_height), onalldesktops_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(onalldesktops_width, onalldesktops_height), onalldesktops_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("On All Desktops"), bmp, 'S', false, m_supportedButtons.contains('S'));
|
return Button(i18n("On All Desktops"), bmp, type, false, m_supportedButtons.contains('S'));
|
||||||
} else if (type == 'M') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonMenu: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18nc("Button showing window actions menu", "Window Menu"), bmp, 'M', false, m_supportedButtons.contains('M'));
|
return Button(i18nc("Button showing window actions menu", "Window Menu"), bmp, type, false, m_supportedButtons.contains('M'));
|
||||||
#ifdef KWIN_BUILD_KAPPMENU
|
#ifdef KWIN_BUILD_KAPPMENU
|
||||||
} else if (type == 'N') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonApplicationMenu: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18nc("Button showing application menu imported from dbusmenu", "Application Menu"), bmp, 'N', false, m_supportedButtons.contains('N'));
|
return Button(i18nc("Button showing application menu imported from dbusmenu", "Application Menu"), bmp, type, false, m_supportedButtons.contains('N'));
|
||||||
#endif
|
#endif
|
||||||
} else if (type == '_') {
|
}
|
||||||
|
case KDecorationDefines::DecorationButtonExplicitSpacer: {
|
||||||
QBitmap bmp = QBitmap::fromData(QSize(spacer_width, spacer_height), spacer_bits);
|
QBitmap bmp = QBitmap::fromData(QSize(spacer_width, spacer_height), spacer_bits);
|
||||||
bmp.createMaskFromColor(Qt::white);
|
bmp.createMaskFromColor(Qt::white);
|
||||||
return Button(i18n("--- spacer ---"), bmp, '_', true, m_supportedButtons.contains('_'));
|
return Button(i18n("--- spacer ---"), bmp, type, true, m_supportedButtons.contains('_'));
|
||||||
} else {
|
}
|
||||||
|
default:
|
||||||
success = false;
|
success = false;
|
||||||
return Button();
|
return Button();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ButtonPositionWidget::buttonsLeft() const
|
QList<KDecorationDefines::DecorationButton> ButtonPositionWidget::buttonsLeft() const
|
||||||
{
|
{
|
||||||
ButtonList btns = m_dropSite->buttonsLeft;
|
QList<KDecorationDefines::DecorationButton> ret;
|
||||||
QString btnString = "";
|
for (auto button : m_dropSite->buttonsLeft) {
|
||||||
for (ButtonList::const_iterator it = btns.constBegin(); it != btns.constEnd(); ++it) {
|
ret << button->button().type;
|
||||||
btnString.append((*it)->button().type);
|
|
||||||
}
|
}
|
||||||
return btnString;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ButtonPositionWidget::buttonsRight() const
|
QList<KDecorationDefines::DecorationButton> ButtonPositionWidget::buttonsRight() const
|
||||||
{
|
{
|
||||||
ButtonList btns = m_dropSite->buttonsRight;
|
QList<KDecorationDefines::DecorationButton> ret;
|
||||||
QString btnString = "";
|
for (auto button : m_dropSite->buttonsRight) {
|
||||||
for (ButtonList::const_iterator it = btns.constBegin(); it != btns.constEnd(); ++it) {
|
ret << button->button().type;
|
||||||
btnString.append((*it)->button().type);
|
|
||||||
}
|
}
|
||||||
return btnString;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonPositionWidget::setButtonsLeft(const QString &buttons)
|
void ButtonPositionWidget::setButtonsLeft(const QList<KDecorationDefines::DecorationButton> &buttons)
|
||||||
{
|
{
|
||||||
// to keep the button lists consistent, first remove all left buttons, then add buttons again...
|
// to keep the button lists consistent, first remove all left buttons, then add buttons again...
|
||||||
m_dropSite->clearLeft();
|
m_dropSite->clearLeft();
|
||||||
|
|
||||||
for (int i = 0; i < buttons.length(); ++i) {
|
for (auto button : buttons) {
|
||||||
bool succ = false;
|
bool succ = false;
|
||||||
Button btn = getButton(buttons[i], succ);
|
Button btn = getButton(button, succ);
|
||||||
if (succ) {
|
if (succ) {
|
||||||
m_dropSite->buttonsLeft.append(new ButtonDropSiteItem(btn));
|
m_dropSite->buttonsLeft.append(new ButtonDropSiteItem(btn));
|
||||||
m_buttonSource->hideButton(btn.type);
|
m_buttonSource->hideButton(btn.type);
|
||||||
|
@ -814,14 +825,14 @@ void ButtonPositionWidget::setButtonsLeft(const QString &buttons)
|
||||||
m_dropSite->update();
|
m_dropSite->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonPositionWidget::setButtonsRight(const QString &buttons)
|
void ButtonPositionWidget::setButtonsRight(const QList<KDecorationDefines::DecorationButton> &buttons)
|
||||||
{
|
{
|
||||||
// to keep the button lists consistent, first remove all left buttons, then add buttons again...
|
// to keep the button lists consistent, first remove all left buttons, then add buttons again...
|
||||||
m_dropSite->clearRight();
|
m_dropSite->clearRight();
|
||||||
|
|
||||||
for (int i = 0; i < buttons.length(); ++i) {
|
for (auto button : buttons) {
|
||||||
bool succ = false;
|
bool succ = false;
|
||||||
Button btn = getButton(buttons[i], succ);
|
Button btn = getButton(button, succ);
|
||||||
if (succ) {
|
if (succ) {
|
||||||
m_dropSite->buttonsRight.append(new ButtonDropSiteItem(btn));
|
m_dropSite->buttonsRight.append(new ButtonDropSiteItem(btn));
|
||||||
m_buttonSource->hideButton(btn.type);
|
m_buttonSource->hideButton(btn.type);
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
#ifndef BUTTONS_H
|
#ifndef BUTTONS_H
|
||||||
#define BUTTONS_H
|
#define BUTTONS_H
|
||||||
|
|
||||||
|
#include <kdecoration.h>
|
||||||
|
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
class KDecorationFactory;
|
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -48,12 +48,12 @@ class Button
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button();
|
Button();
|
||||||
Button(const QString& name, const QBitmap& icon, QChar type, bool duplicate, bool supported);
|
Button(const QString& name, const QBitmap& icon, KDecorationDefines::DecorationButton type, bool duplicate, bool supported);
|
||||||
virtual ~Button();
|
virtual ~Button();
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
QBitmap icon;
|
QBitmap icon;
|
||||||
QChar type;
|
KDecorationDefines::DecorationButton type;
|
||||||
bool duplicate;
|
bool duplicate;
|
||||||
bool supported;
|
bool supported;
|
||||||
};
|
};
|
||||||
|
@ -199,17 +199,17 @@ public:
|
||||||
explicit ButtonPositionWidget(QWidget *parent = 0);
|
explicit ButtonPositionWidget(QWidget *parent = 0);
|
||||||
~ButtonPositionWidget();
|
~ButtonPositionWidget();
|
||||||
|
|
||||||
QString buttonsLeft() const;
|
QList<KDecorationDefines::DecorationButton> buttonsLeft() const;
|
||||||
QString buttonsRight() const;
|
QList<KDecorationDefines::DecorationButton> buttonsRight() const;
|
||||||
void setButtonsLeft(const QString &buttons);
|
void setButtonsLeft(const QList<KDecorationDefines::DecorationButton> &buttons);
|
||||||
void setButtonsRight(const QString &buttons);
|
void setButtonsRight(const QList<KDecorationDefines::DecorationButton> &buttons);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearButtonList(const ButtonList& btns);
|
void clearButtonList(const ButtonList& btns);
|
||||||
Button getButton(QChar type, bool& success);
|
Button getButton(KDecorationDefines::DecorationButton type, bool& success);
|
||||||
|
|
||||||
ButtonDropSite* m_dropSite;
|
ButtonDropSite* m_dropSite;
|
||||||
ButtonSource *m_buttonSource;
|
ButtonSource *m_buttonSource;
|
||||||
|
|
|
@ -74,12 +74,12 @@ bool KWinDecorationButtonsConfigDialog::showTooltips() const
|
||||||
return m_ui->showToolTipsCheckBox->isChecked();
|
return m_ui->showToolTipsCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KWinDecorationButtonsConfigDialog::buttonsLeft() const
|
QList<KDecorationDefines::DecorationButton> KWinDecorationButtonsConfigDialog::buttonsLeft() const
|
||||||
{
|
{
|
||||||
return m_ui->buttonPositionWidget->buttonsLeft();
|
return m_ui->buttonPositionWidget->buttonsLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KWinDecorationButtonsConfigDialog::buttonsRight() const
|
QList<KDecorationDefines::DecorationButton> KWinDecorationButtonsConfigDialog::buttonsRight() const
|
||||||
{
|
{
|
||||||
return m_ui->buttonPositionWidget->buttonsRight();
|
return m_ui->buttonPositionWidget->buttonsRight();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ public:
|
||||||
|
|
||||||
bool customPositions() const;
|
bool customPositions() const;
|
||||||
bool showTooltips() const;
|
bool showTooltips() const;
|
||||||
QString buttonsLeft() const;
|
QList<KDecorationDefines::DecorationButton> buttonsLeft() const;
|
||||||
QString buttonsRight() const;
|
QList<KDecorationDefines::DecorationButton> buttonsRight() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
|
@ -56,8 +56,6 @@ DecorationModel::DecorationModel(KSharedConfigPtr config, QObject* parent)
|
||||||
, m_plugins(new KDecorationPreviewPlugins(config))
|
, m_plugins(new KDecorationPreviewPlugins(config))
|
||||||
, m_preview(new KDecorationPreview())
|
, m_preview(new KDecorationPreview())
|
||||||
, m_customButtons(false)
|
, m_customButtons(false)
|
||||||
, m_leftButtons(QString())
|
|
||||||
, m_rightButtons(QString())
|
|
||||||
, m_options(new KDecorationPreviewOptions)
|
, m_options(new KDecorationPreviewOptions)
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roleNames;
|
QHash<int, QByteArray> roleNames;
|
||||||
|
@ -313,19 +311,14 @@ bool DecorationModel::setData(const QModelIndex& index, const QVariant& value, i
|
||||||
void DecorationModel::changeButtons(const KWin::DecorationButtons *buttons)
|
void DecorationModel::changeButtons(const KWin::DecorationButtons *buttons)
|
||||||
{
|
{
|
||||||
m_customButtons = buttons->customPositions();
|
m_customButtons = buttons->customPositions();
|
||||||
m_leftButtons = buttons->leftButtons();
|
|
||||||
m_rightButtons = buttons->rightButtons();
|
|
||||||
m_options->setCustomTitleButtonsEnabled(m_customButtons);
|
m_options->setCustomTitleButtonsEnabled(m_customButtons);
|
||||||
m_options->setCustomTitleButtons(m_leftButtons, m_rightButtons);
|
m_options->setCustomTitleButtons(buttons->leftButtons(), buttons->rightButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecorationModel::setButtons(bool custom, const QString& left, const QString& right)
|
void DecorationModel::setButtons(bool custom, const QList<KDecorationDefines::DecorationButton> &left, const QList<KDecorationDefines::DecorationButton> &right)
|
||||||
{
|
{
|
||||||
m_customButtons = custom;
|
m_customButtons = custom;
|
||||||
m_leftButtons = left;
|
m_options->setCustomTitleButtons(left, right);
|
||||||
m_rightButtons = right;
|
|
||||||
m_options->setCustomTitleButtonsEnabled(m_customButtons);
|
|
||||||
m_options->setCustomTitleButtons(m_leftButtons, m_rightButtons);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex DecorationModel::indexOfLibrary(const QString& libraryName) const
|
QModelIndex DecorationModel::indexOfLibrary(const QString& libraryName) const
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Changes the button state without regenerating the preview.
|
* Changes the button state without regenerating the preview.
|
||||||
*/
|
*/
|
||||||
void setButtons(bool custom, const QString& left, const QString& right);
|
void setButtons(bool custom, const QList<KDecorationDefines::DecorationButton>& left, const QList<KDecorationDefines::DecorationButton>& right);
|
||||||
|
|
||||||
void setBorderSize(const QModelIndex& index, KDecorationDefines::BorderSize size);
|
void setBorderSize(const QModelIndex& index, KDecorationDefines::BorderSize size);
|
||||||
|
|
||||||
|
@ -127,8 +127,6 @@ private:
|
||||||
KDecorationPlugins* m_plugins;
|
KDecorationPlugins* m_plugins;
|
||||||
KDecorationPreview* m_preview;
|
KDecorationPreview* m_preview;
|
||||||
bool m_customButtons;
|
bool m_customButtons;
|
||||||
QString m_leftButtons;
|
|
||||||
QString m_rightButtons;
|
|
||||||
KSharedConfigPtr m_config;
|
KSharedConfigPtr m_config;
|
||||||
QScopedPointer<KDecorationPreviewOptions> m_options;
|
QScopedPointer<KDecorationPreviewOptions> m_options;
|
||||||
};
|
};
|
||||||
|
|
|
@ -216,9 +216,11 @@ void KWinDecorationModule::readConfig(const KConfigGroup & conf)
|
||||||
// ============
|
// ============
|
||||||
m_decorationButtons->setCustomPositions(conf.readEntry("CustomButtonPositions", false));
|
m_decorationButtons->setCustomPositions(conf.readEntry("CustomButtonPositions", false));
|
||||||
// Menu and onAllDesktops buttons are default on LHS
|
// Menu and onAllDesktops buttons are default on LHS
|
||||||
m_decorationButtons->setLeftButtons(conf.readEntry("ButtonsOnLeft", KDecorationOptions::defaultTitleButtonsLeft()));
|
m_decorationButtons->setLeftButtons(KDecorationOptions::readDecorationButtons(conf, "ButtonsOnLeft",
|
||||||
|
KDecorationOptions::defaultTitleButtonsLeft()));
|
||||||
// Help, Minimize, Maximize and Close are default on RHS
|
// Help, Minimize, Maximize and Close are default on RHS
|
||||||
m_decorationButtons->setRightButtons(conf.readEntry("ButtonsOnRight", KDecorationOptions::defaultTitleButtonsRight()));
|
m_decorationButtons->setRightButtons(KDecorationOptions::readDecorationButtons(conf, "ButtonsOnRight",
|
||||||
|
KDecorationOptions::defaultTitleButtonsRight()));
|
||||||
if (m_configLoaded)
|
if (m_configLoaded)
|
||||||
m_model->changeButtons(m_decorationButtons);
|
m_model->changeButtons(m_decorationButtons);
|
||||||
else {
|
else {
|
||||||
|
@ -242,8 +244,8 @@ void KWinDecorationModule::writeConfig(KConfigGroup & conf)
|
||||||
conf.writeEntry("ShowToolTips", m_showTooltips);
|
conf.writeEntry("ShowToolTips", m_showTooltips);
|
||||||
|
|
||||||
// Button settings
|
// Button settings
|
||||||
conf.writeEntry("ButtonsOnLeft", m_decorationButtons->leftButtons());
|
KDecorationOptions::writeDecorationButtons(conf, "ButtonsOnLeft", m_decorationButtons->leftButtons());
|
||||||
conf.writeEntry("ButtonsOnRight", m_decorationButtons->rightButtons());
|
KDecorationOptions::writeDecorationButtons(conf, "ButtonsOnRight", m_decorationButtons->rightButtons());
|
||||||
conf.writeEntry("BorderSize",
|
conf.writeEntry("BorderSize",
|
||||||
static_cast<int>(m_model->data(index, DecorationModel::BorderSizeRole).toInt()));
|
static_cast<int>(m_model->data(index, DecorationModel::BorderSizeRole).toInt()));
|
||||||
|
|
||||||
|
@ -508,9 +510,11 @@ void KWinDecorationModule::updateViewPosition(int v)
|
||||||
DecorationButtons::DecorationButtons(QObject *parent)
|
DecorationButtons::DecorationButtons(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_customPositions(false)
|
, m_customPositions(false)
|
||||||
, m_leftButtons(KDecorationOptions::defaultTitleButtonsLeft())
|
, m_leftButtons()
|
||||||
, m_rightButtons(KDecorationOptions::defaultTitleButtonsRight())
|
, m_rightButtons()
|
||||||
{
|
{
|
||||||
|
setLeftButtons(KDecorationOptions::defaultTitleButtonsLeft());
|
||||||
|
setRightButtons(KDecorationOptions::defaultTitleButtonsRight());
|
||||||
}
|
}
|
||||||
|
|
||||||
DecorationButtons::~DecorationButtons()
|
DecorationButtons::~DecorationButtons()
|
||||||
|
@ -522,12 +526,12 @@ bool DecorationButtons::customPositions() const
|
||||||
return m_customPositions;
|
return m_customPositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &DecorationButtons::leftButtons() const
|
const QList<KDecorationDefines::DecorationButton> &DecorationButtons::leftButtons() const
|
||||||
{
|
{
|
||||||
return m_leftButtons;
|
return m_leftButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &DecorationButtons::rightButtons() const
|
const QList<KDecorationDefines::DecorationButton> &DecorationButtons::rightButtons() const
|
||||||
{
|
{
|
||||||
return m_rightButtons;
|
return m_rightButtons;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +545,7 @@ void DecorationButtons::setCustomPositions(bool set)
|
||||||
emit customPositionsChanged();
|
emit customPositionsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecorationButtons::setLeftButtons(const QString &leftButtons)
|
void DecorationButtons::setLeftButtons(const QList<DecorationButton> &leftButtons)
|
||||||
{
|
{
|
||||||
if (m_leftButtons == leftButtons) {
|
if (m_leftButtons == leftButtons) {
|
||||||
return;
|
return;
|
||||||
|
@ -550,7 +554,7 @@ void DecorationButtons::setLeftButtons(const QString &leftButtons)
|
||||||
emit leftButtonsChanged();
|
emit leftButtonsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecorationButtons::setRightButtons (const QString &rightButtons)
|
void DecorationButtons::setRightButtons(const QList<DecorationButton> &rightButtons)
|
||||||
{
|
{
|
||||||
if (m_rightButtons == rightButtons) {
|
if (m_rightButtons == rightButtons) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -53,23 +53,21 @@ public:
|
||||||
explicit KWinDecorationForm(QWidget* parent);
|
explicit KWinDecorationForm(QWidget* parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DecorationButtons : public QObject
|
class DecorationButtons : public QObject, public KDecorationDefines
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool customButtonPositions READ customPositions WRITE setCustomPositions NOTIFY customPositionsChanged)
|
Q_PROPERTY(bool customButtonPositions READ customPositions WRITE setCustomPositions NOTIFY customPositionsChanged)
|
||||||
Q_PROPERTY(QString leftButtons READ leftButtons WRITE setLeftButtons NOTIFY leftButtonsChanged)
|
|
||||||
Q_PROPERTY(QString rightButtons READ rightButtons WRITE setRightButtons NOTIFY rightButtonsChanged)
|
|
||||||
public:
|
public:
|
||||||
explicit DecorationButtons(QObject *parent = 0);
|
explicit DecorationButtons(QObject *parent = 0);
|
||||||
virtual ~DecorationButtons();
|
virtual ~DecorationButtons();
|
||||||
|
|
||||||
bool customPositions() const;
|
bool customPositions() const;
|
||||||
const QString &leftButtons() const;
|
const QList<DecorationButton> &leftButtons() const;
|
||||||
const QString &rightButtons() const;
|
const QList<DecorationButton> &rightButtons() const;
|
||||||
|
|
||||||
void setCustomPositions(bool set);
|
void setCustomPositions(bool set);
|
||||||
void setLeftButtons(const QString &leftButtons);
|
void setLeftButtons(const QList<KDecorationDefines::DecorationButton> &buttons);
|
||||||
void setRightButtons(const QString &rightButtons);
|
void setRightButtons(const QList<KDecorationDefines::DecorationButton> &buttons);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
@ -81,8 +79,8 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_customPositions;
|
bool m_customPositions;
|
||||||
QString m_leftButtons;
|
QList<DecorationButton> m_leftButtons;
|
||||||
QString m_rightButtons;
|
QList<DecorationButton> m_rightButtons;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KWinDecorationModule : public KCModule, public KDecorationDefines
|
class KWinDecorationModule : public KCModule, public KDecorationDefines
|
||||||
|
|
|
@ -577,9 +577,9 @@ void KDecorationPreviewOptions::updateSettings()
|
||||||
if (customButtonsChanged)
|
if (customButtonsChanged)
|
||||||
setCustomButtonPositions(customButtons);
|
setCustomButtonPositions(customButtons);
|
||||||
if (customButtons) {
|
if (customButtons) {
|
||||||
if (!customTitleButtonsLeft.isNull())
|
if (!customTitleButtonsLeft.isEmpty())
|
||||||
setTitleButtonsLeft(customTitleButtonsLeft);
|
setTitleButtonsLeft(customTitleButtonsLeft);
|
||||||
if (!customTitleButtonsRight.isNull())
|
if (!customTitleButtonsRight.isEmpty())
|
||||||
setTitleButtonsRight(customTitleButtonsRight);
|
setTitleButtonsRight(customTitleButtonsRight);
|
||||||
} else {
|
} else {
|
||||||
setTitleButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
|
setTitleButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
|
||||||
|
@ -602,7 +602,7 @@ void KDecorationPreviewOptions::setCustomTitleButtonsEnabled(bool enabled)
|
||||||
updateSettings();
|
updateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KDecorationPreviewOptions::setCustomTitleButtons(const QString &left, const QString &right)
|
void KDecorationPreviewOptions::setCustomTitleButtons(const QList<DecorationButton> &left, const QList<DecorationButton> &right)
|
||||||
{
|
{
|
||||||
customTitleButtonsLeft = left;
|
customTitleButtonsLeft = left;
|
||||||
customTitleButtonsRight = right;
|
customTitleButtonsRight = right;
|
||||||
|
|
|
@ -182,14 +182,14 @@ public:
|
||||||
|
|
||||||
void setCustomBorderSize(BorderSize size);
|
void setCustomBorderSize(BorderSize size);
|
||||||
void setCustomTitleButtonsEnabled(bool enabled);
|
void setCustomTitleButtonsEnabled(bool enabled);
|
||||||
void setCustomTitleButtons(const QString &left, const QString &right);
|
void setCustomTitleButtons(const QList<DecorationButton> &left, const QList<DecorationButton> &right);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BorderSize customBorderSize;
|
BorderSize customBorderSize;
|
||||||
bool customButtonsChanged;
|
bool customButtonsChanged;
|
||||||
bool customButtons;
|
bool customButtons;
|
||||||
QString customTitleButtonsLeft;
|
QList<DecorationButton> customTitleButtonsLeft;
|
||||||
QString customTitleButtonsRight;
|
QList<DecorationButton> customTitleButtonsRight;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KDecorationPreviewPlugins
|
class KDecorationPreviewPlugins
|
||||||
|
|
Loading…
Reference in a new issue