Hide tab texts in Plasmoid by default to avoid problematic overflow behavior

This commit is contained in:
Martchus 2022-09-05 22:54:28 +02:00
parent 1a71d8b534
commit 99a7bd1a01
5 changed files with 50 additions and 3 deletions

View File

@ -114,7 +114,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="passiveLabel">
<property name="text">
<string>States to enable passive mode</string>
@ -124,7 +124,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QListView" name="passiveListView">
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
@ -134,6 +134,20 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Optional GUI elements</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="showTabTextsCheckBox">
<property name="text">
<string>Show tab texts</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -91,6 +91,7 @@ bool AppearanceOptionPage::apply()
{
KConfigGroup config = m_applet->config();
config.writeEntry<QSize>("size", QSize(ui()->widthSpinBox->value(), ui()->heightSpinBox->value()));
config.writeEntry<bool>("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()));
}

View File

@ -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<QSize>("size", QSize(25, 25)));
setShowingTabTexts(config.readEntry<bool>("showTabTexts", false));
IconManager::instance().applySettings(&settings.icons.status);
// restore selected states

View File

@ -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<QtUtilities::ChecklistItem> 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<QtUtilities::ChecklistItem> &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;

View File

@ -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