From 718f6ae321b507dbb5bca737a1d1d486b2b41dc5 Mon Sep 17 00:00:00 2001 From: Francois Andriot Date: Sun, 19 May 2013 16:09:35 +0200 Subject: Add tooltip support in KMenu --- kicker/kicker/ui/service_mnu.cpp | 18 ++++++++++++++++++ kicker/kicker/ui/service_mnu.h | 1 + kicker/libkicker/kickerSettings.kcfg | 5 +++++ 3 files changed, 24 insertions(+) (limited to 'kicker') diff --git a/kicker/kicker/ui/service_mnu.cpp b/kicker/kicker/ui/service_mnu.cpp index 6e3d7beda..ed8b4edda 100644 --- a/kicker/kicker/ui/service_mnu.cpp +++ b/kicker/kicker/ui/service_mnu.cpp @@ -27,6 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include @@ -70,6 +71,7 @@ PanelServiceMenu::PanelServiceMenu(const TQString & label, const TQString & relP connect(KSycoca::self(), TQT_SIGNAL(databaseChanged()), TQT_SLOT(slotClearOnClose())); connect(this, TQT_SIGNAL(aboutToHide()), this, TQT_SLOT(slotClose())); + connect(this, TQT_SIGNAL(highlighted(int)), this, TQT_SLOT(slotSetTooltip(int))); } PanelServiceMenu::~PanelServiceMenu() @@ -1006,3 +1008,19 @@ void PanelServiceMenu::updateRecentlyUsedApps(KService::Ptr &service) RecentlyLaunchedApps::the().m_bNeedToUpdate = true; } +void PanelServiceMenu::slotSetTooltip(int id) +{ + TQToolTip::remove(this); + if (KickerSettings::useTooltip() && entryMap_.contains(id) && entryMap_[id]->isType(KST_KService)) { + KService::Ptr s(static_cast(entryMap_[id].data())); + TQString text; + if (!s->genericName().isEmpty()) { + text = s->genericName(); + } + if (text.isEmpty() && !s->comment().isEmpty()) { + text = s->comment(); + } + TQToolTip::add(this, i18n(text.utf8())); + } +} + diff --git a/kicker/kicker/ui/service_mnu.h b/kicker/kicker/ui/service_mnu.h index 89e66937d..9cbfaa068 100644 --- a/kicker/kicker/ui/service_mnu.h +++ b/kicker/kicker/ui/service_mnu.h @@ -81,6 +81,7 @@ protected slots: virtual void slotClear(); virtual void configChanged(); virtual void slotClose(); + void slotSetTooltip(int id); void slotDragObjectDestroyed(); // for use in Add Applicaton To Panel diff --git a/kicker/libkicker/kickerSettings.kcfg b/kicker/libkicker/kickerSettings.kcfg index c1c4f19a5..4a84885d7 100644 --- a/kicker/libkicker/kickerSettings.kcfg +++ b/kicker/libkicker/kickerSettings.kcfg @@ -359,6 +359,11 @@ true + + + false + + true -- cgit v1.2.3