Index: qt4/toolbar/common-uimstateindicator.cpp =================================================================== --- qt4/toolbar/common-uimstateindicator.cpp (revision 6120) +++ qt4/toolbar/common-uimstateindicator.cpp (working copy) @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -171,11 +172,19 @@ button->setToolTip( fields[ 3 ] ); // create popup +#ifdef PLASMA_APPLET_UIM + popupMenu = new QHelperPopupMenu( 0 ); +#else popupMenu = new QHelperPopupMenu( button ); +#endif connect( popupMenu, SIGNAL( aboutToShow() ), this, SLOT( slotPopupMenuAboutToShow() ) ); connect( popupMenu, SIGNAL( aboutToHide() ), this, SLOT( slotPopupMenuAboutToHide() ) ); + connect( button, SIGNAL( menuRequested( QMenu* ) ), + this, SIGNAL( menuRequested( QMenu* ) ) ); + connect( button, SIGNAL( contextMenuRequested() ), + this, SIGNAL( contextMenuRequested() ) ); button->setMenu( popupMenu ); button->setPopupMode( QToolButton::InstantPopup ); @@ -264,7 +273,31 @@ } /**/ +QHelperToolbarButton::QHelperToolbarButton( QWidget *parent ) + : QToolButton( parent ) +{ + setAutoRaise( true ); +} +QSize QHelperToolbarButton::sizeHint() const +{ + return QSize( BUTTON_SIZE, BUTTON_SIZE ); +} + +void QHelperToolbarButton::mousePressEvent( QMouseEvent *event ) +{ +#ifdef PLASMA_APPLET_UIM + if ( event->button() == Qt::LeftButton ) + emit menuRequested( menu() ); + else + emit contextMenuRequested(); +#else + QToolButton::mousePressEvent( event ); +#endif +} + +/**/ + QHelperPopupMenu::QHelperPopupMenu( QWidget *parent ) : QMenu( parent ) { Index: qt4/toolbar/applet-kde4.h =================================================================== --- qt4/toolbar/applet-kde4.h (revision 6120) +++ qt4/toolbar/applet-kde4.h (working copy) @@ -50,6 +50,7 @@ private slots: void slotToolbarResized(); + void slotMenuRequested(QMenu *menu); private: void initPopup(); Index: qt4/toolbar/common-uimstateindicator.h =================================================================== --- qt4/toolbar/common-uimstateindicator.h (revision 6120) +++ qt4/toolbar/common-uimstateindicator.h (working copy) @@ -70,6 +70,8 @@ signals: void indicatorResized(); + void contextMenuRequested(); + void menuRequested( QMenu *menu ); public slots: void slotStdinActivated( int socket ); @@ -91,14 +93,18 @@ class QHelperToolbarButton : public QToolButton { + Q_OBJECT public: - explicit QHelperToolbarButton( QWidget *parent = 0 ) - : QToolButton( parent ){ setAutoRaise( true ); } + explicit QHelperToolbarButton( QWidget *parent = 0 ); - QSize sizeHint() const - { - return QSize( BUTTON_SIZE, BUTTON_SIZE ); - } + QSize sizeHint() const; + +signals: + void contextMenuRequested(); + void menuRequested( QMenu *menu ); + +private: + void mousePressEvent( QMouseEvent *event ); }; class QHelperPopupMenu : public QMenu Index: qt4/toolbar/common-quimhelpertoolbar.cpp =================================================================== --- qt4/toolbar/common-quimhelpertoolbar.cpp (revision 6120) +++ qt4/toolbar/common-quimhelpertoolbar.cpp (working copy) @@ -56,7 +56,12 @@ m_indicator = new UimStateIndicator( this ); m_layout->addWidget( m_indicator ); - connect( m_indicator, SIGNAL( indicatorResized() ), this, SLOT( slotIndicatorResized() ) ); + connect( m_indicator, SIGNAL( indicatorResized() ), + this, SLOT( slotIndicatorResized() ) ); + connect( m_indicator, SIGNAL( contextMenuRequested() ), + this, SIGNAL( slotContextMenuRequested() ) ); + connect( m_indicator, SIGNAL( menuRequested( QMenu* ) ), + this, SIGNAL( menuRequested( QMenu* ) ) ); QPixmap swicon = QPixmap( ICONDIR + "/im_switcher.png" ); QPixmap preficon = QPixmap( ACTION_ICONDIR + "/configure.png"); @@ -87,7 +92,7 @@ exiticon = QPixmap::fromImage( exitimage.scaled( ICON_SIZE, ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); - m_contextMenu = new QMenu( this ); + m_contextMenu = new QMenu( isApplet ? 0 : this ); m_contextMenu->addAction( m_swicon, _("Switch input method"), this, SLOT(slotExecImSwitcher()) ); m_contextMenu->addAction( m_preficon, _("Preference"), @@ -129,8 +134,13 @@ { if( m_contextMenu->isHidden() ) { +#ifdef PLASMA_APPLET_UIM + Q_UNUSED( e ); + emit menuRequested( m_contextMenu ); +#else m_contextMenu->move( e->globalPos() ); m_contextMenu->exec(); +#endif } } @@ -298,3 +308,8 @@ { m_layout->setMargin( margin ); } + +void QUimHelperToolbar::slotContextMenuRequested() +{ + emit menuRequested( m_contextMenu ); +} Index: qt4/toolbar/common-quimhelpertoolbar.h =================================================================== --- qt4/toolbar/common-quimhelpertoolbar.h (revision 6120) +++ qt4/toolbar/common-quimhelpertoolbar.h (working copy) @@ -80,7 +80,11 @@ signals: void quitToolbar(); void toolbarResized(); + void menuRequested( QMenu *menu ); +private slots: + void slotContextMenuRequested(); + protected: UimStateIndicator *m_indicator; QPixmap m_swicon; Index: qt4/toolbar/applet-kde4.cpp =================================================================== --- qt4/toolbar/applet-kde4.cpp (revision 6120) +++ qt4/toolbar/applet-kde4.cpp (working copy) @@ -61,6 +61,8 @@ m_toolbar->setAttribute(Qt::WA_NoSystemBackground); connect(m_toolbar, SIGNAL(toolbarResized()), this, SLOT(slotToolbarResized())); + connect(m_toolbar, SIGNAL(menuRequested(QMenu*)), + this, SLOT(slotMenuRequested(QMenu*))); m_proxy = new QGraphicsProxyWidget; m_proxy->setWidget(m_toolbar); @@ -115,6 +117,12 @@ resize(m_toolbar->width() + lr, m_toolbar->height() + tb); } +void UimApplet::slotMenuRequested(QMenu *menu) +{ + menu->adjustSize(); + menu->exec(popupPosition(menu->size())); +} + QGraphicsWidget *UimApplet::graphicsWidget() { return m_widget; Index: qt4/toolbar/CMakeLists.txt =================================================================== --- qt4/toolbar/CMakeLists.txt (revision 6120) +++ qt4/toolbar/CMakeLists.txt (working copy) @@ -3,7 +3,7 @@ find_package(KDE4 REQUIRED) include(KDE4Defaults) -add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) +add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -DPLASMA_APPLET_UIM) include_directories(${KDE4_INCLUDES} ${CMAKE_SOURCE_DIR}/../.. ${CMAKE_SOURCE_DIR}/../../uim ${CMAKE_SOURCE_DIR}/../../replace ${CMAKE_SOURCE_DIR}/..)