summaryrefslogtreecommitdiff
path: root/noncore/apps/odict
Unidiff
Diffstat (limited to 'noncore/apps/odict') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/odict/main.cpp11
-rw-r--r--noncore/apps/odict/odict.cpp34
-rw-r--r--noncore/apps/odict/odict.h4
-rw-r--r--noncore/apps/odict/odict.pro5
4 files changed, 23 insertions, 31 deletions
diff --git a/noncore/apps/odict/main.cpp b/noncore/apps/odict/main.cpp
index c68253f..0642022 100644
--- a/noncore/apps/odict/main.cpp
+++ b/noncore/apps/odict/main.cpp
@@ -8,22 +8,17 @@
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17 17
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <opie/oapplicationfactory.h>
20#include "odict.h" 21#include "odict.h"
21 22
22int main(int argc, char **argv) 23
23{ 24OPIE_EXPORT_APP( OApplicationFactory<ODict> )
24 QPEApplication app(argc, argv);
25 ODict *odict= new ODict();
26 app.setMainWidget(odict);
27 odict->showMaximized();
28 return app.exec();
29}
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 010545e..9718c5c 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -27,68 +27,68 @@
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qmainwindow.h> 30#include <qmainwindow.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qaction.h> 32#include <qaction.h>
33#include <qtextbrowser.h> 33#include <qtextbrowser.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35 35
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39ODict::ODict() : QMainWindow() 39ODict::ODict(QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl )
40{ 40{
41 activated_name = QString::null; 41 activated_name = QString::null;
42 42
43 vbox = new QVBox( this ); 43 vbox = new QVBox( this );
44 setCaption( tr( "Opie-Dictionary" ) ); 44 setCaption( tr( "Opie-Dictionary" ) );
45 setupMenus(); 45 setupMenus();
46 46
47 QHBox *hbox = new QHBox( vbox ); 47 QHBox *hbox = new QHBox( vbox );
48 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox ); 48 QLabel* query_label = new QLabel( tr( "Query:" ) , hbox );
49 query_label->show(); 49 query_label->show();
50 query_le = new QLineEdit( hbox ); 50 query_le = new QLineEdit( hbox );
51 query_co = new QComboBox( hbox ); 51 query_co = new QComboBox( hbox );
52 connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) ); 52 connect( query_co , SIGNAL( activated(const QString&) ), this, SLOT( slotMethodChanged(const QString&) ) );
53 ok_button = new QPushButton( tr( "&Ok" ), hbox ); 53 ok_button = new QPushButton( tr( "&Ok" ), hbox );
54 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) ); 54 connect( ok_button, SIGNAL( released() ), this, SLOT( slotStartQuery() ) );
55 55
56 top_name = new QLabel( vbox ); 56 top_name = new QLabel( vbox );
57 top_name->setAlignment( AlignHCenter ); 57 top_name->setAlignment( AlignHCenter );
58 browser_top = new QTextBrowser( vbox ); 58 browser_top = new QTextBrowser( vbox );
59 bottom_name = new QLabel( vbox ); 59 bottom_name = new QLabel( vbox );
60 bottom_name->setAlignment( AlignHCenter ); 60 bottom_name->setAlignment( AlignHCenter );
61 browser_bottom = new QTextBrowser( vbox ); 61 browser_bottom = new QTextBrowser( vbox );
62 62
63 ding = new DingWidget(); 63 ding = new DingWidget();
64 64
65 loadConfig(); 65 loadConfig();
66 setCentralWidget( vbox ); 66 setCentralWidget( vbox );
67} 67}
68 68
69void ODict::loadConfig() 69void ODict::loadConfig()
70{ 70{
71 /* 71 /*
72 * the name of the last used dictionary 72 * the name of the last used dictionary
73 */ 73 */
74 QString lastname; 74 QString lastname;
75 75
76 Config cfg ( "odict" ); 76 Config cfg ( "odict" );
77 cfg.setGroup( "generalsettings" ); 77 cfg.setGroup( "generalsettings" );
78 casesens = cfg.readEntry( "casesens" ).toInt(); 78 casesens = cfg.readEntry( "casesens" ).toInt();
79 79
80 QString lastDict = cfg.readEntry( "lastdict" ); 80 QString lastDict = cfg.readEntry( "lastdict" );
81 int i = 0, e = 0; 81 int i = 0, e = 0;
82 82
83 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 83 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
84 query_co->clear(); 84 query_co->clear();
85 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 85 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
86 { 86 {
87 QString name; 87 QString name;
88 cfg.setGroup( *it ); 88 cfg.setGroup( *it );
89 name = cfg.readEntry( "Name" ); 89 name = cfg.readEntry( "Name" );
90 query_co->insertItem( name ); 90 query_co->insertItem( name );
91 91
92 /* 92 /*
93 * this check is to look up what dictionary has been used the 93 * this check is to look up what dictionary has been used the
94 * last time 94 * last time
@@ -108,65 +108,65 @@ void ODict::loadConfig()
108 ding->loadDict( lastname ); 108 ding->loadDict( lastname );
109 ding->loadValues(); 109 ding->loadValues();
110 110
111 query_co->setCurrentItem( e ); 111 query_co->setCurrentItem( e );
112 top_name->setText( top_name_content ); 112 top_name->setText( top_name_content );
113 bottom_name->setText( bottom_name_content ); 113 bottom_name->setText( bottom_name_content );
114} 114}
115 115
116void ODict::lookupLanguageNames( QString dictname ) 116void ODict::lookupLanguageNames( QString dictname )
117{ 117{
118 Config cfg ( "odict" ); 118 Config cfg ( "odict" );
119 cfg.setGroup( "Method_"+dictname ); 119 cfg.setGroup( "Method_"+dictname );
120 top_name_content = cfg.readEntry( "Lang1" ); 120 top_name_content = cfg.readEntry( "Lang1" );
121 bottom_name_content = cfg.readEntry( "Lang2" ); 121 bottom_name_content = cfg.readEntry( "Lang2" );
122} 122}
123 123
124void ODict::saveConfig() 124void ODict::saveConfig()
125{ 125{
126 Config cfg ( "odict" ); 126 Config cfg ( "odict" );
127 cfg.setGroup( "generalsettings" ); 127 cfg.setGroup( "generalsettings" );
128 cfg.writeEntry( "casesens" , casesens ); 128 cfg.writeEntry( "casesens" , casesens );
129 cfg.writeEntry( "lastdict" , query_co->currentText() ); 129 cfg.writeEntry( "lastdict" , query_co->currentText() );
130} 130}
131 131
132void ODict::slotStartQuery() 132void ODict::slotStartQuery()
133{ 133{
134 QString querystring = query_le->text(); 134 QString querystring = query_le->text();
135 if ( !querystring.isEmpty() ) 135 if ( !querystring.isEmpty() )
136 { 136 {
137 /* 137 /*
138 * if the user has not yet defined a dictionary 138 * if the user has not yet defined a dictionary
139 */ 139 */
140 if ( !query_co->currentText() ) 140 if ( !query_co->currentText() )
141 { 141 {
142 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), 142 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ),
143 tr( "No dictionary defined" ), 143 tr( "No dictionary defined" ),
144 tr( "&Define one" ), 144 tr( "&Define one" ),
145 tr( "&Cancel" ), 145 tr( "&Cancel" ),
146 0, // Define a dict 146 0, // Define a dict
147 1 ) ) // Cancel choosen 147 1 ) ) // Cancel choosen
148 { 148 {
149 case 0: 149 case 0:
150 slotSettings(); 150 slotSettings();
151 break; 151 break;
152 case 1: // stop here 152 case 1: // stop here
153 return; 153 return;
154 } 154 }
155 } 155 }
156 156
157 /* 157 /*
158 * ok, the user has defined a dict 158 * ok, the user has defined a dict
159 */ 159 */
160 ding->setCaseSensitive( casesens ); 160 ding->setCaseSensitive( casesens );
161 161
162 BroswerContent test = ding->setText( querystring ); 162 BroswerContent test = ding->setText( querystring );
163 163
164 browser_top->setText( test.top ); 164 browser_top->setText( test.top );
165 browser_bottom->setText( test.bottom ); 165 browser_bottom->setText( test.bottom );
166 } 166 }
167} 167}
168 168
169void ODict::slotSettings() 169void ODict::slotSettings()
170{ 170{
171 ConfigDlg dlg( this, "Config" , true); 171 ConfigDlg dlg( this, "Config" , true);
172 if ( dlg.exec() == QDialog::Accepted ) 172 if ( dlg.exec() == QDialog::Accepted )
@@ -180,41 +180,41 @@ void ODict::slotSetParameter( int count )
180 if ( casesens ) 180 if ( casesens )
181 casesens = false; 181 casesens = false;
182 else 182 else
183 casesens = true; 183 casesens = true;
184 } 184 }
185 185
186 saveConfig(); 186 saveConfig();
187} 187}
188 188
189void ODict::slotMethodChanged( const QString& methodnumber ) 189void ODict::slotMethodChanged( const QString& methodnumber )
190{ 190{
191 activated_name = methodnumber; 191 activated_name = methodnumber;
192 192
193 if ( activated_name != ding->loadedDict() ) 193 if ( activated_name != ding->loadedDict() )
194 { 194 {
195 ding->loadDict(activated_name); 195 ding->loadDict(activated_name);
196 196
197 lookupLanguageNames( activated_name ); 197 lookupLanguageNames( activated_name );
198 top_name->setText( top_name_content ); 198 top_name->setText( top_name_content );
199 bottom_name->setText( bottom_name_content ); 199 bottom_name->setText( bottom_name_content );
200 } 200 }
201} 201}
202 202
203void ODict::setupMenus() 203void ODict::setupMenus()
204{ 204{
205 menu = new QMenuBar( this ); 205 menu = new QMenuBar( this );
206 206
207 settings = new QPopupMenu( menu ); 207 settings = new QPopupMenu( menu );
208 setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 208 setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
209 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 209 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
210 setting_a->addTo( settings ); 210 setting_a->addTo( settings );
211 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); 211 setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 );
212 212
213 parameter = new QPopupMenu( menu ); 213 parameter = new QPopupMenu( menu );
214 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); 214 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) );
215 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); 215 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 );
216 parameter->insertSeparator(); 216 parameter->insertSeparator();
217 217
218 menu->insertItem( tr( "Settings" ) , settings ); 218 menu->insertItem( tr( "Settings" ) , settings );
219 menu->insertItem( tr( "Parameter" ) , parameter ); 219 menu->insertItem( tr( "Parameter" ) , parameter );
220} 220}
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h
index be2a532..68a8f95 100644
--- a/noncore/apps/odict/odict.h
+++ b/noncore/apps/odict/odict.h
@@ -20,30 +20,30 @@ class QAction;
20class QVBoxLayout; 20class QVBoxLayout;
21class QActionGroup; 21class QActionGroup;
22class DingWidget; 22class DingWidget;
23class QTextBrowser; 23class QTextBrowser;
24class QComboBox; 24class QComboBox;
25class DingWidget; 25class DingWidget;
26 26
27class ODict : public QMainWindow 27class ODict : public QMainWindow
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 30
31 public: 31 public:
32 ODict(); 32 ODict(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
33 QVBox *vbox; 33 QVBox *vbox;
34 QTextBrowser *browser_top, 34 QTextBrowser *browser_top,
35 *browser_bottom; 35 *browser_bottom;
36 DingWidget *ding; 36 DingWidget *ding;
37 37 static QString appName() { return QString::fromLatin1("odict"); }
38 private: 38 private:
39 QPopupMenu *help, *settings, *parameter; 39 QPopupMenu *help, *settings, *parameter;
40 QMenuBar *menu; 40 QMenuBar *menu;
41 QHBox *hbox; 41 QHBox *hbox;
42 QLineEdit *query_le; 42 QLineEdit *query_le;
43 QComboBox *query_co; 43 QComboBox *query_co;
44 QPushButton *ok_button; 44 QPushButton *ok_button;
45 45
46 QVBoxLayout *vbox_layout; 46 QVBoxLayout *vbox_layout;
47 47
48 QAction *setting_a, *setting_b; 48 QAction *setting_a, *setting_b;
49 49
diff --git a/noncore/apps/odict/odict.pro b/noncore/apps/odict/odict.pro
index 82f6a41..4ad287b 100644
--- a/noncore/apps/odict/odict.pro
+++ b/noncore/apps/odict/odict.pro
@@ -1,30 +1,27 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on debug
3 #CONFIG = qt warn_on release
4 HEADERS = odict.h \ 2 HEADERS = odict.h \
5 searchmethoddlg.h \ 3 searchmethoddlg.h \
6 configdlg.h \ 4 configdlg.h \
7 dingwidget.h 5 dingwidget.h
8 6
9 SOURCES = main.cpp \ 7 SOURCES = main.cpp \
10 odict.cpp \ 8 odict.cpp \
11 searchmethoddlg.cpp \ 9 searchmethoddlg.cpp \
12 configdlg.cpp \ 10 configdlg.cpp \
13 dingwidget.cpp 11 dingwidget.cpp
14INCLUDEPATH += $(OPIEDIR)/include 12INCLUDEPATH += $(OPIEDIR)/include
15DEPENDPATH += $(OPIEDIR)/include 13DEPENDPATH += $(OPIEDIR)/include
16 LIBS += -lqpe -lstdc++ -lopie 14 LIBS += -lqpe -lstdc++ -lopie
17 TARGET = odict 15 TARGET = odict
18 DESTDIR = $(OPIEDIR)/bin
19 16
20TRANSLATIONS = ../../../i18n/de/odict.ts \ 17TRANSLATIONS = ../../../i18n/de/odict.ts \
21 ../../../i18n/nl/odict.ts \ 18 ../../../i18n/nl/odict.ts \
22 ../../../i18n/xx/odict.ts \ 19 ../../../i18n/xx/odict.ts \
23 ../../../i18n/en/odict.ts \ 20 ../../../i18n/en/odict.ts \
24 ../../../i18n/es/odict.ts \ 21 ../../../i18n/es/odict.ts \
25 ../../../i18n/fr/odict.ts \ 22 ../../../i18n/fr/odict.ts \
26 ../../../i18n/hu/odict.ts \ 23 ../../../i18n/hu/odict.ts \
27 ../../../i18n/ja/odict.ts \ 24 ../../../i18n/ja/odict.ts \
28 ../../../i18n/ko/odict.ts \ 25 ../../../i18n/ko/odict.ts \
29 ../../../i18n/no/odict.ts \ 26 ../../../i18n/no/odict.ts \
30 ../../../i18n/pl/odict.ts \ 27 ../../../i18n/pl/odict.ts \