summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-01 18:55:39 (UTC)
committer mickeyl <mickeyl>2003-05-01 18:55:39 (UTC)
commit8266da96576ad43a768da37000cef4e8eba000ac (patch) (unidiff)
tree904f07a06eb9e18e650c123bad8e901a5da56bf1
parent95e533a6ac257d3b95cd8905660008fb7dcd33f1 (diff)
downloadopie-8266da96576ad43a768da37000cef4e8eba000ac.zip
opie-8266da96576ad43a768da37000cef4e8eba000ac.tar.gz
opie-8266da96576ad43a768da37000cef4e8eba000ac.tar.bz2
remove stupid approach to encapsulate X11/Embedded differences into OApplication
thanks to zecke reminding me (once again) that moc does not preprocess... if I ever forget it again, I owe you a beer :-)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oapplication.cpp13
-rw-r--r--libopie2/opiecore/oapplication.h116
2 files changed, 43 insertions, 86 deletions
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index ce26420..7a6c174 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -29,96 +29,85 @@
29*/ 29*/
30 30
31#include <opie2/oapplication.h> 31#include <opie2/oapplication.h>
32#include <opie2/oconfig.h> 32#include <opie2/oconfig.h>
33 33
34OApplication* OApplication::_instance = 0; 34OApplication* OApplication::_instance = 0;
35 35
36/**************************************************************************************************/ 36/**************************************************************************************************/
37/* OApplicationPrivate 37/* OApplicationPrivate
38/**************************************************************************************************/ 38/**************************************************************************************************/
39 39
40class OApplicationPrivate 40class OApplicationPrivate
41{ 41{
42 public: 42 public:
43 OApplicationPrivate() {}; 43 OApplicationPrivate() {};
44 ~OApplicationPrivate() {}; 44 ~OApplicationPrivate() {};
45}; 45};
46 46
47/**************************************************************************************************/ 47/**************************************************************************************************/
48/* OApplication 48/* OApplication
49/**************************************************************************************************/ 49/**************************************************************************************************/
50 50
51 51
52OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) 52OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
53 :OApplicationBaseClass( argc, argv ), 53 :QPEApplication( argc, argv ),
54 _appname( rAppName ), 54 _appname( rAppName ),
55 _config( 0 ) 55 _config( 0 )
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60 60
61OApplication::~OApplication() 61OApplication::~OApplication()
62{ 62{
63 delete d; 63 delete d;
64 if ( _config ) 64 if ( _config )
65 delete _config; 65 delete _config;
66 OApplication::_instance = 0; 66 OApplication::_instance = 0;
67 // after deconstruction of the one-and-only application object, 67 // after deconstruction of the one-and-only application object,
68 // the construction of another object is allowed 68 // the construction of another object is allowed
69} 69}
70 70
71 71
72OConfig* OApplication::config() 72OConfig* OApplication::config()
73{ 73{
74 if ( !_config ) 74 if ( !_config )
75 { 75 {
76 _config = new OConfig( _appname ); 76 _config = new OConfig( _appname );
77 } 77 }
78 return _config; 78 return _config;
79} 79}
80 80
81 81
82void OApplication::init() 82void OApplication::init()
83{ 83{
84 d = new OApplicationPrivate(); 84 d = new OApplicationPrivate();
85 if ( !OApplication::_instance ) 85 if ( !OApplication::_instance )
86 { 86 {
87 OApplication::_instance = this; 87 OApplication::_instance = this;
88 } 88 }
89 else 89 else
90 { 90 {
91 qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); 91 qFatal( "OApplication: Can't create more than one OApplication object. Aborting." );
92 } 92 }
93} 93}
94 94
95 95
96void OApplication::setMainWidget( QWidget* widget )
97{
98 showMainWidget( widget );
99}
100
101
102void OApplication::showMainWidget( QWidget* widget, bool nomax ) 96void OApplication::showMainWidget( QWidget* widget, bool nomax )
103{ 97{
104 #ifdef Q_WS_QWS
105 QPEApplication::showMainWidget( widget, nomax ); 98 QPEApplication::showMainWidget( widget, nomax );
106 #else
107 QApplication::setMainWidget( widget );
108 widget->show();
109 #endif
110 widget->setCaption( _appname ); 99 widget->setCaption( _appname );
111} 100}
112 101
113 102
114void OApplication::setTitle( const QString& title ) const 103void OApplication::setTitle( const QString& title ) const
115{ 104{
116 if ( mainWidget() ) 105 if ( mainWidget() )
117 { 106 {
118 if ( !title.isNull() ) 107 if ( !title.isNull() )
119 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); 108 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
120 else 109 else
121 mainWidget()->setCaption( _appname ); 110 mainWidget()->setCaption( _appname );
122 } 111 }
123} 112}
124 113
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index 8326847..94ac488 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -12,123 +12,91 @@
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#ifndef OAPPLICATION_H 31#ifndef OAPPLICATION_H
32#define OAPPLICATION_H 32#define OAPPLICATION_H
33 33
34#define oApp OApplication::oApplication() 34#define oApp OApplication::oApplication()
35 35
36// the below stuff will fail with moc because moc does not pre process headers 36#include <qpe/qpeapplication.h>
37// This will make usage of signal and slots hard inside QPEApplication -zecke
38
39#ifdef QWS
40 #include <qpe/qpeapplication.h>
41 #define OApplicationBaseClass QPEApplication
42#else
43 #include <qapplication.h>
44 #define OApplicationBaseClass QApplication
45#endif
46 37
47class OApplicationPrivate; 38class OApplicationPrivate;
48class OConfig; 39class OConfig;
49 40
50class OApplication: public OApplicationBaseClass 41class OApplication: public QPEApplication
51{ 42{
52// Q_OBJECT would fail -zecke 43 Q_OBJECT
44
53 public: 45 public:
54 46 /**
55 /** 47 * Constructor. Parses command-line arguments and sets the window caption.
56 * Constructor. Parses command-line arguments and sets the window caption. 48 *
57 * 49 * @param rAppName application name. Will be used for finding the
58 * @param rAppName application name. Will be used for finding the 50 * associated message, icon and configuration files
59 * associated message, icon and configuration files 51 *
60 * 52 */
61 */
62 OApplication( int& argc, char** argv, const QCString& rAppName ); 53 OApplication( int& argc, char** argv, const QCString& rAppName );
63 /** 54 /**
64 * Destructor. Destroys the application object and its children. 55 * Destructor. Destroys the application object and its children.
65 */ 56 */
66 virtual ~OApplication(); 57 virtual ~OApplication();
67 58 /**
68 /** 59 * @returns the process-wide application object
69 * Returns the current application object. 60 *
70 * 61 * This is similar to the global @ref QApplication pointer qApp. It
71 * This is similar to the global @ref QApplication pointer qApp. It 62 * allows access to the single global OApplication object, since
72 * allows access to the single global OApplication object, since 63 * more than one cannot be created in the same application. It
73 * more than one cannot be created in the same application. It 64 * saves you the trouble of having to pass the pointer explicitly
74 * saves you the trouble of having to pass the pointer explicitly 65 * to every function that may require it.
75 * to every function that may require it. 66 */
76 *
77 * @return the current application object
78 */
79 static const OApplication* oApplication() { return _instance; }; 67 static const OApplication* oApplication() { return _instance; };
80 68 /**
81 /** 69 * Returns the application name as given during creation.
82 * Returns the application name as given during creation. 70 *
83 * 71 * @returns a reference to the application name
84 * @return A reference to the application name 72 */
85 */
86 const QCString& appName() const { return _appname; }; 73 const QCString& appName() const { return _appname; };
87 74 /**
88 /** 75 * @returns the application session config object.
89 * Returns the application session config object. 76 *
90 * 77 * @see OConfig
91 * @return A pointer to the application's instance specific 78 */
92 * @ref OConfig object.
93 * @see OConfig
94 */
95 OConfig* config(); 79 OConfig* config();
96 80 /**
97 /** 81 * Shows the main @a widget and sets the name of the application as window caption.
98 * Sets the main widget - reimplemented to call showMainWidget() 82 */
99 * on Qt/Embedded.
100 *
101 * @param mainWidget the widget to become the main widget
102 * @see QWidget object
103 */
104 virtual void setMainWidget( QWidget *mainWidget );
105
106 /**
107 * Shows the main widget - reimplemented to call setMainWidget()
108 * on platforms other than Qt/Embedded.
109 *
110 * @param mainWidget the widget to become the main widget
111 * @see QWidget object
112 */
113 virtual void showMainWidget( QWidget* widget, bool nomax = false ); 83 virtual void showMainWidget( QWidget* widget, bool nomax = false );
114 84 /**
115 /** 85 * Set the application title. The application title will be concatenated
116 * Set the application title. The application title will be concatenated 86 * to the application name given in the constructor.
117 * to the application name given in the constructor. 87 *
118 * 88 * @param title the title. If not given, resets caption to appname
119 * @param title the title. If not given, resets caption to appname 89 */
120 */
121 virtual void setTitle( const QString& title = QString::null ) const; 90 virtual void setTitle( const QString& title = QString::null ) const;
122 //virtual void setTitle() const;
123 91
124 protected: 92 protected:
125 void init(); 93 void init();
126 94
127 private: 95 private:
128 const QCString _appname; 96 const QCString _appname;
129 static OApplication* _instance; 97 static OApplication* _instance;
130 OConfig* _config; 98 OConfig* _config;
131 OApplicationPrivate* d; 99 OApplicationPrivate* d;
132}; 100};
133 101
134#endif // OAPPLICATION_H 102#endif // OAPPLICATION_H