diff --git a/plasmoid/lib/appearanceoptionpage.ui b/plasmoid/lib/appearanceoptionpage.ui index f174c00..91057ac 100644 --- a/plasmoid/lib/appearanceoptionpage.ui +++ b/plasmoid/lib/appearanceoptionpage.ui @@ -114,7 +114,7 @@ - + States to enable passive mode @@ -124,7 +124,7 @@ - + QAbstractItemView::NoSelection @@ -134,6 +134,20 @@ + + + + Optional GUI elements + + + + + + + Show tab texts + + + diff --git a/plasmoid/lib/settingsdialog.cpp b/plasmoid/lib/settingsdialog.cpp index 7c10bfe..a36b370 100644 --- a/plasmoid/lib/settingsdialog.cpp +++ b/plasmoid/lib/settingsdialog.cpp @@ -91,6 +91,7 @@ bool AppearanceOptionPage::apply() { KConfigGroup config = m_applet->config(); config.writeEntry("size", QSize(ui()->widthSpinBox->value(), ui()->heightSpinBox->value())); + config.writeEntry("showTabTexts", ui()->showTabTextsCheckBox->isChecked()); config.writeEntry("passiveStates", m_passiveStatusSelection.toVariantList()); return true; @@ -102,6 +103,7 @@ void AppearanceOptionPage::reset() const auto size(config.readEntry<>("size", QSize(25, 25))); ui()->widthSpinBox->setValue(size.width()); ui()->heightSpinBox->setValue(size.height()); + ui()->showTabTextsCheckBox->setChecked(config.readEntry<>("showTabTexts", false)); m_passiveStatusSelection.applyVariantList(config.readEntry("passiveStates", QVariantList())); } diff --git a/plasmoid/lib/syncthingapplet.cpp b/plasmoid/lib/syncthingapplet.cpp index dd17c5f..a82f2bb 100644 --- a/plasmoid/lib/syncthingapplet.cpp +++ b/plasmoid/lib/syncthingapplet.cpp @@ -87,6 +87,7 @@ SyncthingApplet::SyncthingApplet(QObject *parent, const QVariantList &data) , m_currentConnectionConfig(-1) , m_hasInternalErrors(false) , m_initialized(false) + , m_showTabTexts(false) { #ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD m_notifier.setService(&m_service); @@ -451,6 +452,7 @@ void SyncthingApplet::handleSettingsChanged() // apply appearance settings setSize(config.readEntry("size", QSize(25, 25))); + setShowingTabTexts(config.readEntry("showTabTexts", false)); IconManager::instance().applySettings(&settings.icons.status); // restore selected states diff --git a/plasmoid/lib/syncthingapplet.h b/plasmoid/lib/syncthingapplet.h index 7c5b312..471e11f 100644 --- a/plasmoid/lib/syncthingapplet.h +++ b/plasmoid/lib/syncthingapplet.h @@ -74,6 +74,7 @@ class SyncthingApplet : public Plasma::Applet { Q_PROPERTY(bool startStopEnabled READ isStartStopEnabled NOTIFY settingsChanged) Q_PROPERTY(bool hasInternalErrors READ hasInternalErrors NOTIFY hasInternalErrorsChanged) Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) + Q_PROPERTY(bool showTabTexts READ isShowingTabTexts WRITE setShowingTabTexts NOTIFY showTabTextsChanged) Q_PROPERTY(bool notificationsAvailable READ areNotificationsAvailable NOTIFY notificationsAvailableChanged) Q_PROPERTY(bool passive READ isPassive NOTIFY passiveChanged) Q_PROPERTY(QList passiveStates READ passiveStates WRITE setPassiveStates) @@ -114,6 +115,8 @@ public: bool hasInternalErrors() const; QSize size() const; void setSize(const QSize &size); + bool isShowingTabTexts() const; + void setShowingTabTexts(bool showTabTexts); bool areNotificationsAvailable() const; bool isPassive() const; const QList &passiveStates() const; @@ -161,6 +164,7 @@ Q_SIGNALS: void currentConnectionConfigIndexChanged(int index); void hasInternalErrorsChanged(bool hasInternalErrors); void sizeChanged(const QSize &size); + void showTabTextsChanged(bool isShowingTabTexts); void notificationsAvailableChanged(bool notificationsAvailable); void passiveChanged(bool passive); void faUrlChanged(const QString &faUrl); @@ -217,6 +221,7 @@ private: int m_currentConnectionConfig; bool m_hasInternalErrors; bool m_initialized; + bool m_showTabTexts; QSize m_size; }; @@ -306,6 +311,18 @@ inline void SyncthingApplet::setSize(const QSize &size) } } +inline bool SyncthingApplet::isShowingTabTexts() const +{ + return m_showTabTexts; +} + +inline void SyncthingApplet::setShowingTabTexts(bool showTabTexts) +{ + if (showTabTexts != m_showTabTexts) { + emit showTabTextsChanged(m_showTabTexts = showTabTexts); + } +} + inline bool SyncthingApplet::isPassive() const { return status() == Plasma::Types::PassiveStatus; diff --git a/plasmoid/package/contents/ui/TabButton.qml b/plasmoid/package/contents/ui/TabButton.qml index c3f4cf3..1d86dd7 100644 --- a/plasmoid/package/contents/ui/TabButton.qml +++ b/plasmoid/package/contents/ui/TabButton.qml @@ -1,11 +1,23 @@ import QtQuick 2.8 +import QtQuick.Templates 2.15 as T import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 3.0 as PlasmaComponents3 +import org.kde.kirigami 2.5 as Kirigami PlasmaComponents3.TabButton { id: root spacing: 0 + + property bool showTabText: plasmoid.nativeInterface.showTabTexts + property string tooltip: "" + + PlasmaComponents3.ToolTip { + id: tooltip + text: root.tooltip !== "" ? root.tooltip : (root.showTabText ? "" : root.text) + visible: text !== "" && parent instanceof T.AbstractButton && (Kirigami.Settings.tabletMode ? parent.pressed : parent.hovered) + } + contentItem: RowLayout { spacing: label.visible ? units.smallSpacing : 0 PlasmaCore.ColorScope.inherit: true @@ -24,7 +36,7 @@ PlasmaComponents3.TabButton { PlasmaComponents3.Label { id: label visible: text.length > 0 - text: root.text + text: root.showTabText ? root.text : "" color: PlasmaCore.ColorScope.textColor elide: Text.ElideRight Layout.fillHeight: true