-rw-r--r-- | libopie2/opieui/big-screen/obigscreen_p.h | 2 | ||||
-rw-r--r-- | libopie2/opieui/big-screen/osplitter.cpp | 6 | ||||
-rw-r--r-- | libopie2/opieui/big-screen/osplitter.h | 6 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 5 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.h | 12 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector_p.h | 2 | ||||
-rw-r--r-- | libopie2/opieui/ofontselector.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/ofontselector.h | 4 | ||||
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 41 | ||||
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.h | 8 | ||||
-rw-r--r-- | libopie2/opieui/okeyconfigwidget_p.h | 2 | ||||
-rw-r--r-- | libopie2/opieui/otaskbarapplet.h | 4 |
12 files changed, 49 insertions, 47 deletions
diff --git a/libopie2/opieui/big-screen/obigscreen_p.h b/libopie2/opieui/big-screen/obigscreen_p.h index a85a56c..baa2bbc 100644 --- a/libopie2/opieui/big-screen/obigscreen_p.h +++ b/libopie2/opieui/big-screen/obigscreen_p.h @@ -1,31 +1,31 @@ #ifndef OPIE_BIG_SCREEN_PRIVATE #define OPIE_BIG_SCREEN_PRIVATE /* QT */ #include <qstring.h> class QWidget; namespace Opie { namespace Ui { -namespace Private{ +namespace Internal{ struct OSplitterContainer { bool operator==( const OSplitterContainer& o) const { if (widget != o.widget ) return false; if (icon != o.icon ) return false; if (name != o.name ) return false; return true; } QWidget* widget; QString icon; QString name; }; } } } #endif diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp index bcfd3a6..f0287ed 100644 --- a/libopie2/opieui/big-screen/osplitter.cpp +++ b/libopie2/opieui/big-screen/osplitter.cpp @@ -1,135 +1,135 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "osplitter.h" /* OPIE */ #include <opie2/otabwidget.h> /* QT */ #include <qvaluelist.h> #include <qvbox.h> using namespace Opie::Ui; -using namespace Opie::Ui::Private; +using namespace Opie::Ui::Internal; /** * * This is the constructor of OSplitter * You might want to call setSizeChange to tell * OSplitter to change its layout when a specefic * mark was crossed. OSplitter sets a default value. * * You cann add widget with addWidget to the OSplitter. * OSplitter supports also grouping of Splitters where they * can share one OTabBar in small screen mode. This can be used * for email clients like vies but see the example. * * @param orient The orientation wether to layout horizontal or vertical * @param parent The parent of this widget * @param name The name passed on to QObject * @param fl Additional widgets flags passed to QWidget * * @short single c'tor of the OSplitter */ OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) : QFrame( parent, name, fl ) { m_orient = orient; m_hbox = 0; m_size_policy = 330; setFontPropagation( AllChildren ); setPalettePropagation( AllChildren ); /* start by default with the tab widget */ m_tabWidget = 0; m_parentTab = 0; changeTab(); } /** * Destructor destructs this object and cleans up. All child * widgets will be deleted * @see addWidget */ OSplitter::~OSplitter() { qWarning("Deleted Splitter"); m_splitter.setAutoDelete( true ); m_splitter.clear(); delete m_hbox; delete m_tabWidget; } /** * Sets the label for the Splitter. This label will be used * if a parent splitter is arranged as TabWidget but * this splitter is in fullscreen mode. Then a tab with OSplitter::label() * and iconName() gets added. * * @param name The name of the Label */ void OSplitter::setLabel( const QString& name ) { m_name = name; } /** * @see setLabel but this is for the icon retrieved by Resource * * @param name The name of the icon in example ( "zoom" ) */ void OSplitter::setIconName( const QString& name ) { m_icon = name; } /** * returns the iconName * @see setIconName */ QString OSplitter::iconName()const { return m_icon; } /** * returns the label set with setLabel * @see setLabel */ QString OSplitter::label()const { return m_name; } /** @@ -304,207 +304,207 @@ void OSplitter::setCurrentWidget( const QString& label ) } /** * This will only work when the TabWidget is active * If everything is visible this signal is kindly ignored * @see OTabWidget::setCurrentTab(int) * * @param tab The tab to make current */ void OSplitter::setCurrentWidget( int tab ) { if (m_tabWidget ) m_tabWidget->setCurrentTab( tab ); } /** * return the currently activated widget if in tab widget mode * or null because all widgets are visible */ QWidget* OSplitter::currentWidget() const { if (m_tabWidget) return m_tabWidget->currentWidget(); else if (m_parentTab ) return m_parentTab->currentWidget(); return 0l; } /* wrong */ #if 0 /** * @reimplented for internal reasons * returns the sizeHint of one of its sub widgets */ QSize OSplitter::sizeHint()const { if (m_parentTab ) return QFrame::sizeHint(); if (m_hbox ) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } QSize OSplitter::minimumSizeHint()const { if (m_parentTab ) return QFrame::minimumSizeHint(); if (m_hbox) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } #endif /** * @reimplemented for internal reasons */ void OSplitter::resizeEvent( QResizeEvent* res ) { QFrame::resizeEvent( res ); /* * */ // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); bool mode = true; qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); if ( res->size().width() > m_size_policy && m_orient == Horizontal ) { changeHBox(); mode = false; } else if ( (res->size().width() <= m_size_policy && m_orient == Horizontal ) || (res->size().height() <= m_size_policy && m_orient == Vertical ) ) { changeTab(); } else if ( res->size().height() > m_size_policy && m_orient == Vertical ) { qWarning("Changng to vbox %s", name() ); changeVBox(); mode = false; } emit sizeChanged(mode, m_orient ); } /* * Adds a container to a tab either the parent tab * or our own */ -void OSplitter::addToTab( const Opie::Ui::Private::OSplitterContainer& con ) +void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con ) { QWidget *wid = con.widget; // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); if (m_parentTab ) m_parentTab->addTab( wid, con.icon, con.name ); else m_tabWidget->addTab( wid, con.icon, con.name ); } /* * adds a container to the box */ -void OSplitter::addToBox( const Opie::Ui::Private::OSplitterContainer& con ) +void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con ) { QWidget* wid = con.widget; wid->reparent(m_hbox, 0, QPoint(0, 0) ); } /* * Removes a widget from the tab */ void OSplitter::removeFromTab( QWidget* wid ) { if (m_parentTab ) m_parentTab->removePage( wid ); else m_tabWidget->removePage( wid ); } /* * switches over to a OTabWidget layout * it is recursive */ void OSplitter::changeTab() { /* if we're the owner of the tab widget */ if (m_tabWidget ) { raise(); show(); m_tabWidget->setGeometry( frameRect() ); return; } qWarning(" New Tab Widget %s", name() ); /* * and add all widgets this will reparent them * delete m_hbox set it to 0 * */ OTabWidget *tab; if ( m_parentTab ) { hide(); tab = m_parentTab; /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ if (!m_container.isEmpty() ) { ContainerList::Iterator it = m_container.begin(); for (; it != m_container.end(); ++it ) m_parentTab->removePage( (*it).widget ); } } else tab = m_tabWidget = new OTabWidget( this ); connect(tab, SIGNAL(currentChanged(QWidget*) ), this, SIGNAL(currentChanged(QWidget*) ) ); for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { qWarning("Widget is %s", (*it).name.latin1() ); addToTab( (*it) ); } for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { split->reparent(this, 0, QPoint(0, 0) ); split->setTabWidget( tab ); } delete m_hbox; m_hbox = 0; if (!m_tabWidget ) return; m_tabWidget->setGeometry( frameRect() ); m_tabWidget->show(); } /* * changes over to a box * this is recursive as well */ void OSplitter::changeHBox() { if (m_hbox ) { m_hbox->setGeometry( frameRect() ); return; } qWarning("new HBox %s", name() ); m_hbox = new QHBox( this ); commonChangeBox(); } diff --git a/libopie2/opieui/big-screen/osplitter.h b/libopie2/opieui/big-screen/osplitter.h index 7b5ea53..46dad05 100644 --- a/libopie2/opieui/big-screen/osplitter.h +++ b/libopie2/opieui/big-screen/osplitter.h @@ -1,151 +1,151 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OSPLITTER_H #define OSPLITTER_H #include "obigscreen_p.h" /* QT */ #include <qframe.h> #include <qlist.h> #include <qstring.h> #include <qvaluelist.h> class QHBox; //template class QValueList<Opie::OSplitterContainer>; /* * TODO * -check API docu * -one more example * -allow inserting at a position */ namespace Opie{ namespace Ui { class OTabWidget; /** * * If you've widgets that could be placed side by side but you think * on small resolutions is not enough place but it would really make sense * on bigger resolutions this class will help you. * You can add as many widgets you want to it. Set a poliy on which width/height it * should switch the layout. * You can either say to place widgets vertical or horizontal. * This class uses QHBox, QVBox and QTAbWidget internally. * OSplitter takes ownership of the widgets * * @since 1.2 * * @short a small dynamically changing its layout to store two or more widgets side by side * @version 0.1 * @author zecke */ class OSplitter : public QFrame { Q_OBJECT public: - typedef QValueList<Opie::Ui::Private::OSplitterContainer> ContainerList; + typedef QValueList<Opie::Ui::Internal::OSplitterContainer> ContainerList; OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, const char* name = 0, WFlags fl = 0 ); ~OSplitter(); void setLabel( const QString& name ); void setIconName( const QString& name ); QString label()const; QString iconName()const; void setSizeChange( int width_height ); void addWidget( OSplitter* splitter ); void addWidget( QWidget* wid, const QString& icon, const QString& label ); void removeWidget( QWidget* ); void removeWidget( OSplitter* ); void setCurrentWidget( QWidget* ); void setCurrentWidget( const QString& label ); void setCurrentWidget( int ); QWidget* currentWidget()const; signals: /** * Emitted if in tab and comes directly from the tab widget * */ void currentChanged( QWidget* ); /** * emitted whenever a border is crossed * true if in small screen mode * false if in bigscreen * this signal is emitted after the layout switch * @param b The layout mode * @param ori The orientation */ void sizeChanged( bool b, Orientation ori); public: // QSize sizeHint()const; // QSize minimumSizeHint()const; protected: void resizeEvent( QResizeEvent* ); private: /* true if OTabMode */ bool layoutMode()const; // void reparentAll(); void setTabWidget( OTabWidget*); - void addToTab( const Opie::Ui::Private::OSplitterContainer& ); - void addToBox( const Opie::Ui::Private::OSplitterContainer& ); + void addToTab( const Opie::Ui::Internal::OSplitterContainer& ); + void addToBox( const Opie::Ui::Internal::OSplitterContainer& ); void removeFromTab( QWidget* ); void changeTab(); void changeHBox(); void changeVBox(); void commonChangeBox(); QHBox *m_hbox; OTabWidget *m_tabWidget; OTabWidget *m_parentTab; Orientation m_orient; int m_size_policy; ContainerList m_container; QList<OSplitter> m_splitter; QString m_icon, m_name; struct Private; Private *d; }; } } #endif diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index c4d5033..a9ec8c4 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -1,158 +1,159 @@ + /* =. This file is part of the OPIE Project .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* hacky but we need to get FileSelector::filter */ #define private public #include <qpe/fileselector.h> #undef private #include "ofileselector_p.h" /* OPIE */ #include <opie2/ofileselector.h> #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include <qpe/storage.h> /* QT */ #include <qcombobox.h> #include <qdir.h> #include <qhbox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qpopupmenu.h> #include <qwidgetstack.h> #include <qregexp.h> #include <qobjectlist.h> -using namespace Opie::Ui::Private; +using namespace Opie::Ui::Internal; namespace Opie { namespace Ui { -namespace Private { +namespace Internal { OFileViewInterface::OFileViewInterface( OFileSelector* selector ) : m_selector( selector ) {} OFileViewInterface::~OFileViewInterface() {} QString OFileViewInterface::name()const { return m_name; } void OFileViewInterface::setName( const QString& name ) { m_name = name; } OFileSelector* OFileViewInterface::selector()const { return m_selector; } DocLnk OFileViewInterface::selectedDocument()const { return DocLnk( selectedName() ); } bool OFileViewInterface::showNew()const { return selector()->showNew(); } bool OFileViewInterface::showClose()const { return selector()->showClose(); } MimeTypes OFileViewInterface::mimeTypes()const { return selector()->mimeTypes(); } QStringList OFileViewInterface::currentMimeType()const { return selector()->currentMimeType(); } void OFileViewInterface::activate( const QString& ) { // not implemented here } void OFileViewInterface::ok() { emit selector()->ok(); } void OFileViewInterface::cancel() { emit selector()->cancel(); } void OFileViewInterface::closeMe() { emit selector()->closeMe(); } void OFileViewInterface::fileSelected( const QString& str) { emit selector()->fileSelected( str); } void OFileViewInterface::fileSelected( const DocLnk& lnk) { emit selector()->fileSelected( lnk ); } void OFileViewInterface::setCurrentFileName( const QString& str ) { selector()->m_lneEdit->setText( str ); } QString OFileViewInterface::currentFileName()const { return selector()->m_lneEdit->text(); } QString OFileViewInterface::startDirectory()const { return selector()->m_startDir; } ODocumentFileView::ODocumentFileView( OFileSelector* selector ) :OFileViewInterface( selector ) { m_selector = 0; diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h index 2205963..8bcd9ee 100644 --- a/libopie2/opieui/fileselector/ofileselector.h +++ b/libopie2/opieui/fileselector/ofileselector.h @@ -1,222 +1,222 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This is based on code and ideas of L. J. Potter ljp@llornkcor.com Thanks a lot */ #ifndef OFILESELECTOR_H #define OFILESELECTOR_H /* OPIE */ #include <qpe/applnk.h> /* QT */ #include <qlist.h> #include <qwidget.h> #include <qmap.h> #include <qvaluelist.h> #include <qstringlist.h> class QLineEdit; class QComboBox; class QWidgetStack; class QHBox; typedef QMap<QString, QStringList> MimeTypes; namespace Opie { namespace Ui { -namespace Private { +namespace Internal { class OFileViewInterface; class OFileViewFileListView; } /** * @short a dropin replacement for the FileSelector * * This class is first used insert the OFileDialog. * It supports multiple view and mimetype filtering for now. * * @see OFileDialog * @see FileSelector * @author zecke * @version 0.1 */ class OFileSelector : public QWidget { Q_OBJECT - friend class Private::OFileViewInterface; - friend class Private::OFileViewFileListView; + friend class Internal::OFileViewInterface; + friend class Internal::OFileViewFileListView; public: /** * The Mode of the Fileselector * Open = Open A File * Save = Save a File * FILESELECTOR = As A GUI in a screen to select a file */ enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; /** * Normal = The old FileSelector * Extended = Dir View * ExtendedAll = Dir View with all hidden files * Default = What the vendor considers best */ enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; OFileSelector(QWidget* parent, int mode, int selector, const QString& dirName, const QString& fileName, const MimeTypes& mimetypes = MimeTypes(), bool newVisible = FALSE, bool closeVisible = FALSE ); OFileSelector(const QString& mimeFilter, QWidget* parent, const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); ~OFileSelector(); const DocLnk* selected(); QString selectedName()const; QString selectedPath()const; QString directory()const; DocLnk selectedDocument()const; int fileCount()const; void reread(); int mode()const; int selector()const; /** * Set the Icon visible * @param b Show or Hide the New Button */ void setNewVisible( bool b ); /** * Set the Icon visible */ void setCloseVisible( bool b ); /** * Set the Name Line visible */ void setNameVisible( bool b ); signals: /** * dirSelected is emitted whenever changed into a different dir */ void dirSelected( const QString& ); /** * fileSelected is emitted when a file is selected * it uses a DocLnk as parameter */ void fileSelected( const DocLnk& ); /** * fileSelected is emitted when a file is selected * the complete path is a parameter */ void fileSelected( const QString& ); /** * Create a new File with a DocLnk */ void newSelected( const DocLnk& ); void closeMe(); /** * Ok is emitted on a Qt::Key_Return or Q::Key_Enter * in the line edit */ void ok(); void cancel(); /* used by the ViewInterface */ private: bool showNew()const; bool showClose()const; MimeTypes mimeTypes()const; QStringList currentMimeType()const; private: /* inits the Widgets */ void initUI(); /* inits the MimeType ComboBox content + connects signals and slots */ void initMime(); /* init the Views :) */ void initViews(); private: QLineEdit* m_lneEdit; // the LineEdit for the Name QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType QWidgetStack* m_stack; // our widget stack which will contain the views - Private::OFileViewInterface* currentView() const; // returns the currentView - Private::OFileViewInterface* m_current; // here is the view saved + Internal::OFileViewInterface* currentView() const; // returns the currentView + Internal::OFileViewInterface* m_current; // here is the view saved bool m_shNew : 1; // should we show New? bool m_shClose : 1; // should we show Close? MimeTypes m_mimeType; // list of mimetypes - QMap<QString, Private::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr + QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr QHBox* m_nameBox; // the LineEdit + Label is hold here QHBox* m_cmbBox; // this holds the two combo boxes QString m_startDir; int m_mode; int m_selector; struct Data; // used for future versions Data *d; private slots: void slotMimeTypeChanged(); /* will set the text of the lineedit and emit a fileChanged signal */ void slotDocLnkBridge( const DocLnk& ); void slotFileBridge( const QString& ); void slotViewChange( const QString& ); bool eventFilter (QObject *o, QEvent *e); }; } } #endif diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h index 376dc98..a3ef8e2 100644 --- a/libopie2/opieui/fileselector/ofileselector_p.h +++ b/libopie2/opieui/fileselector/ofileselector_p.h @@ -1,158 +1,158 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OFILESELECTOR_PRIVATE_H #define OFILESELECTOR_PRIVATE_H /* OPIE */ #include <qpe/applnk.h> #include <qpe/fileselector.h> /* QT */ #include <qmap.h> #include <qstringlist.h> #include <qwidget.h> #include <qlistview.h> /* * How to avoid having really two different objects * for Extended and ExtendedAll * The only difference is the Lister... * a) static object? * b) leave some object inside the OFileSelector which can be used? * c) when switching views tell which view we want o have.. internally we can switch then * * I'll take c) -zecke */ typedef QMap<QString, QStringList> MimeTypes; /* the View Interface */ class QFileInfo; class QToolButton; namespace Opie{ namespace Ui{ class OFileSelector; -namespace Private { +namespace Internal { class OFileViewInterface { public: OFileViewInterface( OFileSelector* selector ); virtual ~OFileViewInterface(); virtual QString selectedName()const = 0; virtual QString selectedPath()const = 0; virtual QString directory()const = 0; virtual void reread() = 0; virtual int fileCount()const = 0; virtual DocLnk selectedDocument()const; virtual QWidget* widget( QWidget* parent) = 0; virtual void activate( const QString& ); QString name()const; protected: OFileSelector* selector()const; void setName( const QString& ); bool showNew()const; bool showClose()const; MimeTypes mimeTypes()const; QStringList currentMimeType()const; QString startDirectory()const; protected: void ok(); void cancel(); void closeMe(); void fileSelected( const QString& ); void fileSelected( const DocLnk& ); void setCurrentFileName( const QString& ); QString currentFileName()const; private: QString m_name; OFileSelector* m_selector; }; /* THE Document View hosting a FileSelector*/ class ODocumentFileView : public OFileViewInterface { public: ODocumentFileView( OFileSelector* selector ); ~ODocumentFileView(); QString selectedName() const; QString selectedPath() const; QString directory() const; void reread(); int fileCount()const; DocLnk selectedDocument()const; QWidget* widget( QWidget* parent ); private: mutable FileSelector* m_selector; }; class OFileSelectorItem : public QListViewItem { public: OFileSelectorItem( QListView* view, const QPixmap& pixmap, const QString& path, const QString& date, const QString& size, const QString& mDir, bool isLocked = false, bool isDir = false ); ~OFileSelectorItem(); bool isLocked()const; bool isDir()const; QString directory()const; QString path()const; QString key(int id, bool )const; private: bool m_locked : 1; bool m_isDir : 1; QString m_dir; }; class OFileViewFileListView : public QWidget { Q_OBJECT public: OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); ~OFileViewFileListView(); OFileSelectorItem* currentItem()const; void reread( bool all = false ); int fileCount()const; QString currentDir()const; protected: bool eventFilter (QObject *o, QEvent *e); private slots: void slotNew(); // will emit newSelected diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp index b19c26e..6763ee6 100644 --- a/libopie2/opieui/ofontselector.cpp +++ b/libopie2/opieui/ofontselector.cpp @@ -1,195 +1,195 @@ /* This file is part of the Opie Project Copyright (C) Robert Griebl <sandman@handhelds.org> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/ofontselector.h> #include <qpe/fontdatabase.h> /* QT */ #include <qlayout.h> #include <qlistbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qmultilineedit.h> namespace Opie { namespace Ui { -namespace Private { +namespace Internal { class OFontSelectorPrivate { public: QListBox * m_font_family_list; QComboBox * m_font_style_list; QComboBox * m_font_size_list; QMultiLineEdit *m_preview; bool m_pointbug : 1; FontDatabase m_fdb; }; class FontListItem : public QListBoxText { public: FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() { m_name = t; m_styles = styles; m_sizes = sizes; QString str = t; str [0] = str [0]. upper(); setText ( str ); } QString family() const { return m_name; } const QStringList &styles() const { return m_styles; } const QValueList<int> &sizes() const { return m_sizes; } private: QStringList m_styles; QValueList<int> m_sizes; QString m_name; }; } } } using namespace Opie::Ui; -using namespace Opie::Ui::Private; +using namespace Opie::Ui::Internal; static int findItemCB( QComboBox *box, const QString &str ) { for ( int i = 0; i < box->count(); i++ ) { if ( box->text ( i ) == str ) return i; } return -1; } /* static same as anon. namespace */ static int qt_version() { const char *qver = qVersion(); return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); } /** * Constructs the Selector object * @param withpreview If a font preview should be given * @param parent The parent of the Font Selector * @param name The name of the object * @param fl WidgetFlags */ OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) { d = new OFontSelectorPrivate(); QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); gridLayout->setRowStretch( 4, 10 ); d->m_font_family_list = new QListBox( this, "FontListBox" ); gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) ); QLabel *label = new QLabel( tr( "Style" ), this ); gridLayout->addWidget( label, 0, 1 ); d->m_font_style_list = new QComboBox( this, "StyleListBox" ); connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) ); gridLayout->addWidget( d->m_font_style_list, 1, 1 ); label = new QLabel( tr( "Size" ), this ); gridLayout->addWidget( label, 2, 1 ); d->m_font_size_list = new QComboBox( this, "SizeListBox" ); connect( d->m_font_size_list, SIGNAL( activated(int) ), this, SLOT( fontSizeClicked(int) ) ); gridLayout->addWidget( d->m_font_size_list, 3, 1 ); d->m_pointbug = ( qt_version() <= 233 ); if ( withpreview ) { d->m_preview = new QMultiLineEdit ( this, "Preview" ); d->m_preview->setAlignment ( AlignCenter ); d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); d->m_preview->setMargin ( 3 ); d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); gridLayout->addRowSpacing ( 5, 4 ); gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); gridLayout->setRowStretch ( 6, 5 ); } else d->m_preview = 0; loadFonts ( d->m_font_family_list ); } OFontSelector::~OFontSelector() { delete d; } /** * This methods tries to set the font * @param f The wishes font * @return success or failure */ bool OFontSelector::setSelectedFont ( const QFont &f ) { return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); } /** * This is an overloaded method @see setSelectedFont * @param familyStr The family of the font * @param styleStr The style of the font * @param sizeVal The size of font * @param charset The charset to be used. Will be deprecated by QT3 */ bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) { diff --git a/libopie2/opieui/ofontselector.h b/libopie2/opieui/ofontselector.h index 1d97233..cd134f4 100644 --- a/libopie2/opieui/ofontselector.h +++ b/libopie2/opieui/ofontselector.h @@ -1,106 +1,106 @@ /* This file is part of the Opie Project Copyright (C) Robert Griebl <sandman@handhelds.org> =. Copyright (C) The Opie Team <opie-devel@handhelds.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OFONTSELECTOR_H #define OFONTSELECTOR_H /* QT */ #include <qwidget.h> class QListBox; namespace Opie { namespace Ui { -namespace Private { +namespace Internal { class OFontSelectorPrivate; } /** * This class lets you chose a Font out of a list of Fonts. * It can show a preview too. This selector will use all available * fonts * * * @short A widget to select a font * @see QWidget * @see QFont * @author Rober Griebl */ class OFontSelector : public QWidget { Q_OBJECT public: OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); virtual ~OFontSelector ( ); bool selectedFont ( QString &family, QString &style, int &size ); bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); QFont selectedFont ( ); bool setSelectedFont ( const QFont & ); bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); QString fontFamily ( ) const; QString fontStyle ( ) const; int fontSize ( ) const; QString fontCharSet ( ) const; signals: /** * This signal gets emitted when a font got chosen */ void fontSelected ( const QFont & ); protected slots: /** @internal */ virtual void fontFamilyClicked ( int ); /** @internal */ virtual void fontStyleClicked ( int ); /** @internal */ virtual void fontSizeClicked ( int ); protected: virtual void resizeEvent ( QResizeEvent *re ); private: void loadFonts ( QListBox * ); void changeFont ( ); private: - Private::OFontSelectorPrivate *d; + Internal::OFontSelectorPrivate *d; }; } } #endif diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index ef6d713..eb7acbd 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp @@ -381,435 +381,436 @@ bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const { if ( m_id != conf.m_id ) return false; if ( m_obj != conf.m_obj ) return false; if ( m_text != conf.m_text ) return false; if ( m_key != conf.m_key ) return false; if ( m_def != conf.m_def ) return false; return true; } bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { return !( *this == conf ); } /** * \brief c'tor * The Constructor for a OKeyConfigManager * * You can use this manager in multiple ways. Either make it handle * QKeyEvents * * \code * Opie::Core::Config conf = oApp->config(); * Opie::Ui::OKeyPairList blackList; * blackList.append(Opie::Ui::OKeyPair::leftArrowKey()); * blackList.append(Opie::Ui::OKeyPair::rightArrowKey()); * Opie::Ui::OKeyConfigManager *manager = new Opie::Ui::OKeyConfigManager(conf,"key_actions",blackList, * false); * QListView *view = new QListView(); * manager->handleWidget(view); * manager->addKeyConfig( Opie::Ui::OKeyPair::returnKey()); * manager->load(); * * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&))); * * .... * * void update(){ * QDialog diag(true); * QHBoxLayout *lay = new QHBoxLayout(&diag); * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); * lay->addWidget(wid); * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){ * wid->save(); * } * } * * .... * MyListView::keyPressEvent( QKeyEvent* e ){ * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); * if(!item.isEmpty() ){ * switch(item.id()){ * case My_Delete_Key: * break; * } * } * } * * \endcode * * @param conf The Config where the KeySetting should be stored * @param group The group where the KeySetting will be stored * @param black Which keys shouldn't be allowed to handle * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons * @param par The parent/owner of this manager * @param name The name of this object */ OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, const QString& group, const OKeyPair::List& black, bool grabkeyboard, QObject* par, const char* name) : QObject( par, name ), m_conf( conf ), m_group( group ), m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ if ( m_grab ) QPEApplication::grabKeyboard(); } /** * Destructor */ OKeyConfigManager::~OKeyConfigManager() { if ( m_grab ) QPEApplication::ungrabKeyboard(); } /** * Load the Configuration from the OConfig * If a Key is restricted but was in the config we will * make it be the empty key paur - * We will change the group of the OConfig Item! + * We will change the group but restore to the previous. * * @see OKeyPair::emptyKey */ void OKeyConfigManager::load() { - m_conf->setGroup( m_group ); + Opie::Core::OConfigGroupSaver( m_conf, m_group ); /* * Read each item */ int key, mod; for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) { key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); OKeyPair okey( key, mod ); if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) (*it).setKeyPair( OKeyPair(key, mod) ); else (*it).setKeyPair( OKeyPair::emptyKey() ); } delete m_map; m_map = 0; } /** * We will save the current configuration - * to the OConfig. We will change the group. + * to the OConfig. We will change the group but restore + * to the previous */ void OKeyConfigManager::save() { - m_conf->setGroup( m_group ); + Opie::Core::OConfigGroupSaver( m_conf, m_group ); /* * Write each item */ for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) { /* skip empty items */ if ( (*it).isEmpty() ) continue; OKeyPair pair = (*it).keyPair(); OKeyPair deft = (*it).defaultKeyPair(); /* * don't write if it is the default setting * FIXME allow to remove Keys from config if ( (pair.keycode() == deft.keycode()) && (pair.modifier()== deft.modifier() ) ) return; */ m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); } } /** * This is function uses a QMap internally but you can have the same keycode * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem * with same keycode and modifier key. The GUI takes care that a user can't * cofigure two keys. * * Make sure you call e->ignore if you don't want to handle this event */ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { /* * Fix Up issues with Qt/E, my keybard, and virtual input * methods * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower * case ascii */ int key, mod; - Opie::Ui::Private::fixupKeys( key, mod, e ); + Opie::Ui::Internal::fixupKeys( key, mod, e ); OKeyConfigItem::List _keyList = keyList( key ); if ( _keyList.isEmpty() ) return OKeyConfigItem(); OKeyConfigItem item; for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); ++it ) { if ( (*it).keyPair().modifier() == mod ) { item = *it; break; } } return item; } /** * Return the associated id of the item or -1 if no item * matched the key * * @see handleKeyEvent */ int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { return handleKeyEvent( ev ).id(); } /** * Add Key Config to the List of items */ void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { m_keys.append( item ); delete m_map; m_map = 0; } /** * Remove the Key from the Config. Internal lists will be destroyed * and rebuild on demand later */ void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { m_keys.remove( item ); delete m_map; m_map = 0; } /** * Clears the complete list */ void OKeyConfigManager::clearKeyConfig() { m_keys.clear(); delete m_map; m_map = 0; } /** * */ Opie::Ui::OKeyConfigItem::List OKeyConfigManager::keyConfigList()const{ return m_keys; } /** * Add this OKeyPair to the blackList. * Internal lists will be destroyed */ void OKeyConfigManager::addToBlackList( const OKeyPair& key) { m_blackKeys.append( key ); delete m_map; m_map = 0; } /** * Remove this OKeyPair from the black List * Internal lists will be destroyed */ void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { m_blackKeys.remove( key ); delete m_map; m_map = 0; } /** * Clear the blackList */ void OKeyConfigManager::clearBlackList() { m_blackKeys.clear(); delete m_map; m_map = 0; } /** * Return a copy of the blackList */ OKeyPair::List OKeyConfigManager::blackList()const { return m_blackKeys; } /** * Ask the Manager to handle KeyEvents for you. * All handled keys will emit a QSignal and return true * that it handled the keyevent */ void OKeyConfigManager::handleWidget( QWidget* wid ) { wid->installEventFilter( this ); } /** * @internal */ bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { if ( !obj->isWidgetType() ) return false; if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease ) return false; QKeyEvent *key = static_cast<QKeyEvent*>( ev ); OKeyConfigItem item = handleKeyEvent( key ); if ( item.isEmpty() ) return false; QWidget *wid = static_cast<QWidget*>( obj ); if ( item.object() && !item.slot().isEmpty() ) { connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)), item.object(), item.slot().data() ); emit actionActivated(wid, key); disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)), item.object(), item.slot().data() ); } emit actionActivated( wid, key, item ); return true; } /** * @internal */ OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) { /* * Create the map if not existing anymore */ if ( !m_map ) { m_map = new OKeyMapConfigPrivate; /* for every key */ for ( OKeyConfigItem::List::Iterator it = m_keys.begin(); it!= m_keys.end(); ++it ) { bool add = true; /* see if this key is blocked */ OKeyPair pair = (*it).keyPair(); for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin(); pairIt != m_blackKeys.end(); ++pairIt ) { if ( (*pairIt).keycode() == pair.keycode() && (*pairIt).modifier() == pair.modifier() ) { add = false; break; } } /* check if we added it */ if ( add ) (*m_map)[pair.keycode()].append( *it ); } } return (*m_map)[keycode]; } namespace Opie { namespace Ui { -namespace Private { +namespace Internal { OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) : Opie::Ui::OListViewItem( parent ), m_manager( man ) { m_origItem = item; setItem( item ); } OKeyListViewItem::~OKeyListViewItem() {} OKeyConfigItem &OKeyListViewItem::item(){ return m_item; } OKeyConfigItem OKeyListViewItem::origItem() const{ return m_origItem; } OKeyConfigManager* OKeyListViewItem::manager() { return m_manager; } void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { m_item = item; setPixmap( 0, m_item.pixmap() ); setText ( 1, m_item.text() ); m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : setText( 2, keyToString( m_item.keyPair() ) ); m_item.defaultKeyPair().isEmpty() ? setText( 3, QObject::tr( "None" ) ) : setText ( 3, keyToString( m_item.defaultKeyPair() ) ); } void OKeyListViewItem::updateText() { m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : setText( 2, keyToString( m_item.keyPair() ) ); } QString keyToString( const OKeyPair& pair ) { int mod = 0; if ( pair.modifier() & Qt::ShiftButton ) mod |= Qt::SHIFT; if ( pair.modifier() & Qt::ControlButton ) mod |= Qt::CTRL; if ( pair.modifier() & Qt::AltButton ) mod |= Qt::ALT; return QAccel::keyToString( mod + pair.keycode() ); } /* * the virtual and hardware key events have both issues... */ void fixupKeys( int& key, int &mod, QKeyEvent* e ) { key = e->key(); mod = e->state(); /* * virtual keyboard * else change the button mod only */ if ( key == 0 ) { key = e->ascii(); if ( key > 96 && key < 123) key -= 32; }else{ int new_mod = 0; if ( mod & 256 ) new_mod |= Qt::ShiftButton; else if ( mod & 512 ) new_mod |= Qt::ControlButton; else if ( mod & 1024 ) new_mod |= Qt::AltButton; mod = new_mod == 0? mod : new_mod; } } struct OKeyConfigWidgetPrivate{ OKeyConfigWidgetPrivate(const QString& = QString::null, OKeyConfigManager* = 0); bool operator==( const OKeyConfigWidgetPrivate& ); QString name; OKeyConfigManager *manager; }; OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, OKeyConfigManager* man ) : name( _name ), manager( man ){} bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { if ( manager != item.manager) return false; if ( name != item.name ) return false; return true; } } } } //////////////////////// @@ -845,403 +846,403 @@ OKeyConfigWidget::~OKeyConfigWidget() { */ void OKeyConfigWidget::initUi() { QBoxLayout *layout = new QVBoxLayout( this ); QGridLayout *gridLay = new QGridLayout( 2, 2 ); layout->addLayout( gridLay, 10 ); gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth /* * LISTVIEW with the Keys */ m_view = new Opie::Ui::OListView( this ); m_view->setFocus(); m_view->setAllColumnsShowFocus( true ); m_view->addColumn( tr("Pixmap") ); m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); m_view->addColumn( tr("Key" ) ); m_view->addColumn( tr("Default Key" ) ); m_view->setRootIsDecorated( true ); connect(m_view, SIGNAL(currentChanged(QListViewItem*)), this, SLOT(slotListViewItem(QListViewItem*)) ); gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); /* * GROUP with button info */ QGroupBox *box = new QGroupBox( this ); box ->setTitle( tr("Shortcut for Selected Action") ); box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); layout->addWidget( box, 1 ); gridLay = new QGridLayout( box, 3, 4 ); gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); gridLay->setMargin( 4 ); QButtonGroup *gr = new QButtonGroup( box ); gr->hide(); gr->setExclusive( true ); QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); connect( rad, SIGNAL(clicked()), this, SLOT(slotNoKey()) ); gr->insert( rad, 10 ); gridLay->addWidget( rad, 1, 0 ); m_none = rad; rad = new QRadioButton( tr("&Default" ), box ); connect( rad, SIGNAL(clicked()), this, SLOT(slotDefaultKey()) ); gr->insert( rad, 11 ); gridLay->addWidget( rad, 1, 1 ); m_def = rad; rad = new QRadioButton( tr("C&ustom"), box ); connect( rad, SIGNAL(clicked()), this, SLOT(slotCustomKey()) ); gr->insert( rad, 12 ); gridLay->addWidget( rad, 1, 2 ); m_cus = rad; m_btn = new QPushButton( tr("Configure Key"), box ); gridLay->addWidget( m_btn, 1, 4 ); m_lbl= new QLabel( tr( "Default: " ), box ); gridLay->addWidget( m_lbl, 2, 0 ); connect(m_btn, SIGNAL(clicked()), this, SLOT(slotConfigure())); m_box = box; } /** * Set the ChangeMode. * You need to call this function prior to load * If you call this function past load the behaviour is undefined * But caling load again is safe */ void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { m_mode = mode; } /** * return the current mode */ OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { return m_mode; } /** * insert these items before calling load */ void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { - Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, man ); + Opie::Ui::Internal::OKeyConfigWidgetPrivate root( str, man ); m_list.append(root); } /** * loads the items and allows editing them */ void OKeyConfigWidget::load() { - Opie::Ui::Private::OKeyConfigWidgetPrivateList::Iterator it; + Opie::Ui::Internal::OKeyConfigWidgetPrivateList::Iterator it; for ( it = m_list.begin(); it != m_list.end(); ++it ) { OListViewItem *item = new OListViewItem( m_view, (*it).name ); OKeyConfigItem::List list = (*it).manager->keyConfigList(); for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt ) - (void )new Opie::Ui::Private::OKeyListViewItem(*keyIt, (*it).manager, item ); + (void )new Opie::Ui::Internal::OKeyListViewItem(*keyIt, (*it).manager, item ); } } /** * Saves if in Queue Mode. It'll update the supplied * OKeyConfigManager objects. * If in Queue mode it'll just return */ void OKeyConfigWidget::save() { /* * Iterate over all config items */ QListViewItemIterator it( m_view ); while ( it.current() ) { if (it.current()->parent() ) { - Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( it.current() ); + Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( it.current() ); OKeyConfigManager *man = item->manager(); man->removeKeyConfig( item->origItem() ); man->addKeyConfig( item->item() ); } ++it; } } /** * @internal */ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { if ( !_item || !_item->parent() ) { m_box->setEnabled( false ); m_none->setChecked( true ); m_btn ->setEnabled( false ); m_def ->setChecked( false ); m_cus ->setChecked( false ); }else{ m_box->setEnabled( true ); - Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); + Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( _item ); OKeyConfigItem keyItem= item->item(); m_lbl->setText( tr("Default: " )+ item->text( 3 ) ); if ( keyItem.keyPair().isEmpty() ) { m_none->setChecked( true ); m_btn ->setEnabled( false ); m_def ->setChecked( false ); m_cus ->setChecked( false ); }else { m_none->setChecked( false ); m_cus ->setChecked( true ); m_btn ->setEnabled( true ); m_def ->setChecked( false ); } } } void OKeyConfigWidget::slotNoKey() { m_none->setChecked( true ); m_cus ->setChecked( false ); m_btn ->setEnabled( false ); m_def ->setChecked( false ); if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) return; /* * If immediate we need to remove and readd the key */ - Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); + Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem()); updateItem( item, OKeyPair::emptyKey() ); } void OKeyConfigWidget::slotDefaultKey() { m_none->setChecked( false ); m_cus ->setChecked( false ); m_btn ->setEnabled( false ); m_def ->setChecked( true ); if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) return; - Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); + Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem()); updateItem( item, item->item().defaultKeyPair() ); } void OKeyConfigWidget::slotCustomKey() { m_cus ->setChecked( true ); m_btn ->setEnabled( true ); m_def ->setChecked( false ); m_none->setChecked( false ); if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) return; } void OKeyConfigWidget::slotConfigure() { if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) return; /* FIXME make use of OModalHelper */ OKeyChooserConfigDialog dlg( this, "Dialog Name", true ); dlg.setCaption(tr("Configure Key")); connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) ); if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { - Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); + Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem()); updateItem( item, dlg.keyPair() ); } } -bool OKeyConfigWidget::sanityCheck( Opie::Ui::Private::OKeyListViewItem* item, +bool OKeyConfigWidget::sanityCheck( Opie::Ui::Internal::OKeyListViewItem* item, const OKeyPair& newItem ) { OKeyPair::List bList = item->manager()->blackList(); for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) { /* black list matched */ if ( *it == newItem ) { QMessageBox::warning( 0, tr("Key is on BlackList" ), tr("<qt>The Key you choose is on the black list " "and may not be used with this manager. Please " "use a different key.</qt>" ) ); return false; } } /* no we need to check the other items which is dog slow */ QListViewItemIterator it( item->parent() ); while ( it.current() ) { /* if not our parent and not us */ if (it.current()->parent() && it.current() != item) { /* damn already given away*/ - if ( newItem == static_cast<Opie::Ui::Private::OKeyListViewItem*>(it.current() )->item().keyPair() ) { + if ( newItem == static_cast<Opie::Ui::Internal::OKeyListViewItem*>(it.current() )->item().keyPair() ) { QMessageBox::warning( 0, tr("Key is already assigned" ), tr("<qt>The Key you choose is already taken by " "a different Item of your config. Please try" "using a different key.</qt>" ) ); return false; } } ++it; } return true; } -void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item, +void OKeyConfigWidget::updateItem( Opie::Ui::Internal::OKeyListViewItem *item, const OKeyPair& newItem) { /* sanity check * check against the blacklist of the manager * check if another item uses this key which is o(n) at least */ if ( !newItem.isEmpty() && !sanityCheck(item, newItem )) return; /* * If immediate we need to remove and readd the key */ if ( m_mode == Imediate ) item->manager()->removeKeyConfig( item->item() ); item->item().setKeyPair( newItem ); item->updateText(); if ( m_mode == Imediate ) item->manager()->addKeyConfig( item->item() ); } ///// OKeyChooserConfigDialog::OKeyChooserConfigDialog( QWidget* par, const char* nam, bool mod, WFlags fl ) : QDialog( par, nam, mod, fl ), m_virtKey( false ), m_keyPair( OKeyPair::emptyKey() ) , m_key( 0 ), m_mod( 0 ) { setFocusPolicy( StrongFocus ); QHBoxLayout *lay = new QHBoxLayout( this ); QLabel *lbl = new QLabel( tr("Configure Key" ), this ); lay->addWidget( lbl ); lbl->setFocusPolicy( NoFocus ); m_lbl = new QLabel( this ); lay->addWidget( m_lbl ); m_lbl->setFocusPolicy( NoFocus ); m_timer = new QTimer( this ); connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeUp()) ); } OKeyChooserConfigDialog::~OKeyChooserConfigDialog() { } Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{ return m_keyPair; } void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) { QDialog::keyPressEvent( ev ); if ( ev->isAutoRepeat() ) return; int mod, key; - Opie::Ui::Private::fixupKeys( key,mod, ev ); + Opie::Ui::Internal::fixupKeys( key,mod, ev ); /* either we used software keyboard * or we've true support */ if ( !m_virtKey && !ev->key()) { m_virtKey = true; m_keyPair = OKeyPair( key, mod ); }else{ mod = 0; switch( key ) { case Qt::Key_Control: mod = Qt::ControlButton; break; case Qt::Key_Shift: mod = Qt::ShiftButton; break; case Qt::Key_Alt: mod = Qt::AltButton; break; default: break; } if (mod ) { m_mod |= mod; key = 0; }else m_key = key; if ( ( !mod || m_key || key ) && !m_timer->isActive() ) m_timer->start( 150, true ); m_keyPair = OKeyPair( m_key, m_mod ); } - m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); + m_lbl->setText( Opie::Ui::Internal::keyToString( m_keyPair ) ); } void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) { m_timer->stop(); QDialog::keyPressEvent( ev ); if ( ev->isAutoRepeat() ) return; if ( m_virtKey && !ev->key()) { m_virtKey = false; slotTimeUp(); }else { int mod = 0; int key = ev->key(); switch( key ) { case Qt::Key_Control: mod = Qt::ControlButton; break; case Qt::Key_Shift: mod = Qt::ShiftButton; break; case Qt::Key_Alt: mod = Qt::AltButton; break; default: break; } if (mod ) m_mod &= ~mod; else m_key = key; m_keyPair = OKeyPair( m_key, m_mod ); - m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); + m_lbl->setText( Opie::Ui::Internal::keyToString( m_keyPair ) ); } } void OKeyChooserConfigDialog::slotTimeUp() { m_mod = m_key = 0; QTimer::singleShot(0, this, SIGNAL(keyCaptured()) ); } diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h index f75ed99..bb8eb6c 100644 --- a/libopie2/opieui/okeyconfigwidget.h +++ b/libopie2/opieui/okeyconfigwidget.h @@ -1,124 +1,124 @@ /* * Copyright (C) 2004 * LGPL v2 zecke@handhelds.org */ #ifndef ODP_KEY_CONFIG_WIDGET_H #define ODP_KEY_CONFIG_WIDGET_H #include <opie2/oconfig.h> #include <opie2/odevice.h> #include <qstring.h> #include <qpixmap.h> #include <qcstring.h> #include <qhbox.h> #include <qvaluelist.h> class QKeyEvent; class QLabel; class QPushButton; class QListViewItem; class QRadioButton; class QTimer; namespace Opie { namespace Ui { -namespace Private { +namespace Internal { class OKeyConfigWidgetPrivate; typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList; class OKeyListViewItem; } class OListViewItem; class OListView; /** * \brief small class representing a Key with possible modifiers * This class holds information about key code and possible * modifier state. That is the lowest level of the key input * functions. * There are also static methods to get special keys. * OKeyPair will be used with \see OKeyConfigItem * * @since 1.2 */ class OKeyPair { public: typedef QValueList<OKeyPair> List; OKeyPair( int key = -1, int modifier = -1); ~OKeyPair(); bool operator==( const OKeyPair& )const; bool operator!=( const OKeyPair& )const; bool isEmpty()const; int keycode()const; int modifier()const; void setKeycode( int ); void setModifier( int ); static OKeyPair returnKey(); static OKeyPair leftArrowKey(); static OKeyPair rightArrowKey(); static OKeyPair upArrowKey(); static OKeyPair downArrowKey(); static OKeyPair emptyKey(); static OKeyPair::List hardwareKeys(); private: int m_key; int m_mod; class Private; Private* d; }; /** * A class to represent an OKeyPair. * It consists out of a Text exposed to the user, Config Key Item, * Pixmap, A default OKeyPair and the set OKeyPair. * You can also pass an id to it * * @since 1.1.2 */ class OKeyConfigItem { friend class OKeyConfigManager; public: typedef QValueList<OKeyConfigItem> List; OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), const QPixmap& symbol = QPixmap(), int id = -1, const OKeyPair& def = OKeyPair::emptyKey(), QObject *caller = 0, const char* slot = 0); OKeyConfigItem( const Opie::Core::ODeviceButton& ); ~OKeyConfigItem(); bool operator==( const OKeyConfigItem& )const; bool operator!=( const OKeyConfigItem& )const; QString text()const; QPixmap pixmap()const; int id()const; OKeyPair keyPair()const; OKeyPair defaultKeyPair()const; QCString configKey()const; void setText( const QString& text ); void setPixmap( const QPixmap& ); void setKeyPair( const OKeyPair& ); void setDefaultKeyPair( const OKeyPair& ); bool isEmpty()const; protected: QObject *object()const; QCString slot()const; void setId( int id ); void setConfigKey( const QCString& ); @@ -160,163 +160,163 @@ public: OKeyConfigManager(Opie::Core::OConfig *conf = 0, const QString& group = QString::null, const OKeyPair::List &block = OKeyPair::List(), bool grabkeyboard = false, QObject * par = 0, const char* name = 0 ); ~OKeyConfigManager(); void load(); void save(); OKeyConfigItem handleKeyEvent( QKeyEvent* ); int handleKeyEventId( QKeyEvent* ); void addKeyConfig( const OKeyConfigItem& ); void removeKeyConfig( const OKeyConfigItem& ); void clearKeyConfig(); void addToBlackList( const OKeyPair& ); void removeFromBlackList( const OKeyPair& ); void clearBlackList(); OKeyPair::List blackList()const; void handleWidget( QWidget* ); bool eventFilter( QObject*, QEvent* ); OKeyConfigItem::List keyConfigList()const; signals: /** * The Signals are triggered on KeyPress and KeyRelease! * You can check the isDown of the QKeyEvent * @see QKeyEvent */ void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); /** * This Signal correspondents to the OKeyConfigItem slot * and object * * @see OKeyConfigItem::slot * @see OKeyConfigItem::object */ void actionActivated( QWidget* par, QKeyEvent* key); private: OKeyConfigItem::List keyList( int ); OKeyConfigItem::List m_keys; QValueList<QWidget*> m_widgets; Opie::Core::OConfig *m_conf; QString m_group; OKeyPair::List m_blackKeys; bool m_grab : 1; OKeyMapConfigPrivate *m_map; class Private; Private *d; }; /** * With this Widget you can let the Keyboard Shortcuts * be configured by the user. * There are two ways you can use this widget. Either in a tab were * all changes are immediately getting into effect or in a queue * were you ask for saving. Save won't write the data but only set * it to the OKeyConfigManager * * @since 1.2 */ class OKeyConfigWidget : public QWidget { Q_OBJECT public: /** * Immediate Apply the change directly to the underlying OKeyConfigManager * Queue Save all items and then apply when you save() */ enum ChangeMode { Imediate, Queue }; OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~OKeyConfigWidget(); void setChangeMode( enum ChangeMode ); ChangeMode changeMode()const; void insert( const QString& name, OKeyConfigManager* ); void load(); void save(); private slots: void slotListViewItem( QListViewItem* ); void slotNoKey(); void slotDefaultKey(); void slotCustomKey(); void slotConfigure(); private: - static bool sanityCheck( Opie::Ui::Private::OKeyListViewItem* man, + static bool sanityCheck( Opie::Ui::Internal::OKeyListViewItem* man, const OKeyPair& newItem ); - void updateItem( Opie::Ui::Private::OKeyListViewItem* man, + void updateItem( Opie::Ui::Internal::OKeyListViewItem* man, const OKeyPair& newItem); void initUi(); Opie::Ui::OListView *m_view; - Opie::Ui::Private::OKeyConfigWidgetPrivateList m_list; + Opie::Ui::Internal::OKeyConfigWidgetPrivateList m_list; QLabel *m_lbl; QPushButton *m_btn; QRadioButton *m_def, *m_cus, *m_none; QWidget* m_box; ChangeMode m_mode; class Private; Private *d; }; /** * This is a small dialog that allows you to * capture a key sequence. * If you want it to close after a key was captured you * can use this code snippet. * * \code * OKeyChooserConfigDialog diag(0,0,true); * connect(&diag,SIGNAL(keyCaptured()), * this,SLOT(accept())); * if( QPEApplication::execDialog(&diag) == QDialog::Accept ){ * take_the_key_and_do_something * } * * \endcode * */ class OKeyChooserConfigDialog : public QDialog { Q_OBJECT public: OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); ~OKeyChooserConfigDialog(); OKeyPair keyPair()const; protected: void keyPressEvent( QKeyEvent* ); void keyReleaseEvent( QKeyEvent* ); signals: void keyCaptured(); private slots: void slotTimeUp(); private: QTimer *m_timer; QLabel *m_lbl; bool m_virtKey : 1; OKeyPair m_keyPair; int m_key, m_mod; class Private; Private *d; }; } } #endif diff --git a/libopie2/opieui/okeyconfigwidget_p.h b/libopie2/opieui/okeyconfigwidget_p.h index e7eaba6..7690846 100644 --- a/libopie2/opieui/okeyconfigwidget_p.h +++ b/libopie2/opieui/okeyconfigwidget_p.h @@ -1,33 +1,33 @@ /* * Only Internal implemented in the same .cpp file anyway */ #include <opie2/olistview.h> namespace Opie { namespace Ui { -namespace Private { +namespace Internal { static QString keyToString( const OKeyPair& ); static void fixupKeys( int&, int&, QKeyEvent* ); class OKeyListViewItem : public Opie::Ui::OListViewItem { public: OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); ~OKeyListViewItem(); void setDefault(); OKeyConfigItem& item(); OKeyConfigItem origItem()const; void setItem( const OKeyConfigItem& item ); void updateText(); OKeyConfigManager *manager(); private: OKeyConfigItem m_item; OKeyConfigItem m_origItem; OKeyConfigManager* m_manager; }; } } } diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h index 0c85ee7..ec7b9c4 100644 --- a/libopie2/opieui/otaskbarapplet.h +++ b/libopie2/opieui/otaskbarapplet.h @@ -1,129 +1,129 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library 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 program 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTASKBARAPPLET_H #define OTASKBARAPPLET_H #include <qpe/taskbarappletinterface.h> #include <qpe/qcom.h> #include <qwidget.h> class QMouseEvent; namespace Opie { namespace Ui { -namespace Private { +namespace Internal { /*====================================================================================== * OTaskbarAppletWrapper *======================================================================================*/ class OTaskbarAppletWrapperPrivate; template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface { public: OTaskbarAppletWrapper():_applet( 0 ) { } virtual ~OTaskbarAppletWrapper() { delete _applet; } QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) { qDebug( "OTaskbarAppletWrapper::queryInterface()" ); *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_TaskbarApplet ) *iface = this; else return QS_FALSE; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT virtual T* applet( QWidget* parent ) { if ( !_applet ) _applet = new T( parent ); return _applet; } virtual int position() const { return T::position(); } private: T* _applet; OTaskbarAppletWrapperPrivate *d; }; } /*====================================================================================== * OTaskbarApplet *======================================================================================*/ // Must be inline until after we shipped Opie 1.0 // Having OTaskBarApplet reside in libopieui2 is not possible // until we link the launcher binary against libopieui2 - // otherwise the necessary symbols are not present, when // the dynamic loader [dlopen] tries to resolve an applet which // inherits OTaskbarApplet class OTaskbarApplet : public QWidget { public: OTaskbarApplet( QWidget* parent, const char* name = 0 ); virtual ~OTaskbarApplet(); protected: virtual void popup( QWidget* widget ); private: class Private; Private *d; }; } } #define EXPORT_OPIE_APPLET_v1( AppLet ) \ Q_EXPORT_INTERFACE() { \ - Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<AppLet> ) \ + Q_CREATE_INSTANCE( Opie::Ui::Internal::OTaskbarAppletWrapper<AppLet> ) \ } #endif |