-rw-r--r-- | core/launcher/inputmethods.cpp | 14 | ||||
-rw-r--r-- | core/launcher/inputmethods.h | 2 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 17 | ||||
-rw-r--r-- | core/launcher/taskbar.h | 28 | ||||
-rw-r--r-- | core/settings/launcher/inputmethodsettings.cpp | 87 | ||||
-rw-r--r-- | core/settings/launcher/inputmethodsettings.h | 57 | ||||
-rw-r--r-- | core/settings/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/settings/launcher/launchersettings.cpp | 5 | ||||
-rw-r--r-- | core/settings/launcher/launchersettings.h | 2 | ||||
-rw-r--r-- | pics/launchersettings/inputmethod.png | bin | 0 -> 232 bytes |
10 files changed, 187 insertions, 27 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index f0d8294..d89a366 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp @@ -1,566 +1,566 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define QTOPIA_INTERNAL_LANGLIST #include "inputmethods.h" #include <qtopia/config.h> #include <qtopia/qpeapplication.h> #include <qtopia/inputmethodinterface.h> #include <qtopia/global.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qtoolbutton.h> #include <qwidgetstack.h> #include <qwidget.h> #include <qlayout.h> #include <qtimer.h> #include <qdir.h> #include <stdlib.h> #include <qtranslator.h> #include <qtl.h> #ifdef Q_WS_QWS #include <qwindowsystem_qws.h> #include <qwsevent_qws.h> #include <qcopchannel_qws.h> #endif /* ### SingleFloppy if someone is interested? */ #if 0 #ifdef QT_NO_COMPONENT #include "../plugins/inputmethods/handwriting/handwritingimpl.h" #include "../plugins/inputmethods/keyboard/keyboardimpl.h" #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" #endif #endif /* XPM */ static const char * tri_xpm[]={ "9 9 2 1", "a c #000000", ". c None", ".........", ".........", ".........", "....a....", "...aaa...", "..aaaaa..", ".aaaaaaa.", ".........", "........."}; -static const int inputWidgetStyle = QWidget::WStyle_Customize | - QWidget::WStyle_Tool | - QWidget::WStyle_StaysOnTop | - QWidget::WGroupLeader; - - int InputMethod::operator <(const InputMethod& o) const { return name() < o.name(); } int InputMethod::operator >(const InputMethod& o) const { return name() > o.name(); } int InputMethod::operator <=(const InputMethod& o) const { return name() <= o.name(); } /* Slightly hacky: We use WStyle_Tool as a flag to say "this widget belongs to the IM system, so clicking it should not cause a reset". */ class IMToolButton : public QToolButton { public: IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) { setWFlags( WStyle_Tool ); } }; InputMethods::InputMethods( QWidget *parent ) : QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), mkeyboard(0), imethod(0) { + Config cfg( "Launcher" ); + cfg.setGroup( "InputMethods" ); + inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader; + inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : QWidget::WStyle_Tool; + inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); + setBackgroundMode( PaletteBackground ); QHBoxLayout *hbox = new QHBoxLayout( this ); kbdButton = new IMToolButton( this); kbdButton->setFocusPolicy(NoFocus); kbdButton->setToggleButton( TRUE ); if (parent->sizeHint().height() > 0) kbdButton->setFixedHeight( parent->sizeHint().height() ); kbdButton->setFixedWidth( 32 ); kbdButton->setAutoRaise( TRUE ); kbdButton->setUsesBigPixmap( TRUE ); hbox->addWidget( kbdButton ); connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); kbdChoice = new IMToolButton( this ); kbdChoice->setFocusPolicy(NoFocus); kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); if (parent->sizeHint().height() > 0) kbdChoice->setFixedHeight( parent->sizeHint().height() ); kbdChoice->setFixedWidth( 13 ); kbdChoice->setAutoRaise( TRUE ); hbox->addWidget( kbdChoice ); connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), this, SLOT(resetStates()) ); imButton = new QWidgetStack( this ); // later a widget stack imButton->setFocusPolicy(NoFocus); if (parent->sizeHint().height() > 0) imButton->setFixedHeight( parent->sizeHint().height() ); hbox->addWidget(imButton); imChoice = new QToolButton( this ); imChoice->setFocusPolicy(NoFocus); imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); if (parent->sizeHint().height() > 0) imChoice->setFixedHeight( parent->sizeHint().height() ); imChoice->setFixedWidth( 13 ); imChoice->setAutoRaise( TRUE ); hbox->addWidget( imChoice ); connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); loadInputMethods(); QCopChannel *channel = new QCopChannel( "QPE/IME", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(qcopReceive(const QCString&, const QByteArray&)) ); } InputMethods::~InputMethods() { Config cfg("qpe"); cfg.setGroup("InputMethod"); if (imethod) cfg.writeEntry("im", imethod->name() ); if (mkeyboard) cfg.writeEntry("current", mkeyboard->name() ); unloadInputMethods(); } void InputMethods::hideInputMethod() { kbdButton->setOn( FALSE ); } void InputMethods::showInputMethod() { kbdButton->setOn( TRUE ); } void InputMethods::showInputMethod(const QString& name) { int i = 0; QValueList<InputMethod>::Iterator it; InputMethod *im = 0; for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); if ( (*it).name() == name || lname == name ) { im = &(*it); break; } } if ( im ) chooseKeyboard(im); } void InputMethods::resetStates() { if ( mkeyboard && !mkeyboard->newIM ) mkeyboard->interface->resetState(); } QRect InputMethods::inputRect() const { if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) return QRect(); else return mkeyboard->widget->geometry(); } void InputMethods::unloadInputMethods() { unloadMethod( inputMethodList ); unloadMethod( inputModifierList ); inputMethodList.clear(); inputModifierList.clear(); } void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { QValueList<InputMethod>::Iterator it; for (it = list.begin(); it != list.end(); ++it ) (*it).releaseInterface(); } QStringList InputMethods::plugins()const { QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; QDir dir( path, "lib*.so" ); return dir.entryList(); } void InputMethods::installTranslator( const QString& type ) { QStringList langs = Global::languageList(); QStringList::ConstIterator lit; for ( lit= langs.begin(); lit!=langs.end(); ++lit) { QString lang = *lit; QTranslator * trans = new QTranslator(qApp); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; } } void InputMethods::setPreferedHandlers() { Config cfg("qpe"); cfg.setGroup("InputMethod"); QString current = cfg.readEntry("current"); QString im = cfg.readEntry("im"); QValueList<InputMethod>::Iterator it; if (!inputModifierList.isEmpty() && !im.isEmpty() ) { for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) if ( (*it).name() == im ) { imethod = &(*it); break; } } if (!inputMethodList.isEmpty() && !current.isEmpty() ) { for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) if ( (*it).name() == current ) { qWarning("preferred keyboard is %s", current.latin1() ); mkeyboard = &(*it); kbdButton->setPixmap( *mkeyboard->icon() ); break; } } } void InputMethods::loadInputMethods() { #ifndef QT_NO_COMPONENT hideInputMethod(); mkeyboard = 0; unloadInputMethods(); QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; QStringList list = plugins(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { InputMethodInterface *iface = 0; ExtInputMethodInterface *eface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { InputMethod input; input.newIM = FALSE; input.library = lib; input.libName = *it; input.interface = iface; input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); inputMethodList.append( input ); } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { InputMethod input; input.newIM = TRUE; input.library = lib; input.libName = *it; input.extInterface = eface; input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); // may be either a simple, or advanced. if (input.widget) { //qDebug("its a keyboard"); inputMethodList.append( input ); } else { //qDebug("its a real im"); input.widget = input.extInterface->statusWidget( 0, 0 ); if (input.widget) { //qDebug("blah"); inputModifierList.append( input ); imButton->addWidget(input.widget, inputModifierList.count()); } } }else{ delete lib; lib = 0l; } installTranslator( (*it).left( (*it).find(".") ) ); } qHeapSort( inputMethodList ); #endif /* killed BUILT in cause they would not compile */ QWSServer::setCurrentInputMethod( 0 ); /* set the prefered IM + handler */ setPreferedHandlers(); if ( !inputModifierList.isEmpty() ) { if (!imethod) imethod = &inputModifierList[0]; imButton->raiseWidget(imethod->widget); QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); } else { imethod = 0; } // we need to update keyboards afterwards, as some of them may not be compatible with // the current input method updateKeyboards(imethod); if ( !inputModifierList.isEmpty() ) imButton->show(); else imButton->hide(); if ( inputModifierList.count() > 1 ) imChoice->show(); else imChoice->hide(); } void InputMethods::chooseKbd() { QPopupMenu pop( this ); pop.setFocusPolicy( NoFocus ); //don't reset IM QString imname; if (imethod) imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); int i = 0; int firstDepKbd = 0; QValueList<InputMethod>::Iterator it; for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { // add empty new items, all old items. if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { pop.insertItem( (*it).name(), i, firstDepKbd); if ( mkeyboard == &(*it) ) pop.setItemChecked( i, TRUE ); firstDepKbd++; } else if ( (*it).extInterface->compatible().contains(imname)) { // check if we need to insert a sep. if (firstDepKbd == i) pop.insertSeparator(); pop.insertItem( (*it).name(), i, -1); if ( mkeyboard == &(*it) ) pop.setItemChecked( i, TRUE ); } } QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); QSize s = pop.sizeHint(); pt.ry() -= s.height(); pt.rx() -= s.width(); i = pop.exec( pt ); if ( i == -1 ) return; InputMethod *im = &inputMethodList[i]; chooseKeyboard(im); } void InputMethods::chooseIm() { QPopupMenu pop( this ); int i = 0; QValueList<InputMethod>::Iterator it; for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { pop.insertItem( (*it).name(), i ); if ( imethod == &(*it) ) pop.setItemChecked( i, TRUE ); } QPoint pt = mapToGlobal(imChoice->geometry().topRight()); QSize s = pop.sizeHint(); pt.ry() -= s.height(); pt.rx() -= s.width(); i = pop.exec( pt ); if ( i == -1 ) return; InputMethod *im = &inputModifierList[i]; chooseMethod(im); } void InputMethods::chooseKeyboard(InputMethod* im) { if ( im != mkeyboard ) { if ( mkeyboard && mkeyboard->widget->isVisible() ) mkeyboard->widget->hide(); mkeyboard = im; kbdButton->setPixmap( *mkeyboard->icon() ); } if ( !kbdButton->isOn() ) kbdButton->setOn( TRUE ); else showKbd( TRUE ); } static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) { if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) return TRUE; if ( keyb->extInterface->compatible().contains(imname) ) return TRUE; return FALSE; } // Updates the display of the soft keyboards available to the current input method void InputMethods::updateKeyboards(InputMethod *im ) { uint count; if ( im ) { QString imname = im->libName.mid(im->libName.findRev('/') + 1); if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { kbdButton->setOn( FALSE ); showKbd( FALSE ); mkeyboard = 0; } count = 0; QValueList<InputMethod>::Iterator it; for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { if ( keyboardCompatible( &(*it), imname ) ) { if ( !mkeyboard ) { mkeyboard = &(*it); kbdButton->setPixmap( *mkeyboard->icon() ); } count++; } } } else { count = inputMethodList.count(); if ( count && !mkeyboard ) { mkeyboard = &inputMethodList[0]; kbdButton->setPixmap( *mkeyboard->icon() ); } else if (!count){ mkeyboard = 0; //might be redundant } } if ( count > 1 ) kbdChoice->show(); else kbdChoice->hide(); if ( count ) kbdButton->show(); else kbdButton->hide(); } void InputMethods::chooseMethod(InputMethod* im) { if ( im != imethod ) { updateKeyboards( im ); Config cfg("qpe"); cfg.setGroup("InputMethod"); if (im ) cfg.writeEntry("im", im->name() ); if (mkeyboard) cfg.writeEntry("current", mkeyboard->name() ); QWSServer::setCurrentInputMethod( 0 ); imethod = im; if ( imethod && imethod->newIM ) QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); else QWSServer::setCurrentInputMethod( 0 ); if ( im ) imButton->raiseWidget(im->widget); else imButton->hide(); //### good UI? make sure it is shown again! } } void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) { if ( imethod && imethod->newIM ) imethod->extInterface->qcopReceive( msg, data ); } void InputMethods::showKbd( bool on ) { if ( !mkeyboard ) return; if ( on ) { mkeyboard->resetState(); // HACK... Make the texteditor fit with all input methods // Input methods should also never use more than about 40% of the screen int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); - mkeyboard->widget->resize( qApp->desktop()->width(), height ); + mkeyboard->widget->resize( qApp->desktop()->width() * (inputWidgetWidth*0.01), height ); mkeyboard->widget->move( 0, mapToGlobal( QPoint() ).y() - height ); mkeyboard->widget->show(); } else { mkeyboard->widget->hide(); } emit inputToggled( on ); } bool InputMethods::shown() const { return mkeyboard && mkeyboard->widget->isVisible(); } QString InputMethods::currentShown() const { return mkeyboard && mkeyboard->widget->isVisible() ? mkeyboard->name() : QString::null; } void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) { #if defined(Q_WS_QWS) QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); #endif } diff --git a/core/launcher/inputmethods.h b/core/launcher/inputmethods.h index 93b69de..246661a 100644 --- a/core/launcher/inputmethods.h +++ b/core/launcher/inputmethods.h @@ -1,110 +1,112 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __INPUT_METHODS_H__ #define __INPUT_METHODS_H__ #include <qtopia/qlibrary.h> #include <qtopia/inputmethodinterface.h> #include <qwidget.h> #include <qvaluelist.h> class QToolButton; class QWidgetStack; struct InputMethod { #ifndef QT_NO_COMPONENT QLibrary *library; #endif QWidget *widget; QString libName; bool newIM; union { InputMethodInterface *interface; ExtInputMethodInterface *extInterface; }; inline void releaseInterface() { newIM ? (void)extInterface->release() : (void)interface->release(); library->unload(); delete library; library = 0l; } inline QString name() const { return newIM ? extInterface->name() : interface->name(); } inline QPixmap *icon() const { return newIM ? extInterface->icon() : interface->icon(); } inline QUnknownInterface *iface() { return newIM ? (QUnknownInterface *)extInterface : (QUnknownInterface *)interface; } inline void resetState() { if ( !newIM ) interface->resetState(); } int operator <(const InputMethod& o) const; int operator >(const InputMethod& o) const; int operator <=(const InputMethod& o) const; }; class InputMethods : public QWidget { Q_OBJECT public: InputMethods( QWidget * ); ~InputMethods(); QRect inputRect() const; bool shown() const; QString currentShown() const; // name of interface void showInputMethod(const QString& id); void showInputMethod(); void hideInputMethod(); void unloadInputMethods(); void loadInputMethods(); signals: void inputToggled( bool on ); private slots: void chooseKbd(); void chooseIm(); void showKbd( bool ); void resetStates(); void sendKey( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); void qcopReceive( const QCString &msg, const QByteArray &data ); private: void setPreferedHandlers(); /*static */QStringList plugins()const; /*static */void installTranslator( const QString& ); void unloadMethod( QValueList<InputMethod>& ); void chooseMethod(InputMethod* im); void chooseKeyboard(InputMethod* im); void updateKeyboards(InputMethod *im); private: QToolButton *kbdButton; QToolButton *kbdChoice; QWidgetStack *imButton; // later will be widget stack QToolButton *imChoice; InputMethod *mkeyboard; InputMethod *imethod; QValueList<InputMethod> inputMethodList; QValueList<InputMethod> inputModifierList; + int inputWidgetStyle; + int inputWidgetWidth; }; #endif // __INPUT_METHODS_H__ diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index 37fdb30..2966168 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp @@ -1,374 +1,377 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "startmenu.h" #include "inputmethods.h" #include "runningappbar.h" #include "systray.h" #include "wait.h" #include "appicons.h" #include "taskbar.h" #include "server.h" +#include <qtopia/config.h> #include <qtopia/qpeapplication.h> #ifdef QWS #include <qtopia/qcopenvelope_qws.h> #endif #include <qtopia/global.h> #include <qtopia/custom.h> #include <qlabel.h> #include <qlayout.h> #include <qtimer.h> #ifdef QWS #include <qwindowsystem_qws.h> #endif #include <qwidgetstack.h> #if defined( Q_WS_QWS ) #include <qwsdisplay_qws.h> #include <qgfx_qws.h> #endif static bool initNumLock() { #ifdef QPE_INITIAL_NUMLOCK_STATE QPE_INITIAL_NUMLOCK_STATE #endif return FALSE; } //--------------------------------------------------------------------------- class SafeMode : public QWidget { Q_OBJECT public: SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) { message = tr("Safe Mode"); QFont f( font() ); f.setWeight( QFont::Bold ); setFont( f ); } void mousePressEvent( QMouseEvent *); QSize sizeHint() const; void paintEvent( QPaintEvent* ); private slots: void action(int i); private: QString message; QPopupMenu *menu; }; void SafeMode::mousePressEvent( QMouseEvent *) { if ( !menu ) { menu = new QPopupMenu(this); menu->insertItem( tr("Plugin Manager..."), 0 ); menu->insertItem( tr("Restart Qtopia"), 1 ); menu->insertItem( tr("Help..."), 2 ); connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); } QPoint curPos = mapToGlobal( QPoint(0,0) ); QSize sh = menu->sizeHint(); menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); } void SafeMode::action(int i) { switch (i) { case 0: Global::execute( "pluginmanager" ); break; case 1: Global::restart(); break; case 2: Global::execute( "helpbrowser", "safemode.html" ); break; } } QSize SafeMode::sizeHint() const { QFontMetrics fm = fontMetrics(); return QSize( fm.width(message), fm.height() ); } void SafeMode::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawText( rect(), AlignCenter, message ); } //--------------------------------------------------------------------------- class LockKeyState : public QWidget { public: LockKeyState( QWidget *parent ) : QWidget(parent), nl(initNumLock()), cl(FALSE) { nl_pm = Resource::loadPixmap("numlock"); cl_pm = Resource::loadPixmap("capslock"); } QSize sizeHint() const { return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); } void toggleNumLockState() { nl = !nl; repaint(); } void toggleCapsLockState() { cl = !cl; repaint(); } void paintEvent( QPaintEvent * ) { int y = (height()-sizeHint().height())/2; QPainter p(this); if ( nl ) p.drawPixmap(1,y,nl_pm); if ( cl ) p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); } private: QPixmap nl_pm, cl_pm; bool nl, cl; }; //--------------------------------------------------------------------------- TaskBar::~TaskBar() { } TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) { + Config cfg( "Launcher" ); + cfg.setGroup( "InputMethods" ); + resizeRunningApp = cfg.readBoolEntry( "Resize", true ); + sm = new StartMenu( this ); connect( sm, SIGNAL(tabSelected(const QString&)), this, SIGNAL(tabSelected(const QString&)) ); inputMethods = new InputMethods( this ); connect( inputMethods, SIGNAL(inputToggled(bool)), this, SLOT(calcMaxWindowRect()) ); stack = new QWidgetStack( this ); stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); label = new QLabel(stack); runningAppBar = new RunningAppBar(stack); stack->raiseWidget(runningAppBar); waitIcon = new Wait( this ); (void) new AppIcons( this ); sysTray = new SysTray( this ); /* ### FIXME plugin loader and safe mode */ #if 0 if (PluginLoader::inSafeMode()) (void)new SafeMode( this ); #endif // ## make customizable in some way? #ifdef QT_QWS_CUSTOM lockState = new LockKeyState( this ); #else lockState = 0; #endif #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); #endif #endif waitTimer = new QTimer( this ); connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); clearer = new QTimer( this ); QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); } void TaskBar::setStatusMessage( const QString &text ) { if ( !text.isEmpty() ) { label->setText( text ); stack->raiseWidget( label ); if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) sysTray->hide(); clearer->start( 3000, TRUE ); } else { clearStatusBar(); } } void TaskBar::clearStatusBar() { label->clear(); stack->raiseWidget(runningAppBar); if ( sysTray ) sysTray->show(); // stack->raiseWidget( mru ); } void TaskBar::startWait() { waitIcon->setWaiting( true ); // a catchall stop after 10 seconds... waitTimer->start( 10 * 1000, true ); } void TaskBar::stopWait(const QString&) { waitTimer->stop(); waitIcon->setWaiting( false ); } void TaskBar::stopWait() { waitTimer->stop(); waitIcon->setWaiting( false ); } /* * This resizeEvent will be captured by * the ServerInterface and it'll layout * and calc rect. Now if we go from bigger * to smaller screen the SysTray is out of * bounds and repaint() won't trigger an Event */ void TaskBar::resizeEvent( QResizeEvent *e ) { if ( sysTray ) sysTray->hide(); QHBox::resizeEvent( e ); if ( sysTray ) sysTray->show(); qWarning("TaskBar::resize event"); } void TaskBar::styleChange( QStyle &s ) { QHBox::styleChange( s ); calcMaxWindowRect(); } void TaskBar::calcMaxWindowRect() { - /* -#ifdef Q_WS_QWS + if ( resizeRunningApp ) + { + #if defined(Q_WS_QWS) QRect wr; int displayWidth = qApp->desktop()->width(); QRect ir = inputMethods->inputRect(); if ( ir.isValid() ) { wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); } else { wr.setCoords( 0, 0, displayWidth-1, y()-1 ); } - #if QT_VERSION < 0x030000 - QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, - QSize(qt_screen->width(),qt_screen->height())) - ); + QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); #else QWSServer::setMaxWindowRect( wr ); #endif #endif - */ + } } void TaskBar::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString text; stream >> text; setStatusMessage( text ); } else if ( msg == "hideInputMethod()" ) { inputMethods->hideInputMethod(); } else if ( msg == "showInputMethod()" ) { inputMethods->showInputMethod(); } else if ( msg == "showInputMethod(QString)" ) { QString name; stream >> name; inputMethods->showInputMethod(name); } else if ( msg == "reloadInputMethods()" ) { inputMethods->loadInputMethods(); } else if ( msg == "reloadApplets()" ) { sysTray->clearApplets(); sm->createMenu(); sysTray->addApplets(); }else if ( msg == "toggleMenu()" ) { if ( sm-> launchMenu-> isVisible() ) sm-> launch(); else QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); }else if ( msg == "toggleStartMenu()" ) sm->launch(); } void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) { if ( state == ServerInterface::Launching ) runningAppBar->applicationLaunched( name ); else if ( state == ServerInterface::Terminated ) runningAppBar->applicationTerminated( name ); } void TaskBar::toggleNumLockState() { if ( lockState ) lockState->toggleNumLockState(); } void TaskBar::toggleCapsLockState() { if ( lockState ) lockState->toggleCapsLockState(); } void TaskBar::toggleSymbolInput() { QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); if ( inputMethods->currentShown() == unicodeInput ) { inputMethods->hideInputMethod(); } else { inputMethods->showInputMethod( unicodeInput ); } } #include "taskbar.moc" diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h index 0cfc123..ed558b1 100644 --- a/core/launcher/taskbar.h +++ b/core/launcher/taskbar.h @@ -1,83 +1,87 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ -#ifndef __TASKBAR_H__ -#define __TASKBAR_H__ +#ifndef TASKBAR_H +#define TASKBAR_H #include <qhbox.h> +#include "serverinterface.h" +#include "startmenu.h" class QLabel; class QTimer; class InputMethods; class Wait; class SysTray; class RunningAppBar; class QWidgetStack; class QTimer; class QLabel; -class StartMenu; class LockKeyState; +class AppLnkSet; class TaskBar : public QHBox { Q_OBJECT public: TaskBar(); ~TaskBar(); - static QWidget *calibrate( bool ); + void launchStartMenu() { if (sm) sm->launch(); } + void refreshStartMenu() { if (sm) sm->refreshMenu(); } + void setApplicationState( const QString &name, ServerInterface::ApplicationState state ); - bool recoverMemory(); +signals: + void tabSelected(const QString&); - StartMenu *startMenu() const { return sm; } public slots: void startWait(); void stopWait(const QString&); void stopWait(); + void clearStatusBar(); void toggleNumLockState(); void toggleCapsLockState(); void toggleSymbolInput(); + void calcMaxWindowRect(); protected: void resizeEvent( QResizeEvent * ); void styleChange( QStyle & ); void setStatusMessage( const QString &text ); -public slots: - void calcMaxWindowRect(); private slots: void receive( const QCString &msg, const QByteArray &data ); private: - QTimer *waitTimer; Wait *waitIcon; InputMethods *inputMethods; SysTray *sysTray; RunningAppBar* runningAppBar; QWidgetStack *stack; QTimer *clearer; QLabel *label; LockKeyState* lockState; StartMenu *sm; + bool resizeRunningApp; }; -#endif // __TASKBAR_H__ +#endif // TASKBAR_H diff --git a/core/settings/launcher/inputmethodsettings.cpp b/core/settings/launcher/inputmethodsettings.cpp new file mode 100644 index 0000000..1aa1ae8 --- a/dev/null +++ b/core/settings/launcher/inputmethodsettings.cpp @@ -0,0 +1,87 @@ +/* + This file is part of the OPIE Project + =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> + .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "inputmethodsettings.h" + +#include <qpe/config.h> +#include <qpe/qlibrary.h> +#include <qpe/qpeapplication.h> + +#include <qspinbox.h> +#include <qcheckbox.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qwhatsthis.h> + +InputMethodSettings::InputMethodSettings( QWidget *parent, const char *name ):QWidget( parent, name ) +{ + QBoxLayout *lay = new QVBoxLayout( this, 4, 4 ); + + _resize = new QCheckBox( tr( "Resize application on Popup" ), this ); + _float = new QCheckBox( tr( "Enable floating and resizing" ), this ); + + QHBoxLayout* hbox = new QHBoxLayout( this, 4, 4 ); + hbox->addWidget( new QLabel( "Initial Width:", this ) ); + _size = new QSpinBox( 10, 100, 10, this ); + _size->setSuffix( "%" ); + hbox->addWidget( _size ); + hbox->addStretch(); + + Config cfg( "Launcher" ); + cfg.setGroup( "InputMethods" ); + _resize->setChecked( cfg.readBoolEntry( "Resize", true ) ); + _float->setChecked( cfg.readBoolEntry( "Float", false ) ); + _size->setValue( cfg.readNumEntry( "Width", 100 ) ); + + lay->addWidget( _resize ); + lay->addWidget( _float ); + lay->addLayout( hbox ); + lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) ); + + lay->addStretch(); + + QWhatsThis::add( _resize, tr( "Check, if you want the application to be automatically resized if the input method pops up." ) ); + QWhatsThis::add( _float, tr( "Check, if you want to move and/or resize input methods" ) ); + QWhatsThis::add( _size, tr( "Specify the percentage of the screen width for the input method" ) ); +} + +void InputMethodSettings::appletChanged() +{ +} + +void InputMethodSettings::accept() +{ + qDebug( "InputMethodSettings::accept()" ); + Config cfg( "Launcher" ); + cfg.setGroup( "InputMethods" ); + cfg.writeEntry( "Resize", _resize->isChecked() ); + cfg.writeEntry( "Float", _float->isChecked() ); + cfg.writeEntry( "Width", _size->value() ); + cfg.write(); +} + diff --git a/core/settings/launcher/inputmethodsettings.h b/core/settings/launcher/inputmethodsettings.h new file mode 100644 index 0000000..486ee5e --- a/dev/null +++ b/core/settings/launcher/inputmethodsettings.h @@ -0,0 +1,57 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef __IMETHOD_SETTINGS_H__ +#define __IMETHOD_SETTINGS_H__ + +#include <qwidget.h> + +class QCheckBox; +class QSpinBox; + +class InputMethodSettings : public QWidget +{ + Q_OBJECT + + public: + InputMethodSettings ( QWidget *parent = 0, const char *name = 0 ); + + void accept ( ); + + protected slots: + void appletChanged ( ); + + protected: + void init ( ); + + private: + QCheckBox* _resize; + QCheckBox* _float; + QSpinBox* _size; +}; + +#endif diff --git a/core/settings/launcher/launcher.pro b/core/settings/launcher/launcher.pro index e532852..cea268d 100644 --- a/core/settings/launcher/launcher.pro +++ b/core/settings/launcher/launcher.pro @@ -1,26 +1,28 @@ TEMPLATE = app CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = launchersettings.h \ tabssettings.h \ taskbarsettings.h \ menusettings.h \ + inputmethodsettings.h \ tabconfig.h \ tabdialog.h SOURCES = main.cpp \ launchersettings.cpp \ tabssettings.cpp \ taskbarsettings.cpp \ menusettings.cpp \ + inputmethodsettings.cpp \ tabdialog.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = launchersettings include ( $(OPIEDIR)/include.pro ) diff --git a/core/settings/launcher/launchersettings.cpp b/core/settings/launcher/launchersettings.cpp index cb6e98a..3982194 100644 --- a/core/settings/launcher/launchersettings.cpp +++ b/core/settings/launcher/launchersettings.cpp @@ -1,73 +1,76 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qlayout.h> #include <qapplication.h> #include <opie/otabwidget.h> #include "launchersettings.h" #include "tabssettings.h" #include "menusettings.h" #include "taskbarsettings.h" - +#include "inputmethodsettings.h" LauncherSettings::LauncherSettings ( ) : QDialog ( 0, "LauncherSettings", false, WStyle_ContextHelp ) { setCaption ( tr( "Launcher Settings" )); QVBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); OTabWidget *tw = new OTabWidget ( this, "otab" ); lay-> addWidget ( tw ); m_tabs = new TabsSettings ( tw ); m_taskbar = new TaskbarSettings ( tw ); m_menu = new MenuSettings ( tw ); + m_imethods = new InputMethodSettings ( tw ); tw-> addTab ( m_taskbar, "wait", tr( "Taskbar" )); tw-> addTab ( m_menu, "go", tr( "O-Menu" )); tw-> addTab ( m_tabs, "launchersettings/tabstab.png", tr( "Tabs" )); + tw-> addTab ( m_imethods, "launchersettings/inputmethod.png", tr( "InputMethods" )); tw-> setCurrentTab ( m_taskbar ); } void LauncherSettings::accept ( ) { m_taskbar-> accept ( ); m_menu-> accept ( ); m_tabs-> accept ( ); + m_imethods-> accept ( ); QDialog::accept ( ); } void LauncherSettings::done ( int r ) { QDialog::done ( r ); close ( ); } diff --git a/core/settings/launcher/launchersettings.h b/core/settings/launcher/launchersettings.h index 56c916e..71165a3 100644 --- a/core/settings/launcher/launchersettings.h +++ b/core/settings/launcher/launchersettings.h @@ -1,52 +1,54 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __LAUNCHER_SETTINGS_H__ #define __LAUNCHER_SETTINGS_H__ #include <qdialog.h> class TabsSettings; class TaskbarSettings; class MenuSettings; +class InputMethodSettings; class LauncherSettings : public QDialog { Q_OBJECT public: LauncherSettings ( ); virtual void accept ( ); virtual void done ( int r ); private: TabsSettings *m_tabs; TaskbarSettings *m_taskbar; MenuSettings *m_menu; + InputMethodSettings* m_imethods; }; #endif diff --git a/pics/launchersettings/inputmethod.png b/pics/launchersettings/inputmethod.png Binary files differnew file mode 100644 index 0000000..f5af6cb --- a/dev/null +++ b/pics/launchersettings/inputmethod.png |