From fd7a608ffe99df747f0496300276b95f766c18b9 Mon Sep 17 00:00:00 2001 From: tpearson Date: Fri, 3 Sep 2010 20:49:48 +0000 Subject: * Added Kickoff menu git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1171422 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kicker/libkicker/kickerSettings.kcfg | 100 +++++++++++++++++++++++++++++++++++ kicker/libkicker/kickertip.cpp | 24 ++++++--- kicker/libkicker/kickertip.h | 2 +- kicker/libkicker/panelbutton.cpp | 56 ++++++++++++++++---- kicker/libkicker/panelbutton.h | 13 +++-- 5 files changed, 172 insertions(+), 23 deletions(-) (limited to 'kicker/libkicker') diff --git a/kicker/libkicker/kickerSettings.kcfg b/kicker/libkicker/kickerSettings.kcfg index 6f7f2427e..99625809d 100644 --- a/kicker/libkicker/kickerSettings.kcfg +++ b/kicker/libkicker/kickerSettings.kcfg @@ -98,6 +98,70 @@ + + + true + + + + + true + + + + + true + + + + + 0 + + + + + 0 + + + + + 0 + -100 + 100 + + + + + false + + + + + false + + + + + + + + + + + + + + + LabelAndIcon + + + + + + true + + + @@ -177,6 +241,19 @@ false + + + + + + + false + + + + + + @@ -352,6 +429,29 @@ + + + + + + + + 50 + + + + + + + + + + 2 + + + + + diff --git a/kicker/libkicker/kickertip.cpp b/kicker/libkicker/kickertip.cpp index 34cf65c56..215320c84 100644 --- a/kicker/libkicker/kickertip.cpp +++ b/kicker/libkicker/kickertip.cpp @@ -38,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // putting this #include higher results in compile errors #include +#include static const int DEFAULT_FRAMES_PER_SECOND = 30; @@ -71,14 +72,16 @@ KickerTip::KickerTip(TQWidget * parent) m_dissolveDelta(-1), m_direction(KPanelApplet::Up), m_dirty(false), - m_toolTipsEnabled(KickerSettings::showToolTips()), - m_tippingFor(0) + m_tippingFor(0), + m_timer(0, "KickerTip::m_timer"), + m_frameTimer(0, "KickerTip::m_frameTimer") { setFocusPolicy(NoFocus); setBackgroundMode(NoBackground); resize(0, 0); hide(); connect(&m_frameTimer, TQT_SIGNAL(timeout()), TQT_SLOT(internalUpdate())); + connect(kapp, TQT_SIGNAL(settingsChanged(SettingsCategory)), TQT_SLOT(slotSettingsChanged())); } KickerTip::~KickerTip() @@ -87,6 +90,11 @@ KickerTip::~KickerTip() delete m_mimeFactory; } +void KickerTip::slotSettingsChanged() +{ + TQToolTip::setGloballyEnabled(KickerSettings::showToolTips()); +} + void KickerTip::display() { if (!tippingEnabled()) @@ -194,7 +202,7 @@ void KickerTip::paintEvent(TQPaintEvent * e) void KickerTip::mousePressEvent(TQMouseEvent * /*e*/) { - TQToolTip::setGloballyEnabled(m_toolTipsEnabled); + m_timer.stop(); hide(); } @@ -463,8 +471,11 @@ void KickerTip::enableTipping(bool tip) m_tippingEnabled--; } + assert(m_tippingEnabled >= -1); + if (m_tippingEnabled < 1 && m_self) { + m_self->m_timer.stop(); m_self->hide(); } } @@ -480,6 +491,8 @@ void KickerTip::hide() m_timer.stop(); m_frameTimer.stop(); TQWidget::hide(); + + TQToolTip::setGloballyEnabled(KickerSettings::showToolTips()); } bool KickerTip::eventFilter(TQObject *object, TQEvent *event) @@ -508,7 +521,6 @@ bool KickerTip::eventFilter(TQObject *object, TQEvent *event) !qApp->activePopupWidget() && !isTippingFor(widget)) { - m_toolTipsEnabled = TQToolTip::isGloballyEnabled(); TQToolTip::setGloballyEnabled(false); tipFor(widget); @@ -530,8 +542,6 @@ bool KickerTip::eventFilter(TQObject *object, TQEvent *event) } break; case TQEvent::Leave: - TQToolTip::setGloballyEnabled(m_toolTipsEnabled); - m_timer.stop(); if (isTippingFor(widget) && isVisible()) @@ -544,7 +554,7 @@ bool KickerTip::eventFilter(TQObject *object, TQEvent *event) tipFor(0); break; case TQEvent::MouseButtonPress: - TQToolTip::setGloballyEnabled(m_toolTipsEnabled); + m_timer.stop(); hide(); default: break; diff --git a/kicker/libkicker/kickertip.h b/kicker/libkicker/kickertip.h index 6bcc863f8..14118029b 100644 --- a/kicker/libkicker/kickertip.h +++ b/kicker/libkicker/kickertip.h @@ -92,6 +92,7 @@ protected slots: void tipperDestroyed(TQObject* o); void internalUpdate(); void display(); + void slotSettingsChanged(); private: TQBitmap m_mask; @@ -108,7 +109,6 @@ private: TQTimer m_timer; TQTimer m_frameTimer; bool m_dirty; - bool m_toolTipsEnabled; const TQWidget* m_tippingFor; diff --git a/kicker/libkicker/panelbutton.cpp b/kicker/libkicker/panelbutton.cpp index 972e5195e..f1ab69fb8 100644 --- a/kicker/libkicker/panelbutton.cpp +++ b/kicker/libkicker/panelbutton.cpp @@ -44,6 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #include "global.h" @@ -67,6 +68,7 @@ PanelButton::PanelButton( TQWidget* parent, const char* name ) m_hasAcceptedDrag(false), m_arrowDirection(KPanelExtension::Bottom), m_popupDirection(KPanelApplet::Up), + m_iconAlignment(AlignCenter), m_orientation(Horizontal), m_size((KIcon::StdSizes)-1), m_fontPercent(0.40) @@ -188,6 +190,12 @@ void PanelButton::setPopupDirection(KPanelApplet::Direction d) setArrowDirection(KickerLib::directionToPopupPosition(d)); } +void PanelButton::setIconAlignment(AlignmentFlags align) +{ + m_iconAlignment = align; + update(); +} + void PanelButton::setOrientation(Orientation o) { m_orientation = o; @@ -303,7 +311,9 @@ int PanelButton::widthForHeight(int height) const int PanelButton::heightForWidth(int width) const { - return preferredDimension(width); + int rc=preferredDimension(width); + + return rc; } const TQPixmap& PanelButton::labelIcon() const @@ -562,11 +572,16 @@ void PanelButton::drawButtonLabel(TQPainter *p) icon.height() - 2); } + int y = 0; + if (m_iconAlignment & AlignVCenter) + y = (height() - icon.height()) / 2; + else if (m_iconAlignment & AlignBottom) + y = (height() - icon.height()); + if (!m_buttonText.isEmpty() && orientation() == Horizontal) { int h = height(); int w = width(); - int y = (h - icon.height())/2; p->save(); TQFont f = font(); @@ -635,8 +650,11 @@ void PanelButton::drawButtonLabel(TQPainter *p) } else if (!icon.isNull()) { - int y = (height() - icon.height()) / 2; - int x = (width() - icon.width()) / 2; + int x = 0; + if (m_iconAlignment & AlignHCenter) + x = (width() - icon.width()) / 2; + else if (m_iconAlignment & AlignRight) + x = (width() - icon.width()); p->drawPixmap(x, y, icon); } @@ -798,7 +816,19 @@ void PanelButton::loadIcons() TQString nm = m_iconName; KIcon::States defaultState = isEnabled() ? KIcon::DefaultState : KIcon::DisabledState; - m_icon = ldr->loadIcon(nm, KIcon::Panel, m_size, defaultState, 0L, true); + if (nm=="kmenu-suse") + { + TQString pth = locate( "data", "kicker/pics/kmenu_basic.mng" ); + if (!pth.isEmpty()) + { + m_icon = TQImage(pth); + m_iconh = TQPixmap(m_icon); + m_iconz = TQPixmap(m_icon); + return; + } + } + else + m_icon = ldr->loadIcon(nm, KIcon::Panel, m_size, defaultState, 0L, true); if (m_icon.isNull()) { @@ -863,7 +893,7 @@ PanelPopupButton::PanelPopupButton(TQWidget *parent, const char *name) connect(this, TQT_SIGNAL(pressed()), TQT_SLOT(slotExecMenu())); } -void PanelPopupButton::setPopup(TQPopupMenu *popup) +void PanelPopupButton::setPopup(TQWidget *popup) { if (m_popup) { @@ -881,7 +911,7 @@ void PanelPopupButton::setPopup(TQPopupMenu *popup) } } -TQPopupMenu *PanelPopupButton::popup() const +TQWidget *PanelPopupButton::popup() const { return m_popup; } @@ -960,7 +990,9 @@ void PanelPopupButton::slotExecMenu() } m_popup->adjustSize(); - m_popup->exec(KickerLib::popupPosition(popupDirection(), m_popup, this)); + if(dynamic_cast(m_popup)) + static_cast(m_popup)->exec(KickerLib::popupPosition(popupDirection(), m_popup, this)); + // else.. hmm. some derived class has to fix it. } void PanelPopupButton::menuAboutToHide() @@ -970,8 +1002,10 @@ void PanelPopupButton::menuAboutToHide() return; } - setDown(false); - KickerTip::enableTipping(true); + if (isDown()) { + setDown(false); + KickerTip::enableTipping(true); + } } void PanelPopupButton::triggerDrag() @@ -989,3 +1023,5 @@ void PanelPopupButton::setInitialized(bool initialized) m_initialized = initialized; } + + diff --git a/kicker/libkicker/panelbutton.h b/kicker/libkicker/panelbutton.h index 78f36ed5c..770d0e1be 100644 --- a/kicker/libkicker/panelbutton.h +++ b/kicker/libkicker/panelbutton.h @@ -254,9 +254,11 @@ public slots: /** * Sets the direction to pop up the contents of the button. */ - void setPopupDirection(KPanelApplet::Direction d); + virtual void setPopupDirection(KPanelApplet::Direction d); protected: + + void setIconAlignment(AlignmentFlags align); /** * Subclasses must implement this to define the name of the button which is * used to identify this button for saving and loading. It must be unique @@ -391,6 +393,7 @@ private: TQPixmap m_iconz; // mouse over KPanelExtension::Position m_arrowDirection; KPanelApplet::Direction m_popupDirection; + AlignmentFlags m_iconAlignment; Orientation m_orientation; int m_size; double m_fontPercent; @@ -419,12 +422,12 @@ public: * Sets the button's popup menu. * @param popup the menu to pop up */ - void setPopup(TQPopupMenu *popup); + void setPopup(TQWidget *popup); /** * @return the button's popup menu */ - TQPopupMenu *popup() const; + TQWidget *popup() const; bool eventFilter(TQObject *, TQEvent *); virtual void showMenu(); @@ -459,8 +462,8 @@ protected slots: private slots: void menuAboutToHide(); -private: - TQPopupMenu *m_popup; +protected: + TQWidget *m_popup; bool m_pressedDuringPopup; bool m_initialized; -- cgit v1.2.1