Commit 82b3e2a6 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Resurrect show tooltips option

Summary:
In KDE 4, there was a very handy option to disable decoration tooltips.
Decoration tooltips were lost in transition to KDE Plasma 5, and so
the option.

Given that decoration tooltips were brought back to KDE Plasma 5, "Show
decoration button tooltips" option can be still useful for people(like me)
who may wish to disable them because of personal preference.

Reviewers: #kwin, broulik, mart

Reviewed By: #kwin, mart

Subscribers: ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19152
parent 10fdf2a2
......@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "decoratedclient.h"
#include "decorationbridge.h"
#include "decorationpalette.h"
#include "decorationrenderer.h"
#include "abstract_client.h"
......@@ -219,6 +220,10 @@ QColor DecoratedClientImpl::color(KDecoration2::ColorGroup group, KDecoration2::
void DecoratedClientImpl::requestShowToolTip(const QString &text)
{
if (!DecorationBridge::self()->showToolTips()) {
return;
}
m_toolTipText = text;
int wakeUpDelay = QApplication::style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay);
......
......@@ -65,6 +65,7 @@ DecorationBridge::DecorationBridge(QObject *parent)
: KDecoration2::DecorationBridge(parent)
, m_factory(nullptr)
, m_blur(false)
, m_showToolTips(false)
, m_settings()
, m_noPlugin(false)
{
......@@ -73,6 +74,8 @@ DecorationBridge::DecorationBridge(QObject *parent)
// try to extract the proper defaults file from a lookandfeel package
const QString looknfeel = cg.readEntry(QStringLiteral("LookAndFeelPackage"), "org.kde.breeze.desktop");
m_lnfConfig = KSharedConfig::openConfig(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("plasma/look-and-feel/") + looknfeel + QStringLiteral("/contents/defaults")));
readDecorationOptions();
}
DecorationBridge::~DecorationBridge()
......@@ -101,6 +104,11 @@ QString DecorationBridge::readTheme() const
return kwinApp()->config()->group(s_pluginName).readEntry("theme", cg.readEntry("theme", m_defaultTheme));
}
void DecorationBridge::readDecorationOptions()
{
m_showToolTips = kwinApp()->config()->group(s_pluginName).readEntry("ShowToolTips", true);
}
void DecorationBridge::init()
{
using namespace KWayland::Server;
......@@ -156,6 +164,8 @@ static void recreateDecorations()
void DecorationBridge::reconfigure()
{
readDecorationOptions();
if (m_noPlugin != readNoPlugin()) {
m_noPlugin = !m_noPlugin;
// no plugin setting changed
......
......@@ -61,6 +61,10 @@ public:
return m_blur;
}
bool showToolTips() const {
return m_showToolTips;
}
void reconfigure();
const QSharedPointer<KDecoration2::DecorationSettings> &settings() const {
......@@ -75,9 +79,11 @@ private:
void findTheme(const QVariantMap &map);
void initPlugin();
QString readTheme() const;
void readDecorationOptions();
KPluginFactory *m_factory;
KSharedConfig::Ptr m_lnfConfig;
bool m_blur;
bool m_showToolTips;
QString m_plugin;
QString m_defaultTheme;
QString m_theme;
......
......@@ -50,11 +50,13 @@ const QString s_configPlugin { QStringLiteral("library") };
const QString s_configTheme { QStringLiteral("theme") };
const QString s_configBorderSize { QStringLiteral("BorderSize") };
const QString s_configCloseOnDoubleClickOnMenu { QStringLiteral("CloseOnDoubleClickOnMenu") };
const QString s_configShowToolTips { QStringLiteral("ShowToolTips") };
const QString s_configDecoButtonsOnLeft { QStringLiteral("ButtonsOnLeft") };
const QString s_configDecoButtonsOnRight { QStringLiteral("ButtonsOnRight") };
const KDecoration2::BorderSize s_defaultBorderSize = KDecoration2::BorderSize::Normal;
const bool s_defaultCloseOnDoubleClickOnMenu = false;
const bool s_defaultShowToolTips = true;
const DecorationButtonsList s_defaultDecoButtonsOnLeft {
KDecoration2::DecorationButtonType::Menu,
......@@ -83,7 +85,7 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
, m_leftButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this))
, m_rightButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this))
, m_availableButtonsModel(new KDecoration2::Preview::ButtonsModel(this))
, m_savedSettings{ s_defaultBorderSize, -2 /* for setTheme() */, false, s_defaultDecoButtonsOnLeft, s_defaultDecoButtonsOnRight }
, m_savedSettings{ s_defaultBorderSize, -2 /* for setTheme() */, false, s_defaultShowToolTips, s_defaultDecoButtonsOnLeft, s_defaultDecoButtonsOnRight }
, m_currentSettings(m_savedSettings)
{
auto about = new KAboutData(QStringLiteral("kcm_kwindecoration"),
......@@ -160,6 +162,7 @@ void KCMKWinDecoration::load()
setTheme(themeIndex);
setCloseOnDoubleClickOnMenu(config.readEntry(s_configCloseOnDoubleClickOnMenu, s_defaultCloseOnDoubleClickOnMenu));
setShowToolTips(config.readEntry(s_configShowToolTips, s_defaultShowToolTips));
const QString defaultSizeName = Utils::borderSizeToString(s_defaultBorderSize);
setBorderSize(Utils::stringToBorderSize(config.readEntry(s_configBorderSize, defaultSizeName)));
......@@ -192,6 +195,7 @@ void KCMKWinDecoration::save()
}
config.writeEntry(s_configCloseOnDoubleClickOnMenu, m_currentSettings.closeOnDoubleClickOnMenu);
config.writeEntry(s_configShowToolTips, m_currentSettings.showToolTips);
config.writeEntry(s_configBorderSize, Utils::borderSizeToString(m_currentSettings.borderSize));
config.writeEntry(s_configDecoButtonsOnLeft, Utils::buttonsToString(m_currentSettings.buttonsOnLeft));
config.writeEntry(s_configDecoButtonsOnRight, Utils::buttonsToString(m_currentSettings.buttonsOnRight));
......@@ -217,6 +221,7 @@ void KCMKWinDecoration::defaults()
setTheme(themeIndex);
setBorderSize(s_defaultBorderSize);
setCloseOnDoubleClickOnMenu(s_defaultCloseOnDoubleClickOnMenu);
setShowToolTips(s_defaultShowToolTips);
m_leftButtonsModel->replace(s_defaultDecoButtonsOnLeft);
m_rightButtonsModel->replace(s_defaultDecoButtonsOnRight);
......@@ -230,6 +235,7 @@ void KCMKWinDecoration::updateNeedsSave()
m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons();
setNeedsSave(m_savedSettings.closeOnDoubleClickOnMenu != m_currentSettings.closeOnDoubleClickOnMenu
|| m_savedSettings.showToolTips != m_currentSettings.showToolTips
|| m_savedSettings.borderSize != m_currentSettings.borderSize
|| m_savedSettings.themeIndex != m_currentSettings.themeIndex
|| m_savedSettings.buttonsOnLeft != m_currentSettings.buttonsOnLeft
......@@ -276,6 +282,11 @@ bool KCMKWinDecoration::closeOnDoubleClickOnMenu() const
return m_currentSettings.closeOnDoubleClickOnMenu;
}
bool KCMKWinDecoration::showToolTips() const
{
return m_currentSettings.showToolTips;
}
void KCMKWinDecoration::setBorderSize(int index)
{
setBorderSize(Utils::getBorderSizeNames().keys().at(index));
......@@ -312,4 +323,14 @@ void KCMKWinDecoration::setCloseOnDoubleClickOnMenu(bool enable)
updateNeedsSave();
}
void KCMKWinDecoration::setShowToolTips(bool show)
{
if (m_currentSettings.showToolTips == show) {
return;
}
m_currentSettings.showToolTips = show;
emit showToolTipsChanged();
updateNeedsSave();
}
#include "kcm.moc"
......@@ -57,6 +57,7 @@ class KCMKWinDecoration : public KQuickAddons::ConfigModule
Q_PROPERTY(QAbstractListModel *rightButtonsModel READ rightButtonsModel NOTIFY buttonsChanged)
Q_PROPERTY(QAbstractListModel *availableButtonsModel READ availableButtonsModel CONSTANT)
Q_PROPERTY(bool closeOnDoubleClickOnMenu READ closeOnDoubleClickOnMenu WRITE setCloseOnDoubleClickOnMenu NOTIFY closeOnDoubleClickOnMenuChanged)
Q_PROPERTY(bool showToolTips READ showToolTips WRITE setShowToolTips NOTIFY showToolTipsChanged)
public:
KCMKWinDecoration(QObject *parent, const QVariantList &arguments);
......@@ -69,11 +70,13 @@ public:
int borderSize() const;
int theme() const;
bool closeOnDoubleClickOnMenu() const;
bool showToolTips() const;
void setBorderSize(int index);
void setBorderSize(KDecoration2::BorderSize size);
void setTheme(int index);
void setCloseOnDoubleClickOnMenu(bool enable);
void setShowToolTips(bool show);
Q_INVOKABLE void getNewStuff(QQuickItem *context);
......@@ -82,6 +85,7 @@ Q_SIGNALS:
void buttonsChanged();
void borderSizeChanged();
void closeOnDoubleClickOnMenuChanged();
void showToolTipsChanged();
public Q_SLOTS:
void load() override;
......@@ -107,6 +111,7 @@ private:
KDecoration2::BorderSize borderSize;
int themeIndex;
bool closeOnDoubleClickOnMenu;
bool showToolTips;
DecorationButtonsList buttonsOnLeft;
DecorationButtonsList buttonsOnRight;
};
......
......@@ -120,6 +120,13 @@ Kirigami.Page {
showCloseButton: true
visible: false
}
Controls.CheckBox {
id: showToolTipsCheckBox
text: i18nc("checkbox label", "Show titlebar button tooltips")
checked: kcm.showToolTips
onToggled: kcm.showToolTips = checked
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment