[uim-commit] r486 - trunk/qt
kzk at freedesktop.org
kzk at freedesktop.org
Wed Feb 2 12:31:37 PST 2005
Author: kzk
Date: 2005-02-02 12:31:34 -0800 (Wed, 02 Feb 2005)
New Revision: 486
Modified:
trunk/qt/toolbar-common-quimhelpertoolbar.cpp
trunk/qt/toolbar-common-quimhelpertoolbar.h
trunk/qt/toolbar-common-uimstateindicator.cpp
trunk/qt/toolbar-common-uimstateindicator.h
trunk/qt/toolbar-standalone-qt.cpp
trunk/qt/toolbar-standalone-qt.h
Log:
* uim-toolbar-qt reorganization.
Rightclicking, custom, size handling is implemented.
* qt/toolbar-standalone-qt.h
* qt/toolbar-standalone-qt.cpp
- (class UimStandaloneToolbar): new class
* qt/toolbar-common-uimstateindicator.h
* qt/toolbar-common-uimstateindicator.cpp
- (class QHelperToolbarButton): new class for handling size
* qt/toolbar-common-quimhelpertoolbar.h
* qt/toolbar-common-quimhelpertoolbar.cpp
- (slotExecPref): new func
- (quitToolbar): new signal
- (contextMenuEvent): new func
Modified: trunk/qt/toolbar-common-quimhelpertoolbar.cpp
===================================================================
--- trunk/qt/toolbar-common-quimhelpertoolbar.cpp 2005-02-02 19:55:12 UTC (rev 485)
+++ trunk/qt/toolbar-common-quimhelpertoolbar.cpp 2005-02-02 20:31:34 UTC (rev 486)
@@ -38,30 +38,59 @@
#include <stdlib.h>
+#include "uim-compat-scm.h"
#include "qtgettext.h"
+static const QString ICONDIR = UIM_PIXMAPSDIR;
+
QUimHelperToolbar::QUimHelperToolbar( QWidget *parent, const char *name, WFlags f )
- : QHBox( parent, name, f )
+ : QHBox( parent, name, f )
{
new UimStateIndicator( this );
+ m_swicon = QPixmap( ICONDIR + "/switcher-icon.png" );
+ m_preficon = QPixmap( ICONDIR + "/configure-qt.png");
+
+ m_contextMenu = new QPopupMenu( this );
+ m_contextMenu->insertItem( m_swicon, _("Execute uim's input method switcher"), this, SLOT(slotExecSwitcher()) );
+ m_contextMenu->insertItem( m_preficon, _("Execute uim's preference tool"), this, SLOT(slotExecPref()) );
+ m_contextMenu->insertItem( _("Quit this toolbar"), this, SIGNAL(quitToolbar()) );
+
// switcher exec button
addExecImSwitcherButton();
- // kasumi exec button (configure option)
- addExecKasumiButton();
+ // pref exec button
+ addExecPrefButton();
}
QUimHelperToolbar::~QUimHelperToolbar()
-{}
+{
+}
+void QUimHelperToolbar::contextMenuEvent( QContextMenuEvent * e )
+{
+ if( !m_contextMenu->isShown() )
+ {
+ m_contextMenu->move( e->globalPos() );
+ m_contextMenu->exec();
+ }
+}
+
void QUimHelperToolbar::addExecImSwitcherButton()
{
- QToolButton * swbutton = new QToolButton( this );
- swbutton->setText( _( "sw" ) );
- QObject::connect( swbutton, SIGNAL( clicked() ),
+ uim_bool isShowSwitcher = uim_scm_symbol_value_bool("toolbar-show-switcher-button?");
+ if( isShowSwitcher == UIM_FALSE )
+ return;
+
+ QToolButton * swButton = new QHelperToolbarButton( this );
+ if( !m_swicon.isNull() )
+ swButton->setPixmap( m_swicon );
+ else
+ swButton->setText( "sw" );
+
+ QObject::connect( swButton, SIGNAL( clicked() ),
this, SLOT( slotExecSwitcher() ) );
- QToolTip::add( swbutton, _( "exec im-switcher" ) );
+ QToolTip::add( swButton, _( "exec im-switcher" ) );
}
@@ -71,23 +100,27 @@
system( "uim-im-switcher-qt &" );
}
-void QUimHelperToolbar::addExecKasumiButton()
+void QUimHelperToolbar::addExecPrefButton()
{
-#ifdef USE_KASUMI
- QToolButton * kasumiButton = new QToolButton( this );
- kasumiButton->setText( _( "Kasumi" ) );
- QObject::connect( kasumiButton, SIGNAL( clicked() ),
- this, SLOT( slotExecKasumi() ) );
- QToolTip::add( kasumiButton, _( "exec Kasumi" ) );
-#endif
+ uim_bool isShowPref = uim_scm_symbol_value_bool("toolbar-show-pref-button?");
+ if( isShowPref == UIM_FALSE )
+ return;
+
+ QToolButton * prefButton = new QHelperToolbarButton( this );
+ if( !m_preficon.isNull() )
+ prefButton->setPixmap( m_preficon );
+ else
+ prefButton->setText( "pref" );
+
+ QObject::connect( prefButton, SIGNAL( clicked() ),
+ this, SLOT( slotExecPref() ) );
+ QToolTip::add( prefButton, _( "exec Preference Application" ) );
}
-void QUimHelperToolbar::slotExecKasumi()
+void QUimHelperToolbar::slotExecPref()
{
-#ifdef USE_KASUMI
- /* exec kasumi */
- system( "kasumi &" );
-#endif
+ /* exec uim-pref-qt */
+ system( "uim-pref-qt &" );
}
#include "toolbar-common-quimhelpertoolbar.moc"
Modified: trunk/qt/toolbar-common-quimhelpertoolbar.h
===================================================================
--- trunk/qt/toolbar-common-quimhelpertoolbar.h 2005-02-02 19:55:12 UTC (rev 485)
+++ trunk/qt/toolbar-common-quimhelpertoolbar.h 2005-02-02 20:31:34 UTC (rev 486)
@@ -34,6 +34,9 @@
#define _QUIM_HELPER_TOOLBAR_H_
#include <qhbox.h>
+#include <qevent.h>
+#include <qpopupmenu.h>
+#include <qpixmap.h>
class QUimHelperToolbar : public QHBox
{
@@ -45,11 +48,22 @@
protected:
void addExecImSwitcherButton();
- void addExecKasumiButton(); // configure option
+ void addExecPrefButton();
+ // right click
+ virtual void contextMenuEvent ( QContextMenuEvent * e );
+
protected slots:
void slotExecSwitcher();
- void slotExecKasumi(); // configure option
+ void slotExecPref();
+
+signals:
+ void quitToolbar();
+
+protected:
+ QPixmap m_swicon;
+ QPixmap m_preficon;
+ QPopupMenu *m_contextMenu;
};
Modified: trunk/qt/toolbar-common-uimstateindicator.cpp
===================================================================
--- trunk/qt/toolbar-common-uimstateindicator.cpp 2005-02-02 19:55:12 UTC (rev 485)
+++ trunk/qt/toolbar-common-uimstateindicator.cpp 2005-02-02 20:31:34 UTC (rev 486)
@@ -43,7 +43,7 @@
#include <stdlib.h>
static int uim_fd;
-static QToolButton *fallbackButton = NULL;
+static QHelperToolbarButton *fallbackButton = NULL;
static QSocketNotifier *notifier = NULL;
UimStateIndicator::UimStateIndicator( QWidget *parent, const char *name, WFlags f )
@@ -51,7 +51,7 @@
{
if ( !fallbackButton )
{
- fallbackButton = new QToolButton( this );
+ fallbackButton = new QHelperToolbarButton( this );
fallbackButton->setText( "?" );
fallbackButton->show();
}
@@ -105,7 +105,7 @@
if ( !buttons.isEmpty() )
buttons.clear();
- QToolButton *button = NULL;
+ QHelperToolbarButton *button = NULL;
QHelperPopupMenu *popupMenu = NULL;
QStringList::ConstIterator it = lines.begin();
@@ -128,7 +128,7 @@
popupMenu->setCheckable( true );
// create button
- button = new QToolButton( this );
+ button = new QHelperToolbarButton( this );
button->setText( fields[ 1 ] );
QToolTip::add( button, fields[ 2 ] );
button->setPopup( popupMenu );
Modified: trunk/qt/toolbar-common-uimstateindicator.h
===================================================================
--- trunk/qt/toolbar-common-uimstateindicator.h 2005-02-02 19:55:12 UTC (rev 485)
+++ trunk/qt/toolbar-common-uimstateindicator.h 2005-02-02 20:31:34 UTC (rev 486)
@@ -41,6 +41,9 @@
#include <uim/uim.h>
#include <uim/uim-helper.h>
+#define BUTTON_SIZE 25
+
+class QHelperToolbarButton;
class QHelperPopupMenu;
class UimStateIndicator : public QHBox
@@ -64,9 +67,21 @@
void slotStdinActivated( int socket );
protected:
- QPtrList<QToolButton> buttons;
+ QPtrList<QHelperToolbarButton> buttons;
};
+class QHelperToolbarButton : public QToolButton
+{
+public:
+ QHelperToolbarButton( QWidget *parent = 0, const char *name = 0 )
+ : QToolButton( parent, name ){}
+
+ QSize sizeHint() const
+ {
+ return QSize( BUTTON_SIZE, BUTTON_SIZE );
+ }
+};
+
class QHelperPopupMenu : public QPopupMenu
{
Q_OBJECT
Modified: trunk/qt/toolbar-standalone-qt.cpp
===================================================================
--- trunk/qt/toolbar-standalone-qt.cpp 2005-02-02 19:55:12 UTC (rev 485)
+++ trunk/qt/toolbar-standalone-qt.cpp 2005-02-02 20:31:34 UTC (rev 486)
@@ -41,9 +41,46 @@
#include <locale.h>
+#include "uim/uim.h"
#include "uim/config.h"
#include "qtgettext.h"
+UimStandaloneToolbar::UimStandaloneToolbar( QWidget *parent, const char *name )
+ : QHBox( parent, name, Qt::WStyle_NoBorder | Qt::WX11BypassWM )
+{
+ uim_init();
+
+ adjustSize();
+ UimToolbarDraggingHandler *h = new UimToolbarDraggingHandler( this );
+ h->adjustSize();
+ h->show();
+
+ QUimHelperToolbar *b = new QUimHelperToolbar( this );
+ b->adjustSize();
+ b->show();
+
+ // Move
+ int panelHeight = 64; // FIXME!
+ int screenwidth = QApplication::desktop() ->screenGeometry().width();
+ int screenheight = QApplication::desktop() ->screenGeometry().height();
+ QPoint p( screenwidth - width() - panelHeight, screenheight - height() - panelHeight );
+ move( p );
+
+ // Enable Dragging Feature
+ QObject::connect( h, SIGNAL( moveTo( const QPoint & ) ),
+ this, SLOT( move( const QPoint & ) ) );
+
+ // Quit
+ QObject::connect( b, SIGNAL( quitToolbar() ),
+ qApp, SLOT( quit() ) );
+
+ show();
+}
+UimStandaloneToolbar::~UimStandaloneToolbar()
+{
+ uim_quit();
+}
+
UimToolbarDraggingHandler::UimToolbarDraggingHandler( QWidget *parent,
const char* name )
: QFrame( parent, name ),
@@ -99,29 +136,10 @@
bind_textdomain_codeset(PACKAGE, "UTF-8"); // ensure code encoding is UTF8-
QApplication a( argc, argv );
+ UimStandaloneToolbar *toolbar = new UimStandaloneToolbar( 0, 0 );
+ toolbar->show();
+ a.setMainWidget( toolbar );
- QHBox toolbar( 0, 0, Qt::WStyle_NoBorder | Qt::WX11BypassWM );
- toolbar.adjustSize();
- UimToolbarDraggingHandler h( &toolbar );
- h.adjustSize();
- QUimHelperToolbar b( &toolbar );
- b.adjustSize();
-
- a.setMainWidget( &toolbar );
-
- // Move : FIXME!
- int panelHeight = 64; /* FIXME! */
- int screenwidth = QApplication::desktop() ->screenGeometry().width();
- int screenheight = QApplication::desktop() ->screenGeometry().height();
- QPoint p( screenwidth - toolbar.width() - panelHeight, screenheight - toolbar.height() - panelHeight );
- toolbar.move( p );
-
- // Enable Dragging Feature
- QObject::connect( &h, SIGNAL( moveTo( const QPoint & ) ),
- &toolbar, SLOT( move( const QPoint & ) ) );
-
- // Show
- toolbar.show();
return a.exec();
}
Modified: trunk/qt/toolbar-standalone-qt.h
===================================================================
--- trunk/qt/toolbar-standalone-qt.h 2005-02-02 19:55:12 UTC (rev 485)
+++ trunk/qt/toolbar-standalone-qt.h 2005-02-02 20:31:34 UTC (rev 486)
@@ -36,12 +36,23 @@
#include <qframe.h>
#include <qevent.h>
#include <qpoint.h>
+#include <qhbox.h>
+class UimStandaloneToolbar : public QHBox
+{
+ Q_OBJECT
+
+public:
+ UimStandaloneToolbar( QWidget *paret = 0, const char *name = 0 );
+ ~UimStandaloneToolbar();
+};
+
class UimToolbarDraggingHandler : public QFrame
{
Q_OBJECT
+
public:
- UimToolbarDraggingHandler( QWidget *parent, const char* name = 0 );
+ UimToolbarDraggingHandler( QWidget *parent, const char *name = 0 );
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
More information about the Uim-commit
mailing list