From 03ff318661712cd8e50f423071b81147637618f5 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Thu, 16 Aug 2018 16:16:55 -0500 Subject: [PATCH] Add an autoexpansion feature to the spacer plugin. --- debian/changelog | 1 + debian/patches/add-autoexpansion-1.patch | 105 ++++++++++ debian/patches/add-autoexpansion-2.patch | 35 ++++ debian/patches/add-autoexpansion-3.patch | 238 +++++++++++++++++++++++ debian/patches/add-autoexpansion-4.patch | 114 +++++++++++ debian/patches/series | 4 + 6 files changed, 497 insertions(+) create mode 100644 debian/patches/add-autoexpansion-1.patch create mode 100644 debian/patches/add-autoexpansion-2.patch create mode 100644 debian/patches/add-autoexpansion-3.patch create mode 100644 debian/patches/add-autoexpansion-4.patch diff --git a/debian/changelog b/debian/changelog index cdba58d..be4de2a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ lxqt-panel (0.13.0-0ubuntu4) UNRELEASED; urgency=medium * Change the Uploaders to Ubuntu uploaders. * Update Standards-version to 4.2.0, no changes needed. + * Add an autoexpansion feature to the spacer plugin. -- Simon Quigley Thu, 16 Aug 2018 16:07:44 -0500 diff --git a/debian/patches/add-autoexpansion-1.patch b/debian/patches/add-autoexpansion-1.patch new file mode 100644 index 0000000..3d26ebf --- /dev/null +++ b/debian/patches/add-autoexpansion-1.patch @@ -0,0 +1,105 @@ +Description: Allow plugin's "static" configration change + This is patch 1/4 adding autoexpansion support to the spacer plugin. +Author: Palo Kisa +Origin: upstream +Bug: https://github.com/lxqt/lxqt/issues/1038 +Applied-Upstream: commit:6fbe184 +Last-Update: 2018-08-16 +--- a/panel/ilxqtpanel.h ++++ b/panel/ilxqtpanel.h +@@ -110,6 +110,16 @@ public: + * + */ + virtual void willShowWindow(QWidget * w) = 0; ++ ++ /*! ++ * \brief By calling this function, a plugin notifies the panel about change of it's "static" ++ * configuration ++ * ++ * \param plugin the changed plugin ++ * ++ * \sa ILXQtPanelPlugin::isSeparate(), ILXQtPanelPlugin::isExpandable ++ */ ++ virtual void pluginFlagsChanged(const ILXQtPanelPlugin * plugin) = 0; + }; + + #endif // ILXQTPANEL_H +--- a/panel/ilxqtpanelplugin.h ++++ b/panel/ilxqtpanelplugin.h +@@ -196,6 +196,17 @@ public: + mPanel->willShowWindow(w); + } + ++ /*! ++ * \brief By calling this function, a plugin notifies the panel about change of it's "static" ++ * configuration ++ * ++ * \sa isSeparate(), isExpandable ++ */ ++ inline void pluginFlagsChanged() ++ { ++ mPanel->pluginFlagsChanged(this); ++ } ++ + virtual bool isSeparate() const { return false; } + virtual bool isExpandable() const { return false; } + private: +--- a/panel/lxqtpanel.cpp ++++ b/panel/lxqtpanel.cpp +@@ -1225,6 +1225,14 @@ void LXQtPanel::willShowWindow(QWidget * + /************************************************ + + ************************************************/ ++void LXQtPanel::pluginFlagsChanged(const ILXQtPanelPlugin * /*plugin*/) ++{ ++ mLayout->rebuild(); ++} ++ ++/************************************************ ++ ++ ************************************************/ + QString LXQtPanel::qssPosition() const + { + return positionToStr(position()); +--- a/panel/lxqtpanel.h ++++ b/panel/lxqtpanel.h +@@ -146,6 +146,7 @@ public: + QRect calculatePopupWindowPos(QPoint const & absolutePos, QSize const & windowSize) const override; + QRect calculatePopupWindowPos(const ILXQtPanelPlugin *plugin, const QSize &windowSize) const override; + void willShowWindow(QWidget * w) override; ++ void pluginFlagsChanged(const ILXQtPanelPlugin * plugin) override; + // ........ end of ILXQtPanel overrides + + /** +--- a/panel/lxqtpanellayout.cpp ++++ b/panel/lxqtpanellayout.cpp +@@ -946,6 +946,16 @@ void LXQtPanelLayout::setLineCount(int v + /************************************************ + + ************************************************/ ++void LXQtPanelLayout::rebuild() ++{ ++ mLeftGrid->rebuild(); ++ mRightGrid->rebuild(); ++} ++ ++ ++/************************************************ ++ ++ ************************************************/ + int LXQtPanelLayout::lineSize() const + { + return mLeftGrid->lineSize(); +--- a/panel/lxqtpanellayout.h ++++ b/panel/lxqtpanellayout.h +@@ -73,6 +73,10 @@ public: + ILXQtPanel::Position position() const { return mPosition; } + void setPosition(ILXQtPanel::Position value); + ++ /*! \brief Force the layout to re-read items/plugins "static" configuration ++ */ ++ void rebuild(); ++ + static bool itemIsSeparate(QLayoutItem *item); + signals: + void pluginMoved(Plugin * plugin); diff --git a/debian/patches/add-autoexpansion-2.patch b/debian/patches/add-autoexpansion-2.patch new file mode 100644 index 0000000..c9f9d0e --- /dev/null +++ b/debian/patches/add-autoexpansion-2.patch @@ -0,0 +1,35 @@ +Description: Add "override" to declarations + This is patch 2/4 adding autoexpansion support to the spacer plugin. +Author: Palo Kisa +Origin: upstream +Bug: https://github.com/lxqt/lxqt/issues/1038 +Applied-Upstream: commit:764aadd +Last-Update: 2018-08-16 +--- a/plugin-spacer/spacer.h ++++ b/plugin-spacer/spacer.h +@@ -57,18 +57,18 @@ class Spacer : public QObject, public I + public: + Spacer(const ILXQtPanelPluginStartupInfo &startupInfo); + +- virtual QWidget *widget() { return &mSpacer; } +- virtual QString themeId() const { return "Spacer"; } ++ virtual QWidget *widget() override { return &mSpacer; } ++ virtual QString themeId() const override { return "Spacer"; } + +- bool isSeparate() const { return true; } ++ bool isSeparate() const override { return true; } + +- virtual ILXQtPanelPlugin::Flags flags() const { return HaveConfigDialog; } +- QDialog *configureDialog(); ++ virtual ILXQtPanelPlugin::Flags flags() const override { return HaveConfigDialog; } ++ QDialog *configureDialog() override; + +- virtual void realign(); ++ virtual void realign() override; + + private slots: +- virtual void settingsChanged(); ++ virtual void settingsChanged() override; + + private: + void setSizes(); diff --git a/debian/patches/add-autoexpansion-3.patch b/debian/patches/add-autoexpansion-3.patch new file mode 100644 index 0000000..dc58736 --- /dev/null +++ b/debian/patches/add-autoexpansion-3.patch @@ -0,0 +1,238 @@ +Description: Add auto-expansion feature + This is patch 3/4 adding autoexpansion support to the spacer plugin. +Author: Palo Kisa +Origin: upstream +Bug: https://github.com/lxqt/lxqt/issues/1038 +Applied-Upstream: commit:b57a178 +Last-Update: 2018-08-16 +--- a/plugin-spacer/spacer.cpp ++++ b/plugin-spacer/spacer.cpp +@@ -55,6 +55,7 @@ Spacer::Spacer(const ILXQtPanelPluginSta + QObject() + , ILXQtPanelPlugin(startupInfo) + , mSize(8) ++ , mExpandable(false) + { + settingsChanged(); + } +@@ -65,8 +66,12 @@ Spacer::Spacer(const ILXQtPanelPluginSta + void Spacer::settingsChanged() + { + mSize = settings()->value("size", 8).toInt(); ++ const bool old_expandable = mExpandable; ++ mExpandable = settings()->value("expandable", false).toBool(); + mSpacer.setType(settings()->value("spaceType", SpacerConfiguration::msTypes[0]).toString()); + setSizes(); ++ if (old_expandable != mExpandable) ++ pluginFlagsChanged(); + } + + /************************************************ +@@ -82,21 +87,30 @@ QDialog *Spacer::configureDialog() + ************************************************/ + void Spacer::setSizes() + { +- if (panel()->isHorizontal()) ++ if (mExpandable) + { +- mSpacer.setOrientation("horizontal"); +- mSpacer.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); +- mSpacer.setFixedWidth(mSize); +- mSpacer.setMinimumHeight(0); +- mSpacer.setMaximumHeight(QWIDGETSIZE_MAX); +- } +- else ++ mSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ++ mSpacer.setMinimumSize({1, 1}); ++ mSpacer.setMaximumSize({QWIDGETSIZE_MAX, QWIDGETSIZE_MAX}); ++ mSpacer.setOrientation(panel()->isHorizontal() ? "horizontal" : "vertical"); ++ } else + { +- mSpacer.setOrientation("vertical"); +- mSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); +- mSpacer.setFixedHeight(mSize); +- mSpacer.setMinimumWidth(0); +- mSpacer.setMaximumWidth(QWIDGETSIZE_MAX); ++ if (panel()->isHorizontal()) ++ { ++ mSpacer.setOrientation("horizontal"); ++ mSpacer.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); ++ mSpacer.setFixedWidth(mSize); ++ mSpacer.setMinimumHeight(0); ++ mSpacer.setMaximumHeight(QWIDGETSIZE_MAX); ++ } ++ else ++ { ++ mSpacer.setOrientation("vertical"); ++ mSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); ++ mSpacer.setFixedHeight(mSize); ++ mSpacer.setMinimumWidth(0); ++ mSpacer.setMaximumWidth(QWIDGETSIZE_MAX); ++ } + } + } + +--- a/plugin-spacer/spacer.h ++++ b/plugin-spacer/spacer.h +@@ -61,6 +61,7 @@ public: + virtual QString themeId() const override { return "Spacer"; } + + bool isSeparate() const override { return true; } ++ bool isExpandable() const override { return mExpandable; } + + virtual ILXQtPanelPlugin::Flags flags() const override { return HaveConfigDialog; } + QDialog *configureDialog() override; +@@ -76,6 +77,7 @@ private: + private: + SpacerWidget mSpacer; + int mSize; ++ int mExpandable; + }; + + class SpacerPluginLibrary: public QObject, public ILXQtPanelPluginLibrary +--- a/plugin-spacer/spacerconfiguration.cpp ++++ b/plugin-spacer/spacerconfiguration.cpp +@@ -52,6 +52,8 @@ SpacerConfiguration::SpacerConfiguration + + connect(ui->sizeSB, static_cast(&QSpinBox::valueChanged), this, &SpacerConfiguration::sizeChanged); + connect(ui->typeCB, static_cast(&QComboBox::currentIndexChanged), this, &SpacerConfiguration::typeChanged); ++ //Note: if there will be more than 2 radio buttons for width/size type, this simple setting logic will break ++ connect(ui->sizeExpandRB, &QAbstractButton::toggled, this, &SpacerConfiguration::widthTypeChanged); + } + + SpacerConfiguration::~SpacerConfiguration() +@@ -63,6 +65,10 @@ void SpacerConfiguration::loadSettings() + { + ui->sizeSB->setValue(settings().value("size", 8).toInt()); + ui->typeCB->setCurrentIndex(ui->typeCB->findData(settings().value("spaceType", msTypes[0]).toString())); ++ const bool expandable = settings().value("expandable", false).toBool(); ++ ui->sizeExpandRB->setChecked(expandable); ++ ui->sizeFixedRB->setChecked(!expandable); ++ ui->sizeSB->setDisabled(expandable); + } + + void SpacerConfiguration::sizeChanged(int value) +@@ -74,3 +80,8 @@ void SpacerConfiguration::typeChanged(in + { + settings().setValue("spaceType", ui->typeCB->itemData(index, Qt::UserRole)); + } ++ ++void SpacerConfiguration::widthTypeChanged(bool expandableChecked) ++{ ++ settings().setValue("expandable", expandableChecked); ++} +--- a/plugin-spacer/spacerconfiguration.h ++++ b/plugin-spacer/spacerconfiguration.h +@@ -58,6 +58,7 @@ private slots: + void loadSettings(); + void sizeChanged(int value); + void typeChanged(int index); ++ void widthTypeChanged(bool expandableChecked); + }; + + #endif // SPACERCONFIGURATION_H +--- a/plugin-spacer/spacerconfiguration.ui ++++ b/plugin-spacer/spacerconfiguration.ui +@@ -6,6 +6,8 @@ + + 0 + 0 ++ 289 ++ 135 + + + +@@ -19,7 +21,7 @@ + + + +- ++ + + + 4 +@@ -32,21 +34,14 @@ + + + +- ++ + + + Space type: + + + +- +- +- +- false +- +- +- +- ++ + + + Qt::Horizontal +@@ -56,6 +51,27 @@ + + + ++ ++ ++ ++ fixed ++ ++ ++ ++ ++ ++ ++ false ++ ++ ++ ++ ++ ++ ++ expandable ++ ++ ++ + + + +@@ -65,6 +81,32 @@ + clicked(QAbstractButton*) + SpacerConfiguration + close() ++ ++ ++ 20 ++ 20 ++ ++ ++ 20 ++ 20 ++ ++ ++ ++ ++ sizeFixedRB ++ toggled(bool) ++ sizeSB ++ setEnabled(bool) ++ ++ ++ 152 ++ 21 ++ ++ ++ 244 ++ 21 ++ ++ + + + diff --git a/debian/patches/add-autoexpansion-4.patch b/debian/patches/add-autoexpansion-4.patch new file mode 100644 index 0000000..3ca8802 --- /dev/null +++ b/debian/patches/add-autoexpansion-4.patch @@ -0,0 +1,114 @@ +Description: Use QStringLiteral whenever possible + This is patch 4/4 adding autoexpansion support to the spacer plugin. +Author: Palo Kisa +Origin: upstream +Bug: https://github.com/lxqt/lxqt/issues/1038 +Applied-Upstream: commit:4908fcd +Last-Update: 2018-08-16 +--- a/plugin-spacer/spacer.cpp ++++ b/plugin-spacer/spacer.cpp +@@ -65,10 +65,10 @@ Spacer::Spacer(const ILXQtPanelPluginSta + ************************************************/ + void Spacer::settingsChanged() + { +- mSize = settings()->value("size", 8).toInt(); ++ mSize = settings()->value(QStringLiteral("size"), 8).toInt(); + const bool old_expandable = mExpandable; +- mExpandable = settings()->value("expandable", false).toBool(); +- mSpacer.setType(settings()->value("spaceType", SpacerConfiguration::msTypes[0]).toString()); ++ mExpandable = settings()->value(QStringLiteral("expandable"), false).toBool(); ++ mSpacer.setType(settings()->value(QStringLiteral("spaceType"), SpacerConfiguration::msTypes[0]).toString()); + setSizes(); + if (old_expandable != mExpandable) + pluginFlagsChanged(); +@@ -92,12 +92,12 @@ void Spacer::setSizes() + mSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + mSpacer.setMinimumSize({1, 1}); + mSpacer.setMaximumSize({QWIDGETSIZE_MAX, QWIDGETSIZE_MAX}); +- mSpacer.setOrientation(panel()->isHorizontal() ? "horizontal" : "vertical"); ++ mSpacer.setOrientation(panel()->isHorizontal() ? QStringLiteral("horizontal") : QStringLiteral("vertical")); + } else + { + if (panel()->isHorizontal()) + { +- mSpacer.setOrientation("horizontal"); ++ mSpacer.setOrientation(QStringLiteral("horizontal")); + mSpacer.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + mSpacer.setFixedWidth(mSize); + mSpacer.setMinimumHeight(0); +@@ -105,7 +105,7 @@ void Spacer::setSizes() + } + else + { +- mSpacer.setOrientation("vertical"); ++ mSpacer.setOrientation(QStringLiteral("vertical")); + mSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + mSpacer.setFixedHeight(mSize); + mSpacer.setMinimumWidth(0); +--- a/plugin-spacer/spacer.h ++++ b/plugin-spacer/spacer.h +@@ -58,7 +58,7 @@ public: + Spacer(const ILXQtPanelPluginStartupInfo &startupInfo); + + virtual QWidget *widget() override { return &mSpacer; } +- virtual QString themeId() const override { return "Spacer"; } ++ virtual QString themeId() const override { return QStringLiteral("Spacer"); } + + bool isSeparate() const override { return true; } + bool isExpandable() const override { return mExpandable; } +--- a/plugin-spacer/spacerconfiguration.cpp ++++ b/plugin-spacer/spacerconfiguration.cpp +@@ -31,9 +31,9 @@ + //Note: strings can't actually be translated here (in static initialization time) + // the QT_TR_NOOP here is just for qt translate tools to get the strings for translation + const QStringList SpacerConfiguration::msTypes = { +- QLatin1String(QT_TR_NOOP("lined")) +- , QLatin1String(QT_TR_NOOP("dotted")) +- , QLatin1String(QT_TR_NOOP("invisible")) ++ QStringLiteral(QT_TR_NOOP("lined")) ++ , QStringLiteral(QT_TR_NOOP("dotted")) ++ , QStringLiteral(QT_TR_NOOP("invisible")) + }; + + SpacerConfiguration::SpacerConfiguration(PluginSettings *settings, QWidget *parent) : +@@ -41,7 +41,7 @@ SpacerConfiguration::SpacerConfiguration + ui(new Ui::SpacerConfiguration) + { + setAttribute(Qt::WA_DeleteOnClose); +- setObjectName("SpacerConfigurationWindow"); ++ setObjectName(QStringLiteral("SpacerConfigurationWindow")); + ui->setupUi(this); + + //Note: translation is needed here in runtime (translator is attached already) +@@ -63,9 +63,9 @@ SpacerConfiguration::~SpacerConfiguratio + + void SpacerConfiguration::loadSettings() + { +- ui->sizeSB->setValue(settings().value("size", 8).toInt()); +- ui->typeCB->setCurrentIndex(ui->typeCB->findData(settings().value("spaceType", msTypes[0]).toString())); +- const bool expandable = settings().value("expandable", false).toBool(); ++ ui->sizeSB->setValue(settings().value(QStringLiteral("size"), 8).toInt()); ++ ui->typeCB->setCurrentIndex(ui->typeCB->findData(settings().value(QStringLiteral("spaceType"), msTypes[0]).toString())); ++ const bool expandable = settings().value(QStringLiteral("expandable"), false).toBool(); + ui->sizeExpandRB->setChecked(expandable); + ui->sizeFixedRB->setChecked(!expandable); + ui->sizeSB->setDisabled(expandable); +@@ -73,15 +73,15 @@ void SpacerConfiguration::loadSettings() + + void SpacerConfiguration::sizeChanged(int value) + { +- settings().setValue("size", value); ++ settings().setValue(QStringLiteral("size"), value); + } + + void SpacerConfiguration::typeChanged(int index) + { +- settings().setValue("spaceType", ui->typeCB->itemData(index, Qt::UserRole)); ++ settings().setValue(QStringLiteral("spaceType"), ui->typeCB->itemData(index, Qt::UserRole)); + } + + void SpacerConfiguration::widthTypeChanged(bool expandableChecked) + { +- settings().setValue("expandable", expandableChecked); ++ settings().setValue(QStringLiteral("expandable"), expandableChecked); + } diff --git a/debian/patches/series b/debian/patches/series index 709a30e..43121d9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,6 @@ completely-remove-plugin-clock.patch don't-autounmute-on-volume-change.patch +add-autoexpansion-1.patch +add-autoexpansion-2.patch +add-autoexpansion-3.patch +add-autoexpansion-4.patch