diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index a9202244ae..e3a28c4ce7 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -46,6 +46,7 @@ void AuroraeFactory::init() KConfig config("aurorae/themes/" + themeName + '/' + themeName + "rc", KConfig::FullConfig, "data"); m_theme->loadTheme(themeName, config); m_theme->setBorderSize(KDecoration::options()->preferredBorderSize(this)); + m_theme->setShowTooltips(options()->showTooltips()); } AuroraeFactory::~AuroraeFactory() diff --git a/clients/aurorae/src/lib/auroraescene.cpp b/clients/aurorae/src/lib/auroraescene.cpp index b66ea94503..07fd4f19ed 100644 --- a/clients/aurorae/src/lib/auroraescene.cpp +++ b/clients/aurorae/src/lib/auroraescene.cpp @@ -57,6 +57,7 @@ AuroraeScene::AuroraeScene(Aurorae::AuroraeTheme* theme, const QString& leftButt { init(); connect(m_theme, SIGNAL(themeChanged()), SLOT(resetTheme())); + connect(m_theme, SIGNAL(showTooltipsChanged(bool)), SLOT(showTooltipsChanged(bool))); } AuroraeScene::~AuroraeScene() @@ -290,6 +291,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but switch (button.toAscii()) { case 'M': { AuroraeMenuButton *button = new AuroraeMenuButton(m_theme); + if (m_theme->isShowTooltips()) { + button->setToolTip(i18n("Menu")); + } connect(button, SIGNAL(clicked()), SIGNAL(menuClicked())); connect(button, SIGNAL(doubleClicked()), SIGNAL(menuDblClicked())); layout->addItem(button); @@ -300,6 +304,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but AuroraeButton *button = new AuroraeButton(m_theme, AllDesktopsButton); button->setCheckable(true); button->setChecked(m_allDesktops); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_allDesktops?i18n("Not on all desktops"):i18n("On all desktops")); + } connect(button, SIGNAL(clicked()), SIGNAL(toggleOnAllDesktops())); layout->addItem(button); } @@ -307,6 +314,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but case 'H': if (m_contextHelp && m_theme->hasButton(HelpButton)) { AuroraeButton *button = new AuroraeButton(m_theme, HelpButton); + if (m_theme->isShowTooltips()) { + button->setToolTip(i18n("Help")); + } connect(button, SIGNAL(clicked()), SIGNAL(showContextHelp())); layout->addItem(button); } @@ -314,6 +324,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but case 'I': if (m_theme->hasButton(MinimizeButton)) { AuroraeButton *button = new AuroraeButton(m_theme, MinimizeButton); + if (m_theme->isShowTooltips()) { + button->setToolTip(i18n("Minimize")); + } connect(button, SIGNAL(clicked()), SIGNAL(minimizeWindow())); layout->addItem(button); } @@ -322,6 +335,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but if (m_theme->hasButton(MaximizeButton) || m_theme->hasButton(RestoreButton)) { AuroraeMaximizeButton *button = new AuroraeMaximizeButton(m_theme); button->setMaximizeMode(m_maximizeMode); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_maximizeMode==KDecorationDefines::MaximizeFull?i18n("Restore"):i18n("Maximize") ); + } connect(button, SIGNAL(clicked(Qt::MouseButtons)), SIGNAL(maximize(Qt::MouseButtons))); layout->addItem(button); } @@ -329,6 +345,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but case 'X': if (m_theme->hasButton(CloseButton)){ AuroraeButton *button = new AuroraeButton(m_theme, CloseButton); + if (m_theme->isShowTooltips()) { + button->setToolTip(i18n("Close")); + } connect(button, SIGNAL(clicked()), SIGNAL(closeWindow())); layout->addItem(button); } @@ -338,6 +357,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but AuroraeButton *button = new AuroraeButton(m_theme, KeepAboveButton); button->setCheckable(true); button->setChecked(m_keepAbove); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_keepAbove?i18n("Do not keep above others"):i18n("Keep above others")); + } connect(button, SIGNAL(clicked()), SIGNAL(toggleKeepAbove())); layout->addItem(button); } @@ -347,6 +369,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but AuroraeButton *button = new AuroraeButton(m_theme, KeepBelowButton); button->setCheckable(true); button->setChecked(m_keepBelow); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_keepBelow?i18n("Do not keep below others"):i18n("Keep below others")); + } connect(button, SIGNAL(clicked()), SIGNAL(toggleKeepBelow())); layout->addItem(button); } @@ -356,6 +381,9 @@ void AuroraeScene::initButtons(QGraphicsLinearLayout* layout, const QString& but AuroraeButton *button = new AuroraeButton(m_theme, ShadeButton); button->setCheckable(true); button->setChecked(m_shade); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_shade?i18n("Unshade"):i18n("Shade")); + } connect(button, SIGNAL(clicked()), SIGNAL(toggleShade())); layout->addItem(button); } @@ -417,6 +445,9 @@ void AuroraeScene::setMaximizeMode(KDecorationDefines::MaximizeMode mode) foreach (QGraphicsItem *item, items()) { if (AuroraeMaximizeButton *button = dynamic_cast< AuroraeMaximizeButton* >(item)) { button->setMaximizeMode(mode); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_maximizeMode==KDecorationDefines::MaximizeFull?i18n("Restore"):i18n("Maximize") ); + } } } updateLayout(); @@ -454,6 +485,9 @@ void AuroraeScene::setAllDesktops(bool all) if (AuroraeButton *button = dynamic_cast< AuroraeButton* >(item)) { if (button->type() == AllDesktopsButton) { button->setChecked(m_allDesktops); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_allDesktops?i18n("Not on all desktops"):i18n("On all desktops")); + } button->update(); } } @@ -475,6 +509,9 @@ void AuroraeScene::setKeepAbove(bool keep) if (AuroraeButton *button = dynamic_cast< AuroraeButton* >(item)) { if (button->type() == KeepAboveButton) { button->setChecked(m_keepAbove); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_keepAbove?i18n("Do not keep above others"):i18n("Keep above others")); + } button->update(); } } @@ -496,6 +533,9 @@ void AuroraeScene::setKeepBelow(bool keep) if (AuroraeButton *button = dynamic_cast< AuroraeButton* >(item)) { if (button->type() == KeepBelowButton) { button->setChecked(m_keepBelow); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_keepBelow?i18n("Do not keep below others"):i18n("Keep below others")); + } button->update(); } } @@ -517,6 +557,9 @@ void AuroraeScene::setShade(bool shade) if (AuroraeButton *button = dynamic_cast< AuroraeButton* >(item)) { if (button->type() == ShadeButton) { button->setChecked(m_shade); + if (m_theme->isShowTooltips()) { + button->setToolTip(m_shade?i18n("Unshade"):i18n("Shade")); + } button->update(); } } @@ -617,4 +660,50 @@ QString AuroraeScene::buttonsToDirection(const QString &buttons) return ret; } +void AuroraeScene::showTooltipsChanged(bool show) +{ + foreach (QGraphicsItem *item, items()) { + if (AuroraeButton *button = dynamic_cast< AuroraeButton* >(item)) { + if (show) { + // switch over type + switch (button->type()) { + case MenuButton: + button->setToolTip(i18n("Menu")); + break; + case MinimizeButton: + button->setToolTip(i18n("Minimize")); + break; + case RestoreButton: // fall through + case MaximizeButton: + button->setToolTip(m_maximizeMode==KDecorationDefines::MaximizeFull?i18n("Restore"):i18n("Maximize") ); + break; + case KeepAboveButton: + button->setToolTip(m_keepAbove?i18n("Do not keep above others"):i18n("Keep above others")); + break; + case KeepBelowButton: + button->setToolTip(m_keepBelow?i18n("Do not keep below others"):i18n("Keep below others")); + break; + case ShadeButton: + button->setToolTip(m_shade?i18n("Unshade"):i18n("Shade")); + break; + case CloseButton: + button->setToolTip(i18n("Close")); + break; + case AllDesktopsButton: + button->setToolTip(m_allDesktops?i18n("Not on all desktops"):i18n("On all desktops")); + break; + case HelpButton: + button->setToolTip(i18n("Help")); + break; + default: + // nothing + break; + } + } else { + button->setToolTip(QString()); + } + } + } +} + } // namespace diff --git a/clients/aurorae/src/lib/auroraescene.h b/clients/aurorae/src/lib/auroraescene.h index 8981eeaa5e..a62658fe30 100644 --- a/clients/aurorae/src/lib/auroraescene.h +++ b/clients/aurorae/src/lib/auroraescene.h @@ -97,6 +97,7 @@ protected: private Q_SLOTS: void resetTheme(); + void showTooltipsChanged(bool show); private: void init(); diff --git a/clients/aurorae/src/lib/auroraetheme.cpp b/clients/aurorae/src/lib/auroraetheme.cpp index 9e826a3254..9bad33d6ad 100644 --- a/clients/aurorae/src/lib/auroraetheme.cpp +++ b/clients/aurorae/src/lib/auroraetheme.cpp @@ -48,12 +48,14 @@ public: QHash< AuroraeButtonType, Plasma::FrameSvg* > buttons; bool activeCompositing; KDecorationDefines::BorderSize borderSize; + bool showTooltips; }; AuroraeThemePrivate::AuroraeThemePrivate() : decoration(0) , activeCompositing(true) , borderSize(KDecoration::BorderNormal) + , showTooltips(true) { } @@ -320,5 +322,15 @@ void AuroraeTheme::setBorderSize(KDecorationDefines::BorderSize size) d->borderSize = size; } +bool AuroraeTheme::isShowTooltips() const +{ + return d->showTooltips; +} + +void AuroraeTheme::setShowTooltips(bool show) +{ + d->showTooltips = show; + emit showTooltipsChanged(show); +} } // namespace diff --git a/clients/aurorae/src/lib/auroraetheme.h b/clients/aurorae/src/lib/auroraetheme.h index 8cef60e8e2..f8e151f046 100644 --- a/clients/aurorae/src/lib/auroraetheme.h +++ b/clients/aurorae/src/lib/auroraetheme.h @@ -103,12 +103,17 @@ public: QString defaultButtonsLeft() const; QString defaultButtonsRight() const; void setBorderSize(KDecorationDefines::BorderSize size); + bool isShowTooltips() const; // TODO: move to namespace static QLatin1String mapButtonToName(AuroraeButtonType type); +public Q_SLOTS: + void setShowTooltips(bool show); + Q_SIGNALS: void themeChanged(); + void showTooltipsChanged(bool show); private: const ThemeConfig &themeConfig() const;