Proper button handling in Aurorae QML
Buttons are exported as a global "options" in the factory. Additionally the theme's buttons are also exported. The thme decided based on the custom button positions property which one to use. In the kcm the button options are also exported.
This commit is contained in:
parent
4e07ced451
commit
a1bee6f8a7
10 changed files with 165 additions and 62 deletions
|
@ -63,7 +63,7 @@ void AuroraeFactory::init()
|
||||||
}
|
}
|
||||||
m_component->loadUrl(QUrl(KStandardDirs::locate("data", "kwin/aurorae/aurorae.qml")));
|
m_component->loadUrl(QUrl(KStandardDirs::locate("data", "kwin/aurorae/aurorae.qml")));
|
||||||
m_engine->rootContext()->setContextProperty("auroraeTheme", m_theme);
|
m_engine->rootContext()->setContextProperty("auroraeTheme", m_theme);
|
||||||
|
m_engine->rootContext()->setContextProperty("options", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuroraeFactory::~AuroraeFactory()
|
AuroraeFactory::~AuroraeFactory()
|
||||||
|
@ -82,6 +82,9 @@ AuroraeFactory *AuroraeFactory::instance()
|
||||||
|
|
||||||
bool AuroraeFactory::reset(unsigned long changed)
|
bool AuroraeFactory::reset(unsigned long changed)
|
||||||
{
|
{
|
||||||
|
if (changed & SettingButtons) {
|
||||||
|
emit buttonsChanged();
|
||||||
|
}
|
||||||
init();
|
init();
|
||||||
resetDecorations(changed);
|
resetDecorations(changed);
|
||||||
return false; // need hard reset
|
return false; // need hard reset
|
||||||
|
@ -134,6 +137,21 @@ QDeclarativeItem *AuroraeFactory::createQmlDecoration(Aurorae::AuroraeClient *cl
|
||||||
return qobject_cast< QDeclarativeItem* >(m_component->create(context));
|
return qobject_cast< QDeclarativeItem* >(m_component->create(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AuroraeFactory::rightButtons()
|
||||||
|
{
|
||||||
|
return options()->titleButtonsRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AuroraeFactory::leftButtons()
|
||||||
|
{
|
||||||
|
return options()->titleButtonsLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AuroraeFactory::customButtonPositions()
|
||||||
|
{
|
||||||
|
return options()->customButtonPositions();
|
||||||
|
}
|
||||||
|
|
||||||
AuroraeFactory *AuroraeFactory::s_instance = NULL;
|
AuroraeFactory *AuroraeFactory::s_instance = NULL;
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
|
@ -393,18 +411,6 @@ void AuroraeClient::titleMouseMoved(Qt::MouseButton button, Qt::MouseButtons but
|
||||||
event = 0;
|
event = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AuroraeClient::rightButtons() const
|
|
||||||
{
|
|
||||||
// TODO: make independent of Aurorae
|
|
||||||
return options()->customButtonPositions() ? options()->titleButtonsRight() : AuroraeFactory::instance()->theme()->defaultButtonsRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AuroraeClient::leftButtons() const
|
|
||||||
{
|
|
||||||
// TODO: make independent of Aurorae
|
|
||||||
return options()->customButtonPositions() ? options()->titleButtonsLeft() : AuroraeFactory::instance()->theme()->defaultButtonsLeft();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AuroraeClient::themeChanged()
|
void AuroraeClient::themeChanged()
|
||||||
{
|
{
|
||||||
m_scene->clear();
|
m_scene->clear();
|
||||||
|
|
|
@ -37,6 +37,10 @@ class AuroraeClient;
|
||||||
|
|
||||||
class AuroraeFactory : public QObject, public KDecorationFactoryUnstable
|
class AuroraeFactory : public QObject, public KDecorationFactoryUnstable
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString leftButtons READ leftButtons NOTIFY buttonsChanged)
|
||||||
|
Q_PROPERTY(QString rightButtons READ rightButtons NOTIFY buttonsChanged)
|
||||||
|
Q_PROPERTY(bool customButtonPositions READ customButtonPositions NOTIFY buttonsChanged)
|
||||||
public:
|
public:
|
||||||
~AuroraeFactory();
|
~AuroraeFactory();
|
||||||
|
|
||||||
|
@ -50,11 +54,17 @@ public:
|
||||||
return m_theme;
|
return m_theme;
|
||||||
}
|
}
|
||||||
QDeclarativeItem *createQmlDecoration(AuroraeClient *client);
|
QDeclarativeItem *createQmlDecoration(AuroraeClient *client);
|
||||||
|
QString leftButtons();
|
||||||
|
QString rightButtons();
|
||||||
|
bool customButtonPositions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AuroraeFactory();
|
AuroraeFactory();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void buttonsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AuroraeFactory *s_instance;
|
static AuroraeFactory *s_instance;
|
||||||
|
|
||||||
|
@ -91,8 +101,6 @@ class AuroraeClient : public KDecorationUnstable
|
||||||
Q_PROPERTY(int width READ width)
|
Q_PROPERTY(int width READ width)
|
||||||
Q_PROPERTY(qulonglong windowId READ windowId CONSTANT)
|
Q_PROPERTY(qulonglong windowId READ windowId CONSTANT)
|
||||||
// TODO: window tabs - they suck for dynamic features
|
// TODO: window tabs - they suck for dynamic features
|
||||||
Q_PROPERTY(QString leftButtons READ leftButtons CONSTANT)
|
|
||||||
Q_PROPERTY(QString rightButtons READ rightButtons CONSTANT)
|
|
||||||
public:
|
public:
|
||||||
AuroraeClient(KDecorationBridge* bridge, KDecorationFactory* factory);
|
AuroraeClient(KDecorationBridge* bridge, KDecorationFactory* factory);
|
||||||
virtual ~AuroraeClient();
|
virtual ~AuroraeClient();
|
||||||
|
@ -110,8 +118,6 @@ public:
|
||||||
// optional overrides
|
// optional overrides
|
||||||
virtual void padding(int &left, int &right, int &top, int &bottom) const;
|
virtual void padding(int &left, int &right, int &top, int &bottom) const;
|
||||||
virtual void reset(long unsigned int changed);
|
virtual void reset(long unsigned int changed);
|
||||||
QString leftButtons() const;
|
|
||||||
QString rightButtons() const;
|
|
||||||
bool isMaximized() const;
|
bool isMaximized() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
|
@ -107,6 +107,8 @@ class /*LIBAURORAE_EXPORT*/ AuroraeTheme : public QObject
|
||||||
Q_PROPERTY(QColor inactiveTextColor READ inactiveTextColor NOTIFY themeChanged)
|
Q_PROPERTY(QColor inactiveTextColor READ inactiveTextColor NOTIFY themeChanged)
|
||||||
Q_PROPERTY(Qt::Alignment horizontalAlignment READ alignment NOTIFY themeChanged)
|
Q_PROPERTY(Qt::Alignment horizontalAlignment READ alignment NOTIFY themeChanged)
|
||||||
Q_PROPERTY(Qt::Alignment verticalAlignment READ verticalAlignment NOTIFY themeChanged)
|
Q_PROPERTY(Qt::Alignment verticalAlignment READ verticalAlignment NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(QString defaultButtonsLeft READ defaultButtonsLeft NOTIFY themeChanged)
|
||||||
|
Q_PROPERTY(QString defaultButtonsRight READ defaultButtonsRight NOTIFY themeChanged)
|
||||||
public:
|
public:
|
||||||
AuroraeTheme(QObject* parent = 0);
|
AuroraeTheme(QObject* parent = 0);
|
||||||
virtual ~AuroraeTheme();
|
virtual ~AuroraeTheme();
|
||||||
|
|
|
@ -96,7 +96,7 @@ Decoration {
|
||||||
}
|
}
|
||||||
AuroraeButtonGroup {
|
AuroraeButtonGroup {
|
||||||
id: leftButtonGroup
|
id: leftButtonGroup
|
||||||
buttons: decoration.leftButtons
|
buttons: options.customButtonPositions ? options.leftButtons : auroraeTheme.defaultButtonsLeft
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
|
@ -123,7 +123,7 @@ Decoration {
|
||||||
}
|
}
|
||||||
AuroraeButtonGroup {
|
AuroraeButtonGroup {
|
||||||
id: rightButtonGroup
|
id: rightButtonGroup
|
||||||
buttons: decoration.rightButtons
|
buttons: options.customButtonPositions ? options.rightButtons : auroraeTheme.defaultButtonsRight
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
|
|
|
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include "buttonsconfigdialog.h"
|
#include "buttonsconfigdialog.h"
|
||||||
|
#include "kwindecoration.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
@ -33,12 +34,10 @@ KWinDecorationButtonsConfigForm::KWinDecorationButtonsConfigForm(QWidget* parent
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
KWinDecorationButtonsConfigDialog::KWinDecorationButtonsConfigDialog(bool customPositions, bool showTooltips, QString buttonsLeft, QString buttonsRight, QWidget* parent, Qt::WFlags flags)
|
KWinDecorationButtonsConfigDialog::KWinDecorationButtonsConfigDialog(DecorationButtons const *buttons, bool showTooltips, QWidget* parent, Qt::WFlags flags)
|
||||||
: KDialog(parent, flags)
|
: KDialog(parent, flags)
|
||||||
, m_customPositions(customPositions)
|
|
||||||
, m_showTooltip(showTooltips)
|
, m_showTooltip(showTooltips)
|
||||||
, m_buttonsLeft(buttonsLeft)
|
, m_buttons(buttons)
|
||||||
, m_buttonsRight(buttonsRight)
|
|
||||||
{
|
{
|
||||||
m_ui = new KWinDecorationButtonsConfigForm(this);
|
m_ui = new KWinDecorationButtonsConfigForm(this);
|
||||||
setWindowTitle(i18n("Buttons"));
|
setWindowTitle(i18n("Buttons"));
|
||||||
|
@ -46,7 +45,7 @@ KWinDecorationButtonsConfigDialog::KWinDecorationButtonsConfigDialog(bool custom
|
||||||
enableButton(KDialog::Reset, false);
|
enableButton(KDialog::Reset, false);
|
||||||
QVBoxLayout* layout = new QVBoxLayout;
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
layout->addWidget(m_ui);
|
layout->addWidget(m_ui);
|
||||||
m_ui->buttonPositionWidget->setEnabled(customPositions);
|
m_ui->buttonPositionWidget->setEnabled(buttons->customPositions());
|
||||||
|
|
||||||
QWidget* main = new QWidget(this);
|
QWidget* main = new QWidget(this);
|
||||||
main->setLayout(layout);
|
main->setLayout(layout);
|
||||||
|
@ -101,10 +100,10 @@ void KWinDecorationButtonsConfigDialog::slotDefaultClicked()
|
||||||
|
|
||||||
void KWinDecorationButtonsConfigDialog::slotResetClicked()
|
void KWinDecorationButtonsConfigDialog::slotResetClicked()
|
||||||
{
|
{
|
||||||
m_ui->useCustomButtonPositionsCheckBox->setChecked(m_customPositions);
|
m_ui->useCustomButtonPositionsCheckBox->setChecked(m_buttons->customPositions());
|
||||||
m_ui->showToolTipsCheckBox->setChecked(m_showTooltip);
|
m_ui->showToolTipsCheckBox->setChecked(m_showTooltip);
|
||||||
m_ui->buttonPositionWidget->setButtonsLeft(m_buttonsLeft);
|
m_ui->buttonPositionWidget->setButtonsLeft(m_buttons->leftButtons());
|
||||||
m_ui->buttonPositionWidget->setButtonsRight(m_buttonsRight);
|
m_ui->buttonPositionWidget->setButtonsRight(m_buttons->rightButtons());
|
||||||
changed();
|
changed();
|
||||||
enableButton(KDialog::Reset, false);
|
enableButton(KDialog::Reset, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class DecorationButtons;
|
||||||
|
|
||||||
class KWinDecorationButtonsConfigForm : public QWidget, public Ui::KWinDecorationButtonsConfigForm
|
class KWinDecorationButtonsConfigForm : public QWidget, public Ui::KWinDecorationButtonsConfigForm
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -40,7 +42,7 @@ class KWinDecorationButtonsConfigDialog : public KDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
KWinDecorationButtonsConfigDialog(bool customPositions, bool showTooltips, QString buttonsLeft, QString buttonsRight, QWidget* parent = 0, Qt::WFlags flags = 0);
|
KWinDecorationButtonsConfigDialog(DecorationButtons const *buttons, bool showTooltips, QWidget* parent = 0, Qt::WFlags flags = 0);
|
||||||
~KWinDecorationButtonsConfigDialog();
|
~KWinDecorationButtonsConfigDialog();
|
||||||
|
|
||||||
bool customPositions() const;
|
bool customPositions() const;
|
||||||
|
@ -55,10 +57,8 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KWinDecorationButtonsConfigForm* m_ui;
|
KWinDecorationButtonsConfigForm* m_ui;
|
||||||
bool m_customPositions;
|
|
||||||
bool m_showTooltip;
|
bool m_showTooltip;
|
||||||
QString m_buttonsLeft;
|
DecorationButtons const *m_buttons;
|
||||||
QString m_buttonsRight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace KWin
|
} // namespace KWin
|
||||||
|
|
|
@ -236,14 +236,14 @@ bool DecorationModel::setData(const QModelIndex& index, const QVariant& value, i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DecorationModel::changeButtons(bool custom, const QString& left, const QString& right)
|
void DecorationModel::changeButtons(const KWin::DecorationButtons *buttons)
|
||||||
{
|
{
|
||||||
bool regenerate = (custom != m_customButtons);
|
bool regenerate = (buttons->customPositions() != m_customButtons);
|
||||||
if (!regenerate && custom)
|
if (!regenerate && buttons->customPositions())
|
||||||
regenerate = (left != m_leftButtons) || (right != m_rightButtons);
|
regenerate = (buttons->leftButtons() != m_leftButtons) || (buttons->rightButtons() != m_rightButtons);
|
||||||
m_customButtons = custom;
|
m_customButtons = buttons->customPositions();
|
||||||
m_leftButtons = left;
|
m_leftButtons = buttons->leftButtons();
|
||||||
m_rightButtons = right;
|
m_rightButtons = buttons->rightButtons();
|
||||||
if (regenerate)
|
if (regenerate)
|
||||||
regeneratePreviews();
|
regeneratePreviews();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ class KDecorationPreview;
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class DecorationButtons;
|
||||||
|
|
||||||
class DecorationModelData
|
class DecorationModelData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -93,7 +95,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Changes the button state and regenerates the preview.
|
* Changes the button state and regenerates the preview.
|
||||||
*/
|
*/
|
||||||
void changeButtons(bool custom, const QString& left, const QString& right);
|
void changeButtons(const DecorationButtons *buttons);
|
||||||
/**
|
/**
|
||||||
* Changes the button state without regenerating the preview.
|
* Changes the button state without regenerating the preview.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -70,10 +70,8 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const QVariantList &
|
||||||
: KCModule(KWinDecoFactory::componentData(), parent)
|
: KCModule(KWinDecoFactory::componentData(), parent)
|
||||||
, kwinConfig(KSharedConfig::openConfig("kwinrc"))
|
, kwinConfig(KSharedConfig::openConfig("kwinrc"))
|
||||||
, m_showTooltips(false)
|
, m_showTooltips(false)
|
||||||
, m_customPositions(false)
|
|
||||||
, m_leftButtons(QString())
|
|
||||||
, m_rightButtons(QString())
|
|
||||||
, m_configLoaded(false)
|
, m_configLoaded(false)
|
||||||
|
, m_decorationButtons(new DecorationButtons(this))
|
||||||
{
|
{
|
||||||
qmlRegisterType<Aurorae::AuroraeTheme>("org.kde.kwin.aurorae", 0, 1, "AuroraeTheme");
|
qmlRegisterType<Aurorae::AuroraeTheme>("org.kde.kwin.aurorae", 0, 1, "AuroraeTheme");
|
||||||
m_ui = new KWinDecorationForm(this);
|
m_ui = new KWinDecorationForm(this);
|
||||||
|
@ -95,6 +93,7 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const QVariantList &
|
||||||
m_ui->decorationList->engine()->addImportPath(importPath);
|
m_ui->decorationList->engine()->addImportPath(importPath);
|
||||||
}
|
}
|
||||||
m_ui->decorationList->rootContext()->setContextProperty("decorationModel", m_proxyModel);
|
m_ui->decorationList->rootContext()->setContextProperty("decorationModel", m_proxyModel);
|
||||||
|
m_ui->decorationList->rootContext()->setContextProperty("options", m_decorationButtons);
|
||||||
m_ui->decorationList->rootContext()->setContextProperty("auroraeSource", KStandardDirs::locate("data", "kwin/aurorae/aurorae.qml"));
|
m_ui->decorationList->rootContext()->setContextProperty("auroraeSource", KStandardDirs::locate("data", "kwin/aurorae/aurorae.qml"));
|
||||||
m_ui->decorationList->setSource(KStandardDirs::locate("data", "kwin/kcm_kwindecoration/main.qml"));
|
m_ui->decorationList->setSource(KStandardDirs::locate("data", "kwin/kcm_kwindecoration/main.qml"));
|
||||||
|
|
||||||
|
@ -172,16 +171,16 @@ void KWinDecorationModule::readConfig(const KConfigGroup & conf)
|
||||||
|
|
||||||
// Buttons tab
|
// Buttons tab
|
||||||
// ============
|
// ============
|
||||||
m_customPositions = 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_leftButtons = conf.readEntry("ButtonsOnLeft", KDecorationOptions::defaultTitleButtonsLeft());
|
m_decorationButtons->setLeftButtons(conf.readEntry("ButtonsOnLeft", KDecorationOptions::defaultTitleButtonsLeft()));
|
||||||
// Help, Minimize, Maximize and Close are default on RHS
|
// Help, Minimize, Maximize and Close are default on RHS
|
||||||
m_rightButtons = conf.readEntry("ButtonsOnRight", KDecorationOptions::defaultTitleButtonsRight());
|
m_decorationButtons->setRightButtons(conf.readEntry("ButtonsOnRight", KDecorationOptions::defaultTitleButtonsRight()));
|
||||||
if (m_configLoaded)
|
if (m_configLoaded)
|
||||||
m_model->changeButtons(m_customPositions, m_leftButtons, m_rightButtons);
|
m_model->changeButtons(m_decorationButtons);
|
||||||
else {
|
else {
|
||||||
m_configLoaded = true;
|
m_configLoaded = true;
|
||||||
m_model->setButtons(m_customPositions, m_leftButtons, m_rightButtons);
|
m_model->setButtons(m_decorationButtons->customPositions(), m_decorationButtons->leftButtons(), m_decorationButtons->rightButtons());
|
||||||
}
|
}
|
||||||
|
|
||||||
emit KCModule::changed(false);
|
emit KCModule::changed(false);
|
||||||
|
@ -196,12 +195,12 @@ void KWinDecorationModule::writeConfig(KConfigGroup & conf)
|
||||||
|
|
||||||
// General settings
|
// General settings
|
||||||
conf.writeEntry("PluginLib", libName);
|
conf.writeEntry("PluginLib", libName);
|
||||||
conf.writeEntry("CustomButtonPositions", m_customPositions);
|
conf.writeEntry("CustomButtonPositions", m_decorationButtons->customPositions());
|
||||||
conf.writeEntry("ShowToolTips", m_showTooltips);
|
conf.writeEntry("ShowToolTips", m_showTooltips);
|
||||||
|
|
||||||
// Button settings
|
// Button settings
|
||||||
conf.writeEntry("ButtonsOnLeft", m_leftButtons);
|
conf.writeEntry("ButtonsOnLeft", m_decorationButtons->leftButtons());
|
||||||
conf.writeEntry("ButtonsOnRight", m_rightButtons);
|
conf.writeEntry("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()));
|
||||||
|
|
||||||
|
@ -243,16 +242,14 @@ void KWinDecorationModule::save()
|
||||||
void KWinDecorationModule::defaults()
|
void KWinDecorationModule::defaults()
|
||||||
{
|
{
|
||||||
// Set the KDE defaults
|
// Set the KDE defaults
|
||||||
m_customPositions = false;
|
|
||||||
m_showTooltips = true;
|
m_showTooltips = true;
|
||||||
const QModelIndex index = m_proxyModel->mapFromSource(m_model->indexOfName(i18n("Oxygen")));
|
const QModelIndex index = m_proxyModel->mapFromSource(m_model->indexOfName(i18n("Oxygen")));
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
m_ui->decorationList->rootObject()->setProperty("currentIndex", index.row());
|
m_ui->decorationList->rootObject()->setProperty("currentIndex", index.row());
|
||||||
|
|
||||||
m_leftButtons = KDecorationOptions::defaultTitleButtonsLeft();
|
m_decorationButtons->resetToDefaults();
|
||||||
m_rightButtons = KDecorationOptions::defaultTitleButtonsRight();
|
|
||||||
|
|
||||||
m_model->changeButtons(m_customPositions, m_leftButtons, m_rightButtons);
|
m_model->changeButtons(m_decorationButtons);
|
||||||
|
|
||||||
emit changed(true);
|
emit changed(true);
|
||||||
}
|
}
|
||||||
|
@ -271,13 +268,13 @@ QString KWinDecorationModule::quickHelp() const
|
||||||
|
|
||||||
void KWinDecorationModule::slotConfigureButtons()
|
void KWinDecorationModule::slotConfigureButtons()
|
||||||
{
|
{
|
||||||
QPointer< KWinDecorationButtonsConfigDialog > configDialog = new KWinDecorationButtonsConfigDialog(m_customPositions, m_showTooltips, m_leftButtons, m_rightButtons, this);
|
QPointer< KWinDecorationButtonsConfigDialog > configDialog = new KWinDecorationButtonsConfigDialog(m_decorationButtons, m_showTooltips, this);
|
||||||
if (configDialog->exec() == KDialog::Accepted) {
|
if (configDialog->exec() == KDialog::Accepted) {
|
||||||
m_customPositions = configDialog->customPositions();
|
m_decorationButtons->setCustomPositions(configDialog->customPositions());
|
||||||
m_showTooltips = configDialog->showTooltips();
|
m_showTooltips = configDialog->showTooltips();
|
||||||
m_leftButtons = configDialog->buttonsLeft();
|
m_decorationButtons->setLeftButtons(configDialog->buttonsLeft());
|
||||||
m_rightButtons = configDialog->buttonsRight();
|
m_decorationButtons->setRightButtons(configDialog->buttonsRight());
|
||||||
m_model->changeButtons(m_customPositions, m_leftButtons, m_rightButtons);
|
m_model->changeButtons(m_decorationButtons);
|
||||||
emit changed(true);
|
emit changed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,6 +344,67 @@ void KWinDecorationModule::slotConfigureDecoration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DecorationButtons::DecorationButtons(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_customPositions(false)
|
||||||
|
, m_leftButtons(KDecorationOptions::defaultTitleButtonsLeft())
|
||||||
|
, m_rightButtons(KDecorationOptions::defaultTitleButtonsRight())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DecorationButtons::~DecorationButtons()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DecorationButtons::customPositions() const
|
||||||
|
{
|
||||||
|
return m_customPositions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &DecorationButtons::leftButtons() const
|
||||||
|
{
|
||||||
|
return m_leftButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &DecorationButtons::rightButtons() const
|
||||||
|
{
|
||||||
|
return m_rightButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecorationButtons::setCustomPositions(bool set)
|
||||||
|
{
|
||||||
|
if (m_customPositions == set) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_customPositions = set;
|
||||||
|
emit customPositionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecorationButtons::setLeftButtons(const QString &leftButtons)
|
||||||
|
{
|
||||||
|
if (m_leftButtons == leftButtons) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_leftButtons = leftButtons;
|
||||||
|
emit leftButtonsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecorationButtons::setRightButtons (const QString &rightButtons)
|
||||||
|
{
|
||||||
|
if (m_rightButtons == rightButtons) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_rightButtons = rightButtons;
|
||||||
|
emit rightButtonsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecorationButtons::resetToDefaults()
|
||||||
|
{
|
||||||
|
setCustomPositions(false);
|
||||||
|
setLeftButtons(KDecorationOptions::defaultTitleButtonsLeft());
|
||||||
|
setRightButtons(KDecorationOptions::defaultTitleButtonsRight());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace KWin
|
} // namespace KWin
|
||||||
|
|
||||||
#include "kwindecoration.moc"
|
#include "kwindecoration.moc"
|
||||||
|
|
|
@ -52,6 +52,38 @@ public:
|
||||||
explicit KWinDecorationForm(QWidget* parent);
|
explicit KWinDecorationForm(QWidget* parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DecorationButtons : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
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:
|
||||||
|
explicit DecorationButtons(QObject *parent = 0);
|
||||||
|
virtual ~DecorationButtons();
|
||||||
|
|
||||||
|
bool customPositions() const;
|
||||||
|
const QString &leftButtons() const;
|
||||||
|
const QString &rightButtons() const;
|
||||||
|
|
||||||
|
void setCustomPositions(bool set);
|
||||||
|
void setLeftButtons(const QString &leftButtons);
|
||||||
|
void setRightButtons(const QString &rightButtons);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void resetToDefaults();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void customPositionsChanged();
|
||||||
|
void leftButtonsChanged();
|
||||||
|
void rightButtonsChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_customPositions;
|
||||||
|
QString m_leftButtons;
|
||||||
|
QString m_rightButtons;
|
||||||
|
};
|
||||||
|
|
||||||
class KWinDecorationModule : public KCModule, public KDecorationDefines
|
class KWinDecorationModule : public KCModule, public KDecorationDefines
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -88,13 +120,11 @@ private:
|
||||||
|
|
||||||
KWinDecorationForm* m_ui;
|
KWinDecorationForm* m_ui;
|
||||||
bool m_showTooltips;
|
bool m_showTooltips;
|
||||||
bool m_customPositions;
|
|
||||||
QString m_leftButtons;
|
|
||||||
QString m_rightButtons;
|
|
||||||
|
|
||||||
DecorationModel* m_model;
|
DecorationModel* m_model;
|
||||||
QSortFilterProxyModel* m_proxyModel;
|
QSortFilterProxyModel* m_proxyModel;
|
||||||
bool m_configLoaded;
|
bool m_configLoaded;
|
||||||
|
DecorationButtons *m_decorationButtons;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
Loading…
Reference in a new issue