[kcmkwin/kwinoptions] Use text to describe maximize button actions

Summary:
Currently, we use icons to display possible maximize button actions. The
problem with those icons is that they are confusing even for me, a person
who knows kwin in and out. The size_all icon implies that if you click the
maximize button, you'll be able to move the window around. Same goes with
the size_ver and size_hor icons, they indicate that user will start
resizing the window in the vertical and horizontal direction, respectively.

Test Plan:
Before

{F8312394}

After

{F8312395}

Reviewers: #kwin, #vdg, ndavis

Reviewed By: #vdg, ndavis

Subscribers: ngraham, ndavis, broulik, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29671
This commit is contained in:
Vlad Zahorodnii 2020-05-12 10:04:48 +03:00
parent 9e5498238f
commit 88c4de60fd
3 changed files with 45 additions and 145 deletions

View file

@ -19,100 +19,13 @@
#include "mouse.h"
#include <QLabel>
#include <KComboBox>
#include <QLayout>
#include <QSizePolicy>
#include <QBitmap>
#include <QGroupBox>
#include <QPixmap>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QDebug>
#include <kcolorscheme.h>
#include <kseparator.h>
#include <QtDBus>
#include <cstdlib>
#include "kwinoptions_settings.h"
namespace
{
QPixmap maxButtonPixmaps[3];
void createMaxButtonPixmaps()
{
char const *maxButtonXpms[][3 + 13] = {
{
nullptr, nullptr, nullptr,
"...............",
".......#.......",
"......###......",
".....#####.....",
"..#....#....#..",
".##....#....##.",
"###############",
".##....#....##.",
"..#....#....#..",
".....#####.....",
"......###......",
".......#.......",
"..............."
},
{
nullptr, nullptr, nullptr,
"...............",
".......#.......",
"......###......",
".....#####.....",
".......#.......",
".......#.......",
".......#.......",
".......#.......",
".......#.......",
".....#####.....",
"......###......",
".......#.......",
"..............."
},
{
nullptr, nullptr, nullptr,
"...............",
"...............",
"...............",
"...............",
"..#.........#..",
".##.........##.",
"###############",
".##.........##.",
"..#.........#..",
"...............",
"...............",
"...............",
"..............."
},
};
QByteArray baseColor(". c " + KColorScheme(QPalette::Active, KColorScheme::View).background().color().name().toLatin1());
QByteArray textColor("# c " + KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name().toLatin1());
for (int t = 0; t < 3; ++t) {
maxButtonXpms[t][0] = "15 13 2 1";
maxButtonXpms[t][1] = baseColor.constData();
maxButtonXpms[t][2] = textColor.constData();
maxButtonPixmaps[t] = QPixmap(maxButtonXpms[t]);
maxButtonPixmaps[t].setMask(maxButtonPixmaps[t].createHeuristicMask());
}
}
} // namespace
KWinMouseConfigForm::KWinMouseConfigForm(QWidget *parent)
: QWidget(parent)
{
@ -125,45 +38,15 @@ KWinActionsConfigForm::KWinActionsConfigForm(QWidget *parent)
setupUi(parent);
}
void KTitleBarActionsConfig::paletteChanged()
{
createMaxButtonPixmaps();
for (int i=0; i<3; ++i) {
m_ui->kcfg_MaximizeButtonLeftClickCommand->setItemIcon(i, maxButtonPixmaps[i]);
m_ui->kcfg_MaximizeButtonMiddleClickCommand->setItemIcon(i, maxButtonPixmaps[i]);
m_ui->kcfg_MaximizeButtonRightClickCommand->setItemIcon(i, maxButtonPixmaps[i]);
}
}
KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent)
: KCModule(parent), standAlone(_standAlone)
, m_ui(new KWinMouseConfigForm(this))
, m_settings(settings)
{
addConfig(m_settings, this);
// create the items for the maximize button actions
createMaxButtonPixmaps();
for (int i=0; i<3; ++i) {
m_ui->kcfg_MaximizeButtonLeftClickCommand->addItem(maxButtonPixmaps[i], QString());
m_ui->kcfg_MaximizeButtonMiddleClickCommand->addItem(maxButtonPixmaps[i], QString());
m_ui->kcfg_MaximizeButtonRightClickCommand->addItem(maxButtonPixmaps[i], QString());
}
createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonLeftClickCommand);
createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonMiddleClickCommand);
createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonRightClickCommand);
load();
}
void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo)
{
combo->setItemData(0, i18n("Maximize"), Qt::ToolTipRole);
combo->setItemData(1, i18n("Maximize (vertical only)"), Qt::ToolTipRole);
combo->setItemData(2, i18n("Maximize (horizontal only)"), Qt::ToolTipRole);
}
void KTitleBarActionsConfig::showEvent(QShowEvent *ev)
{
if (!standAlone) {
@ -176,9 +59,6 @@ void KTitleBarActionsConfig::showEvent(QShowEvent *ev)
void KTitleBarActionsConfig::changeEvent(QEvent *ev)
{
if (ev->type() == QEvent::PaletteChange) {
paletteChanged();
}
ev->accept();
}

View file

@ -25,7 +25,6 @@
class KConfig;
#include <kcmodule.h>
#include <KComboBox>
#include <KLocalizedString>
#include "ui_actions.h"
@ -68,12 +67,6 @@ private:
KWinMouseConfigForm *m_ui;
KWinOptionsSettings *m_settings;
void createMaximizeButtonTooltips(KComboBox* combo);
private Q_SLOTS:
void paletteChanged();
};
class KWindowActionsConfig : public KCModule

View file

@ -607,15 +607,24 @@
</item>
<item row="0" column="1">
<widget class="KComboBox" name="kcfg_MaximizeButtonLeftClickCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>Behavior on &lt;em&gt;left&lt;/em&gt; click onto the maximize button.</string>
</property>
<item>
<property name="text">
<string>Maximize</string>
</property>
</item>
<item>
<property name="text">
<string>Maximize (vertical only)</string>
</property>
</item>
<item>
<property name="text">
<string>Maximize (horizontal only)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
@ -633,15 +642,24 @@
</item>
<item row="1" column="1">
<widget class="KComboBox" name="kcfg_MaximizeButtonMiddleClickCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>Behavior on &lt;em&gt;middle&lt;/em&gt; click onto the maximize button.</string>
</property>
<item>
<property name="text">
<string>Maximize</string>
</property>
</item>
<item>
<property name="text">
<string>Maximize (vertical only)</string>
</property>
</item>
<item>
<property name="text">
<string>Maximize (horizontal only)</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
@ -659,15 +677,24 @@
</item>
<item row="2" column="1">
<widget class="KComboBox" name="kcfg_MaximizeButtonRightClickCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>Behavior on &lt;em&gt;right&lt;/em&gt; click onto the maximize button.</string>
</property>
<item>
<property name="text">
<string>Maximize</string>
</property>
</item>
<item>
<property name="text">
<string>Maximize (vertical only)</string>
</property>
</item>
<item>
<property name="text">
<string>Maximize (horizontal only)</string>
</property>
</item>
</widget>
</item>
</layout>