You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lxqt-panel-packaging/debian/patches/add-autoexpansion-3.patch

239 lines
7.4 KiB

Description: Add auto-expansion feature
This is patch 3/4 adding autoexpansion support to the spacer plugin.
Author: Palo Kisa <palo.kisa@gmail.com>
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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &SpacerConfiguration::sizeChanged);
connect(ui->typeCB, static_cast<void (QComboBox::*)(int index)>(&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 @@
<rect>
<x>0</x>
<y>0</y>
+ <width>289</width>
+ <height>135</height>
</rect>
</property>
<property name="windowTitle">
@@ -19,7 +21,7 @@
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="2">
<widget class="QSpinBox" name="sizeSB">
<property name="minimum">
<number>4</number>
@@ -32,21 +34,14 @@
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="labelType">
<property name="text">
<string>Space type:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QComboBox" name="typeCB">
- <property name="editable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
+ <item row="3" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -56,6 +51,27 @@
</property>
</widget>
</item>
+ <item row="0" column="1">
+ <widget class="QRadioButton" name="sizeFixedRB">
+ <property name="text">
+ <string>fixed</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2">
+ <widget class="QComboBox" name="typeCB">
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2">
+ <widget class="QRadioButton" name="sizeExpandRB">
+ <property name="text">
+ <string>expandable</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
@@ -65,6 +81,32 @@
<signal>clicked(QAbstractButton*)</signal>
<receiver>SpacerConfiguration</receiver>
<slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>sizeFixedRB</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>sizeSB</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>152</x>
+ <y>21</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>244</x>
+ <y>21</y>
+ </hint>
+ </hints>
</connection>
</connections>
</ui>