summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp328
1 files changed, 328 insertions, 0 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
new file mode 100644
index 0000000..c9149ac
--- a/dev/null
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
@@ -0,0 +1,328 @@
1/***************************************************************************
2 gutenbrowser.cpp - description
3 -------------------
4 begin : Mon Jul 24 22:33:12 MDT 2000
5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com
7***************************************************************************/
8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
14//#include "gutenbrowserData.h"
15#include "gutenbrowser.h"
16
17#include <qpe/config.h>
18#include <qpe/fontdatabase.h>
19#include <qpe/menubutton.h>
20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h>
22
23#include <qfontinfo.h>
24#include <qtoolbutton.h>
25
26void Gutenbrowser::initSlots() {
27
28 connect(LibraryButton,SIGNAL(released()),SLOT(LibraryBtn()));
29 connect(OpenButton,SIGNAL(released()),SLOT(OpenBtn()));
30 connect(SearchButton,SIGNAL(released()),SLOT(SearchBtn()));
31 connect(ForwardButton,SIGNAL(clicked()),SLOT(ForwardBtn()));
32 connect(BackButton,SIGNAL(clicked()),SLOT(BackBtn()));
33 connect(setBookmarkButton,SIGNAL(released()),SLOT(setBookmark()));
34 connect(dictionaryButton,SIGNAL(released()),SLOT(LookupBtn()));
35 connect(InfoBar,SIGNAL(clicked()),SLOT(InfoBarClick()));
36 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp()));
37 connect(mainList,SIGNAL(clicked(QListBoxItem *)),SLOT(listClickedSlot(QListBoxItem *)));
38 connect(bookmarksMenu,SIGNAL(activated(int)),SLOT(Bookmark(int)));
39}
40
41void Gutenbrowser::initConfig() {
42//qDebug("Starting configuration.");
43 QDir library(local_library);
44 if ( !library.exists()) {
45 library.mkdir(local_library, TRUE);
46 QString msg;
47// #ifndef Q_WS_WIN
48 msg = "chmod 755 " + local_library;
49 system(msg);
50// QDir pixdir(local_library+"pix");
51// if ( !pixdir.exists()) {
52// pixdir.mkdir(local_library+"pix", TRUE);
53// QString msg;
54// msg = "chmod 755 " + local_library+"pix";
55// system(msg);
56// }
57// #endif
58
59 }
60 // qDebug( "init file is %s",iniFile.latin1());
61
62#ifdef Q_WS_QWS
63 useSplitter=FALSE;
64 Config config("Gutenbrowser");
65
66 config.setGroup( "General" );
67//useWordWrap_CheckBox
68 useIcons=TRUE;
69#else
70
71 config.setGroup( "General" );
72 QString s_Split=config.readEntry("Splitter", "TRUE" );
73 QWidget *d = QApplication::desktop();
74 int width=d->width();
75 int height=d->height();
76 int w=0, h=0;
77 QString str, str2;
78
79 this->setMaximumWidth(width);
80
81 if(s_Split=="TRUE")
82 useSplitter=TRUE;
83 else
84 useSplitter=FALSE;
85
86 config.setGroup( "Geometry" );
87 if(width < 1030) {
88 str = config.readEntry("Frame", "700,500");
89 if( !str.isEmpty() && str.find(',')>=0) {
90 sscanf(str,"%d,%d",&w,&h);
91 resize(w,h);
92 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
93 str = config.readEntry( "Position", str2);
94 } else {
95 resize( 740,510 );
96 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
97 str = config.readEntry( "Position",str2);
98 }
99 } else {// desktop is high res
100 str = config.readEntry("Frame", "990,640");
101 if( !str.isEmpty() && str.find(',')>=0) {
102 sscanf(str,"%d,%d",&w,&h);
103 resize(w,h);
104 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
105 str = config.readEntry( "Position", str2);
106 } else {
107 resize( 990,640 );
108 str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
109 str = config.readEntry( "Position", str2);
110 }
111 }
112 int posX, posY;
113 bool ok;
114 QString goober;
115 goober=str.left( str.find(",", 0, TRUE) );
116 posX=goober.toInt( &ok, 10);
117 goober=str.right( str.findRev(",", -1, TRUE) );
118 posY= goober.toInt( &ok, 10);
119// move( posX, posY);
120 str = config.readEntry("Icons", "TRUE");
121 if(str == "TRUE")
122 useIcons=TRUE;
123 else
124 useIcons=FALSE;
125#endif
126// #if defined(_WS_WIN_)
127// move( posX-4, posY-20);
128// #endif
129
130 config.setGroup( "Browser" );
131 brow = config.readEntry( "Preferred", "Opera");
132 config.setGroup( "FTPsite" ); // ftp server config
133 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
134// ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
135 ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
136 ftp_host=ftp_host.stripWhiteSpace();
137
138 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
139
140 //bool ok2;
141 QString temp;
142 QString copying;
143 copying="";
144
145 config.setGroup("General");
146 QString qExit;
147 qExit=config.readEntry("queryExit","TRUE");
148 if(qExit=="TRUE") {
149 b_queryExit=TRUE;
150// qDebug("Please query before leaving the library.");
151 } else {
152// qDebug("Please DO NOT query before leaving the library.");
153 b_queryExit=FALSE;
154 }
155// bookmarks
156// config.setGroup("Titles");
157// QString tmpTitle=config.readEntry(file_name,"");
158
159
160}// end initConfig()
161
162void Gutenbrowser::initMenuBar()
163{
164// qDebug("Starting menu init.");
165 // menuBar entry fileMenu
166 menubar = new QPEMenuBar(this);
167
168 fileMenu=new QPopupMenu();
169 fileMenu->insertItem(Resource::loadPixmap("gutenbrowser/openbook"),
170 "Open Local Library...", this, SLOT( OpenBtn()) );
171// fileMenu->insertItem("Download FTPSite", this, SLOT( downloadFtpList()) );
172 fileMenu->insertItem( Resource::loadPixmap("home"),
173 "Download Library Index", this, SLOT( downloadLibIndex()) );
174 fileMenu->insertItem( Resource::loadPixmap("quit"),
175 "Quit Gutenbrowser...", this, SLOT( ByeBye()) );
176 // menuBar entry editMenu
177
178 editMenu=new QPopupMenu();
179
180 editMenu->insertItem(Resource::loadPixmap("up"), "Top",
181 this, SLOT(TopBtn()) );
182 editMenu->insertItem( Resource::loadPixmap("back"), "Beginning",
183 this, SLOT(doBeginBtn()) );
184 editMenu->insertItem( Resource::loadPixmap("gutenbrowser/search"), "Search",
185 this, SLOT(SearchBtn()) );
186
187 editMenu->insertItem("Clear", this, SLOT(ClearEdit()) );
188
189 optionsMenu= new QPopupMenu();
190 optionsMenu->insertItem( Resource::loadPixmap("gutenbrowser/configure"),
191 "Configure", this, SLOT(doOptions()) );
192
193 donateMenu = new QPopupMenu();
194// donateMenu->insertItem("Gutenberg", this, SLOT(donateGutenberg()) );
195 donateMenu->insertItem( Resource::loadPixmap("gutenbrowser/gutenbrowser_sm"),
196 "Gutenbrowser Developer", this, SLOT(infoGutenbrowser()) );
197
198 menubar->insertItem("File", fileMenu);
199 menubar->insertItem("Page", editMenu);
200 menubar->insertItem("Options", optionsMenu);
201// menubar->insertItem("More Info", donateMenu);
202
203 menu->addWidget( menubar,0);
204
205 topLayout->addLayout( menu, 0);
206}
207
208void Gutenbrowser::initButtonBar()
209{
210//qDebug("Starting buttonbar init.");
211
212 OpenButton = new QPushButton( this, "OpenButton" );
213 OpenButton->setFocusPolicy( QWidget::TabFocus );
214
215 LibraryButton = new QPushButton( this, "LibraryButton" );
216 LibraryButton->setFocusPolicy( QWidget::TabFocus );
217
218 BackButton = new QPushButton( this, "BackButton" );
219 BackButton->setFocusPolicy( QWidget::TabFocus );
220 BackButton->setAutoRepeat(TRUE);
221
222 ForwardButton = new QPushButton( this, "ForwardButton" );
223 ForwardButton->setFocusPolicy( QWidget::TabFocus );
224// ForwardButton->setAutoRepeat(TRUE);
225
226 SearchButton = new QPushButton( this, "SearchButton" );
227 SearchButton->setFocusPolicy( QWidget::TabFocus );
228
229 setBookmarkButton = new QPushButton( this, "setBookmark" );
230 setBookmarkButton->setFocusPolicy( QWidget::TabFocus );
231
232 lastBmkButton = new MenuButton( this, "lastBmkButton" );
233 lastBmkButton->setFocusPolicy( QWidget::TabFocus );
234
235 bookmarksMenu = new QPopupMenu();
236 bookmarksMenu->insertItem("Last Set", this, SLOT(Bookmark( int) ));
237
238 lastBmkButton->setPopup(bookmarksMenu);
239
240 dictionaryButton = new QPushButton( this, "dictionaryButton" );
241 dictionaryButton->setFocusPolicy( QWidget::TabFocus );
242
243 InfoBar = new QPushButton( this, "Info_Bar" );
244// qDebug("Infobar");
245// if(!useSplitter) {
246
247 buttonsHidden=FALSE;
248 buttons2->setSpacing(2);
249 buttons2->addWidget(OpenButton, 0, AlignCenter);
250 buttons2->addWidget(LibraryButton, 0, AlignCenter);
251 buttons2->addWidget(BackButton, 0, AlignCenter);
252 buttons2->addWidget(ForwardButton, 0, AlignCenter);
253 buttons2->addWidget(SearchButton, 0, AlignCenter);
254 buttons2->addWidget(setBookmarkButton, 0, AlignCenter);
255 buttons2->addWidget(lastBmkButton, 0, AlignCenter);
256 buttons2->addWidget(dictionaryButton, 0, AlignCenter);
257 buttons2->addWidget(InfoBar, 0, AlignCenter);
258
259 topLayout->setSpacing(0);
260 topLayout->addLayout( buttons2,0);
261
262}
263
264/* STATUSBAR*/
265void Gutenbrowser::initStatusBar()
266{
267// #ifndef Q_WS_QWS
268
269// statusBar = new QStatusBar( this, "Status Bar");
270// statusBar->message(IDS_STATUS_DEFAULT, 2000);
271// #endif
272}
273
274void Gutenbrowser::initView()
275{
276 // set the main widget here
277// QFont defaultFont( "charter", 10, 50, 0 );
278 Lview = new MultiLine_Ex(this);
279
280 Config cfg("Gutenbrowser");
281 cfg.setGroup("Font");
282
283 FontDatabase fdb;
284 QFont defaultFont=Lview->font();
285 QFontInfo fontInfo(defaultFont);
286
287 QString family = cfg.readEntry("Family", fontInfo.family());
288 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
289 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
290 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
291
292 defaultFont = fdb.font(family,style,i_size,charSet);
293
294 QString italic=cfg.readEntry("Italic","FALSE");
295 if(italic=="TRUE") {
296 qDebug("Set Italic font");
297 defaultFont = fdb.font(family,"Regular",i_size,charSet); //workaround
298 defaultFont.setItalic(TRUE);
299 }
300
301 Lview->setFont( defaultFont);
302 update();
303
304 cfg.setGroup("General");
305
306 if( cfg.readBoolEntry("WordWrap", 1)) {
307 Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
308 useWrap=true;
309 } else {
310 Lview->setWordWrap(QMultiLineEdit::NoWrap);
311 useWrap=false;
312 }
313 mainList = new QListBox(this,"mainlist");
314
315// QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
316 // mainList->showMaximized();
317// mainList->setGeometry(2,30,230,160);
318 Lview->setReadOnly( true);
319 edits->addWidget( Lview);
320 edits->addWidget(mainList);
321
322 if(!showMainList) {
323 Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. ");
324 } else
325 Lview->hide();
326
327 topLayout->addLayout( edits, 0);
328}