summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-08-09 16:24:58 (UTC)
committer kergoth <kergoth>2003-08-09 16:24:58 (UTC)
commite16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (unidiff)
tree9e9068190a15bc9b2a52ab33b40881128f732c0e
parent1c58d1407f9584fedcdae390a04e2b37e5853361 (diff)
downloadopie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2
Merge from BRANCH_1_0
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/networkapplet/opie-networkapplet.control2
-rw-r--r--noncore/applets/notesapplet/opie-notesapplet.control4
-rw-r--r--noncore/applets/wirelessapplet/opie-wirelessapplet.control2
-rw-r--r--noncore/apps/odict/configdlg.cpp22
-rw-r--r--noncore/apps/odict/configdlg.h2
-rw-r--r--noncore/apps/odict/odict.cpp12
-rw-r--r--noncore/apps/odict/odict.h2
-rw-r--r--noncore/apps/odict/odict.pro2
-rw-r--r--noncore/apps/odict/opie-odict.control2
-rw-r--r--noncore/apps/tableviewer/db/xmlsource.cpp6
-rw-r--r--noncore/apps/tableviewer/tableviewer.pro2
-rw-r--r--noncore/apps/tableviewer/ui/tvbrowseview.cpp7
-rw-r--r--noncore/apps/tableviewer/xmlencodeattr.cpp48
-rw-r--r--noncore/apps/tableviewer/xmlencodeattr.h26
-rw-r--r--noncore/comm/keypebble/keypebble.pro3
-rw-r--r--noncore/comm/keypebble/opie-keypebble.control2
-rw-r--r--noncore/comm/mobilemsg/opie-mobilemsg.control2
-rw-r--r--noncore/decorations/flat/opie-deco-flat.control2
-rw-r--r--noncore/decorations/liquid/opie-deco-liquid.control2
-rw-r--r--noncore/decorations/polished/opie-deco-polished.control2
-rw-r--r--noncore/games/backgammon/backgammon.control2
-rw-r--r--noncore/games/backgammon/backgammon.cpp2
-rw-r--r--noncore/games/backgammon/backgammon.h1
-rw-r--r--noncore/games/bounce/kbounce.cpp6
-rw-r--r--noncore/games/buzzword/buzzword.cpp8
-rw-r--r--noncore/games/fifteen/opie-fifteen.control2
-rw-r--r--noncore/games/go/opie-go.control2
-rw-r--r--noncore/games/kpacman/kpacman.cpp2
-rw-r--r--noncore/games/mindbreaker/opie-mindbreaker.control2
-rw-r--r--noncore/games/minesweep/opie-minesweep.control2
-rw-r--r--noncore/games/parashoot/opie-parashoot.control2
-rw-r--r--noncore/games/qasteroids/opie-qasteroids.control2
-rw-r--r--noncore/games/sfcave-sdl/sfcave-sdl.control2
-rw-r--r--noncore/games/sfcave/opie-sfcave.control2
-rw-r--r--noncore/games/snake/interface.cpp4
-rw-r--r--noncore/games/snake/opie-snake.control2
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp14
-rw-r--r--noncore/games/solitaire/opie-solitaire.control2
-rw-r--r--noncore/games/tetrix/opie-tetrix.control2
-rw-r--r--noncore/games/tictac/main.cpp2
-rw-r--r--noncore/games/tictac/opie-tictac.control2
-rw-r--r--noncore/games/wordgame/opie-wordgame.control2
-rw-r--r--noncore/games/wordgame/wordgame.cpp4
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp6
-rw-r--r--noncore/graphics/drawpad/drawpad.h1
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp20
-rw-r--r--noncore/graphics/drawpad/exportdialog.cpp11
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp14
-rw-r--r--noncore/graphics/drawpad/importdialog.h4
-rw-r--r--noncore/graphics/drawpad/main.cpp2
-rw-r--r--noncore/graphics/drawpad/opie-drawpad.control2
-rw-r--r--noncore/graphics/drawpad/texttool.h1
-rw-r--r--noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-Pod.control2
-rw-r--r--noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default-landscape.control2
-rw-r--r--noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default.control2
-rw-r--r--noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-techno.control2
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h7
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp59
-rw-r--r--noncore/multimedia/opieplayer2/lib.h5
-rw-r--r--noncore/multimedia/opieplayer2/mediadetect.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/mediadetect.h31
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control10
-rwxr-xr-xnoncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.postinst5
-rw-r--r--noncore/multimedia/opieplayer2/opie-mediaplayer2.control4
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro2
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp31
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h7
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp28
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h10
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h4
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h1
-rw-r--r--noncore/multimedia/opieplayer2/yuv2rgb_arm2.c875
-rw-r--r--noncore/multimedia/opierec/opierec.control6
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp30
-rw-r--r--noncore/multimedia/showimg/opie-showimg.control2
-rw-r--r--noncore/net/ftplib/ftplib.control2
-rw-r--r--noncore/net/mailit/opie-mailit.control2
-rw-r--r--noncore/net/opieftp/opie-ftp.control2
-rw-r--r--noncore/net/opieirc/opie-irc.control2
-rw-r--r--noncore/net/opietooth/applet/opie-bluetoothapplet.control2
-rw-r--r--noncore/net/opietooth/lib/libopietooth1.control2
-rw-r--r--noncore/unsupported/gsmtool/gsmtool.pro2
-rw-r--r--noncore/unsupported/mail2/addresspicker.cpp1
-rw-r--r--noncore/unsupported/mail2/bend/opie-mailapplet.control4
-rw-r--r--noncore/unsupported/mail2/opie-mail2.control2
-rw-r--r--noncore/unsupported/mailit/opie-mailit.control2
-rw-r--r--noncore/unsupported/qpdf/QOutputDev.cpp367
-rw-r--r--noncore/unsupported/qpdf/opie-qpdf.control2
-rw-r--r--noncore/unsupported/qpdf/qpdf.cpp2
96 files changed, 1386 insertions, 528 deletions
diff --git a/noncore/applets/networkapplet/opie-networkapplet.control b/noncore/applets/networkapplet/opie-networkapplet.control
index ae07eb3..f4ee7be 100644
--- a/noncore/applets/networkapplet/opie-networkapplet.control
+++ b/noncore/applets/networkapplet/opie-networkapplet.control
@@ -1,10 +1,10 @@
1Package: opie-networkapplet 1Package: opie-networkapplet
2Files: plugins/applets/libnetworkapplet.so* pics/networkapplet 2Files: plugins/applets/libnetworkapplet.so* pics/networkapplet
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal, libopie2 (1.8.1), opie-networksettings 7Depends: task-opie-minimal, libopie2 (1.8.1), opie-networksettings
9Description: Network Applet 8Description: Network Applet
10 A taskbar applet for controlling network interfaces 9 A taskbar applet for controlling network interfaces
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/applets/notesapplet/opie-notesapplet.control b/noncore/applets/notesapplet/opie-notesapplet.control
index da02b44..f19b964 100644
--- a/noncore/applets/notesapplet/opie-notesapplet.control
+++ b/noncore/applets/notesapplet/opie-notesapplet.control
@@ -1,10 +1,10 @@
1Package: opie-notesapplet 1Package: opie-notesapplet
2Files: plugins/applets/libnotesapplet.so* 2Files: plugins/applets/libnotesapplet.so*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: L. J. Potter <ljp@llornkcor.com> 5Maintainer: L. J. Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Screenshot Applet 8Description: Notes Applet
10 A simple taskbar applet for making quick notes. 9 A simple taskbar applet for making quick notes.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/applets/wirelessapplet/opie-wirelessapplet.control b/noncore/applets/wirelessapplet/opie-wirelessapplet.control
index ac7fad2..6dfa214 100644
--- a/noncore/applets/wirelessapplet/opie-wirelessapplet.control
+++ b/noncore/applets/wirelessapplet/opie-wirelessapplet.control
@@ -1,10 +1,10 @@
1Package: opie-wirelessapplet 1Package: opie-wirelessapplet
2Files: plugins/applets/libwirelessapplet.so* 2Files: plugins/applets/libwirelessapplet.so*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 5Maintainer: Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION.1
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Wireless Applet 8Description: Wireless Applet
10 A wireless network card status taskbar applet for the Opie environment 9 A wireless network card status taskbar applet for the Opie environment
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/apps/odict/configdlg.cpp b/noncore/apps/odict/configdlg.cpp
index 400298d..2103df9 100644
--- a/noncore/apps/odict/configdlg.cpp
+++ b/noncore/apps/odict/configdlg.cpp
@@ -1,117 +1,107 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : ODict 2 application: : ODict
3 3
4 begin : December 2002 4 begin : December 2002
5 copyright : ( C ) 2002, 2003 by Carsten Niehaus 5 copyright : ( C ) 2002, 2003 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
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#include "configdlg.h" 17#include "configdlg.h"
18#include "searchmethoddlg.h" 18#include "searchmethoddlg.h"
19 19
20#include <qdialog.h> 20#include <qdialog.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qlayout.h> 22#include <qlayout.h>
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qstringlist.h> 30#include <qstringlist.h>
31 31
32#include <opie/otabwidget.h>
33
34ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) 32ConfigDlg::ConfigDlg(QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal)
35{ 33{
36 setCaption( tr( "Options" ) ); 34 setCaption( tr( "Options" ) );
37 QVBoxLayout *vbox_layout = new QVBoxLayout( this ); 35 QVBoxLayout *vbox_layout = new QVBoxLayout( this );
38 tab = new OTabWidget( this, "OTabWidget_tab", OTabWidget::Global, OTabWidget::Bottom ); 36 search_tab = new QWidget( this , "search_tab" );
39 vbox_layout->addWidget( tab );
40
41 /*general settings*/
42 settings_tab = new QWidget( tab , "settings_tab" );
43
44 /*searchmethods*/
45 search_tab = new QWidget( tab , "search_tab" );
46 QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" ); 37 QVBoxLayout *vbox_layout_searchtab = new QVBoxLayout( search_tab, 4 , 4 ,"blah" );
47 38
48 QHBox *hbox = new QHBox( search_tab ); 39 QHBox *hbox = new QHBox( search_tab );
49 list = new QListView( hbox ); 40 list = new QListView( hbox );
50 list->addColumn( tr( "Searchmethod" ) ); 41 list->addColumn( tr( "Searchmethod" ) );
51 loadSearchMethodNames(); 42 loadSearchMethodNames();
52 43
53 QVBox *vbox = new QVBox( hbox ); 44 QVBox *vbox = new QVBox( hbox );
54 new_button = new QPushButton( "New" , vbox ); 45 new_button = new QPushButton( tr( "New" ) , vbox );
55 change_button = new QPushButton( "Change" , vbox ); 46 change_button = new QPushButton( tr( "Change" ) , vbox );
56 delete_button = new QPushButton( "Delete" , vbox ); 47 delete_button = new QPushButton( tr( "Delete" ) , vbox );
57 connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) ); 48 connect( new_button, SIGNAL( clicked() ), this, SLOT( slotNewMethod() ) );
58 connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() )); 49 connect( change_button, SIGNAL( clicked() ), this, SLOT( slotChangeMethod() ));
59 connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() )); 50 connect( delete_button, SIGNAL( clicked() ), this, SLOT( slotDeleteMethod() ));
60 51
61 vbox_layout_searchtab->addWidget( hbox ); 52 vbox_layout_searchtab->addWidget( hbox );
62 53
63 /*add the tabs and maximize*/ 54 vbox_layout->addWidget( search_tab );
64 tab->addTab( settings_tab, "pass", tr( "General Settings" ) ); 55
65 tab->addTab( search_tab, "zoom", tr( "Searchmethods" ) );
66 showMaximized(); 56 showMaximized();
67} 57}
68 58
69void ConfigDlg::slotNewMethod() 59void ConfigDlg::slotNewMethod()
70{ 60{
71 SearchMethodDlg dlg( this, "SearchMethodDlg", true ); 61 SearchMethodDlg dlg( this, "SearchMethodDlg", true );
72 if ( dlg.exec() == QDialog::Accepted ) 62 if ( dlg.exec() == QDialog::Accepted )
73 { 63 {
74 dlg.saveItem(); 64 dlg.saveItem();
75 QListViewItem *item = new QListViewItem( list ); 65 QListViewItem *item = new QListViewItem( list );
76 item->setText( 0 , dlg.nameLE->text() ); 66 item->setText( 0 , dlg.nameLE->text() );
77 } 67 }
78} 68}
79 69
80void ConfigDlg::slotChangeMethod() 70void ConfigDlg::slotChangeMethod()
81{ 71{
82 if ( list->selectedItem() ) 72 if ( list->selectedItem() )
83 { 73 {
84 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) ); 74 SearchMethodDlg dlg( this, "SearchMethodDlg", true, list->selectedItem()->text( 0 ) );
85 if ( dlg.exec() == QDialog::Accepted ) 75 if ( dlg.exec() == QDialog::Accepted )
86 { 76 {
87 dlg.saveItem(); 77 dlg.saveItem();
88 QListViewItem *item = list->selectedItem(); 78 QListViewItem *item = list->selectedItem();
89 item->setText( 0 , dlg.nameLE->text() ); 79 item->setText( 0 , dlg.nameLE->text() );
90 } 80 }
91 } 81 }
92} 82}
93 83
94void ConfigDlg::slotDeleteMethod() 84void ConfigDlg::slotDeleteMethod()
95{ 85{
96 if ( list->selectedItem() ) 86 if ( list->selectedItem() )
97 { 87 {
98 Config cfg ( "odict" ); 88 Config cfg ( "odict" );
99 cfg.setGroup( "Method_"+list->selectedItem()->text(0) ); 89 cfg.setGroup( "Method_"+list->selectedItem()->text(0) );
100 cfg.clearGroup(); 90 cfg.clearGroup();
101 //FIXME: this only removes the entries but not the group itself 91 //FIXME: this only removes the entries but not the group itself
102 92
103 list->takeItem( list->selectedItem() ); 93 list->takeItem( list->selectedItem() );
104 } 94 }
105} 95}
106 96
107void ConfigDlg::loadSearchMethodNames() 97void ConfigDlg::loadSearchMethodNames()
108{ 98{
109 Config cfg( "odict" ); 99 Config cfg( "odict" );
110 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 100 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
111 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 101 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
112 { 102 {
113 QListViewItem *item = new QListViewItem( list ); 103 QListViewItem *item = new QListViewItem( list );
114 cfg.setGroup( *it ); 104 cfg.setGroup( *it );
115 item->setText( 0 , cfg.readEntry( "Name" ) ); 105 item->setText( 0 , cfg.readEntry( "Name" ) );
116 } 106 }
117} 107}
diff --git a/noncore/apps/odict/configdlg.h b/noncore/apps/odict/configdlg.h
index e3ef3ce..6c85989 100644
--- a/noncore/apps/odict/configdlg.h
+++ b/noncore/apps/odict/configdlg.h
@@ -1,36 +1,34 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * ( at your option ) any later version. * 6 * ( at your option ) any later version. *
7 * * 7 * *
8 **************************************************************************/ 8 **************************************************************************/
9 9
10class QWidget; 10class QWidget;
11class OTabWidget;
12class QListView; 11class QListView;
13class QPushButton; 12class QPushButton;
14 13
15#include <qdialog.h> 14#include <qdialog.h>
16 15
17class ConfigDlg : public QDialog 16class ConfigDlg : public QDialog
18{ 17{
19 Q_OBJECT 18 Q_OBJECT
20 19
21 public: 20 public:
22 ConfigDlg(QWidget *parent, const char *name, bool modal=FALSE ); 21 ConfigDlg(QWidget *parent, const char *name, bool modal=FALSE );
23 22
24 private: 23 private:
25 OTabWidget *tab;
26 QWidget *settings_tab, *search_tab; 24 QWidget *settings_tab, *search_tab;
27 QListView *list; 25 QListView *list;
28 QPushButton *new_button, *change_button, *delete_button; 26 QPushButton *new_button, *change_button, *delete_button;
29 27
30 void loadSearchMethodNames(); 28 void loadSearchMethodNames();
31 29
32 private slots: 30 private slots:
33 void slotNewMethod(); 31 void slotNewMethod();
34 void slotChangeMethod(); 32 void slotChangeMethod();
35 void slotDeleteMethod(); 33 void slotDeleteMethod();
36}; 34};
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp
index 2028701..010545e 100644
--- a/noncore/apps/odict/odict.cpp
+++ b/noncore/apps/odict/odict.cpp
@@ -1,230 +1,220 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : ODict 2 application: : ODict
3 3
4 begin : December 2002 4 begin : December 2002
5 copyright : ( C ) 2002, 2003 by Carsten Niehaus 5 copyright : ( C ) 2002, 2003 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
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#include "odict.h" 17#include "odict.h"
18#include "configdlg.h" 18#include "configdlg.h"
19#include "dingwidget.h" 19#include "dingwidget.h"
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpopupmenu.h> 22#include <qpopupmenu.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qmessagebox.h> 24#include <qmessagebox.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qvbox.h> 26#include <qvbox.h>
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() : QMainWindow()
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 regexp = cfg.readEntry( "regexp" ).toInt();
80 79
81 QString lastDict = cfg.readEntry( "lastdict" ); 80 QString lastDict = cfg.readEntry( "lastdict" );
82 int i = 0, e = 0; 81 int i = 0, e = 0;
83 82
84 QStringList groupListCfg = cfg.groupList().grep( "Method_" ); 83 QStringList groupListCfg = cfg.groupList().grep( "Method_" );
85 query_co->clear(); 84 query_co->clear();
86 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it ) 85 for ( QStringList::Iterator it = groupListCfg.begin() ; it != groupListCfg.end() ; ++it )
87 { 86 {
88 QString name; 87 QString name;
89 cfg.setGroup( *it ); 88 cfg.setGroup( *it );
90 name = cfg.readEntry( "Name" ); 89 name = cfg.readEntry( "Name" );
91 query_co->insertItem( name ); 90 query_co->insertItem( name );
92 91
93 /* 92 /*
94 * 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
95 * last time 94 * last time
96 */ 95 */
97 if ( lastDict == name ) 96 if ( lastDict == name )
98 { 97 {
99 e = i; 98 e = i;
100 lastname = name; 99 lastname = name;
101 } 100 }
102 i++; 101 i++;
103 } 102 }
104 /* 103 /*
105 * now set the two names of the dictionary and the correct QComboBox-Entry 104 * now set the two names of the dictionary and the correct QComboBox-Entry
106 */ 105 */
107 106
108 lookupLanguageNames( lastname ); 107 lookupLanguageNames( lastname );
109 ding->loadDict( lastname ); 108 ding->loadDict( lastname );
110 ding->loadValues(); 109 ding->loadValues();
111 110
112 query_co->setCurrentItem( e ); 111 query_co->setCurrentItem( e );
113 top_name->setText( top_name_content ); 112 top_name->setText( top_name_content );
114 bottom_name->setText( bottom_name_content ); 113 bottom_name->setText( bottom_name_content );
115} 114}
116 115
117void ODict::lookupLanguageNames( QString dictname ) 116void ODict::lookupLanguageNames( QString dictname )
118{ 117{
119 Config cfg ( "odict" ); 118 Config cfg ( "odict" );
120 cfg.setGroup( "Method_"+dictname ); 119 cfg.setGroup( "Method_"+dictname );
121 top_name_content = cfg.readEntry( "Lang1" ); 120 top_name_content = cfg.readEntry( "Lang1" );
122 bottom_name_content = cfg.readEntry( "Lang2" ); 121 bottom_name_content = cfg.readEntry( "Lang2" );
123} 122}
124 123
125void ODict::saveConfig() 124void ODict::saveConfig()
126{ 125{
127 Config cfg ( "odict" ); 126 Config cfg ( "odict" );
128 cfg.setGroup( "generalsettings" ); 127 cfg.setGroup( "generalsettings" );
129 cfg.writeEntry( "casesens" , casesens ); 128 cfg.writeEntry( "casesens" , casesens );
130 cfg.writeEntry( "regexp" , regexp );
131 cfg.writeEntry( "lastdict" , query_co->currentText() ); 129 cfg.writeEntry( "lastdict" , query_co->currentText() );
132} 130}
133 131
134void ODict::slotStartQuery() 132void ODict::slotStartQuery()
135{ 133{
136 QString querystring = query_le->text(); 134 QString querystring = query_le->text();
137 if ( !querystring.isEmpty() ) 135 if ( !querystring.isEmpty() )
138 { 136 {
139 /* 137 /*
140 * if the user has not yet defined a dictionary 138 * if the user has not yet defined a dictionary
141 */ 139 */
142 if ( !query_co->currentText() ) 140 if ( !query_co->currentText() )
143 { 141 {
144 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), 142 switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ),
145 tr( "No dictionary defined" ), 143 tr( "No dictionary defined" ),
146 tr( "&Define one" ), 144 tr( "&Define one" ),
147 tr( "&Cancel" ), 145 tr( "&Cancel" ),
148 0, // Define a dict 146 0, // Define a dict
149 1 ) ) // Cancel choosen 147 1 ) ) // Cancel choosen
150 { 148 {
151 case 0: 149 case 0:
152 slotSettings(); 150 slotSettings();
153 break; 151 break;
154 case 1: // stop here 152 case 1: // stop here
155 return; 153 return;
156 } 154 }
157 } 155 }
158 156
159 /* 157 /*
160 * ok, the user has defined a dict 158 * ok, the user has defined a dict
161 */ 159 */
162 ding->setCaseSensitive( casesens ); 160 ding->setCaseSensitive( casesens );
163 161
164 BroswerContent test = ding->setText( querystring ); 162 BroswerContent test = ding->setText( querystring );
165 163
166 browser_top->setText( test.top ); 164 browser_top->setText( test.top );
167 browser_bottom->setText( test.bottom ); 165 browser_bottom->setText( test.bottom );
168 } 166 }
169} 167}
170 168
171void ODict::slotSettings() 169void ODict::slotSettings()
172{ 170{
173 ConfigDlg dlg( this, "Config" , true); 171 ConfigDlg dlg( this, "Config" , true);
174 if ( dlg.exec() == QDialog::Accepted ) 172 if ( dlg.exec() == QDialog::Accepted )
175 saveConfig(); 173 saveConfig();
176} 174}
177 175
178void ODict::slotSetParameter( int count ) 176void ODict::slotSetParameter( int count )
179{ 177{
180 if ( count == 0 ) 178 if ( count == 0 )
181 { 179 {
182 if ( casesens ) 180 if ( casesens )
183 casesens = false; 181 casesens = false;
184 else 182 else
185 casesens = true; 183 casesens = true;
186 } 184 }
187 185
188 if ( count == 1 )
189 {
190 if ( regexp )
191 regexp = false;
192 else
193 regexp = true;
194 }
195 saveConfig(); 186 saveConfig();
196} 187}
197 188
198void ODict::slotMethodChanged( const QString& methodnumber ) 189void ODict::slotMethodChanged( const QString& methodnumber )
199{ 190{
200 activated_name = methodnumber; 191 activated_name = methodnumber;
201 192
202 if ( activated_name != ding->loadedDict() ) 193 if ( activated_name != ding->loadedDict() )
203 { 194 {
204 ding->loadDict(activated_name); 195 ding->loadDict(activated_name);
205 196
206 lookupLanguageNames( activated_name ); 197 lookupLanguageNames( activated_name );
207 top_name->setText( top_name_content ); 198 top_name->setText( top_name_content );
208 bottom_name->setText( bottom_name_content ); 199 bottom_name->setText( bottom_name_content );
209 } 200 }
210} 201}
211 202
212void ODict::setupMenus() 203void ODict::setupMenus()
213{ 204{
214 menu = new QMenuBar( this ); 205 menu = new QMenuBar( this );
215 206
216 settings = new QPopupMenu( menu ); 207 settings = new QPopupMenu( menu );
217 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 );
218 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 209 connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
219 setting_a->addTo( settings ); 210 setting_a->addTo( settings );
220 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 );
221 212
222 parameter = new QPopupMenu( menu ); 213 parameter = new QPopupMenu( menu );
223 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); 214 connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) );
224 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); 215 parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 );
225 parameter->insertItem( tr( "Allow &reg. expressions" ), 2 );
226 parameter->insertSeparator(); 216 parameter->insertSeparator();
227 217
228 menu->insertItem( tr( "Settings" ) , settings ); 218 menu->insertItem( tr( "Settings" ) , settings );
229 menu->insertItem( tr( "Parameter" ) , parameter ); 219 menu->insertItem( tr( "Parameter" ) , parameter );
230} 220}
diff --git a/noncore/apps/odict/odict.h b/noncore/apps/odict/odict.h
index 9c037ea..be2a532 100644
--- a/noncore/apps/odict/odict.h
+++ b/noncore/apps/odict/odict.h
@@ -1,70 +1,70 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * ( at your option ) any later version. * 6 * ( at your option ) any later version. *
7 * * 7 * *
8 **************************************************************************/ 8 **************************************************************************/
9 9
10#include <qmainwindow.h> 10#include <qmainwindow.h>
11 11
12class QLabel; 12class QLabel;
13class QVBox; 13class QVBox;
14class QPopupMenu; 14class QPopupMenu;
15class QMenuBar; 15class QMenuBar;
16class QHBox; 16class QHBox;
17class QPushButton; 17class QPushButton;
18class QLineEdit; 18class QLineEdit;
19class QAction; 19class 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();
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
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
50 void setupMenus(); 50 void setupMenus();
51 51
52 bool casesens, completewords, regexp; 52 bool casesens, completewords;
53 53
54 void loadConfig(); 54 void loadConfig();
55 void saveConfig(); 55 void saveConfig();
56 56
57 QString activated_name; 57 QString activated_name;
58 QLabel *bottom_name, 58 QLabel *bottom_name,
59 *top_name; 59 *top_name;
60 60
61 QString top_name_content, bottom_name_content; 61 QString top_name_content, bottom_name_content;
62 62
63 void lookupLanguageNames( QString ); 63 void lookupLanguageNames( QString );
64 64
65 private slots: 65 private slots:
66 void slotStartQuery(); 66 void slotStartQuery();
67 void slotSettings(); 67 void slotSettings();
68 void slotSetParameter( int ); 68 void slotSetParameter( int );
69 void slotMethodChanged( const QString& ); 69 void slotMethodChanged( const QString& );
70}; 70};
diff --git a/noncore/apps/odict/odict.pro b/noncore/apps/odict/odict.pro
index 427a5c6..82f6a41 100644
--- a/noncore/apps/odict/odict.pro
+++ b/noncore/apps/odict/odict.pro
@@ -1,41 +1,41 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 #CONFIG = qt warn_on release 3 #CONFIG = qt warn_on release
4 HEADERS = odict.h \ 4 HEADERS = odict.h \
5 searchmethoddlg.h \ 5 searchmethoddlg.h \
6 configdlg.h \ 6 configdlg.h \
7 dingwidget.h \ 7 dingwidget.h
8 8
9 SOURCES = main.cpp \ 9 SOURCES = main.cpp \
10 odict.cpp \ 10 odict.cpp \
11 searchmethoddlg.cpp \ 11 searchmethoddlg.cpp \
12 configdlg.cpp \ 12 configdlg.cpp \
13 dingwidget.cpp 13 dingwidget.cpp
14INCLUDEPATH += $(OPIEDIR)/include 14INCLUDEPATH += $(OPIEDIR)/include
15DEPENDPATH += $(OPIEDIR)/include 15DEPENDPATH += $(OPIEDIR)/include
16 LIBS += -lqpe -lstdc++ -lopie 16 LIBS += -lqpe -lstdc++ -lopie
17 TARGET = odict 17 TARGET = odict
18 DESTDIR = $(OPIEDIR)/bin 18 DESTDIR = $(OPIEDIR)/bin
19 19
20TRANSLATIONS = ../../../i18n/de/odict.ts \ 20TRANSLATIONS = ../../../i18n/de/odict.ts \
21 ../../../i18n/nl/odict.ts \ 21 ../../../i18n/nl/odict.ts \
22 ../../../i18n/xx/odict.ts \ 22 ../../../i18n/xx/odict.ts \
23 ../../../i18n/en/odict.ts \ 23 ../../../i18n/en/odict.ts \
24 ../../../i18n/es/odict.ts \ 24 ../../../i18n/es/odict.ts \
25 ../../../i18n/fr/odict.ts \ 25 ../../../i18n/fr/odict.ts \
26 ../../../i18n/hu/odict.ts \ 26 ../../../i18n/hu/odict.ts \
27 ../../../i18n/ja/odict.ts \ 27 ../../../i18n/ja/odict.ts \
28 ../../../i18n/ko/odict.ts \ 28 ../../../i18n/ko/odict.ts \
29 ../../../i18n/no/odict.ts \ 29 ../../../i18n/no/odict.ts \
30 ../../../i18n/pl/odict.ts \ 30 ../../../i18n/pl/odict.ts \
31 ../../../i18n/pt/odict.ts \ 31 ../../../i18n/pt/odict.ts \
32 ../../../i18n/pt_BR/odict.ts \ 32 ../../../i18n/pt_BR/odict.ts \
33 ../../../i18n/sl/odict.ts \ 33 ../../../i18n/sl/odict.ts \
34 ../../../i18n/zh_CN/odict.ts \ 34 ../../../i18n/zh_CN/odict.ts \
35 ../../../i18n/zh_TW/odict.ts \ 35 ../../../i18n/zh_TW/odict.ts \
36 ../../../i18n/it/odict.ts \ 36 ../../../i18n/it/odict.ts \
37 ../../../i18n/da/odict.ts 37 ../../../i18n/da/odict.ts
38 38
39 39
40 40
41include ( $(OPIEDIR)/include.pro ) 41include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/odict/opie-odict.control b/noncore/apps/odict/opie-odict.control
index 2fa731f..f684716 100644
--- a/noncore/apps/odict/opie-odict.control
+++ b/noncore/apps/odict/opie-odict.control
@@ -1,10 +1,10 @@
1Package: opie-odict 1Package: opie-odict
2Files: bin/odict apps/Applications/odict.desktop pics/odict/odict.png 2Files: bin/odict apps/Applications/odict.desktop pics/odict/odict.png
3Priority: optional 3Priority: optional
4Section: applications 4Section: applications
5Maintainer: Carsten Niehaus <cniehaus@handhelds.org> 5Maintainer: Carsten Niehaus <cniehaus@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Dictionarylookupprogram 8Description: Dictionarylookupprogram
10 Look up words :) 9 Look up words :)
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp
index 7418a85..94fec36 100644
--- a/noncore/apps/tableviewer/db/xmlsource.cpp
+++ b/noncore/apps/tableviewer/db/xmlsource.cpp
@@ -1,295 +1,297 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "xmlsource.h" 20#include "xmlsource.h"
21#include <qdict.h> 21#include <qdict.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <qtextstream.h> 23#include <qtextstream.h>
24#include "../xmlencodeattr.h"
25
24 26
25 27
26DBXml::DBXml(DBStore *d) 28DBXml::DBXml(DBStore *d)
27{ 29{
28 dstore = d; 30 dstore = d;
29} 31}
30 32
31QString DBXml::type() 33QString DBXml::type()
32{ 34{
33 return "xml"; 35 return "xml";
34} 36}
35 37
36bool DBXml::openSource(QIODevice *inDev) 38bool DBXml::openSource(QIODevice *inDev)
37{ 39{
38 bool ok; 40 bool ok;
39 41
40 DBXmlHandler h(dstore); 42 DBXmlHandler h(dstore);
41 43
42 QTextStream tsIn(inDev); 44 QTextStream tsIn(inDev);
43 QXmlInputSource source(tsIn); 45 QXmlInputSource source(tsIn);
44 QXmlSimpleReader reader; 46 QXmlSimpleReader reader;
45 reader.setContentHandler(&h); 47 reader.setContentHandler(&h);
46 reader.setErrorHandler(&h); 48 reader.setErrorHandler(&h);
47 ok = reader.parse(source); 49 ok = reader.parse(source);
48 50
49 return ok; 51 return ok;
50} 52}
51 53
52bool DBXml::saveSource(QIODevice *outDev) 54bool DBXml::saveSource(QIODevice *outDev)
53{ 55{
54 int i; 56 int i;
55 DataElem *elem; 57 DataElem *elem;
56 KeyList *k; 58 KeyList *k;
57 59
58 QTextStream outstream(outDev); 60 QTextStream outstream(outDev);
59 61
60 outstream << "<database name=\"" << dstore->getName() << "\">" << endl; 62 outstream << "<database name=\"" << dstore->getName() << "\">" << endl;
61 outstream << "<header>" << endl; 63 outstream << "<header>" << endl;
62 64
63 k = dstore->getKeys(); 65 k = dstore->getKeys();
64 KeyListIterator it(*k); 66 KeyListIterator it(*k);
65 while(it.current()) { 67 while(it.current()) {
66 if (!it.current()->delFlag()) { 68 if (!it.current()->delFlag()) {
67 outstream << "<key name=\"KEYID" << it.currentKey() << "\" "; 69 outstream << "<key name=\"KEYID" << it.currentKey() << "\" ";
68 outstream << "type=\"" 70 outstream << "type=\""
69 << TVVariant::typeToName(it.current()->type()) 71 << TVVariant::typeToName(it.current()->type())
70 << "\">"; 72 << "\">";
71 outstream << it.current()->name() << "</key>" << endl; 73 outstream << encodeAttr(it.current()->name()) << "</key>" << endl;
72 } 74 }
73 ++it; 75 ++it;
74 } 76 }
75 77
76 outstream << "</header>" << endl; 78 outstream << "</header>" << endl;
77 79
78 dstore->first(); 80 dstore->first();
79 81
80 do { 82 do {
81 elem = dstore->getCurrentData(); 83 elem = dstore->getCurrentData();
82 if (!elem) 84 if (!elem)
83 break; 85 break;
84 outstream << "<record>" << endl; 86 outstream << "<record>" << endl;
85 it.toFirst(); 87 it.toFirst();
86 while (it.current()) { 88 while (it.current()) {
87 i = it.currentKey(); 89 i = it.currentKey();
88 if (elem->hasValidValue(i)) { 90 if (elem->hasValidValue(i)) {
89 outstream << "<KEYID" << i << ">"; 91 outstream << "<KEYID" << i << ">";
90 if (dstore->getKeyType(i) == TVVariant::Date) { 92 if (dstore->getKeyType(i) == TVVariant::Date) {
91 // dates in files are different from displayed dates 93 // dates in files are different from displayed dates
92 QDate date = elem->getField(i).toDate(); 94 QDate date = elem->getField(i).toDate();
93 outstream << date.day() << "/" 95 outstream << date.day() << "/"
94 << date.month() << "/" 96 << date.month() << "/"
95 << date.year(); 97 << date.year();
96 } else { 98 } else {
97 outstream << elem->toQString(i); 99 outstream << encodeAttr(elem->toQString(i));
98 } 100 }
99 outstream << "</KEYID" << i << ">" << endl; 101 outstream << "</KEYID" << i << ">" << endl;
100 } 102 }
101 ++it; 103 ++it;
102 } 104 }
103 outstream << "</record>" << endl; 105 outstream << "</record>" << endl;
104 } while(dstore->next()); 106 } while(dstore->next());
105 107
106 outstream << "</database>" << endl; 108 outstream << "</database>" << endl;
107 return TRUE; 109 return TRUE;
108} 110}
109 111
110DBXml::~DBXml() {} 112DBXml::~DBXml() {}
111 113
112/*! 114/*!
113 \class DBXmlHandler 115 \class DBXmlHandler
114 \brief An Xml parser for flat tables. 116 \brief An Xml parser for flat tables.
115 117
116 An xml parser for parsing the files used by the table viewer application. 118 An xml parser for parsing the files used by the table viewer application.
117 119
118 The format of the xml files can be found at the front of the file 120 The format of the xml files can be found at the front of the file
119 dataparser.h 121 dataparser.h
120*/ 122*/
121 123
122/*! 124/*!
123 Constructs a new DBXmlHandler, and sets that the table should be 125 Constructs a new DBXmlHandler, and sets that the table should be
124 constructed in the DBStore pointed to by ds. 126 constructed in the DBStore pointed to by ds.
125*/ 127*/
126DBXmlHandler::DBXmlHandler(DBStore *ds) 128DBXmlHandler::DBXmlHandler(DBStore *ds)
127{ 129{
128 data_store = ds; 130 data_store = ds;
129 current_keyrep = 0; 131 current_keyrep = 0;
130} 132}
131 133
132/*! 134/*!
133 Destroys the DBXmlHandler 135 Destroys the DBXmlHandler
134*/ 136*/
135DBXmlHandler::~DBXmlHandler() 137DBXmlHandler::~DBXmlHandler()
136{ 138{
137} 139}
138 140
139QString DBXmlHandler::errorProtocol() 141QString DBXmlHandler::errorProtocol()
140{ 142{
141 qWarning("Error reading file"); 143 qWarning("Error reading file");
142 return errorProt; 144 return errorProt;
143} 145}
144 146
145bool DBXmlHandler::startDocument() 147bool DBXmlHandler::startDocument()
146{ 148{
147 errorProt = ""; 149 errorProt = "";
148 state = StateInit; 150 state = StateInit;
149 return TRUE; 151 return TRUE;
150} 152}
151 153
152bool DBXmlHandler::startElement(const QString&, const QString&, 154bool DBXmlHandler::startElement(const QString&, const QString&,
153 const QString& qName, const QXmlAttributes& atts) 155 const QString& qName, const QXmlAttributes& atts)
154{ 156{
155 if (state == StateInit && qName == "database") { 157 if (state == StateInit && qName == "database") {
156 // First thing it expects is a <document name="..."> tag 158 // First thing it expects is a <document name="..."> tag
157 state = StateDocument; 159 state = StateDocument;
158 data_store->setName(atts.value("name")); 160 data_store->setName(atts.value("name"));
159 return TRUE; 161 return TRUE;
160 } 162 }
161 if (state == StateDocument && qName == "header") { 163 if (state == StateDocument && qName == "header") {
162 state = StateHeader; 164 state = StateHeader;
163 if (current_keyrep) delete current_keyrep; 165 if (current_keyrep) delete current_keyrep;
164 current_keyrep = new KeyList(); 166 current_keyrep = new KeyList();
165 return TRUE; 167 return TRUE;
166 } 168 }
167 if (state == StateHeader && qName == "key") { 169 if (state == StateHeader && qName == "key") {
168 /* Ok, adding a new key to our KeyList TODO */ 170 /* Ok, adding a new key to our KeyList TODO */
169 state = StateKey; 171 state = StateKey;
170 last_key_type = TVVariant::String; 172 last_key_type = TVVariant::String;
171 key = atts.value("name"); 173 key = atts.value("name");
172 if (key.isEmpty()) { 174 if (key.isEmpty()) {
173 qWarning("empty key name"); 175 qWarning("empty key name");
174 return FALSE; 176 return FALSE;
175 } 177 }
176 if(!atts.value("type").isEmpty()) 178 if(!atts.value("type").isEmpty())
177 last_key_type = TVVariant::nameToType(atts.value("type")); 179 last_key_type = TVVariant::nameToType(atts.value("type"));
178 return TRUE; 180 return TRUE;
179 } 181 }
180 if (state == StateDocument && qName == "record") { 182 if (state == StateDocument && qName == "record") {
181 state = StateRecord; 183 state = StateRecord;
182 current_data = new DataElem(data_store); 184 current_data = new DataElem(data_store);
183 // Now expecting a <record> tag 185 // Now expecting a <record> tag
184 return TRUE; 186 return TRUE;
185 } 187 }
186 if (state == StateRecord) { 188 if (state == StateRecord) {
187 state = StateField; 189 state = StateField;
188 /* the qName is the name of a key */ 190 /* the qName is the name of a key */
189 if (!keyIndexList[qName]) { 191 if (!keyIndexList[qName]) {
190 /* invalid key, we failed */ 192 /* invalid key, we failed */
191 qWarning("Invalid key in record"); 193 qWarning("Invalid key in record");
192 return FALSE; 194 return FALSE;
193 } 195 }
194 keyIndex = *keyIndexList[qName]; 196 keyIndex = *keyIndexList[qName];
195 return TRUE; 197 return TRUE;
196 } 198 }
197 qWarning("Unable to determine tag type"); 199 qWarning("Unable to determine tag type");
198 return FALSE; 200 return FALSE;
199} 201}
200 202
201bool DBXmlHandler::endElement(const QString&, const QString&, 203bool DBXmlHandler::endElement(const QString&, const QString&,
202 const QString& qName) 204 const QString& qName)
203{ 205{
204 switch(state) { 206 switch(state) {
205 case StateField: 207 case StateField:
206 // TODO checks 'could' be done of the popped value 208 // TODO checks 'could' be done of the popped value
207 state = StateRecord; 209 state = StateRecord;
208 break; 210 break;
209 case StateKey: 211 case StateKey:
210 // TODO checks 'could' be done of the popped value 212 // TODO checks 'could' be done of the popped value
211 state = StateHeader; 213 state = StateHeader;
212 break; 214 break;
213 case StateHeader: 215 case StateHeader:
214 data_store->setKeys(current_keyrep); 216 data_store->setKeys(current_keyrep);
215 state = StateDocument; 217 state = StateDocument;
216 break; 218 break;
217 case StateRecord: 219 case StateRecord:
218 data_store->addItem(current_data); 220 data_store->addItem(current_data);
219 state = StateDocument; 221 state = StateDocument;
220 break; 222 break;
221 case StateDocument: 223 case StateDocument:
222 // we are done... 224 // we are done...
223 break; 225 break;
224 default: 226 default:
225 // should only get a 'endElement' from one of the above states. 227 // should only get a 'endElement' from one of the above states.
226 qWarning("Invalid end tag"); 228 qWarning("Invalid end tag");
227 return FALSE; 229 return FALSE;
228 break; 230 break;
229 } 231 }
230 return TRUE; 232 return TRUE;
231} 233}
232 234
233bool DBXmlHandler::characters(const QString& ch) 235bool DBXmlHandler::characters(const QString& ch)
234{ 236{
235 // this is where the 'between tag' stuff happens. 237 // this is where the 'between tag' stuff happens.
236 // e.g. the stuff between tags. 238 // e.g. the stuff between tags.
237 QString ch_simplified = ch.simplifyWhiteSpace(); 239 QString ch_simplified = ch.simplifyWhiteSpace();
238 240
239 if (ch_simplified.isEmpty()) 241 if (ch_simplified.isEmpty())
240 return TRUE; 242 return TRUE;
241 243
242 if (state == StateKey) { 244 if (state == StateKey) {
243 int *tmp_val = new int; 245 int *tmp_val = new int;
244 /* We just grabbed the display name of a key */ 246 /* We just grabbed the display name of a key */
245 *tmp_val = current_keyrep->addKey(ch_simplified, last_key_type); 247 *tmp_val = current_keyrep->addKey(ch_simplified, last_key_type);
246 keyIndexList.insert(key, tmp_val); 248 keyIndexList.insert(key, tmp_val);
247 return TRUE; 249 return TRUE;
248 } 250 }
249 if (state == StateField) { 251 if (state == StateField) {
250 /* Ok, need to add data here */ 252 /* Ok, need to add data here */
251 current_data->setField(keyIndex, ch_simplified); 253 current_data->setField(keyIndex, ch_simplified);
252 return TRUE; 254 return TRUE;
253 } 255 }
254 256
255 qWarning("Junk characters found... ignored"); 257 qWarning("Junk characters found... ignored");
256 return TRUE; 258 return TRUE;
257} 259}
258 260
259QString DBXmlHandler::errorString() 261QString DBXmlHandler::errorString()
260{ 262{
261 return "the document is not in the expected file format"; 263 return "the document is not in the expected file format";
262} 264}
263 265
264bool DBXmlHandler::warning(const QXmlParseException& exception) 266bool DBXmlHandler::warning(const QXmlParseException& exception)
265{ 267{
266 errorProt += QString("warning parsing error: %1 in line %2, column %3\n" ) 268 errorProt += QString("warning parsing error: %1 in line %2, column %3\n" )
267 .arg(exception.message()) 269 .arg(exception.message())
268 .arg(exception.lineNumber()) 270 .arg(exception.lineNumber())
269 .arg(exception.columnNumber()); 271 .arg(exception.columnNumber());
270 272
271 qWarning(errorProt); 273 qWarning(errorProt);
272 return QXmlDefaultHandler::fatalError(exception); 274 return QXmlDefaultHandler::fatalError(exception);
273} 275}
274 276
275bool DBXmlHandler::error(const QXmlParseException& exception) 277bool DBXmlHandler::error(const QXmlParseException& exception)
276{ 278{
277 errorProt += QString("error parsing error: %1 in line %2, column %3\n" ) 279 errorProt += QString("error parsing error: %1 in line %2, column %3\n" )
278 .arg(exception.message()) 280 .arg(exception.message())
279 .arg(exception.lineNumber()) 281 .arg(exception.lineNumber())
280 .arg(exception.columnNumber()); 282 .arg(exception.columnNumber());
281 283
282 qWarning(errorProt); 284 qWarning(errorProt);
283 return QXmlDefaultHandler::fatalError(exception); 285 return QXmlDefaultHandler::fatalError(exception);
284} 286}
285 287
286bool DBXmlHandler::fatalError(const QXmlParseException& exception) 288bool DBXmlHandler::fatalError(const QXmlParseException& exception)
287{ 289{
288 errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" ) 290 errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" )
289 .arg(exception.message()) 291 .arg(exception.message())
290 .arg(exception.lineNumber()) 292 .arg(exception.lineNumber())
291 .arg(exception.columnNumber()); 293 .arg(exception.columnNumber());
292 294
293 qWarning(errorProt); 295 qWarning(errorProt);
294 return QXmlDefaultHandler::fatalError(exception); 296 return QXmlDefaultHandler::fatalError(exception);
295} 297}
diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro
index 6f73400..f047e0b 100644
--- a/noncore/apps/tableviewer/tableviewer.pro
+++ b/noncore/apps/tableviewer/tableviewer.pro
@@ -1,58 +1,60 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 SUBDIRS = db ui 4 SUBDIRS = db ui
5 HEADERS = tableviewer.h \ 5 HEADERS = tableviewer.h \
6 xmlencodeattr.h \
6 ui/commonwidgets.h \ 7 ui/commonwidgets.h \
7 ui/tvbrowseview.h \ 8 ui/tvbrowseview.h \
8 ui/tvlistview.h \ 9 ui/tvlistview.h \
9 ui/tvfilterview.h \ 10 ui/tvfilterview.h \
10 ui/tveditview.h \ 11 ui/tveditview.h \
11 ui/browsekeyentry.h \ 12 ui/browsekeyentry.h \
12 ui/filterkeyentry.h \ 13 ui/filterkeyentry.h \
13 ui/tvkeyedit.h \ 14 ui/tvkeyedit.h \
14 db/datacache.h \ 15 db/datacache.h \
15 db/common.h \ 16 db/common.h \
16 db/xmlsource.h \ 17 db/xmlsource.h \
17 db/csvsource.h 18 db/csvsource.h
18 SOURCES = main.cpp \ 19 SOURCES = main.cpp \
19 tableviewer.cpp \ 20 tableviewer.cpp \
21 xmlencodeattr.cpp \
20 ui/commonwidgets.cpp \ 22 ui/commonwidgets.cpp \
21 ui/tvbrowseview.cpp \ 23 ui/tvbrowseview.cpp \
22 ui/tvfilterview.cpp \ 24 ui/tvfilterview.cpp \
23 ui/browsekeyentry.cpp \ 25 ui/browsekeyentry.cpp \
24 ui/filterkeyentry.cpp \ 26 ui/filterkeyentry.cpp \
25 ui/tvlistview.cpp \ 27 ui/tvlistview.cpp \
26 ui/tveditview.cpp \ 28 ui/tveditview.cpp \
27 ui/tvkeyedit.cpp \ 29 ui/tvkeyedit.cpp \
28 db/datacache.cpp \ 30 db/datacache.cpp \
29 db/xmlsource.cpp \ 31 db/xmlsource.cpp \
30 db/csvsource.cpp \ 32 db/csvsource.cpp \
31 db/common.cpp 33 db/common.cpp
32 INTERFACES= ui/tvkeyedit_gen.ui 34 INTERFACES= ui/tvkeyedit_gen.ui
33 TARGET = tableviewer 35 TARGET = tableviewer
34INCLUDEPATH += $(OPIEDIR)/include 36INCLUDEPATH += $(OPIEDIR)/include
35DEPENDPATH += $(OPIEDIR)/include 37DEPENDPATH += $(OPIEDIR)/include
36 LIBS += -lqpe 38 LIBS += -lqpe
37 39
38TRANSLATIONS = ../../../i18n/de/tableviewer.ts \ 40TRANSLATIONS = ../../../i18n/de/tableviewer.ts \
39 ../../../i18n/nl/tableviewer.ts \ 41 ../../../i18n/nl/tableviewer.ts \
40 ../../../i18n/da/tableviewer.ts \ 42 ../../../i18n/da/tableviewer.ts \
41 ../../../i18n/xx/tableviewer.ts \ 43 ../../../i18n/xx/tableviewer.ts \
42 ../../../i18n/en/tableviewer.ts \ 44 ../../../i18n/en/tableviewer.ts \
43 ../../../i18n/es/tableviewer.ts \ 45 ../../../i18n/es/tableviewer.ts \
44 ../../../i18n/fr/tableviewer.ts \ 46 ../../../i18n/fr/tableviewer.ts \
45 ../../../i18n/hu/tableviewer.ts \ 47 ../../../i18n/hu/tableviewer.ts \
46 ../../../i18n/ja/tableviewer.ts \ 48 ../../../i18n/ja/tableviewer.ts \
47 ../../../i18n/ko/tableviewer.ts \ 49 ../../../i18n/ko/tableviewer.ts \
48 ../../../i18n/no/tableviewer.ts \ 50 ../../../i18n/no/tableviewer.ts \
49 ../../../i18n/pl/tableviewer.ts \ 51 ../../../i18n/pl/tableviewer.ts \
50 ../../../i18n/pt/tableviewer.ts \ 52 ../../../i18n/pt/tableviewer.ts \
51 ../../../i18n/pt_BR/tableviewer.ts \ 53 ../../../i18n/pt_BR/tableviewer.ts \
52 ../../../i18n/sl/tableviewer.ts \ 54 ../../../i18n/sl/tableviewer.ts \
53 ../../../i18n/zh_CN/tableviewer.ts \ 55 ../../../i18n/zh_CN/tableviewer.ts \
54 ../../../i18n/zh_TW/tableviewer.ts 56 ../../../i18n/zh_TW/tableviewer.ts
55 57
56 58
57 59
58include ( $(OPIEDIR)/include.pro ) 60include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
index f5f2555..22bac55 100644
--- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp
+++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp
@@ -1,122 +1,123 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "tvbrowseview.h" 20#include "tvbrowseview.h"
21#include "browsekeyentry.h" 21#include "browsekeyentry.h"
22#include <qtoolbutton.h> 22#include <qtoolbutton.h>
23#include <qtextview.h> 23#include <qtextview.h>
24#include <qtextbrowser.h> 24#include <qtextbrowser.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include "../xmlencodeattr.h"
26 27
27/*! 28/*!
28 \class TVBrowseView 29 \class TVBrowseView
29 \brief The widget describing how to draw the browse view user interface 30 \brief The widget describing how to draw the browse view user interface
30 31
31 This widget allows for the user to browse through the table, one element 32 This widget allows for the user to browse through the table, one element
32 at a time, or search on a single key. Its main goal is to show a 33 at a time, or search on a single key. Its main goal is to show a
33 single element in a readable format and make it easy for the user to 34 single element in a readable format and make it easy for the user to
34 rapidly find specific elements in the table. 35 rapidly find specific elements in the table.
35*/ 36*/
36 37
37/*! 38/*!
38 Constructs a new TVBrowseView widget 39 Constructs a new TVBrowseView widget
39*/ 40*/
40TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, 41TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name,
41 WFlags fl ) 42 WFlags fl )
42{ 43{
43 if (!name) 44 if (!name)
44 setName("BrowseView"); 45 setName("BrowseView");
45 46
46// setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); 47// setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) );
47 QVBoxLayout *vlayout = new QVBoxLayout(this); 48 QVBoxLayout *vlayout = new QVBoxLayout(this);
48 textViewDisplay = new QTextBrowser(this, "textViewDisplay"); 49 textViewDisplay = new QTextBrowser(this, "textViewDisplay");
49 vlayout->addWidget( textViewDisplay ); 50 vlayout->addWidget( textViewDisplay );
50 51
51 keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); 52 keyEntry = new TVBrowseKeyEntry(this, "keyEntry");
52 vlayout->addWidget( keyEntry ); 53 vlayout->addWidget( keyEntry );
53 54
54 /* connect the signals down */ 55 /* connect the signals down */
55 56
56 connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), 57 connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)),
57 this, SIGNAL(searchOnKey(int, TVVariant))); 58 this, SIGNAL(searchOnKey(int, TVVariant)));
58 connect(keyEntry, SIGNAL(sortChanged(int)), 59 connect(keyEntry, SIGNAL(sortChanged(int)),
59 this, SIGNAL(sortChanged(int))); 60 this, SIGNAL(sortChanged(int)));
60 61
61 ts = t; 62 ts = t;
62 keyEntry->setTableState(t); 63 keyEntry->setTableState(t);
63} 64}
64 65
65/*! 66/*!
66 Destroys the TVBrowseView widget 67 Destroys the TVBrowseView widget
67*/ 68*/
68TVBrowseView::~TVBrowseView() 69TVBrowseView::~TVBrowseView()
69{ 70{
70} 71}
71 72
72void TVBrowseView::rebuildData() 73void TVBrowseView::rebuildData()
73{ 74{
74 if(!ts) 75 if(!ts)
75 return; 76 return;
76 if(!ts->current_elem) { 77 if(!ts->current_elem) {
77 /* also disable buttons */ 78 /* also disable buttons */
78 textViewDisplay->setText(""); 79 textViewDisplay->setText("");
79 return; 80 return;
80 } 81 }
81 82
82 setDisplayText(ts->current_elem); 83 setDisplayText(ts->current_elem);
83} 84}
84 85
85/* Reset to initial state */ 86/* Reset to initial state */
86void TVBrowseView::reset() 87void TVBrowseView::reset()
87{ 88{
88 textViewDisplay->setText(""); 89 textViewDisplay->setText("");
89 keyEntry->reset(); 90 keyEntry->reset();
90} 91}
91 92
92/*! 93/*!
93 sets the data element to be displayed to element 94 sets the data element to be displayed to element
94*/ 95*/
95void TVBrowseView::setDisplayText(const DataElem *element) 96void TVBrowseView::setDisplayText(const DataElem *element)
96{ 97{
97 QString rep = ""; 98 QString rep = "";
98 99
99 KeyListIterator it(*ts->kRep); 100 KeyListIterator it(*ts->kRep);
100 101
101 while (it.current()) { 102 while (it.current()) {
102 if (element->hasValidValue(it.currentKey())) { 103 if (element->hasValidValue(it.currentKey())) {
103 if(it.currentKey() == ts->current_column) { 104 if(it.currentKey() == ts->current_column) {
104 rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" 105 rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>"
105 + it.current()->name() 106 + encodeAttr(it.current()->name())
106 + ":</FONT></B> "; 107 + ":</FONT></B> ";
107 } else { 108 } else {
108 rep += "<B>" + it.current()->name() + ":</B> "; 109 rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> ";
109 } 110 }
110 rep += element->toQString(it.currentKey()) + "<BR>"; 111 rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>";
111 } 112 }
112 ++it; 113 ++it;
113 } 114 }
114 115
115 textViewDisplay->setText(rep); 116 textViewDisplay->setText(rep);
116 textViewDisplay->scrollToAnchor("ckey"); 117 textViewDisplay->scrollToAnchor("ckey");
117} 118}
118 119
119void TVBrowseView::rebuildKeys() 120void TVBrowseView::rebuildKeys()
120{ 121{
121 keyEntry->rebuildKeys(); 122 keyEntry->rebuildKeys();
122} 123}
diff --git a/noncore/apps/tableviewer/xmlencodeattr.cpp b/noncore/apps/tableviewer/xmlencodeattr.cpp
new file mode 100644
index 0000000..de264f7
--- a/dev/null
+++ b/noncore/apps/tableviewer/xmlencodeattr.cpp
@@ -0,0 +1,48 @@
1/*
2 * xmlencodeattr.h
3 *
4 * copyright : (c) 2003 by Joseph Wenninger
5 * except for a small modification it's identical to qdom.cpp:encodeAttr
6 * email : jowenn@handhelds.org
7 *
8 */
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "xmlencodeattr.h"
19QString encodeAttr( const QString& str )
20{
21 QString tmp( str );
22 uint len = tmp.length();
23 uint i = 0;
24 while ( i < len ) {
25 if ( tmp[(int)i] == '<' ) {
26 tmp.replace( i, 1, "&lt;" );
27 len += 3;
28 i += 4;
29 } else if ( tmp[(int)i] == '"' ) {
30 tmp.replace( i, 1, "&quot;" );
31 len += 5;
32 i += 6;
33 } else if ( tmp[(int)i] == '&' ) {
34 tmp.replace( i, 1, "&amp;" );
35 len += 4;
36 i += 5;
37 } else if ( tmp[(int)i] == '>' ) {
38 tmp.replace( i, 1, "&gt;" );
39 len += 3;
40 i += 4;
41 } else {
42 ++i;
43 }
44 }
45
46 return tmp;
47}
48
diff --git a/noncore/apps/tableviewer/xmlencodeattr.h b/noncore/apps/tableviewer/xmlencodeattr.h
new file mode 100644
index 0000000..5fd3b95
--- a/dev/null
+++ b/noncore/apps/tableviewer/xmlencodeattr.h
@@ -0,0 +1,26 @@
1/*
2 * xmlencodeattr.h
3 *
4 * copyright : (c) 2003 by Joseph Wenninger
5 * except for a small modification it's identical to qdom.cpp:encodeAttr
6 * email : jowenn@handhelds.org
7 *
8 */
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef _XML_ENCODE_ATTR_
19#define _XML_ENCODE_ATTR_
20
21#include <qstring.h>
22
23QString encodeAttr( const QString& str );
24
25#endif
26
diff --git a/noncore/comm/keypebble/keypebble.pro b/noncore/comm/keypebble/keypebble.pro
index 04f4b64..7af60f9 100644
--- a/noncore/comm/keypebble/keypebble.pro
+++ b/noncore/comm/keypebble/keypebble.pro
@@ -1,56 +1,55 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4 HEADERS = d3des.h \ 4 HEADERS = d3des.h \
5 krfbbuffer.h \ 5 krfbbuffer.h \
6 krfbcanvas.h \ 6 krfbcanvas.h \
7 krfbconnection.h \ 7 krfbconnection.h \
8 krfbdecoder.h \ 8 krfbdecoder.h \
9 krfblogin.h \ 9 krfblogin.h \
10 krfbserver.h \ 10 krfbserver.h \
11 krfbserverinfo.h \ 11 krfbserverinfo.h \
12 kvnc.h \ 12 kvnc.h \
13 kvncconndlg.h \ 13 kvncconndlg.h \
14 kvncbookmarkdlg.h \ 14 kvncbookmarkdlg.h \
15 version.h \
16 vncauth.h 15 vncauth.h
17 SOURCES = d3des.c \ 16 SOURCES = d3des.c \
18 vncauth.c \ 17 vncauth.c \
19 krfbbuffer.cpp \ 18 krfbbuffer.cpp \
20 krfbcanvas.cpp \ 19 krfbcanvas.cpp \
21 krfbconnection.cpp \ 20 krfbconnection.cpp \
22 krfbdecoder.cpp \ 21 krfbdecoder.cpp \
23 krfblogin.cpp \ 22 krfblogin.cpp \
24 krfbserver.cpp \ 23 krfbserver.cpp \
25 kvnc.cpp \ 24 kvnc.cpp \
26 kvncconndlg.cpp \ 25 kvncconndlg.cpp \
27 kvncbookmarkdlg.cpp \ 26 kvncbookmarkdlg.cpp \
28 main.cpp 27 main.cpp
29 INTERFACES= kvncconndlgbase.ui \ 28 INTERFACES= kvncconndlgbase.ui \
30 kvncbookmarkdlgbase.ui 29 kvncbookmarkdlgbase.ui
31TARGET = keypebble 30TARGET = keypebble
32INCLUDEPATH += $(OPIEDIR)/include 31INCLUDEPATH += $(OPIEDIR)/include
33DEPENDPATH += $(OPIEDIR)/include 32DEPENDPATH += $(OPIEDIR)/include
34LIBS += -lqpe 33LIBS += -lqpe
35 34
36TRANSLATIONS = ../../../i18n/de/keypebble.ts \ 35TRANSLATIONS = ../../../i18n/de/keypebble.ts \
37 ../../../i18n/nl/keypebble.ts \ 36 ../../../i18n/nl/keypebble.ts \
38 ../../../i18n/da/keypebble.ts \ 37 ../../../i18n/da/keypebble.ts \
39 ../../../i18n/xx/keypebble.ts \ 38 ../../../i18n/xx/keypebble.ts \
40 ../../../i18n/en/keypebble.ts \ 39 ../../../i18n/en/keypebble.ts \
41 ../../../i18n/es/keypebble.ts \ 40 ../../../i18n/es/keypebble.ts \
42 ../../../i18n/fr/keypebble.ts \ 41 ../../../i18n/fr/keypebble.ts \
43 ../../../i18n/hu/keypebble.ts \ 42 ../../../i18n/hu/keypebble.ts \
44 ../../../i18n/ja/keypebble.ts \ 43 ../../../i18n/ja/keypebble.ts \
45 ../../../i18n/ko/keypebble.ts \ 44 ../../../i18n/ko/keypebble.ts \
46 ../../../i18n/no/keypebble.ts \ 45 ../../../i18n/no/keypebble.ts \
47 ../../../i18n/pl/keypebble.ts \ 46 ../../../i18n/pl/keypebble.ts \
48 ../../../i18n/pt/keypebble.ts \ 47 ../../../i18n/pt/keypebble.ts \
49 ../../../i18n/pt_BR/keypebble.ts \ 48 ../../../i18n/pt_BR/keypebble.ts \
50 ../../../i18n/sl/keypebble.ts \ 49 ../../../i18n/sl/keypebble.ts \
51 ../../../i18n/zh_CN/keypebble.ts \ 50 ../../../i18n/zh_CN/keypebble.ts \
52 ../../../i18n/zh_TW/keypebble.ts 51 ../../../i18n/zh_TW/keypebble.ts
53 52
54 53
55 54
56include ( $(OPIEDIR)/include.pro ) 55include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/comm/keypebble/opie-keypebble.control b/noncore/comm/keypebble/opie-keypebble.control
index 123f307..23e4e89 100644
--- a/noncore/comm/keypebble/opie-keypebble.control
+++ b/noncore/comm/keypebble/opie-keypebble.control
@@ -1,11 +1,11 @@
1Package: opie-keypebble 1Package: opie-keypebble
2Files: bin/keypebble apps/Applications/keypebble.desktop pics/vnc 2Files: bin/keypebble apps/Applications/keypebble.desktop pics/vnc
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Arch: iPAQ 7Arch: iPAQ
8Version: $QPE_VERSION-$SUB_VERSION
9Depends: task-opie-minimal 8Depends: task-opie-minimal
10Description: VNC Viewer 9Description: VNC Viewer
11 Virtual Network Computing (VNC) viewer 10 Virtual Network Computing (VNC) viewer
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/comm/mobilemsg/opie-mobilemsg.control b/noncore/comm/mobilemsg/opie-mobilemsg.control
index 1713af5..c5fbc7f 100644
--- a/noncore/comm/mobilemsg/opie-mobilemsg.control
+++ b/noncore/comm/mobilemsg/opie-mobilemsg.control
@@ -1,10 +1,10 @@
1Package: opie-mobilemsg 1Package: opie-mobilemsg
2Files: bin/mobilemsg apps/Applications/mobilemsg.desktop 2Files: bin/mobilemsg apps/Applications/mobilemsg.desktop
3Priority: optional 3Priority: optional
4Section: opie/comm 4Section: opie/comm
5Maintainer: Bruno Rodrigues <bruno.rodrigues@litux.org> 5Maintainer: Bruno Rodrigues <bruno.rodrigues@litux.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Mobile Messaging 8Description: Mobile Messaging
10 For the Opie environment. 9 For the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/decorations/flat/opie-deco-flat.control b/noncore/decorations/flat/opie-deco-flat.control
index ae64aae..311f37b 100644
--- a/noncore/decorations/flat/opie-deco-flat.control
+++ b/noncore/decorations/flat/opie-deco-flat.control
@@ -1,10 +1,10 @@
1Package: opie-deco-flat 1Package: opie-deco-flat
2Files: plugins/decorations/libflat.so* 2Files: plugins/decorations/libflat.so*
3Priority: optional 3Priority: optional
4Section: opie/decorations 4Section: opie/decorations
5Maintainer: Robert Griebl <sandman@handhelds.org> 5Maintainer: Robert Griebl <sandman@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION.1
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: OPIE window decoration style 8Description: OPIE window decoration style
10 Flat window decoration style for OPIE. 9 Flat window decoration style for OPIE.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/decorations/liquid/opie-deco-liquid.control b/noncore/decorations/liquid/opie-deco-liquid.control
index 2f91612..c14b8bf 100644
--- a/noncore/decorations/liquid/opie-deco-liquid.control
+++ b/noncore/decorations/liquid/opie-deco-liquid.control
@@ -1,10 +1,10 @@
1Package: opie-deco-liquid 1Package: opie-deco-liquid
2Files: plugins/decorations/libliquid.so* 2Files: plugins/decorations/libliquid.so*
3Priority: optional 3Priority: optional
4Section: opie/decorations 4Section: opie/decorations
5Maintainer: Robert Griebl <sandman@handhelds.org> 5Maintainer: Robert Griebl <sandman@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION.1
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: OPIE window decoration style 8Description: OPIE window decoration style
10 Liquid (KDE3) window decoration style for OPIE. 9 Liquid (KDE3) window decoration style for OPIE.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/decorations/polished/opie-deco-polished.control b/noncore/decorations/polished/opie-deco-polished.control
index 4d4b4e3..15afa83 100644
--- a/noncore/decorations/polished/opie-deco-polished.control
+++ b/noncore/decorations/polished/opie-deco-polished.control
@@ -1,10 +1,10 @@
1Package: opie-deco-polished 1Package: opie-deco-polished
2Files: plugins/decorations/libpolished.so* 2Files: plugins/decorations/libpolished.so*
3Priority: optional 3Priority: optional
4Section: opie/decorations 4Section: opie/decorations
5Maintainer: Robert Griebl <sandman@handhelds.org> 5Maintainer: Robert Griebl <sandman@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION.1
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: OPIE window decoration style 8Description: OPIE window decoration style
10 Blended window decoration style for OPIE. 9 Blended window decoration style for OPIE.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/backgammon/backgammon.control b/noncore/games/backgammon/backgammon.control
index b75bc60..6468181 100644
--- a/noncore/games/backgammon/backgammon.control
+++ b/noncore/games/backgammon/backgammon.control
@@ -1,10 +1,10 @@
1Package: backgammon 1Package: backgammon
2Files: bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html 2Files: bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Ralf Waspe <rwaspe@web.de> 5Maintainer: Ralf Waspe <rwaspe@web.de>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Backgammon Game 8Description: Backgammon Game
10 A Backgammon game for the Opie environment. 9 A Backgammon game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp
index db1a058..06523f1 100644
--- a/noncore/games/backgammon/backgammon.cpp
+++ b/noncore/games/backgammon/backgammon.cpp
@@ -1,976 +1,974 @@
1#include "backgammon.h" 1#include "backgammon.h"
2 2
3#include "aidialog.h" 3#include "aidialog.h"
4#include "filedialog.h" 4#include "filedialog.h"
5#include "playerdialog.h" 5#include "playerdialog.h"
6#include "rulesdialog.h" 6#include "rulesdialog.h"
7#include "themedialog.h" 7#include "themedialog.h"
8 8
9#include <qdatetime.h> 9#include <qdatetime.h>
10#include <qfile.h> 10#include <qfile.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qstring.h> 13#include <qstring.h>
14#include <qtimer.h> 14#include <qtimer.h>
15#include <qmainwindow.h> 15#include <qmainwindow.h>
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20 20
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23 23
24BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 24BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
25 : QMainWindow(parent, name, fl) 25 : QMainWindow(parent, name, fl)
26{ 26{
27 if (!name) setName("BackGammon"); 27 if (!name) setName("BackGammon");
28 setCaption(tr( "Backgammon") ); 28 setCaption(tr( "Backgammon") );
29 setIcon( Resource::loadPixmap( "backgammon" ) ); 29 setIcon( Resource::loadPixmap( "backgammon" ) );
30 //general counter varaible 30 //general counter varaible
31 int a=0; 31 int a=0;
32 //the game engine 32 //the game engine
33 move=new MoveEngine(); 33 move=new MoveEngine();
34 34
35 //load the default theme 35 //load the default theme
36 Config conf("backgammon"); 36 Config conf("backgammon");
37 if(!conf.isValid()) 37 if(!conf.isValid())
38 { 38 {
39 qDebug("config file does not exist"); 39 qDebug("config file does not exist");
40 conf.setGroup("general"); 40 conf.setGroup("general");
41 conf.writeEntry("theme","default"); 41 conf.writeEntry("theme","default");
42 conf.setGroup("rules"); 42 conf.setGroup("rules");
43 conf.writeEntry("move_with_pieces_out",false); 43 conf.writeEntry("move_with_pieces_out",false);
44 conf.writeEntry("nice_dice",false); 44 conf.writeEntry("nice_dice",false);
45 conf.setGroup("display"); 45 conf.setGroup("display");
46 conf.writeEntry("small",false); 46 conf.writeEntry("small",false);
47 conf.writeEntry("warning",true); 47 conf.writeEntry("warning",true);
48 conf.setGroup("ai"); 48 conf.setGroup("ai");
49 conf.writeEntry("rescue",6); 49 conf.writeEntry("rescue",6);
50 conf.writeEntry("eliminate",4); 50 conf.writeEntry("eliminate",4);
51 conf.writeEntry("expose",1); 51 conf.writeEntry("expose",1);
52 conf.writeEntry("protect",5); 52 conf.writeEntry("protect",5);
53 conf.writeEntry("safe",3); 53 conf.writeEntry("safe",3);
54 conf.writeEntry("empty",2); 54 conf.writeEntry("empty",2);
55 55
56 } 56 }
57 conf.setGroup("general"); 57 conf.setGroup("general");
58 theme_name=conf.readEntry("theme","default"); 58 theme_name=conf.readEntry("theme","default");
59 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 59 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme";
60 60
61 //the rules 61 //the rules
62 conf.setGroup("rules"); 62 conf.setGroup("rules");
63 rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); 63 rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false);
64 rules.generous_dice=conf.readBoolEntry("nice_dice",false); 64 rules.generous_dice=conf.readBoolEntry("nice_dice",false);
65 65
66 move->setRules(rules); 66 move->setRules(rules);
67 67
68 //get the AI settings 68 //get the AI settings
69 AISettings ai; 69 AISettings ai;
70 conf.setGroup("ai"); 70 conf.setGroup("ai");
71 ai.rescue=conf.readNumEntry("rescue",6); 71 ai.rescue=conf.readNumEntry("rescue",6);
72 ai.eliminate=conf.readNumEntry("eliminate",4); 72 ai.eliminate=conf.readNumEntry("eliminate",4);
73 ai.expose=conf.readNumEntry("expose",1); 73 ai.expose=conf.readNumEntry("expose",1);
74 ai.protect=conf.readNumEntry("protect",5); 74 ai.protect=conf.readNumEntry("protect",5);
75 ai.safe=conf.readNumEntry("safe",3); 75 ai.safe=conf.readNumEntry("safe",3);
76 ai.empty=conf.readNumEntry("empty",2); 76 ai.empty=conf.readNumEntry("empty",2);
77 move->setAISettings(ai); 77 move->setAISettings(ai);
78 78
79 79
80 //get the theme component names 80 //get the theme component names
81 Config theme(theme_file,Config::File); 81 Config theme(theme_file,Config::File);
82 if(!theme.isValid()) 82 if(!theme.isValid())
83 { 83 {
84 qDebug("theme file does not exist"); 84 qDebug("theme file does not exist");
85 theme.setGroup("theme"); 85 theme.setGroup("theme");
86 theme.writeEntry("board","casino_board_1"); 86 theme.writeEntry("board","casino_board_1");
87 theme.writeEntry("pieces1","casino_pieces_blue"); 87 theme.writeEntry("pieces1","casino_pieces_blue");
88 theme.writeEntry("pieces2","casino_pieces_white"); 88 theme.writeEntry("pieces2","casino_pieces_white");
89 theme.writeEntry("dice1","casino_dice"); 89 theme.writeEntry("dice1","casino_dice");
90 theme.writeEntry("dice2","casino_dice"); 90 theme.writeEntry("dice2","casino_dice");
91 theme.writeEntry("table","casino_table_green"); 91 theme.writeEntry("table","casino_table_green");
92 theme.writeEntry("odds","casino_odds"); 92 theme.writeEntry("odds","casino_odds");
93 } 93 }
94 theme.setGroup("theme"); 94 theme.setGroup("theme");
95 board_name=theme.readEntry("board","casino_board_1"); 95 board_name=theme.readEntry("board","casino_board_1");
96 piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); 96 piecesA_name=theme.readEntry("pieces1","casino_pieces_blue");
97 piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); 97 piecesB_name=theme.readEntry("pieces2","casino_pieces_white");
98 diceA_name=theme.readEntry("dice1","casino_dice"); 98 diceA_name=theme.readEntry("dice1","casino_dice");
99 diceB_name=theme.readEntry("dice2","casino_dice"); 99 diceB_name=theme.readEntry("dice2","casino_dice");
100 table_name=theme.readEntry("table","casino_table_green"); 100 table_name=theme.readEntry("table","casino_table_green");
101 odds_name=theme.readEntry("odds","casino_odds"); 101 odds_name=theme.readEntry("odds","casino_odds");
102 102
103 103
104 //the menu 104 //the menu
105 QPEMenuBar* menuBar = new QPEMenuBar(this); 105 QPEMenuBar* menuBar = new QPEMenuBar(this);
106 106
107 QPopupMenu* gamemenu= new QPopupMenu(this); 107 QPopupMenu* gamemenu= new QPopupMenu(this);
108 gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); 108 gamemenu->insertItem(tr( "New" ),this,SLOT(newgame()));
109 gamemenu->insertSeparator(); 109 gamemenu->insertSeparator();
110 gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); 110 gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame()));
111 gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); 111 gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame()));
112 gamemenu->insertSeparator(); 112 gamemenu->insertSeparator();
113 gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame())); 113 gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame()));
114 menuBar->insertItem(tr( "Game" ),gamemenu); 114 menuBar->insertItem(tr( "Game" ),gamemenu);
115 115
116 QPopupMenu* thememenu= new QPopupMenu(this); 116 QPopupMenu* thememenu= new QPopupMenu(this);
117 thememenu->insertItem(tr( "New" ),this,SLOT(newtheme())); 117 thememenu->insertItem(tr( "New" ),this,SLOT(newtheme()));
118 thememenu->insertSeparator(); 118 thememenu->insertSeparator();
119 thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme())); 119 thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme()));
120 thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme())); 120 thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme()));
121 thememenu->insertSeparator(); 121 thememenu->insertSeparator();
122 thememenu->insertItem(tr( "Default"),this,SLOT(themedefault())); 122 thememenu->insertItem(tr( "Default"),this,SLOT(themedefault()));
123 thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme())); 123 thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme()));
124 menuBar->insertItem(tr( "Theme" ),thememenu); 124 menuBar->insertItem(tr( "Theme" ),thememenu);
125 125
126 QPopupMenu* optionmenu=new QPopupMenu(this); 126 QPopupMenu* optionmenu=new QPopupMenu(this);
127 optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect())); 127 optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect()));
128 optionmenu->insertSeparator(); 128 optionmenu->insertSeparator();
129 optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI())); 129 optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI()));
130 optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules())); 130 optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules()));
131 menuBar->insertItem(tr( "Options"),optionmenu); 131 menuBar->insertItem(tr( "Options"),optionmenu);
132 132
133 QWidget* mainarea=new QWidget(this); 133 QWidget* mainarea=new QWidget(this);
134 setCentralWidget(mainarea); 134 setCentralWidget(mainarea);
135 //the main area 135 //the main area
136 QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); 136 QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom);
137 area=new QCanvas(235,235); 137 area=new QCanvas(235,235);
138 QColor bgColor=palette().color(QPalette::Normal,QColorGroup::Background);
139 area->setBackgroundColor(bgColor);
140 boardview=new BackGammonView(area,mainarea); 138 boardview=new BackGammonView(area,mainarea);
141 boardview->setMaximumHeight(240); 139 boardview->setMaximumHeight(240);
142 layout->addWidget(boardview); 140 layout->addWidget(boardview);
143 connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); 141 connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int)));
144 //status bar 142 //status bar
145 message=new QLabel("<b>Backgammon</b>",mainarea); 143 message=new QLabel("<b>Backgammon</b>",mainarea);
146 message->setAlignment(AlignHCenter); 144 message->setAlignment(AlignHCenter);
147 layout->addWidget(message); 145 layout->addWidget(message);
148 146
149 //the marker 147 //the marker
150 marker_current=new QCanvasRectangle(area); 148 marker_current=new QCanvasRectangle(area);
151 marker_current->setBrush(QColor(0,0,255)); 149 marker_current->setBrush(QColor(0,0,255));
152 marker_current->setSize(15,5); 150 marker_current->setSize(15,5);
153 marker_current->setZ(1); 151 marker_current->setZ(1);
154 152
155 for(a=0;a<4;a++) 153 for(a=0;a<4;a++)
156 { 154 {
157 marker_next[a]=new QCanvasRectangle(area); 155 marker_next[a]=new QCanvasRectangle(area);
158 marker_next[a]->setBrush(QColor(0,255,0)); 156 marker_next[a]->setBrush(QColor(0,255,0));
159 marker_next[a]->setSize(15,5); 157 marker_next[a]->setSize(15,5);
160 marker_next[a]->setZ(1); 158 marker_next[a]->setZ(1);
161 } 159 }
162 160
163 connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1())); 161 connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1()));
164 connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2())); 162 connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2()));
165 connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3())); 163 connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3()));
166 connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4())); 164 connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4()));
167 connect(move,SIGNAL(nomove()),this,SLOT(nomove())); 165 connect(move,SIGNAL(nomove()),this,SLOT(nomove()));
168 connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int))); 166 connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int)));
169 167
170 //the pieces 168 //the pieces
171 p1=new CanvasImageItem*[15]; 169 p1=new CanvasImageItem*[15];
172 p1_side=new CanvasImageItem*[15]; 170 p1_side=new CanvasImageItem*[15];
173 QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); 171 QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name));
174 QImage piece_1_front=piece_1_all.copy(0,0,15,15); 172 QImage piece_1_front=piece_1_all.copy(0,0,15,15);
175 QImage piece_1_side=piece_1_all.copy(0,15,15,5); 173 QImage piece_1_side=piece_1_all.copy(0,15,15,5);
176 174
177 p2=new CanvasImageItem*[15]; 175 p2=new CanvasImageItem*[15];
178 p2_side=new CanvasImageItem*[15]; 176 p2_side=new CanvasImageItem*[15];
179 QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); 177 QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name));
180 QImage piece_2_front=piece_2_all.copy(0,0,15,15); 178 QImage piece_2_front=piece_2_all.copy(0,0,15,15);
181 QImage piece_2_side=piece_2_all.copy(0,15,15,5); 179 QImage piece_2_side=piece_2_all.copy(0,15,15,5);
182 180
183 181
184 for(a=0;a<15;a++) 182 for(a=0;a<15;a++)
185 { 183 {
186 p1[a]=new CanvasImageItem(piece_1_front,area); 184 p1[a]=new CanvasImageItem(piece_1_front,area);
187 p1[a]->setSize(15,15); 185 p1[a]->setSize(15,15);
188 p1_side[a]=new CanvasImageItem(piece_1_side,area); 186 p1_side[a]=new CanvasImageItem(piece_1_side,area);
189 p1_side[a]->setSize(15,5); 187 p1_side[a]->setSize(15,5);
190 188
191 p2[a]=new CanvasImageItem(piece_2_front,area); 189 p2[a]=new CanvasImageItem(piece_2_front,area);
192 p2[a]->setSize(15,15); 190 p2[a]->setSize(15,15);
193 p2_side[a]=new CanvasImageItem(piece_2_side,area); 191 p2_side[a]=new CanvasImageItem(piece_2_side,area);
194 p2_side[a]->setSize(15,5); 192 p2_side[a]->setSize(15,5);
195 } 193 }
196 draw(); 194 draw();
197 195
198 //the dice 196 //the dice
199 QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); 197 QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name));
200 diceA1=new CanvasImageItem*[7]; 198 diceA1=new CanvasImageItem*[7];
201 diceA2=new CanvasImageItem*[7]; 199 diceA2=new CanvasImageItem*[7];
202 QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); 200 QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name));
203 diceB1=new CanvasImageItem*[7]; 201 diceB1=new CanvasImageItem*[7];
204 diceB2=new CanvasImageItem*[7]; 202 diceB2=new CanvasImageItem*[7];
205 QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); 203 QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name));
206 //oddsDice=new CanvasImageItem*[6]; 204 //oddsDice=new CanvasImageItem*[6];
207 205
208 206
209 for(a=0;a<7;a++) 207 for(a=0;a<7;a++)
210 { 208 {
211 QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); 209 QImage dicebgA=dicebgA_all.copy(a*25,0,25,25);
212 diceA1[a]=new CanvasImageItem(dicebgA,area); 210 diceA1[a]=new CanvasImageItem(dicebgA,area);
213 diceA1[a]->setX(5); 211 diceA1[a]->setX(5);
214 diceA1[a]->setY(205-2); 212 diceA1[a]->setY(205-2);
215 diceA1[a]->setZ(1); 213 diceA1[a]->setZ(1);
216 diceA1[a]->setSize(25,25); 214 diceA1[a]->setSize(25,25);
217 diceA2[a]=new CanvasImageItem(dicebgA,area); 215 diceA2[a]=new CanvasImageItem(dicebgA,area);
218 diceA2[a]->setX(35); 216 diceA2[a]->setX(35);
219 diceA2[a]->setY(205-2); 217 diceA2[a]->setY(205-2);
220 diceA2[a]->setZ(1); 218 diceA2[a]->setZ(1);
221 diceA2[a]->setSize(25,25); 219 diceA2[a]->setSize(25,25);
222 220
223 QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); 221 QImage dicebgB=dicebgB_all.copy(a*25,0,25,25);
224 diceB1[a]=new CanvasImageItem(dicebgB,area); 222 diceB1[a]=new CanvasImageItem(dicebgB,area);
225 diceB1[a]->setX(175); 223 diceB1[a]->setX(175);
226 diceB1[a]->setY(205-2); 224 diceB1[a]->setY(205-2);
227 diceB1[a]->setZ(1); 225 diceB1[a]->setZ(1);
228 diceB1[a]->setSize(25,25); 226 diceB1[a]->setSize(25,25);
229 diceB2[a]=new CanvasImageItem(dicebgB,area); 227 diceB2[a]=new CanvasImageItem(dicebgB,area);
230 diceB2[a]->setX(205); 228 diceB2[a]->setX(205);
231 diceB2[a]->setY(205-2); 229 diceB2[a]->setY(205-2);
232 diceB2[a]->setZ(1); 230 diceB2[a]->setZ(1);
233 diceB2[a]->setSize(25,25); 231 diceB2[a]->setSize(25,25);
234 232
235 /* 233 /*
236 if(a<6) 234 if(a<6)
237 { 235 {
238 QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); 236 QImage oddsbg=oddsbg_all.copy(a*15,0,15,15);
239 oddsDice[a]=new CanvasImageItem(oddsbg,area); 237 oddsDice[a]=new CanvasImageItem(oddsbg,area);
240 oddsDice[a]->setX(110); 238 oddsDice[a]->setX(110);
241 oddsDice[a]->setY(210-2); 239 oddsDice[a]->setY(210-2);
242 oddsDice[a]->setZ(1); 240 oddsDice[a]->setZ(1);
243 oddsDice[a]->setSize(15,15); 241 oddsDice[a]->setSize(15,15);
244 oddsDice[a]->hide(); 242 oddsDice[a]->hide();
245 } 243 }
246 */ 244 */
247 } 245 }
248 //oddsDice[0]->show(); 246 //oddsDice[0]->show();
249 247
250 //set the board 248 //set the board
251 QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); 249 QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name));
252 board=new CanvasImageItem(boardbg,area); 250 board=new CanvasImageItem(boardbg,area);
253 board->setX(0); 251 board->setX(0);
254 board->setY(0); 252 board->setY(0);
255 board->setZ(0); 253 board->setZ(0);
256 board->setSize(235-2,200-2); 254 board->setSize(235-2,200-2);
257 board->show(); 255 board->show();
258 256
259 //the table 257 //the table
260 QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); 258 QImage tablebg(Resource::loadImage("backgammon/table/"+table_name));
261 table=new CanvasImageItem(tablebg,area); 259 table=new CanvasImageItem(tablebg,area);
262 table->setX(0); 260 table->setX(0);
263 table->setY(200-2); 261 table->setY(200-2);
264 table->setZ(0); 262 table->setZ(0);
265 table->setSize(235-2,20); 263 table->setSize(235-2,20);
266 table->show(); 264 table->show();
267 265
268 //the no move marker 266 //the no move marker
269 QImage nomovebg(Resource::loadImage("backgammon/no_move")); 267 QImage nomovebg(Resource::loadImage("backgammon/no_move"));
270 nomove_marker=new CanvasImageItem(nomovebg,area); 268 nomove_marker=new CanvasImageItem(nomovebg,area);
271 nomove_marker->setX(0); 269 nomove_marker->setX(0);
272 nomove_marker->setY(200); 270 nomove_marker->setY(200);
273 nomove_marker->setZ(2); 271 nomove_marker->setZ(2);
274 nomove_marker->hide(); 272 nomove_marker->hide();
275 273
276 //default human against computer 274 //default human against computer
277 player1_auto=false; 275 player1_auto=false;
278 player2_auto=true; 276 player2_auto=true;
279 //start new game 277 //start new game
280 newgame(); 278 newgame();
281} 279}
282 280
283BackGammon::~BackGammon() 281BackGammon::~BackGammon()
284{ 282{
285 //DESTRUCTOR 283 //DESTRUCTOR
286} 284}
287 285
288void BackGammon::newgame() 286void BackGammon::newgame()
289{ 287{
290 gameFinished=false; 288 gameFinished=false;
291 QDateTime now=QDateTime::currentDateTime(); 289 QDateTime now=QDateTime::currentDateTime();
292 game_name=now.date().toString()+"_"+now.time().toString(); 290 game_name=now.date().toString()+"_"+now.time().toString();
293 move->reset(); 291 move->reset();
294 draw(); 292 draw();
295 diceA1_value=7; 293 diceA1_value=7;
296 diceA2_value=7; 294 diceA2_value=7;
297 diceA3_value=7; 295 diceA3_value=7;
298 diceA4_value=7; 296 diceA4_value=7;
299 diceB1_value=7; 297 diceB1_value=7;
300 diceB2_value=7; 298 diceB2_value=7;
301 diceB3_value=7; 299 diceB3_value=7;
302 diceB4_value=7; 300 diceB4_value=7;
303 showdice(); 301 showdice();
304 player=2; 302 player=2;
305 dice1_played=true; 303 dice1_played=true;
306 dice2_played=true; 304 dice2_played=true;
307 dice3_played=true; 305 dice3_played=true;
308 dice4_played=true; 306 dice4_played=true;
309 dice_rolled=false; 307 dice_rolled=false;
310 setplayer(); 308 setplayer();
311 area->update(); 309 area->update();
312} 310}
313 311
314void BackGammon::playerselect() 312void BackGammon::playerselect()
315{ 313{
316 PlayerDialog* playerdialog=new PlayerDialog(this); 314 PlayerDialog* playerdialog=new PlayerDialog(this);
317 playerdialog->setAuto1(player1_auto); 315 playerdialog->setAuto1(player1_auto);
318 playerdialog->setAuto2(player2_auto); 316 playerdialog->setAuto2(player2_auto);
319 if(!playerdialog->exec()) 317 if(!playerdialog->exec())
320 return; 318 return;
321 player1_auto=playerdialog->getAuto1(); 319 player1_auto=playerdialog->getAuto1();
322 player2_auto=playerdialog->getAuto2(); 320 player2_auto=playerdialog->getAuto2();
323} 321}
324 322
325void BackGammon::loadgame() 323void BackGammon::loadgame()
326{ 324{
327 FileDialog* file=new FileDialog(this,"Load Game",".game"); 325 FileDialog* file=new FileDialog(this,"Load Game",".game");
328 if(!file->exec()) 326 if(!file->exec())
329 return; 327 return;
330 328
331 game_name=file->filename(); 329 game_name=file->filename();
332 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; 330 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game";
333 331
334 Config game(game_file,Config::File); 332 Config game(game_file,Config::File);
335 game.setGroup("dice"); 333 game.setGroup("dice");
336 diceA1_value=game.readNumEntry("diceA1_value"); 334 diceA1_value=game.readNumEntry("diceA1_value");
337 diceA2_value=game.readNumEntry("diceA2_value"); 335 diceA2_value=game.readNumEntry("diceA2_value");
338 diceA3_value=game.readNumEntry("diceA3_value"); 336 diceA3_value=game.readNumEntry("diceA3_value");
339 diceA4_value=game.readNumEntry("diceA4_value"); 337 diceA4_value=game.readNumEntry("diceA4_value");
340 diceB1_value=game.readNumEntry("diceB1_value"); 338 diceB1_value=game.readNumEntry("diceB1_value");
341 diceB2_value=game.readNumEntry("diceB2_value"); 339 diceB2_value=game.readNumEntry("diceB2_value");
342 diceB3_value=game.readNumEntry("diceB3_value"); 340 diceB3_value=game.readNumEntry("diceB3_value");
343 diceB4_value=game.readNumEntry("diceB4_value"); 341 diceB4_value=game.readNumEntry("diceB4_value");
344 player=game.readNumEntry("player"); 342 player=game.readNumEntry("player");
345 dice1_played=game.readBoolEntry("dice1_played"); 343 dice1_played=game.readBoolEntry("dice1_played");
346 dice2_played=game.readBoolEntry("dice2_played"); 344 dice2_played=game.readBoolEntry("dice2_played");
347 dice3_played=game.readBoolEntry("dice3_played"); 345 dice3_played=game.readBoolEntry("dice3_played");
348 dice4_played=game.readBoolEntry("dice4_played"); 346 dice4_played=game.readBoolEntry("dice4_played");
349 dice_rolled=game.readBoolEntry("dice_rolled"); 347 dice_rolled=game.readBoolEntry("dice_rolled");
350 player1_auto=game.readBoolEntry("player1_auto"); 348 player1_auto=game.readBoolEntry("player1_auto");
351 player2_auto=game.readBoolEntry("player2_auto"); 349 player2_auto=game.readBoolEntry("player2_auto");
352 350
353 game.setGroup("pieces"); 351 game.setGroup("pieces");
354 QString label; 352 QString label;
355 LoadSave load; 353 LoadSave load;
356 for(int a=0;a<28;a++) 354 for(int a=0;a<28;a++)
357 { 355 {
358 label.setNum(a); 356 label.setNum(a);
359 load.pop[a].total = game.readNumEntry(label,0); 357 load.pop[a].total = game.readNumEntry(label,0);
360 } 358 }
361 359
362 move->loadGame(load); 360 move->loadGame(load);
363 setplayer(); 361 setplayer();
364 showdice(); 362 showdice();
365 draw(); 363 draw();
366 area->update(); 364 area->update();
367} 365}
368 366
369void BackGammon::savegame() 367void BackGammon::savegame()
370{ 368{
371 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; 369 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game";
372 370
373 Config game(game_file,Config::File); 371 Config game(game_file,Config::File);
374 game.setGroup("dice"); 372 game.setGroup("dice");
375 game.writeEntry("diceA1_value",diceA1_value); 373 game.writeEntry("diceA1_value",diceA1_value);
376 game.writeEntry("diceA2_value",diceA2_value); 374 game.writeEntry("diceA2_value",diceA2_value);
377 game.writeEntry("diceA3_value",diceA3_value); 375 game.writeEntry("diceA3_value",diceA3_value);
378 game.writeEntry("diceA4_value",diceA4_value); 376 game.writeEntry("diceA4_value",diceA4_value);
379 game.writeEntry("diceB1_value",diceB1_value); 377 game.writeEntry("diceB1_value",diceB1_value);
380 game.writeEntry("diceB2_value",diceB3_value); 378 game.writeEntry("diceB2_value",diceB3_value);
381 game.writeEntry("diceB3_value",diceB4_value); 379 game.writeEntry("diceB3_value",diceB4_value);
382 game.writeEntry("diceB4_value",diceB4_value); 380 game.writeEntry("diceB4_value",diceB4_value);
383 game.writeEntry("player",player); 381 game.writeEntry("player",player);
384 game.writeEntry("dice1_played",dice1_played); 382 game.writeEntry("dice1_played",dice1_played);
385 game.writeEntry("dice2_played",dice2_played); 383 game.writeEntry("dice2_played",dice2_played);
386 game.writeEntry("dice3_played",dice3_played); 384 game.writeEntry("dice3_played",dice3_played);
387 game.writeEntry("dice4_played",dice4_played); 385 game.writeEntry("dice4_played",dice4_played);
388 game.writeEntry("dice_rolled",dice_rolled); 386 game.writeEntry("dice_rolled",dice_rolled);
389 game.writeEntry("player1_auto",player1_auto); 387 game.writeEntry("player1_auto",player1_auto);
390 game.writeEntry("player2_auto",player2_auto); 388 game.writeEntry("player2_auto",player2_auto);
391 389
392 game.setGroup("pieces"); 390 game.setGroup("pieces");
393 QString label; 391 QString label;
394 LoadSave save=move->saveGame(); 392 LoadSave save=move->saveGame();
395 for(int a=0;a<28;a++) 393 for(int a=0;a<28;a++)
396 { 394 {
397 label.setNum(a); 395 label.setNum(a);
398 game.writeEntry(label,save.pop[a].total); 396 game.writeEntry(label,save.pop[a].total);
399 } 397 }
400 QMessageBox::information(this,"Backgammon","Game saved","OK"); 398 QMessageBox::information(this,"Backgammon","Game saved","OK");
401} 399}
402 400
403void BackGammon::deletegame() 401void BackGammon::deletegame()
404{ 402{
405 FileDialog* file=new FileDialog(this,"Delete Game",".game"); 403 FileDialog* file=new FileDialog(this,"Delete Game",".game");
406 if(!file->exec()) 404 if(!file->exec())
407 return; 405 return;
408 406
409 game_name=file->filename(); 407 game_name=file->filename();
410 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; 408 QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game";
411 409
412 if(!QMessageBox::warning(this,"Backgammon","deleted game\n"+game_name+" ?","OK","Cancel")) 410 if(!QMessageBox::warning(this,"Backgammon","deleted game\n"+game_name+" ?","OK","Cancel"))
413 { 411 {
414 QFile(game_file).remove(); 412 QFile(game_file).remove();
415 } 413 }
416} 414}
417 415
418 416
419void BackGammon::newtheme() 417void BackGammon::newtheme()
420{ 418{
421 ThemeDialog* theme=new ThemeDialog(this); 419 ThemeDialog* theme=new ThemeDialog(this);
422 420
423 ImageNames names; 421 ImageNames names;
424 names.theme=theme_name; 422 names.theme=theme_name;
425 names.board=board_name; 423 names.board=board_name;
426 names.pieces1=piecesA_name; 424 names.pieces1=piecesA_name;
427 names.pieces2=piecesB_name; 425 names.pieces2=piecesB_name;
428 names.dice1=diceA_name; 426 names.dice1=diceA_name;
429 names.dice2=diceB_name; 427 names.dice2=diceB_name;
430 names.odds=odds_name; 428 names.odds=odds_name;
431 names.table=table_name; 429 names.table=table_name;
432 430
433 theme->setCurrent(names); 431 theme->setCurrent(names);
434 if(!theme->exec()) 432 if(!theme->exec())
435 return; 433 return;
436 434
437 names=theme->getNames(); 435 names=theme->getNames();
438 theme_name=names.theme; 436 theme_name=names.theme;
439 board_name=names.board; 437 board_name=names.board;
440 piecesA_name=names.pieces1; 438 piecesA_name=names.pieces1;
441 piecesB_name=names.pieces2; 439 piecesB_name=names.pieces2;
442 diceA_name=names.dice1; 440 diceA_name=names.dice1;
443 diceB_name=names.dice2; 441 diceB_name=names.dice2;
444 odds_name=names.odds; 442 odds_name=names.odds;
445 table_name=names.table; 443 table_name=names.table;
446 444
447 applytheme(); 445 applytheme();
448} 446}
449 447
450void BackGammon::loadtheme() 448void BackGammon::loadtheme()
451{ 449{
452 FileDialog* file=new FileDialog(this,"Load Theme",".theme"); 450 FileDialog* file=new FileDialog(this,"Load Theme",".theme");
453 if(!file->exec()) 451 if(!file->exec())
454 return; 452 return;
455 453
456 theme_name=file->filename(); 454 theme_name=file->filename();
457 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 455 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme";
458 456
459 Config theme(theme_file,Config::File); 457 Config theme(theme_file,Config::File);
460 theme.setGroup("theme"); 458 theme.setGroup("theme");
461 board_name=theme.readEntry("board","board_1"); 459 board_name=theme.readEntry("board","board_1");
462 piecesA_name=theme.readEntry("pieces1","pieces_1"); 460 piecesA_name=theme.readEntry("pieces1","pieces_1");
463 piecesB_name=theme.readEntry("pieces2","pieces_2"); 461 piecesB_name=theme.readEntry("pieces2","pieces_2");
464 diceA_name=theme.readEntry("dice1","dice_1"); 462 diceA_name=theme.readEntry("dice1","dice_1");
465 diceB_name=theme.readEntry("dice2","dice_2"); 463 diceB_name=theme.readEntry("dice2","dice_2");
466 table_name=theme.readEntry("table","table_1"); 464 table_name=theme.readEntry("table","table_1");
467 odds_name=theme.readEntry("odds","odds_1"); 465 odds_name=theme.readEntry("odds","odds_1");
468 466
469 applytheme(); 467 applytheme();
470 468
471} 469}
472 470
473void BackGammon::savetheme() 471void BackGammon::savetheme()
474{ 472{
475 if(theme_name=="default") 473 if(theme_name=="default")
476 { 474 {
477 QMessageBox::information(this,"Backgammon","Sorry\nCannot overwrite default.theme","OK"); 475 QMessageBox::information(this,"Backgammon","Sorry\nCannot overwrite default.theme","OK");
478 return; 476 return;
479 } 477 }
480 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 478 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme";
481 if(QMessageBox::information(this,"Backgammon","Save Theme\n"+theme_name,"Yes","No")) 479 if(QMessageBox::information(this,"Backgammon","Save Theme\n"+theme_name,"Yes","No"))
482 return; 480 return;
483 481
484 Config theme(theme_file,Config::File); 482 Config theme(theme_file,Config::File);
485 theme.setGroup("theme"); 483 theme.setGroup("theme");
486 theme.writeEntry("board",board_name); 484 theme.writeEntry("board",board_name);
487 theme.writeEntry("pieces1",piecesA_name); 485 theme.writeEntry("pieces1",piecesA_name);
488 theme.writeEntry("pieces2",piecesB_name); 486 theme.writeEntry("pieces2",piecesB_name);
489 theme.writeEntry("dice1",diceA_name); 487 theme.writeEntry("dice1",diceA_name);
490 theme.writeEntry("dice2",diceB_name); 488 theme.writeEntry("dice2",diceB_name);
491 theme.writeEntry("table",table_name); 489 theme.writeEntry("table",table_name);
492 theme.writeEntry("odds",odds_name); 490 theme.writeEntry("odds",odds_name);
493 491
494} 492}
495 493
496void BackGammon::themedefault() 494void BackGammon::themedefault()
497{ 495{
498 if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No")) 496 if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No"))
499 return; 497 return;
500 498
501 Config conf("backgammon"); 499 Config conf("backgammon");
502 conf.setGroup("general"); 500 conf.setGroup("general");
503 conf.writeEntry("theme",theme_name); 501 conf.writeEntry("theme",theme_name);
504} 502}
505 503
506void BackGammon::deletetheme() 504void BackGammon::deletetheme()
507{ 505{
508 FileDialog* file=new FileDialog(this,"Delete Theme",".theme"); 506 FileDialog* file=new FileDialog(this,"Delete Theme",".theme");
509 if(!file->exec()) 507 if(!file->exec())
510 return; 508 return;
511 509
512 theme_name=file->filename(); 510 theme_name=file->filename();
513 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 511 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme";
514 512
515 if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" ))) 513 if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" )))
516 { 514 {
517 QFile(theme_file).remove(); 515 QFile(theme_file).remove();
518 } 516 }
519} 517}
520 518
521void BackGammon::modify_AI() 519void BackGammon::modify_AI()
522{ 520{
523 AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme"); 521 AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme");
524 ai_mod->setAISettings(move->getAISettings()); 522 ai_mod->setAISettings(move->getAISettings());
525 if(!ai_mod->exec()) 523 if(!ai_mod->exec())
526 return; 524 return;
527 525
528 //get the AI settings 526 //get the AI settings
529 AISettings ai=ai_mod->getAISettings(); 527 AISettings ai=ai_mod->getAISettings();
530 move->setAISettings(ai); 528 move->setAISettings(ai);
531 //write new settings to conf file 529 //write new settings to conf file
532 Config conf("backgammon"); 530 Config conf("backgammon");
533 conf.setGroup("ai"); 531 conf.setGroup("ai");
534 conf.writeEntry("rescue",ai.rescue); 532 conf.writeEntry("rescue",ai.rescue);
535 conf.writeEntry("eliminate",ai.eliminate); 533 conf.writeEntry("eliminate",ai.eliminate);
536 conf.writeEntry("expose",ai.expose); 534 conf.writeEntry("expose",ai.expose);
537 conf.writeEntry("protect",ai.protect); 535 conf.writeEntry("protect",ai.protect);
538 conf.writeEntry("safe",ai.safe); 536 conf.writeEntry("safe",ai.safe);
539 conf.writeEntry("empty",ai.empty); 537 conf.writeEntry("empty",ai.empty);
540} 538}
541 539
542void BackGammon::setrules() 540void BackGammon::setrules()
543{ 541{
544 RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme"); 542 RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme");
545 rulesdialog->setRules(rules); 543 rulesdialog->setRules(rules);
546 if(!rulesdialog->exec()) 544 if(!rulesdialog->exec())
547 return; 545 return;
548 rules=rulesdialog->getRules(); 546 rules=rulesdialog->getRules();
549 Config conf("backgammon"); 547 Config conf("backgammon");
550 conf.setGroup("rules"); 548 conf.setGroup("rules");
551 conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out); 549 conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out);
552 conf.writeEntry("nice_dice",rules.generous_dice); 550 conf.writeEntry("nice_dice",rules.generous_dice);
553 move->setRules(rules); 551 move->setRules(rules);
554} 552}
555 553
556 554
557void BackGammon::draw() 555void BackGammon::draw()
558{ 556{
559 Pieces pieces; 557 Pieces pieces;
560 move->position(pieces); 558 move->position(pieces);
561 for(int a=0;a<15;a++) 559 for(int a=0;a<15;a++)
562 { 560 {
563 if(!pieces.player1[a].side) 561 if(!pieces.player1[a].side)
564 { 562 {
565 p1[a]->setX(pieces.player1[a].x); 563 p1[a]->setX(pieces.player1[a].x);
566 p1[a]->setY(pieces.player1[a].y); 564 p1[a]->setY(pieces.player1[a].y);
567 p1[a]->setZ(pieces.player1[a].z); 565 p1[a]->setZ(pieces.player1[a].z);
568 p1[a]->show(); 566 p1[a]->show();
569 p1_side[a]->hide(); 567 p1_side[a]->hide();
570 } 568 }
571 else 569 else
572 { 570 {
573 p1_side[a]->setX(pieces.player1[a].x); 571 p1_side[a]->setX(pieces.player1[a].x);
574 p1_side[a]->setY(pieces.player1[a].y); 572 p1_side[a]->setY(pieces.player1[a].y);
575 p1_side[a]->setZ(pieces.player1[a].z); 573 p1_side[a]->setZ(pieces.player1[a].z);
576 p1_side[a]->show(); 574 p1_side[a]->show();
577 p1[a]->hide(); 575 p1[a]->hide();
578 } 576 }
579 577
580 if(!pieces.player2[a].side) 578 if(!pieces.player2[a].side)
581 { 579 {
582 p2[a]->setX(pieces.player2[a].x); 580 p2[a]->setX(pieces.player2[a].x);
583 p2[a]->setY(pieces.player2[a].y); 581 p2[a]->setY(pieces.player2[a].y);
584 p2[a]->setZ(pieces.player2[a].z); 582 p2[a]->setZ(pieces.player2[a].z);
585 p2[a]->show(); 583 p2[a]->show();
586 p2_side[a]->hide(); 584 p2_side[a]->hide();
587 } 585 }
588 else 586 else
589 { 587 {
590 p2_side[a]->setX(pieces.player2[a].x); 588 p2_side[a]->setX(pieces.player2[a].x);
591 p2_side[a]->setY(pieces.player2[a].y); 589 p2_side[a]->setY(pieces.player2[a].y);
592 p2_side[a]->setZ(pieces.player2[a].z); 590 p2_side[a]->setZ(pieces.player2[a].z);
593 p2_side[a]->show(); 591 p2_side[a]->show();
594 p2[a]->hide(); 592 p2[a]->hide();
595 } 593 }
596 } 594 }
597} 595}
598 596
599void BackGammon::mouse(int x,int y) 597void BackGammon::mouse(int x,int y)
600{ 598{
601 if(gameFinished) 599 if(gameFinished)
602 { 600 {
603 newgame(); 601 newgame();
604 return; 602 return;
605 } 603 }
606 if(y<=200) //move pieces 604 if(y<=200) //move pieces
607 { 605 {
608 if((player==1 && player1_auto) || (player==2 && player2_auto)) 606 if((player==1 && player1_auto) || (player==2 && player2_auto))
609 return; 607 return;
610 608
611 Marker marker; 609 Marker marker;
612 610
613 move->boardpressed(x,y,marker); 611 move->boardpressed(x,y,marker);
614 if(marker.visible_current) 612 if(marker.visible_current)
615 { 613 {
616 marker_current->setX(marker.x_current); 614 marker_current->setX(marker.x_current);
617 marker_current->setY(marker.y_current); 615 marker_current->setY(marker.y_current);
618 marker_current->show(); 616 marker_current->show();
619 } 617 }
620 else 618 else
621 { 619 {
622 marker_current->hide(); 620 marker_current->hide();
623 } 621 }
624 622
625 for(int a=0;a<4;a++) 623 for(int a=0;a<4;a++)
626 { 624 {
627 if(marker.visible_next[a]) 625 if(marker.visible_next[a])
628 { 626 {
629 marker_next[a]->setX(marker.x_next[a]); 627 marker_next[a]->setX(marker.x_next[a]);
630 marker_next[a]->setY(marker.y_next[a]); 628 marker_next[a]->setY(marker.y_next[a]);
631 marker_next[a]->show(); 629 marker_next[a]->show();
632 } 630 }
633 else 631 else
634 { 632 {
635 marker_next[a]->hide(); 633 marker_next[a]->hide();
636 } 634 }
637 } 635 }
638 area->update(); 636 area->update();
639 } 637 }
640 else //roll dice 638 else //roll dice
641 { 639 {
642 if(x>=10 && x<=65 && player==1 && !dice_rolled) 640 if(x>=10 && x<=65 && player==1 && !dice_rolled)
643 { 641 {
644 dice1_played=false; 642 dice1_played=false;
645 dice2_played=false; 643 dice2_played=false;
646 dice3_played=false; 644 dice3_played=false;
647 dice4_played=false; 645 dice4_played=false;
648 dice_rolled=true; 646 dice_rolled=true;
649 srand(QTime::currentTime().msec()); 647 srand(QTime::currentTime().msec());
650 diceA1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 648 diceA1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
651 diceA2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 649 diceA2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
652 if(diceA1_value==diceA2_value) 650 if(diceA1_value==diceA2_value)
653 { 651 {
654 diceA3_value=diceA1_value; 652 diceA3_value=diceA1_value;
655 diceA4_value=diceA1_value; 653 diceA4_value=diceA1_value;
656 } 654 }
657 else 655 else
658 { 656 {
659 diceA3_value=7; 657 diceA3_value=7;
660 dice3_played=true; 658 dice3_played=true;
661 diceA4_value=7; 659 diceA4_value=7;
662 dice4_played=true; 660 dice4_played=true;
663 } 661 }
664 showdice(); 662 showdice();
665 area->update(); 663 area->update();
666 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto); 664 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
667 665
668 } 666 }
669 else if(x>=160 && x<=225 && player==2 && !dice_rolled) 667 else if(x>=160 && x<=225 && player==2 && !dice_rolled)
670 { 668 {
671 dice1_played=false; 669 dice1_played=false;
672 dice2_played=false; 670 dice2_played=false;
673 dice3_played=false; 671 dice3_played=false;
674 dice4_played=false; 672 dice4_played=false;
675 dice_rolled=true; 673 dice_rolled=true;
676 srand(QTime::currentTime().msec()); 674 srand(QTime::currentTime().msec());
677 diceB1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 675 diceB1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
678 diceB2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); 676 diceB2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0));
679 if(diceB1_value==diceB2_value) 677 if(diceB1_value==diceB2_value)
680 { 678 {
681 diceB3_value=diceB1_value; 679 diceB3_value=diceB1_value;
682 diceB4_value=diceB1_value; 680 diceB4_value=diceB1_value;
683 } 681 }
684 else 682 else
685 { 683 {
686 diceB3_value=7; 684 diceB3_value=7;
687 dice3_played=true; 685 dice3_played=true;
688 diceB4_value=7; 686 diceB4_value=7;
689 dice4_played=true; 687 dice4_played=true;
690 } 688 }
691 showdice(); 689 showdice();
692 area->update(); 690 area->update();
693 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto); 691 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
694 } 692 }
695 } 693 }
696} 694}
697 695
698void BackGammon::done_dice1() 696void BackGammon::done_dice1()
699{ 697{
700 dice1_played=true; 698 dice1_played=true;
701 if(player==1) 699 if(player==1)
702 diceA1_value=7; 700 diceA1_value=7;
703 else 701 else
704 diceB1_value=7; 702 diceB1_value=7;
705 setplayer(); 703 setplayer();
706 showdice(); 704 showdice();
707 draw(); 705 draw();
708 area->update(); 706 area->update();
709 if(!dice2_played || !dice3_played || !dice4_played) 707 if(!dice2_played || !dice3_played || !dice4_played)
710 { 708 {
711 if(player==1) 709 if(player==1)
712 { 710 {
713 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto); 711 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
714 } 712 }
715 else 713 else
716 { 714 {
717 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto); 715 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
718 } 716 }
719 } 717 }
720} 718}
721 719
722void BackGammon::done_dice2() 720void BackGammon::done_dice2()
723{ 721{
724 dice2_played=true; 722 dice2_played=true;
725 if(player==1) 723 if(player==1)
726 diceA2_value=7; 724 diceA2_value=7;
727 else 725 else
728 diceB2_value=7; 726 diceB2_value=7;
729 setplayer(); 727 setplayer();
730 showdice(); 728 showdice();
731 draw(); 729 draw();
732 area->update(); 730 area->update();
733 if(!dice1_played || !dice3_played || !dice4_played) 731 if(!dice1_played || !dice3_played || !dice4_played)
734 { 732 {
735 if(player==1) 733 if(player==1)
736 { 734 {
737 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto); 735 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
738 } 736 }
739 else 737 else
740 { 738 {
741 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto); 739 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
742 } 740 }
743 } 741 }
744} 742}
745 743
746 744
747void BackGammon::done_dice3() 745void BackGammon::done_dice3()
748{ 746{
749 dice3_played=true; 747 dice3_played=true;
750 if(player==1) 748 if(player==1)
751 diceA3_value=7; 749 diceA3_value=7;
752 else 750 else
753 diceB3_value=7; 751 diceB3_value=7;
754 setplayer(); 752 setplayer();
755 showdice(); 753 showdice();
756 draw(); 754 draw();
757 area->update(); 755 area->update();
758 if(!dice1_played || !dice2_played || !dice4_played) 756 if(!dice1_played || !dice2_played || !dice4_played)
759 { 757 {
760 if(player==1) 758 if(player==1)
761 { 759 {
762 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto); 760 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
763 } 761 }
764 else 762 else
765 { 763 {
766 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto); 764 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
767 } 765 }
768 } 766 }
769} 767}
770 768
771 769
772void BackGammon::done_dice4() 770void BackGammon::done_dice4()
773{ 771{
774 dice4_played=true; 772 dice4_played=true;
775 if(player==1) 773 if(player==1)
776 diceA4_value=7; 774 diceA4_value=7;
777 else 775 else
778 diceB4_value=7; 776 diceB4_value=7;
779 setplayer(); 777 setplayer();
780 showdice(); 778 showdice();
781 draw(); 779 draw();
782 area->update(); 780 area->update();
783 if(!dice1_played || !dice2_played || !dice3_played) 781 if(!dice1_played || !dice2_played || !dice3_played)
784 { 782 {
785 if(player==1) 783 if(player==1)
786 { 784 {
787 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto); 785 move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
788 } 786 }
789 else 787 else
790 { 788 {
791 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto); 789 move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
792 } 790 }
793 } 791 }
794} 792}
795 793
796 794
797void BackGammon::nomove() 795void BackGammon::nomove()
798{ 796{
799 if(player==1) 797 if(player==1)
800 nomove_marker->setX(0); 798 nomove_marker->setX(0);
801 else 799 else
802 nomove_marker->setX(170); 800 nomove_marker->setX(170);
803 nomove_marker->show(); 801 nomove_marker->show();
804 message->setText(tr( "<b>no move</b>" )); 802 message->setText(tr( "<b>no move</b>" ));
805 dice1_played=true; 803 dice1_played=true;
806 dice2_played=true; 804 dice2_played=true;
807 dice3_played=true; 805 dice3_played=true;
808 dice4_played=true; 806 dice4_played=true;
809 if(player==1) 807 if(player==1)
810 { 808 {
811 diceA1_value=7; 809 diceA1_value=7;
812 diceA2_value=7; 810 diceA2_value=7;
813 diceA3_value=7; 811 diceA3_value=7;
814 diceA4_value=7; 812 diceA4_value=7;
815 } 813 }
816 else 814 else
817 { 815 {
818 diceB1_value=7; 816 diceB1_value=7;
819 diceB2_value=7; 817 diceB2_value=7;
820 diceB3_value=7; 818 diceB3_value=7;
821 diceB4_value=7; 819 diceB4_value=7;
822 } 820 }
823 area->update(); 821 area->update();
824 QTimer::singleShot(2000,this,SLOT(nomove2())); 822 QTimer::singleShot(2000,this,SLOT(nomove2()));
825} 823}
826 824
827void BackGammon::nomove2() 825void BackGammon::nomove2()
828{ 826{
829 nomove_marker->hide(); 827 nomove_marker->hide();
830 setplayer(); 828 setplayer();
831 showdice(); 829 showdice();
832 draw(); 830 draw();
833 area->update(); 831 area->update();
834} 832}
835 833
836void BackGammon::finished(int theplayer) 834void BackGammon::finished(int theplayer)
837{ 835{
838 nomove_marker->hide(); 836 nomove_marker->hide();
839 if(theplayer==1) 837 if(theplayer==1)
840 message->setText(tr( "<b>Player 1 wins. Click on board for new game.</b>" )); 838 message->setText(tr( "<b>Player 1 wins. Click on board for new game.</b>" ));
841 else 839 else
842 message->setText(tr( "<b>Player 2 wins. Click on board for new game.</b>" )); 840 message->setText(tr( "<b>Player 2 wins. Click on board for new game.</b>" ));
843 diceA1_value=7; 841 diceA1_value=7;
844 diceA2_value=7; 842 diceA2_value=7;
845 diceB1_value=7; 843 diceB1_value=7;
846 diceB2_value=7; 844 diceB2_value=7;
847 player=0; 845 player=0;
848 showdice(); 846 showdice();
849 draw(); 847 draw();
850 area->update(); 848 area->update();
851 gameFinished=true; 849 gameFinished=true;
852} 850}
853 851
854void BackGammon::showdice() 852void BackGammon::showdice()
855{ 853{
856 int value_diceA1=diceA1_value-1; 854 int value_diceA1=diceA1_value-1;
857 if(diceA1_value==7 && diceA3_value!=7) 855 if(diceA1_value==7 && diceA3_value!=7)
858 value_diceA1=diceA3_value-1; 856 value_diceA1=diceA3_value-1;
859 857
860 int value_diceA2=diceA2_value-1; 858 int value_diceA2=diceA2_value-1;
861 if(diceA2_value==7 && diceA4_value!=7) 859 if(diceA2_value==7 && diceA4_value!=7)
862 value_diceA2=diceA4_value-1; 860 value_diceA2=diceA4_value-1;
863 861
864 int value_diceB1=diceB1_value-1; 862 int value_diceB1=diceB1_value-1;
865 if(diceB1_value==7 && diceB3_value!=7) 863 if(diceB1_value==7 && diceB3_value!=7)
866 value_diceB1=diceB3_value-1; 864 value_diceB1=diceB3_value-1;
867 865
868 int value_diceB2=diceB2_value-1; 866 int value_diceB2=diceB2_value-1;
869 if(diceB2_value==7 && diceB4_value!=7) 867 if(diceB2_value==7 && diceB4_value!=7)
870 value_diceB2=diceB4_value-1; 868 value_diceB2=diceB4_value-1;
871 869
872 for(int index=0;index<7;index++) 870 for(int index=0;index<7;index++)
873 { 871 {
874 if(value_diceA1==index) 872 if(value_diceA1==index)
875 diceA1[index]->show(); 873 diceA1[index]->show();
876 else 874 else
877 diceA1[index]->hide(); 875 diceA1[index]->hide();
878 876
879 if(value_diceA2==index) 877 if(value_diceA2==index)
880 diceA2[index]->show(); 878 diceA2[index]->show();
881 else 879 else
882 diceA2[index]->hide(); 880 diceA2[index]->hide();
883 881
884 if(value_diceB1==index) 882 if(value_diceB1==index)
885 diceB1[index]->show(); 883 diceB1[index]->show();
886 else 884 else
887 diceB1[index]->hide(); 885 diceB1[index]->hide();
888 886
889 if(value_diceB2==index) 887 if(value_diceB2==index)
890 diceB2[index]->show(); 888 diceB2[index]->show();
891 else 889 else
892 diceB2[index]->hide(); 890 diceB2[index]->hide();
893 } 891 }
894} 892}
895 893
896void BackGammon::setplayer() 894void BackGammon::setplayer()
897{ 895{
898 if(dice1_played && dice2_played && dice3_played && dice4_played && player==1) 896 if(dice1_played && dice2_played && dice3_played && dice4_played && player==1)
899 { 897 {
900 message->setText(tr( "<b>P2 turn</b>", "P means player" )); 898 message->setText(tr( "<b>P2 turn</b>", "P means player" ));
901 dice_rolled=false; 899 dice_rolled=false;
902 player=2; 900 player=2;
903 if(player2_auto) 901 if(player2_auto)
904 QTimer::singleShot(2000,this,SLOT(autoroll_dice2())); 902 QTimer::singleShot(2000,this,SLOT(autoroll_dice2()));
905 } 903 }
906 else if(dice1_played && dice2_played && dice3_played && dice4_played && player==2) 904 else if(dice1_played && dice2_played && dice3_played && dice4_played && player==2)
907 { 905 {
908 message->setText(tr( "<b>P1 turn</b>", "P means player" )); 906 message->setText(tr( "<b>P1 turn</b>", "P means player" ));
909 dice_rolled=false; 907 dice_rolled=false;
910 player=1; 908 player=1;
911 if(player1_auto) 909 if(player1_auto)
912 QTimer::singleShot(2000,this,SLOT(autoroll_dice1())); 910 QTimer::singleShot(2000,this,SLOT(autoroll_dice1()));
913 } 911 }
914} 912}
915 913
916void BackGammon::autoroll_dice1() 914void BackGammon::autoroll_dice1()
917{ 915{
918 mouse(20,210); 916 mouse(20,210);
919} 917}
920 918
921void BackGammon::autoroll_dice2() 919void BackGammon::autoroll_dice2()
922{ 920{
923 mouse(170,210); 921 mouse(170,210);
924} 922}
925 923
926void BackGammon::applytheme() 924void BackGammon::applytheme()
927{ 925{
928 QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); 926 QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name));
929 board->setImage(boardbg); 927 board->setImage(boardbg);
930 928
931 QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); 929 QImage tablebg(Resource::loadImage("backgammon/table/"+table_name));
932 table->setImage(tablebg); 930 table->setImage(tablebg);
933 931
934 QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); 932 QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name));
935 QImage piece_1_front=piece_1_all.copy(0,0,15,15); 933 QImage piece_1_front=piece_1_all.copy(0,0,15,15);
936 QImage piece_1_side=piece_1_all.copy(0,15,15,5); 934 QImage piece_1_side=piece_1_all.copy(0,15,15,5);
937 935
938 QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); 936 QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name));
939 QImage piece_2_front=piece_2_all.copy(0,0,15,15); 937 QImage piece_2_front=piece_2_all.copy(0,0,15,15);
940 QImage piece_2_side=piece_2_all.copy(0,15,15,5); 938 QImage piece_2_side=piece_2_all.copy(0,15,15,5);
941 939
942 int a=0; 940 int a=0;
943 for(a=0;a<15;a++) 941 for(a=0;a<15;a++)
944 { 942 {
945 p1[a]->setImage(piece_1_front); 943 p1[a]->setImage(piece_1_front);
946 p1_side[a]->setImage(piece_1_side); 944 p1_side[a]->setImage(piece_1_side);
947 945
948 p2[a]->setImage(piece_2_front); 946 p2[a]->setImage(piece_2_front);
949 p2_side[a]->setImage(piece_2_side); 947 p2_side[a]->setImage(piece_2_side);
950 } 948 }
951 draw(); 949 draw();
952 950
953 QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); 951 QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name));
954 QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); 952 QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name));
955 QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); 953 QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name));
956 954
957 for(a=0;a<7;a++) 955 for(a=0;a<7;a++)
958 { 956 {
959 QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); 957 QImage dicebgA=dicebgA_all.copy(a*25,0,25,25);
960 diceA1[a]->setImage(dicebgA); 958 diceA1[a]->setImage(dicebgA);
961 diceA2[a]->setImage(dicebgA); 959 diceA2[a]->setImage(dicebgA);
962 960
963 QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); 961 QImage dicebgB=dicebgB_all.copy(a*25,0,25,25);
964 diceB1[a]->setImage(dicebgB); 962 diceB1[a]->setImage(dicebgB);
965 diceB2[a]->setImage(dicebgB); 963 diceB2[a]->setImage(dicebgB);
966 /* 964 /*
967 if(a<6) 965 if(a<6)
968 { 966 {
969 QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); 967 QImage oddsbg=oddsbg_all.copy(a*15,0,15,15);
970 oddsDice[a]->setImage(oddsbg); 968 oddsDice[a]->setImage(oddsbg);
971 } 969 }
972 */ 970 */
973 } 971 }
974} 972}
975 973
976 974
diff --git a/noncore/games/backgammon/backgammon.h b/noncore/games/backgammon/backgammon.h
index d803489..e3276f1 100644
--- a/noncore/games/backgammon/backgammon.h
+++ b/noncore/games/backgammon/backgammon.h
@@ -1,119 +1,120 @@
1#ifndef BACKGAMMON_H 1#ifndef BACKGAMMON_H
2#define BACKGAMMON_H 2#define BACKGAMMON_H
3 3
4#include "backgammonview.h" 4#include "backgammonview.h"
5#include "canvasimageitem.h" 5#include "canvasimageitem.h"
6//#include "rulesdialog.h" 6//#include "rulesdialog.h"
7#include "moveengine.h" 7#include "moveengine.h"
8 8
9 9
10#include <qlabel.h> 10#include <qlabel.h>
11#include <qmainwindow.h> 11#include <qmainwindow.h>
12//#include <qwidget.h> 12//#include <qwidget.h>
13 13
14 14
15 15
16 16
17class BackGammon : public QMainWindow 17class BackGammon : public QMainWindow
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20private: 20private:
21 //GUI
21 //the "status" bar 22 //the "status" bar
22 QLabel* message; 23 QLabel* message;
23 //the main drawing area 24 //the main drawing area
24 QCanvas* area; 25 QCanvas* area;
25 BackGammonView* boardview; 26 BackGammonView* boardview;
26 CanvasImageItem* board; 27 CanvasImageItem* board;
27 CanvasImageItem* table; 28 CanvasImageItem* table;
28 CanvasImageItem** p1; 29 CanvasImageItem** p1;
29 CanvasImageItem** p2; 30 CanvasImageItem** p2;
30 CanvasImageItem** p1_side; 31 CanvasImageItem** p1_side;
31 CanvasImageItem** p2_side; 32 CanvasImageItem** p2_side;
32 33
33 CanvasImageItem** diceA1; 34 CanvasImageItem** diceA1;
34 CanvasImageItem** diceA2; 35 CanvasImageItem** diceA2;
35 CanvasImageItem** diceB1; 36 CanvasImageItem** diceB1;
36 CanvasImageItem** diceB2; 37 CanvasImageItem** diceB2;
37 //CanvasImageItem** oddsDice; 38 //CanvasImageItem** oddsDice;
38 CanvasImageItem* nomove_marker; 39 CanvasImageItem* nomove_marker;
39 40
40 QCanvasRectangle* marker_current; 41 QCanvasRectangle* marker_current;
41 QCanvasRectangle* marker_next[4]; 42 QCanvasRectangle* marker_next[4];
42 43
43 //ENGINE 44 //ENGINE
44 MoveEngine* move; 45 MoveEngine* move;
45 //the dice values 46 //the dice values
46 int diceA1_value; 47 int diceA1_value;
47 int diceA2_value; 48 int diceA2_value;
48 int diceA3_value; 49 int diceA3_value;
49 int diceA4_value; 50 int diceA4_value;
50 int diceB1_value; 51 int diceB1_value;
51 int diceB2_value; 52 int diceB2_value;
52 int diceB3_value; 53 int diceB3_value;
53 int diceB4_value; 54 int diceB4_value;
54 55
55 int player; 56 int player;
56 bool dice1_played; 57 bool dice1_played;
57 bool dice2_played; 58 bool dice2_played;
58 bool dice3_played; 59 bool dice3_played;
59 bool dice4_played; 60 bool dice4_played;
60 bool dice_rolled; 61 bool dice_rolled;
61 //computer opponent 62 //computer opponent
62 bool player1_auto; 63 bool player1_auto;
63 bool player2_auto; 64 bool player2_auto;
64 65
65 //the images; 66 //the images;
66 QString theme_name; 67 QString theme_name;
67 QString board_name; 68 QString board_name;
68 QString piecesA_name; 69 QString piecesA_name;
69 QString piecesB_name; 70 QString piecesB_name;
70 QString diceA_name; 71 QString diceA_name;
71 QString diceB_name; 72 QString diceB_name;
72 QString odds_name; 73 QString odds_name;
73 QString table_name; 74 QString table_name;
74 75
75 //save game 76 //save game
76 QString game_name; 77 QString game_name;
77 78
78 //the rules 79 //the rules
79 Rules rules; 80 Rules rules;
80 81
81 //display settings 82 //display settings
82 Display display; 83 Display display;
83 //is the game finished ? 84 //is the game finished ?
84 bool gameFinished; 85 bool gameFinished;
85 86
86public: 87public:
87 BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 88 BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
88 ~BackGammon(); 89 ~BackGammon();
89private slots: 90private slots:
90 void newgame(); 91 void newgame();
91 void playerselect(); 92 void playerselect();
92 void loadgame(); 93 void loadgame();
93 void savegame(); 94 void savegame();
94 void deletegame(); 95 void deletegame();
95 void newtheme(); 96 void newtheme();
96 void loadtheme(); 97 void loadtheme();
97 void savetheme(); 98 void savetheme();
98 void themedefault(); 99 void themedefault();
99 void deletetheme(); 100 void deletetheme();
100 void modify_AI(); 101 void modify_AI();
101 void setrules(); 102 void setrules();
102 void mouse(int x,int y); 103 void mouse(int x,int y);
103 void done_dice1(); 104 void done_dice1();
104 void done_dice2(); 105 void done_dice2();
105 void done_dice3(); 106 void done_dice3();
106 void done_dice4(); 107 void done_dice4();
107 void nomove(); 108 void nomove();
108 void nomove2(); 109 void nomove2();
109 void finished(int theplayer); 110 void finished(int theplayer);
110 void autoroll_dice1(); 111 void autoroll_dice1();
111 void autoroll_dice2(); 112 void autoroll_dice2();
112private: 113private:
113 void draw(); 114 void draw();
114 void showdice(); 115 void showdice();
115 void setplayer(); 116 void setplayer();
116 void applytheme(); 117 void applytheme();
117}; 118};
118 119
119#endif //BACKGAMMON_H 120#endif //BACKGAMMON_H
diff --git a/noncore/games/bounce/kbounce.cpp b/noncore/games/bounce/kbounce.cpp
index 5d8aba3..50f4ef6 100644
--- a/noncore/games/bounce/kbounce.cpp
+++ b/noncore/games/bounce/kbounce.cpp
@@ -1,311 +1,311 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> 2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qlcdnumber.h> 21#include <qlcdnumber.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26#include "kbounce.h" 26#include "kbounce.h"
27#include "game.h" 27#include "game.h"
28#include <qlabel.h> 28#include <qlabel.h>
29 29
30KJezzball::KJezzball() : QMainWindow(0), m_gameWidget( 0 ) 30KJezzball::KJezzball() : QMainWindow(0), m_gameWidget( 0 )
31{ 31{
32 setCaption(tr("Bounce")); 32 setCaption(tr("Bounce"));
33 // setup variables 33 // setup variables
34 m_game.level = 1; 34 m_game.level = 1;
35 m_game.score = 0; 35 m_game.score = 0;
36 m_state = Idle; 36 m_state = Idle;
37 37
38 38
39 menu = menuBar(); 39 menu = menuBar();
40 game = new QPopupMenu; 40 game = new QPopupMenu;
41 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); 41 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
42 game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P ); 42 game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P );
43 game->insertSeparator(); 43 game->insertSeparator();
44 game->insertItem(tr("&About"), this, SLOT(about())); 44 game->insertItem(tr("&About"), this, SLOT(about()));
45 menu->insertItem( tr("&Game"), game ); 45 menu->insertItem( tr("&Game"), game );
46 46
47 // create widgets 47 // create widgets
48 m_view = new QWidget( this, "m_view" ); 48 m_view = new QWidget( this, "m_view" );
49 setCentralWidget( m_view ); 49 setCentralWidget( m_view );
50 50
51 m_layout = new QGridLayout( m_view ); 51 m_layout = new QGridLayout( m_view );
52 m_layout->setSpacing( 0 ); 52 m_layout->setSpacing( 0 );
53 m_layout->setMargin( 0 ); 53 m_layout->setMargin( 0 );
54 54
55 ScoreLabel = new QLabel( m_view, "ScoreLabel" ); 55 ScoreLabel = new QLabel( m_view, "ScoreLabel" );
56 ScoreLabel->setText( tr( "Score: 00" ) ); 56 ScoreLabel->setText( tr( "Score: 00" ) );
57 ScoreLabel->setAlignment( int( QLabel::AlignCenter ) ); 57 ScoreLabel->setAlignment( int( QLabel::AlignCenter ) );
58 58
59 m_layout->addWidget( ScoreLabel, 1, 0 ); 59 m_layout->addWidget( ScoreLabel, 1, 0 );
60 60
61 LivesLabel = new QLabel( m_view, "LivesLabel" ); 61 LivesLabel = new QLabel( m_view, "LivesLabel" );
62 LivesLabel->setText( tr( "Lives: 0%" ) ); 62 LivesLabel->setText( tr( "Lives: 0%" ) );
63 LivesLabel->setAlignment( int( QLabel::AlignCenter ) ); 63 LivesLabel->setAlignment( int( QLabel::AlignCenter ) );
64 64
65 m_layout->addWidget( LivesLabel, 1, 2 ); 65 m_layout->addWidget( LivesLabel, 1, 2 );
66 66
67 FilledLabel = new QLabel( m_view, "FilledLabel" ); 67 FilledLabel = new QLabel( m_view, "FilledLabel" );
68 FilledLabel->setText( tr( "Filled: 00%" ) ); 68 FilledLabel->setText( tr( "Filled: 00%" ) );
69 FilledLabel->setAlignment( int( QLabel::AlignCenter ) ); 69 FilledLabel->setAlignment( int( QLabel::AlignCenter ) );
70 70
71 m_layout->addWidget( FilledLabel, 1, 1 ); 71 m_layout->addWidget( FilledLabel, 1, 1 );
72 72
73 TimeLabel = new QLabel( m_view, "TimeLabel" ); 73 TimeLabel = new QLabel( m_view, "TimeLabel" );
74 TimeLabel->setText( tr( "Time: 00" ) ); 74 TimeLabel->setText( tr( "Time: 00" ) );
75 TimeLabel->setAlignment( int( QLabel::AlignCenter ) ); 75 TimeLabel->setAlignment( int( QLabel::AlignCenter ) );
76 76
77 m_layout->addWidget( TimeLabel, 1, 3 ); 77 m_layout->addWidget( TimeLabel, 1, 3 );
78 78
79 // create timers 79 // create timers
80 m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" ); 80 m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" );
81 connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) ); 81 connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) );
82 82
83 m_gameOverTimer = new QTimer( this, "m_gameOverTimer" ); 83 m_gameOverTimer = new QTimer( this, "m_gameOverTimer" );
84 connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) ); 84 connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) );
85 85
86 m_timer = new QTimer( this, "m_timer" ); 86 m_timer = new QTimer( this, "m_timer" );
87 connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) ); 87 connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) );
88 88
89 // create demo game 89 // create demo game
90 createLevel( 1 ); 90 createLevel( 1 );
91} 91}
92 92
93void KJezzball::newGame() 93void KJezzball::newGame()
94{ 94{
95 // Check for running game 95 // Check for running game
96 closeGame(); 96 closeGame();
97 if ( m_state==Idle ) 97 if ( m_state==Idle )
98 { 98 {
99 // update displays 99 // update displays
100 m_game.level = 1; 100 m_game.level = 1;
101 m_game.score = 0; 101 m_game.score = 0;
102 102
103 setCaption(tr("Bounce Level %1").arg(m_game.level)); 103 setCaption(tr("Bounce Level %1").arg(m_game.level));
104 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) ); 104 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) );
105 105
106 // start new game 106 // start new game
107 m_state = Running; 107 m_state = Running;
108 108
109 createLevel( m_game.level ); 109 createLevel( m_game.level );
110 startLevel(); 110 startLevel();
111 } 111 }
112} 112}
113 113
114void KJezzball::about() 114void KJezzball::about()
115{ 115{
116 QMessageBox::information( this, "About", 116 QMessageBox::information( this, tr("About"),
117 "Written by: Stefan Schimanski\n" 117 tr("Written by: Stefan Schimanski\n"
118 "Ported by: Martin Imobersteg\n" 118 "Ported by: Martin Imobersteg\n"
119 "\n" 119 "\n"
120 "Click to form walls.\n" 120 "Click to form walls.\n"
121 "Hit space to switch wall direction.\n" 121 "Hit space to switch wall direction.\n"
122 "Try to reduce total space by 75%.\n" 122 "Try to reduce total space by 75%.\n"
123 "\n" 123 "\n"
124 "This program is distributed under\n" 124 "This program is distributed under\n"
125 "the terms of the GPL v2." ); 125 "the terms of the GPL v2.") );
126} 126}
127 127
128void KJezzball::closeGame() 128void KJezzball::closeGame()
129{ 129{
130 if ( m_state!=Idle ) 130 if ( m_state!=Idle )
131 { 131 {
132 stopLevel(); 132 stopLevel();
133 m_state = Idle; 133 m_state = Idle;
134 } 134 }
135} 135}
136 136
137void KJezzball::pauseGame() 137void KJezzball::pauseGame()
138{ 138{
139 switch ( m_state ) 139 switch ( m_state )
140 { 140 {
141 case Running: 141 case Running:
142 m_state = Paused; 142 m_state = Paused;
143 m_gameWidget->display( tr("Game paused.\nPress P to continue!") ); 143 m_gameWidget->display( tr("Game paused.\nPress P to continue!") );
144 stopLevel(); 144 stopLevel();
145 break; 145 break;
146 146
147 case Paused: 147 case Paused:
148 case Suspend: 148 case Suspend:
149 m_state = Running; 149 m_state = Running;
150 m_gameWidget->display( QString::null ); 150 m_gameWidget->display( QString::null );
151 startLevel(); 151 startLevel();
152 break; 152 break;
153 153
154 case Idle: 154 case Idle:
155 break; 155 break;
156 } 156 }
157} 157}
158 158
159void KJezzball::gameOver() 159void KJezzball::gameOver()
160{ 160{
161 stopLevel(); 161 stopLevel();
162 m_gameOverTimer->start( 100, TRUE ); 162 m_gameOverTimer->start( 100, TRUE );
163} 163}
164 164
165 165
166void KJezzball::gameOverNow() 166void KJezzball::gameOverNow()
167{ 167{
168 m_state = Idle; 168 m_state = Idle;
169 169
170 QString score; 170 QString score;
171 score.setNum( m_game.score ); 171 score.setNum( m_game.score );
172 QMessageBox::information( this, "Game Over", tr("Game Over!\nScore: %1").arg(score) ); 172 QMessageBox::information( this, "Game Over", tr("Game Over!\nScore: %1").arg(score) );
173} 173}
174 174
175void KJezzball::focusOutEvent( QFocusEvent *ev ) 175void KJezzball::focusOutEvent( QFocusEvent *ev )
176{ 176{
177 if ( m_state==Running ) 177 if ( m_state==Running )
178 { 178 {
179 stopLevel(); 179 stopLevel();
180 m_state = Suspend; 180 m_state = Suspend;
181 } 181 }
182 182
183 QMainWindow::focusOutEvent( ev ); 183 QMainWindow::focusOutEvent( ev );
184} 184}
185 185
186void KJezzball::focusInEvent ( QFocusEvent *ev ) 186void KJezzball::focusInEvent ( QFocusEvent *ev )
187{ 187{
188 if ( m_state==Suspend ) 188 if ( m_state==Suspend )
189 { 189 {
190 startLevel(); 190 startLevel();
191 m_state = Running; 191 m_state = Running;
192 } 192 }
193 193
194 QMainWindow::focusInEvent( ev ); 194 QMainWindow::focusInEvent( ev );
195} 195}
196 196
197void KJezzball::second() 197void KJezzball::second()
198{ 198{
199 m_level.time--; 199 m_level.time--;
200 TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) ); 200 TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) );
201 if ( m_level.time<=0 ) 201 if ( m_level.time<=0 )
202 { 202 {
203 gameOver(); 203 gameOver();
204 } 204 }
205} 205}
206 206
207void KJezzball::died() 207void KJezzball::died()
208{ 208{
209 m_level.lifes--; 209 m_level.lifes--;
210 LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) ); 210 LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) );
211 if ( m_level.lifes==0 ) gameOver(); 211 if ( m_level.lifes==0 ) gameOver();
212} 212}
213 213
214void KJezzball::newPercent( int percent ) 214void KJezzball::newPercent( int percent )
215{ 215{
216 FilledLabel->setText( tr( "Filled: %1%" ).arg(percent) ); 216 FilledLabel->setText( tr( "Filled: %1%" ).arg(percent) );
217 if ( percent>=75 ) 217 if ( percent>=75 )
218 { 218 {
219 m_level.score = m_level.lifes*15 + (percent-75)*2*(m_game.level+5); 219 m_level.score = m_level.lifes*15 + (percent-75)*2*(m_game.level+5);
220 nextLevel(); 220 nextLevel();
221 } 221 }
222} 222}
223 223
224void KJezzball::createLevel( int level ) 224void KJezzball::createLevel( int level )
225{ 225{
226 // destroy old game 226 // destroy old game
227 if ( m_gameWidget ) delete m_gameWidget; 227 if ( m_gameWidget ) delete m_gameWidget;
228 228
229 m_gameWidget = new JezzGame( level+1, m_view, "m_gameWidget" ); 229 m_gameWidget = new JezzGame( level+1, m_view, "m_gameWidget" );
230 230
231 m_gameWidget->show(); 231 m_gameWidget->show();
232 m_layout->addMultiCellWidget( m_gameWidget, 0, 0, 0, 3 ); 232 m_layout->addMultiCellWidget( m_gameWidget, 0, 0, 0, 3 );
233 connect( m_gameWidget, SIGNAL(died()), this, SLOT(died()) ); 233 connect( m_gameWidget, SIGNAL(died()), this, SLOT(died()) );
234 connect( m_gameWidget, SIGNAL(newPercent(int)), this, SLOT(newPercent(int)) ); 234 connect( m_gameWidget, SIGNAL(newPercent(int)), this, SLOT(newPercent(int)) );
235 235
236 // update displays 236 // update displays
237 m_level.lifes = level+1; 237 m_level.lifes = level+1;
238 LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) ); 238 LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) );
239 FilledLabel->setText( tr( "Filled: 0%" ) ); 239 FilledLabel->setText( tr( "Filled: 0%" ) );
240 240
241 m_level.time = (level+2)*30; 241 m_level.time = (level+2)*30;
242 TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) ); 242 TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) );
243 243
244 m_level.score = 0; 244 m_level.score = 0;
245} 245}
246 246
247void KJezzball::startLevel() 247void KJezzball::startLevel()
248{ 248{
249 if ( m_gameWidget ) 249 if ( m_gameWidget )
250 { 250 {
251 m_timer->start( 1000 ); 251 m_timer->start( 1000 );
252 m_gameWidget->start(); 252 m_gameWidget->start();
253 } 253 }
254} 254}
255 255
256void KJezzball::stopLevel() 256void KJezzball::stopLevel()
257{ 257{
258 if ( m_gameWidget ) 258 if ( m_gameWidget )
259 { 259 {
260 m_gameWidget->stop(); 260 m_gameWidget->stop();
261 m_timer->stop(); 261 m_timer->stop();
262 } 262 }
263} 263}
264 264
265void KJezzball::nextLevel() 265void KJezzball::nextLevel()
266{ 266{
267 stopLevel(); 267 stopLevel();
268 m_nextLevelTimer->start( 100, TRUE ); 268 m_nextLevelTimer->start( 100, TRUE );
269} 269}
270 270
271void KJezzball::switchLevel() 271void KJezzball::switchLevel()
272{ 272{
273 m_game.score += m_level.score; 273 m_game.score += m_level.score;
274 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) ); 274 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) );
275 275
276 QString score; 276 QString score;
277 score.setNum( m_level.score ); 277 score.setNum( m_level.score );
278 278
279 QString level; 279 QString level;
280 level.setNum( m_game.level ); 280 level.setNum( m_game.level );
281 281
282 QString foo = QString( 282 QString foo = QString(
283 tr("Successfully cleared more than 75%.\n") + 283 tr("Successfully cleared more than 75%.\n") +
284 tr("%1 points: 15 points per life\n").arg(m_level.lifes*15) + 284 tr("%1 points: 15 points per life\n").arg(m_level.lifes*15) +
285 tr("%1 points: Bonus\n").arg((m_gameWidget->percent()-75)*2*(m_game.level+5)) + 285 tr("%1 points: Bonus\n").arg((m_gameWidget->percent()-75)*2*(m_game.level+5)) +
286 tr("%1 points: Total score\n").arg(score) + 286 tr("%1 points: Total score\n").arg(score) +
287 tr("On to level %1.\nYou get %2 lives this time!")).arg(m_game.level+1).arg(m_game.level+2); 287 tr("On to level %1.\nYou get %2 lives this time!")).arg(m_game.level+1).arg(m_game.level+2);
288 288
289 QMessageBox::information( this, "Success", foo ); 289 QMessageBox::information( this, "Success", foo );
290 290
291 m_game.level++; 291 m_game.level++;
292 292
293 createLevel( m_game.level ); 293 createLevel( m_game.level );
294 startLevel(); 294 startLevel();
295} 295}
296 296
297void KJezzball::keyPressEvent( QKeyEvent *ev ) 297void KJezzball::keyPressEvent( QKeyEvent *ev )
298{ 298{
299 if ( ev->key() == Key_Space || 299 if ( ev->key() == Key_Space ||
300 ev->key() == Key_Up || 300 ev->key() == Key_Up ||
301 ev->key() == Key_Down || 301 ev->key() == Key_Down ||
302 ev->key() == Key_Right || 302 ev->key() == Key_Right ||
303 ev->key() == Key_Left ) 303 ev->key() == Key_Left )
304 { 304 {
305 m_gameWidget->changeCursor(); 305 m_gameWidget->changeCursor();
306 } 306 }
307 else 307 else
308 { 308 {
309 ev->ignore(); 309 ev->ignore();
310 } 310 }
311} 311}
diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp
index b870a59..97a17a1 100644
--- a/noncore/games/buzzword/buzzword.cpp
+++ b/noncore/games/buzzword/buzzword.cpp
@@ -1,182 +1,182 @@
1/* 1/*
2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> 2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public 5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qgrid.h> 23#include <qgrid.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qbutton.h> 25#include <qbutton.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qdir.h> 30#include <qdir.h>
31 31
32#include <math.h> 32#include <math.h>
33#include <stdlib.h> 33#include <stdlib.h>
34 34
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36 36
37#include "buzzword.h" 37#include "buzzword.h"
38 38
39BuzzLabel::BuzzLabel( QWidget *parent, const char *name ) 39BuzzLabel::BuzzLabel( QWidget *parent, const char *name )
40: QLabel( parent, name ) 40: QLabel( parent, name )
41{ 41{
42} 42}
43 43
44void BuzzLabel::mousePressEvent(QMouseEvent *e) 44void BuzzLabel::mousePressEvent(QMouseEvent *e)
45{ 45{
46 if(e->button() == LeftButton) 46 if(e->button() == LeftButton)
47 { 47 {
48 emit clicked(); 48 emit clicked();
49 } 49 }
50} 50}
51 51
52BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name ) 52BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name )
53: QVBox( parent, name ), _row(row), _column(column) 53: QVBox( parent, name ), _row(row), _column(column)
54{ 54{
55 setFrameStyle( QFrame::Panel | QFrame::Raised ); 55 setFrameStyle( QFrame::Panel | QFrame::Raised );
56 setLineWidth( 1 ); 56 setLineWidth( 1 );
57 label = new BuzzLabel(this, "label"); 57 label = new BuzzLabel(this, "label");
58 label->setText(text); 58 label->setText(text);
59 label->setAlignment( int( QLabel::AlignCenter ) ); 59 label->setAlignment( int( QLabel::AlignCenter ) );
60 60
61 connect( label, SIGNAL(clicked()), this, SLOT(flip()) ); 61 connect( label, SIGNAL(clicked()), this, SLOT(flip()) );
62} 62}
63 63
64void BuzzItem::flip() 64void BuzzItem::flip()
65{ 65{
66 setLineWidth( 1 ); 66 setLineWidth( 1 );
67 label->setBackgroundColor(label->colorGroup().highlight()); 67 label->setBackgroundColor(label->colorGroup().highlight());
68 emit clicked(_row, _column); 68 emit clicked(_row, _column);
69} 69}
70 70
71BuzzWord::BuzzWord() : QMainWindow(0) 71BuzzWord::BuzzWord() : QMainWindow(0)
72{ 72{
73 setCaption(tr("buZzword")); 73 setCaption(tr("buZzword"));
74 74
75 menu = menuBar(); 75 menu = menuBar();
76 game = new QPopupMenu; 76 game = new QPopupMenu;
77 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); 77 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
78 menu->insertItem( tr("&Game"), game ); 78 menu->insertItem( tr("&Game"), game );
79 79
80 gridVal = 4; 80 gridVal = 4;
81 grid = NULL; 81 grid = NULL;
82 gameOver = false; 82 gameOver = false;
83 newGame(); 83 newGame();
84} 84}
85 85
86void BuzzWord::drawGrid() 86void BuzzWord::drawGrid()
87{ 87{
88 QStringList l; 88 QStringList l;
89 89
90 QString path = QPEApplication::qpeDir()+"share/buzzword/"; 90 QString path = QPEApplication::qpeDir()+"share/buzzword/";
91 QFile f( path + "buzzwords" ); 91 QFile f( path + "buzzwords" );
92 if ( !f.open( IO_ReadOnly ) ) 92 if ( !f.open( IO_ReadOnly ) )
93 return; 93 return;
94 94
95 QTextStream t( &f ); 95 QTextStream t( &f );
96 96
97 while (!t.atEnd()) 97 while (!t.atEnd())
98 { 98 {
99 l << t.readLine(); 99 l << t.readLine();
100 } 100 }
101 101
102 f.close(); 102 f.close();
103 103
104 grid = new QGrid(gridVal, this); 104 grid = new QGrid(gridVal, this);
105 grid->setFixedSize(240,240); 105 //grid->setFixedSize( 480, 480 );
106 106
107 for( int c = 0 ; c < gridVal ; c++ ) 107 for( int c = 0 ; c < gridVal ; c++ )
108 { 108 {
109 for( int r = 0 ; r < gridVal ; r++ ) 109 for( int r = 0 ; r < gridVal ; r++ )
110 { 110 {
111 uint pos = rand() % l. count(); 111 uint pos = rand() % l. count();
112 112
113 QString word = QStringList::split(" ", l[pos]).join("\n"); 113 QString word = QStringList::split(" ", l[pos]).join("\n");
114 BuzzItem* bi = new BuzzItem( c, r, word, grid ); 114 BuzzItem* bi = new BuzzItem( c, r, word, grid );
115 connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); 115 connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) );
116 map[c][r] = 0; 116 map[c][r] = 0;
117 117
118 l.remove( l.at( pos )); 118 l.remove( l.at( pos ));
119 } 119 }
120 } 120 }
121} 121}
122 122
123void BuzzWord::clicked(int row, int column) 123void BuzzWord::clicked(int row, int column)
124{ 124{
125 if ( ! gameOver ) 125 if ( ! gameOver )
126 { 126 {
127 int rowTotal = 0; 127 int rowTotal = 0;
128 int columnTotal = 0; 128 int columnTotal = 0;
129 129
130 map[column][row] = 1; 130 map[column][row] = 1;
131 131
132 for( int c = 0 ; c < gridVal ; c++ ) 132 for( int c = 0 ; c < gridVal ; c++ )
133 { 133 {
134 for( int r = 0 ; r < gridVal ; r++ ) 134 for( int r = 0 ; r < gridVal ; r++ )
135 { 135 {
136 if ( map[c][r] == 1 ) 136 if ( map[c][r] == 1 )
137 rowTotal++; 137 rowTotal++;
138 138
139 if ( rowTotal == 4 ) 139 if ( rowTotal == 4 )
140 { 140 {
141 bingo(); 141 bingo();
142 } 142 }
143 } 143 }
144 rowTotal = 0; 144 rowTotal = 0;
145 } 145 }
146 146
147 for( int r = 0 ; r < gridVal ; r++ ) 147 for( int r = 0 ; r < gridVal ; r++ )
148 { 148 {
149 for( int c = 0 ; c < gridVal ; c++ ) 149 for( int c = 0 ; c < gridVal ; c++ )
150 { 150 {
151 if ( map[c][r] == 1 ) 151 if ( map[c][r] == 1 )
152 columnTotal++; 152 columnTotal++;
153 153
154 if ( columnTotal == 4 ) 154 if ( columnTotal == 4 )
155 { 155 {
156 bingo(); 156 bingo();
157 } 157 }
158 } 158 }
159 columnTotal = 0; 159 columnTotal = 0;
160 } 160 }
161 161
162 if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) 162 if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] )
163 bingo(); 163 bingo();
164 164
165 if ( map[0][3] && map[1][2] && map[2][1] && map[3][0] ) 165 if ( map[0][3] && map[1][2] && map[2][1] && map[3][0] )
166 bingo(); 166 bingo();
167 } 167 }
168} 168}
169 169
170void BuzzWord::bingo() 170void BuzzWord::bingo()
171{ 171{
172 gameOver = true; 172 gameOver = true;
173 QMessageBox::information( this, "BUZZWORD", tr("<h1><b>BINGO !</b></h1>")); 173 QMessageBox::information( this, "BUZZWORD", tr("<h1><b>BINGO !</b></h1>"));
174} 174}
175 175
176void BuzzWord::newGame() 176void BuzzWord::newGame()
177{ 177{
178 gameOver = false; 178 gameOver = false;
179 delete grid; 179 delete grid;
180 drawGrid(); 180 drawGrid();
181 setCentralWidget(grid); 181 setCentralWidget(grid);
182} 182}
diff --git a/noncore/games/fifteen/opie-fifteen.control b/noncore/games/fifteen/opie-fifteen.control
index 662fd03..8fa355f 100644
--- a/noncore/games/fifteen/opie-fifteen.control
+++ b/noncore/games/fifteen/opie-fifteen.control
@@ -1,11 +1,11 @@
1Package: opie-fifteen 1Package: opie-fifteen
2Files: bin/fifteen apps/Games/fifteen.desktop pics/fifteen 2Files: bin/fifteen apps/Games/fifteen.desktop pics/fifteen
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Arch: iPAQ 7Arch: iPAQ
8Version: $QPE_VERSION-$SUB_VERSION
9Depends: task-opie-minimal 8Depends: task-opie-minimal
10Description: Fifteen pieces game 9Description: Fifteen pieces game
11 A game for the Opie environment. 10 A game for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/go/opie-go.control b/noncore/games/go/opie-go.control
index 061c02c..24929de 100644
--- a/noncore/games/go/opie-go.control
+++ b/noncore/games/go/opie-go.control
@@ -1,10 +1,10 @@
1Package: opie-go 1Package: opie-go
2Files: bin/go apps/Games/go.desktop pics/go 2Files: bin/go apps/Games/go.desktop pics/go
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Warwick Allison <warwick@trolltech.com> 5Maintainer: Warwick Allison <warwick@trolltech.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: The game of Go 8Description: The game of Go
10 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp
index 812e9ea..df27c76 100644
--- a/noncore/games/kpacman/kpacman.cpp
+++ b/noncore/games/kpacman/kpacman.cpp
@@ -1,368 +1,368 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kpacman.h> 5#include <kpacman.h>
6#include <kpacman.moc> 6#include <kpacman.moc>
7#include <kcolordlg.h> 7#include <kcolordlg.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11#include <qapplication.h> 11#include <qapplication.h>
12#include "kpacman.h" 12#include "kpacman.h"
13#endif 13#endif
14 14
15#include <qkeycode.h> 15#include <qkeycode.h>
16#include <qcolor.h> 16#include <qcolor.h>
17#include <qstring.h> 17#include <qstring.h>
18#include <qpopmenu.h> 18#include <qpopmenu.h>
19#include <qmsgbox.h> 19#include <qmsgbox.h>
20 20
21Kpacman::Kpacman(QWidget *parent, const char *name) 21Kpacman::Kpacman(QWidget *parent, const char *name)
22 : KTMainWindow(parent, name) 22 : KTMainWindow(parent, name)
23{ 23{
24 schemesPopup = new QList<QPopupMenu>; 24 schemesPopup = new QList<QPopupMenu>;
25 schemesPopup->setAutoDelete(TRUE); 25 schemesPopup->setAutoDelete(TRUE);
26 26
27 menu(); 27 menu();
28 28
29 m_view = new QWidget( this, "m_view" ); 29 m_view = new QWidget( this, "m_view" );
30 m_view->setBackgroundColor( black ); 30 m_view->setBackgroundColor( black );
31 m_layout = new QGridLayout( m_view ); 31 m_layout = new QGridLayout( m_view );
32 m_layout->setMargin( 7 ); 32 m_layout->setMargin( 7 );
33 33
34 view = new KpacmanWidget( this, QString(name)+"widget"); 34 view = new KpacmanWidget( this, QString(name)+"widget");
35 m_layout->addWidget( view, 0, 0 ); 35 m_layout->addWidget( view, 0, 0 );
36 36
37 setCaption( "KPacman" ); 37 setCaption( tr("KPacman") );
38 38
39 view->referee->setFocus(); 39 view->referee->setFocus();
40 40
41 connect(view->referee, SIGNAL(setScore(int, int)), 41 connect(view->referee, SIGNAL(setScore(int, int)),
42 view->score, SLOT(setScore(int, int))); 42 view->score, SLOT(setScore(int, int)));
43 connect(view->referee, SIGNAL(setPoints(int)), 43 connect(view->referee, SIGNAL(setPoints(int)),
44 view->score, SLOT(set(int))); 44 view->score, SLOT(set(int)));
45 connect(view->referee, SIGNAL(setLifes(int)), 45 connect(view->referee, SIGNAL(setLifes(int)),
46 view->status, SLOT(setLifes(int))); 46 view->status, SLOT(setLifes(int)));
47 connect(view->referee, SIGNAL(setLevel(int)), 47 connect(view->referee, SIGNAL(setLevel(int)),
48 view->status, SLOT(setLevel(int))); 48 view->status, SLOT(setLevel(int)));
49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
50 this, SLOT(forcedHallOfFame(bool))); 50 this, SLOT(forcedHallOfFame(bool)));
51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
53 53
54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
55 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 55 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
56 this, SLOT(forcedHallOfFame(bool))); 56 this, SLOT(forcedHallOfFame(bool)));
57 57
58 APP_CONFIG_BEGIN( cfg ); 58 APP_CONFIG_BEGIN( cfg );
59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
62 APP_CONFIG_END( cfg ); 62 APP_CONFIG_END( cfg );
63 63
64 toggleFocusOutPause(); 64 toggleFocusOutPause();
65 toggleFocusInContinue(); 65 toggleFocusInContinue();
66 toggleHideMouseCursor(); 66 toggleHideMouseCursor();
67 67
68 setCentralWidget( m_view ); 68 setCentralWidget( m_view );
69} 69}
70 70
71Kpacman::~Kpacman() 71Kpacman::~Kpacman()
72{ 72{
73 /* APP_CONFIG_BEGIN( cfg ); 73 /* APP_CONFIG_BEGIN( cfg );
74 cfg->writeEntry("FocusOutPause", focusOutPause); 74 cfg->writeEntry("FocusOutPause", focusOutPause);
75 cfg->writeEntry("FocusInContinue", focusInContinue); 75 cfg->writeEntry("FocusInContinue", focusInContinue);
76 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 76 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
77 APP_CONFIG_END( cfg ); 77 APP_CONFIG_END( cfg );
78 */ 78 */
79 delete _menuBar; 79 delete _menuBar;
80} 80}
81 81
82void Kpacman::menu() 82void Kpacman::menu()
83{ 83{
84 gamePopup = new QPopupMenu(); 84 gamePopup = new QPopupMenu();
85 CHECK_PTR( gamePopup ); 85 CHECK_PTR( gamePopup );
86 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); 86 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
87 pauseID = gamePopup->insertItem(tr("&Pause"), 87 pauseID = gamePopup->insertItem(tr("&Pause"),
88 this, SLOT(pauseKpacman()), Key_F3); 88 this, SLOT(pauseKpacman()), Key_F3);
89 hofID = gamePopup->insertItem(tr("&Hall of fame"), 89 hofID = gamePopup->insertItem(tr("&Hall of fame"),
90 this, SLOT(toggleHallOfFame()), Key_F4); 90 this, SLOT(toggleHallOfFame()), Key_F4);
91 gamePopup->insertSeparator(); 91 gamePopup->insertSeparator();
92 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 92 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
93 gamePopup->setCheckable(TRUE); 93 gamePopup->setCheckable(TRUE);
94 94
95 optionsPopup = new QPopupMenu(); 95 optionsPopup = new QPopupMenu();
96 CHECK_PTR(optionsPopup); 96 CHECK_PTR(optionsPopup);
97 97
98 modesPopup = new QPopupMenu(); 98 modesPopup = new QPopupMenu();
99 CHECK_PTR(modesPopup); 99 CHECK_PTR(modesPopup);
100 100
101 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), 101 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
102 this, SLOT(toggleHideMouseCursor()), 102 this, SLOT(toggleHideMouseCursor()),
103 CTRL+Key_H); 103 CTRL+Key_H);
104 optionsPopup->insertSeparator(); 104 optionsPopup->insertSeparator();
105 105
106 if (lookupSchemes() > 0) { 106 if (lookupSchemes() > 0) {
107 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); 107 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
108 optionsPopup->insertSeparator(); 108 optionsPopup->insertSeparator();
109 } 109 }
110 110
111 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), 111 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
112 this, SLOT(toggleFocusOutPause())); 112 this, SLOT(toggleFocusOutPause()));
113 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), 113 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
114 this, SLOT(toggleFocusInContinue())); 114 this, SLOT(toggleFocusInContinue()));
115 optionsPopup->insertSeparator(); 115 optionsPopup->insertSeparator();
116 116
117 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); 117 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys()));
118 118
119#ifndef QPE_PORT 119#ifndef QPE_PORT
120 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" 120 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n"
121 "Joerg Thoennissen (joe@dsite.de)\n\n" 121 "Joerg Thoennissen (joe@dsite.de)\n\n"
122 "A pacman game for the KDE Desktop\n\n" 122 "A pacman game for the KDE Desktop\n\n"
123 "The program based on the source of ksnake\n" 123 "The program based on the source of ksnake\n"
124 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" 124 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n"
125 "The design was strongly influenced by the pacman\n" 125 "The design was strongly influenced by the pacman\n"
126 "(c) 1980 MIDWAY MFG.CO.\n\n" 126 "(c) 1980 MIDWAY MFG.CO.\n\n"
127 "I like to thank my girlfriend Elke Krueers for\n" 127 "I like to thank my girlfriend Elke Krueers for\n"
128 "the last 10 years of her friendship.\n"); 128 "the last 10 years of her friendship.\n");
129 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); 129 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE);
130 aboutText.replace(QRegExp("@VERSION@"), VERSION); 130 aboutText.replace(QRegExp("@VERSION@"), VERSION);
131 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); 131 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE);
132#endif 132#endif
133 133
134 //_menuBar = new KMenuBar(this); 134 //_menuBar = new KMenuBar(this);
135 //CHECK_PTR( _menuBar ); 135 //CHECK_PTR( _menuBar );
136 //_menuBar->insertItem(tr("&Game"), gamePopup); 136 //_menuBar->insertItem(tr("&Game"), gamePopup);
137 //_menuBar->insertItem(tr("&Options"), optionsPopup); 137 //_menuBar->insertItem(tr("&Options"), optionsPopup);
138 //_menuBar->insertSeparator(); 138 //_menuBar->insertSeparator();
139#ifndef QPE_PORT 139#ifndef QPE_PORT
140 _menuBar->insertItem(tr("&Help"), helpPopup); 140 _menuBar->insertItem(tr("&Help"), helpPopup);
141#endif 141#endif
142} 142}
143 143
144int Kpacman::lookupSchemes() 144int Kpacman::lookupSchemes()
145{ 145{
146 APP_CONFIG_BEGIN( cfg ); 146 APP_CONFIG_BEGIN( cfg );
147 int ModeCount = cfg->readNumEntry("ModeCount", 0); 147 int ModeCount = cfg->readNumEntry("ModeCount", 0);
148 int Mode = cfg->readNumEntry("Mode", 0); 148 int Mode = cfg->readNumEntry("Mode", 0);
149 int SchemeCount = cfg->readNumEntry("SchemeCount", 0); 149 int SchemeCount = cfg->readNumEntry("SchemeCount", 0);
150 int Scheme = cfg->readNumEntry("Scheme", 0); 150 int Scheme = cfg->readNumEntry("Scheme", 0);
151 151
152 /* 152 /*
153 if (SchemeCount == 0 || Scheme == -1) { 153 if (SchemeCount == 0 || Scheme == -1) {
154 QMessageBox::warning(this, tr("Configuration Error"), 154 QMessageBox::warning(this, tr("Configuration Error"),
155 tr("There are no schemes defined,\n" 155 tr("There are no schemes defined,\n"
156 "or no scheme is selected.")); 156 "or no scheme is selected."));
157 APP_CONFIG_END( cfg ); 157 APP_CONFIG_END( cfg );
158 return 0; 158 return 0;
159 } 159 }
160 */ 160 */
161 161
162 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 162 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
163 modeID.resize(ModeCount > 0 ? ModeCount : 0); 163 modeID.resize(ModeCount > 0 ? ModeCount : 0);
164 164
165 if (!schemesPopup->isEmpty()) 165 if (!schemesPopup->isEmpty())
166 schemesPopup->clear(); 166 schemesPopup->clear();
167 167
168 SAVE_CONFIG_GROUP( cfg, oldgroup ); 168 SAVE_CONFIG_GROUP( cfg, oldgroup );
169 169
170 QString ModeGroup; 170 QString ModeGroup;
171 QString ModeName; 171 QString ModeName;
172 172
173 for (int m = 0; m < ModeCount; m++) { 173 for (int m = 0; m < ModeCount; m++) {
174 ModeGroup.sprintf("Mode %d", m); 174 ModeGroup.sprintf("Mode %d", m);
175 cfg->setGroup(ModeGroup); 175 cfg->setGroup(ModeGroup);
176 176
177 ModeName = cfg->readEntry("Description", ModeGroup); 177 ModeName = cfg->readEntry("Description", ModeGroup);
178 178
179 QPopupMenu *p = new QPopupMenu; 179 QPopupMenu *p = new QPopupMenu;
180 p->setCheckable(TRUE); 180 p->setCheckable(TRUE);
181 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 181 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
182 schemesPopup->append(p); 182 schemesPopup->append(p);
183 183
184 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m)); 184 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m));
185 modesPopup->setItemEnabled(modeID[m], FALSE); 185 modesPopup->setItemEnabled(modeID[m], FALSE);
186 modesPopup->setItemChecked(modeID[m], m == Mode); 186 modesPopup->setItemChecked(modeID[m], m == Mode);
187 } 187 }
188 188
189 schemeID.resize(SchemeCount); 189 schemeID.resize(SchemeCount);
190 schemeMode.resize(SchemeCount); 190 schemeMode.resize(SchemeCount);
191 191
192 QString SchemeGroup; 192 QString SchemeGroup;
193 QString SchemeName; 193 QString SchemeName;
194 int SchemeMode; 194 int SchemeMode;
195 195
196 for (int i = 0; i < SchemeCount; i++) { 196 for (int i = 0; i < SchemeCount; i++) {
197 SchemeGroup.sprintf("Scheme %d", i); 197 SchemeGroup.sprintf("Scheme %d", i);
198 cfg->setGroup(SchemeGroup); 198 cfg->setGroup(SchemeGroup);
199 199
200 SchemeName = cfg->readEntry("Description", SchemeGroup); 200 SchemeName = cfg->readEntry("Description", SchemeGroup);
201 SchemeMode = cfg->readNumEntry("Mode", -1); 201 SchemeMode = cfg->readNumEntry("Mode", -1);
202 202
203 schemeMode[i] = SchemeMode; 203 schemeMode[i] = SchemeMode;
204 if (SchemeMode == -1) { 204 if (SchemeMode == -1) {
205 schemeID[i] = modesPopup->insertItem(SchemeName); 205 schemeID[i] = modesPopup->insertItem(SchemeName);
206 modesPopup->setItemChecked(schemeID[i], i == Scheme); 206 modesPopup->setItemChecked(schemeID[i], i == Scheme);
207 } else { 207 } else {
208 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName); 208 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName);
209 schemesPopup->at(SchemeMode)-> 209 schemesPopup->at(SchemeMode)->
210 setItemChecked(schemeID[i], i == Scheme); 210 setItemChecked(schemeID[i], i == Scheme);
211 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE); 211 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE);
212 } 212 }
213 } 213 }
214 214
215 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 215 RESTORE_CONFIG_GROUP( cfg, oldgroup );
216 216
217 APP_CONFIG_END( cfg ); 217 APP_CONFIG_END( cfg );
218 return SchemeCount; 218 return SchemeCount;
219} 219}
220 220
221void Kpacman::quitKpacman() 221void Kpacman::quitKpacman()
222{ 222{
223 APP_QUIT(); 223 APP_QUIT();
224} 224}
225 225
226void Kpacman::newKpacman() 226void Kpacman::newKpacman()
227{ 227{
228 if (!gamePopup->isItemEnabled(hofID)) 228 if (!gamePopup->isItemEnabled(hofID))
229 gamePopup->setItemEnabled(hofID, TRUE); 229 gamePopup->setItemEnabled(hofID, TRUE);
230 230
231 if (gamePopup->isItemChecked(hofID)) 231 if (gamePopup->isItemChecked(hofID))
232 toggleHallOfFame(); 232 toggleHallOfFame();
233 233
234 if (gamePopup->isItemChecked(pauseID)) 234 if (gamePopup->isItemChecked(pauseID))
235 pauseKpacman(); 235 pauseKpacman();
236 236
237 view->referee->play(); 237 view->referee->play();
238} 238}
239 239
240void Kpacman::pauseKpacman() 240void Kpacman::pauseKpacman()
241{ 241{
242 view->referee->pause(); 242 view->referee->pause();
243 view->score->setPause(gamePopup->isItemChecked(pauseID)); 243 view->score->setPause(gamePopup->isItemChecked(pauseID));
244} 244}
245 245
246void Kpacman::toggleHallOfFame() 246void Kpacman::toggleHallOfFame()
247{ 247{
248 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID)); 248 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID));
249 view->referee->toggleHallOfFame(); 249 view->referee->toggleHallOfFame();
250 250
251 if (gamePopup->isItemChecked(hofID)) { 251 if (gamePopup->isItemChecked(hofID)) {
252 view->referee->lower(); 252 view->referee->lower();
253 view->status->lower(); 253 view->status->lower();
254 } else { 254 } else {
255 view->status->raise(); 255 view->status->raise();
256 view->referee->raise(); 256 view->referee->raise();
257 view->referee->setFocus(); 257 view->referee->setFocus();
258 } 258 }
259} 259}
260 260
261/* 261/*
262 * Disable or enable the "Hall of fame"-menuitem if the referee says so. 262 * Disable or enable the "Hall of fame"-menuitem if the referee says so.
263 * This is done, to disable turning off the "hall of fame"-display, in the automated 263 * This is done, to disable turning off the "hall of fame"-display, in the automated
264 * sequence of displaying the introduction, the demonstration (or playing) and the 264 * sequence of displaying the introduction, the demonstration (or playing) and the
265 * hall of fame. 265 * hall of fame.
266 * If on == TRUE then also lower the referee and the status widgets. 266 * If on == TRUE then also lower the referee and the status widgets.
267 */ 267 */
268void Kpacman::forcedHallOfFame(bool on) 268void Kpacman::forcedHallOfFame(bool on)
269{ 269{
270 if (!on && !gamePopup->isItemChecked(hofID)) 270 if (!on && !gamePopup->isItemChecked(hofID))
271 return; 271 return;
272 272
273 gamePopup->setItemEnabled(hofID, !on); 273 gamePopup->setItemEnabled(hofID, !on);
274 gamePopup->setItemChecked(hofID, on); 274 gamePopup->setItemChecked(hofID, on);
275 275
276 view->referee->toggleHallOfFame(); 276 view->referee->toggleHallOfFame();
277 if (on) { 277 if (on) {
278 view->referee->lower(); 278 view->referee->lower();
279 view->status->lower(); 279 view->status->lower();
280 } else { 280 } else {
281 view->status->raise(); 281 view->status->raise();
282 view->referee->raise(); 282 view->referee->raise();
283 view->referee->setFocus(); 283 view->referee->setFocus();
284 view->referee->intro(); 284 view->referee->intro();
285 } 285 }
286} 286}
287 287
288void Kpacman::togglePaused() 288void Kpacman::togglePaused()
289{ 289{
290 static bool checked = FALSE; 290 static bool checked = FALSE;
291 checked = !checked; 291 checked = !checked;
292 gamePopup->setItemChecked( pauseID, checked ); 292 gamePopup->setItemChecked( pauseID, checked );
293 view->score->setPause(gamePopup->isItemChecked(pauseID)); 293 view->score->setPause(gamePopup->isItemChecked(pauseID));
294} 294}
295 295
296/* 296/*
297 * This disables the "New Game" menuitem to prevent interruptions of the current 297 * This disables the "New Game" menuitem to prevent interruptions of the current
298 * play. 298 * play.
299 */ 299 */
300void Kpacman::toggleNew() 300void Kpacman::toggleNew()
301{ 301{
302 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID)); 302 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID));
303} 303}
304 304
305void Kpacman::toggleHideMouseCursor() 305void Kpacman::toggleHideMouseCursor()
306{ 306{
307 hideMouseCursor = !hideMouseCursor; 307 hideMouseCursor = !hideMouseCursor;
308 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor); 308 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor);
309 if (hideMouseCursor) 309 if (hideMouseCursor)
310 view->setCursor(blankCursor); 310 view->setCursor(blankCursor);
311 else 311 else
312 view->setCursor(arrowCursor); 312 view->setCursor(arrowCursor);
313} 313}
314 314
315void Kpacman::toggleFocusOutPause() 315void Kpacman::toggleFocusOutPause()
316{ 316{
317 focusOutPause = !focusOutPause; 317 focusOutPause = !focusOutPause;
318 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause); 318 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause);
319 view->referee->setFocusOutPause(focusOutPause); 319 view->referee->setFocusOutPause(focusOutPause);
320} 320}
321 321
322void Kpacman::toggleFocusInContinue() 322void Kpacman::toggleFocusInContinue()
323{ 323{
324 focusInContinue = !focusInContinue; 324 focusInContinue = !focusInContinue;
325 optionsPopup->setItemChecked(focusInContinueID, focusInContinue); 325 optionsPopup->setItemChecked(focusInContinueID, focusInContinue);
326 view->referee->setFocusInContinue(focusInContinue); 326 view->referee->setFocusInContinue(focusInContinue);
327} 327}
328 328
329void Kpacman::confKeys() 329void Kpacman::confKeys()
330{ 330{
331 Keys *keys = new Keys(); 331 Keys *keys = new Keys();
332 if (keys->exec() == QDialog::Accepted) { 332 if (keys->exec() == QDialog::Accepted) {
333 view->referee->initKeys(); 333 view->referee->initKeys();
334 view->score->initKeys(); 334 view->score->initKeys();
335 } 335 }
336 delete keys; 336 delete keys;
337} 337}
338 338
339void Kpacman::schemeChecked(int id) 339void Kpacman::schemeChecked(int id)
340{ 340{
341 int mode = 0, scheme = -1; 341 int mode = 0, scheme = -1;
342 342
343 for (uint s = 0; s < schemeID.size(); s++) { 343 for (uint s = 0; s < schemeID.size(); s++) {
344 if (schemeID[s] == id) { 344 if (schemeID[s] == id) {
345 scheme = s; 345 scheme = s;
346 mode = schemeMode[s]; 346 mode = schemeMode[s];
347 } 347 }
348 if (schemeMode[s] == -1) { 348 if (schemeMode[s] == -1) {
349 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); 349 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id);
350 } else { 350 } else {
351 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); 351 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode);
352 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); 352 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id);
353 } 353 }
354 } 354 }
355 /* 355 /*
356 APP_CONFIG_BEGIN( cfg ); 356 APP_CONFIG_BEGIN( cfg );
357 cfg->writeEntry("Scheme", scheme); 357 cfg->writeEntry("Scheme", scheme);
358 cfg->writeEntry("Mode", mode); 358 cfg->writeEntry("Mode", mode);
359 APP_CONFIG_END( cfg ); 359 APP_CONFIG_END( cfg );
360 */ 360 */
361 361
362 view->setScheme(scheme, mode); 362 view->setScheme(scheme, mode);
363 view->updateGeometry(); 363 view->updateGeometry();
364 updateGeometry(); 364 updateGeometry();
365 update(); 365 update();
366 repaint(TRUE); 366 repaint(TRUE);
367 show(); 367 show();
368} 368}
diff --git a/noncore/games/mindbreaker/opie-mindbreaker.control b/noncore/games/mindbreaker/opie-mindbreaker.control
index 7623d6a..7b5ead6 100644
--- a/noncore/games/mindbreaker/opie-mindbreaker.control
+++ b/noncore/games/mindbreaker/opie-mindbreaker.control
@@ -1,10 +1,10 @@
1Package: opie-mindbreaker 1Package: opie-mindbreaker
2Files: bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker 2Files: bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Game: crack the coloured code 8Description: Game: crack the coloured code
10 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/minesweep/opie-minesweep.control b/noncore/games/minesweep/opie-minesweep.control
index 7236cf8..32f0352 100644
--- a/noncore/games/minesweep/opie-minesweep.control
+++ b/noncore/games/minesweep/opie-minesweep.control
@@ -1,10 +1,10 @@
1Package: opie-minesweep 1Package: opie-minesweep
2Files: bin/minesweep apps/Games/minesweep.desktop pics/minesweep 2Files: bin/minesweep apps/Games/minesweep.desktop pics/minesweep
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Game: find the mines 8Description: Game: find the mines
10 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/parashoot/opie-parashoot.control b/noncore/games/parashoot/opie-parashoot.control
index ad955f5..758d24d 100644
--- a/noncore/games/parashoot/opie-parashoot.control
+++ b/noncore/games/parashoot/opie-parashoot.control
@@ -1,10 +1,10 @@
1Package: opie-parashoot 1Package: opie-parashoot
2Files: bin/parashoot apps/Games/parashoot.desktop pics/parashoot 2Files: bin/parashoot apps/Games/parashoot.desktop pics/parashoot
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Game: shoot the parachutists 8Description: Game: shoot the parachutists
10 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/qasteroids/opie-qasteroids.control b/noncore/games/qasteroids/opie-qasteroids.control
index 49cc6b2..25a49b4 100644
--- a/noncore/games/qasteroids/opie-qasteroids.control
+++ b/noncore/games/qasteroids/opie-qasteroids.control
@@ -1,10 +1,10 @@
1Package: opie-qasteroids 1Package: opie-qasteroids
2Files: bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/* 2Files: bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/*
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Jones <mjones@trolltech.com> 5Maintainer: Martin Jones <mjones@trolltech.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Game: shoot the asteroids 8Description: Game: shoot the asteroids
10 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/sfcave-sdl/sfcave-sdl.control b/noncore/games/sfcave-sdl/sfcave-sdl.control
index c017280..9bf43ba 100644
--- a/noncore/games/sfcave-sdl/sfcave-sdl.control
+++ b/noncore/games/sfcave-sdl/sfcave-sdl.control
@@ -1,10 +1,10 @@
1Files: bin/sfcave-sdl apps/Games/sfcave-sdl.desktop pics/sfcave-sdl sounds/sfcave-sdl 1Files: bin/sfcave-sdl apps/Games/sfcave-sdl.desktop pics/sfcave-sdl sounds/sfcave-sdl
2Package: sfcave-sdl 2Package: sfcave-sdl
3Priority: optional 3Priority: optional
4Section: Games 4Section: Games
5Version: $QPE_VERSION-$SUB_VERSION
6Architecture: arm 5Architecture: arm
7Maintainer: Andy Qua (andy.qua@blueyonder.co.uk) 6Maintainer: Andy Qua (andy.qua@blueyonder.co.uk)
8Depends: libSDL,libSDL_-mixer,libSDL-image,libSDL-gfx 7Depends: libSDL,libSDL_-mixer,libSDL-image,libSDL-gfx
9Description: SFCave SDL for the Zaurus. Fly though the cave avoiding the walls. 8Description: SFCave SDL for the Zaurus. Fly though the cave avoiding the walls.
10 9
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/sfcave/opie-sfcave.control b/noncore/games/sfcave/opie-sfcave.control
index 1566959..0ff3e2c 100644
--- a/noncore/games/sfcave/opie-sfcave.control
+++ b/noncore/games/sfcave/opie-sfcave.control
@@ -1,9 +1,9 @@
1Package: opie-sfcave 1Package: opie-sfcave
2Files: bin/sfcave apps/Games/sfcave.desktop pics/sfcave 2Files: bin/sfcave apps/Games/sfcave.desktop pics/sfcave
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Andy Qua <andy.qua@blueyonder.co.uk> 5Maintainer: Andy Qua <andy.qua@blueyonder.co.uk>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: SFCave for the Zaurus. Fly the dot though the cave avoiding the walls. 8Description: SFCave for the Zaurus. Fly the dot though the cave avoiding the walls.
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp
index 0f312ac..68e0f14 100644
--- a/noncore/games/snake/interface.cpp
+++ b/noncore/games/snake/interface.cpp
@@ -1,221 +1,221 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qstyle.h> 27#include <qstyle.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30 30
31SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : 31SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) :
32 QMainWindow(parent,name,f), 32 QMainWindow(parent,name,f),
33 canvas(232, 258) 33 canvas(232, 258)
34{ 34{
35 setCaption( tr("Snake") ); 35 setCaption( tr("Snake") );
36 QPixmap bg = Resource::loadPixmap("snake/grass"); 36 QPixmap bg = Resource::loadPixmap("snake/grass");
37 canvas.setBackgroundPixmap(bg); 37 canvas.setBackgroundPixmap(bg);
38 canvas.setUpdatePeriod(100); 38 canvas.setUpdatePeriod(100);
39 snake = 0; 39 snake = 0;
40 40
41 cv = new QCanvasView(&canvas, this); 41 cv = new QCanvasView(&canvas, this);
42 42
43 pauseTimer = new QTimer(this); 43 pauseTimer = new QTimer(this);
44 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); 44 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
45 45
46 setToolBarsMovable( FALSE ); 46 setToolBarsMovable( FALSE );
47 47
48 QPEToolBar* toolbar = new QPEToolBar( this); 48 QPEToolBar* toolbar = new QPEToolBar( this);
49 toolbar->setHorizontalStretchable( TRUE ); 49 toolbar->setHorizontalStretchable( TRUE );
50 50
51 QPixmap newicon = Resource::loadPixmap("ksnake"); 51 QPixmap newicon = Resource::loadPixmap("ksnake");
52 setIcon(newicon); 52 setIcon(newicon);
53 (void)new QToolButton(newicon, tr("New Game"), 0, 53 (void)new QToolButton(newicon, tr("New Game"), 0,
54 this, SLOT(newGame()), toolbar, "New Game"); 54 this, SLOT(newGame()), toolbar, "New Game");
55 55
56 scorelabel = new QLabel(toolbar); 56 scorelabel = new QLabel(toolbar);
57 showScore(0); 57 showScore(0);
58 scorelabel->setBackgroundMode( PaletteButton ); 58 scorelabel->setBackgroundMode( PaletteButton );
59 scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); 59 scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
60 toolbar->setStretchableWidget( scorelabel ); 60 toolbar->setStretchableWidget( scorelabel );
61 61
62 setFocusPolicy(StrongFocus); 62 setFocusPolicy(StrongFocus);
63 63
64 setCentralWidget(cv); 64 setCentralWidget(cv);
65 65
66 QTimer::singleShot( 16, this, SLOT(welcomescreen()) ); 66 QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
67 gamestopped = true; 67 gamestopped = true;
68 waitover = true; 68 waitover = true;
69} 69}
70 70
71SnakeGame::~SnakeGame() 71SnakeGame::~SnakeGame()
72{ 72{
73 delete snake; 73 delete snake;
74} 74}
75 75
76void SnakeGame::resizeEvent(QResizeEvent *) 76void SnakeGame::resizeEvent(QResizeEvent *)
77{ 77{
78 QSize s = centralWidget()->size(); 78 QSize s = centralWidget()->size();
79 int fw = style().defaultFrameWidth(); 79 int fw = style().defaultFrameWidth();
80 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 80 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
81} 81}
82 82
83void SnakeGame::welcomescreen() 83void SnakeGame::welcomescreen()
84{ 84{
85 QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas); 85 QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas);
86 title->setColor(yellow); 86 title->setColor(yellow);
87 title->setFont( QFont("times", 18, QFont::Bold) ); 87 title->setFont( QFont("times", 18, QFont::Bold) );
88 int w = title->boundingRect().width(); 88 int w = title->boundingRect().width();
89 title->move(canvas.width()/2 -w/2, canvas.height()/2-110); 89 title->move(canvas.width()/2 -w/2, canvas.height()/2-110);
90 title->show(); 90 title->show();
91 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title")); 91 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title"));
92 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); 92 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas);
93 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); 93 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85);
94 titlepic->show(); 94 titlepic->show();
95 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" 95 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n"
96 "snake to eat the mouse. You must not\n" 96 "snake to eat the mouse. You must not\n"
97 "crash into the walls, edges or its tail."), 97 "crash into the walls, edges or its tail."),
98 &canvas); 98 &canvas);
99 w = instr->boundingRect().width(); 99 w = instr->boundingRect().width();
100 instr->move(canvas.width()/2-w/2, canvas.height()/2-20); 100 instr->move(canvas.width()/2-w/2, canvas.height()/2-20);
101 instr->setColor(white); 101 instr->setColor(white);
102 instr->show(); 102 instr->show();
103 QCanvasText* cont = new QCanvasText(tr("Press Any Key To Start"), &canvas); 103 QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas);
104 w = cont->boundingRect().width(); 104 w = cont->boundingRect().width();
105 cont->move(canvas.width()/2-w/2, canvas.height()-20); 105 cont->move(canvas.width()/2-w/2, canvas.height()-20);
106 cont->setColor(yellow); 106 cont->setColor(yellow);
107 cont->show(); 107 cont->show();
108 108
109} 109}
110 110
111void SnakeGame::newGame() 111void SnakeGame::newGame()
112{ 112{
113 clear(); 113 clear();
114 snake = new Snake(&canvas); 114 snake = new Snake(&canvas);
115 connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) ); 115 connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) );
116 connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) ); 116 connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) );
117 connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) ); 117 connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) );
118 connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) ); 118 connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) );
119 last = 0; 119 last = 0;
120 targetamount = 1; 120 targetamount = 1;
121 notargets = 1; 121 notargets = 1;
122 level = 1; 122 level = 1;
123 stage = 1; 123 stage = 1;
124 showScore(0); 124 showScore(0);
125 gamestopped = false; 125 gamestopped = false;
126 waitover = true; 126 waitover = true;
127 int y = canvas.height()-50; 127 int y = canvas.height()-50;
128 (void)new Obstacle(&canvas, 32); 128 (void)new Obstacle(&canvas, 32);
129 (void)new Obstacle(&canvas, y); 129 (void)new Obstacle(&canvas, y);
130 createTargets(); 130 createTargets();
131} 131}
132 132
133 133
134void SnakeGame::showScore(int score) 134void SnakeGame::showScore(int score)
135{ 135{
136 scorelabel->setText(tr(" Score : %1 ").arg(score) ); 136 scorelabel->setText(tr(" Score : %1 ").arg(score) );
137} 137}
138 138
139 139
140void SnakeGame::scoreInc() 140void SnakeGame::scoreInc()
141{ 141{
142 showScore( snake->getScore() ); 142 showScore( snake->getScore() );
143} 143}
144 144
145void SnakeGame::levelUp() 145void SnakeGame::levelUp()
146{ 146{
147 notargets--; 147 notargets--;
148 if (notargets == 0) { 148 if (notargets == 0) {
149 stage++; 149 stage++;
150 if (stage == 3) { 150 if (stage == 3) {
151 level++; 151 level++;
152 emit moveFaster(); 152 emit moveFaster();
153 targetamount++; 153 targetamount++;
154 stage = 0; 154 stage = 0;
155 } 155 }
156 createTargets(); 156 createTargets();
157 } 157 }
158} 158}
159 159
160void SnakeGame::createTargets() 160void SnakeGame::createTargets()
161{ 161{
162 for (int i = 0; i < targetamount; i++) 162 for (int i = 0; i < targetamount; i++)
163 (void)new Target(&canvas); 163 (void)new Target(&canvas);
164 notargets = targetamount; 164 notargets = targetamount;
165} 165}
166 166
167void SnakeGame::clear() 167void SnakeGame::clear()
168{ 168{
169 delete snake; 169 delete snake;
170 snake = 0; 170 snake = 0;
171 QCanvasItemList l = canvas.allItems(); 171 QCanvasItemList l = canvas.allItems();
172 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { 172 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
173 delete *it; 173 delete *it;
174 } 174 }
175} 175}
176 176
177void SnakeGame::gameOver() 177void SnakeGame::gameOver()
178{ 178{
179 int score = snake->getScore(); 179 int score = snake->getScore();
180 QString scoreoutput=""; 180 QString scoreoutput="";
181 scoreoutput.setNum(score); 181 scoreoutput.setNum(score);
182 QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas); 182 QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas);
183 183
184 gameover->setZ(100); 184 gameover->setZ(100);
185 gameover->setColor(yellow); 185 gameover->setColor(yellow);
186 gameover->setFont( QFont("times", 18, QFont::Bold) ); 186 gameover->setFont( QFont("times", 18, QFont::Bold) );
187 int w = gameover->boundingRect().width(); 187 int w = gameover->boundingRect().width();
188 gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50); 188 gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50);
189 gameover->show(); 189 gameover->show();
190 gamestopped = true; 190 gamestopped = true;
191 waitover = false; 191 waitover = false;
192 pauseTimer->start(1500); 192 pauseTimer->start(1500);
193} 193}
194 194
195void SnakeGame::wait() 195void SnakeGame::wait()
196{ 196{
197 waitover = true; 197 waitover = true;
198 pauseTimer->stop(); 198 pauseTimer->stop();
199 QCanvasText* cont = new QCanvasText(tr("Press Any Key to Begin a New Game."), 199 QCanvasText* cont = new QCanvasText(tr("Press any key to begin a new game."),
200 &canvas); 200 &canvas);
201 cont->setZ(100); 201 cont->setZ(100);
202 cont->setColor(white); 202 cont->setColor(white);
203 int w = cont->boundingRect().width(); 203 int w = cont->boundingRect().width();
204 cont->move(canvas.width()/2 -w/2, canvas.height()/2); 204 cont->move(canvas.width()/2 -w/2, canvas.height()/2);
205 cont->show(); 205 cont->show();
206} 206}
207 207
208void SnakeGame::keyPressEvent(QKeyEvent* event) 208void SnakeGame::keyPressEvent(QKeyEvent* event)
209{ 209{
210 if (gamestopped) { 210 if (gamestopped) {
211 if (waitover) 211 if (waitover)
212 newGame(); 212 newGame();
213 else 213 else
214 return; 214 return;
215 } 215 }
216 else { 216 else {
217 int newkey = event->key(); 217 int newkey = event->key();
218 snake->go(newkey); 218 snake->go(newkey);
219 } 219 }
220} 220}
221 221
diff --git a/noncore/games/snake/opie-snake.control b/noncore/games/snake/opie-snake.control
index 3ab6640..ef4fc61 100644
--- a/noncore/games/snake/opie-snake.control
+++ b/noncore/games/snake/opie-snake.control
@@ -1,10 +1,10 @@
1Package: opie-snake 1Package: opie-snake
2Files: bin/snake apps/Games/snake.desktop pics/snake 2Files: bin/snake apps/Games/snake.desktop pics/snake
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Game: control the snake 8Description: Game: control the snake
10 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp
index e836eb2..317a02d 100644
--- a/noncore/games/solitaire/canvascardwindow.cpp
+++ b/noncore/games/solitaire/canvascardwindow.cpp
@@ -1,314 +1,314 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22#include "patiencecardgame.h" 22#include "patiencecardgame.h"
23#include "freecellcardgame.h" 23#include "freecellcardgame.h"
24#include "chicanecardgame.h" 24#include "chicanecardgame.h"
25#include "harpcardgame.h" 25#include "harpcardgame.h"
26#include "teeclubcardgame.h" 26#include "teeclubcardgame.h"
27 27
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29 29
30#include <qmainwindow.h> 30#include <qmainwindow.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qstyle.h> 32#include <qstyle.h>
33 33
34 34
35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : 35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) :
36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), 36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0),
37 cardGame(NULL) 37 cardGame(NULL)
38{ 38{
39 setIcon( Resource::loadPixmap( "cards" ) ); 39 setIcon( Resource::loadPixmap( "cards" ) );
40 40
41 // Create Playing Area for Games 41 // Create Playing Area for Games
42 if ( QPixmap::defaultDepth() < 12 ) { 42 if ( QPixmap::defaultDepth() < 12 ) {
43// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); 43// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B));
44// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); 44// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50));
45 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); 45 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D));
46 } else { 46 } else {
47 QPixmap bg; 47 QPixmap bg;
48 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); 48 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither );
49 canvas.setBackgroundPixmap(bg); 49 canvas.setBackgroundPixmap(bg);
50 } 50 }
51 51
52#if defined( QT_QWS_CASSIOPEIA ) 52#if defined( QT_QWS_CASSIOPEIA )
53 canvas.setAdvancePeriod(70); 53 canvas.setAdvancePeriod(70);
54#else 54#else
55 canvas.setAdvancePeriod(30); 55 canvas.setAdvancePeriod(30);
56#endif 56#endif
57 57
58 58
59#ifdef _PATIENCE_USE_ACCELS_ 59#ifdef _PATIENCE_USE_ACCELS_
60 QPEMenuBar* menu = menuBar(); 60 QPEMenuBar* menu = menuBar();
61 61
62 QPopupMenu* file = new QPopupMenu; 62 QPopupMenu* file = new QPopupMenu;
63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); 63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); 64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
65 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); 65 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F);
66 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); 66 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F);
67 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); 67 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F);
68 menu->insertItem(tr("&Game"), file); 68 menu->insertItem(tr("&Game"), file);
69 69
70 menu->insertSeparator(); 70 menu->insertSeparator();
71 71
72 settings = new QPopupMenu; 72 settings = new QPopupMenu;
73 settings->insertItem(tr("&Change Card Backs"), this, SLOT(changeCardBacks()), Key_F2); 73 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2);
74 snap_id = settings->insertItem(tr("&Snap To Position"), this, SLOT(snapToggle()), Key_F3); 74 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3);
75 settings->setCheckable(TRUE); 75 settings->setCheckable(TRUE);
76 menu->insertItem(tr("&Settings"),settings); 76 menu->insertItem(tr("&Settings"),settings);
77 77
78 menu->insertSeparator(); 78 menu->insertSeparator();
79 79
80 QPopupMenu* help = new QPopupMenu; 80 QPopupMenu* help = new QPopupMenu;
81 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); 81 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1);
82 help->setItemChecked(dbf_id, TRUE); 82 help->setItemChecked(dbf_id, TRUE);
83 menu->insertItem(tr("&Help"),help); 83 menu->insertItem(tr("&Help"),help);
84#else 84#else
85 QMenuBar* menu = menuBar(); 85 QMenuBar* menu = menuBar();
86 86
87 QPopupMenu* file = new QPopupMenu; 87 QPopupMenu* file = new QPopupMenu;
88 file->insertItem(tr("Patience"), this, SLOT(initPatience())); 88 file->insertItem(tr("Patience"), this, SLOT(initPatience()));
89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); 89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
90 file->insertItem(tr("Chicane"), this, SLOT(initChicane())); 90 file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
91 file->insertItem(tr("Harp"), this, SLOT(initHarp())); 91 file->insertItem(tr("Harp"), this, SLOT(initHarp()));
92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); 92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()));
93 menu->insertItem(tr("Play"), file); 93 menu->insertItem(tr("Play"), file);
94 94
95 menu->insertSeparator(); 95 menu->insertSeparator();
96 96
97 settings = new QPopupMenu; 97 settings = new QPopupMenu;
98 settings->setCheckable(TRUE); 98 settings->setCheckable(TRUE);
99 settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks())); 99 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks()));
100 snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle())); 100 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle()));
101 QString m; 101 QString m;
102 102
103 drawId = settings->insertItem(tr("Turn One Card"), this, SLOT(drawnToggle())); 103 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle()));
104 menu->insertItem(tr("Settings"),settings); 104 menu->insertItem(tr("Settings"),settings);
105 settings->setCheckable(TRUE); 105 settings->setCheckable(TRUE);
106 106
107#endif 107#endif
108 108
109 menu->show(); 109 menu->show();
110 110
111 Config cfg( "Patience" ); 111 Config cfg( "Patience" );
112 cfg.setGroup( "GlobalSettings" ); 112 cfg.setGroup( "GlobalSettings" );
113 snapOn = cfg.readBoolEntry( "SnapOn", TRUE); 113 snapOn = cfg.readBoolEntry( "SnapOn", TRUE);
114 settings->setItemChecked(snap_id, snapOn); 114 settings->setItemChecked(snap_id, snapOn);
115 115
116 gameType = cfg.readNumEntry( "GameType", -1 ); 116 gameType = cfg.readNumEntry( "GameType", -1 );
117 drawThree = cfg.readBoolEntry( "DrawThree", FALSE); 117 drawThree = cfg.readBoolEntry( "DrawThree", FALSE);
118 if ( gameType == 0 ) { 118 if ( gameType == 0 ) {
119 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 119 cardGame = new PatienceCardGame( &canvas, snapOn, this );
120 cardGame->setNumberToDraw(drawThree ? 3 : 1); 120 cardGame->setNumberToDraw(drawThree ? 3 : 1);
121 121
122 setCaption(tr("Patience")); 122 setCaption(tr("Patience"));
123 setCentralWidget(cardGame); 123 setCentralWidget(cardGame);
124 cardGame->readConfig( cfg ); 124 cardGame->readConfig( cfg );
125 setCardBacks(); 125 setCardBacks();
126 } else if ( gameType == 1 ) { 126 } else if ( gameType == 1 ) {
127 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 127 cardGame = new FreecellCardGame( &canvas, snapOn, this );
128 setCaption(tr("Freecell")); 128 setCaption(tr("Freecell"));
129 setCentralWidget(cardGame); 129 setCentralWidget(cardGame);
130 //cardGame->newGame(); // Until we know how to handle reading freecell config 130 //cardGame->newGame(); // Until we know how to handle reading freecell config
131 cardGame->readConfig( cfg ); 131 cardGame->readConfig( cfg );
132 setCardBacks(); 132 setCardBacks();
133 } else if ( gameType == 2 ) { 133 } else if ( gameType == 2 ) {
134 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 134 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
135 cardGame->setNumberToDraw(1); 135 cardGame->setNumberToDraw(1);
136 setCaption(tr("Chicane")); 136 setCaption(tr("Chicane"));
137 setCentralWidget(cardGame); 137 setCentralWidget(cardGame);
138 cardGame->readConfig( cfg ); 138 cardGame->readConfig( cfg );
139 setCardBacks(); 139 setCardBacks();
140 } else if ( gameType == 3 ) { 140 } else if ( gameType == 3 ) {
141 cardGame = new HarpCardGame( &canvas, snapOn, this ); 141 cardGame = new HarpCardGame( &canvas, snapOn, this );
142 cardGame->setNumberToDraw(1); 142 cardGame->setNumberToDraw(1);
143 setCaption(tr("Harp")); 143 setCaption(tr("Harp"));
144 setCentralWidget(cardGame); 144 setCentralWidget(cardGame);
145 cardGame->readConfig( cfg ); 145 cardGame->readConfig( cfg );
146 setCardBacks(); 146 setCardBacks();
147 } else if ( gameType == 4 ) { 147 } else if ( gameType == 4 ) {
148 cardGame = new TeeclubCardGame( &canvas, snapOn, this ); 148 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
149 cardGame->setNumberToDraw(1); 149 cardGame->setNumberToDraw(1);
150 setCaption(tr("Teeclub")); 150 setCaption(tr("Teeclub"));
151 setCentralWidget(cardGame); 151 setCentralWidget(cardGame);
152 cardGame->readConfig( cfg ); 152 cardGame->readConfig( cfg );
153 setCardBacks(); 153 setCardBacks();
154 } else { 154 } else {
155 // Probably there isn't a config file or it is broken 155 // Probably there isn't a config file or it is broken
156 // Start a new game 156 // Start a new game
157 initPatience(); 157 initPatience();
158 } 158 }
159 159
160 updateDraw(); 160 updateDraw();
161} 161}
162 162
163 163
164CanvasCardWindow::~CanvasCardWindow() 164CanvasCardWindow::~CanvasCardWindow()
165{ 165{
166 if (cardGame) { 166 if (cardGame) {
167 Config cfg("Patience"); 167 Config cfg("Patience");
168 cfg.setGroup( "GlobalSettings" ); 168 cfg.setGroup( "GlobalSettings" );
169 cfg.writeEntry( "GameType", gameType ); 169 cfg.writeEntry( "GameType", gameType );
170 cfg.writeEntry( "SnapOn", snapOn ); 170 cfg.writeEntry( "SnapOn", snapOn );
171 cfg.writeEntry( "DrawThree", drawThree); 171 cfg.writeEntry( "DrawThree", drawThree);
172 cfg.write(); 172 cfg.write();
173 cardGame->writeConfig( cfg ); 173 cardGame->writeConfig( cfg );
174 delete cardGame; 174 delete cardGame;
175 } 175 }
176} 176}
177 177
178 178
179void CanvasCardWindow::resizeEvent(QResizeEvent *) 179void CanvasCardWindow::resizeEvent(QResizeEvent *)
180{ 180{
181 QSize s = centralWidget()->size(); 181 QSize s = centralWidget()->size();
182 int fw = style().defaultFrameWidth(); 182 int fw = style().defaultFrameWidth();
183 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 183 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
184} 184}
185 185
186 186
187void CanvasCardWindow::initPatience() 187void CanvasCardWindow::initPatience()
188{ 188{
189 // Create New Game 189 // Create New Game
190 if ( cardGame ) 190 if ( cardGame )
191 delete cardGame; 191 delete cardGame;
192 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 192 cardGame = new PatienceCardGame( &canvas, snapOn, this );
193 cardGame->setNumberToDraw(drawThree ? 3 : 1); 193 cardGame->setNumberToDraw(drawThree ? 3 : 1);
194 gameType = 0; 194 gameType = 0;
195 setCaption(tr("Patience")); 195 setCaption(tr("Patience"));
196 setCentralWidget(cardGame); 196 setCentralWidget(cardGame);
197 cardGame->newGame(); 197 cardGame->newGame();
198 setCardBacks(); 198 setCardBacks();
199 updateDraw(); 199 updateDraw();
200} 200}
201 201
202 202
203void CanvasCardWindow::initFreecell() 203void CanvasCardWindow::initFreecell()
204{ 204{
205 // Create New Game 205 // Create New Game
206 if ( cardGame ) { 206 if ( cardGame ) {
207 delete cardGame; 207 delete cardGame;
208 } 208 }
209 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 209 cardGame = new FreecellCardGame( &canvas, snapOn, this );
210 gameType = 1; 210 gameType = 1;
211 setCaption(tr("Freecell")); 211 setCaption(tr("Freecell"));
212 setCentralWidget(cardGame); 212 setCentralWidget(cardGame);
213 cardGame->newGame(); 213 cardGame->newGame();
214 setCardBacks(); 214 setCardBacks();
215} 215}
216 216
217 217
218void CanvasCardWindow::initChicane() 218void CanvasCardWindow::initChicane()
219{ 219{
220 // Create New Game 220 // Create New Game
221 if ( cardGame ) { 221 if ( cardGame ) {
222 delete cardGame; 222 delete cardGame;
223 } 223 }
224 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 224 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
225 cardGame->setNumberToDraw(1); 225 cardGame->setNumberToDraw(1);
226 gameType = 2; 226 gameType = 2;
227 setCaption(tr("Chicane")); 227 setCaption(tr("Chicane"));
228 setCentralWidget(cardGame); 228 setCentralWidget(cardGame);
229 cardGame->newGame(); 229 cardGame->newGame();
230 setCardBacks(); 230 setCardBacks();
231} 231}
232 232
233void CanvasCardWindow::initHarp() 233void CanvasCardWindow::initHarp()
234{ 234{
235 // Create New Game 235 // Create New Game
236 if ( cardGame ) { 236 if ( cardGame ) {
237 delete cardGame; 237 delete cardGame;
238 } 238 }
239 cardGame = new HarpCardGame( &canvas, snapOn, this ); 239 cardGame = new HarpCardGame( &canvas, snapOn, this );
240 cardGame->setNumberToDraw(1); 240 cardGame->setNumberToDraw(1);
241 gameType = 3; 241 gameType = 3;
242 setCaption(tr("Harp")); 242 setCaption(tr("Harp"));
243 setCentralWidget(cardGame); 243 setCentralWidget(cardGame);
244 cardGame->newGame(); 244 cardGame->newGame();
245 setCardBacks(); 245 setCardBacks();
246} 246}
247 247
248 248
249void CanvasCardWindow::initTeeclub() 249void CanvasCardWindow::initTeeclub()
250{ 250{
251 // Create New Game 251 // Create New Game
252 if ( cardGame ) { 252 if ( cardGame ) {
253 delete cardGame; 253 delete cardGame;
254 } 254 }
255 cardGame = new TeeclubCardGame( &canvas, snapOn, this ); 255 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
256 cardGame->setNumberToDraw(1); 256 cardGame->setNumberToDraw(1);
257 gameType = 4; 257 gameType = 4;
258 setCaption(tr("Teeclub")); 258 setCaption(tr("Teeclub"));
259 setCentralWidget(cardGame); 259 setCentralWidget(cardGame);
260 cardGame->newGame(); 260 cardGame->newGame();
261 setCardBacks(); 261 setCardBacks();
262} 262}
263 263
264 264
265void CanvasCardWindow::snapToggle() 265void CanvasCardWindow::snapToggle()
266{ 266{
267 snapOn = !snapOn; 267 snapOn = !snapOn;
268 settings->setItemChecked(snap_id, snapOn); 268 settings->setItemChecked(snap_id, snapOn);
269 cardGame->toggleSnap(); 269 cardGame->toggleSnap();
270} 270}
271 271
272 272
273void CanvasCardWindow::drawnToggle() 273void CanvasCardWindow::drawnToggle()
274{ 274{
275 drawThree=!drawThree; 275 drawThree=!drawThree;
276 Config cfg( "Patience" ); 276 Config cfg( "Patience" );
277 cfg.setGroup( "GlobalSettings" ); 277 cfg.setGroup( "GlobalSettings" );
278 cardGame->toggleCardsDrawn(); 278 cardGame->toggleCardsDrawn();
279 updateDraw(); 279 updateDraw();
280 cfg.writeEntry( "DrawThree", drawThree); 280 cfg.writeEntry( "DrawThree", drawThree);
281 cfg.write(); 281 cfg.write();
282} 282}
283 283
284void CanvasCardWindow::updateDraw() { 284void CanvasCardWindow::updateDraw() {
285 if(cardGame->cardsDrawn() == 3){ 285 if(cardGame->cardsDrawn() == 3){
286 settings->changeItem(drawId, tr("Turn One Card")); 286 settings->changeItem(drawId, tr("Turn one card"));
287 } else { 287 } else {
288 settings->changeItem(drawId, tr("Turn Three Cards")); 288 settings->changeItem(drawId, tr("Turn three cards"));
289 } 289 }
290} 290}
291 291
292 292
293void CanvasCardWindow::setCardBacks() 293void CanvasCardWindow::setCardBacks()
294{ 294{
295 QCanvasItemList l = canvas.allItems(); 295 QCanvasItemList l = canvas.allItems();
296 296
297 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { 297 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
298 if ( (*it)->rtti() == canvasCardId ) 298 if ( (*it)->rtti() == canvasCardId )
299 ((CanvasCard *)(*it))->setCardBack( cardBack ); 299 ((CanvasCard *)(*it))->setCardBack( cardBack );
300 } 300 }
301} 301}
302 302
303 303
304void CanvasCardWindow::changeCardBacks() 304void CanvasCardWindow::changeCardBacks()
305{ 305{
306 cardBack++; 306 cardBack++;
307 307
308 if (cardBack == 5) 308 if (cardBack == 5)
309 cardBack = 0; 309 cardBack = 0;
310 310
311 setCardBacks(); 311 setCardBacks();
312} 312}
313 313
314 314
diff --git a/noncore/games/solitaire/opie-solitaire.control b/noncore/games/solitaire/opie-solitaire.control
index 76e7208..5fa521f 100644
--- a/noncore/games/solitaire/opie-solitaire.control
+++ b/noncore/games/solitaire/opie-solitaire.control
@@ -1,10 +1,10 @@
1Package: opie-solitaire 1Package: opie-solitaire
2Files: bin/patience apps/Games/patience.desktop pics/cards 2Files: bin/patience apps/Games/patience.desktop pics/cards
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Game: solitaire card games 8Description: Game: solitaire card games
10 A solitaire game for the Opie environment. 9 A solitaire game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/tetrix/opie-tetrix.control b/noncore/games/tetrix/opie-tetrix.control
index e335507..e901dbf 100644
--- a/noncore/games/tetrix/opie-tetrix.control
+++ b/noncore/games/tetrix/opie-tetrix.control
@@ -1,11 +1,11 @@
1Package: opie-tetrix 1Package: opie-tetrix
2Files: bin/tetrix apps/Games/tetrix.desktop pics/tetrix/* 2Files: bin/tetrix apps/Games/tetrix.desktop pics/tetrix/*
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Arch: iPAQ 7Arch: iPAQ
8Version: $QPE_VERSION-$SUB_VERSION
9Depends: task-opie-minimal 8Depends: task-opie-minimal
10Description: Game: control falling blocks 9Description: Game: control falling blocks
11 A game for the Opie environment. 10 A game for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/tictac/main.cpp b/noncore/games/tictac/main.cpp
index f2ab334..78fb3b7 100644
--- a/noncore/games/tictac/main.cpp
+++ b/noncore/games/tictac/main.cpp
@@ -1,31 +1,31 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of an example program for Qt. This example 6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation. 7** program may be used, distributed and modified without limitation.
8** 8**
9*****************************************************************************/ 9*****************************************************************************/
10 10
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include "tictac.h" 13#include "tictac.h"
14 14
15 15
16int main( int argc, char **argv ) 16int main( int argc, char **argv )
17{ 17{
18 QPEApplication a( argc, argv ); 18 QPEApplication a( argc, argv );
19 int n = 3; 19 int n = 3;
20 if ( argc == 2 ) // get board size n 20 if ( argc == 2 ) // get board size n
21 n = atoi(argv[1]); 21 n = atoi(argv[1]);
22 if ( n < 3 || n > 10 ) { // out of range 22 if ( n < 3 || n > 10 ) { // out of range
23 qWarning( "%s: Board size must be from 3x3 to 10x10", argv[0] ); 23 qWarning( "%s: Board size must be from 3x3 to 10x10", argv[0] );
24 return 1; 24 return 1;
25 } 25 }
26 TicTacToe ttt( n ); // create game 26 TicTacToe ttt( n ); // create game
27 a.setMainWidget( &ttt ); 27 a.setMainWidget( &ttt );
28 ttt.setCaption("TicTac"); 28 ttt.setCaption( QObject::tr("TicTac") );
29 ttt.show(); // show widget 29 ttt.show(); // show widget
30 return a.exec(); // go 30 return a.exec(); // go
31} 31}
diff --git a/noncore/games/tictac/opie-tictac.control b/noncore/games/tictac/opie-tictac.control
index c4ee36c..0074505 100644
--- a/noncore/games/tictac/opie-tictac.control
+++ b/noncore/games/tictac/opie-tictac.control
@@ -1,9 +1,9 @@
1Package: opie-tictac 1Package: opie-tictac
2Files: bin/tictac apps/Games/tictac.desktop pics/tictac 2Files: bin/tictac apps/Games/tictac.desktop pics/tictac
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: ljp <ljp@llornkcor.com> 5Maintainer: ljp <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Tic Tac Toe game. 8Description: Tic Tac Toe game.
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/wordgame/opie-wordgame.control b/noncore/games/wordgame/opie-wordgame.control
index 3be8e8f..c7dc126 100644
--- a/noncore/games/wordgame/opie-wordgame.control
+++ b/noncore/games/wordgame/opie-wordgame.control
@@ -1,11 +1,11 @@
1Package: opie-wordgame 1Package: opie-wordgame
2Files: bin/wordgame apps/Games/wordgame.desktop pics/wordgame 2Files: bin/wordgame apps/Games/wordgame.desktop pics/wordgame
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Crossword game 8Description: Crossword game
10 A crossword game for the Opie environment. 9 A crossword game for the Opie environment.
11 Play against the computer or human opponents. 10 Play against the computer or human opponents.
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp
index d3160f4..d46e824 100644
--- a/noncore/games/wordgame/wordgame.cpp
+++ b/noncore/games/wordgame/wordgame.cpp
@@ -1,1519 +1,1519 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21 21
22#include "wordgame.h" 22#include "wordgame.h"
23 23
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/global.h> 25#include <qpe/global.h>
26#include <qpe/filemanager.h> 26#include <qpe/filemanager.h>
27#include <qpe/resource.h> 27#include <qpe/resource.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29 29
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qdir.h> 36#include <qdir.h>
37#include <qiconset.h> 37#include <qiconset.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qpe/qpetoolbar.h> 43#include <qpe/qpetoolbar.h>
44#include <qtoolbutton.h> 44#include <qtoolbutton.h>
45#include <qvbox.h> 45#include <qvbox.h>
46#include <qwidgetstack.h> 46#include <qwidgetstack.h>
47#include <qpainter.h> 47#include <qpainter.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qregexp.h> 49#include <qregexp.h>
50 50
51#include <stdlib.h> 51#include <stdlib.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <pwd.h> 53#include <pwd.h>
54#include <sys/types.h> 54#include <sys/types.h>
55 55
56enum RuleEffects { 56enum RuleEffects {
57 Multiplier=15, 57 Multiplier=15,
58 MultiplyAll=64, 58 MultiplyAll=64,
59 Start=128 59 Start=128
60}; 60};
61 61
62static int tile_smallw = 16; 62static int tile_smallw = 16;
63static int tile_smallh = 16; 63static int tile_smallh = 16;
64static int tile_bigw = 22; 64static int tile_bigw = 22;
65static int tile_bigh = 22; 65static int tile_bigh = 22;
66static int tile_stweak = -2; 66static int tile_stweak = -2;
67static int tile_btweak = -1; 67static int tile_btweak = -1;
68 68
69static const int rack_tiles=7; 69static const int rack_tiles=7;
70 70
71const char* sampleWGR= 71const char* sampleWGR=
72 "wordgame_shapes\n" 72 "wordgame_shapes\n"
73 "15 15\n" 73 "15 15\n"
74 "400001040100004\n" 74 "400001040100004\n"
75 "030000000000030\n" 75 "030000000000030\n"
76 "002002000200200\n" 76 "002002000200200\n"
77 "000300020003000\n" 77 "000300020003000\n"
78 "000020000020000\n" 78 "000020000020000\n"
79 "102001000100201\n" 79 "102001000100201\n"
80 "000000202000000\n" 80 "000000202000000\n"
81 "400200050002004\n" 81 "400200050002004\n"
82 "000000202000000\n" 82 "000000202000000\n"
83 "102001000100201\n" 83 "102001000100201\n"
84 "000020000020000\n" 84 "000020000020000\n"
85 "000300020003000\n" 85 "000300020003000\n"
86 "002002000200200\n" 86 "002002000200200\n"
87 "030000000000030\n" 87 "030000000000030\n"
88 "400001040100004\n" 88 "400001040100004\n"
89 "1 2 3 66 67 194 100 0\n" 89 "1 2 3 66 67 194 100 0\n"
90 "1 j 8\n" 90 "1 j 8\n"
91 "1 q 7\n" 91 "1 q 7\n"
92 "1 x 6\n" 92 "1 x 6\n"
93 "1 z 6\n" 93 "1 z 6\n"
94 "1 w 4\n" 94 "1 w 4\n"
95 "1 k 4\n" 95 "1 k 4\n"
96 "1 v 3\n" 96 "1 v 3\n"
97 "1 f 3\n" 97 "1 f 3\n"
98 "2 y 3\n" 98 "2 y 3\n"
99 "2 h 2\n" 99 "2 h 2\n"
100 "2 b 2\n" 100 "2 b 2\n"
101 "2 m 2\n" 101 "2 m 2\n"
102 "3 p 2\n" 102 "3 p 2\n"
103 "3 g 2\n" 103 "3 g 2\n"
104 "3 u 2\n" 104 "3 u 2\n"
105 "4 d 2\n" 105 "4 d 2\n"
106 "4 c 2\n" 106 "4 c 2\n"
107 "5 l 1\n" 107 "5 l 1\n"
108 "5 o 1\n" 108 "5 o 1\n"
109 "7 t 1\n" 109 "7 t 1\n"
110 "7 n 1\n" 110 "7 n 1\n"
111 "7 a 1\n" 111 "7 a 1\n"
112 "7 r 1\n" 112 "7 r 1\n"
113 "8 s 1\n" 113 "8 s 1\n"
114 "8 i 1\n" 114 "8 i 1\n"
115 "11 e 1\n" 115 "11 e 1\n"
116 "0\n"; 116 "0\n";
117 117
118WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : 118WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) :
119 QMainWindow(parent, name, fl) 119 QMainWindow(parent, name, fl)
120{ 120{
121 if ( qApp->desktop()->width() < 240 ) { 121 if ( qApp->desktop()->width() < 240 ) {
122 tile_smallw = 10; 122 tile_smallw = 10;
123 tile_smallh = 10; 123 tile_smallh = 10;
124 tile_bigw = 16; 124 tile_bigw = 16;
125 tile_bigh = 16; 125 tile_bigh = 16;
126 tile_stweak = 0; 126 tile_stweak = 0;
127 tile_btweak = 0; 127 tile_btweak = 0;
128 } 128 }
129 129
130 setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) ); 130 setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) );
131 setCaption( tr("Word Game") ); 131 setCaption( tr("Word Game") );
132 132
133 setToolBarsMovable( FALSE ); 133 setToolBarsMovable( FALSE );
134 vbox = new QVBox(this); 134 vbox = new QVBox(this);
135 135
136 setCentralWidget(vbox); 136 setCentralWidget(vbox);
137 toolbar = new QPEToolBar(this); 137 toolbar = new QPEToolBar(this);
138 addToolBar(toolbar, Bottom); 138 addToolBar(toolbar, Bottom);
139 reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); 139 reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar);
140 done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); 140 done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar);
141 scoreinfo = new ScoreInfo(toolbar); 141 scoreinfo = new ScoreInfo(toolbar);
142 scoreinfo->setFont(QFont("Helvetica",10)); 142 scoreinfo->setFont(QFont("Helvetica",10));
143 new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); 143 new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar);
144 toolbar->setStretchableWidget(scoreinfo); 144 toolbar->setStretchableWidget(scoreinfo);
145 145
146 cpu = 0; 146 cpu = 0;
147 board = 0; 147 board = 0;
148 bag = 0; 148 bag = 0;
149 racks = 0; 149 racks = 0;
150 150
151 aiheart = new QTimer(this); 151 aiheart = new QTimer(this);
152 connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); 152 connect(aiheart, SIGNAL(timeout()), this, SLOT(think()));
153 153
154 readConfig(); 154 readConfig();
155} 155}
156 156
157WordGame::~WordGame() 157WordGame::~WordGame()
158{ 158{
159 writeConfig(); 159 writeConfig();
160} 160}
161 161
162void WordGame::writeConfig() 162void WordGame::writeConfig()
163{ 163{
164 Config cfg("WordGame"); 164 Config cfg("WordGame");
165 cfg.setGroup("Game"); 165 cfg.setGroup("Game");
166 cfg.writeEntry("NameList",namelist,';'); 166 cfg.writeEntry("NameList",namelist,';');
167 cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1); 167 cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1);
168 if ( !gameover ) { 168 if ( !gameover ) {
169 cfg.writeEntry("Rules",rules); 169 cfg.writeEntry("Rules",rules);
170 bag->writeConfig(cfg); 170 bag->writeConfig(cfg);
171 board->writeConfig(cfg); 171 board->writeConfig(cfg);
172 scoreinfo->writeConfig(cfg); 172 scoreinfo->writeConfig(cfg);
173 } 173 }
174 for (int p=0; p<nplayers; p++) { 174 for (int p=0; p<nplayers; p++) {
175 cfg.setGroup("Player"+QString::number(p+1)); 175 cfg.setGroup("Player"+QString::number(p+1));
176 if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg); 176 if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg);
177 } 177 }
178} 178}
179 179
180void WordGame::readConfig() 180void WordGame::readConfig()
181{ 181{
182 Config cfg("WordGame"); 182 Config cfg("WordGame");
183 cfg.setGroup("Game"); 183 cfg.setGroup("Game");
184 int currentplayer = cfg.readNumEntry("CurrentPlayer",0); 184 int currentplayer = cfg.readNumEntry("CurrentPlayer",0);
185 QStringList pnames = cfg.readListEntry("NameList",';'); 185 QStringList pnames = cfg.readListEntry("NameList",';');
186 if ( currentplayer ) { 186 if ( currentplayer ) {
187 gameover = FALSE; 187 gameover = FALSE;
188 rules = cfg.readEntry("Rules"); 188 rules = cfg.readEntry("Rules");
189 if ( rules.find("x-wordgamerules") >= 0 ) { 189 if ( rules.find("x-wordgamerules") >= 0 ) {
190 // rules files moved 190 // rules files moved
191 rules = "Sample.rules"; 191 rules = "Sample.rules";
192 } 192 }
193 if ( loadRules(rules) ) { 193 if ( loadRules(rules) ) {
194 startGame(pnames); 194 startGame(pnames);
195 bag->readConfig(cfg); 195 bag->readConfig(cfg);
196 board->readConfig(cfg); 196 board->readConfig(cfg);
197 scoreinfo->readConfig(cfg); 197 scoreinfo->readConfig(cfg);
198 for (int p=0; p<nplayers; p++) { 198 for (int p=0; p<nplayers; p++) {
199 cfg.setGroup("Player"+QString::number(p+1)); 199 cfg.setGroup("Player"+QString::number(p+1));
200 rack(p)->readConfig(cfg); 200 rack(p)->readConfig(cfg);
201 } 201 }
202 player=currentplayer-1; 202 player=currentplayer-1;
203 readyRack(player); 203 readyRack(player);
204 return; 204 return;
205 } 205 }
206 } 206 }
207 // fall-back 207 // fall-back
208 openGameSelector(pnames); 208 openGameSelector(pnames);
209} 209}
210 210
211void WordGame::openGameSelector(const QStringList& initnames) 211void WordGame::openGameSelector(const QStringList& initnames)
212{ 212{
213 toolbar->hide(); 213 toolbar->hide();
214 gameover = FALSE; 214 gameover = FALSE;
215 215
216 delete board; 216 delete board;
217 board = 0; 217 board = 0;
218 delete racks; 218 delete racks;
219 racks = 0; 219 racks = 0;
220 220
221 delete cpu; 221 delete cpu;
222 cpu = 0; 222 cpu = 0;
223 223
224 newgame = new NewGame(vbox); 224 newgame = new NewGame(vbox);
225 225
226 //Rules rules(this); 226 //Rules rules(this);
227 //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules())); 227 //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules()));
228 //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets())); 228 //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets()));
229 struct passwd* n = getpwuid(getuid()); 229 struct passwd* n = getpwuid(getuid());
230 QString playername = n ? n->pw_name : ""; 230 QString playername = n ? n->pw_name : "";
231 if ( playername.isEmpty() ) { 231 if ( playername.isEmpty() ) {
232 playername = "Player"; 232 playername = "Player";
233 } 233 }
234 newgame->player0->changeItem(playername,0); 234 newgame->player0->changeItem(playername,0);
235 newgame->player1->setCurrentItem(1); 235 newgame->player1->setCurrentItem(1);
236 newgame->updateRuleSets(); 236 newgame->updateRuleSets();
237 newgame->show(); 237 newgame->show();
238 238
239 connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame())); 239 connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame()));
240} 240}
241 241
242void WordGame::startGame() 242void WordGame::startGame()
243{ 243{
244 rules = newgame->ruleslist[newgame->rules->currentItem()]; 244 rules = newgame->ruleslist[newgame->rules->currentItem()];
245 if ( loadRules(rules) ) { 245 if ( loadRules(rules) ) {
246 QStringList names; 246 QStringList names;
247 names.append(newgame->player0->currentText()); 247 names.append(newgame->player0->currentText());
248 names.append(newgame->player1->currentText()); 248 names.append(newgame->player1->currentText());
249 names.append(newgame->player2->currentText()); 249 names.append(newgame->player2->currentText());
250 names.append(newgame->player3->currentText()); 250 names.append(newgame->player3->currentText());
251 names.append(newgame->player4->currentText()); 251 names.append(newgame->player4->currentText());
252 names.append(newgame->player5->currentText()); 252 names.append(newgame->player5->currentText());
253 delete newgame; 253 delete newgame;
254 startGame(names); 254 startGame(names);
255 } else { 255 } else {
256 // error... 256 // error...
257 delete newgame; 257 delete newgame;
258 close(); 258 close();
259 } 259 }
260} 260}
261 261
262void WordGame::startGame(const QStringList& playerlist) 262void WordGame::startGame(const QStringList& playerlist)
263{ 263{
264 toolbar->show(); 264 toolbar->show();
265 racks = new QWidgetStack(vbox); 265 racks = new QWidgetStack(vbox);
266 racks->setFixedHeight(TileItem::bigHeight()+2); 266 racks->setFixedHeight(TileItem::bigHeight()+2);
267 namelist.clear(); 267 namelist.clear();
268 nplayers=0; 268 nplayers=0;
269 for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) 269 for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it)
270 addPlayer(*it); 270 addPlayer(*it);
271 scoreinfo->init(namelist); 271 scoreinfo->init(namelist);
272 272
273 if ( nplayers ) { 273 if ( nplayers ) {
274 player=0; 274 player=0;
275 readyRack(player); 275 readyRack(player);
276 } 276 }
277 277
278 board->show(); 278 board->show();
279 racks->show(); 279 racks->show();
280} 280}
281 281
282bool WordGame::loadRules(const QString &name) 282bool WordGame::loadRules(const QString &name)
283{ 283{
284 QString filename = Global::applicationFileName( "wordgame", name ); 284 QString filename = Global::applicationFileName( "wordgame", name );
285 QFile file( filename ); 285 QFile file( filename );
286 if ( !file.open( IO_ReadOnly ) ) 286 if ( !file.open( IO_ReadOnly ) )
287 return FALSE; 287 return FALSE;
288 288
289 QTextStream ts( &file ); 289 QTextStream ts( &file );
290 290
291 QString title = name; 291 QString title = name;
292 title.truncate( title.length() - 6 ); 292 title.truncate( title.length() - 6 );
293 setCaption( title ); 293 //setCaption( title );
294 294
295 QString shapepixmap; 295 QString shapepixmap;
296 ts >> shapepixmap; 296 ts >> shapepixmap;
297 int htiles,vtiles; 297 int htiles,vtiles;
298 ts >> htiles >> vtiles; 298 ts >> htiles >> vtiles;
299 299
300 if ( htiles < 3 || vtiles < 3 ) 300 if ( htiles < 3 || vtiles < 3 )
301 return FALSE; 301 return FALSE;
302 302
303 QString rule_shapes; 303 QString rule_shapes;
304 for (int i=0; i<vtiles; i++) { 304 for (int i=0; i<vtiles; i++) {
305 QString line; 305 QString line;
306 ts >> line; 306 ts >> line;
307 rule_shapes += line; 307 rule_shapes += line;
308 } 308 }
309 static int rule_effects[12]; 309 static int rule_effects[12];
310 int re=0,e; 310 int re=0,e;
311 ts >> e; 311 ts >> e;
312 while ( e && re < 10 ) { 312 while ( e && re < 10 ) {
313 rule_effects[re] = e; 313 rule_effects[re] = e;
314 if ( re++ < 10 ) ts >> e; 314 if ( re++ < 10 ) ts >> e;
315 } 315 }
316 316
317 QImage shim = Resource::loadImage("wordgame/wordgame_shapes.xpm"); 317 QImage shim = Resource::loadImage("wordgame/wordgame_shapes");
318 shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); 318 shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight());
319 QPixmap bgshapes; 319 QPixmap bgshapes;
320 bgshapes.convertFromImage(shim); 320 bgshapes.convertFromImage(shim);
321 321
322 rule_effects[re++] = 100; // default bonus 322 rule_effects[re++] = 100; // default bonus
323 board = new Board(bgshapes, htiles, vtiles, vbox); 323 board = new Board(bgshapes, htiles, vtiles, vbox);
324 board->setRules(rule_shapes, rule_effects); 324 board->setRules(rule_shapes, rule_effects);
325 connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); 325 connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int)));
326 326
327 bag = new Bag; 327 bag = new Bag;
328 328
329 int count; 329 int count;
330 ts >> count; 330 ts >> count;
331 while ( count ) { 331 while ( count ) {
332 QString text; 332 QString text;
333 int value; 333 int value;
334 ts >> text >> value; 334 ts >> text >> value;
335 if ( text == "_" ) 335 if ( text == "_" )
336 text = ""; 336 text = "";
337 337
338 Tile t(text, value); 338 Tile t(text, value);
339 for (int n=count; n--; ) 339 for (int n=count; n--; )
340 bag->add(t); 340 bag->add(t);
341 341
342 ts >> count; 342 ts >> count;
343 } 343 }
344 344
345 return TRUE; 345 return TRUE;
346} 346}
347 347
348 348
349NewGame::NewGame(QWidget* parent) : 349NewGame::NewGame(QWidget* parent) :
350 NewGameBase(parent) 350 NewGameBase(parent)
351{ 351{
352} 352}
353 353
354void NewGame::updateRuleSets() 354void NewGame::updateRuleSets()
355{ 355{
356 rules->clear(); 356 rules->clear();
357 357
358 QString rulesDir = Global::applicationFileName( "wordgame", "" ); 358 QString rulesDir = Global::applicationFileName( "wordgame", "" );
359 QDir dir( rulesDir, "*.rules" ); 359 QDir dir( rulesDir, "*.rules" );
360 ruleslist = dir.entryList(); 360 ruleslist = dir.entryList();
361 if ( ruleslist.isEmpty() ) { 361 if ( ruleslist.isEmpty() ) {
362 // Provide a sample 362 // Provide a sample
363 QFile file( rulesDir + "Sample.rules" ); 363 QFile file( rulesDir + "Sample.rules" );
364 if ( file.open( IO_WriteOnly ) ) { 364 if ( file.open( IO_WriteOnly ) ) {
365 file.writeBlock( sampleWGR, strlen(sampleWGR) ); 365 file.writeBlock( sampleWGR, strlen(sampleWGR) );
366 file.close(); 366 file.close();
367 updateRuleSets(); 367 updateRuleSets();
368 } 368 }
369 return; 369 return;
370 } 370 }
371 int newest=0; 371 int newest=0;
372 int newest_age=INT_MAX; 372 int newest_age=INT_MAX;
373 QDateTime now = QDateTime::currentDateTime(); 373 QDateTime now = QDateTime::currentDateTime();
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) { 375 for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) {
376 QFileInfo fi((*it)); 376 QFileInfo fi((*it));
377 int age = fi.lastModified().secsTo(now); 377 int age = fi.lastModified().secsTo(now);
378 QString name = *it; 378 QString name = *it;
379 name.truncate( name.length()-6 ); // remove extension 379 name.truncate( name.length()-6 ); // remove extension
380 rules->insertItem( name ); 380 rules->insertItem( name );
381 if ( age < newest_age ) { 381 if ( age < newest_age ) {
382 newest_age = age; 382 newest_age = age;
383 newest = rules->count()-1; 383 newest = rules->count()-1;
384 } 384 }
385 } 385 }
386 rules->setCurrentItem(newest); 386 rules->setCurrentItem(newest);
387} 387}
388 388
389Rules::Rules(QWidget* parent) : 389Rules::Rules(QWidget* parent) :
390 RulesBase(parent,0,TRUE) 390 RulesBase(parent,0,TRUE)
391{ 391{
392} 392}
393 393
394void Rules::editRules() 394void Rules::editRules()
395{ 395{
396 if ( exec() ) { 396 if ( exec() ) {
397 // ### create a new set of rules 397 // ### create a new set of rules
398 emit rulesChanged(); 398 emit rulesChanged();
399 } 399 }
400} 400}
401 401
402void Rules::deleteRuleSet() 402void Rules::deleteRuleSet()
403{ 403{
404 // ### delete existing rule set 404 // ### delete existing rule set
405 emit rulesChanged(); 405 emit rulesChanged();
406} 406}
407 407
408void WordGame::addPlayer(const QString& name) 408void WordGame::addPlayer(const QString& name)
409{ 409{
410 if ( !name.isEmpty() ) { 410 if ( !name.isEmpty() ) {
411 int colon = name.find(':'); 411 int colon = name.find(':');
412 int cpu = (colon >=0 && name.left(2) == "AI") ? name.mid(2,1).toInt() : 0; 412 int cpu = (colon >=0 && name.left(2) == "AI") ? name.mid(2,1).toInt() : 0;
413 addPlayer(name,cpu); 413 addPlayer(name,cpu);
414 } 414 }
415} 415}
416 416
417void WordGame::addPlayer(const QString& name, int cpu) 417void WordGame::addPlayer(const QString& name, int cpu)
418{ 418{
419 Rack* r = new Rack(rack_tiles,racks); 419 Rack* r = new Rack(rack_tiles,racks);
420 r->setPlayerName(name); 420 r->setPlayerName(name);
421 r->setComputerization(cpu); 421 r->setComputerization(cpu);
422 racks->addWidget(r, nplayers); 422 racks->addWidget(r, nplayers);
423 refillRack(nplayers); 423 refillRack(nplayers);
424 namelist.append(name); 424 namelist.append(name);
425 425
426 ++nplayers; 426 ++nplayers;
427} 427}
428 428
429void WordGame::nextPlayer() 429void WordGame::nextPlayer()
430{ 430{
431 if ( !refillRack(player) ) { 431 if ( !refillRack(player) ) {
432 endGame(); 432 endGame();
433 } else { 433 } else {
434 player = (player+1)%nplayers; 434 player = (player+1)%nplayers;
435 scoreinfo->setBoldOne(player); 435 scoreinfo->setBoldOne(player);
436 readyRack(player); 436 readyRack(player);
437 } 437 }
438} 438}
439 439
440bool WordGame::mayEndGame() 440bool WordGame::mayEndGame()
441{ 441{
442 int out=-1; 442 int out=-1;
443 int i; 443 int i;
444 for (i=0; i<nplayers; i++) 444 for (i=0; i<nplayers; i++)
445 if ( !rack(i)->count() ) 445 if ( !rack(i)->count() )
446 out = i; 446 out = i;
447 if ( out<0 ) { 447 if ( out<0 ) {
448 if ( QMessageBox::warning(this,tr("End game"), 448 if ( QMessageBox::warning(this,tr("End game"),
449 tr("Do you want to end the game early?"), 449 tr("Do you want to end the game early?"),
450 tr("Yes"), tr("No") )!=0 ) 450 tr("Yes"), tr("No") )!=0 )
451 { 451 {
452 return FALSE; 452 return FALSE;
453 } 453 }
454 } 454 }
455 return TRUE; 455 return TRUE;
456} 456}
457 457
458void WordGame::endGame() 458void WordGame::endGame()
459{ 459{
460 if ( gameover ) { 460 if ( gameover ) {
461 close(); 461 close();
462 return; 462 return;
463 } 463 }
464 464
465 if ( !mayEndGame() ) 465 if ( !mayEndGame() )
466 return; 466 return;
467 int out=-1; 467 int out=-1;
468 int totalleft=0; 468 int totalleft=0;
469 int i; 469 int i;
470 for (i=0; i<nplayers; i++) { 470 for (i=0; i<nplayers; i++) {
471 Rack* r = rack(i); 471 Rack* r = rack(i);
472 int c = r->count(); 472 int c = r->count();
473 if ( c ) { 473 if ( c ) {
474 int lose=0; 474 int lose=0;
475 for ( int j=0; j<c; j++ ) 475 for ( int j=0; j<c; j++ )
476 lose += r->tileRef(j)->value(); 476 lose += r->tileRef(j)->value();
477 totalleft += lose; 477 totalleft += lose;
478 scoreinfo->addScore(i,-lose); 478 scoreinfo->addScore(i,-lose);
479 } else { 479 } else {
480 out = i; 480 out = i;
481 } 481 }
482 } 482 }
483 int highest=0; 483 int highest=0;
484 int winner=0; 484 int winner=0;
485 for (i=0; i<nplayers; i++) { 485 for (i=0; i<nplayers; i++) {
486 int s = scoreinfo->playerScore(i); 486 int s = scoreinfo->playerScore(i);
487 if ( s > highest ) { 487 if ( s > highest ) {
488 highest = s; 488 highest = s;
489 winner = i; 489 winner = i;
490 } 490 }
491 } 491 }
492 if ( out >= 0 ) 492 if ( out >= 0 )
493 scoreinfo->addScore(out,totalleft); 493 scoreinfo->addScore(out,totalleft);
494 scoreinfo->setBoldOne(winner); 494 scoreinfo->setBoldOne(winner);
495 gameover = TRUE; 495 gameover = TRUE;
496 done->setEnabled(TRUE); 496 done->setEnabled(TRUE);
497 reset->setEnabled(FALSE); 497 reset->setEnabled(FALSE);
498} 498}
499 499
500void WordGame::endTurn() 500void WordGame::endTurn()
501{ 501{
502 if ( gameover ) { 502 if ( gameover ) {
503 openGameSelector(namelist); 503 openGameSelector(namelist);
504 } else { 504 } else {
505 if ( board->checkTurn() ) { 505 if ( board->checkTurn() ) {
506 if ( board->turnScore() >= 0 ) { 506 if ( board->turnScore() >= 0 ) {
507 scoreinfo->addScore(player,board->turnScore()); 507 scoreinfo->addScore(player,board->turnScore());
508 board->finalizeTurn(); 508 board->finalizeTurn();
509 } else { 509 } else {
510 QApplication::beep(); 510 QApplication::beep();
511 } 511 }
512 nextPlayer(); 512 nextPlayer();
513 } 513 }
514 } 514 }
515} 515}
516 516
517void WordGame::resetTurn() 517void WordGame::resetTurn()
518{ 518{
519 board->resetRack(); 519 board->resetRack();
520} 520}
521 521
522void WordGame::passTurn() 522void WordGame::passTurn()
523{ 523{
524 // ######## trade? 524 // ######## trade?
525 nextPlayer(); 525 nextPlayer();
526} 526}
527 527
528bool WordGame::refillRack(int i) 528bool WordGame::refillRack(int i)
529{ 529{
530 Rack* r = rack(i); 530 Rack* r = rack(i);
531 while ( !bag->isEmpty() && !r->isFull() ) { 531 while ( !bag->isEmpty() && !r->isFull() ) {
532 r->addTile(bag->takeRandom()); 532 r->addTile(bag->takeRandom());
533 } 533 }
534 return r->count() != 0; 534 return r->count() != 0;
535} 535}
536 536
537void WordGame::readyRack(int i) 537void WordGame::readyRack(int i)
538{ 538{
539 Rack* r = rack(i); 539 Rack* r = rack(i);
540 racks->raiseWidget(i); 540 racks->raiseWidget(i);
541 board->setCurrentRack(r); 541 board->setCurrentRack(r);
542 542
543 done->setEnabled( !r->computerized() ); 543 done->setEnabled( !r->computerized() );
544 reset->setEnabled( !r->computerized() ); 544 reset->setEnabled( !r->computerized() );
545 545
546 if ( r->computerized() ) { 546 if ( r->computerized() ) {
547 cpu = new ComputerPlayer(board, r); 547 cpu = new ComputerPlayer(board, r);
548 aiheart->start(0); 548 aiheart->start(0);
549 } 549 }
550} 550}
551 551
552Rack* WordGame::rack(int i) const 552Rack* WordGame::rack(int i) const
553{ 553{
554 return (Rack*)racks->widget(i); 554 return (Rack*)racks->widget(i);
555} 555}
556 556
557void WordGame::think() 557void WordGame::think()
558{ 558{
559 if ( !cpu->step() ) { 559 if ( !cpu->step() ) {
560 delete cpu; 560 delete cpu;
561 cpu = 0; 561 cpu = 0;
562 aiheart->stop(); 562 aiheart->stop();
563 if ( board->turnScore() < 0 ) 563 if ( board->turnScore() < 0 )
564 passTurn(); 564 passTurn();
565 else 565 else
566 endTurn(); 566 endTurn();
567 } 567 }
568} 568}
569 569
570ComputerPlayer::ComputerPlayer(Board* b, Rack* r) : 570ComputerPlayer::ComputerPlayer(Board* b, Rack* r) :
571 board(b), rack(r), best(new const Tile*[rack_tiles]), 571 board(b), rack(r), best(new const Tile*[rack_tiles]),
572 best_blankvalues(new Tile[rack_tiles]) 572 best_blankvalues(new Tile[rack_tiles])
573{ 573{
574 best_score = -1; 574 best_score = -1;
575 across=FALSE; 575 across=FALSE;
576 dict=0; 576 dict=0;
577} 577}
578 578
579ComputerPlayer::~ComputerPlayer() 579ComputerPlayer::~ComputerPlayer()
580{ 580{
581 delete [] best; 581 delete [] best;
582 delete [] best_blankvalues; 582 delete [] best_blankvalues;
583} 583}
584 584
585bool ComputerPlayer::step() 585bool ComputerPlayer::step()
586{ 586{
587 const QDawg::Node* root = dict ? Global::dawg("WordGame").root() 587 const QDawg::Node* root = dict ? Global::dawg("WordGame").root()
588 : Global::fixedDawg().root(); 588 : Global::fixedDawg().root();
589 QPoint d = across ? QPoint(1,0) : QPoint(0,1); 589 QPoint d = across ? QPoint(1,0) : QPoint(0,1);
590 const Tile* tiles[99]; // ### max board size 590 const Tile* tiles[99]; // ### max board size
591 uchar nletter[4095]; // QDawg only handles 0..4095 591 uchar nletter[4095]; // QDawg only handles 0..4095
592 memset(nletter,0,4096); 592 memset(nletter,0,4096);
593 for (int i=0; i<rack->count(); i++) { 593 for (int i=0; i<rack->count(); i++) {
594 const Tile* r = rack->tileRef(i); 594 const Tile* r = rack->tileRef(i);
595 if ( r->isBlank() ) 595 if ( r->isBlank() )
596 nletter[0]++; 596 nletter[0]++;
597 else 597 else
598 nletter[r->text()[0].unicode()]++; 598 nletter[r->text()[0].unicode()]++;
599 } 599 }
600 Tile blankvalues[99]; // ### max blanks 600 Tile blankvalues[99]; // ### max blanks
601 findBest(current, d, root, 0, nletter, tiles, 0, blankvalues, 0); 601 findBest(current, d, root, 0, nletter, tiles, 0, blankvalues, 0);
602 if ( ++current.rx() == board->xTiles() ) { 602 if ( ++current.rx() == board->xTiles() ) {
603 current.rx() = 0; 603 current.rx() = 0;
604 if ( ++current.ry() == board->yTiles() ) { 604 if ( ++current.ry() == board->yTiles() ) {
605 if ( across ) { 605 if ( across ) {
606 if ( dict == 1 ) { 606 if ( dict == 1 ) {
607 if ( best_score >= 0 ) { 607 if ( best_score >= 0 ) {
608 rack->arrangeTiles(best,best_n); 608 rack->arrangeTiles(best,best_n);
609 rack->setBlanks(best_blankvalues); 609 rack->setBlanks(best_blankvalues);
610 board->scoreTurn(best_start, best_n, best_dir); 610 board->scoreTurn(best_start, best_n, best_dir);
611 board->showTurn(); 611 board->showTurn();
612 } 612 }
613 return FALSE; 613 return FALSE;
614 } 614 }
615 dict++; 615 dict++;
616 across = FALSE; 616 across = FALSE;
617 current = QPoint(0,0); 617 current = QPoint(0,0);
618 } else { 618 } else {
619 across = TRUE; 619 across = TRUE;
620 current = QPoint(0,0); 620 current = QPoint(0,0);
621 } 621 }
622 } 622 }
623 } 623 }
624 return TRUE; 624 return TRUE;
625} 625}
626 626
627void ComputerPlayer::findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar* nletter, const Tile** tiles, int n, Tile* blankvalues, int blused) 627void ComputerPlayer::findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar* nletter, const Tile** tiles, int n, Tile* blankvalues, int blused)
628{ 628{
629 if ( !node ) 629 if ( !node )
630 return; 630 return;
631 QChar l = node->letter(); 631 QChar l = node->letter();
632 const Tile* cur = board->tile(at); 632 const Tile* cur = board->tile(at);
633 if ( cur ) { 633 if ( cur ) {
634 if ( cur->text()[0] == l ) { 634 if ( cur->text()[0] == l ) {
635 bool nextok = board->contains(at+d); 635 bool nextok = board->contains(at+d);
636 if ( node->isWord() && n && (!nextok || !board->tile(at+d)) ) 636 if ( node->isWord() && n && (!nextok || !board->tile(at+d)) )
637 noteChoice(tiles,n,d,blankvalues,blused); 637 noteChoice(tiles,n,d,blankvalues,blused);
638 if ( nextok ) 638 if ( nextok )
639 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused); 639 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused);
640 // #### text()[1]... 640 // #### text()[1]...
641 } 641 }
642 } else { 642 } else {
643 if ( nletter[l.unicode()] || nletter[0] ) { 643 if ( nletter[l.unicode()] || nletter[0] ) {
644 int rc = rack->count(); 644 int rc = rack->count();
645 ulong msk = 1; 645 ulong msk = 1;
646 for ( int x=0; x<rc; x++ ) { 646 for ( int x=0; x<rc; x++ ) {
647 if ( !(used&msk) ) { 647 if ( !(used&msk) ) {
648 const Tile* t = rack->tileRef(x); 648 const Tile* t = rack->tileRef(x);
649 if ( t->isBlank() || t->text() == l ) { // #### multi-char value()s 649 if ( t->isBlank() || t->text() == l ) { // #### multi-char value()s
650 bool nextok = board->contains(at+d); 650 bool nextok = board->contains(at+d);
651 tiles[n++] = t; 651 tiles[n++] = t;
652 if ( t->isBlank() ) 652 if ( t->isBlank() )
653 blankvalues[blused++] = Tile(l,0); 653 blankvalues[blused++] = Tile(l,0);
654 if ( node->isWord() && (!nextok || !board->tile(at+d)) ) 654 if ( node->isWord() && (!nextok || !board->tile(at+d)) )
655 noteChoice(tiles,n,d,blankvalues,blused); 655 noteChoice(tiles,n,d,blankvalues,blused);
656 used |= msk; // mark 656 used |= msk; // mark
657 nletter[t->text()[0].unicode()]--; 657 nletter[t->text()[0].unicode()]--;
658 if ( nextok ) 658 if ( nextok )
659 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused); 659 findBest(at+d, d, node->jump(), used, nletter, tiles, n, blankvalues, blused);
660 n--; 660 n--;
661 nletter[t->text()[0].unicode()]++; 661 nletter[t->text()[0].unicode()]++;
662 if ( t->isBlank() ) { 662 if ( t->isBlank() ) {
663 // keep looking 663 // keep looking
664 blused--; 664 blused--;
665 used &= ~msk; // unmark 665 used &= ~msk; // unmark
666 } else { 666 } else {
667 break; 667 break;
668 } 668 }
669 } 669 }
670 } 670 }
671 msk <<= 1; 671 msk <<= 1;
672 } 672 }
673 } 673 }
674 // #### text()[1]... 674 // #### text()[1]...
675 } 675 }
676 findBest(at, d, node->next(), used, nletter, tiles, n, blankvalues, blused); 676 findBest(at, d, node->next(), used, nletter, tiles, n, blankvalues, blused);
677} 677}
678 678
679void ComputerPlayer::noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused) 679void ComputerPlayer::noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused)
680{ 680{
681 int s = board->score(current, tiles, n, blankvalues, d, TRUE, 0); 681 int s = board->score(current, tiles, n, blankvalues, d, TRUE, 0);
682/* 682/*
683if (s>0 || current==QPoint(5,1)){ 683if (s>0 || current==QPoint(5,1)){
684QString st; 684QString st;
685for ( int i=0; i<n; i++ ) 685for ( int i=0; i<n; i++ )
686 st += tiles[i]->text(); 686 st += tiles[i]->text();
687qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s); 687qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s);
688} 688}
689*/ 689*/
690 if ( s > best_score ) { 690 if ( s > best_score ) {
691 int i; 691 int i;
692 for ( i=0; i<n; i++ ) 692 for ( i=0; i<n; i++ )
693 best[i] = tiles[i]; 693 best[i] = tiles[i];
694 for ( i=0; i<blused; i++ ) 694 for ( i=0; i<blused; i++ )
695 best_blankvalues[i] = blankvalues[i]; 695 best_blankvalues[i] = blankvalues[i];
696 best_n = n; 696 best_n = n;
697 best_blused = blused; 697 best_blused = blused;
698 best_score = s; 698 best_score = s;
699 best_dir = d; 699 best_dir = d;
700 best_start = current; 700 best_start = current;
701 } 701 }
702} 702}
703 703
704int TileItem::smallWidth() 704int TileItem::smallWidth()
705{ 705{
706 return tile_smallw; 706 return tile_smallw;
707} 707}
708 708
709int TileItem::smallHeight() 709int TileItem::smallHeight()
710{ 710{
711 return tile_smallh; 711 return tile_smallh;
712} 712}
713 713
714int TileItem::bigWidth() 714int TileItem::bigWidth()
715{ 715{
716 return tile_bigw; 716 return tile_bigw;
717} 717}
718 718
719int TileItem::bigHeight() 719int TileItem::bigHeight()
720{ 720{
721 return tile_bigh; 721 return tile_bigh;
722} 722}
723 723
724void TileItem::setState( State state ) 724void TileItem::setState( State state )
725{ 725{
726 hide(); 726 hide();
727 s = state; 727 s = state;
728 show(); // ### use update() in Qt 3.0 728 show(); // ### use update() in Qt 3.0
729} 729}
730 730
731void TileItem::setTile(const Tile& tile) 731void TileItem::setTile(const Tile& tile)
732{ 732{
733 hide(); 733 hide();
734 t = tile; 734 t = tile;
735 show(); // ### use update() in Qt 3.0 735 show(); // ### use update() in Qt 3.0
736} 736}
737 737
738void TileItem::setBig(bool b) 738void TileItem::setBig(bool b)
739{ 739{
740 big = b; 740 big = b;
741} 741}
742 742
743void TileItem::drawShape(QPainter& p) 743void TileItem::drawShape(QPainter& p)
744{ 744{
745 static QFont *value_font=0; 745 static QFont *value_font=0;
746 static QFont *big_font=0; 746 static QFont *big_font=0;
747 static QFont *small_font=0; 747 static QFont *small_font=0;
748 if ( !value_font ) { 748 if ( !value_font ) {
749 value_font = new QFont("helvetica",8); 749 value_font = new QFont("helvetica",8);
750 if ( TileItem::bigWidth() < 20 ) { 750 if ( TileItem::bigWidth() < 20 ) {
751 big_font = new QFont("helvetica",12); 751 big_font = new QFont("helvetica",12);
752 small_font = new QFont("helvetica",8); 752 small_font = new QFont("helvetica",8);
753 } else { 753 } else {
754 big_font = new QFont("smoothtimes",17); 754 big_font = new QFont("smoothtimes",17);
755 small_font = new QFont("smoothtimes",10); 755 small_font = new QFont("smoothtimes",10);
756 } 756 }
757 } 757 }
758 758
759 QRect area(x(),y(),width(),height()); 759 QRect area(x(),y(),width(),height());
760 p.setBrush(s == Floating ? yellow/*lightGray*/ : white); 760 p.setBrush(s == Floating ? yellow/*lightGray*/ : white);
761 p.drawRect(area); 761 p.drawRect(area);
762 if ( big ) { 762 if ( big ) {
763 p.setFont(*value_font); 763 p.setFont(*value_font);
764 QString n = QString::number(t.value()); 764 QString n = QString::number(t.value());
765 int w = p.fontMetrics().width('1'); 765 int w = p.fontMetrics().width('1');
766 int h = p.fontMetrics().height(); 766 int h = p.fontMetrics().height();
767 w *= n.length(); 767 w *= n.length();
768 QRect valuearea(x()+width()-w-1,y()+height()-h,w,h); 768 QRect valuearea(x()+width()-w-1,y()+height()-h,w,h);
769 p.drawText(valuearea,AlignCenter,n); 769 p.drawText(valuearea,AlignCenter,n);
770 p.setFont(*big_font); 770 p.setFont(*big_font);
771 area = QRect(x(),y()+tile_btweak,width()-4,height()-1); 771 area = QRect(x(),y()+tile_btweak,width()-4,height()-1);
772 } else { 772 } else {
773 p.setFont(*small_font); 773 p.setFont(*small_font);
774 area = QRect(x()+1+tile_stweak,y()+1,width(),height()-3); 774 area = QRect(x()+1+tile_stweak,y()+1,width(),height()-3);
775 } 775 }
776 if ( t.value() == 0 ) 776 if ( t.value() == 0 )
777 p.setPen(darkGray); 777 p.setPen(darkGray);
778 p.drawText(area,AlignCenter,t.text().upper()); 778 p.drawText(area,AlignCenter,t.text().upper());
779} 779}
780 780
781Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) : 781Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) :
782 QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()), 782 QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()),
783 parent) 783 parent)
784{ 784{
785 setFixedSize(w*TileItem::smallWidth(),h*TileItem::smallHeight()); 785 setFixedSize(w*TileItem::smallWidth(),h*TileItem::smallHeight());
786 grid = new TileItem*[w*h]; 786 grid = new TileItem*[w*h];
787 memset(grid,0,w*h*sizeof(TileItem*)); 787 memset(grid,0,w*h*sizeof(TileItem*));
788 setFrameStyle(0); 788 setFrameStyle(0);
789 setHScrollBarMode(AlwaysOff); 789 setHScrollBarMode(AlwaysOff);
790 setVScrollBarMode(AlwaysOff); 790 setVScrollBarMode(AlwaysOff);
791 current_rack = 0; 791 current_rack = 0;
792 shown_n = 0; 792 shown_n = 0;
793} 793}
794 794
795Board::~Board() 795Board::~Board()
796{ 796{
797 delete canvas(); 797 delete canvas();
798} 798}
799 799
800QSize Board::sizeHint() const 800QSize Board::sizeHint() const
801{ 801{
802 return QSize(canvas()->width(),canvas()->height()); 802 return QSize(canvas()->width(),canvas()->height());
803} 803}
804 804
805void Board::writeConfig(Config& cfg) 805void Board::writeConfig(Config& cfg)
806{ 806{
807 QStringList t; 807 QStringList t;
808 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically(); 808 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically();
809 for (int i=0; i<n; i++) 809 for (int i=0; i<n; i++)
810 t.append( grid[i] ? grid[i]->tile().key() : QString(".") ); 810 t.append( grid[i] ? grid[i]->tile().key() : QString(".") );
811 cfg.writeEntry("Board",t,';'); 811 cfg.writeEntry("Board",t,';');
812} 812}
813 813
814void Board::readConfig(Config& cfg) 814void Board::readConfig(Config& cfg)
815{ 815{
816 clear(); 816 clear();
817 QStringList t = cfg.readListEntry("Board",';'); 817 QStringList t = cfg.readListEntry("Board",';');
818 int i=0; 818 int i=0;
819 int h=canvas()->tilesHorizontally(); 819 int h=canvas()->tilesHorizontally();
820 for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it) { 820 for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it) {
821 if ( *it != "." ) { 821 if ( *it != "." ) {
822 QPoint p(i%h,i/h); 822 QPoint p(i%h,i/h);
823 setTile(p,Tile(*it)); 823 setTile(p,Tile(*it));
824 } 824 }
825 i++; 825 i++;
826 } 826 }
827 canvas()->update(); 827 canvas()->update();
828} 828}
829 829
830void Board::clear() 830void Board::clear()
831{ 831{
832 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically(); 832 int n=canvas()->tilesHorizontally()*canvas()->tilesVertically();
833 for (int i=0; i<n; i++) { 833 for (int i=0; i<n; i++) {
834 delete grid[i]; 834 delete grid[i];
835 grid[i]=0; 835 grid[i]=0;
836 } 836 }
837} 837}
838 838
839 839
840void Board::setCurrentRack(Rack* r) 840void Board::setCurrentRack(Rack* r)
841{ 841{
842 turn_score = -1; 842 turn_score = -1;
843 current_rack = r; 843 current_rack = r;
844} 844}
845 845
846void Board::resetRack() 846void Board::resetRack()
847{ 847{
848 unshowTurn(); 848 unshowTurn();
849 canvas()->update(); 849 canvas()->update();
850} 850}
851 851
852void Board::contentsMousePressEvent(QMouseEvent* e) 852void Board::contentsMousePressEvent(QMouseEvent* e)
853{ 853{
854 dragstart = e->pos(); 854 dragstart = e->pos();
855} 855}
856 856
857void Board::contentsMouseMoveEvent(QMouseEvent* e) 857void Board::contentsMouseMoveEvent(QMouseEvent* e)
858{ 858{
859 if ( current_rack && !current_rack->computerized() ) { 859 if ( current_rack && !current_rack->computerized() ) {
860 QPoint d = e->pos() - dragstart; 860 QPoint d = e->pos() - dragstart;
861 if ( d.x() <= 0 && d.y() <= 0 ) { 861 if ( d.x() <= 0 && d.y() <= 0 ) {
862 // None 862 // None
863 resetRack(); 863 resetRack();
864 } else { 864 } else {
865 int n; 865 int n;
866 QPoint start=boardPos(dragstart); 866 QPoint start=boardPos(dragstart);
867 QPoint end=boardPos(e->pos()); 867 QPoint end=boardPos(e->pos());
868 QPoint diff=end-start; 868 QPoint diff=end-start;
869 QPoint dir; 869 QPoint dir;
870 if ( d.x() > d.y() ) { 870 if ( d.x() > d.y() ) {
871 n = diff.x()+1; 871 n = diff.x()+1;
872 dir = QPoint(1,0); 872 dir = QPoint(1,0);
873 } else { 873 } else {
874 n = diff.y()+1; 874 n = diff.y()+1;
875 dir = QPoint(0,1); 875 dir = QPoint(0,1);
876 } 876 }
877 877
878 unshowTurn(); 878 unshowTurn();
879 879
880 // Subtract existing tiles from n 880 // Subtract existing tiles from n
881 QPoint t = start; 881 QPoint t = start;
882 for ( int i=n; i--; ) { 882 for ( int i=n; i--; ) {
883 if ( contains(t) && tile(t) ) 883 if ( contains(t) && tile(t) )
884 n--; 884 n--;
885 t += dir; 885 t += dir;
886 } 886 }
887 887
888 // Move start back to real start 888 // Move start back to real start
889 while (contains(start-dir) && tile(start-dir)) 889 while (contains(start-dir) && tile(start-dir))
890 start -= dir; 890 start -= dir;
891 891
892 scoreTurn(start, n, dir); 892 scoreTurn(start, n, dir);
893 showTurn(); 893 showTurn();
894 } 894 }
895 } 895 }
896} 896}
897 897
898void Board::finalizeTurn() 898void Board::finalizeTurn()
899{ 899{
900 int i=0; 900 int i=0;
901 QPoint at = shown_at; 901 QPoint at = shown_at;
902 while ( i<shown_n && contains(at) ) { 902 while ( i<shown_n && contains(at) ) {
903 if ( item(at) && item(at)->state() == TileItem::Floating ) { 903 if ( item(at) && item(at)->state() == TileItem::Floating ) {
904 current_rack->remove(item(at)->tile()); 904 current_rack->remove(item(at)->tile());
905 setTileState(at,TileItem::Firm); 905 setTileState(at,TileItem::Firm);
906 i++; 906 i++;
907 } 907 }
908 at += shown_step; 908 at += shown_step;
909 } 909 }
910 canvas()->update(); 910 canvas()->update();
911} 911}
912 912
913void Board::unshowTurn() 913void Board::unshowTurn()
914{ 914{
915 int i=0; 915 int i=0;
916 QPoint at = shown_at; 916 QPoint at = shown_at;
917 while ( i<shown_n && i<current_rack->count() && contains(at) ) { 917 while ( i<shown_n && i<current_rack->count() && contains(at) ) {
918 if ( item(at) && item(at)->state() == TileItem::Floating ) { 918 if ( item(at) && item(at)->state() == TileItem::Floating ) {
919 unsetTile(at); 919 unsetTile(at);
920 i++; 920 i++;
921 } 921 }
922 at += shown_step; 922 at += shown_step;
923 } 923 }
924} 924}
925 925
926void Board::showTurn() 926void Board::showTurn()
927{ 927{
928 unshowTurn(); 928 unshowTurn();
929 QPoint at = shown_at; 929 QPoint at = shown_at;
930 int i=0; 930 int i=0;
931 while ( i<shown_n && i<current_rack->count() && contains(at) ) { 931 while ( i<shown_n && i<current_rack->count() && contains(at) ) {
932 if ( !tile(at) ) { 932 if ( !tile(at) ) {
933 Tile t = current_rack->tile(i); 933 Tile t = current_rack->tile(i);
934 setTile(at,t); 934 setTile(at,t);
935 setTileState(at,TileItem::Floating); 935 setTileState(at,TileItem::Floating);
936 i++; 936 i++;
937 } 937 }
938 at += shown_step; 938 at += shown_step;
939 } 939 }
940 canvas()->update(); 940 canvas()->update();
941} 941}
942 942
943int Board::bonussedValue(const QPoint& at, int base, int& all_mult) const 943int Board::bonussedValue(const QPoint& at, int base, int& all_mult) const
944{ 944{
945 int rule = rule_shape[idx(at)]-'0'; 945 int rule = rule_shape[idx(at)]-'0';
946 int effect = rule_effect[rule]; 946 int effect = rule_effect[rule];
947 int mult = effect&Multiplier; 947 int mult = effect&Multiplier;
948 if ( effect & MultiplyAll ) { 948 if ( effect & MultiplyAll ) {
949 all_mult *= mult; 949 all_mult *= mult;
950 return base; 950 return base;
951 } else { 951 } else {
952 return base * mult; 952 return base * mult;
953 } 953 }
954} 954}
955 955
956bool Board::isStart(const QPoint& at) const 956bool Board::isStart(const QPoint& at) const
957{ 957{
958 int rule = rule_shape[idx(at)]-'0'; 958 int rule = rule_shape[idx(at)]-'0';
959 int effect = rule_effect[rule]; 959 int effect = rule_effect[rule];
960 return effect&Start; 960 return effect&Start;
961} 961}
962 962
963bool Board::checkTurn() 963bool Board::checkTurn()
964{ 964{
965 if ( current_rack->computerized() ) 965 if ( current_rack->computerized() )
966 return TRUE; // computer doesn't cheat, and has already set blanks. 966 return TRUE; // computer doesn't cheat, and has already set blanks.
967 967
968 QPoint at = shown_at; 968 QPoint at = shown_at;
969 int n = shown_n; 969 int n = shown_n;
970 QPoint d = shown_step; 970 QPoint d = shown_step;
971 const Tile* tiles[99]; 971 const Tile* tiles[99];
972 Tile blankvalues[99]; 972 Tile blankvalues[99];
973 if ( n > current_rack->count() ) 973 if ( n > current_rack->count() )
974 n = current_rack->count(); 974 n = current_rack->count();
975 975
976 QDialog check(this,0,TRUE); 976 QDialog check(this,0,TRUE);
977 (new QVBoxLayout(&check))->setAutoAdd(TRUE); 977 (new QVBoxLayout(&check))->setAutoAdd(TRUE);
978 978
979 QHBox mw(&check); 979 QHBox mw(&check);
980 new QLabel(tr("Blanks: "),&mw); 980 new QLabel(tr("Blanks: "),&mw);
981 981
982 int bl=0; 982 int bl=0;
983 QLineEdit* le[99]; 983 QLineEdit* le[99];
984 for (int i=0; i<n; i++) { 984 for (int i=0; i<n; i++) {
985 tiles[i] = current_rack->tileRef(i); 985 tiles[i] = current_rack->tileRef(i);
986 if ( tiles[i]->isBlank() ) { 986 if ( tiles[i]->isBlank() ) {
987 QLineEdit *l = new QLineEdit(&mw); 987 QLineEdit *l = new QLineEdit(&mw);
988 le[bl++] = l; 988 le[bl++] = l;
989 l->setMaxLength(1); 989 l->setMaxLength(1);
990 l->setFixedSize(l->minimumSizeHint()); 990 l->setFixedSize(l->minimumSizeHint());
991 } 991 }
992 } 992 }
993 993
994 QHBox btns(&check); 994 QHBox btns(&check);
995 connect(new QPushButton(tr("OK"),&btns), SIGNAL(clicked()), &check, SLOT(accept())); 995 connect(new QPushButton(tr("OK"),&btns), SIGNAL(clicked()), &check, SLOT(accept()));
996 connect(new QPushButton(tr("Cancel"),&btns), SIGNAL(clicked()), &check, SLOT(reject())); 996 connect(new QPushButton(tr("Cancel"),&btns), SIGNAL(clicked()), &check, SLOT(reject()));
997 997
998 if ( bl ) { 998 if ( bl ) {
999retry: 999retry:
1000 if ( !check.exec() ) { 1000 if ( !check.exec() ) {
1001 unshowTurn(); 1001 unshowTurn();
1002 canvas()->update(); 1002 canvas()->update();
1003 return FALSE; 1003 return FALSE;
1004 } 1004 }
1005 1005
1006 for (int b=0; b<bl; b++) { 1006 for (int b=0; b<bl; b++) {
1007 QString v = le[b]->text(); 1007 QString v = le[b]->text();
1008 blankvalues[b]=Tile(v,0); 1008 blankvalues[b]=Tile(v,0);
1009 if ( v.length() != 1 ) 1009 if ( v.length() != 1 )
1010 goto retry; 1010 goto retry;
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 QStringList words; 1014 QStringList words;
1015 unshowTurn(); 1015 unshowTurn();
1016 turn_score = score(at,tiles,n,blankvalues,d,FALSE,&words); 1016 turn_score = score(at,tiles,n,blankvalues,d,FALSE,&words);
1017 showTurn(); 1017 showTurn();
1018 QStringList to_add; 1018 QStringList to_add;
1019 for (QStringList::Iterator it=words.begin(); it!=words.end(); ++it) { 1019 for (QStringList::Iterator it=words.begin(); it!=words.end(); ++it) {
1020 if ( !Global::fixedDawg().contains(*it) 1020 if ( !Global::fixedDawg().contains(*it)
1021 && !Global::dawg("WordGame").contains(*it) ) { 1021 && !Global::dawg("WordGame").contains(*it) ) {
1022 switch (QMessageBox::warning(this, tr("Unknown word"), 1022 switch (QMessageBox::warning(this, tr("Unknown word"),
1023 tr("<p>The word \"%1\" is not in the dictionary.").arg(*it), 1023 tr("<p>The word \"%1\" is not in the dictionary.").arg(*it),
1024 tr("Add"), tr("Ignore"), tr("Cancel"))) 1024 tr("Add"), tr("Ignore"), tr("Cancel")))
1025 { 1025 {
1026 case 0: 1026 case 0:
1027 // ####### add to wordgame dictionary 1027 // ####### add to wordgame dictionary
1028 to_add.append(*it); 1028 to_add.append(*it);
1029 break; 1029 break;
1030 case 1: 1030 case 1:
1031 break; 1031 break;
1032 case 2: 1032 case 2:
1033 unshowTurn(); 1033 unshowTurn();
1034 canvas()->update(); 1034 canvas()->update();
1035 return FALSE; 1035 return FALSE;
1036 } 1036 }
1037 } 1037 }
1038 } 1038 }
1039 if ( to_add.count() ) 1039 if ( to_add.count() )
1040 Global::addWords("WordGame",to_add); 1040 Global::addWords("WordGame",to_add);
1041 return TRUE; 1041 return TRUE;
1042} 1042}
1043 1043
1044void Board::scoreTurn(const QPoint& at, int n, const QPoint& d) 1044void Board::scoreTurn(const QPoint& at, int n, const QPoint& d)
1045{ 1045{
1046 unshowTurn(); 1046 unshowTurn();
1047 shown_at = at; 1047 shown_at = at;
1048 shown_n = n; 1048 shown_n = n;
1049 shown_step = d; 1049 shown_step = d;
1050 const Tile* tiles[99]; 1050 const Tile* tiles[99];
1051 if ( n > current_rack->count() ) 1051 if ( n > current_rack->count() )
1052 n = current_rack->count(); 1052 n = current_rack->count();
1053 for (int i=0; i<n; i++) 1053 for (int i=0; i<n; i++)
1054 tiles[i] = current_rack->tileRef(i); 1054 tiles[i] = current_rack->tileRef(i);
1055 turn_score = score(at,tiles,n,0,d,FALSE,0); 1055 turn_score = score(at,tiles,n,0,d,FALSE,0);
1056 emit temporaryScore(turn_score); 1056 emit temporaryScore(turn_score);
1057} 1057}
1058 1058
1059int Board::score(QPoint at, const Tile** tiles, int n, const Tile* blankvalue, const QPoint& d, bool checkdict, QStringList* words) const 1059int Board::score(QPoint at, const Tile** tiles, int n, const Tile* blankvalue, const QPoint& d, bool checkdict, QStringList* words) const
1060{ 1060{
1061 int total=0; 1061 int total=0;
1062 int totalsidetotal=0; 1062 int totalsidetotal=0;
1063 1063
1064 // words gets filled with words made 1064 // words gets filled with words made
1065 1065
1066 // mainword==0 -> 1066 // mainword==0 ->
1067 // Checks side words, but not main word 1067 // Checks side words, but not main word
1068 1068
1069 // -1 means words not in dict, or illegally positioned (eg. not connected) 1069 // -1 means words not in dict, or illegally positioned (eg. not connected)
1070 1070
1071 // text is assumed to fit on board. 1071 // text is assumed to fit on board.
1072 1072
1073 if ( words ) *words=QStringList(); 1073 if ( words ) *words=QStringList();
1074 1074
1075 QPoint otherd(d.y(), d.x()); 1075 QPoint otherd(d.y(), d.x());
1076 1076
1077 int all_mult = 1; 1077 int all_mult = 1;
1078 int bl=0; 1078 int bl=0;
1079 1079
1080 bool connected = FALSE; 1080 bool connected = FALSE;
1081 1081
1082 QString mainword=""; 1082 QString mainword="";
1083 1083
1084 if ( contains(at-d) && tile(at-d) ) { 1084 if ( contains(at-d) && tile(at-d) ) {
1085 return -1; // preceeding tiles 1085 return -1; // preceeding tiles
1086 } 1086 }
1087 1087
1088 const Tile* t; 1088 const Tile* t;
1089 for (int i=0; contains(at) && ((t=tile(at)) || i<n); ) { 1089 for (int i=0; contains(at) && ((t=tile(at)) || i<n); ) {
1090 if ( t ) { 1090 if ( t ) {
1091 if ( checkdict || words ) mainword += t->text(); 1091 if ( checkdict || words ) mainword += t->text();
1092 total += t->value(); 1092 total += t->value();
1093 connected = TRUE; 1093 connected = TRUE;
1094 } else { 1094 } else {
1095 QString sideword; 1095 QString sideword;
1096 QString tt; 1096 QString tt;
1097 if ( tiles[i]->isBlank() ) { 1097 if ( tiles[i]->isBlank() ) {
1098 if ( blankvalue ) 1098 if ( blankvalue )
1099 tt = blankvalue[bl++].text(); 1099 tt = blankvalue[bl++].text();
1100 } else { 1100 } else {
1101 tt = tiles[i]->text(); 1101 tt = tiles[i]->text();
1102 } 1102 }
1103 sideword=tt; 1103 sideword=tt;
1104 if ( checkdict || words ) mainword += tt; 1104 if ( checkdict || words ) mainword += tt;
1105 int side_mult = 1; 1105 int side_mult = 1;
1106 int tilevalue = bonussedValue(at,tiles[i]->value(),side_mult); 1106 int tilevalue = bonussedValue(at,tiles[i]->value(),side_mult);
1107 all_mult *= side_mult; 1107 all_mult *= side_mult;
1108 if ( !connected && isStart(at) ) 1108 if ( !connected && isStart(at) )
1109 connected = TRUE; 1109 connected = TRUE;
1110 total += tilevalue; 1110 total += tilevalue;
1111 int sidetotal = tilevalue; 1111 int sidetotal = tilevalue;
1112 { 1112 {
1113 QPoint side = at-otherd; 1113 QPoint side = at-otherd;
1114 1114
1115 while ( contains(side) && (t=tile(side)) ) { 1115 while ( contains(side) && (t=tile(side)) ) {
1116 sidetotal += t->value(); 1116 sidetotal += t->value();
1117 sideword.prepend(t->text()); 1117 sideword.prepend(t->text());
1118 side -= otherd; 1118 side -= otherd;
1119 } 1119 }
1120 } 1120 }
1121 { 1121 {
1122 QPoint side = at+otherd; 1122 QPoint side = at+otherd;
1123 while ( contains(side) && (t=tile(side)) ) { 1123 while ( contains(side) && (t=tile(side)) ) {
1124 sidetotal += t->value(); 1124 sidetotal += t->value();
1125 sideword.append(t->text()); 1125 sideword.append(t->text());
1126 side += otherd; 1126 side += otherd;
1127 } 1127 }
1128 } 1128 }
1129 if ( sideword.length() > 1 ) { 1129 if ( sideword.length() > 1 ) {
1130 if ( words ) 1130 if ( words )
1131 words->append(sideword); 1131 words->append(sideword);
1132 if ( checkdict && !Global::fixedDawg().contains(sideword) 1132 if ( checkdict && !Global::fixedDawg().contains(sideword)
1133 && !Global::dawg("WordGame").contains(sideword) ) 1133 && !Global::dawg("WordGame").contains(sideword) )
1134 return -1; 1134 return -1;
1135 totalsidetotal += sidetotal * side_mult; 1135 totalsidetotal += sidetotal * side_mult;
1136 connected = TRUE; 1136 connected = TRUE;
1137 } 1137 }
1138 i++; 1138 i++;
1139 } 1139 }
1140 at += d; 1140 at += d;
1141 } 1141 }
1142 1142
1143 if ( words ) 1143 if ( words )
1144 words->append(mainword); 1144 words->append(mainword);
1145 if ( checkdict && !Global::fixedDawg().contains(mainword) 1145 if ( checkdict && !Global::fixedDawg().contains(mainword)
1146 && !Global::dawg("WordGame").contains(mainword) ) 1146 && !Global::dawg("WordGame").contains(mainword) )
1147 return -1; 1147 return -1;
1148 1148
1149 if ( n == rack_tiles ) 1149 if ( n == rack_tiles )
1150 totalsidetotal += rack_tiles_bonus; 1150 totalsidetotal += rack_tiles_bonus;
1151 1151
1152 return connected ? totalsidetotal + total * all_mult : -1; 1152 return connected ? totalsidetotal + total * all_mult : -1;
1153} 1153}
1154 1154
1155QPoint Board::boardPos(const QPoint& p) const 1155QPoint Board::boardPos(const QPoint& p) const
1156{ 1156{
1157 return QPoint(p.x()/canvas()->tileWidth(), p.y()/canvas()->tileHeight()); 1157 return QPoint(p.x()/canvas()->tileWidth(), p.y()/canvas()->tileHeight());
1158} 1158}
1159 1159
1160void Board::contentsMouseReleaseEvent(QMouseEvent*) 1160void Board::contentsMouseReleaseEvent(QMouseEvent*)
1161{ 1161{
1162 if ( current_rack ) { 1162 if ( current_rack ) {
1163 } 1163 }
1164} 1164}
1165 1165
1166 1166
1167void Board::setRules(const QString& shapes, const int* effects) 1167void Board::setRules(const QString& shapes, const int* effects)
1168{ 1168{
1169 rule_shape=shapes; rule_effect=effects; 1169 rule_shape=shapes; rule_effect=effects;
1170 int i=0; 1170 int i=0;
1171 int maxre=0; 1171 int maxre=0;
1172 for (int y=0; y<yTiles(); y++) { 1172 for (int y=0; y<yTiles(); y++) {
1173 for (int x=0; x<xTiles(); x++) { 1173 for (int x=0; x<xTiles(); x++) {
1174 int re = shapes[i++]-'0'; 1174 int re = shapes[i++]-'0';
1175 if ( re > maxre ) maxre = re; 1175 if ( re > maxre ) maxre = re;
1176 canvas()->setTile(x,y,re); 1176 canvas()->setTile(x,y,re);
1177 } 1177 }
1178 } 1178 }
1179 rack_tiles_bonus=effects[maxre+1]; 1179 rack_tiles_bonus=effects[maxre+1];
1180} 1180}
1181 1181
1182void Board::unsetTile(const QPoint& p) 1182void Board::unsetTile(const QPoint& p)
1183{ 1183{
1184 delete item(p); 1184 delete item(p);
1185 grid[idx(p)] = 0; 1185 grid[idx(p)] = 0;
1186} 1186}
1187 1187
1188void Board::setTile(const QPoint& p, const Tile& t) 1188void Board::setTile(const QPoint& p, const Tile& t)
1189{ 1189{
1190 TileItem* it=item(p); 1190 TileItem* it=item(p);
1191 if ( !it ) { 1191 if ( !it ) {
1192 it = grid[idx(p)] = new TileItem(t,FALSE,canvas()); 1192 it = grid[idx(p)] = new TileItem(t,FALSE,canvas());
1193 it->move(p.x()*canvas()->tileWidth(), p.y()*canvas()->tileHeight()); 1193 it->move(p.x()*canvas()->tileWidth(), p.y()*canvas()->tileHeight());
1194 it->show(); 1194 it->show();
1195 } else { 1195 } else {
1196 it->setTile(t); 1196 it->setTile(t);
1197 } 1197 }
1198} 1198}
1199 1199
1200Rack::Rack(int ntiles, QWidget* parent) : QCanvasView( 1200Rack::Rack(int ntiles, QWidget* parent) : QCanvasView(
1201 new QCanvas(ntiles*TileItem::bigWidth(),TileItem::bigHeight()), 1201 new QCanvas(ntiles*TileItem::bigWidth(),TileItem::bigHeight()),
1202 parent), 1202 parent),
1203 item(ntiles) 1203 item(ntiles)
1204{ 1204{
1205 setLineWidth(1); 1205 setLineWidth(1);
1206 setFixedHeight(sizeHint().height()); 1206 setFixedHeight(sizeHint().height());
1207 n = 0; 1207 n = 0;
1208 for (int i=0; i<ntiles; i++) 1208 for (int i=0; i<ntiles; i++)
1209 item[i]=0; 1209 item[i]=0;
1210 setHScrollBarMode(AlwaysOff); 1210 setHScrollBarMode(AlwaysOff);
1211 setVScrollBarMode(AlwaysOff); 1211 setVScrollBarMode(AlwaysOff);
1212 canvas()->setBackgroundColor(gray); 1212 canvas()->setBackgroundColor(gray);
1213 dragging = 0; 1213 dragging = 0;
1214} 1214}
1215 1215
1216Rack::~Rack() 1216Rack::~Rack()
1217{ 1217{
1218 clear(); 1218 clear();
1219 delete canvas(); 1219 delete canvas();
1220} 1220}
1221 1221
1222QSize Rack::sizeHint() const 1222QSize Rack::sizeHint() const
1223{ 1223{
1224 return QSize(-1,TileItem::bigHeight()+2); 1224 return QSize(-1,TileItem::bigHeight()+2);
1225} 1225}
1226 1226
1227void Rack::clear() 1227void Rack::clear()
1228{ 1228{
1229 for (int i=0; i<n; i++) 1229 for (int i=0; i<n; i++)
1230 delete item[i]; 1230 delete item[i];
1231 n=0; 1231 n=0;
1232} 1232}
1233 1233
1234void Rack::writeConfig(Config& cfg) 1234void Rack::writeConfig(Config& cfg)
1235{ 1235{
1236 QStringList l; 1236 QStringList l;
1237 for (int i=0; i<n; i++) 1237 for (int i=0; i<n; i++)
1238 l.append(tile(i).key()); 1238 l.append(tile(i).key());
1239 cfg.writeEntry("Tiles",l,';'); 1239 cfg.writeEntry("Tiles",l,';');
1240} 1240}
1241 1241
1242void Rack::readConfig(Config& cfg) 1242void Rack::readConfig(Config& cfg)
1243{ 1243{
1244 clear(); 1244 clear();
1245 int x=0; 1245 int x=0;
1246 QStringList l = cfg.readListEntry("Tiles",';'); 1246 QStringList l = cfg.readListEntry("Tiles",';');
1247 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { 1247 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) {
1248 TileItem *i = new TileItem(Tile(*it),TRUE,canvas()); 1248 TileItem *i = new TileItem(Tile(*it),TRUE,canvas());
1249 i->move(x++,0); 1249 i->move(x++,0);
1250 i->show(); 1250 i->show();
1251 item[n++] = i; 1251 item[n++] = i;
1252 } 1252 }
1253 layoutTiles(); 1253 layoutTiles();
1254} 1254}
1255 1255
1256static int cmp_tileitem(const void *a, const void *b) 1256static int cmp_tileitem(const void *a, const void *b)
1257{ 1257{
1258 const TileItem* ia = *(TileItem**)a; 1258 const TileItem* ia = *(TileItem**)a;
1259 const TileItem* ib = *(TileItem**)b; 1259 const TileItem* ib = *(TileItem**)b;
1260 return int(ia->x() - ib->x()); 1260 return int(ia->x() - ib->x());
1261} 1261}
1262 1262
1263void Rack::layoutTiles() 1263void Rack::layoutTiles()
1264{ 1264{
1265 int w = TileItem::bigWidth()+2; 1265 int w = TileItem::bigWidth()+2;
1266 1266
1267 if ( dragging ) dragging->moveBy(dragging_adj,0); 1267 if ( dragging ) dragging->moveBy(dragging_adj,0);
1268 qsort(item.data(), n, sizeof(TileItem*), cmp_tileitem); 1268 qsort(item.data(), n, sizeof(TileItem*), cmp_tileitem);
1269 if ( dragging ) dragging->moveBy(-dragging_adj,0); 1269 if ( dragging ) dragging->moveBy(-dragging_adj,0);
1270 1270
1271 for (int i=0; i<n ;i++) 1271 for (int i=0; i<n ;i++)
1272 if ( item[i] == dragging ) { 1272 if ( item[i] == dragging ) {
1273 item[i]->setZ(1); 1273 item[i]->setZ(1);
1274 } else { 1274 } else {
1275 item[i]->move(i*w, 0); 1275 item[i]->move(i*w, 0);
1276 item[i]->setZ(0); 1276 item[i]->setZ(0);
1277 } 1277 }
1278 canvas()->update(); 1278 canvas()->update();
1279} 1279}
1280 1280
1281void Rack::setBlanks(const Tile* bv) 1281void Rack::setBlanks(const Tile* bv)
1282{ 1282{
1283 for (int j=0; j<n; j++) { 1283 for (int j=0; j<n; j++) {
1284 Tile tt = item[j]->tile(); 1284 Tile tt = item[j]->tile();
1285 if ( tt.isBlank() ) { 1285 if ( tt.isBlank() ) {
1286 tt.setText(bv->text()); 1286 tt.setText(bv->text());
1287 item[j]->setTile(tt); 1287 item[j]->setTile(tt);
1288 bv++; 1288 bv++;
1289 } 1289 }
1290 } 1290 }
1291} 1291}
1292 1292
1293bool Rack::arrangeTiles(const Tile** s, int sn) 1293bool Rack::arrangeTiles(const Tile** s, int sn)
1294{ 1294{
1295 bool could = TRUE; 1295 bool could = TRUE;
1296 for (int j=0; j<n; j++) { 1296 for (int j=0; j<n; j++) {
1297 Tile tt = item[j]->tile(); 1297 Tile tt = item[j]->tile();
1298 int f=-1; 1298 int f=-1;
1299 for (int i=0; i<sn && f<0; i++) { 1299 for (int i=0; i<sn && f<0; i++) {
1300 if (s[i] && *s[i] == tt ) { 1300 if (s[i] && *s[i] == tt ) {
1301 s[i]=0; 1301 s[i]=0;
1302 f=i; 1302 f=i;
1303 } 1303 }
1304 } 1304 }
1305 if ( f >= 0 ) { 1305 if ( f >= 0 ) {
1306 item[j]->move(f-999,0); 1306 item[j]->move(f-999,0);
1307 } else { 1307 } else {
1308 could = FALSE; 1308 could = FALSE;
1309 } 1309 }
1310 } 1310 }
1311 layoutTiles(); 1311 layoutTiles();
1312 return could; 1312 return could;
1313} 1313}
1314 1314
1315void Rack::addTile(const Tile& t) 1315void Rack::addTile(const Tile& t)
1316{ 1316{
1317 TileItem *i = new TileItem(t,TRUE,canvas()); 1317 TileItem *i = new TileItem(t,TRUE,canvas());
1318 i->show(); 1318 i->show();
1319 item[n++] = i; 1319 item[n++] = i;
1320 layoutTiles(); 1320 layoutTiles();
1321} 1321}
1322 1322
1323void Rack::remove(Tile t) 1323void Rack::remove(Tile t)
1324{ 1324{
1325 for (int i=0; i<n ;i++) 1325 for (int i=0; i<n ;i++)
1326 if ( item[i]->tile() == t ) { 1326 if ( item[i]->tile() == t ) {
1327 remove(i); 1327 remove(i);
1328 return; 1328 return;
1329 } 1329 }
1330} 1330}
1331 1331
1332void Rack::remove(int i) 1332void Rack::remove(int i)
1333{ 1333{
1334 delete item[i]; 1334 delete item[i];
1335 n--; 1335 n--;
1336 for (;i<n;i++) 1336 for (;i<n;i++)
1337 item[i]=item[i+1]; 1337 item[i]=item[i+1];
1338 layoutTiles(); 1338 layoutTiles();
1339} 1339}
1340 1340
1341void Rack::resizeEvent(QResizeEvent* e) 1341void Rack::resizeEvent(QResizeEvent* e)
1342{ 1342{
1343 canvas()->resize(width()-frameWidth()*2,height()-frameWidth()*2); 1343 canvas()->resize(width()-frameWidth()*2,height()-frameWidth()*2);
1344 QCanvasView::resizeEvent(e); 1344 QCanvasView::resizeEvent(e);
1345} 1345}
1346 1346
1347void Rack::contentsMousePressEvent(QMouseEvent* e) 1347void Rack::contentsMousePressEvent(QMouseEvent* e)
1348{ 1348{
1349 if ( computerized() ) 1349 if ( computerized() )
1350 return; 1350 return;
1351 QCanvasItemList list = canvas()->collisions(e->pos()); 1351 QCanvasItemList list = canvas()->collisions(e->pos());
1352 if (list.count()) { 1352 if (list.count()) {
1353 dragging = list.first(); 1353 dragging = list.first();
1354 dragstart = e->pos()-QPoint(int(dragging->x()),int(dragging->y())); 1354 dragstart = e->pos()-QPoint(int(dragging->x()),int(dragging->y()));
1355 } else { 1355 } else {
1356 dragging = 0; 1356 dragging = 0;
1357 } 1357 }
1358} 1358}
1359 1359
1360void Rack::contentsMouseMoveEvent(QMouseEvent* e) 1360void Rack::contentsMouseMoveEvent(QMouseEvent* e)
1361{ 1361{
1362 if ( computerized() ) 1362 if ( computerized() )
1363 return; 1363 return;
1364 //int w = TileItem::bigWidth()+2; 1364 //int w = TileItem::bigWidth()+2;
1365 if ( dragging ) { 1365 if ( dragging ) {
1366 dragging_adj = TileItem::bigWidth()/2; 1366 dragging_adj = TileItem::bigWidth()/2;
1367 if ( dragging->x() > e->x()-dragstart.x() ) 1367 if ( dragging->x() > e->x()-dragstart.x() )
1368 dragging_adj = -dragging_adj; 1368 dragging_adj = -dragging_adj;
1369 dragging->move(e->x()-dragstart.x(),0); 1369 dragging->move(e->x()-dragstart.x(),0);
1370 layoutTiles(); 1370 layoutTiles();
1371 } 1371 }
1372} 1372}
1373 1373
1374void Rack::contentsMouseReleaseEvent(QMouseEvent* e) 1374void Rack::contentsMouseReleaseEvent(QMouseEvent* e)
1375{ 1375{
1376 if ( computerized() ) 1376 if ( computerized() )
1377 return; 1377 return;
1378 if ( dragging ) { 1378 if ( dragging ) {
1379 dragging=0; 1379 dragging=0;
1380 layoutTiles(); 1380 layoutTiles();
1381 } 1381 }
1382} 1382}
1383 1383
1384Tile::Tile(const QString& key) 1384Tile::Tile(const QString& key)
1385{ 1385{
1386 int a=key.find('@'); 1386 int a=key.find('@');
1387 txt = key.left(a); 1387 txt = key.left(a);
1388 val = key.mid(a+1).toInt(); 1388 val = key.mid(a+1).toInt();
1389 blank = txt.isEmpty(); 1389 blank = txt.isEmpty();
1390} 1390}
1391 1391
1392QString Tile::key() const 1392QString Tile::key() const
1393{ 1393{
1394 return txt+"@"+QString::number(val); 1394 return txt+"@"+QString::number(val);
1395} 1395}
1396 1396
1397Bag::Bag() 1397Bag::Bag()
1398{ 1398{
1399 tiles.setAutoDelete(TRUE); 1399 tiles.setAutoDelete(TRUE);
1400} 1400}
1401 1401
1402void Bag::writeConfig(Config& cfg) 1402void Bag::writeConfig(Config& cfg)
1403{ 1403{
1404 QStringList t; 1404 QStringList t;
1405 for (QListIterator<Tile> it(tiles); it; ++it) 1405 for (QListIterator<Tile> it(tiles); it; ++it)
1406 t.append((*it)->key()); 1406 t.append((*it)->key());
1407 cfg.writeEntry("Tiles",t,';'); 1407 cfg.writeEntry("Tiles",t,';');
1408} 1408}
1409 1409
1410void Bag::readConfig(Config& cfg) 1410void Bag::readConfig(Config& cfg)
1411{ 1411{
1412 tiles.clear(); 1412 tiles.clear();
1413 QStringList t = cfg.readListEntry("Tiles",';'); 1413 QStringList t = cfg.readListEntry("Tiles",';');
1414 for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it ) 1414 for (QStringList::ConstIterator it=t.begin(); it!=t.end(); ++it )
1415 add(Tile(*it)); 1415 add(Tile(*it));
1416} 1416}
1417 1417
1418void Bag::add(const Tile& t) 1418void Bag::add(const Tile& t)
1419{ 1419{
1420 tiles.append(new Tile(t)); 1420 tiles.append(new Tile(t));
1421} 1421}
1422 1422
1423Tile Bag::takeRandom() 1423Tile Bag::takeRandom()
1424{ 1424{
1425 Tile* rp = tiles.take(random()%tiles.count()); 1425 Tile* rp = tiles.take(random()%tiles.count());
1426 Tile r=*rp; 1426 Tile r=*rp;
1427 return r; 1427 return r;
1428} 1428}
1429 1429
1430ScoreInfo::ScoreInfo( QWidget* parent, const char* name, WFlags fl ) : 1430ScoreInfo::ScoreInfo( QWidget* parent, const char* name, WFlags fl ) :
1431 QLabel("<P>",parent,name,fl) 1431 QLabel("<P>",parent,name,fl)
1432{ 1432{
1433 score=0; 1433 score=0;
1434 msgtimer = new QTimer(this); 1434 msgtimer = new QTimer(this);
1435 connect(msgtimer, SIGNAL(timeout()), this, SLOT(showScores())); 1435 connect(msgtimer, SIGNAL(timeout()), this, SLOT(showScores()));
1436 setBackgroundMode( PaletteButton ); 1436 setBackgroundMode( PaletteButton );
1437} 1437}
1438 1438
1439ScoreInfo::~ScoreInfo() 1439ScoreInfo::~ScoreInfo()
1440{ 1440{
1441 if ( score ) delete [] score; 1441 if ( score ) delete [] score;
1442} 1442}
1443 1443
1444void ScoreInfo::writeConfig(Config& cfg) 1444void ScoreInfo::writeConfig(Config& cfg)
1445{ 1445{
1446 QStringList l; 1446 QStringList l;
1447 for (int i=0; i<(int)names.count(); i++) 1447 for (int i=0; i<(int)names.count(); i++)
1448 l.append(QString::number(score[i])); 1448 l.append(QString::number(score[i]));
1449 cfg.writeEntry("Scores",l,';'); 1449 cfg.writeEntry("Scores",l,';');
1450} 1450}
1451 1451
1452void ScoreInfo::readConfig(Config& cfg) 1452void ScoreInfo::readConfig(Config& cfg)
1453{ 1453{
1454 QStringList l = cfg.readListEntry("Scores",';'); 1454 QStringList l = cfg.readListEntry("Scores",';');
1455 int i=0; 1455 int i=0;
1456 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it ) 1456 for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it )
1457 score[i++]=(*it).toInt(); 1457 score[i++]=(*it).toInt();
1458 showScores(); 1458 showScores();
1459} 1459}
1460 1460
1461 1461
1462QSize ScoreInfo::sizeHint() const 1462QSize ScoreInfo::sizeHint() const
1463{ 1463{
1464 return QSize(QLabel::sizeHint().width(),fontMetrics().height()); 1464 return QSize(QLabel::sizeHint().width(),fontMetrics().height());
1465} 1465}
1466 1466
1467void ScoreInfo::init(const QStringList& namelist) 1467void ScoreInfo::init(const QStringList& namelist)
1468{ 1468{
1469 names = namelist; 1469 names = namelist;
1470 if ( score ) delete [] score; 1470 if ( score ) delete [] score;
1471 score = new int[names.count()]; 1471 score = new int[names.count()];
1472 memset(score,0,sizeof(int)*names.count()); 1472 memset(score,0,sizeof(int)*names.count());
1473 boldone = -1; 1473 boldone = -1;
1474 showScores(); 1474 showScores();
1475} 1475}
1476 1476
1477void ScoreInfo::addScore(int player, int change) 1477void ScoreInfo::addScore(int player, int change)
1478{ 1478{
1479 score[player] += change; 1479 score[player] += change;
1480 showScores(); 1480 showScores();
1481} 1481}
1482 1482
1483void ScoreInfo::setBoldOne(int b) 1483void ScoreInfo::setBoldOne(int b)
1484{ 1484{
1485 boldone=b; 1485 boldone=b;
1486 showScores(); 1486 showScores();
1487} 1487}
1488 1488
1489void ScoreInfo::showScores() 1489void ScoreInfo::showScores()
1490{ 1490{
1491 QString r="<p>"; 1491 QString r="<p>";
1492 int i=0; 1492 int i=0;
1493 //int spl=(names.count()+1)/2; // 2 lines 1493 //int spl=(names.count()+1)/2; // 2 lines
1494 for (QStringList::ConstIterator it=names.begin(); it!=names.end(); ) { 1494 for (QStringList::ConstIterator it=names.begin(); it!=names.end(); ) {
1495 if ( i==boldone ) r += "<b>"; 1495 if ( i==boldone ) r += "<b>";
1496 QString n = *it; 1496 QString n = *it;
1497 n.replace(QRegExp(":.*"),""); 1497 n.replace(QRegExp(":.*"),"");
1498 r += n; 1498 r += n;
1499 r += ":"; 1499 r += ":";
1500 r += QString::number(score[i]); 1500 r += QString::number(score[i]);
1501 if ( i==boldone ) r += "</b>"; 1501 if ( i==boldone ) r += "</b>";
1502 1502
1503 ++i; 1503 ++i;
1504 ++it; 1504 ++it;
1505 if ( it != names.end() ) 1505 if ( it != names.end() )
1506 r += " "; 1506 r += " ";
1507 } 1507 }
1508 setText(r); 1508 setText(r);
1509} 1509}
1510 1510
1511void ScoreInfo::showTemporaryScore(int amount) 1511void ScoreInfo::showTemporaryScore(int amount)
1512{ 1512{
1513 if ( amount < 0 ) 1513 if ( amount < 0 )
1514 setText(tr("<P>Invalid move")); 1514 setText(tr("<P>Invalid move"));
1515 else 1515 else
1516 setText(tr("<P>Score: ")+QString::number(amount)); 1516 setText(tr("<P>Score: ")+QString::number(amount));
1517 msgtimer->start(3000,TRUE); 1517 msgtimer->start(3000,TRUE);
1518} 1518}
1519 1519
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 4db6208..aac6bc1 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,661 +1,667 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpad.h" 14#include "drawpad.h"
15 15
16#include "drawpadcanvas.h" 16#include "drawpadcanvas.h"
17#include "ellipsetool.h" 17#include "ellipsetool.h"
18#include "erasetool.h" 18#include "erasetool.h"
19#include "exportdialog.h" 19#include "exportdialog.h"
20#include "filledellipsetool.h" 20#include "filledellipsetool.h"
21#include "filledrectangletool.h" 21#include "filledrectangletool.h"
22#include "filltool.h" 22#include "filltool.h"
23#include "importdialog.h" 23#include "importdialog.h"
24#include "linetool.h" 24#include "linetool.h"
25#include "newpagedialog.h" 25#include "newpagedialog.h"
26#include "page.h" 26#include "page.h"
27#include "pageinformationdialog.h" 27#include "pageinformationdialog.h"
28#include "pointtool.h" 28#include "pointtool.h"
29#include "rectangletool.h" 29#include "rectangletool.h"
30#include "texttool.h" 30#include "texttool.h"
31#include "thumbnailview.h" 31#include "thumbnailview.h"
32 32
33#include <opie/colordialog.h> 33#include <opie/colordialog.h>
34#include <opie/colorpopupmenu.h> 34#include <opie/colorpopupmenu.h>
35 35
36#include <qpe/applnk.h> 36#include <qpe/applnk.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpetoolbar.h> 40#include <qpe/qpetoolbar.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42 42
43#include <qaction.h> 43#include <qaction.h>
44#include <qfile.h> 44#include <qfile.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qpainter.h> 46#include <qpainter.h>
47#include <qspinbox.h> 47#include <qspinbox.h>
48#include <qtoolbutton.h> 48#include <qtoolbutton.h>
49#include <qtooltip.h> 49#include <qtooltip.h>
50#include <qwhatsthis.h> 50#include <qwhatsthis.h>
51 51
52DrawPad::DrawPad(QWidget* parent, const char* name) 52DrawPad::DrawPad(QWidget* parent, const char* name)
53 : QMainWindow(parent, name, WStyle_ContextHelp) 53 : QMainWindow(parent, name, WStyle_ContextHelp)
54{ 54{
55 // init members 55 // init members
56 56
57 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 57 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
58 58
59 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 59 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
60 60
61 setCentralWidget(m_pDrawPadCanvas); 61 setCentralWidget(m_pDrawPadCanvas);
62 62
63 // init menu 63 // init menu
64 64
65 setToolBarsMovable(false); 65 setToolBarsMovable(false);
66 66
67 QPEToolBar* menuToolBar = new QPEToolBar(this); 67 QPEToolBar* menuToolBar = new QPEToolBar(this);
68 QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); 68 QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar);
69 69
70 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); 70 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
71 71
72 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); 72 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
73 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); 73 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
74 deleteAllAction->addTo(toolsPopupMenu); 74 deleteAllAction->addTo(toolsPopupMenu);
75 75
76 toolsPopupMenu->insertSeparator(); 76 toolsPopupMenu->insertSeparator();
77 77
78 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); 78 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
79 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); 79 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
80 importPageAction->addTo(toolsPopupMenu); 80 importPageAction->addTo(toolsPopupMenu);
81 81
82 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); 82 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
83 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); 83 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
84 exportPageAction->addTo(toolsPopupMenu); 84 exportPageAction->addTo(toolsPopupMenu);
85 85
86 toolsPopupMenu->insertSeparator(); 86 toolsPopupMenu->insertSeparator();
87 87
88 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); 88 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
89 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); 89 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
90 thumbnailViewAction->addTo(toolsPopupMenu); 90 thumbnailViewAction->addTo(toolsPopupMenu);
91 91
92 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); 92 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
93 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); 93 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
94 pageInformationAction->addTo(toolsPopupMenu); 94 pageInformationAction->addTo(toolsPopupMenu);
95 95
96 toolsPopupMenu->insertSeparator(); 96 toolsPopupMenu->insertSeparator();
97 97
98 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); 98 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this);
99 m_pAntiAliasingAction->setToggleAction(true); 99 m_pAntiAliasingAction->setToggleAction(true);
100 m_pAntiAliasingAction->addTo(toolsPopupMenu); 100 m_pAntiAliasingAction->addTo(toolsPopupMenu);
101 101
102 menuBar->insertItem(tr("Tools"), toolsPopupMenu); 102 menuBar->insertItem(tr("Tools"), toolsPopupMenu);
103 103
104 // init page toolbar 104 // init page toolbar
105 105
106 QPEToolBar* pageToolBar = new QPEToolBar(this); 106 QPEToolBar* pageToolBar = new QPEToolBar(this);
107 107
108 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); 108 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this);
109 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); 109 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage()));
110 newPageAction->addTo(pageToolBar); 110 newPageAction->addTo(pageToolBar);
111 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); 111 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) );
112 112
113 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); 113 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this);
114 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); 114 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage()));
115 clearPageAction->addTo(pageToolBar); 115 clearPageAction->addTo(pageToolBar);
116 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); 116 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) );
117 117
118 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); 118 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this);
119 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); 119 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage()));
120 deletePageAction->addTo(pageToolBar); 120 deletePageAction->addTo(pageToolBar);
121 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); 121 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) );
122 122
123 QPEToolBar* emptyToolBar = new QPEToolBar(this); 123 QPEToolBar* emptyToolBar = new QPEToolBar(this);
124 emptyToolBar->setHorizontalStretchable(true); 124 emptyToolBar->setHorizontalStretchable(true);
125 125
126 // init navigation toolbar 126 // init navigation toolbar
127 127
128 QPEToolBar* navigationToolBar = new QPEToolBar(this); 128 QPEToolBar* navigationToolBar = new QPEToolBar(this);
129 129
130 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); 130 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this);
131 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); 131 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
132 m_pUndoAction->addTo(navigationToolBar); 132 m_pUndoAction->addTo(navigationToolBar);
133 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); 133 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) );
134 134
135 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); 135 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this);
136 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); 136 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
137 m_pRedoAction->addTo(navigationToolBar); 137 m_pRedoAction->addTo(navigationToolBar);
138 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); 138 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) );
139 139
140 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); 140 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
141 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); 141 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
142 m_pFirstPageAction->addTo(navigationToolBar); 142 m_pFirstPageAction->addTo(navigationToolBar);
143 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); 143 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) );
144 144
145 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); 145 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
146 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); 146 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
147 m_pPreviousPageAction->addTo(navigationToolBar); 147 m_pPreviousPageAction->addTo(navigationToolBar);
148 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); 148 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) );
149 149
150 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); 150 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
151 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); 151 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
152 m_pNextPageAction->addTo(navigationToolBar); 152 m_pNextPageAction->addTo(navigationToolBar);
153 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); 153 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) );
154 154
155 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); 155 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
156 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); 156 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
157 m_pLastPageAction->addTo(navigationToolBar); 157 m_pLastPageAction->addTo(navigationToolBar);
158 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); 158 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) );
159 159
160 // init draw mode toolbar 160 // init draw mode toolbar
161 161
162 QPEToolBar* drawModeToolBar = new QPEToolBar(this); 162 QPEToolBar* drawModeToolBar = new QPEToolBar(this);
163 163
164 m_pLineToolButton = new QToolButton(drawModeToolBar); 164 m_pLineToolButton = new QToolButton(drawModeToolBar);
165 m_pLineToolButton->setToggleButton(true); 165 m_pLineToolButton->setToggleButton(true);
166 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); 166 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) );
167 167
168 168
169 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); 169 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton);
170 170
171 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); 171 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this);
172 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); 172 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
173 m_pPointToolAction->addTo(linePopupMenu); 173 m_pPointToolAction->addTo(linePopupMenu);
174 174
175 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); 175 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this);
176 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); 176 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
177 m_pLineToolAction->addTo(linePopupMenu); 177 m_pLineToolAction->addTo(linePopupMenu);
178 178
179 m_pLineToolButton->setPopup(linePopupMenu); 179 m_pLineToolButton->setPopup(linePopupMenu);
180 m_pLineToolButton->setPopupDelay(0); 180 m_pLineToolButton->setPopupDelay(0);
181 181
182 m_pRectangleToolButton = new QToolButton(drawModeToolBar); 182 m_pRectangleToolButton = new QToolButton(drawModeToolBar);
183 m_pRectangleToolButton->setToggleButton(true); 183 m_pRectangleToolButton->setToggleButton(true);
184 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); 184 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) );
185 185
186 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); 186 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
187 187
188 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); 188 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this);
189 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); 189 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
190 m_pRectangleToolAction->addTo(rectanglePopupMenu); 190 m_pRectangleToolAction->addTo(rectanglePopupMenu);
191 191
192 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); 192 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this);
193 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); 193 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
194 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); 194 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
195 195
196 m_pRectangleToolButton->setPopup(rectanglePopupMenu); 196 m_pRectangleToolButton->setPopup(rectanglePopupMenu);
197 m_pRectangleToolButton->setPopupDelay(0); 197 m_pRectangleToolButton->setPopupDelay(0);
198 198
199 m_pEllipseToolButton = new QToolButton(drawModeToolBar); 199 m_pEllipseToolButton = new QToolButton(drawModeToolBar);
200 m_pEllipseToolButton->setToggleButton(true); 200 m_pEllipseToolButton->setToggleButton(true);
201 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); 201 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) );
202 202
203 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); 203 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
204 204
205 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); 205 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this);
206 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); 206 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
207 m_pEllipseToolAction->addTo(ellipsePopupMenu); 207 m_pEllipseToolAction->addTo(ellipsePopupMenu);
208 208
209 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); 209 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this);
210 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); 210 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
211 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); 211 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
212 212
213 m_pEllipseToolButton->setPopup(ellipsePopupMenu); 213 m_pEllipseToolButton->setPopup(ellipsePopupMenu);
214 m_pEllipseToolButton->setPopupDelay(0); 214 m_pEllipseToolButton->setPopupDelay(0);
215 215
216 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); 216 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this);
217 m_pTextToolAction->setToggleAction(true); 217 m_pTextToolAction->setToggleAction(true);
218 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); 218 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool()));
219 m_pTextToolAction->addTo(drawModeToolBar); 219 m_pTextToolAction->addTo(drawModeToolBar);
220 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); 220 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) );
221 221
222 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); 222 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this);
223 m_pFillToolAction->setToggleAction(true); 223 m_pFillToolAction->setToggleAction(true);
224 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); 224 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
225 m_pFillToolAction->addTo(drawModeToolBar); 225 m_pFillToolAction->addTo(drawModeToolBar);
226 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); 226 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) );
227 227
228 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); 228 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this);
229 m_pEraseToolAction->setToggleAction(true); 229 m_pEraseToolAction->setToggleAction(true);
230 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); 230 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
231 m_pEraseToolAction->addTo(drawModeToolBar); 231 m_pEraseToolAction->addTo(drawModeToolBar);
232 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); 232 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) );
233 233
234 m_pTool = 0; 234 m_pTool = 0;
235 setRectangleTool(); 235 setRectangleTool();
236 setEllipseTool(); 236 setEllipseTool();
237 setPointTool(); 237 setPointTool();
238 238
239 emptyToolBar = new QPEToolBar(this); 239 emptyToolBar = new QPEToolBar(this);
240 emptyToolBar->setHorizontalStretchable(true); 240 emptyToolBar->setHorizontalStretchable(true);
241 emptyToolBar->addSeparator(); 241 emptyToolBar->addSeparator();
242 242
243 // init draw parameters toolbar 243 // init draw parameters toolbar
244 244
245 QPEToolBar* drawParametersToolBar = new QPEToolBar(this); 245 QPEToolBar* drawParametersToolBar = new QPEToolBar(this);
246 246
247 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); 247 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
248 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); 248 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
249 249
250 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); 250 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
251 m_pPenWidthSpinBox->setValue(1); 251 m_pPenWidthSpinBox->setValue(1);
252 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); 252 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
253 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); 253 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) );
254 254
255 m_pPenColorToolButton = new QToolButton(drawParametersToolBar); 255 m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
256 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); 256 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor"));
257 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); 257 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) );
258 258
259 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); 259 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton);
260 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); 260 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
261 261
262 QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); 262 QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
263 m_pPenColorToolButton->setPopup(penColorPopupMenu); 263 m_pPenColorToolButton->setPopup(penColorPopupMenu);
264 m_pPenColorToolButton->setPopupDelay(0); 264 m_pPenColorToolButton->setPopupDelay(0);
265 265
266 changePenColor(Qt::black); 266 changePenColor(Qt::black);
267 267
268 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); 268 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
269 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); 269 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor"));
270 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); 270 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) );
271 271
272 OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); 272 OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton);
273 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); 273 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
274 274
275 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); 275 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
276 m_pBrushColorToolButton->setPopup(brushColorPopupMenu); 276 m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
277 m_pBrushColorToolButton->setPopupDelay(0); 277 m_pBrushColorToolButton->setPopupDelay(0);
278 278
279 changeBrushColor(Qt::white); 279 changeBrushColor(Qt::white);
280 280
281}
282
283
284void DrawPad::finishStartup()
285{
281 // init pages 286 // init pages
282 287
283 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 288 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
284 289
285 if (file.open(IO_ReadOnly)) { 290 if (file.open(IO_ReadOnly)) {
286 m_pDrawPadCanvas->load(&file); 291 m_pDrawPadCanvas->load(&file);
287 file.close(); 292 file.close();
288 } else { 293 } else {
289 m_pDrawPadCanvas->initialPage(); 294 m_pDrawPadCanvas->initialPage();
290 } 295 }
291 296
292 loadConfig(); 297 loadConfig();
298
293} 299}
294 300
295DrawPad::~DrawPad() 301DrawPad::~DrawPad()
296{ 302{
297 saveConfig(); 303 saveConfig();
298 304
299 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 305 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
300 306
301 if (file.open(IO_WriteOnly)) { 307 if (file.open(IO_WriteOnly)) {
302 m_pDrawPadCanvas->save(&file); 308 m_pDrawPadCanvas->save(&file);
303 file.close(); 309 file.close();
304 } 310 }
305} 311}
306 312
307bool DrawPad::antiAliasing() 313bool DrawPad::antiAliasing()
308{ 314{
309 return (m_pAntiAliasingAction->isOn()); 315 return (m_pAntiAliasingAction->isOn());
310} 316}
311 317
312void DrawPad::newPage() 318void DrawPad::newPage()
313{ 319{
314 QRect rect = m_pDrawPadCanvas->contentsRect(); 320 QRect rect = m_pDrawPadCanvas->contentsRect();
315 321
316 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); 322 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
317 323
318 if (newPageDialog.exec() == QDialog::Accepted) { 324 if (newPageDialog.exec() == QDialog::Accepted) {
319 m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), 325 m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
320 newPageDialog.selectedHeight(), newPageDialog.selectedColor()); 326 newPageDialog.selectedHeight(), newPageDialog.selectedColor());
321 } 327 }
322} 328}
323 329
324void DrawPad::clearPage() 330void DrawPad::clearPage()
325{ 331{
326 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), 332 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
327 QMessageBox::Information, QMessageBox::Yes, 333 QMessageBox::Information, QMessageBox::Yes,
328 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 334 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
329 QMessageBox::NoButton, this); 335 QMessageBox::NoButton, this);
330 336
331 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 337 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
332 messageBox.setButtonText(QMessageBox::No, tr("No")); 338 messageBox.setButtonText(QMessageBox::No, tr("No"));
333 339
334 if (messageBox.exec() == QMessageBox::Yes) { 340 if (messageBox.exec() == QMessageBox::Yes) {
335 m_pDrawPadCanvas->clearPage(); 341 m_pDrawPadCanvas->clearPage();
336 } 342 }
337} 343}
338 344
339void DrawPad::deletePage() 345void DrawPad::deletePage()
340{ 346{
341 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), 347 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
342 QMessageBox::Information, QMessageBox::Yes, 348 QMessageBox::Information, QMessageBox::Yes,
343 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 349 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
344 QMessageBox::NoButton, this); 350 QMessageBox::NoButton, this);
345 351
346 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 352 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
347 messageBox.setButtonText(QMessageBox::No, tr("No")); 353 messageBox.setButtonText(QMessageBox::No, tr("No"));
348 354
349 if (messageBox.exec() == QMessageBox::Yes) { 355 if (messageBox.exec() == QMessageBox::Yes) {
350 m_pDrawPadCanvas->deletePage(); 356 m_pDrawPadCanvas->deletePage();
351 } 357 }
352} 358}
353 359
354void DrawPad::setPointTool() 360void DrawPad::setPointTool()
355{ 361{
356 if (m_pTool) { 362 if (m_pTool) {
357 delete m_pTool; 363 delete m_pTool;
358 } 364 }
359 365
360 m_pTool = new PointTool(this, m_pDrawPadCanvas); 366 m_pTool = new PointTool(this, m_pDrawPadCanvas);
361 367
362 m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); 368 m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet());
363 QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); 369 QToolTip::add(m_pLineToolButton, m_pPointToolAction->text());
364 370
365 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); 371 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
366 connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); 372 connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated()));
367 373
368 m_pLineToolButton->setOn(true); 374 m_pLineToolButton->setOn(true);
369 m_pRectangleToolButton->setOn(false); 375 m_pRectangleToolButton->setOn(false);
370 m_pEllipseToolButton->setOn(false); 376 m_pEllipseToolButton->setOn(false);
371 m_pTextToolAction->setOn(false); 377 m_pTextToolAction->setOn(false);
372 m_pFillToolAction->setOn(false); 378 m_pFillToolAction->setOn(false);
373 m_pEraseToolAction->setOn(false); 379 m_pEraseToolAction->setOn(false);
374} 380}
375 381
376void DrawPad::setLineTool() 382void DrawPad::setLineTool()
377{ 383{
378 if (m_pTool) { 384 if (m_pTool) {
379 delete m_pTool; 385 delete m_pTool;
380 } 386 }
381 387
382 m_pTool = new LineTool(this, m_pDrawPadCanvas); 388 m_pTool = new LineTool(this, m_pDrawPadCanvas);
383 389
384 m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); 390 m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet());
385 QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); 391 QToolTip::add(m_pLineToolButton, m_pLineToolAction->text());
386 392
387 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); 393 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
388 connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); 394 connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated()));
389 395
390 m_pLineToolButton->setOn(true); 396 m_pLineToolButton->setOn(true);
391 m_pRectangleToolButton->setOn(false); 397 m_pRectangleToolButton->setOn(false);
392 m_pEllipseToolButton->setOn(false); 398 m_pEllipseToolButton->setOn(false);
393 m_pTextToolAction->setOn(false); 399 m_pTextToolAction->setOn(false);
394 m_pFillToolAction->setOn(false); 400 m_pFillToolAction->setOn(false);
395 m_pEraseToolAction->setOn(false); 401 m_pEraseToolAction->setOn(false);
396} 402}
397 403
398void DrawPad::setRectangleTool() 404void DrawPad::setRectangleTool()
399{ 405{
400 if (m_pTool) { 406 if (m_pTool) {
401 delete m_pTool; 407 delete m_pTool;
402 } 408 }
403 409
404 m_pTool = new RectangleTool(this, m_pDrawPadCanvas); 410 m_pTool = new RectangleTool(this, m_pDrawPadCanvas);
405 411
406 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); 412 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet());
407 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); 413 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text());
408 414
409 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); 415 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
410 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); 416 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
411 417
412 m_pLineToolButton->setOn(false); 418 m_pLineToolButton->setOn(false);
413 m_pRectangleToolButton->setOn(true); 419 m_pRectangleToolButton->setOn(true);
414 m_pEllipseToolButton->setOn(false); 420 m_pEllipseToolButton->setOn(false);
415 m_pTextToolAction->setOn(false); 421 m_pTextToolAction->setOn(false);
416 m_pFillToolAction->setOn(false); 422 m_pFillToolAction->setOn(false);
417 m_pEraseToolAction->setOn(false); 423 m_pEraseToolAction->setOn(false);
418} 424}
419 425
420void DrawPad::setFilledRectangleTool() 426void DrawPad::setFilledRectangleTool()
421{ 427{
422 if (m_pTool) { 428 if (m_pTool) {
423 delete m_pTool; 429 delete m_pTool;
424 } 430 }
425 431
426 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); 432 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas);
427 433
428 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); 434 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet());
429 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); 435 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text());
430 436
431 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); 437 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
432 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); 438 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
433 439
434 m_pLineToolButton->setOn(false); 440 m_pLineToolButton->setOn(false);
435 m_pRectangleToolButton->setOn(true); 441 m_pRectangleToolButton->setOn(true);
436 m_pEllipseToolButton->setOn(false); 442 m_pEllipseToolButton->setOn(false);
437 m_pTextToolAction->setOn(false); 443 m_pTextToolAction->setOn(false);
438 m_pFillToolAction->setOn(false); 444 m_pFillToolAction->setOn(false);
439 m_pEraseToolAction->setOn(false); 445 m_pEraseToolAction->setOn(false);
440} 446}
441 447
442void DrawPad::setEllipseTool() 448void DrawPad::setEllipseTool()
443{ 449{
444 if (m_pTool) { 450 if (m_pTool) {
445 delete m_pTool; 451 delete m_pTool;
446 } 452 }
447 453
448 m_pTool = new EllipseTool(this, m_pDrawPadCanvas); 454 m_pTool = new EllipseTool(this, m_pDrawPadCanvas);
449 455
450 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); 456 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet());
451 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); 457 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text());
452 458
453 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); 459 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
454 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); 460 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
455 461
456 m_pLineToolButton->setOn(false); 462 m_pLineToolButton->setOn(false);
457 m_pRectangleToolButton->setOn(false); 463 m_pRectangleToolButton->setOn(false);
458 m_pEllipseToolButton->setOn(true); 464 m_pEllipseToolButton->setOn(true);
459 m_pTextToolAction->setOn(false); 465 m_pTextToolAction->setOn(false);
460 m_pFillToolAction->setOn(false); 466 m_pFillToolAction->setOn(false);
461 m_pEraseToolAction->setOn(false); 467 m_pEraseToolAction->setOn(false);
462} 468}
463 469
464void DrawPad::setFilledEllipseTool() 470void DrawPad::setFilledEllipseTool()
465{ 471{
466 if (m_pTool) { 472 if (m_pTool) {
467 delete m_pTool; 473 delete m_pTool;
468 } 474 }
469 475
470 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); 476 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas);
471 477
472 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); 478 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet());
473 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); 479 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text());
474 480
475 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); 481 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
476 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); 482 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
477 483
478 m_pLineToolButton->setOn(false); 484 m_pLineToolButton->setOn(false);
479 m_pRectangleToolButton->setOn(false); 485 m_pRectangleToolButton->setOn(false);
480 m_pEllipseToolButton->setOn(true); 486 m_pEllipseToolButton->setOn(true);
481 m_pTextToolAction->setOn(false); 487 m_pTextToolAction->setOn(false);
482 m_pFillToolAction->setOn(false); 488 m_pFillToolAction->setOn(false);
483 m_pEraseToolAction->setOn(false); 489 m_pEraseToolAction->setOn(false);
484} 490}
485 491
486void DrawPad::setTextTool() 492void DrawPad::setTextTool()
487{ 493{
488 if (m_pTool) { 494 if (m_pTool) {
489 delete m_pTool; 495 delete m_pTool;
490 } 496 }
491 497
492 m_pTool = new TextTool(this, m_pDrawPadCanvas); 498 m_pTool = new TextTool(this, m_pDrawPadCanvas);
493 499
494 m_pLineToolButton->setOn(false); 500 m_pLineToolButton->setOn(false);
495 m_pRectangleToolButton->setOn(false); 501 m_pRectangleToolButton->setOn(false);
496 m_pEllipseToolButton->setOn(false); 502 m_pEllipseToolButton->setOn(false);
497 m_pTextToolAction->setOn(true); 503 m_pTextToolAction->setOn(true);
498 m_pFillToolAction->setOn(false); 504 m_pFillToolAction->setOn(false);
499 m_pEraseToolAction->setOn(false); 505 m_pEraseToolAction->setOn(false);
500} 506}
501 507
502void DrawPad::setFillTool() 508void DrawPad::setFillTool()
503{ 509{
504 if (m_pTool) { 510 if (m_pTool) {
505 delete m_pTool; 511 delete m_pTool;
506 } 512 }
507 513
508 m_pTool = new FillTool(this, m_pDrawPadCanvas); 514 m_pTool = new FillTool(this, m_pDrawPadCanvas);
509 515
510 m_pLineToolButton->setOn(false); 516 m_pLineToolButton->setOn(false);
511 m_pRectangleToolButton->setOn(false); 517 m_pRectangleToolButton->setOn(false);
512 m_pEllipseToolButton->setOn(false); 518 m_pEllipseToolButton->setOn(false);
513 m_pTextToolAction->setOn(false); 519 m_pTextToolAction->setOn(false);
514 m_pFillToolAction->setOn(true); 520 m_pFillToolAction->setOn(true);
515 m_pEraseToolAction->setOn(false); 521 m_pEraseToolAction->setOn(false);
516} 522}
517 523
518void DrawPad::setEraseTool() 524void DrawPad::setEraseTool()
519{ 525{
520 if (m_pTool) { 526 if (m_pTool) {
521 delete m_pTool; 527 delete m_pTool;
522 } 528 }
523 529
524 m_pTool = new EraseTool(this, m_pDrawPadCanvas); 530 m_pTool = new EraseTool(this, m_pDrawPadCanvas);
525 531
526 m_pLineToolButton->setOn(false); 532 m_pLineToolButton->setOn(false);
527 m_pRectangleToolButton->setOn(false); 533 m_pRectangleToolButton->setOn(false);
528 m_pEllipseToolButton->setOn(false); 534 m_pEllipseToolButton->setOn(false);
529 m_pTextToolAction->setOn(false); 535 m_pTextToolAction->setOn(false);
530 m_pFillToolAction->setOn(false); 536 m_pFillToolAction->setOn(false);
531 m_pEraseToolAction->setOn(true); 537 m_pEraseToolAction->setOn(true);
532} 538}
533 539
534void DrawPad::changePenWidth(int value) 540void DrawPad::changePenWidth(int value)
535{ 541{
536 m_pen.setWidth(value); 542 m_pen.setWidth(value);
537} 543}
538 544
539void DrawPad::changePenColor(const QColor& color) 545void DrawPad::changePenColor(const QColor& color)
540{ 546{
541 m_pen.setColor(color); 547 m_pen.setColor(color);
542 548
543 QPainter painter; 549 QPainter painter;
544 painter.begin(m_pPenColorToolButton->pixmap()); 550 painter.begin(m_pPenColorToolButton->pixmap());
545 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); 551 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
546 painter.end(); 552 painter.end();
547 553
548 m_pPenColorToolButton->popup()->hide(); 554 m_pPenColorToolButton->popup()->hide();
549} 555}
550 556
551void DrawPad::changeBrushColor(const QColor& color) 557void DrawPad::changeBrushColor(const QColor& color)
552{ 558{
553 m_brush = QBrush(color); 559 m_brush = QBrush(color);
554 560
555 QPainter painter; 561 QPainter painter;
556 painter.begin(m_pBrushColorToolButton->pixmap()); 562 painter.begin(m_pBrushColorToolButton->pixmap());
557 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); 563 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
558 painter.end(); 564 painter.end();
559 565
560 m_pBrushColorToolButton->popup()->hide(); 566 m_pBrushColorToolButton->popup()->hide();
561} 567}
562 568
563void DrawPad::updateView() 569void DrawPad::updateView()
564{ 570{
565 uint pagePosition = m_pDrawPadCanvas->pagePosition(); 571 uint pagePosition = m_pDrawPadCanvas->pagePosition();
566 uint pageCount = m_pDrawPadCanvas->pageCount(); 572 uint pageCount = m_pDrawPadCanvas->pageCount();
567 573
568 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); 574 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) );
569 575
570 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); 576 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled());
571 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); 577 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled());
572 578
573 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 579 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
574 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 580 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
575 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 581 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
576 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 582 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
577} 583}
578 584
579void DrawPad::deleteAll() 585void DrawPad::deleteAll()
580{ 586{
581 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), 587 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
582 QMessageBox::Information, QMessageBox::Yes, 588 QMessageBox::Information, QMessageBox::Yes,
583 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 589 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
584 QMessageBox::NoButton, this); 590 QMessageBox::NoButton, this);
585 591
586 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 592 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
587 messageBox.setButtonText(QMessageBox::No, tr("No")); 593 messageBox.setButtonText(QMessageBox::No, tr("No"));
588 594
589 if (messageBox.exec() == QMessageBox::Yes) { 595 if (messageBox.exec() == QMessageBox::Yes) {
590 m_pDrawPadCanvas->deleteAll(); 596 m_pDrawPadCanvas->deleteAll();
591 } 597 }
592} 598}
593 599
594void DrawPad::importPage() 600void DrawPad::importPage()
595{ 601{
596 ImportDialog importDialog(this); 602 ImportDialog importDialog(this);
597 603
598 importDialog.showMaximized(); 604 importDialog.showMaximized();
599 605
600 if (importDialog.exec() == QDialog::Accepted) { 606 if (importDialog.exec() == QDialog::Accepted) {
601 const DocLnk* docLnk = importDialog.selected(); 607 const DocLnk* docLnk = importDialog.selected();
602 608
603 if (docLnk) { 609 if (docLnk) {
604 m_pDrawPadCanvas->importPage(docLnk->file()); 610 m_pDrawPadCanvas->importPage(docLnk->file());
605 delete docLnk; 611 delete docLnk;
606 } 612 }
607 } 613 }
608} 614}
609 615
610void DrawPad::exportPage() 616void DrawPad::exportPage()
611{ 617{
612 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); 618 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
613 619
614 exportDialog.showMaximized(); 620 exportDialog.showMaximized();
615 621
616 if (exportDialog.exec() == QDialog::Accepted) { 622 if (exportDialog.exec() == QDialog::Accepted) {
617 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), 623 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
618 exportDialog.selectedName(), exportDialog.selectedFormat()); 624 exportDialog.selectedName(), exportDialog.selectedFormat());
619 } 625 }
620} 626}
621 627
622void DrawPad::thumbnailView() 628void DrawPad::thumbnailView()
623{ 629{
624 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); 630 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this);
625 631
626 thumbnailView.showMaximized(); 632 thumbnailView.showMaximized();
627 thumbnailView.exec(); 633 thumbnailView.exec();
628} 634}
629 635
630void DrawPad::pageInformation() 636void DrawPad::pageInformation()
631{ 637{
632 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); 638 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage());
633 639
634 if (pageInformationDialog.exec() == QDialog::Accepted) { 640 if (pageInformationDialog.exec() == QDialog::Accepted) {
635 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); 641 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle());
636 } 642 }
637} 643}
638 644
639void DrawPad::loadConfig() 645void DrawPad::loadConfig()
640{ 646{
641 Config config("drawpad"); 647 Config config("drawpad");
642 config.setGroup("General"); 648 config.setGroup("General");
643 649
644 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); 650 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false));
645 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); 651 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1));
646 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); 652 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name())));
647 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); 653 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name())));
648 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); 654 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1));
649} 655}
650 656
651void DrawPad::saveConfig() 657void DrawPad::saveConfig()
652{ 658{
653 Config config("drawpad"); 659 Config config("drawpad");
654 config.setGroup("General"); 660 config.setGroup("General");
655 661
656 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); 662 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
657 config.writeEntry("AntiAliasing", antiAliasing()); 663 config.writeEntry("AntiAliasing", antiAliasing());
658 config.writeEntry("PenWidth", (int)m_pen.width()); 664 config.writeEntry("PenWidth", (int)m_pen.width());
659 config.writeEntry("PenColor", m_pen.color().name()); 665 config.writeEntry("PenColor", m_pen.color().name());
660 config.writeEntry("BrushColor", m_brush.color().name()); 666 config.writeEntry("BrushColor", m_brush.color().name());
661} 667}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 7306228..2cae700 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -1,110 +1,111 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef DRAWPAD_H 14#ifndef DRAWPAD_H
15#define DRAWPAD_H 15#define DRAWPAD_H
16 16
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18 18
19#include <qpen.h> 19#include <qpen.h>
20 20
21class DrawPadCanvas; 21class DrawPadCanvas;
22class Tool; 22class Tool;
23 23
24class QAction; 24class QAction;
25class QColor; 25class QColor;
26class QSpinBox; 26class QSpinBox;
27class QToolButton; 27class QToolButton;
28class QWidgetStack; 28class QWidgetStack;
29 29
30class DrawPad : public QMainWindow 30class DrawPad : public QMainWindow
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33 33
34public: 34public:
35 DrawPad(QWidget* parent = 0, const char* name = 0); 35 DrawPad(QWidget* parent = 0, const char* name = 0);
36 ~DrawPad(); 36 ~DrawPad();
37 37
38 Tool* tool() { return m_pTool; } 38 Tool* tool() { return m_pTool; }
39 QPen pen() { return m_pen; } 39 QPen pen() { return m_pen; }
40 QBrush brush() { return m_brush; } 40 QBrush brush() { return m_brush; }
41 41
42 bool antiAliasing(); 42 bool antiAliasing();
43 void finishStartup();
43 44
44private slots: 45private slots:
45 void newPage(); 46 void newPage();
46 void clearPage(); 47 void clearPage();
47 void deletePage(); 48 void deletePage();
48 49
49 void setPointTool(); 50 void setPointTool();
50 void setLineTool(); 51 void setLineTool();
51 void setRectangleTool(); 52 void setRectangleTool();
52 void setFilledRectangleTool(); 53 void setFilledRectangleTool();
53 void setEllipseTool(); 54 void setEllipseTool();
54 void setFilledEllipseTool(); 55 void setFilledEllipseTool();
55 void setTextTool(); 56 void setTextTool();
56 void setFillTool(); 57 void setFillTool();
57 void setEraseTool(); 58 void setEraseTool();
58 59
59 void changePenWidth(int value); 60 void changePenWidth(int value);
60 void changePenColor(const QColor& color); 61 void changePenColor(const QColor& color);
61 void changeBrushColor(const QColor& color); 62 void changeBrushColor(const QColor& color);
62 63
63 void updateView(); 64 void updateView();
64 65
65 void deleteAll(); 66 void deleteAll();
66 void importPage(); 67 void importPage();
67 void exportPage(); 68 void exportPage();
68 void thumbnailView(); 69 void thumbnailView();
69 void pageInformation(); 70 void pageInformation();
70 71
71private: 72private:
72 void loadConfig(); 73 void loadConfig();
73 void saveConfig(); 74 void saveConfig();
74 75
75 DrawPadCanvas* m_pDrawPadCanvas; 76 DrawPadCanvas* m_pDrawPadCanvas;
76 77
77 Tool* m_pTool; 78 Tool* m_pTool;
78 QPen m_pen; 79 QPen m_pen;
79 QBrush m_brush; 80 QBrush m_brush;
80 81
81 QAction* m_pAntiAliasingAction; 82 QAction* m_pAntiAliasingAction;
82 83
83 QAction* m_pUndoAction; 84 QAction* m_pUndoAction;
84 QAction* m_pRedoAction; 85 QAction* m_pRedoAction;
85 86
86 QAction* m_pFirstPageAction; 87 QAction* m_pFirstPageAction;
87 QAction* m_pPreviousPageAction; 88 QAction* m_pPreviousPageAction;
88 QAction* m_pNextPageAction; 89 QAction* m_pNextPageAction;
89 QAction* m_pLastPageAction; 90 QAction* m_pLastPageAction;
90 91
91 QAction* m_pPointToolAction; 92 QAction* m_pPointToolAction;
92 QAction* m_pLineToolAction; 93 QAction* m_pLineToolAction;
93 QAction* m_pRectangleToolAction; 94 QAction* m_pRectangleToolAction;
94 QAction* m_pFilledRectangleToolAction; 95 QAction* m_pFilledRectangleToolAction;
95 QAction* m_pEllipseToolAction; 96 QAction* m_pEllipseToolAction;
96 QAction* m_pFilledEllipseToolAction; 97 QAction* m_pFilledEllipseToolAction;
97 QAction* m_pTextToolAction; 98 QAction* m_pTextToolAction;
98 QAction* m_pFillToolAction; 99 QAction* m_pFillToolAction;
99 QAction* m_pEraseToolAction; 100 QAction* m_pEraseToolAction;
100 101
101 QToolButton* m_pLineToolButton; 102 QToolButton* m_pLineToolButton;
102 QToolButton* m_pRectangleToolButton; 103 QToolButton* m_pRectangleToolButton;
103 QToolButton* m_pEllipseToolButton; 104 QToolButton* m_pEllipseToolButton;
104 QToolButton* m_pPenColorToolButton; 105 QToolButton* m_pPenColorToolButton;
105 QToolButton* m_pBrushColorToolButton; 106 QToolButton* m_pBrushColorToolButton;
106 107
107 QSpinBox* m_pPenWidthSpinBox; 108 QSpinBox* m_pPenWidthSpinBox;
108}; 109};
109 110
110#endif // DRAWPAD_H 111#endif // DRAWPAD_H
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 025bebb..dec498b 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -1,510 +1,522 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpadcanvas.h" 14#include "drawpadcanvas.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "page.h" 17#include "page.h"
18#include "tool.h" 18#include "tool.h"
19 19
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/filemanager.h> 21#include <qpe/filemanager.h>
22#include <qpe/mimetype.h> 22#include <qpe/mimetype.h>
23 23
24#include <qbuffer.h> 24#include <qbuffer.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qtextcodec.h> 27#include <qtextcodec.h>
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qxml.h> 29#include <qxml.h>
30 30
31class DrawPadCanvasXmlHandler: public QXmlDefaultHandler 31class DrawPadCanvasXmlHandler: public QXmlDefaultHandler
32{ 32{
33public: 33public:
34 DrawPadCanvasXmlHandler(); 34 DrawPadCanvasXmlHandler();
35 ~DrawPadCanvasXmlHandler(); 35 ~DrawPadCanvasXmlHandler();
36 36
37 QList<Page> pages(); 37 QList<Page> pages();
38 38
39 bool startElement(const QString& namespaceURI, const QString& localName, 39 bool startElement(const QString& namespaceURI, const QString& localName,
40 const QString& qName, const QXmlAttributes& atts); 40 const QString& qName, const QXmlAttributes& atts);
41 bool endElement(const QString& namespaceURI, const QString& localName, 41 bool endElement(const QString& namespaceURI, const QString& localName,
42 const QString& qName); 42 const QString& qName);
43 bool characters(const QString& ch); 43 bool characters(const QString& ch);
44 44
45private: 45private:
46 enum State { 46 enum State {
47 Unknown, 47 Unknown,
48 InTitle, 48 InTitle,
49 InDate, 49 InDate,
50 InData 50 InData
51 }; 51 };
52 52
53 State m_state; 53 State m_state;
54 QString m_title; 54 QString m_title;
55 QDateTime m_date; 55 QDateTime m_date;
56 ulong m_dataLenght; 56 ulong m_dataLenght;
57 QString m_dataFormat; 57 QString m_dataFormat;
58 QList<Page> m_pages; 58 QList<Page> m_pages;
59}; 59};
60 60
61DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() 61DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
62{ 62{
63 m_state = Unknown; 63 m_state = Unknown;
64} 64}
65 65
66DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() 66DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
67{ 67{
68} 68}
69 69
70QList<Page> DrawPadCanvasXmlHandler::pages() 70QList<Page> DrawPadCanvasXmlHandler::pages()
71{ 71{
72 return m_pages; 72 return m_pages;
73} 73}
74 74
75bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, 75bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
76 const QString& qName, const QXmlAttributes& atts) 76 const QString& qName, const QXmlAttributes& atts)
77{ 77{
78 Q_CONST_UNUSED(namespaceURI) 78 Q_CONST_UNUSED(namespaceURI)
79 Q_CONST_UNUSED(localName) 79 Q_CONST_UNUSED(localName)
80 80
81 if (qName == "image") { 81 if (qName == "image") {
82 m_title = QString(); 82 m_title = QString();
83 m_date = QDateTime::currentDateTime(); 83 m_date = QDateTime::currentDateTime();
84 } else if (qName == "title") { 84 } else if (qName == "title") {
85 m_state = InTitle; 85 m_state = InTitle;
86 } else if (qName == "date") { 86 } else if (qName == "date") {
87 m_state = InDate; 87 m_state = InDate;
88 } else if (qName == "data") { 88 } else if (qName == "data") {
89 m_state = InData; 89 m_state = InData;
90 m_dataLenght = atts.value("length").toULong(); 90 m_dataLenght = atts.value("length").toULong();
91 m_dataFormat = atts.value("format"); 91 m_dataFormat = atts.value("format");
92 } 92 }
93 93
94 return true; 94 return true;
95} 95}
96 96
97bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, 97bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName,
98 const QString& qName) 98 const QString& qName)
99{ 99{
100 Q_CONST_UNUSED(namespaceURI) 100 Q_CONST_UNUSED(namespaceURI)
101 Q_CONST_UNUSED(localName) 101 Q_CONST_UNUSED(localName)
102 102
103 if (qName == "title") { 103 if (qName == "title") {
104 m_state = Unknown; 104 m_state = Unknown;
105 } else if (qName == "date") { 105 } else if (qName == "date") {
106 m_state = Unknown; 106 m_state = Unknown;
107 } else if (qName == "data") { 107 } else if (qName == "data") {
108 m_state = Unknown; 108 m_state = Unknown;
109 } 109 }
110 110
111 return true; 111 return true;
112} 112}
113 113
114bool DrawPadCanvasXmlHandler::characters(const QString& ch) 114bool DrawPadCanvasXmlHandler::characters(const QString& ch)
115{ 115{
116 if (m_state == InTitle) { 116 if (m_state == InTitle) {
117 m_title = ch; 117 m_title = ch;
118 } else if (m_state == InDate) { 118 } else if (m_state == InDate) {
119 m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); 119 m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt());
120 } else if (m_state == InData) { 120 } else if (m_state == InData) {
121 QByteArray byteArray(ch.length() / 2); 121 QByteArray byteArray(ch.length() / 2);
122 122
123 for (int i = 0; i < (int)ch.length() / 2; i++) { 123 for (int i = 0; i < (int)ch.length() / 2; i++) {
124 char h = ch[2 * i].latin1(); 124 char h = ch[2 * i].latin1();
125 char l = ch[2 * i + 1].latin1(); 125 char l = ch[2 * i + 1].latin1();
126 uchar r = 0; 126 uchar r = 0;
127 127
128 if (h <= '9') { 128 if (h <= '9') {
129 r += h - '0'; 129 r += h - '0';
130 } else { 130 } else {
131 r += h - 'a' + 10; 131 r += h - 'a' + 10;
132 } 132 }
133 133
134 r = r << 4; 134 r = r << 4;
135 135
136 if (l <= '9') { 136 if (l <= '9') {
137 r += l - '0'; 137 r += l - '0';
138 } else { 138 } else {
139 r += l - 'a' + 10; 139 r += l - 'a' + 10;
140 } 140 }
141 141
142 byteArray[i] = r; 142 byteArray[i] = r;
143 } 143 }
144 144
145 QImage image; 145 QImage image;
146 image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); 146 image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat);
147 147
148 Page* page = new Page(m_title, image.width(), image.height()); 148 Page* page = new Page(m_title, image.width(), image.height());
149 page->setLastModified(m_date); 149 page->setLastModified(m_date);
150 page->pixmap()->convertFromImage(image); 150 page->pixmap()->convertFromImage(image);
151 m_pages.append(page); 151 m_pages.append(page);
152 } 152 }
153 153
154 return true; 154 return true;
155} 155}
156 156
157DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) 157DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
158 : QScrollView(parent, name) 158 : QScrollView(parent, name)
159{ 159{
160 m_pDrawPad = drawPad; 160 m_pDrawPad = drawPad;
161 m_pages.setAutoDelete(true); 161 m_pages.setAutoDelete(true);
162 162
163 viewport()->setBackgroundMode(QWidget::NoBackground); 163 viewport()->setBackgroundMode(QWidget::NoBackground);
164} 164}
165 165
166DrawPadCanvas::~DrawPadCanvas() 166DrawPadCanvas::~DrawPadCanvas()
167{ 167{
168} 168}
169 169
170void DrawPadCanvas::load(QIODevice* ioDevice) 170void DrawPadCanvas::load(QIODevice* ioDevice)
171{ 171{
172 QTextStream textStream(ioDevice); 172 QTextStream textStream(ioDevice);
173 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 173 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
174 174
175 QXmlInputSource xmlInputSource(textStream); 175 QXmlInputSource xmlInputSource(textStream);
176 QXmlSimpleReader xmlSimpleReader; 176 QXmlSimpleReader xmlSimpleReader;
177 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; 177 DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
178 178
179 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); 179 xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
180 xmlSimpleReader.parse(xmlInputSource); 180 xmlSimpleReader.parse(xmlInputSource);
181 181
182 m_pages = drawPadCanvasXmlHandler.pages(); 182 m_pages = drawPadCanvasXmlHandler.pages();
183 183
184 if (m_pages.isEmpty()) { 184 if (m_pages.isEmpty()) {
185 m_pages.append(new Page("", contentsRect().size())); 185 m_pages.append(new Page("",
186 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
187 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
186 m_pages.current()->pixmap()->fill(Qt::white); 188 m_pages.current()->pixmap()->fill(Qt::white);
187 } 189 }
188 190
189 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 191 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
190 viewport()->update(); 192 viewport()->update();
191 193
192 emit pagesChanged(); 194 emit pagesChanged();
193} 195}
194 196
195void DrawPadCanvas::initialPage() 197void DrawPadCanvas::initialPage()
196{ 198{
197 m_pages.append(new Page("", 236, 232)); 199 m_pages.append(new Page("",
200 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
201 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
202 //236, 232)); no more fixed sizes
203
198 m_pages.current()->pixmap()->fill(Qt::white); 204 m_pages.current()->pixmap()->fill(Qt::white);
199 205
200 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 206 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
201 viewport()->update(); 207 viewport()->update();
202 208
203 emit pagesChanged(); 209 emit pagesChanged();
204} 210}
205 211
206void DrawPadCanvas::save(QIODevice* ioDevice) 212void DrawPadCanvas::save(QIODevice* ioDevice)
207{ 213{
208 QTextStream textStream(ioDevice); 214 QTextStream textStream(ioDevice);
209 textStream.setCodec(QTextCodec::codecForName("UTF-8")); 215 textStream.setCodec(QTextCodec::codecForName("UTF-8"));
210 216
211 textStream << "<drawpad>" << endl; 217 textStream << "<drawpad>" << endl;
212 textStream << " <images>" << endl; 218 textStream << " <images>" << endl;
213 219
214 QListIterator<Page> bufferIterator(m_pages); 220 QListIterator<Page> bufferIterator(m_pages);
215 221
216 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { 222 for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
217 textStream << " <image>" << endl; 223 textStream << " <image>" << endl;
218 textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; 224 textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl;
219 225
220 int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); 226 int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified());
221 textStream << " <date>" << intDate << "</date>" << endl; 227 textStream << " <date>" << intDate << "</date>" << endl;
222 228
223 QImage image = bufferIterator.current()->pixmap()->convertToImage(); 229 QImage image = bufferIterator.current()->pixmap()->convertToImage();
224 QByteArray byteArray; 230 QByteArray byteArray;
225 QBuffer buffer(byteArray); 231 QBuffer buffer(byteArray);
226 QImageIO imageIO(&buffer, "PNG"); 232 QImageIO imageIO(&buffer, "PNG");
227 233
228 buffer.open(IO_WriteOnly); 234 buffer.open(IO_WriteOnly);
229 imageIO.setImage(image); 235 imageIO.setImage(image);
230 imageIO.write(); 236 imageIO.write();
231 buffer.close(); 237 buffer.close();
232 238
233 textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; 239 textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">";
234 240
235 static const char hexchars[] = "0123456789abcdef"; 241 static const char hexchars[] = "0123456789abcdef";
236 242
237 for (int i = 0; i < (int)byteArray.size(); i++ ) { 243 for (int i = 0; i < (int)byteArray.size(); i++ ) {
238 uchar s = (uchar)byteArray[i]; 244 uchar s = (uchar)byteArray[i];
239 textStream << hexchars[s >> 4]; 245 textStream << hexchars[s >> 4];
240 textStream << hexchars[s & 0x0f]; 246 textStream << hexchars[s & 0x0f];
241 } 247 }
242 248
243 textStream << "</data>" << endl; 249 textStream << "</data>" << endl;
244 textStream << " </image>" << endl; 250 textStream << " </image>" << endl;
245 } 251 }
246 252
247 textStream << " </images>" << endl; 253 textStream << " </images>" << endl;
248 textStream << "</drawpad>"; 254 textStream << "</drawpad>";
249} 255}
250 256
251void DrawPadCanvas::importPage(const QString& fileName) 257void DrawPadCanvas::importPage(const QString& fileName)
252{ 258{
253 Page* importedPage = new Page(); 259 Page* importedPage = new Page();
254 260
255 importedPage->pixmap()->load(fileName); 261 importedPage->pixmap()->load(fileName);
256 m_pages.insert(m_pages.at() + 1, importedPage); 262 m_pages.insert(m_pages.at() + 1, importedPage);
257 263
258 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 264 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
259 viewport()->update(); 265 viewport()->update();
260 266
261 emit pagesChanged(); 267 emit pagesChanged();
262} 268}
263 269
264void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) 270void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
265{ 271{
266 if (fromPage == toPage) { 272 if (fromPage == toPage) {
267 DocLnk docLnk; 273 DocLnk docLnk;
268 MimeType mimeType(format); 274 MimeType mimeType(format);
269 275
270 docLnk.setName(name); 276 docLnk.setName(name);
271 docLnk.setType(mimeType.id()); 277 docLnk.setType(mimeType.id());
272 278
273 FileManager fileManager; 279 FileManager fileManager;
274 QIODevice* ioDevice = fileManager.saveFile(docLnk); 280 QIODevice* ioDevice = fileManager.saveFile(docLnk);
275 QImageIO imageIO(ioDevice, format); 281 QImageIO imageIO(ioDevice, format);
276 282
277 QImage image = m_pages.current()->pixmap()->convertToImage(); 283 QImage image = m_pages.current()->pixmap()->convertToImage();
278 imageIO.setImage(image); 284 imageIO.setImage(image);
279 imageIO.write(); 285 imageIO.write();
280 delete ioDevice; 286 delete ioDevice;
281 } else { 287 } else {
282 for (uint i = fromPage; i <= toPage; i++) { 288 for (uint i = fromPage; i <= toPage; i++) {
283 DocLnk docLnk; 289 DocLnk docLnk;
284 MimeType mimeType(format); 290 MimeType mimeType(format);
285 291
286 docLnk.setName(name + QString::number(i)); 292 docLnk.setName(name + QString::number(i));
287 docLnk.setType(mimeType.id()); 293 docLnk.setType(mimeType.id());
288 294
289 FileManager fileManager; 295 FileManager fileManager;
290 QIODevice* ioDevice = fileManager.saveFile(docLnk); 296 QIODevice* ioDevice = fileManager.saveFile(docLnk);
291 QImageIO imageIO(ioDevice, format); 297 QImageIO imageIO(ioDevice, format);
292 298
293 QImage image = m_pages.at(i - 1)->pixmap()->convertToImage(); 299 QImage image = m_pages.at(i - 1)->pixmap()->convertToImage();
294 imageIO.setImage(image); 300 imageIO.setImage(image);
295 imageIO.write(); 301 imageIO.write();
296 delete ioDevice; 302 delete ioDevice;
297 } 303 }
298 } 304 }
299} 305}
300 306
301Page* DrawPadCanvas::currentPage() 307Page* DrawPadCanvas::currentPage()
302{ 308{
303 return m_pages.current(); 309 return m_pages.current();
304} 310}
305 311
306QList<Page> DrawPadCanvas::pages() 312QList<Page> DrawPadCanvas::pages()
307{ 313{
308 return m_pages; 314 return m_pages;
309} 315}
310 316
311uint DrawPadCanvas::pagePosition() 317uint DrawPadCanvas::pagePosition()
312{ 318{
313 return (m_pages.at() + 1); 319 return (m_pages.at() + 1);
314} 320}
315 321
316uint DrawPadCanvas::pageCount() 322uint DrawPadCanvas::pageCount()
317{ 323{
318 return m_pages.count(); 324 return m_pages.count();
319} 325}
320 326
321void DrawPadCanvas::selectPage(Page* page) 327void DrawPadCanvas::selectPage(Page* page)
322{ 328{
323 m_pages.findRef(page); 329 m_pages.findRef(page);
324 330
325 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 331 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
326 viewport()->update(); 332 viewport()->update();
327 333
328 emit pagesChanged(); 334 emit pagesChanged();
329} 335}
330 336
331void DrawPadCanvas::backupPage() 337void DrawPadCanvas::backupPage()
332{ 338{
333 m_pages.current()->backup(); 339 m_pages.current()->backup();
334 340
335 emit pagesChanged(); 341 emit pagesChanged();
336} 342}
337 343
338void DrawPadCanvas::selectPage(uint pagePosition) 344void DrawPadCanvas::selectPage(uint pagePosition)
339{ 345{
340 m_pages.at(pagePosition - 1); 346 m_pages.at(pagePosition - 1);
341 347
342 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 348 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
343 viewport()->update(); 349 viewport()->update();
344 350
345 emit pagesChanged(); 351 emit pagesChanged();
346} 352}
347 353
348void DrawPadCanvas::deleteAll() 354void DrawPadCanvas::deleteAll()
349{ 355{
350 m_pages.clear(); 356 m_pages.clear();
351 357
352 m_pages.append(new Page("", contentsRect().size())); 358 m_pages.append(new Page("",
359 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
360 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
361
353 m_pages.current()->pixmap()->fill(Qt::white); 362 m_pages.current()->pixmap()->fill(Qt::white);
354 363
355 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 364 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
356 viewport()->update(); 365 viewport()->update();
357 366
358 emit pagesChanged(); 367 emit pagesChanged();
359} 368}
360 369
361void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) 370void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
362{ 371{
363 m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); 372 m_pages.insert(m_pages.at() + 1, new Page(title, width, height));
364 m_pages.current()->pixmap()->fill(color); 373 m_pages.current()->pixmap()->fill(color);
365 374
366 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 375 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
367 viewport()->update(); 376 viewport()->update();
368 377
369 emit pagesChanged(); 378 emit pagesChanged();
370} 379}
371 380
372void DrawPadCanvas::clearPage() 381void DrawPadCanvas::clearPage()
373{ 382{
374 m_pages.current()->pixmap()->fill(Qt::white); 383 m_pages.current()->pixmap()->fill(Qt::white);
375 384
376 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 385 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
377 viewport()->update(); 386 viewport()->update();
378} 387}
379 388
380void DrawPadCanvas::deletePage() 389void DrawPadCanvas::deletePage()
381{ 390{
382 m_pages.remove(m_pages.current()); 391 m_pages.remove(m_pages.current());
383 392
384 if (m_pages.isEmpty()) { 393 if (m_pages.isEmpty()) {
385 m_pages.append(new Page("", contentsRect().size())); 394 m_pages.append(new Page("",
395 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
396 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
397
386 m_pages.current()->pixmap()->fill(Qt::white); 398 m_pages.current()->pixmap()->fill(Qt::white);
387 } 399 }
388 400
389 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 401 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
390 viewport()->update(); 402 viewport()->update();
391 403
392 emit pagesChanged(); 404 emit pagesChanged();
393} 405}
394 406
395void DrawPadCanvas::movePageUp() 407void DrawPadCanvas::movePageUp()
396{ 408{
397 int index = m_pages.at(); 409 int index = m_pages.at();
398 Page* page = m_pages.take(); 410 Page* page = m_pages.take();
399 m_pages.insert(index - 1, page); 411 m_pages.insert(index - 1, page);
400 412
401 emit pagesChanged(); 413 emit pagesChanged();
402} 414}
403 415
404void DrawPadCanvas::movePageDown() 416void DrawPadCanvas::movePageDown()
405{ 417{
406 int index = m_pages.at(); 418 int index = m_pages.at();
407 Page* page = m_pages.take(); 419 Page* page = m_pages.take();
408 m_pages.insert(index + 1, page); 420 m_pages.insert(index + 1, page);
409 421
410 emit pagesChanged(); 422 emit pagesChanged();
411} 423}
412 424
413bool DrawPadCanvas::goPreviousPageEnabled() 425bool DrawPadCanvas::goPreviousPageEnabled()
414{ 426{
415 return (m_pages.current() != m_pages.getFirst()); 427 return (m_pages.current() != m_pages.getFirst());
416} 428}
417 429
418bool DrawPadCanvas::goNextPageEnabled() 430bool DrawPadCanvas::goNextPageEnabled()
419{ 431{
420 return (m_pages.current() != m_pages.getLast()); 432 return (m_pages.current() != m_pages.getLast());
421} 433}
422 434
423void DrawPadCanvas::undo() 435void DrawPadCanvas::undo()
424{ 436{
425 m_pages.current()->undo(); 437 m_pages.current()->undo();
426 438
427 viewport()->update(); 439 viewport()->update();
428 440
429 emit pagesChanged(); 441 emit pagesChanged();
430} 442}
431 443
432void DrawPadCanvas::redo() 444void DrawPadCanvas::redo()
433{ 445{
434 m_pages.current()->redo(); 446 m_pages.current()->redo();
435 447
436 viewport()->update(); 448 viewport()->update();
437 449
438 emit pagesChanged(); 450 emit pagesChanged();
439} 451}
440 452
441void DrawPadCanvas::goFirstPage() 453void DrawPadCanvas::goFirstPage()
442{ 454{
443 m_pages.first(); 455 m_pages.first();
444 456
445 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 457 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
446 viewport()->update(); 458 viewport()->update();
447 459
448 emit pagesChanged(); 460 emit pagesChanged();
449} 461}
450 462
451void DrawPadCanvas::goPreviousPage() 463void DrawPadCanvas::goPreviousPage()
452{ 464{
453 m_pages.prev(); 465 m_pages.prev();
454 466
455 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 467 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
456 viewport()->update(); 468 viewport()->update();
457 469
458 emit pagesChanged(); 470 emit pagesChanged();
459} 471}
460 472
461void DrawPadCanvas::goNextPage() 473void DrawPadCanvas::goNextPage()
462{ 474{
463 m_pages.next(); 475 m_pages.next();
464 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 476 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
465 viewport()->update(); 477 viewport()->update();
466 478
467 emit pagesChanged(); 479 emit pagesChanged();
468} 480}
469 481
470void DrawPadCanvas::goLastPage() 482void DrawPadCanvas::goLastPage()
471{ 483{
472 m_pages.last(); 484 m_pages.last();
473 485
474 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 486 resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
475 viewport()->update(); 487 viewport()->update();
476 488
477 emit pagesChanged(); 489 emit pagesChanged();
478} 490}
479 491
480void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) 492void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e)
481{ 493{
482 m_pDrawPad->tool()->mousePressEvent(e); 494 m_pDrawPad->tool()->mousePressEvent(e);
483} 495}
484 496
485void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) 497void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
486{ 498{
487 m_pDrawPad->tool()->mouseReleaseEvent(e); 499 m_pDrawPad->tool()->mouseReleaseEvent(e);
488} 500}
489 501
490void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) 502void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
491{ 503{
492 m_pDrawPad->tool()->mouseMoveEvent(e); 504 m_pDrawPad->tool()->mouseMoveEvent(e);
493} 505}
494 506
495void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 507void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
496{ 508{
497 QRect clipRect(cx, cy, cw, ch); 509 QRect clipRect(cx, cy, cw, ch);
498 QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); 510 QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
499 QRect drawRect = pixmapRect.intersect(clipRect); 511 QRect drawRect = pixmapRect.intersect(clipRect);
500 512
501 p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); 513 p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect);
502 514
503 if (drawRect.right() < clipRect.right()) { 515 if (drawRect.right() < clipRect.right()) {
504 p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); 516 p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark());
505 } 517 }
506 518
507 if (drawRect.bottom() < clipRect.bottom()) { 519 if (drawRect.bottom() < clipRect.bottom()) {
508 p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); 520 p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark());
509 } 521 }
510} 522}
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp
index 5b11c0e..adbd612 100644
--- a/noncore/graphics/drawpad/exportdialog.cpp
+++ b/noncore/graphics/drawpad/exportdialog.cpp
@@ -1,173 +1,176 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "exportdialog.h" 14#include "exportdialog.h"
15 15
16#include <qpe/fileselector.h> 16#include <opie/ofileselector.h>
17 17
18#include <qbuttongroup.h> 18#include <qbuttongroup.h>
19#include <qcombobox.h> 19#include <qcombobox.h>
20#include <qgroupbox.h> 20#include <qgroupbox.h>
21#include <qimage.h> 21#include <qimage.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qradiobutton.h> 25#include <qradiobutton.h>
26#include <qspinbox.h> 26#include <qspinbox.h>
27 27
28#include <stdlib.h> 28#include <stdlib.h>
29 29
30ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name) 30ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
31 : QDialog(parent, name, true) 31 : QDialog(parent, name, true)
32{ 32{
33 setCaption(tr("DrawPad - Export")); 33 setCaption(tr("DrawPad - Export"));
34 34
35 m_pageAt = pageAt; 35 m_pageAt = pageAt;
36 m_pageCount = pageCount; 36 m_pageCount = pageCount;
37 37
38 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this); 38 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
39 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int))); 39 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
40 40
41 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup); 41 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
42 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup); 42 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
43 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup); 43 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
44 44
45 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup); 45 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
46 46
47 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); 47 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
48 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int))); 48 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
49 49
50 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); 50 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
51 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int))); 51 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
52 52
53 selectionButtonGroup->setButton(1); 53 selectionButtonGroup->setButton(1);
54 selectionChanged(1); 54 selectionChanged(1);
55 55
56 m_pFromPageSpinBox->setValue(pageAt); 56 m_pFromPageSpinBox->setValue(pageAt);
57 m_pToPageSpinBox->setValue(pageAt); 57 m_pToPageSpinBox->setValue(pageAt);
58 58
59 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this); 59 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
60 60
61 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox); 61 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
62 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox); 62 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
63 63
64 m_pNameLineEdit = new QLineEdit(exportGroupBox); 64 m_pNameLineEdit = new QLineEdit(exportGroupBox);
65 65
66 m_pFormatComboBox = new QComboBox(exportGroupBox); 66 m_pFormatComboBox = new QComboBox(exportGroupBox);
67 m_pFormatComboBox->insertStrList(QImageIO::outputFormats()); 67 m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
68 68
69 FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector"); 69 MimeTypes types; types.insert( tr("All Images"), "image/*" );
70 fileSelector->setNewVisible(false); 70 OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector,
71 fileSelector->setCloseVisible(false); 71 OFileSelector::Normal,
72 QString::null, QString::null,
73 types );
74 fileSelector->setNameVisible( false );
72 75
73 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 76 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
74 selectionButtonGroup->layout()->setSpacing(4); 77 selectionButtonGroup->layout()->setSpacing(4);
75 exportGroupBox->layout()->setSpacing(4); 78 exportGroupBox->layout()->setSpacing(4);
76 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2); 79 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
77 QHBoxLayout* rangeLayout = new QHBoxLayout(); 80 QHBoxLayout* rangeLayout = new QHBoxLayout();
78 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2); 81 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
79 82
80 selectionLayout->addWidget(selectAllRadioButton, 0, 0); 83 selectionLayout->addWidget(selectAllRadioButton, 0, 0);
81 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0); 84 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
82 selectionLayout->addWidget(selectRangeRadioButton, 0, 1); 85 selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
83 selectionLayout->addLayout(rangeLayout, 1, 1); 86 selectionLayout->addLayout(rangeLayout, 1, 1);
84 87
85 rangeLayout->addWidget(m_pFromPageSpinBox); 88 rangeLayout->addWidget(m_pFromPageSpinBox);
86 rangeLayout->addWidget(toLabel); 89 rangeLayout->addWidget(toLabel);
87 rangeLayout->addWidget(m_pToPageSpinBox); 90 rangeLayout->addWidget(m_pToPageSpinBox);
88 91
89 exportLayout->addWidget(nameLabel, 0, 0); 92 exportLayout->addWidget(nameLabel, 0, 0);
90 exportLayout->addWidget(formatLabel, 1, 0); 93 exportLayout->addWidget(formatLabel, 1, 0);
91 94
92 exportLayout->addWidget(m_pNameLineEdit, 0, 1); 95 exportLayout->addWidget(m_pNameLineEdit, 0, 1);
93 exportLayout->addWidget(m_pFormatComboBox, 1, 1); 96 exportLayout->addWidget(m_pFormatComboBox, 1, 1);
94 97
95 exportLayout->setColStretch(1, 1); 98 exportLayout->setColStretch(1, 1);
96 99
97 mainLayout->addWidget(selectionButtonGroup); 100 mainLayout->addWidget(selectionButtonGroup);
98 mainLayout->addWidget(exportGroupBox); 101 mainLayout->addWidget(exportGroupBox);
99 mainLayout->addWidget(fileSelector); 102 mainLayout->addWidget(fileSelector);
100 103
101 m_pNameLineEdit->setFocus(); 104 m_pNameLineEdit->setFocus();
102} 105}
103 106
104ExportDialog::~ExportDialog() 107ExportDialog::~ExportDialog()
105{ 108{
106} 109}
107 110
108uint ExportDialog::selectedFromPage() 111uint ExportDialog::selectedFromPage()
109{ 112{
110 return (m_pFromPageSpinBox->value()); 113 return (m_pFromPageSpinBox->value());
111} 114}
112 115
113uint ExportDialog::selectedToPage() 116uint ExportDialog::selectedToPage()
114{ 117{
115 return (m_pToPageSpinBox->value()); 118 return (m_pToPageSpinBox->value());
116} 119}
117 120
118QString ExportDialog::selectedName() 121QString ExportDialog::selectedName()
119{ 122{
120 return (m_pNameLineEdit->text()); 123 return (m_pNameLineEdit->text());
121} 124}
122 125
123QString ExportDialog::selectedFormat() 126QString ExportDialog::selectedFormat()
124{ 127{
125 return (m_pFormatComboBox->currentText()); 128 return (m_pFormatComboBox->currentText());
126} 129}
127 130
128void ExportDialog::accept() 131void ExportDialog::accept()
129{ 132{
130 if (!(m_pNameLineEdit->text().isEmpty())) { 133 if (!(m_pNameLineEdit->text().isEmpty())) {
131 QDialog::accept(); 134 QDialog::accept();
132 } 135 }
133} 136}
134 137
135void ExportDialog::selectionChanged(int id) 138void ExportDialog::selectionChanged(int id)
136{ 139{
137 switch (id) { 140 switch (id) {
138 case 0: 141 case 0:
139 m_pFromPageSpinBox->setValue(1); 142 m_pFromPageSpinBox->setValue(1);
140 m_pToPageSpinBox->setValue(m_pageCount); 143 m_pToPageSpinBox->setValue(m_pageCount);
141 144
142 m_pFromPageSpinBox->setEnabled(false); 145 m_pFromPageSpinBox->setEnabled(false);
143 m_pToPageSpinBox->setEnabled(false); 146 m_pToPageSpinBox->setEnabled(false);
144 break; 147 break;
145 case 1: 148 case 1:
146 m_pFromPageSpinBox->setValue(m_pageAt); 149 m_pFromPageSpinBox->setValue(m_pageAt);
147 m_pToPageSpinBox->setValue(m_pageAt); 150 m_pToPageSpinBox->setValue(m_pageAt);
148 151
149 m_pFromPageSpinBox->setEnabled(false); 152 m_pFromPageSpinBox->setEnabled(false);
150 m_pToPageSpinBox->setEnabled(false); 153 m_pToPageSpinBox->setEnabled(false);
151 break; 154 break;
152 case 2: 155 case 2:
153 m_pFromPageSpinBox->setEnabled(true); 156 m_pFromPageSpinBox->setEnabled(true);
154 m_pToPageSpinBox->setEnabled(true); 157 m_pToPageSpinBox->setEnabled(true);
155 break; 158 break;
156 default: 159 default:
157 break; 160 break;
158 } 161 }
159} 162}
160 163
161void ExportDialog::fromPageChanged(int value) 164void ExportDialog::fromPageChanged(int value)
162{ 165{
163 if (m_pToPageSpinBox->value() < value) { 166 if (m_pToPageSpinBox->value() < value) {
164 m_pToPageSpinBox->setValue(value); 167 m_pToPageSpinBox->setValue(value);
165 } 168 }
166} 169}
167 170
168void ExportDialog::toPageChanged(int value) 171void ExportDialog::toPageChanged(int value)
169{ 172{
170 if (m_pFromPageSpinBox->value() > value) { 173 if (m_pFromPageSpinBox->value() > value) {
171 m_pFromPageSpinBox->setValue(value); 174 m_pFromPageSpinBox->setValue(value);
172 } 175 }
173} 176}
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp
index 1c447cb..9a59a20 100644
--- a/noncore/graphics/drawpad/importdialog.cpp
+++ b/noncore/graphics/drawpad/importdialog.cpp
@@ -1,113 +1,117 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "importdialog.h" 14#include "importdialog.h"
15 15
16#include <qpe/applnk.h> 16#include <qpe/applnk.h>
17#include <qpe/fileselector.h> 17#include <opie/ofileselector.h>
18 18
19#include <qcheckbox.h> 19#include <qcheckbox.h>
20#include <qimage.h> 20#include <qimage.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24 24
25ImportDialog::ImportDialog(QWidget* parent, const char* name) 25ImportDialog::ImportDialog(QWidget* parent, const char* name)
26 : QDialog(parent, name, true) 26 : QDialog(parent, name, true)
27{ 27{
28 setCaption(tr("DrawPad - Import")); 28 setCaption(tr("DrawPad - Import"));
29 29
30 m_pFileSelector = new FileSelector("image/*", this, "fileselector"); 30 MimeTypes types; types.insert( tr("All images"),"image/*" );
31 m_pFileSelector = new OFileSelector(this,
32 OFileSelector::FileSelector,
33 OFileSelector::Normal,
34 QString::null,
35 QString::null, types );
36 m_pFileSelector->setNameVisible( false );
31 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged())); 37 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged()));
32 m_pFileSelector->setNewVisible(false);
33 m_pFileSelector->setCloseVisible(false);
34 38
35 m_pPreviewLabel = new QLabel(this); 39 m_pPreviewLabel = new QLabel(this);
36 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); 40 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
37 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 41 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
38 m_pPreviewLabel->setFixedSize(114, 114); 42 m_pPreviewLabel->setFixedSize(114, 114);
39 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid); 43 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid);
40 44
41 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this); 45 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this);
42 m_pAutomaticPreviewCheckBox->setChecked(true); 46 m_pAutomaticPreviewCheckBox->setChecked(true);
43 47
44 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this); 48 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this);
45 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview())); 49 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview()));
46 50
47 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 51 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
48 QHBoxLayout* previewLayout = new QHBoxLayout(4); 52 QHBoxLayout* previewLayout = new QHBoxLayout(4);
49 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4); 53 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4);
50 54
51 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox); 55 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox);
52 previewSecondLayout->addWidget(previewPushButton); 56 previewSecondLayout->addWidget(previewPushButton);
53 previewSecondLayout->addStretch(); 57 previewSecondLayout->addStretch();
54 58
55 previewLayout->addWidget(m_pPreviewLabel); 59 previewLayout->addWidget(m_pPreviewLabel);
56 previewLayout->addLayout(previewSecondLayout); 60 previewLayout->addLayout(previewSecondLayout);
57 61
58 mainLayout->addWidget(m_pFileSelector); 62 mainLayout->addWidget(m_pFileSelector);
59 mainLayout->addLayout(previewLayout); 63 mainLayout->addLayout(previewLayout);
60 64
61 preview(); 65 preview();
62} 66}
63 67
64ImportDialog::~ImportDialog() 68ImportDialog::~ImportDialog()
65{ 69{
66} 70}
67 71
68const DocLnk* ImportDialog::selected() 72const DocLnk* ImportDialog::selected()
69{ 73{
70 // FIXME change from pointer to reference -zecke 74 // FIXME change from pointer to reference -zecke
71 DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() ); 75 DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() );
72 return lnk; 76 return lnk;
73} 77}
74 78
75void ImportDialog::fileChanged() 79void ImportDialog::fileChanged()
76{ 80{
77 if (m_pAutomaticPreviewCheckBox->isChecked()) { 81 if (m_pAutomaticPreviewCheckBox->isChecked()) {
78 preview(); 82 preview();
79 } 83 }
80} 84}
81 85
82void ImportDialog::preview() 86void ImportDialog::preview()
83{ 87{
84 const DocLnk* docLnk = selected(); 88 const DocLnk* docLnk = selected();
85 89
86 if (docLnk) { 90 if (docLnk) {
87 QImage image(docLnk->file()); 91 QImage image(docLnk->file());
88 92
89 int previewWidth = m_pPreviewLabel->contentsRect().width(); 93 int previewWidth = m_pPreviewLabel->contentsRect().width();
90 int previewHeight = m_pPreviewLabel->contentsRect().height(); 94 int previewHeight = m_pPreviewLabel->contentsRect().height();
91 95
92 float widthScale = 1.0; 96 float widthScale = 1.0;
93 float heightScale = 1.0; 97 float heightScale = 1.0;
94 98
95 if (previewWidth < image.width()) { 99 if (previewWidth < image.width()) {
96 widthScale = (float)previewWidth / float(image.width()); 100 widthScale = (float)previewWidth / float(image.width());
97 } 101 }
98 102
99 if (previewHeight < image.height()) { 103 if (previewHeight < image.height()) {
100 heightScale = (float)previewHeight / float(image.height()); 104 heightScale = (float)previewHeight / float(image.height());
101 } 105 }
102 106
103 float scale = (widthScale < heightScale ? widthScale : heightScale); 107 float scale = (widthScale < heightScale ? widthScale : heightScale);
104 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); 108 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
105 109
106 QPixmap previewPixmap; 110 QPixmap previewPixmap;
107 previewPixmap.convertFromImage(previewImage); 111 previewPixmap.convertFromImage(previewImage);
108 112
109 m_pPreviewLabel->setPixmap(previewPixmap); 113 m_pPreviewLabel->setPixmap(previewPixmap);
110 114
111 delete docLnk; 115 delete docLnk;
112 } 116 }
113} 117}
diff --git a/noncore/graphics/drawpad/importdialog.h b/noncore/graphics/drawpad/importdialog.h
index ef51d7c..ed655a5 100644
--- a/noncore/graphics/drawpad/importdialog.h
+++ b/noncore/graphics/drawpad/importdialog.h
@@ -1,45 +1,45 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef IMPORTDIALOG_H 14#ifndef IMPORTDIALOG_H
15#define IMPORTDIALOG_H 15#define IMPORTDIALOG_H
16 16
17#include <qdialog.h> 17#include <qdialog.h>
18 18
19class DocLnk; 19class DocLnk;
20class FileSelector; 20class OFileSelector;
21 21
22class QCheckBox; 22class QCheckBox;
23class QLabel; 23class QLabel;
24 24
25class ImportDialog : public QDialog 25class ImportDialog : public QDialog
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28 28
29public: 29public:
30 ImportDialog(QWidget* parent = 0, const char* name = 0); 30 ImportDialog(QWidget* parent = 0, const char* name = 0);
31 ~ImportDialog(); 31 ~ImportDialog();
32 32
33 const DocLnk* selected(); 33 const DocLnk* selected();
34 34
35private slots: 35private slots:
36 void fileChanged(); 36 void fileChanged();
37 void preview(); 37 void preview();
38 38
39private: 39private:
40 FileSelector* m_pFileSelector; 40 OFileSelector* m_pFileSelector;
41 QLabel* m_pPreviewLabel; 41 QLabel* m_pPreviewLabel;
42 QCheckBox* m_pAutomaticPreviewCheckBox; 42 QCheckBox* m_pAutomaticPreviewCheckBox;
43}; 43};
44 44
45#endif // IMPORTDIALOG_H 45#endif // IMPORTDIALOG_H
diff --git a/noncore/graphics/drawpad/main.cpp b/noncore/graphics/drawpad/main.cpp
index ec628cc..12f8084 100644
--- a/noncore/graphics/drawpad/main.cpp
+++ b/noncore/graphics/drawpad/main.cpp
@@ -1,27 +1,27 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "drawpad.h" 14#include "drawpad.h"
15 15
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17 17
18int main(int argc, char **argv) 18int main(int argc, char **argv)
19{ 19{
20 QPEApplication a(argc, argv); 20 QPEApplication a(argc, argv);
21 21
22 DrawPad mw; // = new DrawPad();; 22 DrawPad mw; // = new DrawPad();;
23 a.showMainWidget(&mw ); 23 a.showMainWidget(&mw );
24 24 mw.finishStartup();
25 25
26 return a.exec(); 26 return a.exec();
27} 27}
diff --git a/noncore/graphics/drawpad/opie-drawpad.control b/noncore/graphics/drawpad/opie-drawpad.control
index 1c22186..5095b52 100644
--- a/noncore/graphics/drawpad/opie-drawpad.control
+++ b/noncore/graphics/drawpad/opie-drawpad.control
@@ -1,12 +1,12 @@
1Package: opie-drawpad 1Package: opie-drawpad
2Files: bin/drawpad apps/1Pim/drawpad.desktop pics/drawpad 2Files: bin/drawpad apps/1Pim/drawpad.desktop pics/drawpad
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Sébastien Prud'homme <prudhomme@laposte.net> 5Maintainer: Sébastien Prud'homme <prudhomme@laposte.net>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal, libopie1 7Depends: task-opie-minimal, libopie1
9Description: A note taking program with basic draw tools 8Description: A note taking program with basic draw tools
10 DrawPad is an easy note taking program for Zaurus. It can also 9 DrawPad is an easy note taking program for Zaurus. It can also
11 be used to draw simple images. DrawPad was developed for the Opie 10 be used to draw simple images. DrawPad was developed for the Opie
12 project, an alternative to the standard Zaurus environment. 11 project, an alternative to the standard Zaurus environment.
12Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/graphics/drawpad/texttool.h b/noncore/graphics/drawpad/texttool.h
index 3187675..17556a1 100644
--- a/noncore/graphics/drawpad/texttool.h
+++ b/noncore/graphics/drawpad/texttool.h
@@ -1,46 +1,47 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef TEXTTOOL_H 14#ifndef TEXTTOOL_H
15#define TEXTTOOL_H 15#define TEXTTOOL_H
16 16
17#include "tool.h" 17#include "tool.h"
18 18
19#include <qdialog.h> 19#include <qdialog.h>
20 20
21class QLineEdit; 21class QLineEdit;
22 22
23class TextToolDialog : public QDialog 23class TextToolDialog : public QDialog
24{ 24{
25 Q_OBJECT
25public: 26public:
26 TextToolDialog(QWidget* parent = 0, const char* name = 0); 27 TextToolDialog(QWidget* parent = 0, const char* name = 0);
27 ~TextToolDialog(); 28 ~TextToolDialog();
28 29
29 QString text(); 30 QString text();
30 31
31private: 32private:
32 QLineEdit* m_pLineEdit; 33 QLineEdit* m_pLineEdit;
33}; 34};
34 35
35class TextTool : public Tool 36class TextTool : public Tool
36{ 37{
37public: 38public:
38 TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas); 39 TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
39 ~TextTool(); 40 ~TextTool();
40 41
41 void mousePressEvent(QMouseEvent* e); 42 void mousePressEvent(QMouseEvent* e);
42 void mouseReleaseEvent(QMouseEvent* e); 43 void mouseReleaseEvent(QMouseEvent* e);
43 void mouseMoveEvent(QMouseEvent* e); 44 void mouseMoveEvent(QMouseEvent* e);
44}; 45};
45 46
46#endif // TEXTTOOL_H 47#endif // TEXTTOOL_H
diff --git a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-Pod.control b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-Pod.control
index 2de15e9..faa041b 100644
--- a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-Pod.control
+++ b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-Pod.control
@@ -1,8 +1,8 @@
1Package: opie-mediaplayer2-skin-Pod 1Package: opie-mediaplayer2-skin-Pod
2Files: pics/mediaplayer/skins/Pod 2Files: pics/mediaplayer/skins/Pod
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: ljp <llornkcor@handhelds.org> 5Maintainer: ljp <llornkcor@handhelds.org>
6Version: $QPE_VERSION-$SUB_VERSION
7Description: Opie Mediaplayer's skin. 6Description: Opie Mediaplayer's skin.
8 7
8Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default-landscape.control b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default-landscape.control
index 570b25a..4bc3c60 100644
--- a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default-landscape.control
+++ b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default-landscape.control
@@ -1,9 +1,9 @@
1Package: opie-mediaplayer2-skin-default-landscape 1Package: opie-mediaplayer2-skin-default-landscape
2Files: pics/opieplayer2/skins/default_landscape 2Files: pics/opieplayer2/skins/default_landscape
3Priority: optional 3Priority: optional
4Section: opie/playerskins 4Section: opie/playerskins
5Maintainer: L.J.Potter <ljp@llornkcor.com> 5Maintainer: L.J.Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Landscape skin for opie mediaplayer's 8Description: Landscape skin for opie mediaplayer's
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default.control b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default.control
index 5cd7509..d076fab 100644
--- a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default.control
+++ b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-default.control
@@ -1,9 +1,9 @@
1Package: opie-mediaplayer2-skin-default 1Package: opie-mediaplayer2-skin-default
2Files: pics/opieplayer2/skins/default 2Files: pics/opieplayer2/skins/default
3Priority: optional 3Priority: optional
4Section: opie/playerskins 4Section: opie/playerskins
5Maintainer: L.J.Potter <ljp@llornkcor.com> 5Maintainer: L.J.Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Default skin for opie mediaplayer's 8Description: Default skin for opie mediaplayer's
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-techno.control b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-techno.control
index 0ff1427..ad8c1f8 100644
--- a/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-techno.control
+++ b/noncore/multimedia/mediaplayerskins/opie-mediaplayer2-skin-techno.control
@@ -1,8 +1,8 @@
1Package: opie-mediaplayer2-skin-techno 1Package: opie-mediaplayer2-skin-techno
2Files: pics/mediaplayer/skins/techno 2Files: pics/mediaplayer/skins/techno
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: ljp <llornkcor@handhelds.org> 5Maintainer: ljp <llornkcor@handhelds.org>
6Version: $QPE_VERSION-$SUB_VERSION
7Description: Techno Opie Mediaplayer's skin. Adapted from Qtopia 6Description: Techno Opie Mediaplayer's skin. Adapted from Qtopia
8 7
8Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 5d929cb..2c54ae6 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,338 +1,324 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h>
36#include <qpe/config.h>
37#include <opie/oticker.h>
38
39#include <qwidget.h>
40#include <qpixmap.h>
41#include <qbutton.h>
42#include <qpainter.h>
43#include <qframe.h>
44#include <qlayout.h>
45#include <qdir.h>
46#include <stdlib.h>
47#include <stdio.h>
48 34
49#include "audiowidget.h" 35#include "audiowidget.h"
50#include "mediaplayerstate.h" 36#include "mediaplayerstate.h"
51#include "playlistwidget.h" 37#include "playlistwidget.h"
52 38
53namespace 39namespace
54{ 40{
55 41
56const int xo = -2; // movable x offset 42const int xo = -2; // movable x offset
57const int yo = 22; // movable y offset 43const int yo = 22; // movable y offset
58 44
59const MediaWidget::SkinButtonInfo skinInfo[] = 45const MediaWidget::SkinButtonInfo skinInfo[] =
60{ 46{
61 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 47 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
62 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 48 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
63 { MediaWidget::Next, "next", MediaWidget::NormalButton }, 49 { MediaWidget::Next, "next", MediaWidget::NormalButton },
64 { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, 50 { MediaWidget::Previous, "prev", MediaWidget::NormalButton },
65 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 51 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
66 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 52 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
67 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, 53 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
68 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, 54 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
69 { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, 55 { MediaWidget::Forward, "forward", MediaWidget::NormalButton },
70 { MediaWidget::Back, "back", MediaWidget::NormalButton } 56 { MediaWidget::Back, "back", MediaWidget::NormalButton }
71}; 57};
72 58
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 59const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 60
75void changeTextColor( QWidget * w) { 61void changeTextColor( QWidget * w) {
76 QPalette p = w->palette(); 62 QPalette p = w->palette();
77 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 63 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 64 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
79 w->setPalette( p ); 65 w->setPalette( p );
80} 66}
81 67
82} 68}
83 69
84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 70AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
85 71
86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 72 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
87 audioSliderBeingMoved( false ) 73 audioSliderBeingMoved( false )
88{ 74{
89 setCaption( tr("OpiePlayer") ); 75 setCaption( tr("OpiePlayer") );
90 76
91 loadSkin(); 77 loadSkin();
92 78
93 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 79 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
94 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 80 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
95 81
96 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 82 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
97 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 83 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
98 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 84 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
99 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 85 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
100 86
101 // Intialise state 87 // Intialise state
102 setLength( mediaPlayerState.length() ); 88 setLength( mediaPlayerState.length() );
103 setPosition( mediaPlayerState.position() ); 89 setPosition( mediaPlayerState.position() );
104 setLooping( mediaPlayerState.isFullscreen() ); 90 setLooping( mediaPlayerState.isFullscreen() );
105 // setPaused( mediaPlayerState->paused() ); 91 // setPaused( mediaPlayerState->paused() );
106 setPlaying( mediaPlayerState.isPlaying() ); 92 setPlaying( mediaPlayerState.isPlaying() );
107} 93}
108 94
109AudioWidget::~AudioWidget() { 95AudioWidget::~AudioWidget() {
110 96
111// mediaPlayerState->setPlaying(false); 97// mediaPlayerState->setPlaying(false);
112} 98}
113 99
114MediaWidget::GUIInfo AudioWidget::guiInfo() 100MediaWidget::GUIInfo AudioWidget::guiInfo()
115{ 101{
116 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); 102 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount );
117} 103}
118 104
119void AudioWidget::resizeEvent( QResizeEvent *e ) { 105void AudioWidget::resizeEvent( QResizeEvent *e ) {
120 int h = height(); 106 int h = height();
121 int w = width(); 107 int w = width();
122 108
123 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 109 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
124 slider.setFixedWidth( w - 110 ); 110 slider.setFixedWidth( w - 110 );
125 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 111 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
126 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 112 slider.setBackgroundOrigin( QWidget::ParentOrigin );
127 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 113 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
128 114
129 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; 115 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2;
130 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; 116 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
131 117
132 MediaWidget::resizeEvent( e ); 118 MediaWidget::resizeEvent( e );
133} 119}
134 120
135void AudioWidget::sliderPressed() { 121void AudioWidget::sliderPressed() {
136 audioSliderBeingMoved = TRUE; 122 audioSliderBeingMoved = TRUE;
137} 123}
138 124
139 125
140void AudioWidget::sliderReleased() { 126void AudioWidget::sliderReleased() {
141 audioSliderBeingMoved = FALSE; 127 audioSliderBeingMoved = FALSE;
142 if ( slider.width() == 0 ) 128 if ( slider.width() == 0 )
143 return; 129 return;
144 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 130 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
145 mediaPlayerState.setPosition( val ); 131 mediaPlayerState.setPosition( val );
146} 132}
147 133
148void AudioWidget::setPosition( long i ) { 134void AudioWidget::setPosition( long i ) {
149 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 135 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
150 updateSlider( i, mediaPlayerState.length() ); 136 updateSlider( i, mediaPlayerState.length() );
151} 137}
152 138
153 139
154void AudioWidget::setLength( long max ) { 140void AudioWidget::setLength( long max ) {
155 updateSlider( mediaPlayerState.position(), max ); 141 updateSlider( mediaPlayerState.position(), max );
156} 142}
157 143
158 144
159void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 145void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
160 if ( mediaType == MediaPlayerState::Audio ) { 146 if ( mediaType == MediaPlayerState::Audio ) {
161 // startTimer( 150 ); 147 // startTimer( 150 );
162 showMaximized(); 148 showMaximized();
163 return; 149 return;
164 } 150 }
165 151
166 killTimers(); 152 killTimers();
167 hide(); 153 hide();
168} 154}
169 155
170void AudioWidget::loadSkin() 156void AudioWidget::loadSkin()
171{ 157{
172 loadDefaultSkin( guiInfo() ); 158 loadDefaultSkin( guiInfo() );
173 159
174 songInfo.setFocusPolicy( QWidget::NoFocus ); 160 songInfo.setFocusPolicy( QWidget::NoFocus );
175// changeTextColor( &songInfo ); 161// changeTextColor( &songInfo );
176// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 162// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
177// songInfo.setFrameStyle( QFrame::NoFrame); 163// songInfo.setFrameStyle( QFrame::NoFrame);
178 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 164 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
179// songInfo.setForegroundColor(Qt::white); 165// songInfo.setForegroundColor(Qt::white);
180 166
181 slider.setFixedHeight( 20 ); 167 slider.setFixedHeight( 20 );
182 slider.setMinValue( 0 ); 168 slider.setMinValue( 0 );
183 slider.setMaxValue( 1 ); 169 slider.setMaxValue( 1 );
184 slider.setFocusPolicy( QWidget::NoFocus ); 170 slider.setFocusPolicy( QWidget::NoFocus );
185 slider.setBackgroundPixmap( backgroundPixmap ); 171 slider.setBackgroundPixmap( backgroundPixmap );
186 172
187// Config cofg("qpe"); 173// Config cofg("qpe");
188// cofg.setGroup("Appearance"); 174// cofg.setGroup("Appearance");
189// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 175// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
190 176
191 time.setFocusPolicy( QWidget::NoFocus ); 177 time.setFocusPolicy( QWidget::NoFocus );
192 time.setAlignment( Qt::AlignCenter ); 178 time.setAlignment( Qt::AlignCenter );
193 179
194// time.setFrame(FALSE); 180// time.setFrame(FALSE);
195// changeTextColor( &time ); 181// changeTextColor( &time );
196 182
197 resizeEvent( 0 ); 183 resizeEvent( 0 );
198} 184}
199 185
200void AudioWidget::setSeekable( bool isSeekable ) { 186void AudioWidget::setSeekable( bool isSeekable ) {
201 187
202 if ( !isSeekable ) { 188 if ( !isSeekable ) {
203 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 189 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
204 if( !slider.isHidden()) { 190 if( !slider.isHidden()) {
205 slider.hide(); 191 slider.hide();
206 } 192 }
207 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 193 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
208 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 194 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
209 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 195 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
210 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 196 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
211 } else { 197 } else {
212 // this stops the slider from being moved, thus 198 // this stops the slider from being moved, thus
213 // does not stop stream when it reaches the end 199 // does not stop stream when it reaches the end
214 slider.show(); 200 slider.show();
215 qDebug( " CONNECT SET POSTION " ); 201 qDebug( " CONNECT SET POSTION " );
216 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 202 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
217 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 203 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
218 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 204 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
219 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 205 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
220 } 206 }
221} 207}
222 208
223 209
224static QString timeAsString( long length ) { 210static QString timeAsString( long length ) {
225 int minutes = length / 60; 211 int minutes = length / 60;
226 int seconds = length % 60; 212 int seconds = length % 60;
227 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 213 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
228} 214}
229 215
230void AudioWidget::updateSlider( long i, long max ) { 216void AudioWidget::updateSlider( long i, long max ) {
231 217
232 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 218 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
233// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 219// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
234 220
235 if ( max == 0 ) { 221 if ( max == 0 ) {
236 return; 222 return;
237 } 223 }
238 // Will flicker too much if we don't do this 224 // Will flicker too much if we don't do this
239 // Scale to something reasonable 225 // Scale to something reasonable
240 int width = slider.width(); 226 int width = slider.width();
241 int val = int((double)i * width / max); 227 int val = int((double)i * width / max);
242 if ( !audioSliderBeingMoved ) { 228 if ( !audioSliderBeingMoved ) {
243 if ( slider.value() != val ) { 229 if ( slider.value() != val ) {
244 slider.setValue( val ); 230 slider.setValue( val );
245 } 231 }
246 232
247 if ( slider.maxValue() != width ) { 233 if ( slider.maxValue() != width ) {
248 slider.setMaxValue( width ); 234 slider.setMaxValue( width );
249 } 235 }
250 } 236 }
251} 237}
252 238
253void AudioWidget::skipFor() { 239void AudioWidget::skipFor() {
254 skipDirection = +1; 240 skipDirection = +1;
255 startTimer( 50 ); 241 startTimer( 50 );
256 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 242 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
257} 243}
258 244
259void AudioWidget::skipBack() { 245void AudioWidget::skipBack() {
260 skipDirection = -1; 246 skipDirection = -1;
261 startTimer( 50 ); 247 startTimer( 50 );
262 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 248 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
263} 249}
264 250
265 251
266 252
267void AudioWidget::stopSkip() { 253void AudioWidget::stopSkip() {
268 killTimers(); 254 killTimers();
269} 255}
270 256
271 257
272void AudioWidget::timerEvent( QTimerEvent * ) { 258void AudioWidget::timerEvent( QTimerEvent * ) {
273 if ( skipDirection == +1 ) { 259 if ( skipDirection == +1 ) {
274 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 260 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
275 } else if ( skipDirection == -1 ) { 261 } else if ( skipDirection == -1 ) {
276 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 262 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
277 } 263 }
278} 264}
279 265
280void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 266void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
281 switch ( e->key() ) { 267 switch ( e->key() ) {
282 ////////////////////////////// Zaurus keys 268 ////////////////////////////// Zaurus keys
283 case Key_Home: 269 case Key_Home:
284 break; 270 break;
285 case Key_F9: //activity 271 case Key_F9: //activity
286 hide(); 272 hide();
287 // qDebug("Audio F9"); 273 // qDebug("Audio F9");
288 e->accept(); 274 e->accept();
289 break; 275 break;
290 case Key_F10: //contacts 276 case Key_F10: //contacts
291 break; 277 break;
292 case Key_F11: //menu 278 case Key_F11: //menu
293 mediaPlayerState.toggleBlank(); 279 mediaPlayerState.toggleBlank();
294 e->accept(); 280 e->accept();
295 break; 281 break;
296 case Key_F12: //home 282 case Key_F12: //home
297 break; 283 break;
298 case Key_F13: //mail 284 case Key_F13: //mail
299 mediaPlayerState.toggleBlank(); 285 mediaPlayerState.toggleBlank();
300 e->accept(); 286 e->accept();
301 break; 287 break;
302 case Key_Space: { 288 case Key_Space: {
303 e->accept(); 289 e->accept();
304 mediaPlayerState.togglePaused(); 290 mediaPlayerState.togglePaused();
305 } 291 }
306 break; 292 break;
307 case Key_Down: 293 case Key_Down:
308 // toggleButton(6); 294 // toggleButton(6);
309 emit lessClicked(); 295 emit lessClicked();
310 emit lessReleased(); 296 emit lessReleased();
311 // toggleButton(6); 297 // toggleButton(6);
312 e->accept(); 298 e->accept();
313 break; 299 break;
314 case Key_Up: 300 case Key_Up:
315 // toggleButton(5); 301 // toggleButton(5);
316 emit moreClicked(); 302 emit moreClicked();
317 emit moreReleased(); 303 emit moreReleased();
318 // toggleButton(5); 304 // toggleButton(5);
319 e->accept(); 305 e->accept();
320 break; 306 break;
321 case Key_Right: 307 case Key_Right:
322 // toggleButton(3); 308 // toggleButton(3);
323 mediaPlayerState.setNext(); 309 mediaPlayerState.setNext();
324 // toggleButton(3); 310 // toggleButton(3);
325 e->accept(); 311 e->accept();
326 break; 312 break;
327 case Key_Left: 313 case Key_Left:
328 // toggleButton(4); 314 // toggleButton(4);
329 mediaPlayerState.setPrev(); 315 mediaPlayerState.setPrev();
330 // toggleButton(4); 316 // toggleButton(4);
331 e->accept(); 317 e->accept();
332 break; 318 break;
333 case Key_Escape: { 319 case Key_Escape: {
334 } 320 }
335 break; 321 break;
336 322
337 }; 323 };
338} 324}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 53dbb88..b436239 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,102 +1,95 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qpainter.h>
38#include <qdrawutil.h>
39#include <qpixmap.h>
40#include <qstring.h>
41#include <qslider.h>
42#include <qframe.h>
43#include <qlineedit.h> 37#include <qlineedit.h>
44#include <qimage.h>
45 38
46#include <opie/oticker.h> 39#include <opie/oticker.h>
47 40
48#include "mediawidget.h" 41#include "mediawidget.h"
49 42
50class QPixmap; 43class QPixmap;
51 44
52class AudioWidget : public MediaWidget { 45class AudioWidget : public MediaWidget {
53 Q_OBJECT 46 Q_OBJECT
54public: 47public:
55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 48 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
56 ~AudioWidget(); 49 ~AudioWidget();
57 void setTickerText( const QString &text ) { songInfo.setText( text ); } 50 void setTickerText( const QString &text ) { songInfo.setText( text ); }
58 51
59 static MediaWidget::GUIInfo guiInfo(); 52 static MediaWidget::GUIInfo guiInfo();
60 53
61public slots: 54public slots:
62 void updateSlider( long, long ); 55 void updateSlider( long, long );
63 void sliderPressed( ); 56 void sliderPressed( );
64 void sliderReleased( ); 57 void sliderReleased( );
65 void setLooping( bool b) { setToggleButton( Loop, b ); } 58 void setLooping( bool b) { setToggleButton( Loop, b ); }
66 void setPosition( long ); 59 void setPosition( long );
67 void setSeekable( bool ); 60 void setSeekable( bool );
68 61
69public: 62public:
70 virtual void setLength( long ); 63 virtual void setLength( long );
71 virtual void setPlaying( bool b) { setToggleButton( Play, b ); } 64 virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
72 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 65 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
73 66
74 virtual void loadSkin(); 67 virtual void loadSkin();
75 68
76signals: 69signals:
77 void sliderMoved(long); 70 void sliderMoved(long);
78 71
79protected: 72protected:
80 void doBlank(); 73 void doBlank();
81 void doUnblank(); 74 void doUnblank();
82 void resizeEvent( QResizeEvent *re ); 75 void resizeEvent( QResizeEvent *re );
83 void timerEvent( QTimerEvent *event ); 76 void timerEvent( QTimerEvent *event );
84 void keyReleaseEvent( QKeyEvent *e); 77 void keyReleaseEvent( QKeyEvent *e);
85private slots: 78private slots:
86 void skipFor(); 79 void skipFor();
87 void skipBack(); 80 void skipBack();
88 void stopSkip(); 81 void stopSkip();
89private: 82private:
90 int skipDirection; 83 int skipDirection;
91 QString skin; 84 QString skin;
92 85
93 OTicker songInfo; 86 OTicker songInfo;
94 QSlider slider; 87 QSlider slider;
95 QLineEdit time; 88 QLineEdit time;
96 bool isStreaming : 1; 89 bool isStreaming : 1;
97 bool audioSliderBeingMoved : 1; 90 bool audioSliderBeingMoved : 1;
98}; 91};
99 92
100 93
101#endif // AUDIO_WIDGET_H 94#endif // AUDIO_WIDGET_H
102 95
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index d04af08..11ad745 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,400 +1,433 @@
1 /* 1 /*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <stdio.h> 34
35#include <stdlib.h>
36#include <qimage.h>
37#include <qtextstream.h> 35#include <qtextstream.h>
38#include <qpe/resource.h>
39 36
40#include <qfile.h>
41#include <qdir.h> 37#include <qdir.h>
42 38
43#include <qgfx_qws.h> 39#include <qgfx_qws.h>
44#include <qdirectpainter_qws.h> 40#include <qdirectpainter_qws.h>
45 41
46#include <assert.h> 42#include <assert.h>
47 43
48#include "xinevideowidget.h" 44#include "xinevideowidget.h"
49#include "frame.h" 45#include "frame.h"
50#include "lib.h" 46#include "lib.h"
51 47
52 48
53typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
54 int width, int height,int bytes ); 50 int width, int height,int bytes );
55 51
56extern "C" { 52extern "C" {
57 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 53 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
58 int null_is_showing_video( const xine_vo_driver_t* self ); 54 int null_is_showing_video( const xine_vo_driver_t* self );
59 void null_set_show_video( const xine_vo_driver_t* self, int show ); 55 void null_set_show_video( const xine_vo_driver_t* self, int show );
60 int null_is_fullscreen( const xine_vo_driver_t* self ); 56 int null_is_fullscreen( const xine_vo_driver_t* self );
61 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 57 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
62 int null_is_scaling( const xine_vo_driver_t* self ); 58 int null_is_scaling( const xine_vo_driver_t* self );
63 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 59 void null_set_scaling( const xine_vo_driver_t* self, int scale );
64 void null_set_gui_width( const xine_vo_driver_t* self, int width ); 60 void null_set_gui_width( const xine_vo_driver_t* self, int width );
65 void null_set_gui_height( const xine_vo_driver_t* self, int height ); 61 void null_set_gui_height( const xine_vo_driver_t* self, int height );
66 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); 62 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
67 void null_set_videoGamma( const xine_vo_driver_t* self , int value ); 63 void null_set_videoGamma( const xine_vo_driver_t* self , int value );
68 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); 64 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
69 65
70 void null_preload_decoders( xine_stream_t *stream ); 66 void null_preload_decoders( xine_stream_t *stream );
71} 67}
72 68
73using namespace XINE; 69using namespace XINE;
74 70
75Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 71Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
76{ 72{
77 m_initialized = false; 73 m_initialized = false;
78 m_duringInitialization = false; 74 m_duringInitialization = false;
79 m_video = false; 75 m_video = false;
80 m_wid = widget; 76 m_wid = widget;
81 printf("Lib"); 77 printf("Lib");
82 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 78 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
83 // get the configuration 79 // get the configuration
84 80
85 // not really OO, should be an extra class, later 81 // not really OO, should be an extra class, later
86 if ( !QFile::exists(configPath) ) { 82 if ( !QFile::exists(configPath) ) {
87 QFile f(configPath); 83 QFile f(configPath);
88 f.open(IO_WriteOnly); 84 f.open(IO_WriteOnly);
89 QTextStream ts( &f ); 85 QTextStream ts( &f );
90 ts << "misc.memcpy_method:glibc\n"; 86 ts << "misc.memcpy_method:glibc\n";
87 ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n";
88 ts << "codec.ffmpeg_pp_quality:3\n";
89 ts << "audio.num_buffers:50\n";
90 ts << "audio.size_buffers:4160\n";
91 ts << "video.num_buffers:20\n";
92 ts << "video.size_buffers:4096\n";
93 ts << "audio.out_num_audio_buf:16\n";
94 ts << "audio.out_size_audio_buf:8096\n";
95 ts << "audio.out_size_zero_buf:1024\n";
96 ts << "audio.passthrough_offset:0\n";
91 f.close(); 97 f.close();
92 } 98 }
93 99
94 if ( initMode == InitializeImmediately ) { 100 if ( initMode == InitializeImmediately ) {
95 initialize(); 101 initialize();
96 m_initialized = true; 102 m_initialized = true;
97 } 103 }
98 else 104 else
99 start(); 105 start();
100} 106}
101 107
102void Lib::run() 108void Lib::run()
103{ 109{
104 qDebug( "Lib::run() started" ); 110 qDebug( "Lib::run() started" );
105 initialize(); 111 initialize();
106 m_initialized = true; 112 m_initialized = true;
107 qDebug( "Lib::run() finished" ); 113 qDebug( "Lib::run() finished" );
108} 114}
109 115
110void Lib::initialize() 116void Lib::initialize()
111{ 117{
112 m_duringInitialization = true; 118 m_duringInitialization = true;
113 m_xine = xine_new( ); 119 m_xine = xine_new( );
114 120
115 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 121 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
116 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 122 xine_config_load( m_xine, QFile::encodeName( configPath ) );
117 123
118 xine_init( m_xine ); 124 xine_init( m_xine );
119 125
120 // allocate oss for sound 126 // allocate oss for sound
121 // and fb for framebuffer 127 // and fb for framebuffer
122 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 128 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
123 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 129 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
124 130
125 131
126//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 132//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
127 133
128 134
129// null_display_handler( m_videoOutput, xine_display_frame, this ); 135// null_display_handler( m_videoOutput, xine_display_frame, this );
130 136
131 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 137 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
132 138
133 if (m_wid != 0 ) { 139 if (m_wid != 0 ) {
134 printf( "!0\n" ); 140 printf( "!0\n" );
135 setWidget( m_wid ); 141 setWidget( m_wid );
136 } 142 }
137 143
138 m_queue = xine_event_new_queue (m_stream); 144 m_queue = xine_event_new_queue (m_stream);
139 145
140 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 146 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
141 147
142 ::null_preload_decoders( m_stream ); 148 ::null_preload_decoders( m_stream );
143 149
144 m_duringInitialization = false; 150 m_duringInitialization = false;
145} 151}
146 152
147Lib::~Lib() { 153Lib::~Lib() {
148 assert( isRunning() == false ); 154 assert( isRunning() == false );
149 assert( m_initialized ); 155 assert( m_initialized );
150 156
151// free( m_config ); 157// free( m_config );
152 158
153 xine_close( m_stream ); 159 xine_close( m_stream );
154 160
155 xine_event_dispose_queue( m_queue ); 161 xine_event_dispose_queue( m_queue );
156 162
157 xine_dispose( m_stream ); 163 xine_dispose( m_stream );
158 164
159 xine_exit( m_xine ); 165 xine_exit( m_xine );
160 /* FIXME either free or delete but valgrind bitches against both */ 166 /* FIXME either free or delete but valgrind bitches against both */
161 //free( m_videoOutput ); 167 //free( m_videoOutput );
162 //delete m_audioOutput; 168 //delete m_audioOutput;
163} 169}
164 170
165void Lib::resize ( const QSize &s ) { 171void Lib::resize ( const QSize &s ) {
166 assert( m_initialized || m_duringInitialization ); 172 assert( m_initialized || m_duringInitialization );
167 173
168 if ( s. width ( ) && s. height ( ) ) { 174 if ( s. width ( ) && s. height ( ) ) {
169 ::null_set_gui_width( m_videoOutput, s. width() ); 175 ::null_set_gui_width( m_videoOutput, s. width() );
170 ::null_set_gui_height( m_videoOutput, s. height() ); 176 ::null_set_gui_height( m_videoOutput, s. height() );
171 } 177 }
172} 178}
173 179
174int Lib::majorVersion() { 180int Lib::majorVersion() {
175 int major, minor, sub; 181 int major, minor, sub;
176 xine_get_version ( &major, &minor, &sub ); 182 xine_get_version ( &major, &minor, &sub );
177 return major; 183 return major;
178} 184}
179 185
180int Lib::minorVersion() { 186int Lib::minorVersion() {
181 int major, minor, sub; 187 int major, minor, sub;
182 xine_get_version ( &major, &minor, &sub ); 188 xine_get_version ( &major, &minor, &sub );
183 return minor; 189 return minor;
184} 190}
185 191
186int Lib::subVersion() { 192int Lib::subVersion() {
187 int major, minor, sub; 193 int major, minor, sub;
188 xine_get_version ( &major, &minor, &sub ); 194 xine_get_version ( &major, &minor, &sub );
189 return sub; 195 return sub;
190} 196}
191 197
192int Lib::play( const QString& fileName, int startPos, int start_time ) { 198int Lib::play( const QString& fileName, int startPos, int start_time ) {
193 assert( m_initialized ); 199 assert( m_initialized );
200 // FIXME actually a hack imho. Should not be needed to dispose the whole stream
201 // but without we get wrong media length reads from libxine for the second media
202 //xine_dispose ( m_stream );
194 203
195 QString str = fileName.stripWhiteSpace(); 204 QString str = fileName.stripWhiteSpace();
205
206 //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
207 //m_queue = xine_event_new_queue (m_stream);
208 //xine_event_create_listener_thread (m_queue, xine_event_handler, this);
209
196 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 210 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
197 return 0; 211 return 0;
198 } 212 }
199 return xine_play( m_stream, startPos, start_time); 213 return xine_play( m_stream, startPos, start_time);
200} 214}
201 215
202void Lib::stop() { 216void Lib::stop() {
203 assert( m_initialized ); 217 assert( m_initialized );
204 218
205 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 219 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
206 xine_stop( m_stream ); 220 xine_stop( m_stream );
207} 221}
208 222
209void Lib::pause( bool toggle ) { 223void Lib::pause( bool toggle ) {
210 assert( m_initialized ); 224 assert( m_initialized );
211 225
212 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 226 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
213} 227}
214 228
215int Lib::speed() const { 229int Lib::speed() const {
216 assert( m_initialized ); 230 assert( m_initialized );
217 231
218 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 232 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
219} 233}
220 234
221void Lib::setSpeed( int speed ) { 235void Lib::setSpeed( int speed ) {
222 assert( m_initialized ); 236 assert( m_initialized );
223 237
224 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 238 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
225} 239}
226 240
227int Lib::status() const { 241int Lib::status() const {
228 assert( m_initialized ); 242 assert( m_initialized );
229 243
230 return xine_get_status( m_stream ); 244 return xine_get_status( m_stream );
231} 245}
232 246
233int Lib::currentPosition() const { 247int Lib::currentPosition() const {
234 assert( m_initialized ); 248 assert( m_initialized );
235 249
236 int pos, time, length; 250 int pos, time, length;
237 xine_get_pos_length( m_stream, &pos, &time, &length ); 251 xine_get_pos_length( m_stream, &pos, &time, &length );
238 return pos; 252 return pos;
239} 253}
240 254
241int Lib::currentTime() const { 255int Lib::currentTime() const {
242 assert( m_initialized ); 256 assert( m_initialized );
243 257
244 int pos, time, length; 258 int pos, time, length;
245 xine_get_pos_length( m_stream, &pos, &time, &length ); 259 xine_get_pos_length( m_stream, &pos, &time, &length );
246 return time/1000; 260 if ( time > 0 ) {
261 return time/1000;
262 } else {
263 return 0;
264 }
247} 265}
248 266
249int Lib::length() const { 267int Lib::length() const {
250 assert( m_initialized ); 268 assert( m_initialized );
251 269
252 int pos, time, length; 270 int pos, time, length;
253 xine_get_pos_length( m_stream, &pos, &time, &length ); 271/* dilb: patch to solve the wrong stream length reported to the GUI*/
254 return length/1000; 272 int iRetVal=0, iTestLoop=0;
273
274 do
275 {
276 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
277 if (iRetVal)
278 {/* if the function didn't return 0, then pos, time and length are valid.*/
279 return length/1000;
280 }
281 /*don't poll too much*/
282 usleep(100000);
283 iTestLoop++;
284 }
285 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
286valid stream, then return -1 (this value could be used to make the stream
287unseekable, but it should never occur!! Mr. Murphy ? :) ) */
288
289 return -1;
255} 290}
256 291
257bool Lib::isSeekable() const { 292bool Lib::isSeekable() const {
258 assert( m_initialized ); 293 assert( m_initialized );
259 294
260 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 295 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
261} 296}
262 297
263void Lib::seekTo( int time ) { 298void Lib::seekTo( int time ) {
264 assert( m_initialized ); 299 assert( m_initialized );
265 300
266 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 301 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
267 // since its now milliseconds we need *1000 302 // since its now milliseconds we need *1000
268 xine_play( m_stream, 0, time*1000 ); 303 xine_play( m_stream, 0, time*1000 );
269} 304}
270 305
271 306
272Frame Lib::currentFrame() const { 307Frame Lib::currentFrame() const {
273 assert( m_initialized ); 308 assert( m_initialized );
274 309
275 Frame frame; 310 Frame frame;
276 return frame; 311 return frame;
277}; 312};
278 313
279QString Lib::metaInfo( int number) const { 314QString Lib::metaInfo( int number) const {
280 assert( m_initialized ); 315 assert( m_initialized );
281 316
282 return xine_get_meta_info( m_stream, number ); 317 return xine_get_meta_info( m_stream, number );
283} 318}
284 319
285int Lib::error() const { 320int Lib::error() const {
286 assert( m_initialized ); 321 assert( m_initialized );
287 322
288 return xine_get_error( m_stream ); 323 return xine_get_error( m_stream );
289}; 324};
290 325
291void Lib::ensureInitialized() 326void Lib::ensureInitialized()
292{ 327{
293 if ( m_initialized ) 328 if ( m_initialized )
294 return; 329 return;
295 330
296 qDebug( "waiting for initialization thread to finish" ); 331 qDebug( "waiting for initialization thread to finish" );
297 wait(); 332 wait();
298 qDebug( "initialization thread finished!" ); 333 qDebug( "initialization thread finished!" );
299} 334}
300 335
301void Lib::setWidget( XineVideoWidget *widget ) 336void Lib::setWidget( XineVideoWidget *widget )
302{ 337{
303 m_wid = widget; 338 m_wid = widget;
304 resize ( m_wid-> size ( ) ); 339 resize ( m_wid-> size ( ) );
305 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 340 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
306 m_wid->repaint(); 341 m_wid->repaint();
307} 342}
308 343
309void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 344void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
310{ 345{
311 assert( sendType == ThreadUtil::Channel::OneWay ); 346 assert( sendType == ThreadUtil::Channel::OneWay );
312 handleXineEvent( msg->type() ); 347 handleXineEvent( msg->type() );
313 delete msg; 348 delete msg;
314} 349}
315 350
316void Lib::handleXineEvent( const xine_event_t* t ) { 351void Lib::handleXineEvent( const xine_event_t* t ) {
317 send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); 352 send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
318} 353}
319 354
320void Lib::handleXineEvent( int type ) { 355void Lib::handleXineEvent( int type ) {
321 assert( m_initialized ); 356 assert( m_initialized );
322 357
323 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 358 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
324 emit stopped(); 359 emit stopped();
325 } 360 }
326} 361}
327 362
328 363
329void Lib::setShowVideo( bool video ) { 364void Lib::setShowVideo( bool video ) {
330 assert( m_initialized ); 365 assert( m_initialized );
331 366
332 m_video = video; 367 m_video = video;
333 ::null_set_show_video( m_videoOutput, video ); 368 ::null_set_show_video( m_videoOutput, video );
334} 369}
335 370
336bool Lib::isShowingVideo() const { 371bool Lib::isShowingVideo() const {
337 assert( m_initialized ); 372 assert( m_initialized );
338 373
339 return ::null_is_showing_video( m_videoOutput ); 374 return ::null_is_showing_video( m_videoOutput );
340} 375}
341 376
342bool Lib::hasVideo() const { 377bool Lib::hasVideo() const {
343 assert( m_initialized ); 378 assert( m_initialized );
344 379
345 return xine_get_stream_info( m_stream, 18 ); 380 return xine_get_stream_info( m_stream, 18 );
346} 381}
347 382
348void Lib::showVideoFullScreen( bool fullScreen ) { 383void Lib::showVideoFullScreen( bool fullScreen ) {
349 assert( m_initialized ); 384 assert( m_initialized );
350 385
351 ::null_set_fullscreen( m_videoOutput, fullScreen ); 386 ::null_set_fullscreen( m_videoOutput, fullScreen );
352} 387}
353 388
354bool Lib::isVideoFullScreen() const { 389bool Lib::isVideoFullScreen() const {
355 assert( m_initialized ); 390 assert( m_initialized );
356 391
357 return ::null_is_fullscreen( m_videoOutput ); 392 return ::null_is_fullscreen( m_videoOutput );
358} 393}
359 394
360void Lib::setScaling( bool scale ) { 395void Lib::setScaling( bool scale ) {
361 assert( m_initialized ); 396 assert( m_initialized );
362 397
363 ::null_set_scaling( m_videoOutput, scale ); 398 ::null_set_scaling( m_videoOutput, scale );
364} 399}
365 400
366void Lib::setGamma( int value ) { 401void Lib::setGamma( int value ) {
367 assert( m_initialized ); 402 assert( m_initialized );
368 403
369 //qDebug( QString( "%1").arg(value) ); 404 ::null_set_videoGamma( m_videoOutput, value );
370 /* int gammaValue = ( 100 + value ); */
371 ::null_set_videoGamma( m_videoOutput, value );
372} 405}
373 406
374bool Lib::isScaling() const { 407bool Lib::isScaling() const {
375 assert( m_initialized ); 408 assert( m_initialized );
376 409
377 return ::null_is_scaling( m_videoOutput ); 410 return ::null_is_scaling( m_videoOutput );
378} 411}
379 412
380void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 413void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
381 ( (Lib*)user_data)->handleXineEvent( t ); 414 ( (Lib*)user_data)->handleXineEvent( t );
382} 415}
383 416
384void Lib::xine_display_frame( void* user_data, uint8_t *frame, 417void Lib::xine_display_frame( void* user_data, uint8_t *frame,
385 int width, int height, int bytes ) { 418 int width, int height, int bytes ) {
386 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 419 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
387} 420}
388 421
389void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 422void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
390 assert( m_initialized ); 423 assert( m_initialized );
391 424
392 if ( !m_video ) { 425 if ( !m_video ) {
393 qWarning("not showing video now"); 426 qWarning("not showing video now");
394 return; 427 return;
395 } 428 }
396 429
397 assert( m_wid ); 430 assert( m_wid );
398 431
399 m_wid-> setVideoFrame ( frame, width, height, bytes ); 432 m_wid-> setVideoFrame ( frame, width, height, bytes );
400} 433}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 181735c..0ff14d0 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,221 +1,216 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ZECKEXINELIB_H 34#ifndef ZECKEXINELIB_H
35#define ZECKEXINELIB_H 35#define ZECKEXINELIB_H
36 36
37#include <qcstring.h>
38#include <qstring.h>
39#include <qobject.h>
40
41#include <xine.h> 37#include <xine.h>
42//#include "xine.h"
43 38
44#include "threadutil.h" 39#include "threadutil.h"
45 40
46class XineVideoWidget; 41class XineVideoWidget;
47 42
48namespace XINE { 43namespace XINE {
49 44
50 /** 45 /**
51 * Lib wrapps the simple interface 46 * Lib wrapps the simple interface
52 * of libxine for easy every day use 47 * of libxine for easy every day use
53 * This will become a full C++ Wrapper 48 * This will become a full C++ Wrapper
54 * It supports playing, pausing, info, 49 * It supports playing, pausing, info,
55 * stooping, seeking. 50 * stooping, seeking.
56 */ 51 */
57 class Frame; 52 class Frame;
58 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread 53 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread
59 { 54 {
60 Q_OBJECT 55 Q_OBJECT
61 public: 56 public:
62 enum InitializationMode { InitializeImmediately, InitializeInThread }; 57 enum InitializationMode { InitializeImmediately, InitializeInThread };
63 58
64 Lib( InitializationMode initMode, XineVideoWidget* = 0); 59 Lib( InitializationMode initMode, XineVideoWidget* = 0);
65 60
66 ~Lib(); 61 ~Lib();
67 static int majorVersion(); 62 static int majorVersion();
68 static int minorVersion(); 63 static int minorVersion();
69 static int subVersion(); 64 static int subVersion();
70 65
71 66
72 void resize ( const QSize &s ); 67 void resize ( const QSize &s );
73 68
74 int play( const QString& fileName, 69 int play( const QString& fileName,
75 int startPos = 0, 70 int startPos = 0,
76 int start_time = 0 ); 71 int start_time = 0 );
77 void stop(); 72 void stop();
78 void pause( bool toggle ); 73 void pause( bool toggle );
79 74
80 int speed() const; 75 int speed() const;
81 76
82 /** 77 /**
83 * Set the speed of the stream, if codec supports it 78 * Set the speed of the stream, if codec supports it
84 * XINE_SPEED_PAUSE 0 79 * XINE_SPEED_PAUSE 0
85 * XINE_SPEED_SLOW_4 1 80 * XINE_SPEED_SLOW_4 1
86 * XINE_SPEED_SLOW_2 2 81 * XINE_SPEED_SLOW_2 2
87 * XINE_SPEED_NORMAL 4 82 * XINE_SPEED_NORMAL 4
88 * XINE_SPEED_FAST_2 8 83 * XINE_SPEED_FAST_2 8
89 *XINE_SPEED_FAST_4 16 84 *XINE_SPEED_FAST_4 16
90 */ 85 */
91 void setSpeed( int speed = XINE_SPEED_PAUSE ); 86 void setSpeed( int speed = XINE_SPEED_PAUSE );
92 87
93 int status() const; 88 int status() const;
94 89
95 int currentPosition()const; 90 int currentPosition()const;
96 //in seconds 91 //in seconds
97 int currentTime()const; 92 int currentTime()const;
98 93
99 int length() const; 94 int length() const;
100 95
101 bool isSeekable()const; 96 bool isSeekable()const;
102 97
103 /** 98 /**
104 * Whether or not to show video output 99 * Whether or not to show video output
105 */ 100 */
106 void setShowVideo(bool video); 101 void setShowVideo(bool video);
107 102
108 /** 103 /**
109 * is we show video 104 * is we show video
110 */ 105 */
111 bool isShowingVideo() const; 106 bool isShowingVideo() const;
112 107
113 /** 108 /**
114 * 109 *
115 */ 110 */
116 void showVideoFullScreen( bool fullScreen ); 111 void showVideoFullScreen( bool fullScreen );
117 112
118 /** 113 /**
119 * 114 *
120 */ 115 */
121 bool isVideoFullScreen() const; 116 bool isVideoFullScreen() const;
122 117
123 118
124 /** 119 /**
125 * Get the meta info (like author etc) from the stream 120 * Get the meta info (like author etc) from the stream
126 * XINE_META_INFO_TITLE 0 121 * XINE_META_INFO_TITLE 0
127 * XINE_META_INFO_COMMENT 1 122 * XINE_META_INFO_COMMENT 1
128 * XINE_META_INFO_ARTIST 2 123 * XINE_META_INFO_ARTIST 2
129 * XINE_META_INFO_GENRE 3 124 * XINE_META_INFO_GENRE 3
130 * XINE_META_INFO_ALBUM 4 125 * XINE_META_INFO_ALBUM 4
131 * XINE_META_INFO_YEAR 5 126 * XINE_META_INFO_YEAR 5
132 * XINE_META_INFO_VIDEOCODEC 6 127 * XINE_META_INFO_VIDEOCODEC 6
133 * XINE_META_INFO_AUDIOCODEC 7 128 * XINE_META_INFO_AUDIOCODEC 7
134 * XINE_META_INFO_SYSTEMLAYER 8 129 * XINE_META_INFO_SYSTEMLAYER 8
135 * XINE_META_INFO_INPUT_PLUGIN 9 130 * XINE_META_INFO_INPUT_PLUGIN 9
136 */ 131 */
137 QString metaInfo( int number ) const; 132 QString metaInfo( int number ) const;
138 133
139 /** 134 /**
140 * 135 *
141 */ 136 */
142 bool isScaling() const; 137 bool isScaling() const;
143 138
144 /** 139 /**
145 * seek to a position 140 * seek to a position
146 */ 141 */
147 void seekTo( int time ); 142 void seekTo( int time );
148 143
149 /** 144 /**
150 * 145 *
151 * @return is media stream has video 146 * @return is media stream has video
152 */ 147 */
153 bool hasVideo() const; 148 bool hasVideo() const;
154 149
155 /** 150 /**
156 * 151 *
157 */ 152 */
158 void setScaling( bool ); 153 void setScaling( bool );
159 154
160 /** 155 /**
161 * Set the Gamma value for video output 156 * Set the Gamma value for video output
162 * @param int the value between -100 and 100, 0 is original 157 * @param int the value between -100 and 100, 0 is original
163 */ 158 */
164 void setGamma( int ); 159 void setGamma( int );
165 160
166 /** 161 /**
167 * test 162 * test
168 */ 163 */
169 Frame currentFrame() const; 164 Frame currentFrame() const;
170 165
171 /** 166 /**
172 * Returns the error code 167 * Returns the error code
173 * XINE_ERROR_NONE 0 168 * XINE_ERROR_NONE 0
174 * XINE_ERROR_NO_INPUT_PLUGIN 1 169 * XINE_ERROR_NO_INPUT_PLUGIN 1
175 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 170 * XINE_ERROR_NO_DEMUXER_PLUGIN 2
176 * XINE_ERROR_DEMUXER_FAILED 3 171 * XINE_ERROR_DEMUXER_FAILED 3
177 */ 172 */
178 int error() const; 173 int error() const;
179 174
180 void ensureInitialized(); 175 void ensureInitialized();
181 176
182 void setWidget( XineVideoWidget *widget ); 177 void setWidget( XineVideoWidget *widget );
183 178
184 signals: 179 signals:
185 180
186 void stopped(); 181 void stopped();
187 182
188 void initialized(); 183 void initialized();
189 184
190 protected: 185 protected:
191 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); 186 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType );
192 187
193 virtual void run(); 188 virtual void run();
194 189
195 private: 190 private:
196 void initialize(); 191 void initialize();
197 192
198 int m_bytes_per_pixel; 193 int m_bytes_per_pixel;
199 bool m_initialized:1; 194 bool m_initialized:1;
200 bool m_duringInitialization:1; 195 bool m_duringInitialization:1;
201 bool m_video:1; 196 bool m_video:1;
202 XineVideoWidget *m_wid; 197 XineVideoWidget *m_wid;
203 xine_t *m_xine; 198 xine_t *m_xine;
204 xine_stream_t *m_stream; 199 xine_stream_t *m_stream;
205 xine_cfg_entry_t *m_config; 200 xine_cfg_entry_t *m_config;
206 xine_vo_driver_t *m_videoOutput; 201 xine_vo_driver_t *m_videoOutput;
207 xine_ao_driver_t* m_audioOutput; 202 xine_ao_driver_t* m_audioOutput;
208 xine_event_queue_t *m_queue; 203 xine_event_queue_t *m_queue;
209 204
210 void handleXineEvent( const xine_event_t* t ); 205 void handleXineEvent( const xine_event_t* t );
211 void handleXineEvent( int type ); 206 void handleXineEvent( int type );
212 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 207 void drawFrame( uint8_t* frame, int width, int height, int bytes );
213 // C -> C++ bridge for the event system 208 // C -> C++ bridge for the event system
214 static void xine_event_handler( void* user_data, const xine_event_t* t); 209 static void xine_event_handler( void* user_data, const xine_event_t* t);
215 static void xine_display_frame( void* user_data, uint8_t* frame , 210 static void xine_display_frame( void* user_data, uint8_t* frame ,
216 int width, int height, int bytes ); 211 int width, int height, int bytes );
217 }; 212 };
218}; 213};
219 214
220 215
221#endif 216#endif
diff --git a/noncore/multimedia/opieplayer2/mediadetect.cpp b/noncore/multimedia/opieplayer2/mediadetect.cpp
deleted file mode 100644
index 91137db..0000000
--- a/noncore/multimedia/opieplayer2/mediadetect.cpp
+++ b/dev/null
@@ -1,43 +0,0 @@
1#include <qstring.h>
2#include "mediadetect.h"
3
4
5MediaDetect::MediaDetect() {
6}
7
8MediaDetect::~MediaDetect() {
9}
10
11char MediaDetect::videoOrAudio( const QString& fileName ) {
12 if( (fileName.lower()).right(4) == ".avi" ||
13 (fileName.lower()).right(4) == ".mpg" ||
14 (fileName.lower()).right(4) == ".asf" ||
15 (fileName.lower()).right(4) == ".mov" ||
16 (fileName.lower()).right(5) == ".mpeg" ) {
17 qDebug("Video out taken");
18 return 'v';
19 } else if ( (fileName.lower()).right(4) == "·mp1" ||
20 (fileName.lower()).right(4) == ".mp3" ||
21 (fileName.lower()).right(4) == ".ogg" ||
22 (fileName.lower()).right(4) == ".wav" ) {
23 qDebug("AUDIO out taken");
24 return 'a';
25 } else if ( (fileName.lower()).left(7) == "http://" &&
26 (fileName.lower()).right(1) == "/" ) {
27 return 'a';
28 } else {
29 return 'f';
30 }
31}
32
33bool MediaDetect::isStreaming( const QString& fileName ) {
34 // ugly
35 if( (fileName.lower()).left(4) == "http" ) {
36 return true;
37 } else if ( (fileName.lower()).left(3) == "ftp" ) {
38 return true;
39 } else {
40 return false;
41 }
42}
43
diff --git a/noncore/multimedia/opieplayer2/mediadetect.h b/noncore/multimedia/opieplayer2/mediadetect.h
deleted file mode 100644
index bd5ea1d..0000000
--- a/noncore/multimedia/opieplayer2/mediadetect.h
+++ b/dev/null
@@ -1,31 +0,0 @@
1
2#ifndef MEDIADETECT_H
3#define MEDIADETECT_H
4
5
6class QString;
7class MediaDetect {
8
9public:
10 MediaDetect();
11 ~MediaDetect();
12
13 /**
14 * Look at the filename and decide which gui is to be used
15 *
16 * @param filename the filename
17 * @return the char - a for audio gui, v for video, f for error
18 */
19 char videoOrAudio( const QString& fileName );
20
21 /**
22 * Find out if it is a streaming media file
23 *
24 * @param filename the filename
25 * @return if it is a streaming url or not
26 */
27 bool isStreaming( const QString& fileName );
28
29};
30
31#endif
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index d4396d2..9f51006 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,414 +1,405 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h>
3#include <qpe/resource.h>
4#include <qpe/config.h> 2#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 3#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 4#include <qfileinfo.h>
7 5
8#include <qmainwindow.h>
9#include <qmessagebox.h>
10#include <qwidgetstack.h>
11#include <qfile.h>
12
13#include "mediaplayer.h" 6#include "mediaplayer.h"
14#include "playlistwidget.h" 7#include "playlistwidget.h"
15#include "audiowidget.h" 8#include "audiowidget.h"
16#include "videowidget.h" 9#include "videowidget.h"
17#include "volumecontrol.h" 10#include "volumecontrol.h"
18#include "lib.h" 11#include "lib.h"
19 12
20#include "mediaplayerstate.h" 13#include "mediaplayerstate.h"
21 14
22// for setBacklight() 15 // for setBacklight()
23#include <linux/fb.h> 16#include <linux/fb.h>
24#include <sys/file.h> 17#include <sys/file.h>
25#include <sys/ioctl.h> 18#include <sys/ioctl.h>
26 19
27 20
28
29
30#define FBIOBLANK 0x4611 21#define FBIOBLANK 0x4611
31 22
32MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 23MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
33 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 24 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
34 25
35 m_audioUI = 0; 26 m_audioUI = 0;
36 m_videoUI = 0; 27 m_videoUI = 0;
37 m_xineControl = 0; 28 m_xineControl = 0;
38 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 29 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
39 30
40 fd=-1;fl=-1; 31 fd=-1;fl=-1;
41 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 32 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
42 33
43 qApp->processEvents(); 34 qApp->processEvents();
44 // QPEApplication::grabKeyboard(); // EVIL 35 // QPEApplication::grabKeyboard(); // EVIL
45 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 36 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
46 37
47 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 38 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
48 39
49// What is pauseCheck good for? (Simon) 40// What is pauseCheck good for? (Simon)
50// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 41// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
51 42
52 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 43 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
53 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 44 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
54 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 45 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
55 46
56 volControl = new VolumeControl; 47 volControl = new VolumeControl;
57 Config cfg( "OpiePlayer" ); 48 Config cfg( "OpiePlayer" );
58 cfg.setGroup("PlayList"); 49 cfg.setGroup("PlayList");
59 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 50 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
60 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 51 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
61 52
62 m_skinLoader = new SkinLoader; 53 m_skinLoader = new SkinLoader;
63 m_skinLoader->schedule( AudioWidget::guiInfo() ); 54 m_skinLoader->schedule( AudioWidget::guiInfo() );
64 m_skinLoader->schedule( VideoWidget::guiInfo() ); 55 m_skinLoader->schedule( VideoWidget::guiInfo() );
65 m_skinLoader->start(); 56 m_skinLoader->start();
66} 57}
67 58
68MediaPlayer::~MediaPlayer() { 59MediaPlayer::~MediaPlayer() {
69 // this shold never happen, but one never knows... 60 // this shold never happen, but one never knows...
70 if ( xine ) { 61 if ( xine ) {
71 xine->ensureInitialized(); 62 xine->ensureInitialized();
72 delete xine; 63 delete xine;
73 } 64 }
74 delete m_xineControl; 65 delete m_xineControl;
75 delete m_audioUI; 66 delete m_audioUI;
76 delete m_videoUI; 67 delete m_videoUI;
77 delete volControl; 68 delete volControl;
78} 69}
79 70
80void MediaPlayer::pauseCheck( bool b ) { 71void MediaPlayer::pauseCheck( bool b ) {
81 if ( b && !mediaPlayerState.isPlaying() ) { 72 if ( b && !mediaPlayerState.isPlaying() ) {
82 mediaPlayerState.setPaused( FALSE ); 73 mediaPlayerState.setPaused( FALSE );
83 } 74 }
84} 75}
85 76
86void MediaPlayer::play() { 77void MediaPlayer::play() {
87 mediaPlayerState.setPlaying( FALSE ); 78 mediaPlayerState.setPlaying( FALSE );
88 mediaPlayerState.setPlaying( TRUE ); 79 mediaPlayerState.setPlaying( TRUE );
89} 80}
90 81
91void MediaPlayer::setPlaying( bool play ) { 82void MediaPlayer::setPlaying( bool play ) {
92 if ( !play ) { 83 if ( !play ) {
93 return; 84 return;
94 } 85 }
95 86
96 if ( mediaPlayerState.isPaused() ) { 87 if ( mediaPlayerState.isPaused() ) {
97 mediaPlayerState.setPaused( FALSE ); 88 mediaPlayerState.setPaused( FALSE );
98 return; 89 return;
99 } 90 }
100 91
101 QString tickerText, time, fileName; 92 QString tickerText, time, fileName;
102 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 93 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
103 //if playing in file list.. play in a different way 94 //if playing in file list.. play in a different way
104 // random and looping settings enabled causes problems here, 95 // random and looping settings enabled causes problems here,
105 // since there is no selected file in the playlist, but a selected file in the file list, 96 // since there is no selected file in the playlist, but a selected file in the file list,
106 // so we remember and shutoff 97 // so we remember and shutoff
107 l = mediaPlayerState.isLooping(); 98 l = mediaPlayerState.isLooping();
108 if(l) { 99 if(l) {
109 mediaPlayerState.setLooping( false ); 100 mediaPlayerState.setLooping( false );
110 } 101 }
111 r = mediaPlayerState.isShuffled(); 102 r = mediaPlayerState.isShuffled();
112 mediaPlayerState.setShuffled( false ); 103 mediaPlayerState.setShuffled( false );
113 } 104 }
114 105
115 PlayListWidget::Entry playListEntry = playList.currentEntry(); 106 PlayListWidget::Entry playListEntry = playList.currentEntry();
116 fileName = playListEntry.name; 107 fileName = playListEntry.name;
117 xineControl()->play( playListEntry.file ); 108 xineControl()->play( playListEntry.file );
118 109
119 long seconds = mediaPlayerState.length(); 110 long seconds = mediaPlayerState.length();
120 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 111 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
121 112
122 if( fileName.left(4) == "http" ) { 113 if( fileName.left(4) == "http" ) {
123 fileName = QFileInfo( fileName ).baseName(); 114 fileName = QFileInfo( fileName ).baseName();
124 if ( xineControl()->getMetaInfo().isEmpty() ) { 115 if ( xineControl()->getMetaInfo().isEmpty() ) {
125 tickerText = tr( " File: " ) + fileName; 116 tickerText = tr( " File: " ) + fileName;
126 } else { 117 } else {
127 tickerText = xineControl()->getMetaInfo(); 118 tickerText = xineControl()->getMetaInfo();
128 } 119 }
129 } else { 120 } else {
130 if ( xineControl()->getMetaInfo().isEmpty() ) { 121 if ( xineControl()->getMetaInfo().isEmpty() ) {
131 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 122 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
132 } else { 123 } else {
133 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 124 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
134 } 125 }
135 } 126 }
136 audioUI()->setTickerText( tickerText ); 127 audioUI()->setTickerText( tickerText );
137} 128}
138 129
139 130
140void MediaPlayer::prev() { 131void MediaPlayer::prev() {
141 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 132 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
142 if ( playList.prev() ) { 133 if ( playList.prev() ) {
143 play(); 134 play();
144 } else if ( mediaPlayerState.isLooping() ) { 135 } else if ( mediaPlayerState.isLooping() ) {
145 if ( playList.last() ) { 136 if ( playList.last() ) {
146 play(); 137 play();
147 } 138 }
148 } else { 139 } else {
149 mediaPlayerState.setList(); 140 mediaPlayerState.setList();
150 } 141 }
151 } 142 }
152} 143}
153 144
154 145
155void MediaPlayer::next() { 146void MediaPlayer::next() {
156 147
157 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 148 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
158 if ( playList.next() ) { 149 if ( playList.next() ) {
159 play(); 150 play();
160 } else if ( mediaPlayerState.isLooping() ) { 151 } else if ( mediaPlayerState.isLooping() ) {
161 if ( playList.first() ) { 152 if ( playList.first() ) {
162 play(); 153 play();
163 } 154 }
164 } else { 155 } else {
165 mediaPlayerState.setList(); 156 mediaPlayerState.setList();
166 } 157 }
167 } else { //if playing from file list, let's just stop 158 } else { //if playing from file list, let's just stop
168 qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); 159 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
169 mediaPlayerState.setPlaying(false); 160 mediaPlayerState.setPlaying(false);
170 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 161 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
171 if(l) mediaPlayerState.setLooping(l); 162 if(l) mediaPlayerState.setLooping(l);
172 if(r) mediaPlayerState.setShuffled(r); 163 if(r) mediaPlayerState.setShuffled(r);
173 } 164 }
174 qApp->processEvents(); 165 qApp->processEvents();
175} 166}
176 167
177 168
178void MediaPlayer::startDecreasingVolume() { 169void MediaPlayer::startDecreasingVolume() {
179 volumeDirection = -1; 170 volumeDirection = -1;
180 startTimer( 100 ); 171 startTimer( 100 );
181 volControl->decVol(2); 172 volControl->decVol(2);
182} 173}
183 174
184 175
185void MediaPlayer::startIncreasingVolume() { 176void MediaPlayer::startIncreasingVolume() {
186 volumeDirection = +1; 177 volumeDirection = +1;
187 startTimer( 100 ); 178 startTimer( 100 );
188 volControl->incVol(2); 179 volControl->incVol(2);
189} 180}
190 181
191 182
192bool drawnOnScreenDisplay = FALSE; 183bool drawnOnScreenDisplay = FALSE;
193unsigned int onScreenDisplayVolume = 0; 184unsigned int onScreenDisplayVolume = 0;
194const int yoff = 110; 185const int yoff = 110;
195 186
196void MediaPlayer::stopChangingVolume() { 187void MediaPlayer::stopChangingVolume() {
197 killTimers(); 188 killTimers();
198 // Get rid of the on-screen display stuff 189 // Get rid of the on-screen display stuff
199 drawnOnScreenDisplay = FALSE; 190 drawnOnScreenDisplay = FALSE;
200 onScreenDisplayVolume = 0; 191 onScreenDisplayVolume = 0;
201 int w=0; 192 int w=0;
202 int h=0; 193 int h=0;
203 if( !xineControl()->hasVideo() ) { 194 if( !xineControl()->hasVideo() ) {
204 w = audioUI()->width(); 195 w = audioUI()->width();
205 h = audioUI()->height(); 196 h = audioUI()->height();
206 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 197 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
207 } else { 198 } else {
208 w = videoUI()->width(); 199 w = videoUI()->width();
209 h = videoUI()->height(); 200 h = videoUI()->height();
210 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 201 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
211 } 202 }
212} 203}
213 204
214 205
215void MediaPlayer::timerEvent( QTimerEvent * ) { 206void MediaPlayer::timerEvent( QTimerEvent * ) {
216 if ( volumeDirection == +1 ) { 207 if ( volumeDirection == +1 ) {
217 volControl->incVol( 2 ); 208 volControl->incVol( 2 );
218 } else if ( volumeDirection == -1 ) { 209 } else if ( volumeDirection == -1 ) {
219 volControl->decVol( 2 ); 210 volControl->decVol( 2 );
220 } 211 }
221 212
222 213
223 // TODO FIXME 214 // TODO FIXME
224 // huh?? 215 // huh??
225 unsigned int v= 0; 216 unsigned int v= 0;
226 v = volControl->volume(); 217 v = volControl->volume();
227 v = v / 10; 218 v = v / 10;
228 219
229 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 220 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
230 return; 221 return;
231 } 222 }
232 223
233 int w=0; int h=0; 224 int w=0; int h=0;
234 if( !xineControl()->hasVideo() ) { 225 if( !xineControl()->hasVideo() ) {
235 w = audioUI()->width(); 226 w = audioUI()->width();
236 h = audioUI()->height(); 227 h = audioUI()->height();
237 228
238 if ( drawnOnScreenDisplay ) { 229 if ( drawnOnScreenDisplay ) {
239 if ( onScreenDisplayVolume > v ) { 230 if ( onScreenDisplayVolume > v ) {
240 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 231 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
241 } 232 }
242 } 233 }
243 drawnOnScreenDisplay = TRUE; 234 drawnOnScreenDisplay = TRUE;
244 onScreenDisplayVolume = v; 235 onScreenDisplayVolume = v;
245 QPainter p( audioUI() ); 236 QPainter p( audioUI() );
246 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 237 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
247 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 238 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
248 239
249 QFont f; 240 QFont f;
250 f.setPixelSize( 20 ); 241 f.setPixelSize( 20 );
251 f.setBold( TRUE ); 242 f.setBold( TRUE );
252 p.setFont( f ); 243 p.setFont( f );
253 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 244 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
254 245
255 for ( unsigned int i = 0; i < 10; i++ ) { 246 for ( unsigned int i = 0; i < 10; i++ ) {
256 if ( v > i ) { 247 if ( v > i ) {
257 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 248 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
258 } else { 249 } else {
259 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 250 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
260 } 251 }
261 } 252 }
262 } else { 253 } else {
263 w = videoUI()->width(); 254 w = videoUI()->width();
264 h = videoUI()->height(); 255 h = videoUI()->height();
265 256
266 if ( drawnOnScreenDisplay ) { 257 if ( drawnOnScreenDisplay ) {
267 if ( onScreenDisplayVolume > v ) { 258 if ( onScreenDisplayVolume > v ) {
268 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 259 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
269 } 260 }
270 } 261 }
271 drawnOnScreenDisplay = TRUE; 262 drawnOnScreenDisplay = TRUE;
272 onScreenDisplayVolume = v; 263 onScreenDisplayVolume = v;
273 QPainter p( videoUI() ); 264 QPainter p( videoUI() );
274 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 265 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
275 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 266 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
276 267
277 QFont f; 268 QFont f;
278 f.setPixelSize( 20 ); 269 f.setPixelSize( 20 );
279 f.setBold( TRUE ); 270 f.setBold( TRUE );
280 p.setFont( f ); 271 p.setFont( f );
281 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 272 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
282 273
283 for ( unsigned int i = 0; i < 10; i++ ) { 274 for ( unsigned int i = 0; i < 10; i++ ) {
284 if ( v > i ) { 275 if ( v > i ) {
285 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 276 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
286 } else { 277 } else {
287 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 278 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
288 } 279 }
289 } 280 }
290 } 281 }
291} 282}
292 283
293 284
294void MediaPlayer::blank( bool b ) { 285void MediaPlayer::blank( bool b ) {
295 fd=open("/dev/fb0",O_RDWR); 286 fd=open("/dev/fb0",O_RDWR);
296#ifdef QT_QWS_SL5XXX 287#ifdef QT_QWS_SL5XXX
297 fl= open( "/dev/fl", O_RDWR ); 288 fl= open( "/dev/fl", O_RDWR );
298#endif 289#endif
299 if (fd != -1) { 290 if (fd != -1) {
300 if ( b ) { 291 if ( b ) {
301 qDebug("do blanking"); 292 qDebug("do blanking");
302#ifdef QT_QWS_SL5XXX 293#ifdef QT_QWS_SL5XXX
303 ioctl( fd, FBIOBLANK, 1 ); 294 ioctl( fd, FBIOBLANK, 1 );
304 if(fl !=-1) { 295 if(fl !=-1) {
305 ioctl( fl, 2 ); 296 ioctl( fl, 2 );
306 ::close(fl); 297 ::close(fl);
307 } 298 }
308#else 299#else
309 ioctl( fd, FBIOBLANK, 3 ); 300 ioctl( fd, FBIOBLANK, 3 );
310#endif 301#endif
311 isBlanked = TRUE; 302 isBlanked = TRUE;
312 } else { 303 } else {
313 qDebug("do unblanking"); 304 qDebug("do unblanking");
314 ioctl( fd, FBIOBLANK, 0); 305 ioctl( fd, FBIOBLANK, 0);
315#ifdef QT_QWS_SL5XXX 306#ifdef QT_QWS_SL5XXX
316 if(fl != -1) { 307 if(fl != -1) {
317 ioctl( fl, 1); 308 ioctl( fl, 1);
318 ::close(fl); 309 ::close(fl);
319 } 310 }
320#endif 311#endif
321 isBlanked = FALSE; 312 isBlanked = FALSE;
322 } 313 }
323 close( fd ); 314 close( fd );
324 } else { 315 } else {
325 qDebug("<< /dev/fb0 could not be opened >>"); 316 qDebug("<< /dev/fb0 could not be opened >>");
326 } 317 }
327} 318}
328 319
329void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 320void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
330 switch ( e->key() ) { 321 switch ( e->key() ) {
331////////////////////////////// Zaurus keys 322////////////////////////////// Zaurus keys
332 case Key_Home: 323 case Key_Home:
333 break; 324 break;
334 case Key_F9: //activity 325 case Key_F9: //activity
335 break; 326 break;
336 case Key_F10: //contacts 327 case Key_F10: //contacts
337 break; 328 break;
338 case Key_F11: //menu 329 case Key_F11: //menu
339 break; 330 break;
340 case Key_F12: //home 331 case Key_F12: //home
341 qDebug("Blank here"); 332 qDebug("Blank here");
342// mediaPlayerState->toggleBlank(); 333// mediaPlayerState->toggleBlank();
343 break; 334 break;
344 case Key_F13: //mail 335 case Key_F13: //mail
345 qDebug("Blank here"); 336 qDebug("Blank here");
346 // mediaPlayerState->toggleBlank(); 337 // mediaPlayerState->toggleBlank();
347 break; 338 break;
348 } 339 }
349} 340}
350 341
351void MediaPlayer::cleanUp() {// this happens on closing 342void MediaPlayer::cleanUp() {// this happens on closing
352 Config cfg( "OpiePlayer" ); 343 Config cfg( "OpiePlayer" );
353 mediaPlayerState.writeConfig( cfg ); 344 mediaPlayerState.writeConfig( cfg );
354 playList.writeDefaultPlaylist( ); 345 playList.writeDefaultPlaylist( );
355 346
356// QPEApplication::grabKeyboard(); 347// QPEApplication::grabKeyboard();
357// QPEApplication::ungrabKeyboard(); 348// QPEApplication::ungrabKeyboard();
358} 349}
359 350
360void MediaPlayer::recreateAudioAndVideoWidgets() const 351void MediaPlayer::recreateAudioAndVideoWidgets() const
361{ 352{
362 delete m_skinLoader; 353 delete m_skinLoader;
363 354
364 delete m_xineControl; 355 delete m_xineControl;
365 delete m_audioUI; 356 delete m_audioUI;
366 delete m_videoUI; 357 delete m_videoUI;
367 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 358 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
368 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 359 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
369 360
370 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 361 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
371 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 362 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
372 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 363 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
373 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 364 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
374 365
375 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 366 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
376 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 367 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
377 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 368 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
378 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 369 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
379 370
380 if ( !xine ) 371 if ( !xine )
381 xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); 372 xine = new XINE::Lib( XINE::Lib::InitializeImmediately );
382 373
383 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); 374 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState );
384 375
385 xine = 0; 376 xine = 0;
386} 377}
387 378
388AudioWidget *MediaPlayer::audioUI() const 379AudioWidget *MediaPlayer::audioUI() const
389{ 380{
390 if ( !m_audioUI ) 381 if ( !m_audioUI )
391 recreateAudioAndVideoWidgets(); 382 recreateAudioAndVideoWidgets();
392 return m_audioUI; 383 return m_audioUI;
393} 384}
394 385
395VideoWidget *MediaPlayer::videoUI() const 386VideoWidget *MediaPlayer::videoUI() const
396{ 387{
397 if ( !m_videoUI ) 388 if ( !m_videoUI )
398 recreateAudioAndVideoWidgets(); 389 recreateAudioAndVideoWidgets();
399 return m_videoUI; 390 return m_videoUI;
400} 391}
401 392
402XineControl *MediaPlayer::xineControl() const 393XineControl *MediaPlayer::xineControl() const
403{ 394{
404 if ( !m_xineControl ) 395 if ( !m_xineControl )
405 recreateAudioAndVideoWidgets(); 396 recreateAudioAndVideoWidgets();
406 return m_xineControl; 397 return m_xineControl;
407} 398}
408 399
409void MediaPlayer::reloadSkins() 400void MediaPlayer::reloadSkins()
410{ 401{
411 audioUI()->loadSkin(); 402 audioUI()->loadSkin();
412 videoUI()->loadSkin(); 403 videoUI()->loadSkin();
413} 404}
414 405
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index cbe4d86..34ff064 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -1,105 +1,102 @@
1 /* 1 /*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef MEDIA_PLAYER_H 34#ifndef MEDIA_PLAYER_H
35#define MEDIA_PLAYER_H 35#define MEDIA_PLAYER_H
36 36
37#include <qmainwindow.h>
38#include <qframe.h>
39
40#include "xinecontrol.h" 37#include "xinecontrol.h"
41 38
42#include "playlistwidget.h" 39#include "playlistwidget.h"
43#include "skin.h" 40#include "skin.h"
44 41
45class DocLnk; 42class DocLnk;
46class VolumeControl; 43class VolumeControl;
47class MediaPlayerState; 44class MediaPlayerState;
48class AudioWidget; 45class AudioWidget;
49class VideoWidget; 46class VideoWidget;
50 47
51namespace XINE 48namespace XINE
52{ 49{
53 class Lib; 50 class Lib;
54}; 51};
55 52
56class MediaPlayer : public QObject { 53class MediaPlayer : public QObject {
57 Q_OBJECT 54 Q_OBJECT
58public: 55public:
59 MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); 56 MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name );
60 ~MediaPlayer(); 57 ~MediaPlayer();
61 58
62public slots: 59public slots:
63 void reloadSkins(); 60 void reloadSkins();
64 61
65private slots: 62private slots:
66 void setPlaying( bool ); 63 void setPlaying( bool );
67 void pauseCheck( bool ); 64 void pauseCheck( bool );
68 void play(); 65 void play();
69 void next(); 66 void next();
70 void prev(); 67 void prev();
71 void startIncreasingVolume(); 68 void startIncreasingVolume();
72 void startDecreasingVolume(); 69 void startDecreasingVolume();
73 void stopChangingVolume(); 70 void stopChangingVolume();
74 void cleanUp(); 71 void cleanUp();
75 void blank( bool ); 72 void blank( bool );
76 73
77protected: 74protected:
78 void timerEvent( QTimerEvent *e ); 75 void timerEvent( QTimerEvent *e );
79 void keyReleaseEvent( QKeyEvent *e); 76 void keyReleaseEvent( QKeyEvent *e);
80 77
81private: 78private:
82 AudioWidget *audioUI() const; 79 AudioWidget *audioUI() const;
83 VideoWidget *videoUI() const; 80 VideoWidget *videoUI() const;
84 XineControl *xineControl() const; 81 XineControl *xineControl() const;
85 82
86 bool isBlanked, l, r; 83 bool isBlanked, l, r;
87 int fd, fl; 84 int fd, fl;
88 int volumeDirection; 85 int volumeDirection;
89 VolumeControl *volControl; 86 VolumeControl *volControl;
90 MediaPlayerState &mediaPlayerState; 87 MediaPlayerState &mediaPlayerState;
91 PlayListWidget &playList; 88 PlayListWidget &playList;
92 89
93 void recreateAudioAndVideoWidgets() const; 90 void recreateAudioAndVideoWidgets() const;
94 91
95 mutable XineControl *m_xineControl; 92 mutable XineControl *m_xineControl;
96 mutable AudioWidget *m_audioUI; 93 mutable AudioWidget *m_audioUI;
97 mutable VideoWidget *m_videoUI; 94 mutable VideoWidget *m_videoUI;
98 mutable XINE::Lib *xine; 95 mutable XINE::Lib *xine;
99 96
100 QGuardedPtr<SkinLoader> m_skinLoader; 97 QGuardedPtr<SkinLoader> m_skinLoader;
101}; 98};
102 99
103 100
104#endif // MEDIA_PLAYER_H 101#endif // MEDIA_PLAYER_H
105 102
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 3953d92..b1f88c9 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,263 +1,265 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <simon@lst.de> 2 Copyright (C) 2002 Simon Hausmann <simon@lst.de>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <assert.h>
24
23#include "mediawidget.h" 25#include "mediawidget.h"
24#include "playlistwidget.h" 26#include "playlistwidget.h"
25#include "skin.h" 27#include "skin.h"
26 28
27#include <assert.h> 29#include <assert.h>
28 30
29MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 31MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
30 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 32 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
31{ 33{
32 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 34 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
33 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 35 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
34 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 36 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
35 this, SLOT( setLength( long ) ) ); 37 this, SLOT( setLength( long ) ) );
36 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 38 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
37 this, SLOT( setPlaying( bool ) ) ); 39 this, SLOT( setPlaying( bool ) ) );
38 40
39 setBackgroundMode( NoBackground ); 41 setBackgroundMode( NoBackground );
40} 42}
41 43
42MediaWidget::~MediaWidget() 44MediaWidget::~MediaWidget()
43{ 45{
44} 46}
45 47
46void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 48void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
47 const Skin &skin ) 49 const Skin &skin )
48{ 50{
49 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 51 buttonMask = skin.buttonMask( skinInfo, buttonCount );
50 52
51 buttons.clear(); 53 buttons.clear();
52 buttons.reserve( buttonCount ); 54 buttons.reserve( buttonCount );
53 55
54 for ( uint i = 0; i < buttonCount; ++i ) { 56 for ( uint i = 0; i < buttonCount; ++i ) {
55 Button button = setupButton( skinInfo[ i ], skin ); 57 Button button = setupButton( skinInfo[ i ], skin );
56 buttons.push_back( button ); 58 buttons.push_back( button );
57 } 59 }
58} 60}
59 61
60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 62MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
61{ 63{
62 Button button; 64 Button button;
63 button.command = buttonInfo.command; 65 button.command = buttonInfo.command;
64 button.type = buttonInfo.type; 66 button.type = buttonInfo.type;
65 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 67 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
66 68
67 return button; 69 return button;
68} 70}
69 71
70void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) 72void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
71{ 73{
72 Skin skin( guiInfo.fileNameInfix ); 74 Skin skin( guiInfo.fileNameInfix );
73 skin.setCachable( false ); 75 skin.setCachable( false );
74 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); 76 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin );
75} 77}
76 78
77void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 79void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
78{ 80{
79 backgroundPixmap = skin.backgroundPixmap(); 81 backgroundPixmap = skin.backgroundPixmap();
80 buttonUpImage = skin.buttonUpImage(); 82 buttonUpImage = skin.buttonUpImage();
81 buttonDownImage = skin.buttonDownImage(); 83 buttonDownImage = skin.buttonDownImage();
82 84
83 setupButtons( skinInfo, buttonCount, skin ); 85 setupButtons( skinInfo, buttonCount, skin );
84} 86}
85 87
86void MediaWidget::closeEvent( QCloseEvent * ) 88void MediaWidget::closeEvent( QCloseEvent * )
87{ 89{
88 mediaPlayerState.setList(); 90 mediaPlayerState.setList();
89} 91}
90 92
91void MediaWidget::paintEvent( QPaintEvent *pe ) 93void MediaWidget::paintEvent( QPaintEvent *pe )
92{ 94{
93 QPainter p( this ); 95 QPainter p( this );
94 96
95 if ( mediaPlayerState.isFullscreen() ) { 97 if ( mediaPlayerState.isFullscreen() ) {
96 // Clear the background 98 // Clear the background
97 p.setBrush( QBrush( Qt::black ) ); 99 p.setBrush( QBrush( Qt::black ) );
98 return; 100 return;
99 } 101 }
100 102
101 QPixmap buffer( size() ); 103 QPixmap buffer( size() );
102 QPainter bufferedPainter( &buffer ); 104 QPainter bufferedPainter( &buffer );
103 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); 105 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
104 paintAllButtons( bufferedPainter ); 106 paintAllButtons( bufferedPainter );
105 p.drawPixmap( 0, 0, buffer ); 107 p.drawPixmap( 0, 0, buffer );
106} 108}
107 109
108void MediaWidget::resizeEvent( QResizeEvent *e ) 110void MediaWidget::resizeEvent( QResizeEvent *e )
109{ 111{
110 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 112 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
111 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 113 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
112 114
113 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 115 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
114 Button &button = *it; 116 Button &button = *it;
115 117
116 if ( button.mask.isNull() ) 118 if ( button.mask.isNull() )
117 continue; 119 continue;
118 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 120 button.pixUp = addMaskToPixmap( pixUp, button.mask );
119 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 121 button.pixDown = addMaskToPixmap( pixDn, button.mask );
120 } 122 }
121 123
122 QWidget::resizeEvent( e ); 124 QWidget::resizeEvent( e );
123} 125}
124 126
125MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 127MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
126{ 128{
127 if ( position.x() <= 0 || position.y() <= 0 || 129 if ( position.x() <= 0 || position.y() <= 0 ||
128 position.x() >= buttonMask.width() || 130 position.x() >= buttonMask.width() ||
129 position.y() >= buttonMask.height() ) 131 position.y() >= buttonMask.height() )
130 return 0; 132 return 0;
131 133
132 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 134 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
133 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 135 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
134 if ( it->command + 1 == pixelIdx ) 136 if ( it->command + 1 == pixelIdx )
135 return &( *it ); 137 return &( *it );
136 138
137 return 0; 139 return 0;
138} 140}
139 141
140void MediaWidget::mousePressEvent( QMouseEvent *event ) 142void MediaWidget::mousePressEvent( QMouseEvent *event )
141{ 143{
142 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 144 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
143 145
144 if ( !button ) { 146 if ( !button ) {
145 QWidget::mousePressEvent( event ); 147 QWidget::mousePressEvent( event );
146 return; 148 return;
147 } 149 }
148 150
149 switch ( button->command ) { 151 switch ( button->command ) {
150 case VolumeUp: emit moreClicked(); return; 152 case VolumeUp: emit moreClicked(); return;
151 case VolumeDown: emit lessClicked(); return; 153 case VolumeDown: emit lessClicked(); return;
152 case Back: emit backClicked(); return; 154 case Back: emit backClicked(); return;
153 case Forward: emit forwardClicked(); return; 155 case Forward: emit forwardClicked(); return;
154 default: break; 156 default: break;
155 } 157 }
156} 158}
157 159
158void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 160void MediaWidget::mouseReleaseEvent( QMouseEvent *event )
159{ 161{
160 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 162 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
161 163
162 if ( !button ) { 164 if ( !button ) {
163 QWidget::mouseReleaseEvent( event ); 165 QWidget::mouseReleaseEvent( event );
164 return; 166 return;
165 } 167 }
166 168
167 if ( button->type == ToggleButton ) 169 if ( button->type == ToggleButton )
168 toggleButton( *button ); 170 toggleButton( *button );
169 171
170 handleCommand( button->command, button->isDown ); 172 handleCommand( button->command, button->isDown );
171} 173}
172 174
173void MediaWidget::makeVisible() 175void MediaWidget::makeVisible()
174{ 176{
175} 177}
176 178
177void MediaWidget::handleCommand( Command command, bool buttonDown ) 179void MediaWidget::handleCommand( Command command, bool buttonDown )
178{ 180{
179 switch ( command ) { 181 switch ( command ) {
180 case Play: mediaPlayerState.togglePaused(); return; 182 case Play: mediaPlayerState.togglePaused(); return;
181 case Stop: mediaPlayerState.setPlaying(FALSE); return; 183 case Stop: mediaPlayerState.setPlaying(FALSE); return;
182 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 184 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
183 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 185 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
184 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 186 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
185 case VolumeUp: emit moreReleased(); return; 187 case VolumeUp: emit moreReleased(); return;
186 case VolumeDown: emit lessReleased(); return; 188 case VolumeDown: emit lessReleased(); return;
187 case PlayList: mediaPlayerState.setList(); return; 189 case PlayList: mediaPlayerState.setList(); return;
188 case Forward: emit forwardReleased(); return; 190 case Forward: emit forwardReleased(); return;
189 case Back: emit backReleased(); return; 191 case Back: emit backReleased(); return;
190 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; 192 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
191 default: assert( false ); 193 default: assert( false );
192 } 194 }
193} 195}
194 196
195bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 197bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
196{ 198{
197 return ( position.x() > 0 && position.y() > 0 && 199 return ( position.x() > 0 && position.y() > 0 &&
198 position.x() < buttonMask.width() && 200 position.x() < buttonMask.width() &&
199 position.y() < buttonMask.height() && 201 position.y() < buttonMask.height() &&
200 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 202 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
201} 203}
202 204
203void MediaWidget::paintAllButtons( QPainter &p ) 205void MediaWidget::paintAllButtons( QPainter &p )
204{ 206{
205 for ( ButtonVector::const_iterator it = buttons.begin(); 207 for ( ButtonVector::const_iterator it = buttons.begin();
206 it != buttons.end(); ++it ) 208 it != buttons.end(); ++it )
207 paintButton( p, *it ); 209 paintButton( p, *it );
208} 210}
209 211
210void MediaWidget::paintButton( const Button &button ) 212void MediaWidget::paintButton( const Button &button )
211{ 213{
212 QPainter p( this ); 214 QPainter p( this );
213 paintButton( p, button ); 215 paintButton( p, button );
214} 216}
215 217
216void MediaWidget::paintButton( QPainter &p, const Button &button ) 218void MediaWidget::paintButton( QPainter &p, const Button &button )
217{ 219{
218 if ( button.isDown ) 220 if ( button.isDown )
219 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 221 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
220 else 222 else
221 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 223 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
222} 224}
223 225
224void MediaWidget::setToggleButton( Command command, bool down ) 226void MediaWidget::setToggleButton( Command command, bool down )
225{ 227{
226 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 228 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
227 if ( it->command == command ) { 229 if ( it->command == command ) {
228 setToggleButton( *it, down ); 230 setToggleButton( *it, down );
229 return; 231 return;
230 } 232 }
231} 233}
232 234
233void MediaWidget::setToggleButton( Button &button, bool down ) 235void MediaWidget::setToggleButton( Button &button, bool down )
234{ 236{
235 if ( down != button.isDown ) 237 if ( down != button.isDown )
236 toggleButton( button ); 238 toggleButton( button );
237} 239}
238 240
239void MediaWidget::toggleButton( Button &button ) 241void MediaWidget::toggleButton( Button &button )
240{ 242{
241 button.isDown = !button.isDown; 243 button.isDown = !button.isDown;
242 244
243 paintButton( button ); 245 paintButton( button );
244} 246}
245 247
246QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) 248QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset )
247{ 249{
248 QPixmap pix( image.size() ); 250 QPixmap pix( image.size() );
249 QPainter p( &pix ); 251 QPainter p( &pix );
250 p.drawTiledPixmap( pix.rect(), background, offset ); 252 p.drawTiledPixmap( pix.rect(), background, offset );
251 p.drawImage( 0, 0, image ); 253 p.drawImage( 0, 0, image );
252 return pix; 254 return pix;
253} 255}
254 256
255QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) 257QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask )
256{ 258{
257 QPixmap result( pix ); 259 QPixmap result( pix );
258 result.setMask( mask ); 260 result.setMask( mask );
259 return result; 261 return result;
260} 262}
261 263
262/* vim: et sw=4 ts=4 264/* vim: et sw=4 ts=4
263 */ 265 */
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 841d950..7183fb4 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -1,166 +1,160 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
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..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = 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 31
32#include "playlistwidget.h" 32#include "playlistwidget.h"
33#include "om3u.h" 33#include "om3u.h"
34 34
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/storage.h> 37#include <qpe/storage.h>
38#include <qpe/mimetype.h> 38#include <qpe/mimetype.h>
39#include <qpe/global.h> 39#include <qpe/global.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41 41
42#include <qdir.h> 42#include <qdir.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qcstring.h> 47#include <qcstring.h>
48 48
49//extern PlayListWidget *playList; 49//extern PlayListWidget *playList;
50 50
51Om3u::Om3u( const QString &filePath, int mode) 51Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 52 : QStringList (){
53qDebug("<<<<<<<new m3u "+filePath); 53qDebug("<<<<<<<new m3u "+filePath);
54 f.setName(filePath); 54 f.setName(filePath);
55 f.open(mode); 55 f.open(mode);
56} 56}
57 57
58Om3u::~Om3u(){} 58Om3u::~Om3u(){}
59 59
60void Om3u::readM3u() { 60void Om3u::readM3u() {
61// qDebug("<<<<<<reading m3u "+f.name()); 61// qDebug("<<<<<<reading m3u "+f.name());
62 QTextStream t(&f); 62 QTextStream t(&f);
63 QString s; 63 QString s;
64 while ( !t.atEnd() ) { 64 while ( !t.atEnd() ) {
65 s=t.readLine(); 65 s=t.readLine();
66// qDebug(s); 66// qDebug(s);
67 if( s.find( "#", 0, TRUE) == -1 ) { 67 if( s.find( "#", 0, TRUE) == -1 ) {
68 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 68 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
69 s = s.right( s.length() -2 ); 69 s = s.right( s.length() -2 );
70 QFileInfo f( s ); 70 QFileInfo f( s );
71 QString name = f.baseName(); 71 QString name = f.baseName();
72 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 72 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
73 s=s.replace( QRegExp( "\\" ), "/" ); 73 s=s.replace( QRegExp( "\\" ), "/" );
74 append(s); 74 append(s);
75// qDebug(s); 75// qDebug(s);
76 } else { // is url 76 } else { // is url
77 s.replace( QRegExp( "%20" )," " );
78 QString name; 77 QString name;
79// if( name.left( 4 ) == "http" ) { 78 name = s;
80// name = s.right( s.length() - 7 );
81// } else {
82 name = s;
83// }
84 append(name); 79 append(name);
85// qDebug(name);
86 } 80 }
87 } 81 }
88 } 82 }
89} 83}
90 84
91void Om3u::readPls() { //it's a pls file 85void Om3u::readPls() { //it's a pls file
92 QTextStream t( &f ); 86 QTextStream t( &f );
93 QString s; 87 QString s;
94 while ( !t.atEnd() ) { 88 while ( !t.atEnd() ) {
95 s = t.readLine(); 89 s = t.readLine();
96 if( s.left(4) == "File" ) { 90 if( s.left(4) == "File" ) {
97 s = s.right( s.length() - s.find("=",0,true)-1 ); 91 s = s.right( s.length() - s.find("=",0,true)-1 );
98 s = s.stripWhiteSpace(); 92 s = s.stripWhiteSpace();
99 s.replace( QRegExp( "%20" )," "); 93 s.replace( QRegExp( "%20" )," ");
100// qDebug( "adding " + s + " to playlist" ); 94// qDebug( "adding " + s + " to playlist" );
101 // numberofentries=2 95 // numberofentries=2
102 // File1=http 96 // File1=http
103 // Title 97 // Title
104 // Length 98 // Length
105 // Version 99 // Version
106 // File2=http 100 // File2=http
107 s = s.replace( QRegExp( "\\" ), "/" ); 101 s = s.replace( QRegExp( "\\" ), "/" );
108 QFileInfo f( s ); 102 QFileInfo f( s );
109 QString name = f.baseName(); 103 QString name = f.baseName();
110 if( name.left( 4 ) == "http" ) { 104 if( name.left( 4 ) == "http" ) {
111 name = s.right( s.length() - 7); 105 name = s.right( s.length() - 7);
112 } else { 106 } else {
113 name = s; 107 name = s;
114 } 108 }
115 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 109 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
116 if( s.at( s.length() - 4) == '.') // if this is probably a file 110 if( s.at( s.length() - 4) == '.') // if this is probably a file
117 append(s); 111 append(s);
118 else { //if its a url 112 else { //if its a url
119// if( name.right( 1 ).find( '/' ) == -1) { 113// if( name.right( 1 ).find( '/' ) == -1) {
120// s += "/"; 114// s += "/";
121// } 115// }
122 append(s); 116 append(s);
123 } 117 }
124 } 118 }
125 } 119 }
126} 120}
127 121
128void Om3u::write() { //writes list to m3u file 122void Om3u::write() { //writes list to m3u file
129 QString list; 123 QString list;
130 if(count()>0) { 124 if(count()>0) {
131 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 125 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
132// qDebug(*it); 126// qDebug(*it);
133 list += *it+"\n"; 127 list += *it+"\n";
134 } 128 }
135 f.writeBlock( list, list.length() ); 129 f.writeBlock( list, list.length() );
136 } 130 }
137// f.close(); 131// f.close();
138} 132}
139 133
140void Om3u::add(const QString &filePath) { //adds to m3u file 134void Om3u::add(const QString &filePath) { //adds to m3u file
141 append(filePath); 135 append(filePath);
142} 136}
143 137
144void Om3u::remove(const QString &filePath) { //removes from m3u list 138void Om3u::remove(const QString &filePath) { //removes from m3u list
145 QString list, currentFile; 139 QString list, currentFile;
146 if(count()>0) { 140 if(count()>0) {
147 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 141 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
148 currentFile=*it; 142 currentFile=*it;
149 // qDebug(*it); 143 // qDebug(*it);
150 144
151 if( filePath != currentFile) 145 if( filePath != currentFile)
152 list += currentFile+"\n"; 146 list += currentFile+"\n";
153 } 147 }
154 f.writeBlock( list, list.length() ); 148 f.writeBlock( list, list.length() );
155 } 149 }
156} 150}
157 151
158void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file 152void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file
159 f.close(); 153 f.close();
160 f.remove(); 154 f.remove();
161 155
162} 156}
163 157
164void Om3u::close() { //closes m3u file 158void Om3u::close() { //closes m3u file
165 f.close(); 159 f.close();
166} 160}
diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control
new file mode 100644
index 0000000..0e71fc5
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control
@@ -0,0 +1,10 @@
1Package: opie-mediaplayer2-codecs
2 Files: root/usr/lib/libao.so* root/usr/lib/libogg* root/usr/lib/libvorbisidec.so* root/usr/lib/libxine.so* root/usr/lib/xine/*
3Section: opie/multimedia
4Essential: no
5Priority: optional
6Version: 0.7-$SUB_VERSION.3
7Architecture: arm
8Maintainer: Maximilian Reiss <harlekin@handhelds.org>
9Depends: libc6 (>= 2.1), opie-mediaplayer2
10Description: Codecs for opieplayer 2
diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.postinst b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.postinst
new file mode 100755
index 0000000..8e60212
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.postinst
@@ -0,0 +1,5 @@
1#!/bin/sh
2
3[ "$1" = "configure" ] || exit 1
4
5ldconfig \ No newline at end of file
diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2.control b/noncore/multimedia/opieplayer2/opie-mediaplayer2.control
index c072308..10c5d19 100644
--- a/noncore/multimedia/opieplayer2/opie-mediaplayer2.control
+++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2.control
@@ -1,11 +1,11 @@
1Package: opie-mediaplayer2 1Package: opie-mediaplayer2
2Files: bin/opieplayer2 apps/Applications/mediaplayer.desktop pics/opieplayer2/add_to_playlist.png pics/opieplayer2/cut.png pics/opieplayer2/delete.png pics/opieplayer2/down.png pics/opieplayer2/loop.png pics/opieplayer2/MPEGPlayer.png pics/opieplayer2/musicfile.png pics/opieplayer2/playlist2.png pics/opieplayer2/play.png pics/opieplayer2/remove_from_playlist.png pics/opieplayer2/shuffle.png pics/opieplayer2/up.png pics/opieplayer2/videofile.png 2Files: bin/opieplayer2 apps/Applications/mediaplayer.desktop pics/opieplayer2/add_to_playlist.png pics/opieplayer2/cut.png pics/opieplayer2/delete.png pics/opieplayer2/down.png pics/opieplayer2/loop.png pics/opieplayer2/MPEGPlayer.png pics/opieplayer2/musicfile.png pics/opieplayer2/playlist2.png pics/opieplayer2/play.png pics/opieplayer2/remove_from_playlist.png pics/opieplayer2/shuffle.png pics/opieplayer2/up.png pics/opieplayer2/videofile.png
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: L.J.Potter <ljp@llornkcor.com>, Maximilian Reiss <harlekin@handhelds.org> 5Maintainer: L.J.Potter <ljp@llornkcor.com>, Maximilian Reiss <harlekin@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Depends: task-opie-minimal, libopie1, zlib1g, libstdc++2.10-glibc2.2, opie-mediaplayer2-skin-default | opie-mediaplayer2-skin-default-landscape , libxine1 | opie-mediaplayer2-codecs
8Depends: task-opie-minimal, libopie1, zlib1g, opie-mediaplayer2-skin-default | opie-mediaplayer2-skin-default-landscape , libxine1 | opie-mediaplayer-codecs
9Description: The Opie media player 8Description: The Opie media player
10 The mediaplayer for Opie. It plays mp3, mpeg, wav, ogg, quicktime, divx and 9 The mediaplayer for Opie. It plays mp3, mpeg, wav, ogg, quicktime, divx and
11 more. Also it is streaming capable. 10 more. Also it is streaming capable.
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index 57cd18f..5dabbab 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,48 +1,48 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \ 4HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \
5 videowidget.h audiowidget.h playlistwidget.h om3u.h mediaplayer.h inputDialog.h \ 5 videowidget.h audiowidget.h playlistwidget.h om3u.h mediaplayer.h inputDialog.h \
6 frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ 6 frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\
7 alphablend.h yuv2rgb.h threadutil.h mediawidget.h playlistview.h playlistfileview.h \ 7 alphablend.h yuv2rgb.h threadutil.h mediawidget.h playlistview.h playlistfileview.h \
8 skin.h 8 skin.h
9SOURCES = main.cpp \ 9SOURCES = main.cpp \
10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \ 10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \
11 videowidget.cpp audiowidget.cpp playlistwidget.cpp om3u.cpp mediaplayer.cpp inputDialog.cpp \ 11 videowidget.cpp audiowidget.cpp playlistwidget.cpp om3u.cpp mediaplayer.cpp inputDialog.cpp \
12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ 12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \
13 playlistwidgetgui.cpp\ 13 playlistwidgetgui.cpp\
14 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S \ 14 alphablend.c yuv2rgb.c yuv2rgb_arm2.c yuv2rgb_arm4l.S \
15 threadutil.cpp mediawidget.cpp playlistview.cpp playlistfileview.cpp \ 15 threadutil.cpp mediawidget.cpp playlistview.cpp playlistfileview.cpp \
16 skin.cpp 16 skin.cpp
17TARGET = opieplayer2 17TARGET = opieplayer2
18INCLUDEPATH += $(OPIEDIR)/include 18INCLUDEPATH += $(OPIEDIR)/include
19DEPENDPATH += $(OPIEDIR)/include 19DEPENDPATH += $(OPIEDIR)/include
20LIBS += -lqpe -lpthread -lopie -lxine -lstdc++ 20LIBS += -lqpe -lpthread -lopie -lxine -lstdc++
21MOC_DIR = qpeobj 21MOC_DIR = qpeobj
22OBJECTS_DIR = qpeobj 22OBJECTS_DIR = qpeobj
23 23
24#INCLUDEPATH += $(OPIEDIR)/include 24#INCLUDEPATH += $(OPIEDIR)/include
25#DEPENDPATH += $(OPIEDIR)/include 25#DEPENDPATH += $(OPIEDIR)/include
26 26
27 27
28 28
29TRANSLATIONS = ../../../i18n/de/opieplayer2.ts \ 29TRANSLATIONS = ../../../i18n/de/opieplayer2.ts \
30 ../../../i18n/nl/opieplayer2.ts \ 30 ../../../i18n/nl/opieplayer2.ts \
31 ../../../i18n/da/opieplayer2.ts \ 31 ../../../i18n/da/opieplayer2.ts \
32 ../../../i18n/xx/opieplayer2.ts \ 32 ../../../i18n/xx/opieplayer2.ts \
33 ../../../i18n/en/opieplayer2.ts \ 33 ../../../i18n/en/opieplayer2.ts \
34 ../../../i18n/es/opieplayer2.ts \ 34 ../../../i18n/es/opieplayer2.ts \
35 ../../../i18n/fr/opieplayer2.ts \ 35 ../../../i18n/fr/opieplayer2.ts \
36 ../../../i18n/hu/opieplayer2.ts \ 36 ../../../i18n/hu/opieplayer2.ts \
37 ../../../i18n/ja/opieplayer2.ts \ 37 ../../../i18n/ja/opieplayer2.ts \
38 ../../../i18n/ko/opieplayer2.ts \ 38 ../../../i18n/ko/opieplayer2.ts \
39 ../../../i18n/no/opieplayer2.ts \ 39 ../../../i18n/no/opieplayer2.ts \
40 ../../../i18n/pl/opieplayer2.ts \ 40 ../../../i18n/pl/opieplayer2.ts \
41 ../../../i18n/pt/opieplayer2.ts \ 41 ../../../i18n/pt/opieplayer2.ts \
42 ../../../i18n/pt_BR/opieplayer2.ts \ 42 ../../../i18n/pt_BR/opieplayer2.ts \
43 ../../../i18n/sl/opieplayer2.ts \ 43 ../../../i18n/sl/opieplayer2.ts \
44 ../../../i18n/zh_CN/opieplayer2.ts \ 44 ../../../i18n/zh_CN/opieplayer2.ts \
45 ../../../i18n/zh_TW/opieplayer2.ts 45 ../../../i18n/zh_TW/opieplayer2.ts
46 46
47 47
48include ( $(OPIEDIR)/include.pro ) 48include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 5f750ba..a1a1016 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1043 +1,1034 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qtoolbar.h>
35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h>
37#include <qpe/mimetype.h>
38#include <qpe/global.h>
39#include <qpe/resource.h>
40#include <qpe/config.h>
41 35
42#include <opie/ofiledialog.h> 36#include <opie/ofiledialog.h>
43 37
44#include <qdatetime.h>
45#include <qdir.h>
46#include <qmessagebox.h> 38#include <qmessagebox.h>
47#include <qregexp.h>
48#include <qtextstream.h>
49 39
50#include "playlistselection.h" 40#include "playlistselection.h"
51#include "playlistwidget.h" 41#include "playlistwidget.h"
52#include "mediaplayerstate.h" 42#include "mediaplayerstate.h"
53#include "inputDialog.h" 43#include "inputDialog.h"
54#include "om3u.h" 44#include "om3u.h"
55#include "playlistfileview.h" 45#include "playlistfileview.h"
56 46
57//only needed for the random play 47//only needed for the random play
58#include <stdlib.h>
59#include <assert.h> 48#include <assert.h>
60 49
61PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 50PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
62 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) 51 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 )
63{ 52{
64 53
65 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 54 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
66 "opieplayer2/add_to_playlist", 55 "opieplayer2/add_to_playlist",
67 this , SLOT(addSelected() ) ); 56 this , SLOT(addSelected() ) );
68 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 57 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
69 "opieplayer2/remove_from_playlist", 58 "opieplayer2/remove_from_playlist",
70 this , SLOT(removeSelected() ) ); 59 this , SLOT(removeSelected() ) );
71 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 60 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
72 this , SLOT( btnPlay( bool) ), TRUE ); 61 this , SLOT( btnPlay( bool) ), TRUE );
73 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 62 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
74 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 63 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
75 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 64 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
76 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 65 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
77 66
78 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 67 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
79 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 68 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
80 this, SLOT( addAllMusicToList() ) ); 69 this, SLOT( addAllMusicToList() ) );
81 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 70 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
82 this, SLOT( addAllVideoToList() ) ); 71 this, SLOT( addAllVideoToList() ) );
83 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 72 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
84 this, SLOT( addAllToList() ) ); 73 this, SLOT( addAllToList() ) );
85 pmPlayList->insertSeparator(-1); 74 pmPlayList->insertSeparator(-1);
86 (void)new MenuItem( pmPlayList, tr( "Add File" ), 75 (void)new MenuItem( pmPlayList, tr( "Add File" ),
87 this,SLOT( openFile() ) ); 76 this,SLOT( openFile() ) );
88 (void)new MenuItem( pmPlayList, tr("Add URL"), 77 (void)new MenuItem( pmPlayList, tr("Add URL"),
89 this,SLOT( openURL() ) ); 78 this,SLOT( openURL() ) );
90 pmPlayList->insertSeparator(-1); 79 pmPlayList->insertSeparator(-1);
91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 80 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
92 this, SLOT(writem3u() ) ); 81 this, SLOT(writem3u() ) );
93 pmPlayList->insertSeparator(-1); 82 pmPlayList->insertSeparator(-1);
94 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 83 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
95 audioView, SLOT( scanFiles() ) ); 84 audioView, SLOT( scanFiles() ) );
96 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
97 videoView, SLOT( scanFiles() ) ); 86 videoView, SLOT( scanFiles() ) );
98 87
99 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 88 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
100 &mediaPlayerState, SLOT( toggleFullscreen() ) ); 89 &mediaPlayerState, SLOT( toggleFullscreen() ) );
101 90
102 Config cfg( "OpiePlayer" ); 91 Config cfg( "OpiePlayer" );
103 bool b= cfg.readBoolEntry("FullScreen", 0); 92 bool b= cfg.readBoolEntry("FullScreen", 0);
104 mediaPlayerState.setFullscreen( b ); 93 mediaPlayerState.setFullscreen( b );
105 pmView->setItemChecked( -16, b ); 94 pmView->setItemChecked( -16, b );
106 95
107 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 96 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
108 d->selectedFiles, SLOT(moveSelectedUp() ) ); 97 d->selectedFiles, SLOT(moveSelectedUp() ) );
109 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 98 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
110 d->selectedFiles, SLOT(removeSelected() ) ); 99 d->selectedFiles, SLOT(removeSelected() ) );
111 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 100 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
112 d->selectedFiles, SLOT(moveSelectedDown() ) ); 101 d->selectedFiles, SLOT(moveSelectedDown() ) );
113 QVBox *stretch2 = new QVBox( vbox1 ); 102 QVBox *stretch2 = new QVBox( vbox1 );
114 103
115 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 104 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
116 SLOT( deletePlaylist() ) ); 105 SLOT( deletePlaylist() ) );
117 connect( pmView, SIGNAL( activated( int ) ), 106 connect( pmView, SIGNAL( activated( int ) ),
118 this, SLOT( pmViewActivated( int ) ) ); 107 this, SLOT( pmViewActivated( int ) ) );
119 connect( skinsMenu, SIGNAL( activated( int ) ) , 108 connect( skinsMenu, SIGNAL( activated( int ) ) ,
120 this, SLOT( skinsMenuActivated( int ) ) ); 109 this, SLOT( skinsMenuActivated( int ) ) );
121 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 110 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
122 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 111 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
123 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 112 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
124 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 113 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
125 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 114 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
126 this,SLOT( playIt( QListViewItem *) ) ); 115 this,SLOT( playIt( QListViewItem *) ) );
127 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 116 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
128 this, SLOT( addToSelection( QListViewItem *) ) ); 117 this, SLOT( addToSelection( QListViewItem *) ) );
129 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 118 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
130 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 119 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
131 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 120 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
132 this,SLOT( playIt( QListViewItem *) ) ); 121 this,SLOT( playIt( QListViewItem *) ) );
133 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 122 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
134 this, SLOT( addToSelection( QListViewItem *) ) ); 123 this, SLOT( addToSelection( QListViewItem *) ) );
135 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 124 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
136 this, SLOT( loadList( const DocLnk & ) ) ); 125 this, SLOT( loadList( const DocLnk & ) ) );
137 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 126 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
138 this, SLOT( tabChanged( QWidget* ) ) ); 127 this, SLOT( tabChanged( QWidget* ) ) );
139 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 128 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
140 d->tbPlay, SLOT( setOn( bool ) ) ); 129 d->tbPlay, SLOT( setOn( bool ) ) );
141 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 130 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
142 d->tbLoop, SLOT( setOn( bool ) ) ); 131 d->tbLoop, SLOT( setOn( bool ) ) );
143 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 132 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
144 d->tbShuffle, SLOT( setOn( bool ) ) ); 133 d->tbShuffle, SLOT( setOn( bool ) ) );
145 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 134 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
146 this, SLOT( playIt( QListViewItem *) ) ); 135 this, SLOT( playIt( QListViewItem *) ) );
147 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 136 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
148 &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 137 &mediaPlayerState, SLOT( setVideoGamma( int ) ) );
149 138
150 // see which skins are installed 139 // see which skins are installed
151 populateSkinsMenu(); 140 populateSkinsMenu();
152 initializeStates(); 141 initializeStates();
153 142
154 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 143 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
155 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 144 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
156 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); 145 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
157 146
158 147
159 cfg.setGroup("PlayList"); 148 cfg.setGroup("PlayList");
160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 149 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
161 loadList(DocLnk( currentPlaylist ) ); 150 loadList(DocLnk( currentPlaylist ) );
162 151
163 tabWidget->showPage( playListTab ); 152 tabWidget->showPage( playListTab );
164} 153}
165 154
166 155
167PlayListWidget::~PlayListWidget() { 156PlayListWidget::~PlayListWidget() {
168 delete d; 157 delete d;
169} 158}
170 159
171 160
172void PlayListWidget::initializeStates() { 161void PlayListWidget::initializeStates() {
173 d->tbPlay->setOn( mediaPlayerState.isPlaying() ); 162 d->tbPlay->setOn( mediaPlayerState.isPlaying() );
174 d->tbLoop->setOn( mediaPlayerState.isLooping() ); 163 d->tbLoop->setOn( mediaPlayerState.isLooping() );
175 d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); 164 d->tbShuffle->setOn( mediaPlayerState.isShuffled() );
176 d->playListFrame->show(); 165 d->playListFrame->show();
177} 166}
178 167
179void PlayListWidget::writeDefaultPlaylist() { 168void PlayListWidget::writeDefaultPlaylist() {
180 169
181 Config config( "OpiePlayer" ); 170 Config config( "OpiePlayer" );
182 config.setGroup( "PlayList" ); 171 config.setGroup( "PlayList" );
183 QString filename=QPEApplication::documentDir() + "/default.m3u"; 172 QString filename=QPEApplication::documentDir() + "/default.m3u";
184 QString currentString = config.readEntry( "CurrentPlaylist", filename); 173 QString currentString = config.readEntry( "CurrentPlaylist", filename);
185 if( currentString == filename) { 174 if( currentString == filename) {
186 Om3u *m3uList; 175 Om3u *m3uList;
187 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 176 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
188 if( d->selectedFiles->first() ) { 177 if( d->selectedFiles->first() ) {
189 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 178 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
190 do { 179 do {
191 // qDebug(d->selectedFiles->current()->file()); 180 // qDebug(d->selectedFiles->current()->file());
192 m3uList->add( d->selectedFiles->current()->file() ); 181 m3uList->add( d->selectedFiles->current()->file() );
193 } 182 }
194 while ( d->selectedFiles->next() ); 183 while ( d->selectedFiles->next() );
195 184
196 m3uList->write(); 185 m3uList->write();
197 m3uList->close(); 186 m3uList->close();
198 delete m3uList; 187 delete m3uList;
199 188
200 } 189 }
201 } 190 }
202} 191}
203 192
204void PlayListWidget::addToSelection( const DocLnk& lnk ) { 193void PlayListWidget::addToSelection( const DocLnk& lnk ) {
205 d->setDocumentUsed = FALSE; 194 d->setDocumentUsed = FALSE;
206 if( QFileInfo( lnk.file() ).exists() || 195 if( QFileInfo( lnk.file() ).exists() ||
207 lnk.file().left(4) == "http" ) { 196 lnk.file().left(4) == "http" ) {
208 d->selectedFiles->addToSelection( lnk ); 197 d->selectedFiles->addToSelection( lnk );
209 } 198 }
210// writeCurrentM3u(); 199// writeCurrentM3u();
211} 200}
212 201
213 202
214void PlayListWidget::clearList() { 203void PlayListWidget::clearList() {
215 while ( first() ) { 204 while ( first() ) {
216 d->selectedFiles->removeSelected(); 205 d->selectedFiles->removeSelected();
217 } 206 }
218 Config cfg( "OpiePlayer" ); 207 Config cfg( "OpiePlayer" );
219 cfg.setGroup("PlayList"); 208 cfg.setGroup("PlayList");
220 cfg.writeEntry("CurrentPlaylist","default"); 209 cfg.writeEntry("CurrentPlaylist","default");
221 setCaption("OpiePlayer"); 210 setCaption("OpiePlayer");
222} 211}
223 212
224void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 213void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
225 switch (mouse) { 214 switch (mouse) {
226 case LeftButton: 215 case LeftButton:
227 break; 216 break;
228 case RightButton: 217 case RightButton:
229 { 218 {
230 QPopupMenu m; 219 QPopupMenu m;
231 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 220 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
232 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 221 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
233 m.exec( QCursor::pos() ); 222 m.exec( QCursor::pos() );
234 } 223 }
235 break; 224 break;
236 } 225 }
237} 226}
238 227
239 228
240void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 229void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
241 switch (mouse) { 230 switch (mouse) {
242 case LeftButton: 231 case LeftButton:
243 break; 232 break;
244 case RightButton: 233 case RightButton:
245 { 234 {
246 QPopupMenu m; 235 QPopupMenu m;
247 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 236 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
248 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 237 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
249 m.exec( QCursor::pos() ); 238 m.exec( QCursor::pos() );
250 } 239 }
251 break; 240 break;
252 } 241 }
253} 242}
254 243
255 244
256void PlayListWidget::addAllToList() { 245void PlayListWidget::addAllToList() {
257 246
258 247
259 audioView->populateView(); 248 audioView->populateView();
260 249
261 QListViewItemIterator audioIt( audioView ); 250 QListViewItemIterator audioIt( audioView );
262 DocLnk lnk; 251 DocLnk lnk;
263 QString filename; 252 QString filename;
264 // iterate through all items of the listview 253 // iterate through all items of the listview
265 for ( ; audioIt.current(); ++audioIt ) { 254 for ( ; audioIt.current(); ++audioIt ) {
266 filename = audioIt.current()->text(3); 255 filename = audioIt.current()->text(3);
267 lnk.setName( QFileInfo(filename).baseName() ); //sets name 256 lnk.setName( QFileInfo(filename).baseName() ); //sets name
268 lnk.setFile( filename ); //sets file name 257 lnk.setFile( filename ); //sets file name
269 d->selectedFiles->addToSelection( lnk); 258 d->selectedFiles->addToSelection( lnk);
270 } 259 }
271 260
272 videoView->populateView(); 261 videoView->populateView();
273 262
274 QListViewItemIterator videoIt( videoView ); 263 QListViewItemIterator videoIt( videoView );
275 for ( ; videoIt.current(); ++videoIt ) { 264 for ( ; videoIt.current(); ++videoIt ) {
276 filename = videoIt.current()->text(3); 265 filename = videoIt.current()->text(3);
277 lnk.setName( QFileInfo(filename).baseName() ); //sets name 266 lnk.setName( QFileInfo(filename).baseName() ); //sets name
278 lnk.setFile( filename ); //sets file name 267 lnk.setFile( filename ); //sets file name
279 d->selectedFiles->addToSelection( lnk); 268 d->selectedFiles->addToSelection( lnk);
280 } 269 }
281 270
282 tabWidget->setCurrentPage(0); 271 tabWidget->setCurrentPage(0);
283 272
284 writeCurrentM3u(); 273 writeCurrentM3u();
285 d->selectedFiles->first(); 274 d->selectedFiles->first();
286} 275}
287 276
288 277
289void PlayListWidget::addAllMusicToList() { 278void PlayListWidget::addAllMusicToList() {
290 279
291 audioView->populateView(); 280 audioView->populateView();
292 281
293 QListViewItemIterator audioIt( audioView ); 282 QListViewItemIterator audioIt( audioView );
294 DocLnk lnk; 283 DocLnk lnk;
295 QString filename; 284 QString filename;
296 // iterate through all items of the listview 285 // iterate through all items of the listview
297 for ( ; audioIt.current(); ++audioIt ) { 286 for ( ; audioIt.current(); ++audioIt ) {
298 filename = audioIt.current()->text(3); 287 filename = audioIt.current()->text(3);
299 lnk.setName( QFileInfo(filename).baseName() ); //sets name 288 lnk.setName( QFileInfo(filename).baseName() ); //sets name
300 lnk.setFile( filename ); //sets file name 289 lnk.setFile( filename ); //sets file name
301 d->selectedFiles->addToSelection( lnk); 290 d->selectedFiles->addToSelection( lnk);
302 } 291 }
303 292
304 tabWidget->setCurrentPage(0); 293 tabWidget->setCurrentPage(0);
305 writeCurrentM3u(); 294 writeCurrentM3u();
306 d->selectedFiles->first(); 295 d->selectedFiles->first();
307} 296}
308 297
309 298
310void PlayListWidget::addAllVideoToList() { 299void PlayListWidget::addAllVideoToList() {
311 300
312 videoView->populateView(); 301 videoView->populateView();
313 302
314 QListViewItemIterator videoIt( videoView ); 303 QListViewItemIterator videoIt( videoView );
315 DocLnk lnk; 304 DocLnk lnk;
316 QString filename; 305 QString filename;
317 for ( ; videoIt.current(); ++videoIt ) { 306 for ( ; videoIt.current(); ++videoIt ) {
318 filename = videoIt.current()->text(3); 307 filename = videoIt.current()->text(3);
319 lnk.setName( QFileInfo(filename).baseName() ); //sets name 308 lnk.setName( QFileInfo(filename).baseName() ); //sets name
320 lnk.setFile( filename ); //sets file name 309 lnk.setFile( filename ); //sets file name
321 d->selectedFiles->addToSelection( lnk); 310 d->selectedFiles->addToSelection( lnk);
322 } 311 }
323 tabWidget->setCurrentPage(0); 312 tabWidget->setCurrentPage(0);
324 writeCurrentM3u(); 313 writeCurrentM3u();
325 d->selectedFiles->first(); 314 d->selectedFiles->first();
326} 315}
327 316
328 317
329void PlayListWidget::setDocument( const QString& fileref ) { 318void PlayListWidget::setDocument( const QString& fileref ) {
330 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 319 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
331 fromSetDocument = TRUE; 320 fromSetDocument = TRUE;
332 QFileInfo fileInfo(fileref); 321 QFileInfo fileInfo(fileref);
333 322
334 if ( !fileInfo.exists() ) { 323 if ( !fileInfo.exists() ) {
335 QMessageBox::warning( this, tr( "Invalid File" ), 324 QMessageBox::warning( this, tr( "Invalid File" ),
336 tr( "There was a problem in getting the file." ) ); 325 tr( "There was a problem in getting the file." ) );
337 return; 326 return;
338 } 327 }
339 328
340 clearList(); 329 clearList();
341 QString extension = fileInfo.extension(false); 330 QString extension = fileInfo.extension(false);
342 331
343 if( extension.find( "m3u", 0, false) != -1 332 if( extension.find( "m3u", 0, false) != -1
344 || extension.find( "pls", 0, false) != -1 ) { 333 || extension.find( "pls", 0, false) != -1 ) {
345 readListFromFile( fileref ); 334 readListFromFile( fileref );
346 } else { 335 } else {
347 clearList(); 336 clearList();
348 DocLnk lnk; 337 DocLnk lnk;
349 lnk.setName( fileInfo.baseName() ); //sets name 338 lnk.setName( fileInfo.baseName() ); //sets name
350 lnk.setFile( fileref ); //sets file name 339 lnk.setFile( fileref ); //sets file name
351 addToSelection( lnk ); 340 addToSelection( lnk );
352 writeCurrentM3u(); 341 writeCurrentM3u();
353 342
354 d->setDocumentUsed = TRUE; 343 d->setDocumentUsed = TRUE;
355 mediaPlayerState.setPlaying( FALSE ); 344 mediaPlayerState.setPlaying( FALSE );
356 mediaPlayerState.setPlaying( TRUE ); 345 mediaPlayerState.setPlaying( TRUE );
357 } 346 }
358} 347}
359 348
360 349
361void PlayListWidget::useSelectedDocument() { 350void PlayListWidget::useSelectedDocument() {
362 d->setDocumentUsed = FALSE; 351 d->setDocumentUsed = FALSE;
363} 352}
364 353
365 354
366const DocLnk *PlayListWidget::current() const { // this is fugly 355const DocLnk *PlayListWidget::current() const { // this is fugly
367 assert( currentTab() == CurrentPlayList ); 356 assert( currentTab() == CurrentPlayList );
368 357
369 const DocLnk *lnk = d->selectedFiles->current(); 358 const DocLnk *lnk = d->selectedFiles->current();
370 if ( !lnk ) { 359 if ( !lnk ) {
371 d->selectedFiles->first(); 360 d->selectedFiles->first();
372 lnk = d->selectedFiles->current(); 361 lnk = d->selectedFiles->current();
373 } 362 }
374 assert( lnk ); 363 assert( lnk );
375 return lnk; 364 return lnk;
376} 365}
377 366
378 367
379bool PlayListWidget::prev() { 368bool PlayListWidget::prev() {
380 if ( mediaPlayerState.isShuffled() ) { 369 if ( mediaPlayerState.isShuffled() ) {
381 const DocLnk *cur = current(); 370 const DocLnk *cur = current();
382 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 371 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
383 for ( int i = 0; i < j; i++ ) { 372 for ( int i = 0; i < j; i++ ) {
384 if ( !d->selectedFiles->next() ) 373 if ( !d->selectedFiles->next() )
385 d->selectedFiles->first(); 374 d->selectedFiles->first();
386 } 375 }
387 if ( cur == current() ) 376 if ( cur == current() )
388 if ( !d->selectedFiles->next() ) { 377 if ( !d->selectedFiles->next() ) {
389 d->selectedFiles->first(); 378 d->selectedFiles->first();
390 } 379 }
391 return TRUE; 380 return TRUE;
392 } else { 381 } else {
393 if ( !d->selectedFiles->prev() ) { 382 if ( !d->selectedFiles->prev() ) {
394 if ( mediaPlayerState.isLooping() ) { 383 if ( mediaPlayerState.isLooping() ) {
395 return d->selectedFiles->last(); 384 return d->selectedFiles->last();
396 } else { 385 } else {
397 return FALSE; 386 return FALSE;
398 } 387 }
399 } 388 }
400 return TRUE; 389 return TRUE;
401 } 390 }
402} 391}
403 392
404 393
405bool PlayListWidget::next() { 394bool PlayListWidget::next() {
406//qDebug("<<<<<<<<<<<<next()"); 395//qDebug("<<<<<<<<<<<<next()");
407 if ( mediaPlayerState.isShuffled() ) { 396 if ( mediaPlayerState.isShuffled() ) {
408 return prev(); 397 return prev();
409 } else { 398 } else {
410 if ( !d->selectedFiles->next() ) { 399 if ( !d->selectedFiles->next() ) {
411 if ( mediaPlayerState.isLooping() ) { 400 if ( mediaPlayerState.isLooping() ) {
412 return d->selectedFiles->first(); 401 return d->selectedFiles->first();
413 } else { 402 } else {
414 return FALSE; 403 return FALSE;
415 } 404 }
416 } 405 }
417 return TRUE; 406 return TRUE;
418 } 407 }
419} 408}
420 409
421 410
422bool PlayListWidget::first() { 411bool PlayListWidget::first() {
423 return d->selectedFiles->first(); 412 return d->selectedFiles->first();
424} 413}
425 414
426 415
427bool PlayListWidget::last() { 416bool PlayListWidget::last() {
428 return d->selectedFiles->last(); 417 return d->selectedFiles->last();
429} 418}
430 419
431 420
432 void PlayListWidget::saveList() { 421 void PlayListWidget::saveList() {
433 writem3u(); 422 writem3u();
434 } 423 }
435 424
436 425
437void PlayListWidget::loadList( const DocLnk & lnk) { 426void PlayListWidget::loadList( const DocLnk & lnk) {
438 QString name = lnk.name(); 427 QString name = lnk.name();
439 428
440 if( name.length()>0) { 429 if( name.length()>0) {
441 setCaption("OpiePlayer: "+name); 430 setCaption("OpiePlayer: "+name);
442 clearList(); 431 clearList();
443 readListFromFile(lnk.file()); 432 readListFromFile(lnk.file());
444 tabWidget->setCurrentPage(0); 433 tabWidget->setCurrentPage(0);
445 } 434 }
446} 435}
447 436
448void PlayListWidget::addSelected() { 437void PlayListWidget::addSelected() {
449 assert( inFileListMode() ); 438 assert( inFileListMode() );
450 439
451 QListViewItemIterator it( currentFileListView ); 440 QListViewItemIterator it( currentFileListView );
452 for ( ; it.current(); ++it ) 441 for ( ; it.current(); ++it )
453 if ( it.current()->isSelected() ) { 442 if ( it.current()->isSelected() ) {
454 QString filename = it.current()->text(3); 443 QString filename = it.current()->text(3);
455 444
456 DocLnk lnk; 445 DocLnk lnk;
457 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 446 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
458 lnk.setFile( filename ); //sets file name 447 lnk.setFile( filename ); //sets file name
459 448
460 d->selectedFiles->addToSelection( lnk ); 449 d->selectedFiles->addToSelection( lnk );
461 } 450 }
462 451
463 currentFileListView->clearSelection(); 452 currentFileListView->clearSelection();
464 453
465 writeCurrentM3u(); 454 writeCurrentM3u();
466} 455}
467 456
468 457
469void PlayListWidget::removeSelected() { 458void PlayListWidget::removeSelected() {
470 d->selectedFiles->removeSelected( ); 459 d->selectedFiles->removeSelected( );
471 writeCurrentM3u(); 460 writeCurrentM3u();
472} 461}
473 462
474 463
475void PlayListWidget::playIt( QListViewItem *it) { 464void PlayListWidget::playIt( QListViewItem *it) {
476 if(!it) return; 465 if(!it) return;
477 mediaPlayerState.setPlaying(FALSE); 466 mediaPlayerState.setPlaying(FALSE);
478 mediaPlayerState.setPlaying(TRUE); 467 mediaPlayerState.setPlaying(TRUE);
479 d->selectedFiles->unSelect(); 468 d->selectedFiles->unSelect();
480} 469}
481 470
482 471
483void PlayListWidget::addToSelection( QListViewItem *it) { 472void PlayListWidget::addToSelection( QListViewItem *it) {
484 d->setDocumentUsed = FALSE; 473 d->setDocumentUsed = FALSE;
485 474
486 if(it) { 475 if(it) {
487 if ( currentTab() == CurrentPlayList ) 476 if ( currentTab() == CurrentPlayList )
488 return; 477 return;
489 DocLnk lnk; 478 DocLnk lnk;
490 QString filename; 479 QString filename;
491 480
492 filename=it->text(3); 481 filename=it->text(3);
493 lnk.setName( QFileInfo(filename).baseName() ); //sets name 482 lnk.setName( QFileInfo(filename).baseName() ); //sets name
494 lnk.setFile( filename ); //sets file name 483 lnk.setFile( filename ); //sets file name
495 d->selectedFiles->addToSelection( lnk); 484 d->selectedFiles->addToSelection( lnk);
496 485
497 writeCurrentM3u(); 486 writeCurrentM3u();
498// tabWidget->setCurrentPage(0); 487// tabWidget->setCurrentPage(0);
499 488
500 } 489 }
501} 490}
502 491
503 492
504void PlayListWidget::tabChanged(QWidget *) { 493void PlayListWidget::tabChanged(QWidget *) {
505 494
506 d->tbPlay->setEnabled( true ); 495 d->tbPlay->setEnabled( true );
507 496
508 disconnect( audioView, SIGNAL( itemsSelected( bool ) ), 497 disconnect( audioView, SIGNAL( itemsSelected( bool ) ),
509 d->tbPlay, SLOT( setEnabled( bool ) ) ); 498 d->tbPlay, SLOT( setEnabled( bool ) ) );
510 disconnect( videoView, SIGNAL( itemsSelected( bool ) ), 499 disconnect( videoView, SIGNAL( itemsSelected( bool ) ),
511 d->tbPlay, SLOT( setEnabled( bool ) ) ); 500 d->tbPlay, SLOT( setEnabled( bool ) ) );
512 501
513 currentFileListView = 0; 502 currentFileListView = 0;
514 503
515 switch ( currentTab() ) { 504 switch ( currentTab() ) {
516 case CurrentPlayList: 505 case CurrentPlayList:
517 { 506 {
518 if( !tbDeletePlaylist->isHidden() ) { 507 if( !tbDeletePlaylist->isHidden() ) {
519 tbDeletePlaylist->hide(); 508 tbDeletePlaylist->hide();
520 } 509 }
521 d->tbRemoveFromList->setEnabled(TRUE); 510 d->tbRemoveFromList->setEnabled(TRUE);
522 d->tbAddToList->setEnabled(FALSE); 511 d->tbAddToList->setEnabled(FALSE);
523 512
524 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 513 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
525 } 514 }
526 break; 515 break;
527 case AudioFiles: 516 case AudioFiles:
528 { 517 {
529 audioView->populateView(); 518 audioView->populateView();
530 519
531 if( !tbDeletePlaylist->isHidden() ) { 520 if( !tbDeletePlaylist->isHidden() ) {
532 tbDeletePlaylist->hide(); 521 tbDeletePlaylist->hide();
533 } 522 }
534 d->tbRemoveFromList->setEnabled(FALSE); 523 d->tbRemoveFromList->setEnabled(FALSE);
535 d->tbAddToList->setEnabled(TRUE); 524 d->tbAddToList->setEnabled(TRUE);
536 525
537 connect( audioView, SIGNAL( itemsSelected( bool ) ), 526 connect( audioView, SIGNAL( itemsSelected( bool ) ),
538 d->tbPlay, SLOT( setEnabled( bool ) ) ); 527 d->tbPlay, SLOT( setEnabled( bool ) ) );
539 528
540 d->tbPlay->setEnabled( audioView->hasSelection() ); 529 d->tbPlay->setEnabled( audioView->hasSelection() );
541 530
542 currentFileListView = audioView; 531 currentFileListView = audioView;
543 } 532 }
544 break; 533 break;
545 case VideoFiles: 534 case VideoFiles:
546 { 535 {
547 videoView->populateView(); 536 videoView->populateView();
548 if( !tbDeletePlaylist->isHidden() ) { 537 if( !tbDeletePlaylist->isHidden() ) {
549 tbDeletePlaylist->hide(); 538 tbDeletePlaylist->hide();
550 } 539 }
551 d->tbRemoveFromList->setEnabled(FALSE); 540 d->tbRemoveFromList->setEnabled(FALSE);
552 d->tbAddToList->setEnabled(TRUE); 541 d->tbAddToList->setEnabled(TRUE);
553 542
554 connect( videoView, SIGNAL( itemsSelected( bool ) ), 543 connect( videoView, SIGNAL( itemsSelected( bool ) ),
555 d->tbPlay, SLOT( setEnabled( bool ) ) ); 544 d->tbPlay, SLOT( setEnabled( bool ) ) );
556 545
557 d->tbPlay->setEnabled( videoView->hasSelection() ); 546 d->tbPlay->setEnabled( videoView->hasSelection() );
558 547
559 currentFileListView = videoView; 548 currentFileListView = videoView;
560 } 549 }
561 break; 550 break;
562 case PlayLists: 551 case PlayLists:
563 { 552 {
564 if( tbDeletePlaylist->isHidden() ) { 553 if( tbDeletePlaylist->isHidden() ) {
565 tbDeletePlaylist->show(); 554 tbDeletePlaylist->show();
566 } 555 }
567 playLists->reread(); 556 playLists->reread();
568 d->tbAddToList->setEnabled(FALSE); 557 d->tbAddToList->setEnabled(FALSE);
569 558
570 d->tbPlay->setEnabled( false ); 559 d->tbPlay->setEnabled( false );
571 } 560 }
572 break; 561 break;
573 }; 562 };
574} 563}
575 564
576 565
577void PlayListWidget::btnPlay(bool b) { 566void PlayListWidget::btnPlay(bool b) {
578// mediaPlayerState->setPlaying(false); 567// mediaPlayerState->setPlaying(false);
579 mediaPlayerState.setPlaying(b); 568 mediaPlayerState.setPlaying(b);
580 insanityBool=FALSE; 569 insanityBool=FALSE;
581} 570}
582 571
583void PlayListWidget::deletePlaylist() { 572void PlayListWidget::deletePlaylist() {
584 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 573 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
585 (tr("You really want to delete\nthis playlist?")), 574 (tr("You really want to delete\nthis playlist?")),
586 (tr("Yes")), (tr("No")), 0 )){ 575 (tr("Yes")), (tr("No")), 0 )){
587 case 0: // Yes clicked, 576 case 0: // Yes clicked,
588 QFile().remove(playLists->selectedDocument().file()); 577 QFile().remove(playLists->selectedDocument().file());
589 QFile().remove(playLists->selectedDocument().linkFile()); 578 QFile().remove(playLists->selectedDocument().linkFile());
590 playLists->reread(); 579 playLists->reread();
591 break; 580 break;
592 case 1: // Cancel 581 case 1: // Cancel
593 break; 582 break;
594 }; 583 };
595} 584}
596 585
597 586
598void PlayListWidget::playSelected() { 587void PlayListWidget::playSelected() {
599 btnPlay( TRUE); 588 btnPlay( TRUE);
600} 589}
601 590
602bool PlayListWidget::inFileListMode() const 591bool PlayListWidget::inFileListMode() const
603{ 592{
604 TabType tab = currentTab(); 593 TabType tab = currentTab();
605 return tab == AudioFiles || tab == VideoFiles; 594 return tab == AudioFiles || tab == VideoFiles;
606} 595}
607 596
608void PlayListWidget::openURL() { 597void PlayListWidget::openURL() {
609 // http://66.28.164.33:2080 598 // http://66.28.164.33:2080
610 // http://somafm.com/star0242.m3u 599 // http://somafm.com/star0242.m3u
611 QString filename, name; 600 QString filename, name;
612 InputDialog *fileDlg; 601 InputDialog *fileDlg;
613 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); 602 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0);
614 fileDlg->exec(); 603 fileDlg->exec();
615 if( fileDlg->result() == 1 ) { 604 if( fileDlg->result() == 1 ) {
616 filename = fileDlg->text(); 605 filename = fileDlg->text();
617 qDebug( "Selected filename is " + filename ); 606 qDebug( "Selected filename is " + filename );
618 // Om3u *m3uList; 607 // Om3u *m3uList;
619 DocLnk lnk; 608 DocLnk lnk;
620 Config cfg( "OpiePlayer" ); 609 Config cfg( "OpiePlayer" );
621 cfg.setGroup("PlayList"); 610 cfg.setGroup("PlayList");
622 611
623 if(filename.left(4) == "http") { 612 if(filename.left(4) == "http") {
624 QString m3uFile, m3uFilePath; 613 QString m3uFile, m3uFilePath;
625 if(filename.find(":",8,TRUE) != -1) { //found a port 614 if(filename.find(":",8,TRUE) != -1) { //found a port
626 m3uFile = filename.left( filename.find( ":",8,TRUE)); 615 m3uFile = filename.left( filename.find( ":",8,TRUE));
627 m3uFile = m3uFile.right( 7); 616 m3uFile = m3uFile.right( 7);
628 } else if(filename.left(4) == "http"){ 617 } else if(filename.left(4) == "http"){
629 m3uFile=filename; 618 m3uFile=filename;
630 m3uFile = m3uFile.right( m3uFile.length() - 7); 619 m3uFile = m3uFile.right( m3uFile.length() - 7);
631 } else{ 620 } else{
632 m3uFile=filename; 621 m3uFile=filename;
633 } 622 }
634 623
635 lnk.setName( filename ); //sets name 624 lnk.setName( filename ); //sets name
636 lnk.setFile( filename ); //sets file name 625 lnk.setFile( filename ); //sets file name
637 626
638// lnk.setIcon("opieplayer2/musicfile"); 627// lnk.setIcon("opieplayer2/musicfile");
639 628
640 d->selectedFiles->addToSelection( lnk ); 629 d->selectedFiles->addToSelection( lnk );
641 writeCurrentM3u(); 630 writeCurrentM3u();
642 d->selectedFiles->setSelectedItem( lnk.name()); 631 d->selectedFiles->setSelectedItem( lnk.name());
643 } 632 }
644 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 633 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
645 readListFromFile( filename ); 634 readListFromFile( filename );
646 } else { 635 } else {
647 lnk.setName( QFileInfo(filename).baseName() ); //sets name 636 lnk.setName( QFileInfo(filename).baseName() ); //sets name
648 lnk.setFile( filename ); //sets file name 637 lnk.setFile( filename ); //sets file name
649 d->selectedFiles->addToSelection( lnk); 638 d->selectedFiles->addToSelection( lnk);
650 writeCurrentM3u(); 639 writeCurrentM3u();
651 d->selectedFiles->setSelectedItem( lnk.name()); 640 d->selectedFiles->setSelectedItem( lnk.name());
652 } 641 }
653 } 642 }
654 643
655 644
656 delete fileDlg; 645 delete fileDlg;
657} 646}
658 647
659 648
660void PlayListWidget::openFile() { 649void PlayListWidget::openFile() {
661 650
662 QString filename, name; 651 QString filename, name;
663 652
664 Config cfg( "OpiePlayer" ); 653 Config cfg( "OpiePlayer" );
665 cfg.setGroup("Dialog"); 654 cfg.setGroup("Dialog");
666 MimeTypes types; 655 MimeTypes types;
667 QStringList audio, video, all; 656 QStringList audio, video, all;
668 audio << "audio/*"; 657 audio << "audio/*";
669 audio << "playlist/plain"; 658 audio << "playlist/plain";
659 audio << "application/ogg";
670 audio << "audio/x-mpegurl"; 660 audio << "audio/x-mpegurl";
671 661
672 video << "video/*"; 662 video << "video/*";
673 video << "playlist/plain"; 663 video << "playlist/plain";
674 664
675 all += audio; 665 all += audio;
676 all += video; 666 all += video;
677 types.insert("All Media Files", all ); 667 types.insert("All Media Files", all );
678 types.insert("Audio", audio ); 668 types.insert("Audio", audio );
679 types.insert("Video", video ); 669 types.insert("Video", video );
680 670
681 QString str = OFileDialog::getOpenFileName( 1, 671 QString str = OFileDialog::getOpenFileName( 1,
682 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 672 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
683 types, 0 ); 673 types, 0 );
684 if(str.left(2) == "//") str=str.right(str.length()-1);
685 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
686 674
675 if(str.left(2) == "//") {
676 str=str.right(str.length()-1);
677 }
678 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() );
687 679
688 if( !str.isEmpty() ) { 680 if( !str.isEmpty() ) {
681
689 qDebug( "Selected filename is " + str ); 682 qDebug( "Selected filename is " + str );
690 filename = str; 683 filename = str;
691 DocLnk lnk; 684 DocLnk lnk;
692 Config cfg( "OpiePlayer" );
693 cfg.setGroup("PlayList");
694 685
695 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 686 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
696 readListFromFile( filename ); 687 readListFromFile( filename );
697 } else { 688 } else {
698 lnk.setName( QFileInfo(filename).baseName() ); //sets name 689 lnk.setName( QFileInfo(filename).baseName() ); //sets name
699 lnk.setFile( filename ); //sets file name 690 lnk.setFile( filename ); //sets file name
700 d->selectedFiles->addToSelection( lnk); 691 d->selectedFiles->addToSelection( lnk );
701 writeCurrentM3u(); 692 writeCurrentM3u();
702 d->selectedFiles->setSelectedItem( lnk.name()); 693 d->selectedFiles->setSelectedItem( lnk.name() );
703 } 694 }
704 } 695 }
705} 696}
706 697
707 698
708void PlayListWidget::readListFromFile( const QString &filename ) { 699void PlayListWidget::readListFromFile( const QString &filename ) {
709 qDebug( "read list filename " + filename ); 700 qDebug( "read list filename " + filename );
710 QFileInfo fi(filename); 701 QFileInfo fi(filename);
711 Om3u *m3uList; 702 Om3u *m3uList;
712 QString s, name; 703 QString s, name;
713 m3uList = new Om3u( filename, IO_ReadOnly ); 704 m3uList = new Om3u( filename, IO_ReadOnly );
714 if(fi.extension(false).find("m3u",0,false) != -1 ) 705 if(fi.extension(false).find("m3u",0,false) != -1 )
715 m3uList->readM3u(); 706 m3uList->readM3u();
716 else if(fi.extension(false).find("pls",0,false) != -1 ) 707 else if(fi.extension(false).find("pls",0,false) != -1 )
717 m3uList->readPls(); 708 m3uList->readPls();
718 709
719 DocLnk lnk; 710 DocLnk lnk;
720 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 711 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
721 s = *it; 712 s = *it;
722 // qDebug(s); 713 // qDebug(s);
723 if(s.left(4)=="http") { 714 if(s.left(4)=="http") {
724 lnk.setName( s ); //sets file name 715 lnk.setName( s ); //sets file name
725 lnk.setIcon("opieplayer2/musicfile"); 716 lnk.setIcon("opieplayer2/musicfile");
726 lnk.setFile( s ); //sets file name 717 lnk.setFile( s ); //sets file name
727 718
728 } else { //is file 719 } else { //is file
729 lnk.setName( QFileInfo(s).baseName()); 720 lnk.setName( QFileInfo(s).baseName());
730 if(s.left(1) != "/") { 721 if(s.left(1) != "/") {
731 722
732 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 723 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
733 } else { 724 } else {
734 lnk.setFile( s); 725 lnk.setFile( s);
735 } 726 }
736 } 727 }
737 d->selectedFiles->addToSelection( lnk ); 728 d->selectedFiles->addToSelection( lnk );
738 } 729 }
739 Config config( "OpiePlayer" ); 730 Config config( "OpiePlayer" );
740 config.setGroup( "PlayList" ); 731 config.setGroup( "PlayList" );
741 732
742 config.writeEntry("CurrentPlaylist",filename); 733 config.writeEntry("CurrentPlaylist",filename);
743 config.write(); 734 config.write();
744 currentPlayList=filename; 735 currentPlayList=filename;
745 736
746 m3uList->close(); 737 m3uList->close();
747 delete m3uList; 738 delete m3uList;
748 739
749 d->selectedFiles->setSelectedItem( s); 740 d->selectedFiles->setSelectedItem( s);
750 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 741 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
751 742
752} 743}
753 744
754// writes current playlist to current m3u file */ 745// writes current playlist to current m3u file */
755 void PlayListWidget::writeCurrentM3u() { 746 void PlayListWidget::writeCurrentM3u() {
756 qDebug("writing to current m3u"); 747 qDebug("writing to current m3u");
757 Config cfg( "OpiePlayer" ); 748 Config cfg( "OpiePlayer" );
758 cfg.setGroup("PlayList"); 749 cfg.setGroup("PlayList");
759 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 750 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
760 751
761 Om3u *m3uList; 752 Om3u *m3uList;
762 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 753 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
763 if( d->selectedFiles->first()) { 754 if( d->selectedFiles->first()) {
764 755
765 do { 756 do {
766 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 757 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
767 m3uList->add( d->selectedFiles->current()->file() ); 758 m3uList->add( d->selectedFiles->current()->file() );
768 } 759 }
769 while ( d->selectedFiles->next() ); 760 while ( d->selectedFiles->next() );
770 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 761 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
771 m3uList->write(); 762 m3uList->write();
772 m3uList->close(); 763 m3uList->close();
773 } 764 }
774 delete m3uList; 765 delete m3uList;
775 766
776 } 767 }
777 768
778 /* 769 /*
779 writes current playlist to m3u file */ 770 writes current playlist to m3u file */
780void PlayListWidget::writem3u() { 771void PlayListWidget::writem3u() {
781 //InputDilog *fileDlg; 772 //InputDilog *fileDlg;
782 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 773 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
783 //fileDlg->exec(); 774 //fileDlg->exec();
784 775
785 Config cfg( "OpiePlayer" ); 776 Config cfg( "OpiePlayer" );
786 cfg.setGroup("Dialog"); 777 cfg.setGroup("Dialog");
787 MimeTypes types; 778 MimeTypes types;
788 QStringList audio, video, all; 779 QStringList audio, video, all;
789 audio << "audio/*"; 780 audio << "audio/*";
790 audio << "playlist/plain"; 781 audio << "playlist/plain";
791 audio << "audio/x-mpegurl"; 782 audio << "audio/x-mpegurl";
792 783
793 video << "video/*"; 784 video << "video/*";
794 video << "playlist/plain"; 785 video << "playlist/plain";
795 786
796 all += audio; 787 all += audio;
797 all += video; 788 all += video;
798 types.insert("All Media Files", all ); 789 types.insert("All Media Files", all );
799 types.insert("Audio", audio ); 790 types.insert("Audio", audio );
800 types.insert("Video", video ); 791 types.insert("Video", video );
801 792
802 QString str = OFileDialog::getOpenFileName( 1, 793 QString str = OFileDialog::getOpenFileName( 1,
803 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 794 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
804 types, 0 ); 795 types, 0 );
805 if(str.left(2) == "//") str=str.right(str.length()-1); 796 if(str.left(2) == "//") str=str.right(str.length()-1);
806 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); 797 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
807 798
808 799
809 QString name, filename, list; 800 QString name, filename, list;
810 Om3u *m3uList; 801 Om3u *m3uList;
811 802
812 if( !str.isEmpty() ) { 803 if( !str.isEmpty() ) {
813 name = str; 804 name = str;
814 // name = fileDlg->text(); 805 // name = fileDlg->text();
815// qDebug( filename ); 806// qDebug( filename );
816 if( name.find("/",0,true) != -1) {// assume they specify a file path 807 if( name.find("/",0,true) != -1) {// assume they specify a file path
817 filename = name; 808 filename = name;
818 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 809 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
819 } 810 }
820 else //otherwise dump it somewhere noticable 811 else //otherwise dump it somewhere noticable
821 filename = QPEApplication::documentDir() + "/" + name; 812 filename = QPEApplication::documentDir() + "/" + name;
822 813
823 if( filename.right( 3 ) != "m3u" ) //needs filename extension 814 if( filename.right( 3 ) != "m3u" ) //needs filename extension
824 filename += ".m3u"; 815 filename += ".m3u";
825 816
826 if( d->selectedFiles->first()) { //ramble through playlist view 817 if( d->selectedFiles->first()) { //ramble through playlist view
827 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); 818 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate);
828 819
829 do { 820 do {
830 m3uList->add( d->selectedFiles->current()->file()); 821 m3uList->add( d->selectedFiles->current()->file());
831 } 822 }
832 while ( d->selectedFiles->next() ); 823 while ( d->selectedFiles->next() );
833 // qDebug( list ); 824 // qDebug( list );
834 m3uList->write(); 825 m3uList->write();
835 m3uList->close(); 826 m3uList->close();
836 delete m3uList; 827 delete m3uList;
837 828
838 //delete fileDlg; 829 //delete fileDlg;
839 830
840 DocLnk lnk; 831 DocLnk lnk;
841 lnk.setFile( filename); 832 lnk.setFile( filename);
842 lnk.setIcon("opieplayer2/playlist2"); 833 lnk.setIcon("opieplayer2/playlist2");
843 lnk.setName( name); //sets file name 834 lnk.setName( name); //sets file name
844 835
845 // qDebug(filename); 836 // qDebug(filename);
846 Config config( "OpiePlayer" ); 837 Config config( "OpiePlayer" );
847 config.setGroup( "PlayList" ); 838 config.setGroup( "PlayList" );
848 839
849 config.writeEntry("CurrentPlaylist",filename); 840 config.writeEntry("CurrentPlaylist",filename);
850 currentPlayList=filename; 841 currentPlayList=filename;
851 842
852 if(!lnk.writeLink()) { 843 if(!lnk.writeLink()) {
853 qDebug("Writing doclink did not work"); 844 qDebug("Writing doclink did not work");
854 } 845 }
855 846
856 setCaption(tr("OpiePlayer: ") + name); 847 setCaption(tr("OpiePlayer: ") + name);
857 } 848 }
858 } 849 }
859} 850}
860 851
861void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 852void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
862 switch ( e->key() ) { 853 switch ( e->key() ) {
863 ////////////////////////////// Zaurus keys 854 ////////////////////////////// Zaurus keys
864 case Key_F9: //activity 855 case Key_F9: //activity
865 // if(audioUI->isHidden()) 856 // if(audioUI->isHidden())
866 // audioUI->showMaximized(); 857 // audioUI->showMaximized();
867 break; 858 break;
868 case Key_F10: //contacts 859 case Key_F10: //contacts
869 // if( videoUI->isHidden()) 860 // if( videoUI->isHidden())
870 // videoUI->showMaximized(); 861 // videoUI->showMaximized();
871 break; 862 break;
872 case Key_F11: //menu 863 case Key_F11: //menu
873 break; 864 break;
874 case Key_F12: //home 865 case Key_F12: //home
875 // doBlank(); 866 // doBlank();
876 break; 867 break;
877 case Key_F13: //mail 868 case Key_F13: //mail
878 // doUnblank(); 869 // doUnblank();
879 break; 870 break;
880 case Key_Q: //add to playlist 871 case Key_Q: //add to playlist
881 addSelected(); 872 addSelected();
882 break; 873 break;
883 case Key_R: //remove from playlist 874 case Key_R: //remove from playlist
884 removeSelected(); 875 removeSelected();
885 break; 876 break;
886 // case Key_P: //play 877 // case Key_P: //play
887 // qDebug("Play"); 878 // qDebug("Play");
888 // playSelected(); 879 // playSelected();
889 // break; 880 // break;
890 case Key_Space: 881 case Key_Space:
891 // playSelected(); puh 882 // playSelected(); puh
892 break; 883 break;
893 case Key_1: 884 case Key_1:
894 tabWidget->setCurrentPage( 0 ); 885 tabWidget->setCurrentPage( 0 );
895 break; 886 break;
896 case Key_2: 887 case Key_2:
897 tabWidget->setCurrentPage( 1 ); 888 tabWidget->setCurrentPage( 1 );
898 break; 889 break;
899 case Key_3: 890 case Key_3:
900 tabWidget->setCurrentPage( 2 ); 891 tabWidget->setCurrentPage( 2 );
901 break; 892 break;
902 case Key_4: 893 case Key_4:
903 tabWidget->setCurrentPage( 3 ); 894 tabWidget->setCurrentPage( 3 );
904 break; 895 break;
905 case Key_Down: 896 case Key_Down:
906 if ( !d->selectedFiles->next() ) 897 if ( !d->selectedFiles->next() )
907 d->selectedFiles->first(); 898 d->selectedFiles->first();
908 break; 899 break;
909 case Key_Up: 900 case Key_Up:
910 if ( !d->selectedFiles->prev() ) 901 if ( !d->selectedFiles->prev() )
911 // d->selectedFiles->last(); 902 // d->selectedFiles->last();
912 break; 903 break;
913 } 904 }
914} 905}
915 906
916void PlayListWidget::pmViewActivated(int index) { 907void PlayListWidget::pmViewActivated(int index) {
917// qDebug("%d", index); 908// qDebug("%d", index);
918 switch(index) { 909 switch(index) {
919 case -16: 910 case -16:
920 { 911 {
921 mediaPlayerState.toggleFullscreen(); 912 mediaPlayerState.toggleFullscreen();
922 bool b=mediaPlayerState.isFullscreen(); 913 bool b=mediaPlayerState.isFullscreen();
923 pmView->setItemChecked( index, b); 914 pmView->setItemChecked( index, b);
924 Config cfg( "OpiePlayer" ); 915 Config cfg( "OpiePlayer" );
925 cfg.writeEntry( "FullScreen", b ); 916 cfg.writeEntry( "FullScreen", b );
926 } 917 }
927 break; 918 break;
928 }; 919 };
929} 920}
930 921
931void PlayListWidget::populateSkinsMenu() { 922void PlayListWidget::populateSkinsMenu() {
932 int item = 0; 923 int item = 0;
933 defaultSkinIndex = 0; 924 defaultSkinIndex = 0;
934 QString skinName; 925 QString skinName;
935 Config cfg( "OpiePlayer" ); 926 Config cfg( "OpiePlayer" );
936 cfg.setGroup("Options" ); 927 cfg.setGroup("Options" );
937 QString skin = cfg.readEntry( "Skin", "default" ); 928 QString skin = cfg.readEntry( "Skin", "default" );
938 929
939 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 930 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
940 skinsDir.setFilter( QDir::Dirs ); 931 skinsDir.setFilter( QDir::Dirs );
941 skinsDir.setSorting(QDir::Name ); 932 skinsDir.setSorting(QDir::Name );
942 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 933 const QFileInfoList *skinslist = skinsDir.entryInfoList();
943 QFileInfoListIterator it( *skinslist ); 934 QFileInfoListIterator it( *skinslist );
944 QFileInfo *fi; 935 QFileInfo *fi;
945 while ( ( fi = it.current() ) ) { 936 while ( ( fi = it.current() ) ) {
946 skinName = fi->fileName(); 937 skinName = fi->fileName();
947// qDebug( fi->fileName() ); 938// qDebug( fi->fileName() );
948 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 939 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
949 item = skinsMenu->insertItem( fi->fileName() ) ; 940 item = skinsMenu->insertItem( fi->fileName() ) ;
950 } 941 }
951 if( skinName == "default" ) { 942 if( skinName == "default" ) {
952 defaultSkinIndex = item; 943 defaultSkinIndex = item;
953 } 944 }
954 if( skinName == skin ) { 945 if( skinName == skin ) {
955 skinsMenu->setItemChecked( item, TRUE ); 946 skinsMenu->setItemChecked( item, TRUE );
956 } 947 }
957 ++it; 948 ++it;
958 } 949 }
959} 950}
960 951
961void PlayListWidget::skinsMenuActivated( int item ) { 952void PlayListWidget::skinsMenuActivated( int item ) {
962 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 953 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
963 skinsMenu->setItemChecked( i, FALSE ); 954 skinsMenu->setItemChecked( i, FALSE );
964 } 955 }
965 skinsMenu->setItemChecked( item, TRUE ); 956 skinsMenu->setItemChecked( item, TRUE );
966 957
967 { 958 {
968 Config cfg( "OpiePlayer" ); 959 Config cfg( "OpiePlayer" );
969 cfg.setGroup("Options"); 960 cfg.setGroup("Options");
970 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 961 cfg.writeEntry("Skin", skinsMenu->text( item ) );
971 } 962 }
972 963
973 emit skinSelected(); 964 emit skinSelected();
974} 965}
975 966
976PlayListWidget::TabType PlayListWidget::currentTab() const 967PlayListWidget::TabType PlayListWidget::currentTab() const
977{ 968{
978 static const TabType indexToTabType[ TabTypeCount ] = 969 static const TabType indexToTabType[ TabTypeCount ] =
979 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 970 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
980 971
981 int index = tabWidget->currentPageIndex(); 972 int index = tabWidget->currentPageIndex();
982 assert( index < TabTypeCount && index >= 0 ); 973 assert( index < TabTypeCount && index >= 0 );
983 974
984 return indexToTabType[ index ]; 975 return indexToTabType[ index ];
985} 976}
986 977
987PlayListWidget::Entry PlayListWidget::currentEntry() const 978PlayListWidget::Entry PlayListWidget::currentEntry() const
988{ 979{
989 if ( currentTab() == CurrentPlayList ) { 980 if ( currentTab() == CurrentPlayList ) {
990 const DocLnk *lnk = current(); 981 const DocLnk *lnk = current();
991 return Entry( lnk->name(), lnk->file() ); 982 return Entry( lnk->name(), lnk->file() );
992 } 983 }
993 984
994 return Entry( currentFileListPathName() ); 985 return Entry( currentFileListPathName() );
995} 986}
996 987
997QString PlayListWidget::currentFileListPathName() const { 988QString PlayListWidget::currentFileListPathName() const {
998 return currentFileListView->currentItem()->text( 3 ); 989 return currentFileListView->currentItem()->text( 3 );
999} 990}
1000 991
1001 992
1002void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 993void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1003 qDebug("qcop message "+msg ); 994 qDebug("qcop message "+msg );
1004 QDataStream stream ( data, IO_ReadOnly ); 995 QDataStream stream ( data, IO_ReadOnly );
1005 if ( msg == "play()" ) { //plays current selection 996 if ( msg == "play()" ) { //plays current selection
1006 btnPlay( true); 997 btnPlay( true);
1007 } else if ( msg == "stop()" ) { 998 } else if ( msg == "stop()" ) {
1008 mediaPlayerState.setPlaying( false); 999 mediaPlayerState.setPlaying( false);
1009 } else if ( msg == "togglePause()" ) { 1000 } else if ( msg == "togglePause()" ) {
1010 mediaPlayerState.togglePaused(); 1001 mediaPlayerState.togglePaused();
1011 } else if ( msg == "next()" ) { //select next in list 1002 } else if ( msg == "next()" ) { //select next in list
1012 mediaPlayerState.setNext(); 1003 mediaPlayerState.setNext();
1013 } else if ( msg == "prev()" ) { //select previous in list 1004 } else if ( msg == "prev()" ) { //select previous in list
1014 mediaPlayerState.setPrev(); 1005 mediaPlayerState.setPrev();
1015 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1006 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1016 mediaPlayerState.toggleLooping(); 1007 mediaPlayerState.toggleLooping();
1017 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1008 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1018 mediaPlayerState.toggleShuffled(); 1009 mediaPlayerState.toggleShuffled();
1019 } else if ( msg == "volUp()" ) { //volume more 1010 } else if ( msg == "volUp()" ) { //volume more
1020// emit moreClicked(); 1011// emit moreClicked();
1021// emit moreReleased(); 1012// emit moreReleased();
1022 } else if ( msg == "volDown()" ) { //volume less 1013 } else if ( msg == "volDown()" ) { //volume less
1023// emit lessClicked(); 1014// emit lessClicked();
1024// emit lessReleased(); 1015// emit lessReleased();
1025 } else if ( msg == "play(QString)" ) { //play this now 1016 } else if ( msg == "play(QString)" ) { //play this now
1026 QString file; 1017 QString file;
1027 stream >> file; 1018 stream >> file;
1028 setDocument( (const QString &) file); 1019 setDocument( (const QString &) file);
1029 } else if ( msg == "add(QString)" ) { //add to playlist 1020 } else if ( msg == "add(QString)" ) { //add to playlist
1030 QString file; 1021 QString file;
1031 stream >> file; 1022 stream >> file;
1032 QFileInfo fileInfo(file); 1023 QFileInfo fileInfo(file);
1033 DocLnk lnk; 1024 DocLnk lnk;
1034 lnk.setName( fileInfo.baseName() ); //sets name 1025 lnk.setName( fileInfo.baseName() ); //sets name
1035 lnk.setFile( file ); //sets file name 1026 lnk.setFile( file ); //sets file name
1036 addToSelection( lnk ); 1027 addToSelection( lnk );
1037 } else if ( msg == "rem(QString)" ) { //remove from playlist 1028 } else if ( msg == "rem(QString)" ) { //remove from playlist
1038 QString file; 1029 QString file;
1039 stream >> file; 1030 stream >> file;
1040 1031
1041 } 1032 }
1042 1033
1043} 1034}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 5230b03..fc305cd 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,143 +1,138 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37
38#include <qpe/applnk.h>
39#include <qtabwidget.h>
40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 38#include <qpushbutton.h>
42#include <qpopupmenu.h> 39#include <qpopupmenu.h>
43#include <qpe/qcopenvelope_qws.h> 40#include <qpe/qcopenvelope_qws.h>
44 41
45#include "playlistwidgetgui.h" 42#include "playlistwidgetgui.h"
46 43
47
48//class PlayListWidgetPrivate;
49class Config; 44class Config;
50class QListViewItem; 45class QListViewItem;
51class QListView; 46class QListView;
52class QPoint; 47class QPoint;
53class QAction; 48class QAction;
54class QLabel; 49class QLabel;
55 50
56class PlayListWidget : public PlayListWidgetGui { 51class PlayListWidget : public PlayListWidgetGui {
57 Q_OBJECT 52 Q_OBJECT
58public: 53public:
59 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 54 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
60 enum { TabTypeCount = 4 }; 55 enum { TabTypeCount = 4 };
61 56
62 struct Entry 57 struct Entry
63 { 58 {
64 Entry( const QString &_name, const QString &_fileName ) 59 Entry( const QString &_name, const QString &_fileName )
65 : name( _name ), file( _fileName ) {} 60 : name( _name ), file( _fileName ) {}
66 Entry( const QString &_fileName ) 61 Entry( const QString &_fileName )
67 : name( _fileName ), file( _fileName ) {} 62 : name( _fileName ), file( _fileName ) {}
68 63
69 QString name; 64 QString name;
70 QString file; 65 QString file;
71 }; 66 };
72 67
73 PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 68 PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
74 ~PlayListWidget(); 69 ~PlayListWidget();
75 70
76 // retrieve the current playlist entry (media file link) 71 // retrieve the current playlist entry (media file link)
77 const DocLnk *current() const; 72 const DocLnk *current() const;
78 void useSelectedDocument(); 73 void useSelectedDocument();
79 TabType currentTab() const; 74 TabType currentTab() const;
80 75
81 Entry currentEntry() const; 76 Entry currentEntry() const;
82 77
83public slots: 78public slots:
84 bool first(); 79 bool first();
85 bool last(); 80 bool last();
86 bool next(); 81 bool next();
87 bool prev(); 82 bool prev();
88 void writeDefaultPlaylist( ); 83 void writeDefaultPlaylist( );
89 QString currentFileListPathName() const; 84 QString currentFileListPathName() const;
90protected: 85protected:
91 QCopChannel * channel; 86 QCopChannel * channel;
92 void keyReleaseEvent( QKeyEvent *e); 87 void keyReleaseEvent( QKeyEvent *e);
93 88
94signals: 89signals:
95 void skinSelected(); 90 void skinSelected();
96 91
97private: 92private:
98 int defaultSkinIndex; 93 int defaultSkinIndex;
99/* void readm3u(const QString &); */ 94/* void readm3u(const QString &); */
100/* void readPls(const QString &); */ 95/* void readPls(const QString &); */
101 void readListFromFile(const QString &); 96 void readListFromFile(const QString &);
102 void initializeStates(); 97 void initializeStates();
103 98
104 bool inFileListMode() const; 99 bool inFileListMode() const;
105 100
106private slots: 101private slots:
107 void qcopReceive(const QCString&, const QByteArray&); 102 void qcopReceive(const QCString&, const QByteArray&);
108 void populateSkinsMenu(); 103 void populateSkinsMenu();
109 void skinsMenuActivated(int); 104 void skinsMenuActivated(int);
110 void pmViewActivated(int); 105 void pmViewActivated(int);
111 void writem3u(); 106 void writem3u();
112 void writeCurrentM3u(); 107 void writeCurrentM3u();
113 void openFile(); 108 void openFile();
114 void openURL(); 109 void openURL();
115 void setDocument( const QString& fileref ); 110 void setDocument( const QString& fileref );
116 void addToSelection( const DocLnk& ); // Add a media file to the playlist 111 void addToSelection( const DocLnk& ); // Add a media file to the playlist
117 void addToSelection( QListViewItem* ); // Add a media file to the playlist 112 void addToSelection( QListViewItem* ); // Add a media file to the playlist
118 void clearList(); 113 void clearList();
119 void addAllToList(); 114 void addAllToList();
120 void addAllMusicToList(); 115 void addAllMusicToList();
121 void addAllVideoToList(); 116 void addAllVideoToList();
122 void saveList(); // Save the playlist 117 void saveList(); // Save the playlist
123 void loadList( const DocLnk &); // Load a playlist 118 void loadList( const DocLnk &); // Load a playlist
124 void playIt( QListViewItem *); 119 void playIt( QListViewItem *);
125 void btnPlay(bool); 120 void btnPlay(bool);
126 void deletePlaylist(); 121 void deletePlaylist();
127 void addSelected(); 122 void addSelected();
128 void removeSelected(); 123 void removeSelected();
129 void tabChanged(QWidget*); 124 void tabChanged(QWidget*);
130 void viewPressed( int, QListViewItem *, const QPoint&, int); 125 void viewPressed( int, QListViewItem *, const QPoint&, int);
131 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 126 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
132 void playSelected(); 127 void playSelected();
133 128
134private: 129private:
135 bool fromSetDocument; 130 bool fromSetDocument;
136 bool insanityBool; 131 bool insanityBool;
137 QString setDocFileRef, currentPlayList; 132 QString setDocFileRef, currentPlayList;
138 int selected; 133 int selected;
139 QListView *currentFileListView; 134 QListView *currentFileListView;
140}; 135};
141 136
142#endif // PLAY_LIST_WIDGET_H 137#endif // PLAY_LIST_WIDGET_H
143 138
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index 5fc0c39..293bf45 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -1,206 +1,194 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpemenubar.h> 34
35#include <qpe/qpetoolbar.h> 35#include <qtoolbar.h>
36#include <qpe/fileselector.h>
37#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
38#include <qpe/storage.h> 37
39#include <qpe/mimetype.h>
40#include <qpe/config.h>
41#include <qpe/global.h>
42#include <qpe/resource.h>
43
44#include <qpopupmenu.h>
45#include <qaction.h>
46#include <qcursor.h>
47#include <qdir.h>
48#include <qlayout.h> 38#include <qlayout.h>
39#include <qmenubar.h>
49 40
50#include "playlistselection.h" 41#include "playlistselection.h"
51#include "playlistwidget.h" 42#include "playlistwidget.h"
52#include "mediaplayerstate.h" 43#include "mediaplayerstate.h"
53#include "inputDialog.h" 44#include "inputDialog.h"
54#include "playlistfileview.h" 45#include "playlistfileview.h"
55 46
56//only needed for the random play
57#include <stdlib.h>
58
59#include "mediaplayerstate.h" 47#include "mediaplayerstate.h"
60 48
61PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) 49PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name )
62 : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { 50 : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) {
63 51
64 d = new PlayListWidgetPrivate; 52 d = new PlayListWidgetPrivate;
65 d->setDocumentUsed = FALSE; 53 d->setDocumentUsed = FALSE;
66 54
67 setBackgroundMode( PaletteButton ); 55 setBackgroundMode( PaletteButton );
68 setToolBarsMovable( FALSE ); 56 setToolBarsMovable( FALSE );
69 57
70 // Create Toolbar 58 // Create Toolbar
71 QPEToolBar *toolbar = new QPEToolBar( this ); 59 QToolBar *toolbar = new QToolBar( this );
72 toolbar->setHorizontalStretchable( TRUE ); 60 toolbar->setHorizontalStretchable( TRUE );
73 61
74 // Create Menubar 62 // Create Menubar
75 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 63 QMenuBar *menu = new QMenuBar( toolbar );
76 menu->setMargin( 0 ); 64 menu->setMargin( 0 );
77 65
78 bar = new QPEToolBar( this ); 66 bar = new QToolBar( this );
79 bar->setLabel( tr( "Play Operations" ) ); 67 bar->setLabel( tr( "Play Operations" ) );
80 68
81 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); 69 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" );
82 tbDeletePlaylist->setFlat( TRUE ); 70 tbDeletePlaylist->setFlat( TRUE );
83 tbDeletePlaylist->setFixedSize( 20, 20 ); 71 tbDeletePlaylist->setFixedSize( 20, 20 );
84 72
85 tbDeletePlaylist->hide(); 73 tbDeletePlaylist->hide();
86 74
87 pmPlayList = new QPopupMenu( this ); 75 pmPlayList = new QPopupMenu( this );
88 menu->insertItem( tr( "File" ), pmPlayList ); 76 menu->insertItem( tr( "File" ), pmPlayList );
89 77
90 pmView = new QPopupMenu( this ); 78 pmView = new QPopupMenu( this );
91 menu->insertItem( tr( "View" ), pmView ); 79 menu->insertItem( tr( "View" ), pmView );
92 pmView->isCheckable(); 80 pmView->isCheckable();
93 81
94 skinsMenu = new QPopupMenu( this ); 82 skinsMenu = new QPopupMenu( this );
95 pmView->insertItem( tr( "Skins" ), skinsMenu ); 83 pmView->insertItem( tr( "Skins" ), skinsMenu );
96 skinsMenu->isCheckable(); 84 skinsMenu->isCheckable();
97 85
98 gammaMenu = new QPopupMenu( this ); 86 gammaMenu = new QPopupMenu( this );
99 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); 87 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu );
100 88
101 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); 89 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu );
102 gammaSlider->setRange( -40, 40 ); 90 gammaSlider->setRange( -40, 40 );
103 gammaSlider->setTickmarks( QSlider::Left ); 91 gammaSlider->setTickmarks( QSlider::Left );
104 gammaSlider->setTickInterval( 20 ); 92 gammaSlider->setTickInterval( 20 );
105 gammaSlider->setFocusPolicy( QWidget::StrongFocus ); 93 gammaSlider->setFocusPolicy( QWidget::StrongFocus );
106 gammaSlider->setValue( 0 ); 94 gammaSlider->setValue( 0 );
107 gammaSlider->setMinimumHeight( 50 ); 95 gammaSlider->setMinimumHeight( 50 );
108 96
109 gammaLCD = new QLCDNumber( 3, gammaMenu ); 97 gammaLCD = new QLCDNumber( 3, gammaMenu );
110 gammaLCD-> setFrameShape ( QFrame::NoFrame ); 98 gammaLCD-> setFrameShape ( QFrame::NoFrame );
111 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); 99 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat );
112 100
113 gammaMenu->insertItem( gammaSlider ); 101 gammaMenu->insertItem( gammaSlider );
114 gammaMenu->insertItem( gammaLCD ); 102 gammaMenu->insertItem( gammaLCD );
115 103
116 connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); 104 connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) );
117 105
118 vbox5 = new QVBox( this ); 106 vbox5 = new QVBox( this );
119 QVBox *vbox4 = new QVBox( vbox5 ); 107 QVBox *vbox4 = new QVBox( vbox5 );
120 QHBox *hbox6 = new QHBox( vbox4 ); 108 QHBox *hbox6 = new QHBox( vbox4 );
121 109
122 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 110 tabWidget = new QTabWidget( hbox6, "tabWidget" );
123 111
124 playListTab = new QWidget( tabWidget, "PlayListTab" ); 112 playListTab = new QWidget( tabWidget, "PlayListTab" );
125 tabWidget->insertTab( playListTab, "Playlist"); 113 tabWidget->insertTab( playListTab, "Playlist");
126 114
127 QGridLayout *Playout = new QGridLayout( playListTab ); 115 QGridLayout *Playout = new QGridLayout( playListTab );
128 Playout->setSpacing( 2); 116 Playout->setSpacing( 2);
129 Playout->setMargin( 2); 117 Playout->setMargin( 2);
130 118
131 // Add the playlist area 119 // Add the playlist area
132 QVBox *vbox3 = new QVBox( playListTab ); 120 QVBox *vbox3 = new QVBox( playListTab );
133 d->playListFrame = vbox3; 121 d->playListFrame = vbox3;
134 122
135 QHBox *hbox2 = new QHBox( vbox3 ); 123 QHBox *hbox2 = new QHBox( vbox3 );
136 d->selectedFiles = new PlayListSelection( hbox2 ); 124 d->selectedFiles = new PlayListSelection( hbox2 );
137 125
138 vbox1 = new QVBox( hbox2 ); 126 vbox1 = new QVBox( hbox2 );
139 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); 127 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
140 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch 128 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
141 129
142 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 130 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
143 131
144 QWidget *aTab; 132 QWidget *aTab;
145 aTab = new QWidget( tabWidget, "aTab" ); 133 aTab = new QWidget( tabWidget, "aTab" );
146 134
147 QGridLayout *Alayout = new QGridLayout( aTab ); 135 QGridLayout *Alayout = new QGridLayout( aTab );
148 Alayout->setSpacing( 2 ); 136 Alayout->setSpacing( 2 );
149 Alayout->setMargin( 2 ); 137 Alayout->setMargin( 2 );
150 // no m3u's here please 138 // no m3u's here please
151 audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", aTab, "Audioview" ); 139 audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" );
152 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 140 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
153 tabWidget->insertTab( aTab, tr( "Audio" ) ); 141 tabWidget->insertTab( aTab, tr( "Audio" ) );
154 142
155 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); 143 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
156 144
157 QWidget *vTab; 145 QWidget *vTab;
158 vTab = new QWidget( tabWidget, "vTab" ); 146 vTab = new QWidget( tabWidget, "vTab" );
159 147
160 QGridLayout *Vlayout = new QGridLayout( vTab ); 148 QGridLayout *Vlayout = new QGridLayout( vTab );
161 Vlayout->setSpacing( 2 ); 149 Vlayout->setSpacing( 2 );
162 Vlayout->setMargin( 2 ); 150 Vlayout->setMargin( 2 );
163 videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); 151 videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" );
164 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 152 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
165 153
166 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); 154 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
167 155
168 tabWidget->insertTab( vTab, tr( "Video" ) ); 156 tabWidget->insertTab( vTab, tr( "Video" ) );
169 157
170 //playlists list 158 //playlists list
171 QWidget *LTab; 159 QWidget *LTab;
172 LTab = new QWidget( tabWidget, "LTab" ); 160 LTab = new QWidget( tabWidget, "LTab" );
173 QGridLayout *Llayout = new QGridLayout( LTab ); 161 QGridLayout *Llayout = new QGridLayout( LTab );
174 Llayout->setSpacing( 2 ); 162 Llayout->setSpacing( 2 );
175 Llayout->setMargin( 2 ); 163 Llayout->setMargin( 2 );
176 164
177 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); 165 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE );
178 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 166 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
179 167
180 tabWidget->insertTab( LTab, tr( "Lists" ) ); 168 tabWidget->insertTab( LTab, tr( "Lists" ) );
181 169
182 setCentralWidget( vbox5 ); 170 setCentralWidget( vbox5 );
183} 171}
184 172
185 173
186 174
187PlayListWidgetGui::~PlayListWidgetGui() { 175PlayListWidgetGui::~PlayListWidgetGui() {
188} 176}
189 177
190void PlayListWidgetGui::setView( char view ) { 178void PlayListWidgetGui::setView( char view ) {
191 if ( view == 'l' ) 179 if ( view == 'l' )
192 showMaximized(); 180 showMaximized();
193 else 181 else
194 hide(); 182 hide();
195} 183}
196 184
197 185
198void PlayListWidgetGui::setActiveWindow() { 186void PlayListWidgetGui::setActiveWindow() {
199 // qDebug("SETTING active window"); 187 // qDebug("SETTING active window");
200 // When we get raised we need to ensure that it switches views 188 // When we get raised we need to ensure that it switches views
201 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); 189 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType();
202 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate 190 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate
203 mediaPlayerState.setDisplayType( origDisplayType ); // now switch back 191 mediaPlayerState.setDisplayType( origDisplayType ); // now switch back
204} 192}
205 193
206 194
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
index c965b0d..c0cd37a 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
@@ -1,133 +1,129 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_GUI_H 34#ifndef PLAY_LIST_WIDGET_GUI_H
35#define PLAY_LIST_WIDGET_GUI_H 35#define PLAY_LIST_WIDGET_GUI_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h>
39#include <qpe/resource.h> 38#include <qpe/resource.h>
40#include <qpe/qpemenubar.h>
41 39
42#include <qtabwidget.h> 40#include <qtabwidget.h>
43#include <qpe/fileselector.h> 41#include <qpe/fileselector.h>
44#include <qpushbutton.h>
45#include <qpopupmenu.h>
46#include <qaction.h> 42#include <qaction.h>
43#include <qtoolbutton.h>
47#include <qslider.h> 44#include <qslider.h>
48#include <qlcdnumber.h> 45#include <qlcdnumber.h>
49 46
50class PlayListWidgetPrivate; 47class PlayListWidgetPrivate;
51class PlayListSelection; 48class PlayListSelection;
52class MediaPlayerState; 49class MediaPlayerState;
53class PlayListFileView; 50class PlayListFileView;
54 51
55class Config; 52class Config;
56class QPEToolBar; 53class QToolBar;
57class QListViewItem; 54class QListViewItem;
58class QListView; 55class QListView;
59class QPoint; 56class QPoint;
60class QAction; 57class QAction;
61class QLabel; 58class QLabel;
62 59
63class PlayListWidgetPrivate { 60class PlayListWidgetPrivate {
64public: 61public:
65 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 62 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
66 QFrame *playListFrame; 63 QFrame *playListFrame;
67 PlayListSelection *selectedFiles; 64 PlayListSelection *selectedFiles;
68 bool setDocumentUsed; 65 bool setDocumentUsed;
69}; 66};
70 67
71 68
72class ToolButton : public QToolButton { 69class ToolButton : public QToolButton {
73 Q_OBJECT 70 Q_OBJECT
74public: 71public:
75 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 72 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
76 : QToolButton( parent, name ) { 73 : QToolButton( parent, name ) {
77 setTextLabel( name ); 74 setTextLabel( name );
78 setPixmap( Resource::loadPixmap( icon ) ); 75 setPixmap( Resource::loadPixmap( icon ) );
79 setAutoRaise( TRUE ); 76 setAutoRaise( TRUE );
80 setFocusPolicy( QWidget::NoFocus ); 77 setFocusPolicy( QWidget::NoFocus );
81 setToggleButton( t ); 78 setToggleButton( t );
82 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 79 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
83 QPEMenuToolFocusManager::manager()->addWidget( this );
84 } 80 }
85}; 81};
86 82
87class MenuItem : public QAction { 83class MenuItem : public QAction {
88 84
89public: 85public:
90 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 86 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
91 : QAction( text, QString::null, 0, 0 ) { 87 : QAction( text, QString::null, 0, 0 ) {
92 connect( this, SIGNAL( activated() ), handler, slot ); 88 connect( this, SIGNAL( activated() ), handler, slot );
93 addTo( parent ); 89 addTo( parent );
94 } 90 }
95}; 91};
96 92
97class PlayListWidgetGui : public QMainWindow { 93class PlayListWidgetGui : public QMainWindow {
98 Q_OBJECT 94 Q_OBJECT
99public: 95public:
100 PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); 96 PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 );
101 ~PlayListWidgetGui(); 97 ~PlayListWidgetGui();
102 98
103protected: 99protected:
104 QTabWidget * tabWidget; 100 QTabWidget * tabWidget;
105 PlayListFileView *audioView, *videoView; 101 PlayListFileView *audioView, *videoView;
106 QListView *playlistView; 102 QListView *playlistView;
107 QLabel *libString; 103 QLabel *libString;
108 QPopupMenu *pmView ; 104 QPopupMenu *pmView ;
109 QPopupMenu *gammaMenu; 105 QPopupMenu *gammaMenu;
110 QSlider *gammaSlider; 106 QSlider *gammaSlider;
111 QLCDNumber *gammaLCD; 107 QLCDNumber *gammaLCD;
112 bool fromSetDocument; 108 bool fromSetDocument;
113 bool insanityBool; 109 bool insanityBool;
114 QString setDocFileRef; 110 QString setDocFileRef;
115 // retrieve the current playlist entry (media file link) 111 // retrieve the current playlist entry (media file link)
116 QPushButton *tbDeletePlaylist; 112 QPushButton *tbDeletePlaylist;
117 int selected; 113 int selected;
118 QPopupMenu *pmPlayList; 114 QPopupMenu *pmPlayList;
119 FileSelector* playLists; 115 FileSelector* playLists;
120 QPopupMenu *skinsMenu; 116 QPopupMenu *skinsMenu;
121 PlayListWidgetPrivate *d; // Private implementation data 117 PlayListWidgetPrivate *d; // Private implementation data
122 QVBox *vbox1; 118 QVBox *vbox1;
123 QVBox *vbox5; 119 QVBox *vbox5;
124 QPEToolBar *bar; 120 QToolBar *bar;
125 QWidget *playListTab; 121 QWidget *playListTab;
126 void setActiveWindow(); // need to handle this to show the right view 122 void setActiveWindow(); // need to handle this to show the right view
127 void setView( char ); 123 void setView( char );
128 124
129 MediaPlayerState &mediaPlayerState; 125 MediaPlayerState &mediaPlayerState;
130}; 126};
131 127
132#endif 128#endif
133 129
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 755cd22..c829e03 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,313 +1,303 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h>
36#include <qpe/config.h>
37
38
39#include <qwidget.h>
40#include <qpainter.h>
41#include <qpixmap.h>
42#include <qslider.h>
43#include <qdrawutil.h>
44#include "videowidget.h" 34#include "videowidget.h"
45#include "mediaplayerstate.h" 35#include "mediaplayerstate.h"
46#include "playlistwidget.h" 36#include "playlistwidget.h"
47 37
48 38
49#ifdef Q_WS_QWS 39#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 40# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 41# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 42# include <qgfxraster_qws.h>
53#endif 43#endif
54 44
55 45
56namespace 46namespace
57{ 47{
58 48
59const int xo = 2; // movable x offset 49const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 50const int yo = 0; // movable y offset
61 51
62const MediaWidget::SkinButtonInfo skinInfo[] = 52const MediaWidget::SkinButtonInfo skinInfo[] =
63{ 53{
64 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 54 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 55 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, 56 { MediaWidget::Next, "fwd", MediaWidget::NormalButton },
67 { MediaWidget::Previous, "back", MediaWidget::NormalButton }, 57 { MediaWidget::Previous, "back", MediaWidget::NormalButton },
68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 58 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 59 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 60 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
71}; 61};
72 62
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 63const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 64
75} 65}
76 66
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 67VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) 68 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
79{ 69{
80 setCaption( tr("OpiePlayer - Video") ); 70 setCaption( tr("OpiePlayer - Video") );
81 71
82 videoFrame = new XineVideoWidget ( this, "Video frame" ); 72 videoFrame = new XineVideoWidget ( this, "Video frame" );
83 73
84 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 74 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
85 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 75 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
86 76
87 slider = 0; 77 slider = 0;
88 78
89 loadSkin(); 79 loadSkin();
90 80
91 setLength( mediaPlayerState.length() ); 81 setLength( mediaPlayerState.length() );
92 setPosition( mediaPlayerState.position() ); 82 setPosition( mediaPlayerState.position() );
93 setFullscreen( mediaPlayerState.isFullscreen() ); 83 setFullscreen( mediaPlayerState.isFullscreen() );
94 setPlaying( mediaPlayerState.isPlaying() ); 84 setPlaying( mediaPlayerState.isPlaying() );
95} 85}
96 86
97 87
98VideoWidget::~VideoWidget() 88VideoWidget::~VideoWidget()
99{ 89{
100} 90}
101 91
102MediaWidget::GUIInfo VideoWidget::guiInfo() 92MediaWidget::GUIInfo VideoWidget::guiInfo()
103{ 93{
104 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); 94 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount );
105} 95}
106 96
107void VideoWidget::resizeEvent( QResizeEvent *e ) { 97void VideoWidget::resizeEvent( QResizeEvent *e ) {
108 int h = height(); 98 int h = height();
109 int w = width(); 99 int w = width();
110 //int Vh = 160; 100 //int Vh = 160;
111 //int Vw = 220; 101 //int Vw = 220;
112 102
113 slider->setFixedWidth( w - 20 ); 103 slider->setFixedWidth( w - 20 );
114 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 104 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
115 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 105 slider->setBackgroundOrigin( QWidget::ParentOrigin );
116 slider->setFocusPolicy( QWidget::NoFocus ); 106 slider->setFocusPolicy( QWidget::NoFocus );
117 slider->setBackgroundPixmap( backgroundPixmap ); 107 slider->setBackgroundPixmap( backgroundPixmap );
118 108
119 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 109 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
120 if(w>h) 110 if(w>h)
121 upperLeftOfButtonMask.ry() = 0; 111 upperLeftOfButtonMask.ry() = 0;
122 else 112 else
123 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 113 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
124 114
125 MediaWidget::resizeEvent( e ); 115 MediaWidget::resizeEvent( e );
126} 116}
127 117
128void VideoWidget::sliderPressed() { 118void VideoWidget::sliderPressed() {
129 videoSliderBeingMoved = TRUE; 119 videoSliderBeingMoved = TRUE;
130} 120}
131 121
132void VideoWidget::sliderReleased() { 122void VideoWidget::sliderReleased() {
133 videoSliderBeingMoved = FALSE; 123 videoSliderBeingMoved = FALSE;
134 if ( slider->width() == 0 ) { 124 if ( slider->width() == 0 ) {
135 return; 125 return;
136 } 126 }
137 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 127 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
138 mediaPlayerState.setPosition( val ); 128 mediaPlayerState.setPosition( val );
139} 129}
140 130
141void VideoWidget::setPosition( long i ) { 131void VideoWidget::setPosition( long i ) {
142 updateSlider( i, mediaPlayerState.length() ); 132 updateSlider( i, mediaPlayerState.length() );
143} 133}
144 134
145 135
146void VideoWidget::setLength( long max ) { 136void VideoWidget::setLength( long max ) {
147 updateSlider( mediaPlayerState.position(), max ); 137 updateSlider( mediaPlayerState.position(), max );
148} 138}
149 139
150void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 140void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
151{ 141{
152 if ( displayType == MediaPlayerState::Video ) { 142 if ( displayType == MediaPlayerState::Video ) {
153 makeVisible(); 143 makeVisible();
154 return; 144 return;
155 } 145 }
156 146
157 // Effectively blank the view next time we show it so it looks nicer 147 // Effectively blank the view next time we show it so it looks nicer
158 scaledWidth = 0; 148 scaledWidth = 0;
159 scaledHeight = 0; 149 scaledHeight = 0;
160 hide(); 150 hide();
161} 151}
162 152
163void VideoWidget::loadSkin() 153void VideoWidget::loadSkin()
164{ 154{
165 loadDefaultSkin( guiInfo() ); 155 loadDefaultSkin( guiInfo() );
166 156
167 delete slider; 157 delete slider;
168 slider = new QSlider( Qt::Horizontal, this ); 158 slider = new QSlider( Qt::Horizontal, this );
169 slider->setMinValue( 0 ); 159 slider->setMinValue( 0 );
170 slider->setMaxValue( 1 ); 160 slider->setMaxValue( 1 );
171 slider->setBackgroundPixmap( backgroundPixmap ); 161 slider->setBackgroundPixmap( backgroundPixmap );
172 //slider->setFocusPolicy( QWidget::NoFocus ); 162 //slider->setFocusPolicy( QWidget::NoFocus );
173 163
174 resizeEvent( 0 ); 164 resizeEvent( 0 );
175} 165}
176 166
177void VideoWidget::updateSlider( long i, long max ) { 167void VideoWidget::updateSlider( long i, long max ) {
178 // Will flicker too much if we don't do this 168 // Will flicker too much if we don't do this
179 if ( max == 0 ) { 169 if ( max == 0 ) {
180 return; 170 return;
181 } 171 }
182 int width = slider->width(); 172 int width = slider->width();
183 int val = int((double)i * width / max); 173 int val = int((double)i * width / max);
184 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 174 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
185 if ( slider->value() != val ) { 175 if ( slider->value() != val ) {
186 slider->setValue( val ); 176 slider->setValue( val );
187 } 177 }
188 if ( slider->maxValue() != width ) { 178 if ( slider->maxValue() != width ) {
189 slider->setMaxValue( width ); 179 slider->setMaxValue( width );
190 } 180 }
191 } 181 }
192} 182}
193 183
194void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 184void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
195 if ( mediaPlayerState.isFullscreen() ) { 185 if ( mediaPlayerState.isFullscreen() ) {
196 mediaPlayerState.setFullscreen( FALSE ); 186 mediaPlayerState.setFullscreen( FALSE );
197 makeVisible(); 187 makeVisible();
198 } 188 }
199 MediaWidget::mouseReleaseEvent( event ); 189 MediaWidget::mouseReleaseEvent( event );
200} 190}
201 191
202void VideoWidget::backToNormal() { 192void VideoWidget::backToNormal() {
203 mediaPlayerState.setFullscreen( FALSE ); 193 mediaPlayerState.setFullscreen( FALSE );
204 makeVisible(); 194 makeVisible();
205 setToggleButton( FullScreen, false ); 195 setToggleButton( FullScreen, false );
206} 196}
207 197
208void VideoWidget::makeVisible() { 198void VideoWidget::makeVisible() {
209 if ( mediaPlayerState.isFullscreen() ) { 199 if ( mediaPlayerState.isFullscreen() ) {
210 showFullScreen(); 200 showFullScreen();
211 resize( qApp->desktop()->size() ); 201 resize( qApp->desktop()->size() );
212 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 202 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
213 203
214 slider->hide(); 204 slider->hide();
215 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 205 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
216 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 206 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
217 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 207 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
218 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 208 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
219 209
220 } else { 210 } else {
221 showNormal(); 211 showNormal();
222 showMaximized(); 212 showMaximized();
223 QWidget *d = QApplication::desktop(); 213 QWidget *d = QApplication::desktop();
224 int w = d->width(); 214 int w = d->width();
225 int h = d->height(); 215 int h = d->height();
226 216
227 if(w>h) { 217 if(w>h) {
228 int newW=(w/2)-(246/2); //this will only work with 320x240 218 int newW=(w/2)-(246/2); //this will only work with 320x240
229 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 219 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
230 } else { 220 } else {
231 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 221 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
232 } 222 }
233 223
234 if ( !mediaPlayerState.isSeekable() ) { 224 if ( !mediaPlayerState.isSeekable() ) {
235 if( !slider->isHidden()) { 225 if( !slider->isHidden()) {
236 slider->hide(); 226 slider->hide();
237 } 227 }
238 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 228 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
239 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 229 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
240 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 230 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
241 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 231 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
242 } else { 232 } else {
243 slider->show(); 233 slider->show();
244 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 234 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
245 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 235 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
246 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 236 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
247 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 237 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
248 } 238 }
249 } 239 }
250} 240}
251 241
252void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 242void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
253 switch ( e->key() ) { 243 switch ( e->key() ) {
254////////////////////////////// Zaurus keys 244////////////////////////////// Zaurus keys
255 case Key_Home: 245 case Key_Home:
256 break; 246 break;
257 case Key_F9: //activity 247 case Key_F9: //activity
258 break; 248 break;
259 case Key_F10: //contacts 249 case Key_F10: //contacts
260// hide(); 250// hide();
261 break; 251 break;
262 case Key_F11: //menu 252 case Key_F11: //menu
263 break; 253 break;
264 case Key_F12: //home 254 case Key_F12: //home
265 break; 255 break;
266 case Key_F13: //mail 256 case Key_F13: //mail
267 break; 257 break;
268 case Key_Space: { 258 case Key_Space: {
269 if(mediaPlayerState.isPlaying()) { 259 if(mediaPlayerState.isPlaying()) {
270 mediaPlayerState.setPlaying(FALSE); 260 mediaPlayerState.setPlaying(FALSE);
271 } else { 261 } else {
272 mediaPlayerState.setPlaying(TRUE); 262 mediaPlayerState.setPlaying(TRUE);
273 } 263 }
274 } 264 }
275 break; 265 break;
276 case Key_Down: 266 case Key_Down:
277// toggleButton(6); 267// toggleButton(6);
278 emit lessClicked(); 268 emit lessClicked();
279 emit lessReleased(); 269 emit lessReleased();
280// toggleButton(6); 270// toggleButton(6);
281 break; 271 break;
282 case Key_Up: 272 case Key_Up:
283// toggleButton(5); 273// toggleButton(5);
284 emit moreClicked(); 274 emit moreClicked();
285 emit moreReleased(); 275 emit moreReleased();
286// toggleButton(5); 276// toggleButton(5);
287 break; 277 break;
288 case Key_Right: 278 case Key_Right:
289 mediaPlayerState.setNext(); 279 mediaPlayerState.setNext();
290 break; 280 break;
291 case Key_Left: 281 case Key_Left:
292 mediaPlayerState.setPrev(); 282 mediaPlayerState.setPrev();
293 break; 283 break;
294 case Key_Escape: 284 case Key_Escape:
295 break; 285 break;
296 286
297 }; 287 };
298} 288}
299 289
300XineVideoWidget* VideoWidget::vidWidget() { 290XineVideoWidget* VideoWidget::vidWidget() {
301 return videoFrame; 291 return videoFrame;
302} 292}
303 293
304 294
305void VideoWidget::setFullscreen ( bool b ) { 295void VideoWidget::setFullscreen ( bool b ) {
306 setToggleButton( FullScreen, b ); 296 setToggleButton( FullScreen, b );
307} 297}
308 298
309 299
310void VideoWidget::setPlaying( bool b) { 300void VideoWidget::setPlaying( bool b) {
311 setToggleButton( Play, b ); 301 setToggleButton( Play, b );
312} 302}
313 303
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 84bc964..8c6896b 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,99 +1,95 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h>
38#include <qimage.h>
39#include <qpixmap.h>
40#include "xinevideowidget.h" 37#include "xinevideowidget.h"
41
42#include "mediawidget.h" 38#include "mediawidget.h"
43 39
44class QPixmap; 40class QPixmap;
45class QSlider; 41class QSlider;
46 42
47class VideoWidget : public MediaWidget { 43class VideoWidget : public MediaWidget {
48 Q_OBJECT 44 Q_OBJECT
49public: 45public:
50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 46 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
51 ~VideoWidget(); 47 ~VideoWidget();
52 48
53 static MediaWidget::GUIInfo guiInfo(); 49 static MediaWidget::GUIInfo guiInfo();
54 50
55 XineVideoWidget* vidWidget(); 51 XineVideoWidget* vidWidget();
56public slots: 52public slots:
57 void updateSlider( long, long ); 53 void updateSlider( long, long );
58 void sliderPressed( ); 54 void sliderPressed( );
59 void sliderReleased( ); 55 void sliderReleased( );
60 void setFullscreen( bool b ); 56 void setFullscreen( bool b );
61 virtual void makeVisible(); 57 virtual void makeVisible();
62 void backToNormal(); 58 void backToNormal();
63 void setPosition( long ); 59 void setPosition( long );
64 60
65public: 61public:
66 virtual void setPlaying( bool b); 62 virtual void setPlaying( bool b);
67 virtual void setLength( long ); 63 virtual void setLength( long );
68 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 64 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
69 65
70 virtual void loadSkin(); 66 virtual void loadSkin();
71 67
72signals: 68signals:
73 void moreClicked(); 69 void moreClicked();
74 void lessClicked(); 70 void lessClicked();
75 void sliderMoved( long ); 71 void sliderMoved( long );
76 void videoResized ( const QSize &s ); 72 void videoResized ( const QSize &s );
77 73
78protected: 74protected:
79 75
80 void resizeEvent( QResizeEvent * ); 76 void resizeEvent( QResizeEvent * );
81 void mouseReleaseEvent( QMouseEvent *event ); 77 void mouseReleaseEvent( QMouseEvent *event );
82 void keyReleaseEvent( QKeyEvent *e); 78 void keyReleaseEvent( QKeyEvent *e);
83 79
84private: 80private:
85// Ticker songInfo; 81// Ticker songInfo;
86 82
87 QSlider *slider; 83 QSlider *slider;
88 QImage *currentFrame; 84 QImage *currentFrame;
89 int scaledWidth; 85 int scaledWidth;
90 int scaledHeight; 86 int scaledHeight;
91 XineVideoWidget* videoFrame; 87 XineVideoWidget* videoFrame;
92 88
93 bool videoSliderBeingMoved; 89 bool videoSliderBeingMoved;
94}; 90};
95 91
96#endif // VIDEO_WIDGET_H 92#endif // VIDEO_WIDGET_H
97 93
98 94
99 95
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 1c489e3..a392f4a 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,272 +1,272 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39
39#include "xinecontrol.h" 40#include "xinecontrol.h"
40#include "mediaplayerstate.h" 41#include "mediaplayerstate.h"
41#include "xinevideowidget.h" 42#include "xinevideowidget.h"
42 43
43XineControl::XineControl( XineVideoWidget *xineWidget, 44XineControl::XineControl( XineVideoWidget *xineWidget,
44 MediaPlayerState &_mediaPlayerState, 45 MediaPlayerState &_mediaPlayerState,
45 QObject *parent, const char *name ) 46 QObject *parent, const char *name )
46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 47 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
47{ 48{
48 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); 49 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget );
49 50
50 init(); 51 init();
51} 52}
52 53
53XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 54XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
54 MediaPlayerState &_mediaPlayerState, 55 MediaPlayerState &_mediaPlayerState,
55 QObject *parent, const char *name ) 56 QObject *parent, const char *name )
56 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 57 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
57{ 58{
58 xine->ensureInitialized(); 59 xine->ensureInitialized();
59 60
60 xine->setWidget( xineWidget ); 61 xine->setWidget( xineWidget );
61 62
62 init(); 63 init();
63} 64}
64 65
65void XineControl::init() 66void XineControl::init()
66{ 67{
67 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 68 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
68 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); 69 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) );
69 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 70 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
70 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 71 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
71 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 72 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
72 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 73 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
73 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 74 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
74 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); 75 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) );
75 76
76 disabledSuspendScreenSaver = FALSE; 77 disabledSuspendScreenSaver = FALSE;
77} 78}
78 79
79XineControl::~XineControl() { 80XineControl::~XineControl() {
80#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 81#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
81 if ( disabledSuspendScreenSaver ) { 82 if ( disabledSuspendScreenSaver ) {
82 disabledSuspendScreenSaver = FALSE; 83 disabledSuspendScreenSaver = FALSE;
83 // Re-enable the suspend mode 84 // Re-enable the suspend mode
84 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 85 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
85 } 86 }
86#endif 87#endif
87 delete libXine; 88 delete libXine;
88} 89}
89 90
90void XineControl::play( const QString& fileName ) { 91void XineControl::play( const QString& fileName ) {
92
91 hasVideoChannel = FALSE; 93 hasVideoChannel = FALSE;
92 hasAudioChannel = FALSE; 94 hasAudioChannel = FALSE;
93 m_fileName = fileName; 95 m_fileName = fileName;
94 96
95 qDebug("<<FILENAME: " + fileName + ">>>>"); 97 qDebug("<<FILENAME: " + fileName + ">>>>");
96 98
97 if ( !libXine->play( fileName, 0, 0 ) ) { 99 if ( !libXine->play( fileName, 0, 0 ) ) {
98 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 100 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
99 // toggle stop so the the play button is reset 101 // toggle stop so the the play button is reset
100 mediaPlayerState.setPlaying( false ); 102 mediaPlayerState.setPlaying( false );
101 return; 103 return;
102 } 104 }
103 mediaPlayerState.setPlaying( true ); 105 mediaPlayerState.setPlaying( true );
104 106
105 MediaPlayerState::DisplayType displayType; 107 MediaPlayerState::DisplayType displayType;
106 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
107 if ( !libXine->hasVideo() ) { 108 if ( !libXine->hasVideo() ) {
108 displayType = MediaPlayerState::Audio; 109 displayType = MediaPlayerState::Audio;
109 qDebug("HAS AUDIO"); 110 qDebug("HAS AUDIO");
110 libXine->setShowVideo( false ); 111 libXine->setShowVideo( false );
111 hasAudioChannel = TRUE; 112 hasAudioChannel = TRUE;
112 } else { 113 } else {
113 displayType = MediaPlayerState::Video; 114 displayType = MediaPlayerState::Video;
114 qDebug("HAS VIDEO"); 115 qDebug("HAS VIDEO");
115 libXine->setShowVideo( true ); 116 libXine->setShowVideo( true );
116 hasVideoChannel = TRUE; 117 hasVideoChannel = TRUE;
117 } 118 }
118 // determine if slider is shown 119 // determine if slider is shown
119 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 120 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
120 121
121 // which gui (video / audio) 122 // which gui (video / audio)
122 mediaPlayerState.setDisplayType( displayType ); 123 mediaPlayerState.setDisplayType( displayType );
123 124
124#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 125#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
125 if ( !disabledSuspendScreenSaver ) { 126 if ( !disabledSuspendScreenSaver ) {
126 disabledSuspendScreenSaver = TRUE; 127 disabledSuspendScreenSaver = TRUE;
127 // Stop the screen from blanking and power saving state 128 // Stop the screen from blanking and power saving state
128 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 129 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
129 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 130 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
130 } 131 }
131#endif 132#endif
132 133
133 length(); 134 length();
134 position(); 135 position();
135} 136}
136 137
137void XineControl::nextMedia() { 138void XineControl::nextMedia() {
138 mediaPlayerState.setNext(); 139 mediaPlayerState.setNext();
139} 140}
140 141
141void XineControl::setGamma( int value ) { 142void XineControl::setGamma( int value ) {
142 libXine->setGamma( value ); 143 libXine->setGamma( value );
143} 144}
144 145
145void XineControl::stop( bool isSet ) { 146void XineControl::stop( bool isSet ) {
146 if ( !isSet ) { 147 if ( !isSet ) {
147 libXine->stop(); 148 libXine->stop();
148 149
149#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 150#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
150 if ( disabledSuspendScreenSaver ) { 151 if ( disabledSuspendScreenSaver ) {
151 disabledSuspendScreenSaver = FALSE; 152 disabledSuspendScreenSaver = FALSE;
152 // Re-enable the suspend mode 153 // Re-enable the suspend mode
153 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 154 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
154 } 155 }
155#endif 156#endif
156 } 157 }
157} 158}
158 159
159/** 160/**
160 * Pause playback 161 * Pause playback
161 * @isSet 162 * @isSet
162 */ 163 */
163void XineControl::pause( bool isSet) { 164void XineControl::pause( bool isSet) {
164 libXine->pause( isSet ); 165 libXine->pause( isSet );
165} 166}
166 167
167 168
168/** 169/**
169 * get current time in playback 170 * get current time in playback
170 */ 171 */
171long XineControl::currentTime() { 172long XineControl::currentTime() {
172 // todo: jede sekunde überprüfen 173 // todo: jede sekunde überprüfen
173 m_currentTime = libXine->currentTime(); 174 m_currentTime = libXine->currentTime();
174 return m_currentTime; 175 return m_currentTime;
175 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 176 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
176} 177}
177 178
178/** 179/**
179 * Set the length of the media file 180 * Set the length of the media file
180 */ 181 */
181void XineControl::length() { 182void XineControl::length() {
182 m_length = libXine->length(); 183 m_length = libXine->length();
183 mediaPlayerState.setLength( m_length ); 184 mediaPlayerState.setLength( m_length );
184} 185}
185 186
186 187
187/** 188/**
188 * Reports the position the xine backend is at right now 189 * Reports the position the xine backend is at right now
189 * @return long the postion in seconds 190 * @return long the postion in seconds
190 */ 191 */
191long XineControl::position() { 192long XineControl::position() {
192 m_position = ( currentTime() ); 193 m_position = ( currentTime() );
193 mediaPlayerState.updatePosition( m_position ); 194 mediaPlayerState.updatePosition( m_position );
194 long emitPos = (long)m_position; 195 long emitPos = (long)m_position;
195 emit positionChanged( emitPos ); 196 emit positionChanged( emitPos );
196 if( mediaPlayerState.isPlaying() ) { 197 if( mediaPlayerState.isPlaying() ) {
197 // needs to be stopped the media is stopped 198 // needs to be stopped the media is stopped
198 QTimer::singleShot( 1000, this, SLOT( position() ) ); 199 QTimer::singleShot( 1000, this, SLOT( position() ) );
199 } 200 }
200 // qDebug("POSITION : %d", m_position);
201 return m_position; 201 return m_position;
202} 202}
203 203
204/** 204/**
205 * Set videoplayback to fullscreen 205 * Set videoplayback to fullscreen
206 * @param isSet 206 * @param isSet
207 */ 207 */
208void XineControl::setFullscreen( bool isSet ) { 208void XineControl::setFullscreen( bool isSet ) {
209 libXine->showVideoFullScreen( isSet ); 209 libXine->showVideoFullScreen( isSet );
210} 210}
211 211
212 212
213QString XineControl::getMetaInfo() { 213QString XineControl::getMetaInfo() {
214 214
215 QString returnString; 215 QString returnString;
216 216
217 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 217 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
218 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 218 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
219 } 219 }
220 220
221 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 221 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
222 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 222 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
223 } 223 }
224 224
225 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 225 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
226 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 226 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
227 } 227 }
228 228
229 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 229 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
230 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 230 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
231 } 231 }
232 232
233 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 233 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
234 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 234 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
235 } 235 }
236 236
237 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 237 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
238 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 238 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
239 } 239 }
240 return returnString; 240 return returnString;
241} 241}
242 242
243QString XineControl::getErrorCode() { 243QString XineControl::getErrorCode() {
244 244
245 int errorCode = libXine->error(); 245 int errorCode = libXine->error();
246 246
247 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); 247 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) );
248 248
249 if ( errorCode == 1 ) { 249 if ( errorCode == 1 ) {
250 return tr( "No input plugin found for this media type" ); 250 return tr( "No input plugin found for this media type" );
251 } else if ( errorCode == 2 ) { 251 } else if ( errorCode == 2 ) {
252 return tr( "No demux plugin found for this media type" ); 252 return tr( "No demux plugin found for this media type" );
253 } else if ( errorCode == 3 ) { 253 } else if ( errorCode == 3 ) {
254 return tr( "Demuxing failed for this media type" ); 254 return tr( "Demuxing failed for this media type" );
255 } else if ( errorCode == 4 ) { 255 } else if ( errorCode == 4 ) {
256 return tr( "Malformed MRL" ); 256 return tr( "Malformed MRL" );
257 } else { 257 } else {
258 return tr( "Some other error" ); 258 return tr( "Some other error" );
259 } 259 }
260} 260}
261 261
262/** 262/**
263 * Seek to a position in the track 263 * Seek to a position in the track
264 * @param second the second to jump to 264 * @param second the second to jump to
265 */ 265 */
266void XineControl::seekTo( long second ) { 266void XineControl::seekTo( long second ) {
267 libXine->seekTo( (int)second ); 267 libXine->seekTo( (int)second );
268} 268}
269 269
270void XineControl::videoResized ( const QSize &s ) { 270void XineControl::videoResized ( const QSize &s ) {
271 libXine->resize( s ); 271 libXine->resize( s );
272} 272}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 0e985d6..3f44f2e 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -1,127 +1,126 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef XINECONTROL_H 34#ifndef XINECONTROL_H
35#define XINECONTROL_H 35#define XINECONTROL_H
36 36
37#include "lib.h" 37#include "lib.h"
38#include <qobject.h>
39 38
40#include "mediaplayerstate.h" 39#include "mediaplayerstate.h"
41 40
42class XineControl : public QObject { 41class XineControl : public QObject {
43 Q_OBJECT 42 Q_OBJECT
44public: 43public:
45 XineControl( XineVideoWidget *xineWidget, 44 XineControl( XineVideoWidget *xineWidget,
46 MediaPlayerState &_mediaPlayerState, 45 MediaPlayerState &_mediaPlayerState,
47 QObject *parent = 0, const char *name =0 ); 46 QObject *parent = 0, const char *name =0 );
48 // note that this constructor takes over ownership of the passed 47 // note that this constructor takes over ownership of the passed
49 // XINE::Lib object. 48 // XINE::Lib object.
50 XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 49 XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
51 MediaPlayerState &_mediaPlayerState, 50 MediaPlayerState &_mediaPlayerState,
52 QObject *parent = 0, const char *name =0 ); 51 QObject *parent = 0, const char *name =0 );
53 ~XineControl(); 52 ~XineControl();
54 53
55 bool hasVideo() const { return hasVideoChannel; } 54 bool hasVideo() const { return hasVideoChannel; }
56 bool hasAudio() const { return hasAudioChannel; } 55 bool hasAudio() const { return hasAudioChannel; }
57 56
58public slots: 57public slots:
59 void play( const QString& fileName ); 58 void play( const QString& fileName );
60 void stop( bool ); 59 void stop( bool );
61 60
62 /** 61 /**
63 * Pause the media stream 62 * Pause the media stream
64 * @param if pause or not 63 * @param if pause or not
65 */ 64 */
66 void pause( bool ); 65 void pause( bool );
67 66
68 /** 67 /**
69 * Set videos fullscreen 68 * Set videos fullscreen
70 * @param yes or no 69 * @param yes or no
71 */ 70 */
72 void setFullscreen( bool ); 71 void setFullscreen( bool );
73 72
74 /** 73 /**
75 * 74 *
76 */ 75 */
77 long currentTime(); 76 long currentTime();
78 void seekTo( long ); 77 void seekTo( long );
79 // get length of media file and set it 78 // get length of media file and set it
80 void length(); 79 void length();
81 long position(); 80 long position();
82 81
83 /** 82 /**
84 * Proceed to the next media file in playlist 83 * Proceed to the next media file in playlist
85 */ 84 */
86 void nextMedia(); 85 void nextMedia();
87 86
88 /** 87 /**
89 * Get as much info about the stream from xine as possible 88 * Get as much info about the stream from xine as possible
90 */ 89 */
91 QString getMetaInfo(); 90 QString getMetaInfo();
92 91
93 /** 92 /**
94 * get the error code and "translate" it for the user 93 * get the error code and "translate" it for the user
95 * 94 *
96 */ 95 */
97 QString getErrorCode(); 96 QString getErrorCode();
98 97
99 98
100 void videoResized ( const QSize &s ); 99 void videoResized ( const QSize &s );
101 100
102 /** 101 /**
103 * Set the gamma value of the video output 102 * Set the gamma value of the video output
104 * @param int value between -100 and 100, 0 is original 103 * @param int value between -100 and 100, 0 is original
105 */ 104 */
106 void setGamma( int ); 105 void setGamma( int );
107 106
108private: 107private:
109 void init(); 108 void init();
110 109
111 XINE::Lib *libXine; 110 XINE::Lib *libXine;
112 long m_currentTime; 111 long m_currentTime;
113 long m_position; 112 long m_position;
114 int m_length; 113 int m_length;
115 QString m_fileName; 114 QString m_fileName;
116 bool disabledSuspendScreenSaver : 1; 115 bool disabledSuspendScreenSaver : 1;
117 bool hasVideoChannel : 1; 116 bool hasVideoChannel : 1;
118 bool hasAudioChannel : 1; 117 bool hasAudioChannel : 1;
119 MediaPlayerState &mediaPlayerState; 118 MediaPlayerState &mediaPlayerState;
120 XineVideoWidget *xineVideoWidget; 119 XineVideoWidget *xineVideoWidget;
121 120
122signals: 121signals:
123 void positionChanged( long ); 122 void positionChanged( long );
124}; 123};
125 124
126 125
127#endif 126#endif
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_arm2.c b/noncore/multimedia/opieplayer2/yuv2rgb_arm2.c
new file mode 100644
index 0000000..cbd32e8
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/yuv2rgb_arm2.c
@@ -0,0 +1,875 @@
1/*
2 * yuv2rgb_arm2.c
3 * Copyright (C) 2002 Frederic 'dilb' Boulay.
4 * All Rights Reserved.
5 *
6 * Author: Frederic Boulay <dilb@handhelds.org>
7 *
8 * you can redistribute this file and/or modify
9 * it under the terms of the GNU General Public License (version 2)
10 * as published by the Free Software Foundation.
11 *
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 *
22 * The function defined in this file, are derived from work done in the xine
23 * project.
24 * In order to improve performance, by strongly reducing memory bandwidth
25 * needed, the scaling functions are merged with the yuv2rgb function.
26 */
27
28#ifdef __arm__
29
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include <inttypes.h>
34
35#include "yuv2rgb.h"
36#include <xine/xineutils.h>
37
38/* Prototypes of the "local" functions available here: */
39/* first prototype, function called when no scaling is needed: */
40static void arm_rgb16_noscale(yuv2rgb_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*);
41/* second prototype, function called when no horizontal scaling is needed: */
42static void arm_rgb16_step_dx_32768(yuv2rgb_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*);
43/* third prototype, function called when scaling is needed for zooming in: */
44static void arm_rgb16_step_dx_inf_32768(yuv2rgb_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*);
45/* fourth prototype, function called when scaling is needed for zooming out (between 1x and 2x): */
46static void arm_rgb16_step_dx_bet_32768_65536(yuv2rgb_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*);
47/* fifth prototype, function called when scaling is needed for zooming out (greater than 2x): */
48static void arm_rgb16_step_dx_sup_65536(yuv2rgb_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*);
49/* sixth prototype, function where the decision of the scaling function to use is made.*/
50static void arm_rgb16_2 (yuv2rgb_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*);
51
52
53
54
55/* extern function: */
56
57/* Function: */
58void yuv2rgb_init_arm (yuv2rgb_factory_t *this)
59/* This function initialise the member yuv2rgb_fun, if everything is right
60the function optimised for the arm target should be used.*/
61 {
62 if (this->swapped)
63 return; /*no swapped pixel output upto now*/
64
65 switch (this->mode)
66 {
67 case MODE_16_RGB:
68 this->yuv2rgb_fun = arm_rgb16_2;
69 break;
70 default:
71 }
72 }
73
74
75
76/* local functions: */
77
78/* Function: */
79static void arm_rgb16_2 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
80/* This function takes care of applying the right scaling conversion
81(yuv2rgb is included in each scaling function!)*/
82 {
83 if (!this->do_scale)
84 {
85 arm_rgb16_noscale(this, _dst, _py, _pu, _pv);
86 return;
87 }
88 if (this->step_dx<32768)
89 {
90 arm_rgb16_step_dx_inf_32768(this, _dst, _py, _pu, _pv);
91 return;
92 }
93 if (this->step_dx==32768)
94 {
95 arm_rgb16_step_dx_32768(this, _dst, _py, _pu, _pv);
96 return;
97 }
98 if (this->step_dx<65536)
99 {
100 arm_rgb16_step_dx_bet_32768_65536(this, _dst, _py, _pu, _pv);
101 return;
102 }
103 arm_rgb16_step_dx_sup_65536(this, _dst, _py, _pu, _pv);
104 return;
105 }
106
107
108/* Function: */
109static void arm_rgb16_noscale(yuv2rgb_t *this, uint8_t * _dst, uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
110/* This function is called when the source and the destination pictures have the same size.
111 In this case, scaling part is not needed.
112 (This code is probably far from being optimised, in particular, the asm
113 generated is not the most efficient, a pure asm version will probably
114 emerge sooner or later). But at least, this version is faster than what
115 was used before.*/
116 {
117 int height;
118
119 height=this->dest_height;
120
121 while (height>0)
122 {
123 uint16_t *r, *g, *b;
124 uint8_t *py, *py2, *pu, *pv;
125 uint16_t *dst, *dst2;
126 int width;
127 register uint8_t p1y, p1u, p1v;
128
129 height-=2;
130 width=this->dest_width;
131 dst = _dst;
132 dst2 = _dst + this->rgb_stride;
133 py = _py;
134 py2 = _py + this->y_stride;
135 pu = _pu;
136 pv = _pv;
137
138 while (width>0)
139 {
140 width-=2;
141 p1y=*py++;
142 p1u=*pu++;
143 p1v=*pv++;
144
145 r = this->table_rV[p1v];
146 g = (void *) (((uint8_t *)this->table_gU[p1u]) + this->table_gV[p1v]);
147 b = this->table_bU[p1u];
148
149 *dst++ = r[p1y] + g[p1y] + b[p1y];
150 p1y=*py++;
151 *dst++ = r[p1y] + g[p1y] + b[p1y];
152
153 p1y=*py2++;
154
155 *dst2++ = r[p1y] + g[p1y] + b[p1y];
156 p1y=*py2++;
157 *dst2++ = r[p1y] + g[p1y] + b[p1y];
158 }
159 _dst += (this->rgb_stride)<<1;
160 _py += (this->y_stride)<<1;
161 _pu += this->uv_stride;
162 _pv += this->uv_stride;
163 }
164 }
165
166
167/* Function: */
168static void arm_rgb16_step_dx_inf_32768(yuv2rgb_t *this, uint8_t * _dst, uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
169/* This function is called when the destination picture is bigger than the size
170 of the source picture.
171*/
172 {
173 int recal_uv, height; /* Note about recal_uv: bit0 is for
174applying scale on u and v, bit1 is for increments of u and v pointers.*/
175 int dy;
176
177 dy = 0;
178 height = this->dest_height;
179 recal_uv=1; // 1 for evaluation of scale_line, needed the first time
180
181 while(1)
182 {
183 register int dxy;
184 register int dxuv;
185 register uint8_t p1y, p2y;
186 uint8_t dest1y, dest2y;
187 register uint8_t p1u, p2u;
188 register uint8_t p1v, p2v;
189 uint8_t dest1u;
190 uint8_t dest1v;
191 int width;
192 uint8_t *u_buffer;
193 uint8_t *v_buffer;
194 uint16_t *r, *g, *b;
195 uint8_t *py, *pu, *pv;
196 uint16_t *dst;
197
198 dxy = 0;
199 dxuv = 0;
200 width = this->dest_width;
201 u_buffer=this->u_buffer;
202 v_buffer=this->v_buffer;
203 dst = (uint16_t*)_dst;
204 py = _py;
205 pu = _pu;
206 pv = _pv;
207
208 //proceed with line scaling/conversion
209 if ((recal_uv&1)!=0)
210 {
211 recal_uv^=1; //reset bit0.
212 // init values:
213 p1u = *pu++;
214 p2u = *pu++;
215 p1v = *pv++;
216 p2v = *pv++;
217 p1y = *py++;
218 p2y = *py++;
219
220 //width loop (compute all data for a line).
221 while (width>0)
222 {
223 // proceed with u and v first (ok, and y too finally :)) [scaling part]:
224 // evaluate 1u, 1v, and 2y
225 //block1_uvy
226 dest1u=p1u + ((dxuv*(p2u-p1u))>>15);
227 dest1v=p1v + ((dxuv*(p2v-p1v))>>15);
228 // as u and v are evaluated, better save them now
229 *u_buffer++ = (uint8_t)dest1u;
230 *v_buffer++ = (uint8_t)dest1v;
231
232 dest1y=p1y + ((dxy*(p2y-p1y))>>15);
233
234 dxuv += this->step_dx;
235 dxy += this->step_dx;
236 if (dxuv > 32768)
237 {
238 dxuv -= 32768;
239 p1u = p2u;
240 p2u = *pu++; //idee pour asm, cf cas then, un merge est possible!!!
241 p1v = p2v;
242 p2v = *pv++;
243 }
244 if (dxy > 32768)
245 {
246 dxy -= 32768;
247 p1y = p2y;
248 p2y = *py++;
249 }
250 //end block1_uvy
251
252 //block2_y
253 dest2y=p1y + ((dxy*(p2y-p1y))>>15);
254
255 dxy += this->step_dx;
256 if (dxy > 32768)
257 {
258 dxy -= 32768;
259 p1y = p2y;
260 p2y = *py++; // idee pour asm, cf cas then, un merge est possible!!!
261 }
262 //end block2_y
263
264 // proceed now with YUV2RGB [conversion part]:
265 // u and v are currently in dest1u and dest1v
266 // the 2 y are in dest1y and dest2y.
267 // RGB(0),DST1(0), RGB(1), DST1(1)
268 r = this->table_rV[dest1v];
269 g = (void *) (((uint8_t *)this->table_gU[dest1u]) + this->table_gV[dest1v]);
270 b = this->table_bU[dest1u];
271
272 *dst++ = r[dest1y] + g[dest1y] + b[dest1y];
273 *dst++ = r[dest2y] + g[dest2y] + b[dest2y];
274
275 width -=2;
276 }
277 }
278 else
279 {
280 // this case is simple, u and v are already evaluated,
281 // Note pour moi: r, g et b pourraient etre reutilises!!
282
283 // init values:
284 p1y = *py++;
285 p2y = *py++;
286
287 //width loop (compute all data for a line).
288 while (width>0)
289 {
290 // proceed with y [scaling part]:
291 // evaluate 2y
292 //block1_y
293 dest1y=p1y + ((dxy*(p2y-p1y))>>15);
294
295 dxy += this->step_dx;
296 if (dxy > 32768)
297 {
298 dxy -= 32768;
299 p1y = p2y;
300 p2y = *py++;
301 }
302 //end block1_uvy
303
304 //block2_y
305 dest2y=p1y + ((dxy*(p2y-p1y))>>15);
306
307 dxy += this->step_dx;
308 if (dxy > 32768)
309 {
310 dxy -= 32768;
311 p1y = p2y;
312 p2y = *py++; // idee pour asm, cf cas then, un merge est possible!!!
313 }
314 //end block2_y
315
316 // proceed now with YUV2RGB [conversion part]:
317 // u and v are currently in dest1u and dest1v
318 // the 2 y are in dest1y and dest2y.
319 // RGB(0),DST1(0)
320 dest1u=*u_buffer++;
321 dest1v=*v_buffer++;
322 r = this->table_rV[dest1v];
323 g = (void *) (((uint8_t *)this->table_gU[dest1u]) + this->table_gV[dest1v]);
324 b = this->table_bU[dest1u];
325
326 *dst++ = r[dest1y] + g[dest1y] + b[dest1y];
327 *dst++ = r[dest2y] + g[dest2y] + b[dest2y];
328
329 width -=2;
330 }
331 }
332 // end of line scaling/conversion
333 dy += this->step_dy;
334 _dst += this->rgb_stride;
335
336 while (--height > 0 && dy < 32768)
337 {
338 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); // *2 because of int8 cast!
339 dy += this->step_dy;
340 _dst += this->rgb_stride;
341 }
342
343
344 if (height <= 0)
345 break;
346
347 do
348 {
349 dy -= 32768;
350 _py += this->y_stride;
351
352 recal_uv^=2; /*bit 0 for reevaluation of scanline, bit 1 for offset.*/
353
354 if ((recal_uv&2)==0)
355 {
356 _pu += this->uv_stride;
357 _pv += this->uv_stride;
358 recal_uv|=1; // if update, then reevaluate scanline!
359 }
360 }
361 while( dy>=32768);
362 }
363 }
364
365
366
367/* Function: */
368static void arm_rgb16_step_dx_32768(yuv2rgb_t *this, uint8_t * _dst, uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
369/* This function is called when the widht of the destination picture is the
370 same as the size of the source picture.
371*/
372 {
373 int recal_uv, height;
374 int dy;
375
376 dy = 0;
377 height=this->dest_height;
378 recal_uv=0;
379
380 while (1)
381 {
382 uint16_t *r, *g, *b;
383 uint8_t *py, *pu, *pv;
384 uint16_t *dst;
385 int width;
386 register uint8_t p1y, p1u, p1v;
387
388 width=this->dest_width;
389 dst = (uint16_t*)_dst;
390 py = _py;
391 pu = _pu;
392 pv = _pv;
393
394 while (width>0)
395 {
396 width-=2;
397 p1y=*py++;
398 p1u=*pu++;
399 p1v=*pv++;
400
401 r = this->table_rV[p1v];
402 g = (void *) (((uint8_t *)this->table_gU[p1u]) + this->table_gV[p1v]);
403 b = this->table_bU[p1u];
404
405 *dst++ = r[p1y] + g[p1y] + b[p1y];
406 p1y=*py++;
407 *dst++ = r[p1y] + g[p1y] + b[p1y];
408 }
409
410
411
412 // end of line scaling/conversion
413 dy += this->step_dy;
414 _dst += this->rgb_stride;
415
416 while (--height > 0 && dy < 32768)
417 {
418 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); // *2 because of int8 cast!
419 dy += this->step_dy;
420 _dst += this->rgb_stride;
421 }
422
423
424 if (height <= 0)
425 break;
426
427 do
428 {
429 dy -= 32768;
430 _py += this->y_stride;
431
432 recal_uv^=2; /*bit 0 for reevaluation of scanline, bit 1 for offset.*/
433
434 if ((recal_uv&2)==0)
435 {
436 _pu += this->uv_stride;
437 _pv += this->uv_stride;
438 recal_uv|=1; // if update, then reevaluate scanline!
439 }
440 }
441 while( dy>=32768);
442 }
443 }
444
445
446
447/* Function: */
448static void arm_rgb16_step_dx_bet_32768_65536(yuv2rgb_t *this, uint8_t * _dst, uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
449/* This function is called when the destination picture is between the size
450 of the source picture, and half its size.
451*/
452 {
453 int recal_uv, height; /* Note about recal_uv: bit0 is for
454applying scale on u and v, bit1 is for increments of u and v pointers.*/
455 int dy;
456
457 dy = 0;
458 height = this->dest_height;
459 recal_uv=1; // 1 for evaluation of scale_line, needed the first time
460
461 while(1)
462 {
463 register int dxy;
464 register int dxuv;
465 register uint8_t p1y, p2y;
466 uint8_t dest1y, dest2y;
467 register uint8_t p1u, p2u;
468 register uint8_t p1v, p2v;
469 uint8_t dest1u;
470 uint8_t dest1v;
471 int width;
472 uint8_t *u_buffer;
473 uint8_t *v_buffer;
474 uint16_t *r, *g, *b;
475 uint8_t *py, *pu, *pv;
476 uint16_t *dst;
477
478 dxy = 0;
479 dxuv = 0;
480 width = this->dest_width;
481 u_buffer=this->u_buffer;
482 v_buffer=this->v_buffer;
483 dst = (uint16_t*)_dst;
484 py = _py;
485 pu = _pu;
486 pv = _pv;
487
488 //proceed with line scaling/conversion
489 if ((recal_uv&1)!=0)
490 {
491 recal_uv^=1; //reset bit0.
492 // init values:
493 p1u = *pu++;
494 p2u = *pu++;
495 p1v = *pv++;
496 p2v = *pv++;
497 p1y = *py++;
498 p2y = *py++;
499
500 //width loop (compute all data for a line).
501 while (width>0)
502 {
503 // proceed with u and v first (ok, and y too finally :)) [scaling part]:
504 // evaluate 1u, 1v, and 2y
505 //block1_uvy
506 dest1u=p1u + ((dxuv*(p2u-p1u))>>15);
507 dest1v=p1v + ((dxuv*(p2v-p1v))>>15);
508 // as u and v are evaluated, better save them now
509 *u_buffer++ = (uint8_t)dest1u;
510 *v_buffer++ = (uint8_t)dest1v;
511
512 dest1y=p1y + ((dxy*(p2y-p1y))>>15);
513
514 dxuv += this->step_dx;
515 dxy += this->step_dx;
516 if (dxuv > 65536)
517 {
518 dxuv -= 65536;
519 p1u = *pu++;
520 p2u = *pu++;
521 p1v = *pv++;
522 p2v = *pv++;
523 }
524 else
525 {
526 dxuv -= 32768;
527 p1u = p2u;
528 p2u = *pu++; //idee pour asm, cf cas then, un merge est possible!!!
529 p1v = p2v;
530 p2v = *pv++;
531 }
532 if (dxy > 65536)
533 {
534 dxy -= 65536;
535 p1y = *py++;
536 p2y = *py++;
537 }
538 else
539 {
540 dxy -= 32768;
541 p1y = p2y;
542 p2y = *py++;
543 }
544 //end block1_uvy
545
546 //block2_y
547 dest2y=p1y + ((dxy*(p2y-p1y))>>15);
548
549 dxy += this->step_dx;
550 if (dxy > 65536)
551 {
552 dxy -= 65536;
553 p1y = *py++;
554 p2y = *py++;
555 }
556 else
557 {
558 dxy -= 32768;
559 p1y = p2y;
560 p2y = *py++; // idee pour asm, cf cas then, un merge est possible!!!
561 }
562 //end block2_y
563
564 // proceed now with YUV2RGB [conversion part]:
565 // u and v are currently in dest1u and dest1v
566 // the 2 y are in dest1y and dest2y.
567 // RGB(0),DST1(0), RGB(1), DST1(1)
568 r = this->table_rV[dest1v];
569 g = (void *) (((uint8_t *)this->table_gU[dest1u]) + this->table_gV[dest1v]);
570 b = this->table_bU[dest1u];
571
572 *dst++ = r[dest1y] + g[dest1y] + b[dest1y];
573 *dst++ = r[dest2y] + g[dest2y] + b[dest2y];
574
575 width -=2;
576 }
577 }
578 else
579 {
580 // this case is simple, u and v are already evaluated,
581 // Note pour moi: r, g et b pourraient etre reutilises!!
582
583 // init values:
584 p1y = *py++;
585 p2y = *py++;
586
587 //width loop (compute all data for a line).
588 while (width>0)
589 {
590 // proceed with y [scaling part]:
591 // evaluate 2y
592 //block1_y
593 dest1y=p1y + ((dxy*(p2y-p1y))>>15);
594
595 dxy += this->step_dx;
596 if (dxy > 65536)
597 {
598 dxy -= 65536;
599 p1y = *py++;
600 p2y = *py++;
601 }
602 else
603 {
604 dxy -= 32768;
605 p1y = p2y;
606 p2y = *py++;
607 }
608 //end block1_uvy
609
610 //block2_y
611 dest2y=p1y + ((dxy*(p2y-p1y))>>15);
612
613 dxy += this->step_dx;
614 if (dxy > 65536)
615 {
616 dxy -= 65536;
617 p1y = *py++;
618 p2y = *py++;
619 }
620 else
621 {
622 dxy -= 32768;
623 p1y = p2y;
624 p2y = *py++; // idee pour asm, cf cas then, un merge est possible!!!
625 }
626 //end block2_y
627
628 // proceed now with YUV2RGB [conversion part]:
629 // u and v are currently in dest1u and dest1v
630 // the 2 y are in dest1y and dest2y.
631 // RGB(0),DST1(0)
632 dest1u=*u_buffer++;
633 dest1v=*v_buffer++;
634 r = this->table_rV[dest1v];
635 g = (void *) (((uint8_t *)this->table_gU[dest1u]) + this->table_gV[dest1v]);
636 b = this->table_bU[dest1u];
637
638 *dst++ = r[dest1y] + g[dest1y] + b[dest1y];
639 *dst++ = r[dest2y] + g[dest2y] + b[dest2y];
640
641 width -=2;
642 }
643 }
644 // end of line scaling/conversion
645 dy += this->step_dy;
646 _dst += this->rgb_stride;
647
648 while (--height > 0 && dy < 32768)
649 {
650 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); // *2 because of int8 cast!
651 dy += this->step_dy;
652 _dst += this->rgb_stride;
653 }
654
655
656 if (height <= 0)
657 break;
658
659 do
660 {
661 dy -= 32768;
662 _py += this->y_stride;
663
664 recal_uv^=2; /*bit 0 for reevaluation of scanline, bit 1 for offset.*/
665
666 if ((recal_uv&2)==0)
667 {
668 _pu += this->uv_stride;
669 _pv += this->uv_stride;
670 recal_uv|=1; // if update, then reevaluate scanline!
671 }
672 }
673 while( dy>=32768);
674 }
675 }
676
677
678
679/* Function: */
680static void arm_rgb16_step_dx_sup_65536(yuv2rgb_t *this, uint8_t * _dst, uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
681/* This function is called when the destination picture is smaller than half
682 the size of the source picture, and half its size.
683*/
684 {
685 int recal_uv, height; /* Note about recal_uv: bit0 is for
686applying scale on u and v, bit1 is for increments of u and v pointers.*/
687 int dy;
688
689 dy = 0;
690 height = this->dest_height;
691 recal_uv=1; // 1 for evaluation of scale_line, needed the first time
692
693 while(1)
694 {
695 register int dxy;
696 register int dxuv;
697 int offdxy, offdxuv;
698 register uint8_t p1y, p2y;
699 uint8_t dest1y, dest2y;
700 register uint8_t p1u, p2u;
701 register uint8_t p1v, p2v;
702 uint8_t dest1u;
703 uint8_t dest1v;
704 int width;
705 uint8_t *u_buffer;
706 uint8_t *v_buffer;
707 uint16_t *r, *g, *b;
708 uint8_t *py, *pu, *pv;
709 uint16_t *dst;
710
711 dxy = 0;
712 dxuv = 0;
713 width = this->dest_width;
714 u_buffer=this->u_buffer;
715 v_buffer=this->v_buffer;
716 dst = (uint16_t*)_dst;
717 py = _py;
718 pu = _pu;
719 pv = _pv;
720
721 //proceed with line scaling/conversion
722 if ((recal_uv&1)!=0)
723 {
724 recal_uv^=1; //reset bit0.
725 // init values:
726 p1u = *pu++;
727 p2u = *pu++;
728 p1v = *pv++;
729 p2v = *pv++;
730 p1y = *py++;
731 p2y = *py++;
732
733 //width loop (compute all data for a line).
734 while (width>0)
735 {
736 // proceed with u and v first (ok, and y too finally :)) [scaling part]:
737 // evaluate 1u, 1v, and 2y
738 //block1_uvy
739 dest1u=p1u + ((dxuv*(p2u-p1u))>>15);
740 dest1v=p1v + ((dxuv*(p2v-p1v))>>15);
741 // as u and v are evaluated, better save them now
742 *u_buffer++ = (uint8_t)dest1u;
743 *v_buffer++ = (uint8_t)dest1v;
744
745 dest1y=p1y + ((dxy*(p2y-p1y))>>15);
746
747 dxuv += this->step_dx;
748 dxy += this->step_dx;
749
750 offdxuv=((dxuv-1)>>15);
751 dxuv-=offdxuv<<15;
752 pu+=offdxuv-2;
753 pv+=offdxuv-2;
754 p1u = *pu++;
755 p2u = *pu++;
756 p1v = *pv++;
757 p2v = *pv++;
758 offdxy=((dxy-1)>>15);
759 dxy-=offdxy<<15;
760 py+=offdxy-2;
761 p1y = *py++;
762 p2y = *py++;
763
764 //block2_y
765 dest2y=p1y + ((dxy*(p2y-p1y))>>15);
766
767 dxy += this->step_dx;
768 offdxy=((dxy-1)>>15);
769 dxy-=offdxy<<15;
770 py+=offdxy-2;
771 p1y = *py++;
772 p2y = *py++;
773
774 // proceed now with YUV2RGB [conversion part]:
775 // u and v are currently in dest1u and dest1v
776 // the 2 y are in dest1y and dest2y.
777 // RGB(0),DST1(0), RGB(1), DST1(1)
778 r = this->table_rV[dest1v];
779 g = (void *) (((uint8_t *)this->table_gU[dest1u]) + this->table_gV[dest1v]);
780 b = this->table_bU[dest1u];
781
782 *dst++ = r[dest1y] + g[dest1y] + b[dest1y];
783 *dst++ = r[dest2y] + g[dest2y] + b[dest2y];
784
785 width -=2;
786 }
787 }
788 else
789 {
790 // this case is simple, u and v are already evaluated,
791 // Note pour moi: r, g et b pourraient etre reutilises!!
792
793 // init values:
794 p1y = *py++;
795 p2y = *py++;
796
797 //width loop (compute all data for a line).
798 while (width>0)
799 {
800 // proceed with y [scaling part]:
801 // evaluate 2y
802 //block1_y
803 dest1y=p1y + ((dxy*(p2y-p1y))>>15);
804
805 dxy += this->step_dx;
806 offdxy=((dxy-1)>>15);
807 dxy-=offdxy<<15;
808 py+=offdxy-2;
809 p1y = *py++;
810 p2y = *py++;
811
812 //end block1_uvy
813
814 //block2_y
815 dest2y=p1y + ((dxy*(p2y-p1y))>>15);
816
817 dxy += this->step_dx;
818 offdxy=((dxy-1)>>15);
819 dxy-=offdxy<<15;
820 py+=offdxy-2;
821 p1y = *py++;
822 p2y = *py++;
823 //end block2_y
824
825 // proceed now with YUV2RGB [conversion part]:
826 // u and v are currently in dest1u and dest1v
827 // the 2 y are in dest1y and dest2y.
828 // RGB(0),DST1(0)
829 dest1u=*u_buffer++;
830 dest1v=*v_buffer++;
831 r = this->table_rV[dest1v];
832 g = (void *) (((uint8_t *)this->table_gU[dest1u]) + this->table_gV[dest1v]);
833 b = this->table_bU[dest1u];
834
835 *dst++ = r[dest1y] + g[dest1y] + b[dest1y];
836 *dst++ = r[dest2y] + g[dest2y] + b[dest2y];
837
838 width -=2;
839 }
840 }
841 // end of line scaling/conversion
842 dy += this->step_dy;
843 _dst += this->rgb_stride;
844
845 while (--height > 0 && dy < 32768)
846 {
847 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); // *2 because of int8 cast!
848 dy += this->step_dy;
849 _dst += this->rgb_stride;
850 }
851
852
853 if (height <= 0)
854 break;
855
856 do
857 {
858 dy -= 32768;
859 _py += this->y_stride;
860
861 recal_uv^=2; /*bit 0 for reevaluation of scanline, bit 1 for offset.*/
862
863 if ((recal_uv&2)==0)
864 {
865 _pu += this->uv_stride;
866 _pv += this->uv_stride;
867 recal_uv|=1; // if update, then reevaluate scanline!
868 }
869 }
870 while( dy>=32768);
871 }
872 }
873
874
875#endif
diff --git a/noncore/multimedia/opierec/opierec.control b/noncore/multimedia/opierec/opierec.control
index 96c1b69..a1a2b7e 100644
--- a/noncore/multimedia/opierec/opierec.control
+++ b/noncore/multimedia/opierec/opierec.control
@@ -1,10 +1,10 @@
1Package: opie-rec 1Package: opierec
2Files: bin/opierec pics/opierec apps/Applications/opierec.desktop 2Files: bin/opierec pics/opierec apps/Applications/opierec.desktop
3Priority: optional 3Priority: optional
4Section: multimedia/applications 4Section: multimedia/applications
5Maintainer: L.J. Potter <ljp@llornkcor.com> 5Maintainer: L.J. Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: 1.5-2 7Depends: opie ($QPE_VERSION)
8Depends: task-opie-minimal
9Description: audio sampling recorder 8Description: audio sampling recorder
10 A simple audio recording/playing application. 9 A simple audio recording/playing application.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 0307d99..147f63d 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,2254 +1,2254 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6 6
7#define DEV_VERSION 7#define DEV_VERSION
8 8
9#include "pixmaps.h" 9#include "pixmaps.h"
10#include "qtrec.h" 10#include "qtrec.h"
11 11
12#include <pthread.h> 12#include <pthread.h>
13 13
14extern "C" { 14extern "C" {
15#include "adpcm.h" 15#include "adpcm.h"
16} 16}
17 17
18#include <sys/soundcard.h> 18#include <sys/soundcard.h>
19 19
20// #if defined (QTOPIA_INTERNAL_FSLP) 20// #if defined (QTOPIA_INTERNAL_FSLP)
21// #include <qpe/lnkproperties.h> 21// #include <qpe/lnkproperties.h>
22// #endif 22// #endif
23 23
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/resource.h> 27#include <qpe/resource.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29 29
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32//#include <qdatetime.h> 32//#include <qdatetime.h>
33#include <qdir.h> 33#include <qdir.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qtabwidget.h> 42#include <qtabwidget.h>
43#include <qtimer.h> 43#include <qtimer.h>
44 44
45#include <errno.h> 45#include <errno.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <mntent.h> 48#include <mntent.h>
49#include <stdio.h> 49#include <stdio.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <sys/ioctl.h> 51#include <sys/ioctl.h>
52#include <sys/soundcard.h> 52#include <sys/soundcard.h>
53#include <sys/stat.h> 53#include <sys/stat.h>
54#include <sys/time.h> 54#include <sys/time.h>
55#include <sys/types.h> 55#include <sys/types.h>
56#include <sys/vfs.h> 56#include <sys/vfs.h>
57#include <unistd.h> 57#include <unistd.h>
58#include<sys/wait.h> 58#include<sys/wait.h>
59#include <sys/signal.h> 59#include <sys/signal.h>
60 60
61//#define ZAURUS 0 61//#define ZAURUS 0
62struct adpcm_state encoder_state; 62struct adpcm_state encoder_state;
63struct adpcm_state decoder_state; 63struct adpcm_state decoder_state;
64 64
65long findPeak(long input ); 65long findPeak(long input );
66//char deviceRates[]; 66//char deviceRates[];
67 67
68typedef struct { 68typedef struct {
69 int sampleRate; 69 int sampleRate;
70 /* int fragSize; */ 70 /* int fragSize; */
71 /* int blockSize; */ 71 /* int blockSize; */
72 int resolution; //bitrate 72 int resolution; //bitrate
73 int channels; //number of channels 73 int channels; //number of channels
74 int fd; //file descriptor 74 int fd; //file descriptor
75 int sd; //sound device descriptor 75 int sd; //sound device descriptor
76 int numberSamples; //total number of samples 76 int numberSamples; //total number of samples
77 int SecondsToRecord; // number of seconds that should be recorded 77 int SecondsToRecord; // number of seconds that should be recorded
78 float numberOfRecordedSeconds; //total number of samples recorded 78 float numberOfRecordedSeconds; //total number of samples recorded
79 int samplesToRecord; //number of samples to be recorded 79 int samplesToRecord; //number of samples to be recorded
80 int inVol; //input volume 80 int inVol; //input volume
81 int outVol; //output volume 81 int outVol; //output volume
82 int format; //wavfile format PCM.. ADPCM 82 int format; //wavfile format PCM.. ADPCM
83 const char *fileName; //name of fiel to be played/recorded 83 const char *fileName; //name of fiel to be played/recorded
84} fileParameters; 84} fileParameters;
85 85
86fileParameters filePara; 86fileParameters filePara;
87 87
88bool monitoring, recording; 88bool monitoring, recording;
89bool stopped; 89bool stopped;
90QLabel *timeLabel; 90QLabel *timeLabel;
91QSlider *timeSlider; 91QSlider *timeSlider;
92int sd; 92int sd;
93 93
94#if defined(QT_QWS_EBX) 94#if defined(QT_QWS_EBX)
95#define DSPSTROUT "/dev/dsp" 95#define DSPSTROUT "/dev/dsp"
96#define DSPSTRIN "/dev/dsp1" 96#define DSPSTRIN "/dev/dsp1"
97#define DSPSTRMIXEROUT "/dev/mixer" 97#define DSPSTRMIXEROUT "/dev/mixer"
98#define DSPSTRMIXERIN "/dev/mixer1" 98#define DSPSTRMIXERIN "/dev/mixer1"
99#else 99#else
100#define DSPSTROUT "/dev/dsp" 100#define DSPSTROUT "/dev/dsp"
101#define DSPSTRIN "/dev/dsp" 101#define DSPSTRIN "/dev/dsp"
102#define DSPSTRMIXERIN "/dev/mixer" 102#define DSPSTRMIXERIN "/dev/mixer"
103#define DSPSTRMIXEROUT "/dev/mixer" 103#define DSPSTRMIXEROUT "/dev/mixer"
104#endif 104#endif
105 105
106// threaded recording 106// threaded recording
107void quickRec() { 107void quickRec() {
108//void QtRec::quickRec() { 108//void QtRec::quickRec() {
109 109
110 qDebug("%d", 110 qDebug("%d",
111 filePara.numberSamples/filePara.sampleRate * filePara.channels); 111 filePara.numberSamples/filePara.sampleRate * filePara.channels);
112 qDebug("samples %d, rate %d, channels %d", 112 qDebug("samples %d, rate %d, channels %d",
113 filePara.numberSamples, filePara.sampleRate, filePara.channels); 113 filePara.numberSamples, filePara.sampleRate, filePara.channels);
114 114
115 int total = 0; // Total number of bytes read in so far. 115 int total = 0; // Total number of bytes read in so far.
116 int bytesWritten, number; 116 int bytesWritten, number;
117 117
118 count_info info; 118 count_info info;
119 119
120 bytesWritten=0; 120 bytesWritten=0;
121 number=0; 121 number=0;
122 QString num, timeString; 122 QString num, timeString;
123 int level=0; 123 int level=0;
124 int threshold=0; 124 int threshold=0;
125 // if(limit != 0) 125 // if(limit != 0)
126 // t->start( ( limit +.3) , true); 126 // t->start( ( limit +.3) , true);
127 127
128 recording = true; 128 recording = true;
129 //rate=filePara.sampleRate; 129 //rate=filePara.sampleRate;
130 int bits = filePara.resolution; 130 int bits = filePara.resolution;
131 qDebug("bits %d", bits); 131 qDebug("bits %d", bits);
132// if( filePara.format==WAVE_FORMAT_DVI_ADPCM) 132// if( filePara.format==WAVE_FORMAT_DVI_ADPCM)
133// else 133// else
134 audio_buf_info inInfo; 134 audio_buf_info inInfo;
135 ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo); 135 ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo);
136 qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal); 136 qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal);
137 137
138 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 138 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
139 qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); 139 qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord);
140 qDebug("samples to record %d", filePara.samplesToRecord); 140 qDebug("samples to record %d", filePara.samplesToRecord);
141 qDebug("%d", filePara.sd); 141 qDebug("%d", filePara.sd);
142 level=7; 142 level=7;
143 threshold=0; 143 threshold=0;
144 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 144 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
145 timeLabel->setText( timeString+ " seconds"); 145 timeLabel->setText( timeString+ " seconds");
146 146
147 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 147 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
148 qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); 148 qDebug("start recording WAVE_FORMAT_DVI_ADPCM");
149 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 149 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
150 char abuf[BUFSIZE/2]; 150 char abuf[BUFSIZE/2];
151 short sbuf[BUFSIZE]; 151 short sbuf[BUFSIZE];
152 short sbuf2[BUFSIZE]; 152 short sbuf2[BUFSIZE];
153 memset( abuf,0,BUFSIZE/2); 153 memset( abuf,0,BUFSIZE/2);
154 memset( sbuf,0,BUFSIZE); 154 memset( sbuf,0,BUFSIZE);
155 memset( sbuf2,0,BUFSIZE); 155 memset( sbuf2,0,BUFSIZE);
156 156
157 for(;;) { 157 for(;;) {
158 if (stopped) { 158 if (stopped) {
159 qDebug("quickRec:: stopped"); 159 qDebug("quickRec:: stopped");
160 break; // stop if playing was set to false 160 break; // stop if playing was set to false
161// return; 161// return;
162 } 162 }
163 163
164 number=::read( filePara.sd, sbuf, BUFSIZE); 164 number=::read( filePara.sd, sbuf, BUFSIZE);
165 165
166 if(number <= 0) { 166 if(number <= 0) {
167 perror("recording error "); 167 perror("recording error ");
168 qDebug( "%s %d", filePara.fileName, number); 168 qDebug( "%s %d", filePara.fileName, number);
169 // errorStop(); 169 // errorStop();
170 recording=stopped=false; 170 recording=stopped=false;
171// QMessageBox::message("Note", 171// QMessageBox::message("Note",
172// "Error recording to file\n%s", 172// "Error recording to file\n%s",
173// filePara.fileName); 173// filePara.fileName);
174 return; 174 return;
175 } 175 }
176 //if(stereo == 2) { 176 //if(stereo == 2) {
177// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 177// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
178 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 178 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
179 179
180 bytesWritten = ::write( filePara.fd , abuf, number/4); 180 bytesWritten = ::write( filePara.fd , abuf, number/4);
181 181
182 long peak; 182 long peak;
183 for (int i = 0; i < number; i++) 183 for (int i = 0; i < number; i++)
184 { //since Z is mono do normally 184 { //since Z is mono do normally
185 peak = findPeak((long)sbuf[i]); 185 peak = findPeak((long)sbuf[i]);
186 printf("peak %ld\r",peak); 186 printf("peak %ld\r",peak);
187 fflush(stdout); 187 fflush(stdout);
188 } 188 }
189 189
190 190
191 //------------->>>> out to file 191 //------------->>>> out to file
192 // if(filePara.channels==1) 192 // if(filePara.channels==1)
193 // total += bytesWritten/2; //mono 193 // total += bytesWritten/2; //mono
194 // else 194 // else
195 total += bytesWritten; 195 total += bytesWritten;
196 filePara.numberSamples = total; 196 filePara.numberSamples = total;
197// if( total >= filePara.samplesToRecord) 197// if( total >= filePara.samplesToRecord)
198// timeSlider->setValue(0); 198// timeSlider->setValue(0);
199// else if( filePara.SecondsToRecord !=0) 199// else if( filePara.SecondsToRecord !=0)
200 timeSlider->setValue( total); 200 timeSlider->setValue( total);
201 201
202 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; 202 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;
203 203
204// printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n", 204// printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n",
205// number, 205// number,
206// bytesWritten , 206// bytesWritten ,
207// total, 207// total,
208// filePara.sampleRate, 208// filePara.sampleRate,
209// filePara.numberOfRecordedSeconds); 209// filePara.numberOfRecordedSeconds);
210// fflush(stdout); 210// fflush(stdout);
211 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); 211 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info);
212// qDebug("%d, %d", info.bytes, (info.bytes / filePara.sampleRate) / 2); 212// qDebug("%d, %d", info.bytes, (info.bytes / filePara.sampleRate) / 2);
213 213
214 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 214 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
215 timeLabel->setText( timeString + " seconds"); 215 timeLabel->setText( timeString + " seconds");
216 216
217 qApp->processEvents(); 217 qApp->processEvents();
218 if( total >= filePara.samplesToRecord) 218 if( total >= filePara.samplesToRecord)
219 break; 219 break;
220 } 220 }
221 } else { 221 } else {
222 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 222 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
223 qDebug("start recording WAVE_FORMAT_PCM"); 223 qDebug("start recording WAVE_FORMAT_PCM");
224 short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; 224 short inbuffer[BUFSIZE], outbuffer[BUFSIZE];
225 memset( inbuffer,0,BUFSIZE); 225 memset( inbuffer,0,BUFSIZE);
226 memset( outbuffer,0,BUFSIZE); 226 memset( outbuffer,0,BUFSIZE);
227 for(;;) { 227 for(;;) {
228 if (stopped) { 228 if (stopped) {
229 qDebug("quickRec:: stopped"); 229 qDebug("quickRec:: stopped");
230 break; // stop if playing was set to false 230 break; // stop if playing was set to false
231 return; 231 return;
232 } 232 }
233 233
234 number=::read( filePara.sd, inbuffer, BUFSIZE); 234 number=::read( filePara.sd, inbuffer, BUFSIZE);
235 235
236 if(number <= 0) { 236 if(number <= 0) {
237 perror("recording error "); 237 perror("recording error ");
238 qDebug( filePara.fileName); 238 qDebug( filePara.fileName);
239 recording=stopped=false; 239 recording=stopped=false;
240 // errorStop(); 240 // errorStop();
241// QMessageBox::message("Note","error recording to file\n%s",filePara.fileName); 241// QMessageBox::message("Note","error recording to file\n%s",filePara.fileName);
242 return;// false; 242 return;// false;
243 } 243 }
244/* for (int i=0;i< number;i++) { //2*i is left channel 244/* for (int i=0;i< number;i++) { //2*i is left channel
245 245
246outbuffer[i]=inbuffer[i]>>1; // no clippy, please 246outbuffer[i]=inbuffer[i]>>1; // no clippy, please
247}*/ 247}*/
248 bytesWritten = ::write( filePara.fd , inbuffer, number); 248 bytesWritten = ::write( filePara.fd , inbuffer, number);
249//------------->>>> out to file 249//------------->>>> out to file
250 if(bytesWritten < 0) { 250 if(bytesWritten < 0) {
251 // errorStop(); 251 // errorStop();
252 perror("File writing error "); 252 perror("File writing error ");
253 return;// false; 253 return;// false;
254 } 254 }
255 255
256 // if(filePara.channels==1) 256 // if(filePara.channels==1)
257 // total += bytesWritten/2; //mono 257 // total += bytesWritten/2; //mono
258 // else 258 // else
259 total += bytesWritten; 259 total += bytesWritten;
260 long peak; 260 long peak;
261 for (int i = 0; i < number; i++) 261 for (int i = 0; i < number; i++)
262 { //since Z is mono do normally 262 { //since Z is mono do normally
263 peak = findPeak((long)inbuffer[i]); 263 peak = findPeak((long)inbuffer[i]);
264 printf("peak %ld\r",peak); 264 printf("peak %ld\r",peak);
265 fflush(stdout); 265 fflush(stdout);
266 } 266 }
267 267
268 268
269 filePara.numberSamples = total; 269 filePara.numberSamples = total;
270 if(filePara.SecondsToRecord !=0) 270 if(filePara.SecondsToRecord !=0)
271 timeSlider->setValue( total); 271 timeSlider->setValue( total);
272// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); 272// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total);
273// fflush(stdout); 273// fflush(stdout);
274 274
275 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); 275 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info);
276// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2); 276// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2);
277 277
278 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 278 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
279 279
280 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 280 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
281 timeLabel->setText( timeString + " seconds"); 281 timeLabel->setText( timeString + " seconds");
282 282
283 qApp->processEvents(); 283 qApp->processEvents();
284 if( total >= filePara.samplesToRecord) 284 if( total >= filePara.samplesToRecord)
285 break; 285 break;
286 } 286 }
287 } //end main loop 287 } //end main loop
288 288
289 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 289 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
290 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; 290 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE];
291 memset( unsigned_inbuffer, 0, BUFSIZE); 291 memset( unsigned_inbuffer, 0, BUFSIZE);
292 memset( unsigned_outbuffer, 0, BUFSIZE); 292 memset( unsigned_outbuffer, 0, BUFSIZE);
293 293
294 for(;;) { 294 for(;;) {
295 if (stopped) { 295 if (stopped) {
296 qDebug("quickRec:: stopped"); 296 qDebug("quickRec:: stopped");
297 break; // stop if playing was set to false 297 break; // stop if playing was set to false
298 } 298 }
299 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 299 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
300//-------------<<<< in from device 300//-------------<<<< in from device
301// val = (data ^ 0x80) << 8; 301// val = (data ^ 0x80) << 8;
302 302
303//unsigned_outbuffer = (unsigned_inbuffer ^ 0x80) << 8; 303//unsigned_outbuffer = (unsigned_inbuffer ^ 0x80) << 8;
304 304
305// if(number <= 0) { 305// if(number <= 0) {
306// perror("recording error "); 306// perror("recording error ");
307// qDebug(filePara.fileName); 307// qDebug(filePara.fileName);
308// // errorStop(); 308// // errorStop();
309// QMessageBox::message("Note","error recording"); 309// QMessageBox::message("Note","error recording");
310// return;// false; 310// return;// false;
311// } 311// }
312// for (int i=0;i< number;i++) { //2*i is left channel 312// for (int i=0;i< number;i++) { //2*i is left channel
313// unsigned_outbuffer[i]=unsigned_inbuffer[i]>>1; // no clippy, please 313// unsigned_outbuffer[i]=unsigned_inbuffer[i]>>1; // no clippy, please
314// } 314// }
315 315
316 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 316 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
317 317
318//------------->>>> out to file 318//------------->>>> out to file
319 if(bytesWritten < 0) { 319 if(bytesWritten < 0) {
320 recording=stopped=false; 320 recording=stopped=false;
321 // errorStop(); 321 // errorStop();
322 QMessageBox::message("Note","There was a problem\nwriting to the file"); 322 QMessageBox::message("Note","There was a problem\nwriting to the file");
323 perror("File writing error "); 323 perror("File writing error ");
324 return;// false; 324 return;// false;
325 } 325 }
326 total += bytesWritten; 326 total += bytesWritten;
327 filePara.numberSamples = total; 327 filePara.numberSamples = total;
328 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); 328 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total);
329 // fflush(stdout); 329 // fflush(stdout);
330 if(filePara.SecondsToRecord !=0) 330 if(filePara.SecondsToRecord !=0)
331 timeSlider->setValue( total); 331 timeSlider->setValue( total);
332 332
333 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 333 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
334 334
335 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 335 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
336 timeLabel->setText( timeString + " seconds"); 336 timeLabel->setText( timeString + " seconds");
337 337
338 qApp->processEvents(); 338 qApp->processEvents();
339 if( total >= filePara.samplesToRecord) 339 if( total >= filePara.samplesToRecord)
340 break; 340 break;
341 } //end main loop 341 } //end main loop
342 } 342 }
343// qDebug("Final %d, %d", filePara.samplesToRecord , filePara.numberOfRecordedSeconds); 343// qDebug("Final %d, %d", filePara.samplesToRecord , filePara.numberOfRecordedSeconds);
344} /// END quickRec() 344} /// END quickRec()
345 345
346// threaded play 346// threaded play
347void playIt() { 347void playIt() {
348 348
349} 349}
350 350
351 351
352 352
353/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> 353/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
354/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> 354/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
355 355
356QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 356QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
357 : QWidget( parent, name, fl ) { 357 : QWidget( parent, name, fl ) {
358 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device 358 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
359 // autoMute=TRUE; 359 // autoMute=TRUE;
360// QPEApplication::grabKeyboard(); 360// QPEApplication::grabKeyboard();
361 361
362// signal(SIGPIPE, SIG_IGN); 362// signal(SIGPIPE, SIG_IGN);
363 363
364 if ( !name ) 364 if ( !name )
365 setName( "OpieRec" ); 365 setName( "OpieRec" );
366 init(); 366 init();
367 initConfig(); 367 initConfig();
368 initConnections(); 368 initConnections();
369 renameBox = 0; 369 renameBox = 0;
370 370
371// open sound device to get volumes 371// open sound device to get volumes
372 soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false); 372 soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false);
373 373
374// soundDevice->setDeviceFormat(AFMT_S16_LE); 374// soundDevice->setDeviceFormat(AFMT_S16_LE);
375// soundDevice->setDeviceChannels(1); 375// soundDevice->setDeviceChannels(1);
376// soundDevice->setDeviceRate( 22050); 376// soundDevice->setDeviceRate( 22050);
377 377
378 getInVol(); 378 getInVol();
379 getOutVol(); 379 getOutVol();
380 380
381 soundDevice->closeDevice( true); 381 soundDevice->closeDevice( true);
382 soundDevice->sd=-1; 382 soundDevice->sd=-1;
383 soundDevice=0; 383 soundDevice=0;
384 wavFile=0; 384 wavFile=0;
385 385
386 if(soundDevice) delete soundDevice; 386 if(soundDevice) delete soundDevice;
387 387
388 initIconView(); 388 initIconView();
389 389
390 if(autoMute) 390 if(autoMute)
391 doMute(true); 391 doMute(true);
392 ListView1->setFocus(); 392 ListView1->setFocus();
393 playing=false; 393 playing=false;
394} 394}
395 395
396QtRec::~QtRec() { 396QtRec::~QtRec() {
397 397
398} 398}
399 399
400void QtRec::cleanUp() { 400void QtRec::cleanUp() {
401 401
402 if(!stopped) { 402 if(!stopped) {
403 stopped=true; 403 stopped=true;
404 endRecording(); 404 endRecording();
405 } 405 }
406 406
407 ListView1->clear(); 407 ListView1->clear();
408 408
409 if(autoMute) 409 if(autoMute)
410 doMute(false); 410 doMute(false);
411 411
412 if(wavFile) delete wavFile; 412 if(wavFile) delete wavFile;
413// if(soundDevice) delete soundDevice; 413// if(soundDevice) delete soundDevice;
414 414
415// QPEApplication::grabKeyboard(); 415// QPEApplication::grabKeyboard();
416// QPEApplication::ungrabKeyboard(); 416// QPEApplication::ungrabKeyboard();
417} 417}
418 418
419void QtRec::init() { 419void QtRec::init() {
420 420
421 needsStereoOut=false; 421 needsStereoOut=false;
422 QPixmap image3( ( const char** ) image3_data ); 422 QPixmap image3( ( const char** ) image3_data );
423 QPixmap image4( ( const char** ) image4_data ); 423 QPixmap image4( ( const char** ) image4_data );
424 QPixmap image6( ( const char** ) image6_data ); 424 QPixmap image6( ( const char** ) image6_data );
425 425
426 stopped=true; 426 stopped=true;
427 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 427 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
428 QGridLayout *layout = new QGridLayout( this ); 428 QGridLayout *layout = new QGridLayout( this );
429 layout->setSpacing( 2); 429 layout->setSpacing( 2);
430 layout->setMargin( 2); 430 layout->setMargin( 2);
431 431
432 TabWidget = new QTabWidget( this, "TabWidget" ); 432 TabWidget = new QTabWidget( this, "TabWidget" );
433 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); 433 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7);
434 // TabWidget->setTabShape(QTabWidget::Triangular); 434 // TabWidget->setTabShape(QTabWidget::Triangular);
435 435
436 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 436 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
437 tab = new QWidget( TabWidget, "tab" ); 437 tab = new QWidget( TabWidget, "tab" );
438 438
439 QGridLayout *layout1 = new QGridLayout( tab); 439 QGridLayout *layout1 = new QGridLayout( tab);
440 layout1->setSpacing( 2); 440 layout1->setSpacing( 2);
441 layout1->setMargin( 2); 441 layout1->setMargin( 2);
442 442
443 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 443 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
444 // timeSlider->setFixedWidth(150); 444 // timeSlider->setFixedWidth(150);
445 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 445 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
446// timeSlider->setTickmarks(QSlider::Above); 446// timeSlider->setTickmarks(QSlider::Above);
447 447
448 timeLabel = new QLabel( tab, "TimeLabel" ); 448 timeLabel = new QLabel( tab, "TimeLabel" );
449 layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 449 layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
450 450
451 playLabel2 = new QLabel(tab, "PlayLabel2" ); 451 playLabel2 = new QLabel(tab, "PlayLabel2" );
452 playLabel2->setText("Play"); 452 playLabel2->setText(tr("Play") );
453 playLabel2->setFixedHeight(18); 453 playLabel2->setFixedHeight(18);
454 layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 454 layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
455 455
456 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 456 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
457 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 457 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
458 Stop_PushButton->setFixedSize(22,22); 458 Stop_PushButton->setFixedSize(22,22);
459 Stop_PushButton->setPixmap( image4 ); 459 Stop_PushButton->setPixmap( image4 );
460 460
461 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 461 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
462 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 462 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
463 toBeginningButton->setFixedSize(22,22); 463 toBeginningButton->setFixedSize(22,22);
464 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 464 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") );
465 465
466 toEndButton = new QPushButton( tab, "End_PushButton" ); 466 toEndButton = new QPushButton( tab, "End_PushButton" );
467 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 467 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
468 toEndButton->setFixedSize(22,22); 468 toEndButton->setFixedSize(22,22);
469 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 469 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) );
470 470
471 QLabel *recLabel2; 471 QLabel *recLabel2;
472 recLabel2 = new QLabel( tab, "recLabel2" ); 472 recLabel2 = new QLabel( tab, "recLabel2" );
473 recLabel2->setText("Rec"); 473 recLabel2->setText(tr("Rec"));
474 recLabel2->setFixedHeight(18); 474 recLabel2->setFixedHeight(18);
475 layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 475 layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
476 476
477 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 477 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
478 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 478 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
479 Rec_PushButton->setFixedSize(22,22); 479 Rec_PushButton->setFixedSize(22,22);
480 Rec_PushButton->setPixmap( image6 ); 480 Rec_PushButton->setPixmap( image6 );
481 481
482 t = new QTimer( this ); 482 t = new QTimer( this );
483 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 483 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
484 484
485 rewindTimer = new QTimer( this ); 485 rewindTimer = new QTimer( this );
486 connect( rewindTimer, SIGNAL( timeout() ), SLOT( rewindTimerTimeout() ) ); 486 connect( rewindTimer, SIGNAL( timeout() ), SLOT( rewindTimerTimeout() ) );
487 487
488 forwardTimer = new QTimer( this ); 488 forwardTimer = new QTimer( this );
489 connect( forwardTimer, SIGNAL( timeout() ), SLOT( forwardTimerTimeout() ) ); 489 connect( forwardTimer, SIGNAL( timeout() ), SLOT( forwardTimerTimeout() ) );
490 490
491 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 491 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
492 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 492 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
493 deleteSoundButton->setText( tr( "Delete" ) ); 493 deleteSoundButton->setText( tr( "Delete" ) );
494 494
495 ListView1 = new QListView( tab, "IconView1" ); 495 ListView1 = new QListView( tab, "IconView1" );
496 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 496 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
497 497
498 ListView1->addColumn( tr( "Name" ) ); 498 ListView1->addColumn( tr( "Name" ) );
499 ListView1->setColumnWidth(0,140); 499 ListView1->setColumnWidth(0,140);
500 ListView1->setSorting( 1, false); 500 ListView1->setSorting( 1, false);
501 ListView1->addColumn( tr( "Time" ) ); //in seconds 501 ListView1->addColumn( tr( "Time" ) ); //in seconds
502 ListView1->setColumnWidth(1,50); 502 ListView1->setColumnWidth(1,50);
503 ListView1->addColumn( "Location"); 503 ListView1->addColumn( tr("Location") );
504 ListView1->setColumnWidth(2,50); 504 ListView1->setColumnWidth(2,50);
505 ListView1->addColumn( "Date"); 505 ListView1->addColumn( tr("Date") );
506 ListView1->setColumnWidth(3,63); 506 ListView1->setColumnWidth(3,63);
507 507
508 ListView1->setColumnWidthMode(0,QListView::Manual); 508 ListView1->setColumnWidthMode(0,QListView::Manual);
509 ListView1->setColumnAlignment(1,QListView::AlignCenter); 509 ListView1->setColumnAlignment(1,QListView::AlignCenter);
510 ListView1->setColumnAlignment(2,QListView::AlignRight); 510 ListView1->setColumnAlignment(2,QListView::AlignRight);
511 ListView1->setColumnAlignment(3,QListView::AlignLeft); 511 ListView1->setColumnAlignment(3,QListView::AlignLeft);
512 ListView1->setAllColumnsShowFocus( true ); 512 ListView1->setAllColumnsShowFocus( true );
513 QPEApplication::setStylusOperation( ListView1->viewport(),QPEApplication::RightOnHold); 513 QPEApplication::setStylusOperation( ListView1->viewport(),QPEApplication::RightOnHold);
514 514
515 TabWidget->insertTab( tab, tr( "Files" ) ); 515 TabWidget->insertTab( tab, tr( "Files" ) );
516 516
517 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 517 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
518 tab_3 = new QWidget( TabWidget, "tab_3" ); 518 tab_3 = new QWidget( TabWidget, "tab_3" );
519 //////////////////////////////////// 519 ////////////////////////////////////
520 520
521 Layout19 = new QHBoxLayout( tab_3); 521 Layout19 = new QHBoxLayout( tab_3);
522 Layout19->setSpacing( 2 ); 522 Layout19->setSpacing( 2 );
523 Layout19->setMargin( 0 ); 523 Layout19->setMargin( 0 );
524 524
525 Layout18 = new QVBoxLayout(this); 525 Layout18 = new QVBoxLayout(this);
526 Layout18->setSpacing( 2 ); 526 Layout18->setSpacing( 2 );
527 Layout18->setMargin( 0 ); 527 Layout18->setMargin( 0 );
528 528
529 Layout17 = new QHBoxLayout(this); 529 Layout17 = new QHBoxLayout(this);
530 Layout17->setSpacing( 2 ); 530 Layout17->setSpacing( 2 );
531 Layout17->setMargin( 0 ); 531 Layout17->setMargin( 0 );
532 532
533 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 533 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
534 sampleGroup->setTitle( tr( "Sample Rate" ) ); 534 sampleGroup->setTitle( tr( "Sample Rate" ) );
535 sampleGroup->setFixedSize( 95,50); 535 sampleGroup->setFixedSize( 95,50);
536 536
537 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 537 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
538 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 538 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
539//#ifndef QT_QWS_EBX 539//#ifndef QT_QWS_EBX
540 sampleRateComboBox->insertItem( tr( "44100")); 540 sampleRateComboBox->insertItem( tr( "44100"));
541 sampleRateComboBox->insertItem( tr( "32000")); 541 sampleRateComboBox->insertItem( tr( "32000"));
542//#endif 542//#endif
543 sampleRateComboBox->insertItem( tr( "22050")); 543 sampleRateComboBox->insertItem( tr( "22050"));
544 //#ifndef QT_QWS_VERCEL_IDR 544 //#ifndef QT_QWS_VERCEL_IDR
545 sampleRateComboBox->insertItem( tr( "16000")); 545 sampleRateComboBox->insertItem( tr( "16000"));
546 sampleRateComboBox->insertItem( tr( "11025")); 546 sampleRateComboBox->insertItem( tr( "11025"));
547 sampleRateComboBox->insertItem( tr( "8000")); 547 sampleRateComboBox->insertItem( tr( "8000"));
548 //#endif 548 //#endif
549 549
550 Layout17->addWidget( sampleGroup ); 550 Layout17->addWidget( sampleGroup );
551 551
552 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 552 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
553 sizeGroup->setTitle( tr( "Limit Size" ) ); 553 sizeGroup->setTitle( tr( "Limit Size" ) );
554 sizeGroup->setFixedSize(80,50); 554 sizeGroup->setFixedSize(80,50);
555 555
556 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 556 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
557 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 557 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
558 sizeLimitCombo->insertItem(tr("Unlimited")); 558 sizeLimitCombo->insertItem(tr("Unlimited"));
559 for(int i=1;i<13; i++) { 559 for(int i=1;i<13; i++) {
560 sizeLimitCombo->insertItem( QString::number(i*5)); 560 sizeLimitCombo->insertItem( QString::number(i*5));
561 } 561 }
562 562
563// sizeLimitCombo->insertItem(tr("5 secs")); 563// sizeLimitCombo->insertItem(tr("5 secs"));
564// sizeLimitCombo->insertItem(tr("10 secs")); 564// sizeLimitCombo->insertItem(tr("10 secs"));
565// sizeLimitCombo->insertItem(tr("15 secs")); 565// sizeLimitCombo->insertItem(tr("15 secs"));
566// sizeLimitCombo->insertItem(tr("20 secs")); 566// sizeLimitCombo->insertItem(tr("20 secs"));
567 567
568 // Layout18->addWidget( sizeGroup ); 568 // Layout18->addWidget( sizeGroup );
569 Layout17->addWidget( sizeGroup ); 569 Layout17->addWidget( sizeGroup );
570 570
571 Layout18->addLayout( Layout17 ); 571 Layout18->addLayout( Layout17 );
572 572
573 Layout16 = new QHBoxLayout(this); 573 Layout16 = new QHBoxLayout(this);
574 Layout16->setSpacing( 2 ); 574 Layout16->setSpacing( 2 );
575 Layout16->setMargin( 0 ); 575 Layout16->setMargin( 0 );
576 576
577 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 577 dirGroup = new QGroupBox( tab_3, "dirGroup" );
578 dirGroup->setTitle( tr( "File Directory" ) ); 578 dirGroup->setTitle( tr( "File Directory" ) );
579 dirGroup->setFixedSize(130,50); 579 dirGroup->setFixedSize(130,50);
580 580
581 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 581 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
582 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 582 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
583 583
584 Layout18->addWidget( dirGroup ); 584 Layout18->addWidget( dirGroup );
585 585
586 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 586 bitGroup = new QGroupBox( tab_3, "bitGroup" );
587 bitGroup->setTitle( tr( "Bit Depth" ) ); 587 bitGroup->setTitle( tr( "Bit Depth" ) );
588 bitGroup->setFixedSize(65,50); 588 bitGroup->setFixedSize(65,50);
589 589
590 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 590 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
591 bitRateComboBox->insertItem( tr( "16" ) ); 591 bitRateComboBox->insertItem( tr( "16" ) );
592 bitRateComboBox->insertItem( tr( "8" ) ); 592 bitRateComboBox->insertItem( tr( "8" ) );
593 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 593 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
594 594
595 Layout18->addWidget( bitGroup ); 595 Layout18->addWidget( bitGroup );
596 596
597 compressionCheckBox = new QCheckBox ( "Wave Compression (smaller files)", tab_3 ); 597 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
598 Layout18->addWidget( compressionCheckBox ); 598 Layout18->addWidget( compressionCheckBox );
599 599
600 autoMuteCheckBox= new QCheckBox ( "auto Mute", tab_3 ); 600 autoMuteCheckBox= new QCheckBox ( tr("auto Mute"), tab_3 );
601 Layout18->addWidget( autoMuteCheckBox ); 601 Layout18->addWidget( autoMuteCheckBox );
602 602
603 Layout19->addLayout( Layout18 ); 603 Layout19->addLayout( Layout18 );
604 604
605 QWidget *d = QApplication::desktop(); 605 QWidget *d = QApplication::desktop();
606 int width=d->width(); 606 int width=d->width();
607 int height=d->height(); 607 int height=d->height();
608 608
609 609
610 610
611 if( width < height) { 611 if( width < height) {
612 612
613 tab_5 = new QWidget( TabWidget, "tab_5" ); 613 tab_5 = new QWidget( TabWidget, "tab_5" );
614 614
615 QHBoxLayout *Layout19a; 615 QHBoxLayout *Layout19a;
616 Layout19a = new QHBoxLayout( tab_5); 616 Layout19a = new QHBoxLayout( tab_5);
617 Layout19a->setSpacing( 2 ); 617 Layout19a->setSpacing( 2 );
618 Layout19a->setMargin( 0 ); 618 Layout19a->setMargin( 0 );
619 619
620 620
621 Layout15 = new QVBoxLayout(this); 621 Layout15 = new QVBoxLayout(this);
622 Layout15->setSpacing( 2 ); 622 Layout15->setSpacing( 2 );
623 Layout15->setMargin( 0 ); 623 Layout15->setMargin( 0 );
624 624
625 Layout15b = new QVBoxLayout(this); 625 Layout15b = new QVBoxLayout(this);
626 Layout15b->setSpacing( 2 ); 626 Layout15b->setSpacing( 2 );
627 Layout15b->setMargin( 0 ); 627 Layout15b->setMargin( 0 );
628 628
629 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 629 TextLabel2 = new QLabel( tab_5, "InputLabel" );
630 TextLabel2->setText( tr( "In")); 630 TextLabel2->setText( tr( "In"));
631 TextLabel2->setFixedWidth(35); 631 TextLabel2->setFixedWidth(35);
632 Layout15->addWidget( TextLabel2 ); 632 Layout15->addWidget( TextLabel2 );
633 633
634 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 634 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
635 TextLabel3->setText( tr( "Out" ) ); 635 TextLabel3->setText( tr( "Out" ) );
636 Layout15b->addWidget( TextLabel3 ); 636 Layout15b->addWidget( TextLabel3 );
637 637
638 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 638 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
639 InputSlider->setTickmarks(QSlider::Both); 639 InputSlider->setTickmarks(QSlider::Both);
640 Layout15->addWidget( InputSlider); 640 Layout15->addWidget( InputSlider);
641 641
642 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 642 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
643 OutputSlider->setTickmarks(QSlider::Both); 643 OutputSlider->setTickmarks(QSlider::Both);
644 644
645 Layout15b->addWidget( OutputSlider ); 645 Layout15b->addWidget( OutputSlider );
646 646
647 outMuteCheckBox = new QCheckBox ( "mute", tab_5 ); 647 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
648 Layout15->addWidget( outMuteCheckBox ); 648 Layout15->addWidget( outMuteCheckBox );
649 649
650 inMuteCheckBox = new QCheckBox ( "mute", tab_5 ); 650 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
651 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 651 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
652 Layout15b->addWidget( inMuteCheckBox ); 652 Layout15b->addWidget( inMuteCheckBox );
653 653
654 654
655 Layout19a->addLayout( Layout15 ); 655 Layout19a->addLayout( Layout15 );
656 Layout19a->addLayout( Layout15b ); 656 Layout19a->addLayout( Layout15b );
657 657
658 fillDirectoryCombo(); 658 fillDirectoryCombo();
659 659
660 TabWidget->insertTab( tab_3, tr( "Options" ) ); 660 TabWidget->insertTab( tab_3, tr( "Options" ) );
661 661
662 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 662 TabWidget->insertTab( tab_5, tr( "Volume" ) );
663 663
664 } else {// landscape 664 } else {// landscape
665 665
666 // Layout16->addWidget( dirGroup ); 666 // Layout16->addWidget( dirGroup );
667 // Layout18->addLayout( Layout16 ); 667 // Layout18->addLayout( Layout16 );
668 Layout15 = new QVBoxLayout(this); 668 Layout15 = new QVBoxLayout(this);
669 Layout15->setSpacing( 2 ); 669 Layout15->setSpacing( 2 );
670 Layout15->setMargin( 0 ); 670 Layout15->setMargin( 0 );
671 671
672 Layout15b = new QVBoxLayout(this); 672 Layout15b = new QVBoxLayout(this);
673 Layout15b->setSpacing( 2 ); 673 Layout15b->setSpacing( 2 );
674 Layout15b->setMargin( 0 ); 674 Layout15b->setMargin( 0 );
675 675
676 TextLabel2 = new QLabel( tab_3, "InputLabel" ); 676 TextLabel2 = new QLabel( tab_3, "InputLabel" );
677 TextLabel2->setText( tr( "In")); 677 TextLabel2->setText( tr( "In"));
678 TextLabel2->setFixedWidth(35); 678 TextLabel2->setFixedWidth(35);
679 Layout15->addWidget( TextLabel2 ); 679 Layout15->addWidget( TextLabel2 );
680 680
681 TextLabel3 = new QLabel( tab_3, "OutputLabel" ); 681 TextLabel3 = new QLabel( tab_3, "OutputLabel" );
682 TextLabel3->setText( tr( "Out" ) ); 682 TextLabel3->setText( tr( "Out" ) );
683 Layout15b->addWidget( TextLabel3 ); 683 Layout15b->addWidget( TextLabel3 );
684 684
685 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" ); 685 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" );
686 // InputSlider->setTickmarks(QSlider::Both); 686 // InputSlider->setTickmarks(QSlider::Both);
687 Layout15->addWidget( InputSlider); 687 Layout15->addWidget( InputSlider);
688 688
689 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" ); 689 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" );
690 // OutputSlider->setTickmarks(QSlider::Both); 690 // OutputSlider->setTickmarks(QSlider::Both);
691 691
692 Layout15b->addWidget( OutputSlider ); 692 Layout15b->addWidget( OutputSlider );
693 693
694 outMuteCheckBox = new QCheckBox ( "mute", tab_3 ); 694 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
695 Layout15->addWidget( outMuteCheckBox ); 695 Layout15->addWidget( outMuteCheckBox );
696 696
697 inMuteCheckBox = new QCheckBox ( "mute", tab_3 ); 697 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
698 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 698 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
699 Layout15b->addWidget( inMuteCheckBox ); 699 Layout15b->addWidget( inMuteCheckBox );
700 700
701 701
702 Layout19->addLayout( Layout15 ); 702 Layout19->addLayout( Layout15 );
703 Layout19->addLayout( Layout15b ); 703 Layout19->addLayout( Layout15b );
704 704
705 fillDirectoryCombo(); 705 fillDirectoryCombo();
706 706
707 TabWidget->insertTab( tab_3, tr( "Options" ) ); 707 TabWidget->insertTab( tab_3, tr( "Options" ) );
708 708
709 } 709 }
710 710
711 711
712 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 712 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
713 713
714// tab_4 = new QWidget( TabWidget, "tab_4" ); 714// tab_4 = new QWidget( TabWidget, "tab_4" );
715// QGridLayout *layout4 = new QGridLayout( tab_4); 715// QGridLayout *layout4 = new QGridLayout( tab_4);
716// layout4->setSpacing( 2); 716// layout4->setSpacing( 2);
717// layout4->setMargin( 2); 717// layout4->setMargin( 2);
718// TabWidget->insertTab( tab_4, tr( "Help")); 718// TabWidget->insertTab( tab_4, tr( "Help"));
719 719
720// ///////////////////////////////////////////// FIXME change to a real helpfile path 720// ///////////////////////////////////////////// FIXME change to a real helpfile path
721// QString url="/index.html"; 721// QString url="/index.html";
722// HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help"); 722// HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help");
723// layout4->addMultiCellWidget( help, 0, 1, 0, 1); 723// layout4->addMultiCellWidget( help, 0, 1, 0, 1);
724// if( !QFile(url).exists()) { 724// if( !QFile(url).exists()) {
725// help->hide(); 725// help->hide();
726// //help->showMaximized(); 726// //help->showMaximized();
727// QLabel *helpLabel; 727// QLabel *helpLabel;
728// helpLabel = new QLabel( tab_4, "TimeLabel" ); 728// helpLabel = new QLabel( tab_4, "TimeLabel" );
729// layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 ); 729// layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 );
730// helpLabel->setText( "<B>OpieRec</B><br>" 730// helpLabel->setText( "<B>OpieRec</B><br>"
731// "Records files in standard wav format<br>" 731// "Records files in standard wav format<br>"
732// "or a compressed version<br>" 732// "or a compressed version<br>"
733// "For help, please email the author<br>" 733// "For help, please email the author<br>"
734// "<B>OpieRec</B> is copyright&copy; 2002 by" 734// "<B>OpieRec</B> is copyright&copy; 2002 by"
735// " L.J. Potter<br>llornkcor@handhelds.org<BR>" 735// " L.J. Potter<br>llornkcor@handhelds.org<BR>"
736// "and is licensed under the <B>QPL</B>"); 736// "and is licensed under the <B>QPL</B>");
737// } 737// }
738 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 738 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
739 739
740} 740}
741 741
742void QtRec::initIconView() { 742void QtRec::initIconView() {
743 743
744 ListView1->clear(); 744 ListView1->clear();
745 Config cfg("OpieRec"); 745 Config cfg("OpieRec");
746 cfg.setGroup("Sounds"); 746 cfg.setGroup("Sounds");
747 QString temp; 747 QString temp;
748 QPixmap image0( ( const char** ) image0_data ); 748 QPixmap image0( ( const char** ) image0_data );
749 749
750 750
751 int nFiles = cfg.readNumEntry("NumberofFiles",0); 751 int nFiles = cfg.readNumEntry("NumberofFiles",0);
752 for(int i=1;i<= nFiles;i++) { 752 for(int i=1;i<= nFiles;i++) {
753 753
754 QListViewItem * item; 754 QListViewItem * item;
755 QString fileS, mediaLocation, fileDate, filePath; 755 QString fileS, mediaLocation, fileDate, filePath;
756 756
757// temp.sprintf("%d",i); 757// temp.sprintf("%d",i);
758 temp=cfg.readEntry(temp,""); //reads currentFile 758 temp=cfg.readEntry(temp,""); //reads currentFile
759 filePath = cfg.readEntry(temp,""); //currentFileName 759 filePath = cfg.readEntry(temp,""); //currentFileName
760 760
761 QFileInfo info(filePath); 761 QFileInfo info(filePath);
762 fileDate = info.lastModified().toString(); 762 fileDate = info.lastModified().toString();
763 763
764 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 764 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
765 mediaLocation=getStorage( filePath); 765 mediaLocation=getStorage( filePath);
766 if(info.exists()) { 766 if(info.exists()) {
767 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); 767 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate);
768 item->setPixmap( 0, image0); 768 item->setPixmap( 0, image0);
769 if(currentFileName == filePath) 769 if(currentFileName == filePath)
770 ListView1->setSelected( item, true); 770 ListView1->setSelected( item, true);
771 } 771 }
772 } 772 }
773} 773}
774 774
775void QtRec::initConnections() { 775void QtRec::initConnections() {
776 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 776 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
777 777
778 connect( toBeginningButton, SIGNAL( pressed()), this, SLOT( rewindPressed() )); 778 connect( toBeginningButton, SIGNAL( pressed()), this, SLOT( rewindPressed() ));
779 connect( toBeginningButton, SIGNAL( released()), this, SLOT( rewindReleased() )); 779 connect( toBeginningButton, SIGNAL( released()), this, SLOT( rewindReleased() ));
780 connect( toEndButton, SIGNAL( pressed()), this, SLOT( FastforwardPressed() )); 780 connect( toEndButton, SIGNAL( pressed()), this, SLOT( FastforwardPressed() ));
781 connect( toEndButton, SIGNAL( released()), this, SLOT( FastforwardReleased() )); 781 connect( toEndButton, SIGNAL( released()), this, SLOT( FastforwardReleased() ));
782 connect( deleteSoundButton, SIGNAL(released()), this, SLOT( deleteSound() )); 782 connect( deleteSoundButton, SIGNAL(released()), this, SLOT( deleteSound() ));
783 connect( Stop_PushButton, SIGNAL(released()), this, SLOT( doPlayBtn() )); 783 connect( Stop_PushButton, SIGNAL(released()), this, SLOT( doPlayBtn() ));
784 connect( Rec_PushButton, SIGNAL(released()), this, SLOT( newSound() ) ); 784 connect( Rec_PushButton, SIGNAL(released()), this, SLOT( newSound() ) );
785 connect( TabWidget, SIGNAL( currentChanged( QWidget*)),this, SLOT(thisTab(QWidget*) )); 785 connect( TabWidget, SIGNAL( currentChanged( QWidget*)),this, SLOT(thisTab(QWidget*) ));
786 connect( OutputSlider, SIGNAL(sliderReleased()), this, SLOT( changedOutVolume()) ); 786 connect( OutputSlider, SIGNAL(sliderReleased()), this, SLOT( changedOutVolume()) );
787 connect( InputSlider, SIGNAL(sliderReleased()), this, SLOT( changedInVolume()) ); 787 connect( InputSlider, SIGNAL(sliderReleased()), this, SLOT( changedInVolume()) );
788 788
789 // connect( OutputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedOutVolume(int)) ); 789 // connect( OutputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedOutVolume(int)) );
790 // connect( InputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedInVolume(int)) ); 790 // connect( InputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedInVolume(int)) );
791 791
792 connect( sampleRateComboBox, SIGNAL(activated( int)), this, SLOT( changesamplerateCombo(int)) ); 792 connect( sampleRateComboBox, SIGNAL(activated( int)), this, SLOT( changesamplerateCombo(int)) );
793 connect( bitRateComboBox, SIGNAL(activated( int)), this, SLOT( changebitrateCombo(int)) ); 793 connect( bitRateComboBox, SIGNAL(activated( int)), this, SLOT( changebitrateCombo(int)) );
794 connect( directoryComboBox, SIGNAL(activated( int)), this, SLOT( changeDirCombo(int)) ); 794 connect( directoryComboBox, SIGNAL(activated( int)), this, SLOT( changeDirCombo(int)) );
795 connect( sizeLimitCombo, SIGNAL(activated( int)), this, SLOT( changeSizeLimitCombo(int)) ); 795 connect( sizeLimitCombo, SIGNAL(activated( int)), this, SLOT( changeSizeLimitCombo(int)) );
796 connect( outMuteCheckBox, SIGNAL(toggled( bool)), this, SLOT( doVolMuting(bool)) ); 796 connect( outMuteCheckBox, SIGNAL(toggled( bool)), this, SLOT( doVolMuting(bool)) );
797 connect( inMuteCheckBox , SIGNAL(toggled( bool)), this, SLOT( doMicMuting(bool)) ); 797 connect( inMuteCheckBox , SIGNAL(toggled( bool)), this, SLOT( doMicMuting(bool)) );
798 connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)),this,SLOT( itClick(QListViewItem*))); 798 connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)),this,SLOT( itClick(QListViewItem*)));
799 connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 799 connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
800 this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); 800 this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) );
801 connect( timeSlider, SIGNAL( sliderMoved( int)), this, SLOT( changeTimeSlider(int) )); 801 connect( timeSlider, SIGNAL( sliderMoved( int)), this, SLOT( changeTimeSlider(int) ));
802 connect( timeSlider, SIGNAL( sliderPressed( )), this, SLOT( timeSliderPressed() )); 802 connect( timeSlider, SIGNAL( sliderPressed( )), this, SLOT( timeSliderPressed() ));
803 connect( timeSlider, SIGNAL( sliderReleased( )), this, SLOT( timeSliderReleased() )); 803 connect( timeSlider, SIGNAL( sliderReleased( )), this, SLOT( timeSliderReleased() ));
804 connect( compressionCheckBox, SIGNAL( toggled(bool)),this, SLOT( compressionSelected(bool))); 804 connect( compressionCheckBox, SIGNAL( toggled(bool)),this, SLOT( compressionSelected(bool)));
805 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),this, SLOT( slotAutoMute(bool))); 805 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),this, SLOT( slotAutoMute(bool)));
806} 806}
807 807
808void QtRec::initConfig() { 808void QtRec::initConfig() {
809 int index, fred, i; 809 int index, fred, i;
810 Config cfg("OpieRec"); 810 Config cfg("OpieRec");
811 cfg.setGroup("Settings"); 811 cfg.setGroup("Settings");
812 812
813 index = cfg.readNumEntry("samplerate",22050); 813 index = cfg.readNumEntry("samplerate",22050);
814 bool ok; 814 bool ok;
815 815
816 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 816 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
817 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 817 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
818 if(index == fred) { 818 if(index == fred) {
819 filePara.sampleRate = fred; 819 filePara.sampleRate = fred;
820 sampleRateComboBox->setCurrentItem(ws); 820 sampleRateComboBox->setCurrentItem(ws);
821 } 821 }
822 } 822 }
823 823
824 i=cfg.readNumEntry("bitrate",16); 824 i=cfg.readNumEntry("bitrate",16);
825 if(i == 16) 825 if(i == 16)
826 bitRateComboBox->setCurrentItem( 0); 826 bitRateComboBox->setCurrentItem( 0);
827 else 827 else
828 bitRateComboBox->setCurrentItem( 1); 828 bitRateComboBox->setCurrentItem( 1);
829 filePara.resolution = i; 829 filePara.resolution = i;
830 830
831 i=cfg.readNumEntry("sizeLimit", 5 ); 831 i=cfg.readNumEntry("sizeLimit", 5 );
832 QString temp; 832 QString temp;
833// for(int i=1;i<13; i++) { 833// for(int i=1;i<13; i++) {
834// temp = sizeLimitCombo->text(i); 834// temp = sizeLimitCombo->text(i);
835 835
836// sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs")); 836// sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs"));
837// } 837// }
838 sizeLimitCombo->setCurrentItem((i/5)); 838 sizeLimitCombo->setCurrentItem((i/5));
839 839
840 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 840 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
841 if( compressionCheckBox->isChecked()) { 841 if( compressionCheckBox->isChecked()) {
842 bitRateComboBox->setEnabled(false); 842 bitRateComboBox->setEnabled(false);
843 bitRateComboBox->setCurrentItem(0); 843 bitRateComboBox->setCurrentItem(0);
844 filePara.resolution=16; 844 filePara.resolution=16;
845 } 845 }
846 846
847 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 847 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
848 if( autoMuteCheckBox->isChecked()) 848 if( autoMuteCheckBox->isChecked())
849 slotAutoMute(true); 849 slotAutoMute(true);
850 else 850 else
851 slotAutoMute(false); 851 slotAutoMute(false);
852 852
853 Config cofg( "qpe"); 853 Config cofg( "qpe");
854 cofg.setGroup( "Volume"); 854 cofg.setGroup( "Volume");
855 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 855 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
856 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 856 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
857} 857}
858 858
859//================ 859//================
860 860
861void QtRec::stop() { 861void QtRec::stop() {
862 qDebug("<<<<<<<<<stop()"); 862 qDebug("<<<<<<<<<stop()");
863 setRecordButton(false); 863 setRecordButton(false);
864 monitoring=false; 864 monitoring=false;
865 stopped=true; 865 stopped=true;
866 866
867 if( !recording) 867 if( !recording)
868 endPlaying(); 868 endPlaying();
869 else 869 else
870 endRecording(); 870 endRecording();
871 timeSlider->setValue(0); 871 timeSlider->setValue(0);
872 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device 872 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
873} 873}
874 874
875void QtRec::doPlayBtn() { 875void QtRec::doPlayBtn() {
876 876
877 if(!stopped) { 877 if(!stopped) {
878 playLabel2->setText("Play"); 878 playLabel2->setText(tr("Play"));
879 stop(); 879 stop();
880 } else { 880 } else {
881 if(ListView1->currentItem() == 0) return; 881 if(ListView1->currentItem() == 0) return;
882 playLabel2->setText("Stop"); 882 playLabel2->setText(tr("Stop"));
883 currentFile = ListView1->currentItem()->text(0); 883 currentFile = ListView1->currentItem()->text(0);
884 start(); 884 start();
885 } 885 }
886} 886}
887 887
888void QtRec::start() { //play 888void QtRec::start() { //play
889 if(stopped) { 889 if(stopped) {
890 qDebug("start::"); 890 qDebug("start::");
891 QPixmap image3( ( const char** ) image3_data ); 891 QPixmap image3( ( const char** ) image3_data );
892 Stop_PushButton->setPixmap( image3 ); 892 Stop_PushButton->setPixmap( image3 );
893 Stop_PushButton->setDown(true); 893 Stop_PushButton->setDown(true);
894 stopped=false; 894 stopped=false;
895 paused=false; 895 paused=false;
896 secCount=1; 896 secCount=1;
897 897
898 if( openPlayFile()) 898 if( openPlayFile())
899 if( setupAudio( false)) //recording is false 899 if( setupAudio( false)) //recording is false
900 doPlay(); 900 doPlay();
901 } 901 }
902} 902}
903 903
904bool QtRec::rec() { //record 904bool QtRec::rec() { //record
905 qDebug("rec()"); 905 qDebug("rec()");
906 if(!stopped) { 906 if(!stopped) {
907 qDebug("rec:: !stopped"); 907 qDebug("rec:: !stopped");
908 monitoring=true; 908 monitoring=true;
909 return false; 909 return false;
910 } else { 910 } else {
911 qDebug("go ahead and record"); 911 qDebug("go ahead and record");
912 secCount=1; 912 secCount=1;
913 playLabel2->setText("Stop"); 913 playLabel2->setText(tr("Stop"));
914 monitoring=false; 914 monitoring=false;
915 setRecordButton(true); 915 setRecordButton(true);
916 stopped=false; 916 stopped=false;
917 917
918 if( setupAudio( true)) 918 if( setupAudio( true))
919 if(setUpFile()) { 919 if(setUpFile()) {
920 qDebug("Ok to start recording"); 920 qDebug("Ok to start recording");
921 int fileSize=0; 921 int fileSize=0;
922 Config cfg("OpieRec"); 922 Config cfg("OpieRec");
923 cfg.setGroup("Settings"); 923 cfg.setGroup("Settings");
924 qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", 924 qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d",
925 soundDevice->getDeviceBits(), 925 soundDevice->getDeviceBits(),
926 soundDevice->getDeviceRate(), 926 soundDevice->getDeviceRate(),
927 soundDevice->getDeviceChannels()); 927 soundDevice->getDeviceChannels());
928 928
929 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 929 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
930 qDebug("sample rate is %d", filePara.sampleRate); 930 qDebug("sample rate is %d", filePara.sampleRate);
931 filePara.SecondsToRecord = getCurrentSizeLimit(); 931 filePara.SecondsToRecord = getCurrentSizeLimit();
932 932
933 qDebug("size limit %d sec", filePara.SecondsToRecord); 933 qDebug("size limit %d sec", filePara.SecondsToRecord);
934 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 934 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
935 935
936 if( filePara.SecondsToRecord == 0) { 936 if( filePara.SecondsToRecord == 0) {
937 fileSize = diskSize; 937 fileSize = diskSize;
938 } else if( filePara.format==WAVE_FORMAT_PCM) { 938 } else if( filePara.format==WAVE_FORMAT_PCM) {
939 qDebug("WAVE_FORMAT_PCM"); 939 qDebug("WAVE_FORMAT_PCM");
940 fileSize = (filePara.SecondsToRecord ) * filePara.channels 940 fileSize = (filePara.SecondsToRecord ) * filePara.channels
941 * filePara.sampleRate *(filePara.resolution/8)+1000; 941 * filePara.sampleRate *(filePara.resolution/8)+1000;
942 } else { 942 } else {
943 qDebug("WAVE_FORMAT_DVI_ADPCM"); 943 qDebug("WAVE_FORMAT_DVI_ADPCM");
944 fileSize = ((filePara.SecondsToRecord) * filePara.channels 944 fileSize = ((filePara.SecondsToRecord) * filePara.channels
945 * filePara.sampleRate *(filePara.resolution/8) )/4+250; 945 * filePara.sampleRate *(filePara.resolution/8) )/4+250;
946 } 946 }
947 947
948 filePara.samplesToRecord = fileSize; 948 filePara.samplesToRecord = fileSize;
949 qDebug("filesize should be %d, bits %d, rate %d", 949 qDebug("filesize should be %d, bits %d, rate %d",
950 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); 950 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
951 if(paused) { 951 if(paused) {
952 paused = false; 952 paused = false;
953 } 953 }
954 // else { 954 // else {
955 qDebug("Setting timeslider %d", filePara.samplesToRecord); 955 qDebug("Setting timeslider %d", filePara.samplesToRecord);
956 // if(fileSize != 0) 956 // if(fileSize != 0)
957 timeSlider->setRange(0, filePara.samplesToRecord); 957 timeSlider->setRange(0, filePara.samplesToRecord);
958 // } 958 // }
959 959
960 if( diskSize < fileSize/1024) { 960 if( diskSize < fileSize/1024) {
961 QMessageBox::warning(this, 961 QMessageBox::warning(this,
962 tr("Low Disk Space"), 962 tr("Low Disk Space"),
963 tr("You are running low of\nrecording space\n" 963 tr("You are running low of\nrecording space\n"
964 "or a card isn't being recognized")); 964 "or a card isn't being recognized"));
965 stopped = true; //we need to be stopped 965 stopped = true; //we need to be stopped
966 stop(); 966 stop();
967 } else { 967 } else {
968 QString msg; 968 QString msg;
969 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 969 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
970#ifdef DEV_VERSION 970#ifdef DEV_VERSION
971 setCaption( msg); 971 setCaption( msg);
972#endif 972#endif
973 filePara.fileName=currentFile.latin1(); 973 filePara.fileName=currentFile.latin1();
974 qDebug("Start recording thread"); 974 qDebug("Start recording thread");
975 975
976 pthread_t thread1; 976 pthread_t thread1;
977 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 977 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
978// quickRec(); 978// quickRec();
979 toBeginningButton->setEnabled(false); 979 toBeginningButton->setEnabled(false);
980 toEndButton->setEnabled(false); 980 toEndButton->setEnabled(false);
981 981
982 startTimer(1000); 982 startTimer(1000);
983 } 983 }
984 } //end setUpFile 984 } //end setUpFile
985 } //end setupAudio 985 } //end setupAudio
986 // _exit( 0); 986 // _exit( 0);
987 987
988 // ///* default: 988 // ///* default:
989// // /* pid greater than zero is parent getting the child's pid */ 989// // /* pid greater than zero is parent getting the child's pid */
990// /* printf("Child's pid is %d\n",pid); 990// /* printf("Child's pid is %d\n",pid);
991// waitpid( pid, &status, 0); 991// waitpid( pid, &status, 0);
992// printf("Child[%d] exited with status %d\n", pid, status);*/ 992// printf("Child[%d] exited with status %d\n", pid, status);*/
993 // while (wait(NULL) != pid) 993 // while (wait(NULL) != pid)
994// ; 994// ;
995// printf("child %ld terminated normally, return status is zero\n", (long) pid); 995// printf("child %ld terminated normally, return status is zero\n", (long) pid);
996 // endRecording(); 996 // endRecording();
997/* else { //device was not opened 997/* else { //device was not opened
998 qDebug("Audio device open failed"); 998 qDebug("Audio device open failed");
999 return false; 999 return false;
1000 } 1000 }
1001 }*/ 1001 }*/
1002// } //end fork 1002// } //end fork
1003// } 1003// }
1004// } 1004// }
1005 return true; 1005 return true;
1006} 1006}
1007/* 1007/*
1008 This happens when a tab is selected*/ 1008 This happens when a tab is selected*/
1009void QtRec::thisTab(QWidget* widg) { 1009void QtRec::thisTab(QWidget* widg) {
1010 if(widg != NULL) { 1010 if(widg != NULL) {
1011 int index=TabWidget->currentPageIndex(); 1011 int index=TabWidget->currentPageIndex();
1012 1012
1013 if(index==0) { //file page 1013 if(index==0) { //file page
1014 } 1014 }
1015 1015
1016 if(index ==1) { //control page 1016 if(index ==1) { //control page
1017 fillDirectoryCombo(); 1017 fillDirectoryCombo();
1018// soundDevice->getOutVol(); 1018// soundDevice->getOutVol();
1019// soundDevice->getInVol(); 1019// soundDevice->getInVol();
1020 } 1020 }
1021 1021
1022 if(index==2) { //help page 1022 if(index==2) { //help page
1023 } 1023 }
1024 qApp->processEvents(); 1024 qApp->processEvents();
1025 update(); 1025 update();
1026 } 1026 }
1027} 1027}
1028 1028
1029void QtRec::getOutVol( ) { 1029void QtRec::getOutVol( ) {
1030 filePara.outVol = soundDevice->getOutVolume(); 1030 filePara.outVol = soundDevice->getOutVolume();
1031 qDebug("out vol %d", filePara.outVol); 1031 qDebug("out vol %d", filePara.outVol);
1032 OutputSlider->setValue( -filePara.outVol); 1032 OutputSlider->setValue( -filePara.outVol);
1033} 1033}
1034 1034
1035void QtRec::getInVol() { 1035void QtRec::getInVol() {
1036 filePara.inVol = soundDevice->getInVolume(); 1036 filePara.inVol = soundDevice->getInVolume();
1037 qDebug("in vol %d", filePara.inVol); 1037 qDebug("in vol %d", filePara.inVol);
1038 InputSlider->setValue( -filePara.inVol); 1038 InputSlider->setValue( -filePara.inVol);
1039} 1039}
1040 1040
1041void QtRec::changedOutVolume() { 1041void QtRec::changedOutVolume() {
1042 soundDevice->changedOutVolume(-OutputSlider->value()); 1042 soundDevice->changedOutVolume(-OutputSlider->value());
1043} 1043}
1044 1044
1045void QtRec::changedInVolume( ) { 1045void QtRec::changedInVolume( ) {
1046 soundDevice->changedInVolume( -InputSlider->value()); 1046 soundDevice->changedInVolume( -InputSlider->value());
1047} 1047}
1048 1048
1049 1049
1050bool QtRec::setupAudio( bool b) { 1050bool QtRec::setupAudio( bool b) {
1051 bool ok; 1051 bool ok;
1052 int sampleformat, stereo, flags; 1052 int sampleformat, stereo, flags;
1053 char * dspString, *mixerString; 1053 char * dspString, *mixerString;
1054 1054
1055 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 1055 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
1056 1056
1057 if( !b){ // we want to play 1057 if( !b){ // we want to play
1058 qDebug("setting up DSP for playing"); 1058 qDebug("setting up DSP for playing");
1059 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1059 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1060 sampleformat = AFMT_S16_LE; 1060 sampleformat = AFMT_S16_LE;
1061 filePara.resolution = 16; 1061 filePara.resolution = 16;
1062 } else { 1062 } else {
1063 sampleformat = AFMT_U8; 1063 sampleformat = AFMT_U8;
1064 filePara.resolution=8; 1064 filePara.resolution=8;
1065 } 1065 }
1066 1066
1067 stereo = filePara.channels = 1; 1067 stereo = filePara.channels = 1;
1068 flags= O_WRONLY; 1068 flags= O_WRONLY;
1069 dspString = DSPSTROUT; 1069 dspString = DSPSTROUT;
1070 mixerString = DSPSTRMIXEROUT; 1070 mixerString = DSPSTRMIXEROUT;
1071 } else { // we want to record 1071 } else { // we want to record
1072 qDebug("setting up DSP for recording"); 1072 qDebug("setting up DSP for recording");
1073 1073
1074 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1074 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1075 sampleformat = AFMT_S16_LE; 1075 sampleformat = AFMT_S16_LE;
1076 else 1076 else
1077 sampleformat = AFMT_U8; 1077 sampleformat = AFMT_U8;
1078 1078
1079 if( !compressionCheckBox->isChecked()) { 1079 if( !compressionCheckBox->isChecked()) {
1080 filePara.format=WAVE_FORMAT_PCM; 1080 filePara.format=WAVE_FORMAT_PCM;
1081 qDebug("WAVE_FORMAT_PCM"); 1081 qDebug("WAVE_FORMAT_PCM");
1082 } else { 1082 } else {
1083 filePara.format=WAVE_FORMAT_DVI_ADPCM; 1083 filePara.format=WAVE_FORMAT_DVI_ADPCM;
1084 sampleformat=AFMT_S16_LE; 1084 sampleformat=AFMT_S16_LE;
1085 qDebug("WAVE_FORMAT_DVI_ADPCM"); 1085 qDebug("WAVE_FORMAT_DVI_ADPCM");
1086 } 1086 }
1087 1087
1088 stereo = filePara.channels = 1; 1088 stereo = filePara.channels = 1;
1089// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1089// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1090 flags= O_RDWR; 1090 flags= O_RDWR;
1091// flags= O_RDONLY; 1091// flags= O_RDONLY;
1092 dspString = DSPSTRIN; 1092 dspString = DSPSTRIN;
1093 mixerString = DSPSTRMIXEROUT; 1093 mixerString = DSPSTRMIXEROUT;
1094 } 1094 }
1095 1095
1096 // if(soundDevice) delete soundDevice; 1096 // if(soundDevice) delete soundDevice;
1097 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); 1097 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat);
1098 soundDevice = new Device( this, dspString, mixerString, b); 1098 soundDevice = new Device( this, dspString, mixerString, b);
1099// soundDevice->openDsp(); 1099// soundDevice->openDsp();
1100 soundDevice->reset(); 1100 soundDevice->reset();
1101 1101
1102 qDebug("device has been made %d", soundDevice->sd); 1102 qDebug("device has been made %d", soundDevice->sd);
1103 1103
1104 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> 1104 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1105 soundDevice->setDeviceFormat( sampleformat); 1105 soundDevice->setDeviceFormat( sampleformat);
1106 soundDevice->setDeviceChannels( filePara.channels); 1106 soundDevice->setDeviceChannels( filePara.channels);
1107 soundDevice->setDeviceRate( filePara.sampleRate); 1107 soundDevice->setDeviceRate( filePara.sampleRate);
1108 soundDevice->getDeviceFragSize(); 1108 soundDevice->getDeviceFragSize();
1109#ifdef QT_QWS_EBX 1109#ifdef QT_QWS_EBX
1110 int frag = FRAGSIZE; 1110 int frag = FRAGSIZE;
1111 soundDevice->setFragSize( frag); 1111 soundDevice->setFragSize( frag);
1112 soundDevice->getDeviceFragSize(); 1112 soundDevice->getDeviceFragSize();
1113#endif 1113#endif
1114 ///////////////// 1114 /////////////////
1115 filePara.sd = soundDevice->sd; 1115 filePara.sd = soundDevice->sd;
1116 1116
1117 if ( filePara.sd == -1) { 1117 if ( filePara.sd == -1) {
1118 1118
1119 monitoring=false; 1119 monitoring=false;
1120 stopped=true; 1120 stopped=true;
1121 update(); 1121 update();
1122 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1122 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1123 stopped=true; 1123 stopped=true;
1124 return false; 1124 return false;
1125 } 1125 }
1126 if(autoMute) 1126 if(autoMute)
1127 doMute(false); 1127 doMute(false);
1128 1128
1129 return true; 1129 return true;
1130} 1130}
1131 1131
1132 1132
1133bool QtRec::setUpFile() { //setup file for recording 1133bool QtRec::setUpFile() { //setup file for recording
1134 qDebug("Setting up wavfile"); 1134 qDebug("Setting up wavfile");
1135// if(wavFile) delete wavFile; 1135// if(wavFile) delete wavFile;
1136 wavFile = new WavFile( this, (const QString &)"", 1136 wavFile = new WavFile( this, (const QString &)"",
1137 true, 1137 true,
1138 filePara.sampleRate, 1138 filePara.sampleRate,
1139 filePara.channels, 1139 filePara.channels,
1140 filePara.resolution, 1140 filePara.resolution,
1141 filePara.format); 1141 filePara.format);
1142 1142
1143 filePara.fd = wavFile->wavHandle(); 1143 filePara.fd = wavFile->wavHandle();
1144 if(filePara.fd == -1) { 1144 if(filePara.fd == -1) {
1145 return false; 1145 return false;
1146 } else { 1146 } else {
1147 filePara.channels=1; 1147 filePara.channels=1;
1148 } 1148 }
1149 return true; 1149 return true;
1150} 1150}
1151 1151
1152/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1152/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1153bool QtRec::doPlay() { 1153bool QtRec::doPlay() {
1154 1154
1155// pthread_t thread2; 1155// pthread_t thread2;
1156// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1156// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1157 1157
1158 // qDebug("doPlay file %d", filePara.fd); 1158 // qDebug("doPlay file %d", filePara.fd);
1159 int bytesWritten, number; 1159 int bytesWritten, number;
1160 recording = false; 1160 recording = false;
1161// int number=0; 1161// int number=0;
1162 if( !paused) { 1162 if( !paused) {
1163 qDebug("new"); 1163 qDebug("new");
1164 total=0; 1164 total=0;
1165 bytesWritten=0; 1165 bytesWritten=0;
1166 filePara.numberOfRecordedSeconds = 0; 1166 filePara.numberOfRecordedSeconds = 0;
1167 } else { 1167 } else {
1168 paused = false; 1168 paused = false;
1169 secCount = (int)filePara.numberOfRecordedSeconds; 1169 secCount = (int)filePara.numberOfRecordedSeconds;
1170 } 1170 }
1171 playing=true; 1171 playing=true;
1172 number=0; 1172 number=0;
1173 1173
1174 QString num; 1174 QString num;
1175// block=BUFSIZE; 1175// block=BUFSIZE;
1176 qDebug("Play number of samples %d", filePara.numberSamples); 1176 qDebug("Play number of samples %d", filePara.numberSamples);
1177 timeSlider->setRange(0, filePara.numberSamples); 1177 timeSlider->setRange(0, filePara.numberSamples);
1178 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1178 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1179 timeLabel->setText( timeString+ tr(" seconds")); 1179 timeLabel->setText( timeString+ tr(" seconds"));
1180 1180
1181 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 1181 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
1182 qDebug("WAVE_FORMAT_DVI_ADPCM"); 1182 qDebug("WAVE_FORMAT_DVI_ADPCM");
1183 } else { 1183 } else {
1184 qDebug("WAVE_FORMAT_PCM"); 1184 qDebug("WAVE_FORMAT_PCM");
1185 } 1185 }
1186 QString msg; 1186 QString msg;
1187 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1187 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1188#ifdef DEV_VERSION 1188#ifdef DEV_VERSION
1189 setCaption( msg); 1189 setCaption( msg);
1190#endif 1190#endif
1191 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 1191 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
1192 qDebug("16 bit"); 1192 qDebug("16 bit");
1193 1193
1194 startTimer(1000); 1194 startTimer(1000);
1195 1195
1196 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 1196 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
1197 char abuf[BUFSIZE/2]; 1197 char abuf[BUFSIZE/2];
1198 short sbuf[BUFSIZE]; 1198 short sbuf[BUFSIZE];
1199 short sbuf2[BUFSIZE*2]; 1199 short sbuf2[BUFSIZE*2];
1200 memset( abuf, 0, BUFSIZE / 2); 1200 memset( abuf, 0, BUFSIZE / 2);
1201 memset( sbuf, 0, BUFSIZE); 1201 memset( sbuf, 0, BUFSIZE);
1202 memset( sbuf2, 0, BUFSIZE * 2); 1202 memset( sbuf2, 0, BUFSIZE * 2);
1203// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 1203// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
1204 for(;;) { // play loop 1204 for(;;) { // play loop
1205 if (stopped) 1205 if (stopped)
1206 break; // stop if playing was set to false 1206 break; // stop if playing was set to false
1207 1207
1208 1208
1209 number=::read( filePara.fd, abuf, BUFSIZE/2); 1209 number=::read( filePara.fd, abuf, BUFSIZE/2);
1210 adpcm_decoder( abuf, sbuf, number*2, &decoder_state); 1210 adpcm_decoder( abuf, sbuf, number*2, &decoder_state);
1211 1211
1212// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 1212// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
1213// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 1213// sbuf2[i+1]=sbuf2[i]=sbuf[i];
1214// } 1214// }
1215 1215
1216 bytesWritten = write ( filePara.sd, sbuf, number*4); 1216 bytesWritten = write ( filePara.sd, sbuf, number*4);
1217 // if(filePara.channels==1) 1217 // if(filePara.channels==1)
1218 // total += bytesWritten/2; //mono 1218 // total += bytesWritten/2; //mono
1219 // else 1219 // else
1220 total += bytesWritten; 1220 total += bytesWritten;
1221 timeSlider->setValue( total / 4); 1221 timeSlider->setValue( total / 4);
1222 1222
1223 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 1223 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
1224 1224
1225 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1225 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1226// if(filePara.numberOfRecordedSeconds>1) 1226// if(filePara.numberOfRecordedSeconds>1)
1227 timeLabel->setText( timeString+ tr(" seconds")); 1227 timeLabel->setText( timeString+ tr(" seconds"));
1228// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 1228// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
1229// printf("playing number %d, bytes %d, total %d totalsamples %d number recorded seconds %.2f\r", 1229// printf("playing number %d, bytes %d, total %d totalsamples %d number recorded seconds %.2f\r",
1230// number, bytesWritten, total/4, filePara.numberSamples, filePara.numberOfRecordedSeconds); 1230// number, bytesWritten, total/4, filePara.numberSamples, filePara.numberOfRecordedSeconds);
1231// fflush(stdout); 1231// fflush(stdout);
1232 1232
1233 qApp->processEvents(); 1233 qApp->processEvents();
1234 1234
1235 if( bytesWritten <= 0 ){//|| secCount > filePara.numberOfRecordedSeconds ) { 1235 if( bytesWritten <= 0 ){//|| secCount > filePara.numberOfRecordedSeconds ) {
1236 stopped = true; 1236 stopped = true;
1237 endPlaying(); 1237 endPlaying();
1238 } 1238 }
1239 } 1239 }
1240 } else { 1240 } else {
1241 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 1241 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
1242 short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; 1242 short inbuffer[BUFSIZE], outbuffer[BUFSIZE];
1243 memset( inbuffer, 0, BUFSIZE); 1243 memset( inbuffer, 0, BUFSIZE);
1244 memset( outbuffer, 0, BUFSIZE); 1244 memset( outbuffer, 0, BUFSIZE);
1245 1245
1246 for(;;) { // play loop 1246 for(;;) { // play loop
1247 if (stopped) 1247 if (stopped)
1248 break; // stop if playing was set to false 1248 break; // stop if playing was set to false
1249 number=::read( filePara.fd, inbuffer, BUFSIZE); 1249 number=::read( filePara.fd, inbuffer, BUFSIZE);
1250// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 1250// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
1251// // for (int i=0;i< number ; i++) { //2*i is left channel 1251// // for (int i=0;i< number ; i++) { //2*i is left channel
1252// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 1252// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
1253// } 1253// }
1254 1254
1255 bytesWritten = ::write( filePara.sd, inbuffer, number); 1255 bytesWritten = ::write( filePara.sd, inbuffer, number);
1256 //-------------->>>> out to device 1256 //-------------->>>> out to device
1257 // total+=bytesWritten; 1257 // total+=bytesWritten;
1258 // if(filePara.channels==1) 1258 // if(filePara.channels==1)
1259 // total += bytesWritten/2; //mono 1259 // total += bytesWritten/2; //mono
1260 // else 1260 // else
1261 total += bytesWritten; 1261 total += bytesWritten;
1262 1262
1263 timeSlider->setValue( total); 1263 timeSlider->setValue( total);
1264 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 1264 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
1265 1265
1266 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 1266 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
1267 timeLabel->setText( timeString + tr(" seconds")); 1267 timeLabel->setText( timeString + tr(" seconds"));
1268 1268
1269 qApp->processEvents(); 1269 qApp->processEvents();
1270 1270
1271 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) { 1271 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) {
1272 stopped = true; 1272 stopped = true;
1273 endPlaying(); 1273 endPlaying();
1274 } 1274 }
1275 } 1275 }
1276// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 1276// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
1277// fflush(stdout); 1277// fflush(stdout);
1278 } //end loop 1278 } //end loop
1279 } else { /////////////////////////////// format = AFMT_U8; 1279 } else { /////////////////////////////// format = AFMT_U8;
1280 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; 1280 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE];
1281 memset( unsigned_inbuffer,0,BUFSIZE); 1281 memset( unsigned_inbuffer,0,BUFSIZE);
1282 for(;;) { // main loop 1282 for(;;) { // main loop
1283 if (stopped) 1283 if (stopped)
1284 break; // stop if playing was set to false 1284 break; // stop if playing was set to false
1285 number=::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 1285 number=::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
1286//data = (val >> 8) ^ 0x80; 1286//data = (val >> 8) ^ 0x80;
1287 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 1287 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
1288 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 1288 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
1289 total+=bytesWritten; 1289 total+=bytesWritten;
1290 1290
1291 timeSlider->setValue( total); 1291 timeSlider->setValue( total);
1292 1292
1293 filePara.numberOfRecordedSeconds=(float)total/(float)filePara.sampleRate; 1293 filePara.numberOfRecordedSeconds=(float)total/(float)filePara.sampleRate;
1294 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 1294 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
1295 timeLabel->setText( timeString + tr(" seconds")); 1295 timeLabel->setText( timeString + tr(" seconds"));
1296 qApp->processEvents(); 1296 qApp->processEvents();
1297 1297
1298 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) { 1298 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) {
1299 stopped = true; 1299 stopped = true;
1300 endPlaying(); 1300 endPlaying();
1301 } 1301 }
1302 // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 1302 // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
1303 // fflush(stdout); 1303 // fflush(stdout);
1304 } 1304 }
1305 } 1305 }
1306 1306
1307// qDebug("\nstopped or paused %d", total/4); 1307// qDebug("\nstopped or paused %d", total/4);
1308 if(!paused && !stopped) { 1308 if(!paused && !stopped) {
1309 stopped = true; 1309 stopped = true;
1310// endPlaying(); 1310// endPlaying();
1311 endPlaying(); 1311 endPlaying();
1312 } 1312 }
1313 return true; 1313 return true;
1314} 1314}
1315 1315
1316 1316
1317void QtRec::changebitrateCombo(int i) { 1317void QtRec::changebitrateCombo(int i) {
1318 Config cfg("OpieRec"); 1318 Config cfg("OpieRec");
1319 cfg.setGroup("Settings"); 1319 cfg.setGroup("Settings");
1320 int bits=0; 1320 int bits=0;
1321 if(i==0) { bits=16; } 1321 if(i==0) { bits=16; }
1322 else { bits=8; } 1322 else { bits=8; }
1323 cfg.writeEntry("bitrate", bits); 1323 cfg.writeEntry("bitrate", bits);
1324 filePara.resolution=bits; 1324 filePara.resolution=bits;
1325 cfg.write(); 1325 cfg.write();
1326} 1326}
1327 1327
1328void QtRec::changesamplerateCombo(int i) { 1328void QtRec::changesamplerateCombo(int i) {
1329 Config cfg("OpieRec"); 1329 Config cfg("OpieRec");
1330 cfg.setGroup("Settings"); 1330 cfg.setGroup("Settings");
1331 int rate=0; 1331 int rate=0;
1332 bool ok; 1332 bool ok;
1333 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1333 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1334 cfg.writeEntry("samplerate",rate); 1334 cfg.writeEntry("samplerate",rate);
1335 filePara.sampleRate=rate; 1335 filePara.sampleRate=rate;
1336/* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false); 1336/* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false);
1337 soundDevice->openDsp();*/ 1337 soundDevice->openDsp();*/
1338// 1338//
1339// soundDevice->setDeviceFormat(AFMT_S16_LE); 1339// soundDevice->setDeviceFormat(AFMT_S16_LE);
1340// soundDevice->setDeviceChannels(filePara.channels); 1340// soundDevice->setDeviceChannels(filePara.channels);
1341// soundDevice->setDeviceRate(filePara.sampleRate); 1341// soundDevice->setDeviceRate(filePara.sampleRate);
1342// 1342//
1343// soundDevice->closeDevice( true); 1343// soundDevice->closeDevice( true);
1344// soundDevice=0; 1344// soundDevice=0;
1345// delete soundDevice; 1345// delete soundDevice;
1346 qDebug("Change sample rate %d", rate); 1346 qDebug("Change sample rate %d", rate);
1347 cfg.write(); 1347 cfg.write();
1348 1348
1349} 1349}
1350 1350
1351 1351
1352void QtRec::changeDirCombo(int index) { 1352void QtRec::changeDirCombo(int index) {
1353 Config cfg("OpieRec"); 1353 Config cfg("OpieRec");
1354 cfg.setGroup("Settings"); 1354 cfg.setGroup("Settings");
1355 QString sName = directoryComboBox->text(index); 1355 QString sName = directoryComboBox->text(index);
1356 1356
1357 StorageInfo storageInfo; 1357 StorageInfo storageInfo;
1358 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1358 const QList<FileSystem> &fs = storageInfo.fileSystems();
1359 QListIterator<FileSystem> it ( fs ); 1359 QListIterator<FileSystem> it ( fs );
1360 QString storage; 1360 QString storage;
1361 for( ; it.current(); ++it ){ 1361 for( ; it.current(); ++it ){
1362 if( sName == (*it)->name()+" "+ (*it)->path() || 1362 if( sName == (*it)->name()+" "+ (*it)->path() ||
1363 (*it)->name() == sName ) { 1363 (*it)->name() == sName ) {
1364 const QString path = (*it)->path(); 1364 const QString path = (*it)->path();
1365 recDir = path; 1365 recDir = path;
1366 cfg.writeEntry("directory", recDir); 1366 cfg.writeEntry("directory", recDir);
1367 qDebug("new rec dir "+recDir); 1367 qDebug("new rec dir "+recDir);
1368 } 1368 }
1369 } 1369 }
1370 cfg.write(); 1370 cfg.write();
1371} 1371}
1372 1372
1373 1373
1374void QtRec::changeSizeLimitCombo(int) { 1374void QtRec::changeSizeLimitCombo(int) {
1375 Config cfg("OpieRec"); 1375 Config cfg("OpieRec");
1376 cfg.setGroup("Settings"); 1376 cfg.setGroup("Settings");
1377 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1377 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1378 cfg.write(); 1378 cfg.write();
1379} 1379}
1380 1380
1381void QtRec::newSound() { 1381void QtRec::newSound() {
1382 qDebug("<<<<<<<<<new sound"); 1382 qDebug("<<<<<<<<<new sound");
1383 1383
1384 if( !rec()) { 1384 if( !rec()) {
1385 qDebug("rec() failed"); 1385 qDebug("rec() failed");
1386 endRecording(); 1386 endRecording();
1387 deleteSound(); 1387 deleteSound();
1388 } 1388 }
1389 1389
1390} 1390}
1391 1391
1392void QtRec::itClick(QListViewItem *item) { 1392void QtRec::itClick(QListViewItem *item) {
1393 currentFile=item->text(0); 1393 currentFile=item->text(0);
1394 setCaption("OpieRecord "+currentFile); 1394 setCaption("OpieRecord "+currentFile);
1395} 1395}
1396 1396
1397void QtRec::deleteSound() { 1397void QtRec::deleteSound() {
1398 Config cfg("OpieRec"); 1398 Config cfg("OpieRec");
1399 cfg.setGroup("Sounds"); 1399 cfg.setGroup("Sounds");
1400 if( ListView1->currentItem() == NULL) 1400 if( ListView1->currentItem() == NULL)
1401 return; 1401 return;
1402#ifndef DEV_VERSION 1402#ifndef DEV_VERSION
1403 switch ( QMessageBox::warning(this,tr("Delete"), 1403 switch ( QMessageBox::warning(this,tr("Delete"),
1404 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), 1404 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"),
1405 tr("Yes"),tr("No"),0,1,1) ) { 1405 tr("Yes"),tr("No"),0,1,1) ) {
1406 case 0: 1406 case 0:
1407#endif 1407#endif
1408 { 1408 {
1409 QString file = ListView1->currentItem()->text(0); 1409 QString file = ListView1->currentItem()->text(0);
1410 // qDebug("Filename to find is "+file); 1410 // qDebug("Filename to find is "+file);
1411 QString fileName; 1411 QString fileName;
1412 fileName = cfg.readEntry( file, ""); 1412 fileName = cfg.readEntry( file, "");
1413 QFile f(fileName); 1413 QFile f(fileName);
1414 // qDebug("fileName is "+fileName); 1414 // qDebug("fileName is "+fileName);
1415 if(f.exists()) 1415 if(f.exists())
1416 if( !f.remove()) 1416 if( !f.remove())
1417 QMessageBox::message(tr("Error"),tr("Could not remove file.")); 1417 QMessageBox::message(tr("Error"),tr("Could not remove file."));
1418 1418
1419 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1419 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1420 bool found=false; 1420 bool found=false;
1421 for(int i=0;i<nFiles+1;i++) { 1421 for(int i=0;i<nFiles+1;i++) {
1422 // qDebug(cfg.readEntry(QString::number(i))); 1422 // qDebug(cfg.readEntry(QString::number(i)));
1423 1423
1424 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1424 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1425 found = true; 1425 found = true;
1426// qDebug( cfg.readEntry(QString::number(i))+"\n" +cfg.readEntry(QString::number(i+1)) ); 1426// qDebug( cfg.readEntry(QString::number(i))+"\n" +cfg.readEntry(QString::number(i+1)) );
1427 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1427 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1428 } 1428 }
1429 if(found) 1429 if(found)
1430 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1430 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1431 } 1431 }
1432 1432
1433 cfg.removeEntry(cfg.readEntry(file)); 1433 cfg.removeEntry(cfg.readEntry(file));
1434 cfg.removeEntry( file); 1434 cfg.removeEntry( file);
1435 // cfg.removeEntry( QString::number(nFiles)); 1435 // cfg.removeEntry( QString::number(nFiles));
1436 cfg.writeEntry("NumberofFiles", nFiles-1); 1436 cfg.writeEntry("NumberofFiles", nFiles-1);
1437 cfg.write(); 1437 cfg.write();
1438 1438
1439 ListView1->takeItem( ListView1->currentItem() ); 1439 ListView1->takeItem( ListView1->currentItem() );
1440 // ListView1->takeItem( ListView1->itemAt(nFiles) ); 1440 // ListView1->takeItem( ListView1->itemAt(nFiles) );
1441 delete ListView1->currentItem(); 1441 delete ListView1->currentItem();
1442 1442
1443 ListView1->clear(); 1443 ListView1->clear();
1444 ListView1->setSelected(ListView1->firstChild(), true); 1444 ListView1->setSelected(ListView1->firstChild(), true);
1445 initIconView(); 1445 initIconView();
1446 update(); 1446 update();
1447 } 1447 }
1448#ifndef DEV_VERSION 1448#ifndef DEV_VERSION
1449 }; 1449 };
1450#endif 1450#endif
1451 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1451 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1452 1452
1453} 1453}
1454 1454
1455void QtRec::keyPressEvent( QKeyEvent *e) { 1455void QtRec::keyPressEvent( QKeyEvent *e) {
1456 1456
1457 switch ( e->key() ) { 1457 switch ( e->key() ) {
1458 /* 1458 /*
1459 vercel keys-> 1459 vercel keys->
1460 right side 1460 right side
1461 0 1461 0
1462 1 0x1030 Key_F1 1462 1 0x1030 Key_F1
1463 2 0x1031 Key_F2 1463 2 0x1031 Key_F2
1464 3 0x1032 Key_F3 1464 3 0x1032 Key_F3
1465 4 0x1016 Key_PageUp 1465 4 0x1016 Key_PageUp
1466 5 0x1017 Key_PageDown 1466 5 0x1017 Key_PageDown
1467 6 1467 6
1468 --------------- 1468 ---------------
1469 left side 1469 left side
1470 Up 0x1013 Key_Up 1470 Up 0x1013 Key_Up
1471 Down 0x1015 Key_Down 1471 Down 0x1015 Key_Down
1472 Left 0x1012 Key_Left 1472 Left 0x1012 Key_Left
1473 Right 0x1014 Key_Right 1473 Right 0x1014 Key_Right
1474 0x1010 Key_Home 1474 0x1010 Key_Home
1475 1475
1476 */ 1476 */
1477 // case Key_F1: 1477 // case Key_F1:
1478 // if(stopped && !recording) 1478 // if(stopped && !recording)
1479 // newSound(); 1479 // newSound();
1480 // else 1480 // else
1481 // stop(); 1481 // stop();
1482 // break; 1482 // break;
1483 // case Key_F2: { 1483 // case Key_F2: {
1484 // if( !e->isAutoRepeat()) 1484 // if( !e->isAutoRepeat())
1485 // rewindPressed(); 1485 // rewindPressed();
1486 // } 1486 // }
1487 // break; 1487 // break;
1488 // case Key_F3: { 1488 // case Key_F3: {
1489 // if( !e->isAutoRepeat()) 1489 // if( !e->isAutoRepeat())
1490 // FastforwardPressed(); 1490 // FastforwardPressed();
1491 // } 1491 // }
1492 // break; 1492 // break;
1493 1493
1494 ////////////////////////////// Zaurus keys 1494 ////////////////////////////// Zaurus keys
1495 case Key_F9: //activity 1495 case Key_F9: //activity
1496 break; 1496 break;
1497 case Key_F10: //contacts 1497 case Key_F10: //contacts
1498 break; 1498 break;
1499 case Key_F11: //menu 1499 case Key_F11: //menu
1500 break; 1500 break;
1501 case Key_F12: //home 1501 case Key_F12: //home
1502 break; 1502 break;
1503 case Key_F13: //mail 1503 case Key_F13: //mail
1504 break; 1504 break;
1505 case Key_Space: 1505 case Key_Space:
1506 break; 1506 break;
1507 case Key_Delete: 1507 case Key_Delete:
1508 break; 1508 break;
1509 case Key_Up: 1509 case Key_Up:
1510 // stop(); 1510 // stop();
1511 break; 1511 break;
1512 case Key_Down: 1512 case Key_Down:
1513 // newSound(); 1513 // newSound();
1514 break; 1514 break;
1515 case Key_Left: { 1515 case Key_Left: {
1516 qDebug("rewinding"); 1516 qDebug("rewinding");
1517 if( !e->isAutoRepeat()) 1517 if( !e->isAutoRepeat())
1518 rewindPressed(); 1518 rewindPressed();
1519 } 1519 }
1520 break; 1520 break;
1521 case Key_Right: { 1521 case Key_Right: {
1522 if( !e->isAutoRepeat()) 1522 if( !e->isAutoRepeat())
1523 FastforwardPressed(); 1523 FastforwardPressed();
1524 } 1524 }
1525 break; 1525 break;
1526 } 1526 }
1527} 1527}
1528 1528
1529void QtRec::keyReleaseEvent( QKeyEvent *e) { 1529void QtRec::keyReleaseEvent( QKeyEvent *e) {
1530 switch ( e->key() ) { 1530 switch ( e->key() ) {
1531 // case Key_F1: 1531 // case Key_F1:
1532 // if(stopped && !recording) 1532 // if(stopped && !recording)
1533 // newSound(); 1533 // newSound();
1534 // else 1534 // else
1535 // stop(); 1535 // stop();
1536 // break; 1536 // break;
1537 // case Key_F2: 1537 // case Key_F2:
1538 // rewindReleased(); 1538 // rewindReleased();
1539 // break; 1539 // break;
1540 // case Key_F3: 1540 // case Key_F3:
1541 // FastforwardReleased(); 1541 // FastforwardReleased();
1542 // break; 1542 // break;
1543 1543
1544 ////////////////////////////// Zaurus keys 1544 ////////////////////////////// Zaurus keys
1545 case Key_F9: //activity 1545 case Key_F9: //activity
1546 break; 1546 break;
1547 case Key_F10: //contacts 1547 case Key_F10: //contacts
1548 break; 1548 break;
1549 case Key_F11: //menu 1549 case Key_F11: //menu
1550 break; 1550 break;
1551 case Key_F12: //home 1551 case Key_F12: //home
1552 if(stopped) 1552 if(stopped)
1553 doPlayBtn(); 1553 doPlayBtn();
1554 else 1554 else
1555 stop(); 1555 stop();
1556 break; 1556 break;
1557 case Key_F13: //mail 1557 case Key_F13: //mail
1558 break; 1558 break;
1559 case Key_Space: 1559 case Key_Space:
1560 if(stopped && !recording) 1560 if(stopped && !recording)
1561 newSound(); 1561 newSound();
1562 else 1562 else
1563 stop(); 1563 stop();
1564 break; 1564 break;
1565 case Key_Delete: 1565 case Key_Delete:
1566 deleteSound(); 1566 deleteSound();
1567 break; 1567 break;
1568 case Key_Up: 1568 case Key_Up:
1569 // stop(); 1569 // stop();
1570 qDebug("Up"); 1570 qDebug("Up");
1571 break; 1571 break;
1572 case Key_Down: 1572 case Key_Down:
1573 // start(); 1573 // start();
1574 // qDebug("Down"); 1574 // qDebug("Down");
1575 // newSound(); 1575 // newSound();
1576 break; 1576 break;
1577 case Key_Left: 1577 case Key_Left:
1578 qDebug("Left"); 1578 qDebug("Left");
1579 rewindReleased(); 1579 rewindReleased();
1580 break; 1580 break;
1581 case Key_Right: 1581 case Key_Right:
1582 qDebug("Right"); 1582 qDebug("Right");
1583 FastforwardReleased(); 1583 FastforwardReleased();
1584 break; 1584 break;
1585 } 1585 }
1586} 1586}
1587 1587
1588void QtRec::endRecording() { 1588void QtRec::endRecording() {
1589 qDebug("endRecording"); 1589 qDebug("endRecording");
1590 setRecordButton(false); 1590 setRecordButton(false);
1591 timeSlider->setValue(0); 1591 timeSlider->setValue(0);
1592 toBeginningButton->setEnabled(true); 1592 toBeginningButton->setEnabled(true);
1593 toEndButton->setEnabled(true); 1593 toEndButton->setEnabled(true);
1594 1594
1595 monitoring=false; 1595 monitoring=false;
1596 1596
1597 killTimers(); 1597 killTimers();
1598 1598
1599 if(autoMute) 1599 if(autoMute)
1600 doMute(true); 1600 doMute(true);
1601 1601
1602 soundDevice->closeDevice( true); 1602 soundDevice->closeDevice( true);
1603 1603
1604 recording = false; 1604 recording = false;
1605 stopped=true; 1605 stopped=true;
1606 t->stop(); 1606 t->stop();
1607 1607
1608 if( wavFile->track.isOpen()) { 1608 if( wavFile->track.isOpen()) {
1609 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1609 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1610 // soundDevice->sd=-1; 1610 // soundDevice->sd=-1;
1611 filePara.numberSamples=0; 1611 filePara.numberSamples=0;
1612 // filePara.sd=-1; 1612 // filePara.sd=-1;
1613 wavFile->closeFile(); 1613 wavFile->closeFile();
1614 filePara.fd=0; 1614 filePara.fd=0;
1615 1615
1616 if(wavFile->isTempFile()) { 1616 if(wavFile->isTempFile()) {
1617// move tmp file to regular file 1617// move tmp file to regular file
1618 QString cmd; 1618 QString cmd;
1619 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1619 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1620 qDebug("moving tmp file to "+currentFileName); 1620 qDebug("moving tmp file to "+currentFileName);
1621 system(cmd.latin1()); 1621 system(cmd.latin1());
1622 } 1622 }
1623 1623
1624 qDebug("Just moved "+wavFile->currentFileName); 1624 qDebug("Just moved "+wavFile->currentFileName);
1625 Config cfg("OpieRec"); 1625 Config cfg("OpieRec");
1626 cfg.setGroup("Sounds"); 1626 cfg.setGroup("Sounds");
1627 1627
1628 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1628 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1629 1629
1630 currentFile = QFileInfo(wavFile->currentFileName).fileName(); 1630 currentFile = QFileInfo(wavFile->currentFileName).fileName();
1631 currentFile=currentFile.left(currentFile.length()-4); 1631 currentFile=currentFile.left(currentFile.length()-4);
1632 1632
1633 cfg.writeEntry( "NumberofFiles",nFiles+1); 1633 cfg.writeEntry( "NumberofFiles",nFiles+1);
1634 cfg.writeEntry( QString::number( nFiles+1), currentFile); 1634 cfg.writeEntry( QString::number( nFiles+1), currentFile);
1635 cfg.writeEntry( currentFile, wavFile->currentFileName); 1635 cfg.writeEntry( currentFile, wavFile->currentFileName);
1636 1636
1637 QString time; 1637 QString time;
1638 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1638 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1639 cfg.writeEntry( wavFile->currentFileName, time ); 1639 cfg.writeEntry( wavFile->currentFileName, time );
1640 qDebug("writing config numberOfRecordedSeconds "+time); 1640 qDebug("writing config numberOfRecordedSeconds "+time);
1641 1641
1642 cfg.write(); 1642 cfg.write();
1643 qDebug("finished recording"); 1643 qDebug("finished recording");
1644 timeLabel->setText(""); 1644 timeLabel->setText("");
1645 } 1645 }
1646 1646
1647 if(soundDevice) delete soundDevice; 1647 if(soundDevice) delete soundDevice;
1648 1648
1649 initIconView(); 1649 initIconView();
1650 selectItemByName(currentFile); 1650 selectItemByName(currentFile);
1651} 1651}
1652 1652
1653void QtRec::endPlaying() { 1653void QtRec::endPlaying() {
1654 1654
1655 qDebug("end playing"); 1655 qDebug("end playing");
1656 setRecordButton(false); 1656 setRecordButton(false);
1657 1657
1658 toBeginningButton->setEnabled(true); 1658 toBeginningButton->setEnabled(true);
1659 toEndButton->setEnabled(true); 1659 toEndButton->setEnabled(true);
1660 1660
1661 if(autoMute) 1661 if(autoMute)
1662 doMute(true); 1662 doMute(true);
1663 1663
1664 soundDevice->closeDevice( false); 1664 soundDevice->closeDevice( false);
1665 soundDevice->sd=-1; 1665 soundDevice->sd=-1;
1666 // if(soundDevice) delete soundDevice; 1666 // if(soundDevice) delete soundDevice;
1667 qDebug("file and sound device closed"); 1667 qDebug("file and sound device closed");
1668 stopped=true; 1668 stopped=true;
1669 recording=false; 1669 recording=false;
1670 playing=false; 1670 playing=false;
1671 timeLabel->setText(""); 1671 timeLabel->setText("");
1672 monitoring=false; 1672 monitoring=false;
1673 total = 0; 1673 total = 0;
1674 filePara.numberSamples=0; 1674 filePara.numberSamples=0;
1675 filePara.sd=-1; 1675 filePara.sd=-1;
1676 wavFile->closeFile(); 1676 wavFile->closeFile();
1677 filePara.fd=0; 1677 filePara.fd=0;
1678// if(wavFile) delete wavFile; //this crashes 1678// if(wavFile) delete wavFile; //this crashes
1679 1679
1680 qDebug("track closed"); 1680 qDebug("track closed");
1681 timeSlider->setValue(0); 1681 timeSlider->setValue(0);
1682 1682
1683 if(soundDevice) delete soundDevice; 1683 if(soundDevice) delete soundDevice;
1684 1684
1685} 1685}
1686 1686
1687bool QtRec::openPlayFile() { 1687bool QtRec::openPlayFile() {
1688 1688
1689 qApp->processEvents(); 1689 qApp->processEvents();
1690 if( currentFile.isEmpty()) { 1690 if( currentFile.isEmpty()) {
1691 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1691 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1692 endPlaying(); 1692 endPlaying();
1693 return false; 1693 return false;
1694 } 1694 }
1695 QString currentFileName; 1695 QString currentFileName;
1696 Config cfg("OpieRec"); 1696 Config cfg("OpieRec");
1697 cfg.setGroup("Sounds"); 1697 cfg.setGroup("Sounds");
1698 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1698 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1699 for(int i=0;i<nFiles+1;i++) { //look for file 1699 for(int i=0;i<nFiles+1;i++) { //look for file
1700 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1700 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1701 currentFileName=cfg.readEntry( currentFile, "" ); 1701 currentFileName=cfg.readEntry( currentFile, "" );
1702 qDebug("opening for play: "+currentFileName); 1702 qDebug("opening for play: "+currentFileName);
1703 } 1703 }
1704 } 1704 }
1705 wavFile = new WavFile(this, 1705 wavFile = new WavFile(this,
1706 currentFileName, 1706 currentFileName,
1707 false); 1707 false);
1708 filePara.fd = wavFile->wavHandle(); 1708 filePara.fd = wavFile->wavHandle();
1709 if(filePara.fd == -1) { 1709 if(filePara.fd == -1) {
1710 // if(!track.open(IO_ReadOnly)) { 1710 // if(!track.open(IO_ReadOnly)) {
1711 QString errorMsg=(QString)strerror(errno); 1711 QString errorMsg=(QString)strerror(errno);
1712 monitoring=false; 1712 monitoring=false;
1713 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1713 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1714 QMessageBox::message(tr("Note"),tr("Could not open audio file.\n") 1714 QMessageBox::message(tr("Note"),tr("Could not open audio file.\n")
1715 +errorMsg+"\n"+currentFile); 1715 +errorMsg+"\n"+currentFile);
1716 return false; 1716 return false;
1717 } else { 1717 } else {
1718 filePara.numberSamples=wavFile->getNumberSamples(); 1718 filePara.numberSamples=wavFile->getNumberSamples();
1719 filePara.format = wavFile->getFormat(); 1719 filePara.format = wavFile->getFormat();
1720 // qDebug("file %d, samples %f", filePara.fd, filePara.numberSamples); 1720 // qDebug("file %d, samples %f", filePara.fd, filePara.numberSamples);
1721 filePara.sampleRate= wavFile->getSampleRate(); 1721 filePara.sampleRate= wavFile->getSampleRate();
1722 filePara.resolution=wavFile->getResolution(); 1722 filePara.resolution=wavFile->getResolution();
1723 timeSlider->setPageStep(1); 1723 timeSlider->setPageStep(1);
1724 monitoring=true; 1724 monitoring=true;
1725 timeSlider->setRange(0, filePara.numberSamples ); 1725 timeSlider->setRange(0, filePara.numberSamples );
1726 filePara.numberOfRecordedSeconds=(float) filePara.numberSamples / (float)filePara.sampleRate * (float)2; 1726 filePara.numberOfRecordedSeconds=(float) filePara.numberSamples / (float)filePara.sampleRate * (float)2;
1727 } 1727 }
1728 1728
1729 return true; 1729 return true;
1730} 1730}
1731 1731
1732void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1732void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1733 if(item == NULL ) 1733 if(item == NULL )
1734 return; 1734 return;
1735 switch (mouse) { 1735 switch (mouse) {
1736 case 1: { 1736 case 1: {
1737 if( renameBox !=0 ) //tricky 1737 if( renameBox !=0 ) //tricky
1738 cancelRename(); 1738 cancelRename();
1739 1739
1740 currentFile=item->text(0); 1740 currentFile=item->text(0);
1741 setCaption( "OpieRecord "+currentFile); 1741 setCaption( "OpieRecord "+currentFile);
1742 } 1742 }
1743 break; 1743 break;
1744 case 2: 1744 case 2:
1745 showListMenu(item); 1745 showListMenu(item);
1746 ListView1->clearSelection(); 1746 ListView1->clearSelection();
1747 break; 1747 break;
1748 }; 1748 };
1749} 1749}
1750 1750
1751void QtRec::showListMenu(QListViewItem * item) { 1751void QtRec::showListMenu(QListViewItem * item) {
1752 if(item == NULL) 1752 if(item == NULL)
1753 return; 1753 return;
1754 QPopupMenu *m = new QPopupMenu(this); 1754 QPopupMenu *m = new QPopupMenu(this);
1755 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); 1755 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() ));
1756 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); 1756 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() ));
1757 m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); 1757 m->insertItem( tr( "Rename" ), this, SLOT( doRename() ));
1758 // #if defined (QTOPIA_INTERNAL_FSLP) 1758 // #if defined (QTOPIA_INTERNAL_FSLP)
1759 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1759 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1760 // #endif 1760 // #endif
1761 m->insertSeparator(); 1761 m->insertSeparator();
1762 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); 1762 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) );
1763 m->exec( QCursor::pos() ); 1763 m->exec( QCursor::pos() );
1764 qApp->processEvents(); 1764 qApp->processEvents();
1765} 1765}
1766 1766
1767void QtRec::fileBeamFinished( Ir *ir) { 1767void QtRec::fileBeamFinished( Ir *ir) {
1768 if(ir) 1768 if(ir)
1769 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); 1769 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") );
1770 1770
1771} 1771}
1772 1772
1773void QtRec::doBeam() { 1773void QtRec::doBeam() {
1774 qApp->processEvents(); 1774 qApp->processEvents();
1775 if( ListView1->currentItem() == NULL) 1775 if( ListView1->currentItem() == NULL)
1776 return; 1776 return;
1777 Ir ir; 1777 Ir ir;
1778 if( ir.supported()) { 1778 if( ir.supported()) {
1779 QString file = ListView1->currentItem()->text(0); 1779 QString file = ListView1->currentItem()->text(0);
1780 Config cfg("OpieRec"); 1780 Config cfg("OpieRec");
1781 cfg.setGroup("Sounds"); 1781 cfg.setGroup("Sounds");
1782 1782
1783 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1783 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1784 1784
1785 for(int i=0;i<nFiles+1;i++) { 1785 for(int i=0;i<nFiles+1;i++) {
1786 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1786 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1787 QString filePath = cfg.readEntry(file,""); 1787 QString filePath = cfg.readEntry(file,"");
1788 Ir *file = new Ir(this, "IR"); 1788 Ir *file = new Ir(this, "IR");
1789 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1789 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1790 file->send( filePath, "OPieRec audio file\n"+filePath ); 1790 file->send( filePath, "OPieRec audio file\n"+filePath );
1791 } 1791 }
1792 } 1792 }
1793 } 1793 }
1794} 1794}
1795 1795
1796void QtRec::doMenuPlay() { 1796void QtRec::doMenuPlay() {
1797 qApp->processEvents(); 1797 qApp->processEvents();
1798 currentFile = ListView1->currentItem()->text(0); 1798 currentFile = ListView1->currentItem()->text(0);
1799} 1799}
1800 1800
1801void QtRec::doRename() { 1801void QtRec::doRename() {
1802 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1802 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1803 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1803 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1804 r.setX( ListView1->contentsX() ); 1804 r.setX( ListView1->contentsX() );
1805 if ( r.width() > ListView1->visibleWidth() ) 1805 if ( r.width() > ListView1->visibleWidth() )
1806 r.setWidth( ListView1->visibleWidth() ); 1806 r.setWidth( ListView1->visibleWidth() );
1807 1807
1808 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1808 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1809 renameBox->setFrame(true); 1809 renameBox->setFrame(true);
1810 1810
1811 renameBox->setText( ListView1->currentItem()->text(0) ); 1811 renameBox->setText( ListView1->currentItem()->text(0) );
1812 1812
1813 renameBox->selectAll(); 1813 renameBox->selectAll();
1814 renameBox->installEventFilter( this ); 1814 renameBox->installEventFilter( this );
1815 ListView1->addChild( renameBox, r.x(), r.y() ); 1815 ListView1->addChild( renameBox, r.x(), r.y() );
1816 renameBox->resize( r.size() ); 1816 renameBox->resize( r.size() );
1817 ListView1->viewport()->setFocusProxy( renameBox ); 1817 ListView1->viewport()->setFocusProxy( renameBox );
1818 renameBox->setFocus(); 1818 renameBox->setFocus();
1819 renameBox->show(); 1819 renameBox->show();
1820 1820
1821} 1821}
1822 1822
1823void QtRec::okRename() { 1823void QtRec::okRename() {
1824 qDebug("okRename"); 1824 qDebug("okRename");
1825 qDebug(renameBox->text()); 1825 qDebug(renameBox->text());
1826 QString filename = renameBox->text(); 1826 QString filename = renameBox->text();
1827 cancelRename(); 1827 cancelRename();
1828 1828
1829 if( ListView1->currentItem() == NULL) 1829 if( ListView1->currentItem() == NULL)
1830 return; 1830 return;
1831 1831
1832 Config cfg("OpieRec"); 1832 Config cfg("OpieRec");
1833 cfg.setGroup("Sounds"); 1833 cfg.setGroup("Sounds");
1834 1834
1835 QString file = ListView1->currentItem()->text(0); 1835 QString file = ListView1->currentItem()->text(0);
1836 1836
1837 qDebug("filename is " + filename); 1837 qDebug("filename is " + filename);
1838 1838
1839 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1839 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1840 1840
1841 for(int i=0;i<nFiles+1;i++) { //look for file 1841 for(int i=0;i<nFiles+1;i++) { //look for file
1842 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1842 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1843 1843
1844 QString filePath = cfg.readEntry(file,""); 1844 QString filePath = cfg.readEntry(file,"");
1845 1845
1846 cfg.writeEntry( QString::number(i), filename ); 1846 cfg.writeEntry( QString::number(i), filename );
1847 cfg.writeEntry( filename, filePath ); 1847 cfg.writeEntry( filename, filePath );
1848 cfg.removeEntry(file); 1848 cfg.removeEntry(file);
1849 cfg.write(); 1849 cfg.write();
1850 } 1850 }
1851 } 1851 }
1852 1852
1853 ListView1->takeItem( ListView1->currentItem() ); 1853 ListView1->takeItem( ListView1->currentItem() );
1854 delete ListView1->currentItem(); 1854 delete ListView1->currentItem();
1855 ListView1->clear(); 1855 ListView1->clear();
1856 initIconView(); 1856 initIconView();
1857 update(); 1857 update();
1858} 1858}
1859 1859
1860void QtRec::cancelRename() { 1860void QtRec::cancelRename() {
1861 qDebug("cancel rename"); 1861 qDebug("cancel rename");
1862 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1862 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1863 delete renameBox; 1863 delete renameBox;
1864 renameBox = 0; 1864 renameBox = 0;
1865 if ( resetFocus ) { 1865 if ( resetFocus ) {
1866 ListView1->viewport()->setFocusProxy( ListView1 ); 1866 ListView1->viewport()->setFocusProxy( ListView1 );
1867 ListView1->setFocus(); 1867 ListView1->setFocus();
1868 } 1868 }
1869} 1869}
1870 1870
1871bool QtRec::eventFilter( QObject * o, QEvent * e ) { 1871bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1872 if ( o->inherits( "QLineEdit" ) ) { 1872 if ( o->inherits( "QLineEdit" ) ) {
1873 if ( e->type() == QEvent::KeyPress ) { 1873 if ( e->type() == QEvent::KeyPress ) {
1874 QKeyEvent *ke = (QKeyEvent*)e; 1874 QKeyEvent *ke = (QKeyEvent*)e;
1875 if ( ke->key() == Key_Return || 1875 if ( ke->key() == Key_Return ||
1876 ke->key() == Key_Enter ) { 1876 ke->key() == Key_Enter ) {
1877 okRename(); 1877 okRename();
1878 return true; 1878 return true;
1879 } else if ( ke->key() == Key_Escape ) { 1879 } else if ( ke->key() == Key_Escape ) {
1880 cancelRename(); 1880 cancelRename();
1881 return true; 1881 return true;
1882 } 1882 }
1883 } else if ( e->type() == QEvent::FocusOut ) { 1883 } else if ( e->type() == QEvent::FocusOut ) {
1884 cancelRename(); 1884 cancelRename();
1885 return true; 1885 return true;
1886 } 1886 }
1887 } 1887 }
1888 return QWidget::eventFilter( o, e ); 1888 return QWidget::eventFilter( o, e );
1889} 1889}
1890 1890
1891 1891
1892int QtRec::getCurrentSizeLimit() { 1892int QtRec::getCurrentSizeLimit() {
1893 return sizeLimitCombo->currentItem() * 5; 1893 return sizeLimitCombo->currentItem() * 5;
1894} 1894}
1895 1895
1896void QtRec::timerBreak() { 1896void QtRec::timerBreak() {
1897 qDebug("timer break"); 1897 qDebug("timer break");
1898 stop(); 1898 stop();
1899} 1899}
1900 1900
1901void QtRec::doVolMuting(bool b) { 1901void QtRec::doVolMuting(bool b) {
1902 Config cfg( "qpe" ); 1902 Config cfg( "qpe" );
1903 cfg. setGroup( "Volume" ); 1903 cfg. setGroup( "Volume" );
1904 cfg.writeEntry( "Mute",b); 1904 cfg.writeEntry( "Mute",b);
1905 cfg.write(); 1905 cfg.write();
1906 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1906 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1907} 1907}
1908 1908
1909void QtRec::doMicMuting(bool b) { 1909void QtRec::doMicMuting(bool b) {
1910 // qDebug("mic mute"); 1910 // qDebug("mic mute");
1911 Config cfg( "qpe" ); 1911 Config cfg( "qpe" );
1912 cfg. setGroup( "Volume" ); 1912 cfg. setGroup( "Volume" );
1913 cfg.writeEntry( "MicMute",b); 1913 cfg.writeEntry( "MicMute",b);
1914 cfg.write(); 1914 cfg.write();
1915 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1915 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1916} 1916}
1917 1917
1918void QtRec::compressionSelected(bool b) { 1918void QtRec::compressionSelected(bool b) {
1919 Config cfg("OpieRec"); 1919 Config cfg("OpieRec");
1920 cfg.setGroup("Settings"); 1920 cfg.setGroup("Settings");
1921 cfg.writeEntry("wavCompression", b); 1921 cfg.writeEntry("wavCompression", b);
1922 cfg.writeEntry("bitrate",16); filePara.resolution=16; 1922 cfg.writeEntry("bitrate",16); filePara.resolution=16;
1923 cfg.write(); 1923 cfg.write();
1924 1924
1925 if(b) { 1925 if(b) {
1926 bitRateComboBox->setEnabled(false); 1926 bitRateComboBox->setEnabled(false);
1927 bitRateComboBox->setCurrentItem(0); 1927 bitRateComboBox->setCurrentItem(0);
1928 filePara.resolution=16; 1928 filePara.resolution=16;
1929 } else{ 1929 } else{
1930 bitRateComboBox->setEnabled(true); 1930 bitRateComboBox->setEnabled(true);
1931 } 1931 }
1932} 1932}
1933 1933
1934long QtRec::checkDiskSpace(const QString &path) { 1934long QtRec::checkDiskSpace(const QString &path) {
1935 1935
1936 struct statfs fs; 1936 struct statfs fs;
1937 1937
1938 if ( !statfs( path.latin1(), &fs ) ) { 1938 if ( !statfs( path.latin1(), &fs ) ) {
1939 1939
1940 int blkSize = fs.f_bsize; 1940 int blkSize = fs.f_bsize;
1941 int availBlks = fs.f_bavail; 1941 int availBlks = fs.f_bavail;
1942 1942
1943 long mult = blkSize / 1024; 1943 long mult = blkSize / 1024;
1944 long div = 1024 / blkSize; 1944 long div = 1024 / blkSize;
1945 1945
1946 if ( !mult ) mult = 1; 1946 if ( !mult ) mult = 1;
1947 if ( !div ) div = 1; 1947 if ( !div ) div = 1;
1948 1948
1949 return availBlks * mult / div; 1949 return availBlks * mult / div;
1950 } 1950 }
1951 return -1; 1951 return -1;
1952} 1952}
1953 1953
1954// short f_fstyp; /* File system type */ 1954// short f_fstyp; /* File system type */
1955// long f_bsize; /* Block size */ 1955// long f_bsize; /* Block size */
1956// long f_frsize; /* Fragment size */ 1956// long f_frsize; /* Fragment size */
1957// long f_blocks; /* Total number of blocks*/ 1957// long f_blocks; /* Total number of blocks*/
1958// long f_bfree; /* Count of free blocks */ 1958// long f_bfree; /* Count of free blocks */
1959// long f_files; /* Total number of file nodes */ 1959// long f_files; /* Total number of file nodes */
1960// long f_ffree; /* Count of free file nodes */ 1960// long f_ffree; /* Count of free file nodes */
1961// char f_fname[6]; /* Volumename */ 1961// char f_fname[6]; /* Volumename */
1962// char f_fpack[6]; /* Pack name */ 1962// char f_fpack[6]; /* Pack name */
1963 1963
1964void QtRec::receive( const QCString &msg, const QByteArray & ) { 1964void QtRec::receive( const QCString &msg, const QByteArray & ) {
1965 qDebug("Voicerecord received message "+msg); 1965 qDebug("Voicerecord received message "+msg);
1966 1966
1967} 1967}
1968 1968
1969 1969
1970///////////////////////////// timerEvent 1970///////////////////////////// timerEvent
1971void QtRec::timerEvent( QTimerEvent *e ) { 1971void QtRec::timerEvent( QTimerEvent *e ) {
1972// qDebug( "%d", secCount ); 1972// qDebug( "%d", secCount );
1973#ifdef DEV_VERSION 1973#ifdef DEV_VERSION
1974 QString msg; 1974 QString msg;
1975 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1975 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1976 setCaption( msg +" :: "+QString::number(secCount)); 1976 setCaption( msg +" :: "+QString::number(secCount));
1977#endif 1977#endif
1978 1978
1979 if( !playing ) { 1979 if( !playing ) {
1980 if(!recording ){ 1980 if(!recording ){
1981 killTimer(e->timerId()); 1981 killTimer(e->timerId());
1982///* stopped=true; 1982///* stopped=true;
1983// recording=false; 1983// recording=false;
1984///*/ 1984///*/
1985// _exit( 0); 1985// _exit( 0);
1986 } 1986 }
1987 if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) { 1987 if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) {
1988 killTimer(e->timerId()); 1988 killTimer(e->timerId());
1989 stop(); 1989 stop();
1990 } 1990 }
1991 } 1991 }
1992// if( stopped && !paused) { 1992// if( stopped && !paused) {
1993// if( filePara.numberOfRecordedSeconds < secCount) { 1993// if( filePara.numberOfRecordedSeconds < secCount) {
1994// stopped = true; 1994// stopped = true;
1995// // playing=false; 1995// // playing=false;
1996// killTimer(e->timerId()); 1996// killTimer(e->timerId());
1997// endPlaying(); 1997// endPlaying();
1998// } 1998// }
1999// } 1999// }
2000// qApp->processEvents(); 2000// qApp->processEvents();
2001 secCount++; 2001 secCount++;
2002} 2002}
2003 2003
2004void QtRec::changeTimeSlider(int index) { 2004void QtRec::changeTimeSlider(int index) {
2005 if(ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 2005 if(ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
2006 // qDebug("Slider moved to %d",index); 2006 // qDebug("Slider moved to %d",index);
2007 paused = true; 2007 paused = true;
2008 stopped = true; 2008 stopped = true;
2009 2009
2010 sliderPos=index; 2010 sliderPos=index;
2011 2011
2012 QString timeString; 2012 QString timeString;
2013 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 2013 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2;
2014 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 2014 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2015 secCount = (int)filePara.numberOfRecordedSeconds; 2015 secCount = (int)filePara.numberOfRecordedSeconds;
2016 timeLabel->setText( timeString+ tr(" seconds")); 2016 timeLabel->setText( timeString+ tr(" seconds"));
2017} 2017}
2018 2018
2019void QtRec::timeSliderPressed() { 2019void QtRec::timeSliderPressed() {
2020 if(ListView1->currentItem() == 0) return; 2020 if(ListView1->currentItem() == 0) return;
2021 // qDebug("slider pressed"); 2021 // qDebug("slider pressed");
2022 paused = true; 2022 paused = true;
2023 stopped = true; 2023 stopped = true;
2024} 2024}
2025 2025
2026void QtRec::timeSliderReleased() { 2026void QtRec::timeSliderReleased() {
2027 if(ListView1->currentItem() == 0) return; 2027 if(ListView1->currentItem() == 0) return;
2028 sliderPos=timeSlider->value(); 2028 sliderPos=timeSlider->value();
2029 2029
2030 // qDebug("slider released %d", sliderPos); 2030 // qDebug("slider released %d", sliderPos);
2031 stopped = false; 2031 stopped = false;
2032 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 2032 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2033 total = newPos*4; 2033 total = newPos*4;
2034 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 2034 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2;
2035 2035
2036 doPlay(); 2036 doPlay();
2037} 2037}
2038 2038
2039void QtRec::rewindPressed() { 2039void QtRec::rewindPressed() {
2040 if(ListView1->currentItem() == 0) return; 2040 if(ListView1->currentItem() == 0) return;
2041 if( !wavFile->track.isOpen()) { 2041 if( !wavFile->track.isOpen()) {
2042 if( !openPlayFile() ) 2042 if( !openPlayFile() )
2043 return; 2043 return;
2044 else 2044 else
2045 if( !setupAudio( false)) 2045 if( !setupAudio( false))
2046 return; 2046 return;
2047 } else { 2047 } else {
2048 killTimers(); 2048 killTimers();
2049 paused = true; 2049 paused = true;
2050 stopped = true; 2050 stopped = true;
2051 rewindTimer->start(50, false); 2051 rewindTimer->start(50, false);
2052 } 2052 }
2053} 2053}
2054 2054
2055void QtRec::rewindTimerTimeout() { 2055void QtRec::rewindTimerTimeout() {
2056 int sliderValue = timeSlider->value(); 2056 int sliderValue = timeSlider->value();
2057 sliderValue = sliderValue-(filePara.numberSamples/100); 2057 sliderValue = sliderValue-(filePara.numberSamples/100);
2058 // if(toBeginningButton->isDown()) 2058 // if(toBeginningButton->isDown())
2059 timeSlider->setValue( sliderValue ) ; 2059 timeSlider->setValue( sliderValue ) ;
2060 // qDebug("%d", sliderValue); 2060 // qDebug("%d", sliderValue);
2061 QString timeString; 2061 QString timeString;
2062 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2; 2062 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2;
2063 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 2063 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2064 timeLabel->setText( timeString+ tr(" seconds")); 2064 timeLabel->setText( timeString+ tr(" seconds"));
2065} 2065}
2066 2066
2067void QtRec::rewindReleased() { 2067void QtRec::rewindReleased() {
2068 rewindTimer->stop(); 2068 rewindTimer->stop();
2069 if( wavFile->track.isOpen()) { 2069 if( wavFile->track.isOpen()) {
2070 sliderPos=timeSlider->value(); 2070 sliderPos=timeSlider->value();
2071 stopped = false; 2071 stopped = false;
2072 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 2072 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2073 total = newPos*4; 2073 total = newPos*4;
2074 // qDebug("rewind released %d", total); 2074 // qDebug("rewind released %d", total);
2075 startTimer(1000); 2075 startTimer(1000);
2076 doPlay(); 2076 doPlay();
2077 } 2077 }
2078} 2078}
2079 2079
2080void QtRec::FastforwardPressed() { 2080void QtRec::FastforwardPressed() {
2081 if(ListView1->currentItem() == 0) return; 2081 if(ListView1->currentItem() == 0) return;
2082 if( !wavFile->track.isOpen()) 2082 if( !wavFile->track.isOpen())
2083 if( !openPlayFile() ) 2083 if( !openPlayFile() )
2084 return; 2084 return;
2085 else 2085 else
2086 if( !setupAudio( false)) 2086 if( !setupAudio( false))
2087 return; 2087 return;
2088 killTimers(); 2088 killTimers();
2089 2089
2090 paused = true; 2090 paused = true;
2091 stopped = true; 2091 stopped = true;
2092 forwardTimer->start(50, false); 2092 forwardTimer->start(50, false);
2093} 2093}
2094 2094
2095 2095
2096void QtRec::forwardTimerTimeout() { 2096void QtRec::forwardTimerTimeout() {
2097 int sliderValue = timeSlider->value(); 2097 int sliderValue = timeSlider->value();
2098 sliderValue = sliderValue +(filePara.numberSamples/100); 2098 sliderValue = sliderValue +(filePara.numberSamples/100);
2099 2099
2100 // if(toEndButton->isDown()) 2100 // if(toEndButton->isDown())
2101 timeSlider->setValue(sliderValue); 2101 timeSlider->setValue(sliderValue);
2102 2102
2103 QString timeString; 2103 QString timeString;
2104 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2; 2104 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2;
2105 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 2105 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2106 timeLabel->setText( timeString+ tr(" seconds")); 2106 timeLabel->setText( timeString+ tr(" seconds"));
2107} 2107}
2108 2108
2109void QtRec::FastforwardReleased() { 2109void QtRec::FastforwardReleased() {
2110 forwardTimer->stop(); 2110 forwardTimer->stop();
2111 if( wavFile->track.isOpen()) { 2111 if( wavFile->track.isOpen()) {
2112 sliderPos=timeSlider->value(); 2112 sliderPos=timeSlider->value();
2113 stopped = false; 2113 stopped = false;
2114 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 2114 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2115 total = newPos*4; 2115 total = newPos*4;
2116 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 2116 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2;
2117 startTimer(1000); 2117 startTimer(1000);
2118 doPlay(); 2118 doPlay();
2119 } 2119 }
2120} 2120}
2121 2121
2122 2122
2123QString QtRec::getStorage(const QString &fileName) { 2123QString QtRec::getStorage(const QString &fileName) {
2124 2124
2125 StorageInfo storageInfo; 2125 StorageInfo storageInfo;
2126 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2126 const QList<FileSystem> &fs = storageInfo.fileSystems();
2127 QListIterator<FileSystem> it ( fs ); 2127 QListIterator<FileSystem> it ( fs );
2128 QString storage; 2128 QString storage;
2129 for( ; it.current(); ++it ){ 2129 for( ; it.current(); ++it ){
2130 const QString name = (*it)->name(); 2130 const QString name = (*it)->name();
2131 const QString path = (*it)->path(); 2131 const QString path = (*it)->path();
2132 const QString disk = (*it)->disk(); 2132 const QString disk = (*it)->disk();
2133 if( fileName.find(path,0,true) != -1) 2133 if( fileName.find(path,0,true) != -1)
2134 storage=name; 2134 storage=name;
2135 // const QString options = (*it)->options(); 2135 // const QString options = (*it)->options();
2136 // if( name.find( tr("Internal"),0,true) == -1) { 2136 // if( name.find( tr("Internal"),0,true) == -1) {
2137 // storageComboBox->insertItem( name +" -> "+disk); 2137 // storageComboBox->insertItem( name +" -> "+disk);
2138 // qDebug(name); 2138 // qDebug(name);
2139 } 2139 }
2140 return storage; 2140 return storage;
2141 // struct mntent *me; 2141 // struct mntent *me;
2142 // // if(fileName == "/etc/mtab") { 2142 // // if(fileName == "/etc/mtab") {
2143 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 2143 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
2144 // if ( mntfp ) { 2144 // if ( mntfp ) {
2145 // while ( (me = getmntent( mntfp )) != 0 ) { 2145 // while ( (me = getmntent( mntfp )) != 0 ) {
2146 // QString filesystemType = me->mnt_type; 2146 // QString filesystemType = me->mnt_type;
2147 2147
2148 // } 2148 // }
2149 // } 2149 // }
2150 // endmntent( mntfp ); 2150 // endmntent( mntfp );
2151} 2151}
2152 2152
2153void QtRec::setRecordButton(bool b) { 2153void QtRec::setRecordButton(bool b) {
2154 2154
2155 if(b) { //about to record or play 2155 if(b) { //about to record or play
2156 2156
2157 Rec_PushButton->setDown(true); 2157 Rec_PushButton->setDown(true);
2158 QPixmap image3( ( const char** ) image3_data ); 2158 QPixmap image3( ( const char** ) image3_data );
2159 Stop_PushButton->setPixmap( image3 ); 2159 Stop_PushButton->setPixmap( image3 );
2160 if(Stop_PushButton->isDown()) 2160 if(Stop_PushButton->isDown())
2161 Stop_PushButton->setDown(true); 2161 Stop_PushButton->setDown(true);
2162 playLabel2->setText("Stop"); 2162 playLabel2->setText(tr("Stop") );
2163 2163
2164 } else { //about to stop 2164 } else { //about to stop
2165 2165
2166 QPixmap image4( ( const char** ) image4_data ); 2166 QPixmap image4( ( const char** ) image4_data );
2167 Stop_PushButton->setPixmap( image4); 2167 Stop_PushButton->setPixmap( image4);
2168 if(Stop_PushButton->isDown()) 2168 if(Stop_PushButton->isDown())
2169 Stop_PushButton->setDown(false); 2169 Stop_PushButton->setDown(false);
2170 playLabel2->setText("Play"); 2170 playLabel2->setText(tr("Play") );
2171 if(Rec_PushButton->isDown()) 2171 if(Rec_PushButton->isDown())
2172 Rec_PushButton->setDown( false); 2172 Rec_PushButton->setDown( false);
2173 } 2173 }
2174} 2174}
2175 2175
2176void QtRec::fillDirectoryCombo() { 2176void QtRec::fillDirectoryCombo() {
2177 if( directoryComboBox->count() > 0) 2177 if( directoryComboBox->count() > 0)
2178 directoryComboBox->clear(); 2178 directoryComboBox->clear();
2179 int index=0; 2179 int index=0;
2180 Config cfg("OpieRec"); 2180 Config cfg("OpieRec");
2181 cfg.setGroup("Settings"); 2181 cfg.setGroup("Settings");
2182 QString dir= cfg.readEntry("directory", "/"); 2182 QString dir= cfg.readEntry("directory", "/");
2183 StorageInfo storageInfo; 2183 StorageInfo storageInfo;
2184 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2184 const QList<FileSystem> &fs = storageInfo.fileSystems();
2185 QListIterator<FileSystem> it ( fs ); 2185 QListIterator<FileSystem> it ( fs );
2186 QString storage; 2186 QString storage;
2187 for( ; it.current(); ++it ){ 2187 for( ; it.current(); ++it ){
2188 const QString name = (*it)->name(); 2188 const QString name = (*it)->name();
2189 const QString path = (*it)->path(); 2189 const QString path = (*it)->path();
2190 // directoryComboBox->insertItem(name+" "+path); 2190 // directoryComboBox->insertItem(name+" "+path);
2191 directoryComboBox->insertItem(name); 2191 directoryComboBox->insertItem(name);
2192 if(path==dir) 2192 if(path==dir)
2193 directoryComboBox->setCurrentItem(index); 2193 directoryComboBox->setCurrentItem(index);
2194 index++; 2194 index++;
2195 } 2195 }
2196} 2196}
2197 2197
2198void QtRec::errorStop() { 2198void QtRec::errorStop() {
2199 stopped = true; 2199 stopped = true;
2200 wavFile->closeFile(); 2200 wavFile->closeFile();
2201 killTimers(); 2201 killTimers();
2202} 2202}
2203 2203
2204void QtRec::doMute(bool b) { 2204void QtRec::doMute(bool b) {
2205 doVolMuting( b); 2205 doVolMuting( b);
2206 doMicMuting( b); 2206 doMicMuting( b);
2207} 2207}
2208 2208
2209void QtRec::slotAutoMute(bool b) { 2209void QtRec::slotAutoMute(bool b) {
2210 autoMute=b; 2210 autoMute=b;
2211 Config cfg("OpieRec"); 2211 Config cfg("OpieRec");
2212 cfg.setGroup("Settings"); 2212 cfg.setGroup("Settings");
2213 cfg.writeEntry("useAutoMute",b); 2213 cfg.writeEntry("useAutoMute",b);
2214 doMute(b); 2214 doMute(b);
2215 outMuteCheckBox->setChecked( b); 2215 outMuteCheckBox->setChecked( b);
2216 inMuteCheckBox->setChecked( b); 2216 inMuteCheckBox->setChecked( b);
2217} 2217}
2218 2218
2219void QtRec::selectItemByName(const QString & name) { 2219void QtRec::selectItemByName(const QString & name) {
2220 QListViewItemIterator it( ListView1 ); 2220 QListViewItemIterator it( ListView1 );
2221 for ( ; it.current(); ++it ) 2221 for ( ; it.current(); ++it )
2222 if(name == it.current()->text(0)) 2222 if(name == it.current()->text(0))
2223 ListView1->setCurrentItem(it.current()); 2223 ListView1->setCurrentItem(it.current());
2224} 2224}
2225 2225
2226 2226
2227long findPeak(long input ) { 2227long findPeak(long input ) {
2228 2228
2229// halfLife = time in seconds for output to decay to half value after an impulse 2229// halfLife = time in seconds for output to decay to half value after an impulse
2230 static float output = 0.0; 2230 static float output = 0.0;
2231 int halfLife = .25; 2231 int halfLife = .25;
2232 float vsf = .0025; 2232 float vsf = .0025;
2233 float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2233 float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2234 if( input < 0.0 ) 2234 if( input < 0.0 )
2235 input = -input; // Absolute value. 2235 input = -input; // Absolute value.
2236 if ( input >= output ) 2236 if ( input >= output )
2237 { 2237 {
2238 // When we hit a peak, ride the peak to the top. 2238 // When we hit a peak, ride the peak to the top.
2239 output = input; 2239 output = input;
2240 } 2240 }
2241 else 2241 else
2242 { 2242 {
2243// Exponential decay of output when signal is low. 2243// Exponential decay of output when signal is low.
2244 output = output * scalar; 2244 output = output * scalar;
2245// 2245//
2246// When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2246// When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2247// which can cause a severe performance degradation due to a flood 2247// which can cause a severe performance degradation due to a flood
2248// of interrupts. 2248// of interrupts.
2249// 2249//
2250 if( output < vsf ) output = 0.0; 2250 if( output < vsf ) output = 0.0;
2251 } 2251 }
2252 2252
2253 return output; 2253 return output;
2254} 2254}
diff --git a/noncore/multimedia/showimg/opie-showimg.control b/noncore/multimedia/showimg/opie-showimg.control
index 9dacd94..c543335 100644
--- a/noncore/multimedia/showimg/opie-showimg.control
+++ b/noncore/multimedia/showimg/opie-showimg.control
@@ -1,11 +1,11 @@
1Package: opie-showimg 1Package: opie-showimg
2Files: bin/showimg apps/Applications/showimg.desktop pics/imageviewer 2Files: bin/showimg apps/Applications/showimg.desktop pics/imageviewer
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Warwick Allison <warwick@trolltech.com> 5Maintainer: Warwick Allison <warwick@trolltech.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Image Viewer 8Description: Image Viewer
10 The image viewer for the Opie environment. Supports 9 The image viewer for the Opie environment. Supports
11 Whichever formats are compiled into Qt/Embedded (eg. PNG). 10 Whichever formats are compiled into Qt/Embedded (eg. PNG).
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/ftplib/ftplib.control b/noncore/net/ftplib/ftplib.control
index 3dcb02a..918bcd2 100644
--- a/noncore/net/ftplib/ftplib.control
+++ b/noncore/net/ftplib/ftplib.control
@@ -1,10 +1,10 @@
1Package: ftplib 1Package: ftplib
2Files: $OPIEDIR/lib/libftplib.* 2Files: $OPIEDIR/lib/libftplib.*
3Priority: optional 3Priority: optional
4Section: Communications 4Section: Communications
5Maintainer: L.J. Potter <ljp@llornkcor.com> 5Maintainer: L.J. Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal 7Depends: task-opie-minimal
9Description: Libftp 8Description: Libftp
10 The ftp library for the Opie environment. 9 The ftp library for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/mailit/opie-mailit.control b/noncore/net/mailit/opie-mailit.control
index 65b5b36..77d4102 100644
--- a/noncore/net/mailit/opie-mailit.control
+++ b/noncore/net/mailit/opie-mailit.control
@@ -1,9 +1,9 @@
1Package: opie-mailit 1Package: opie-mailit
2Files: bin/mailit apps/1Pim/mailit.desktop pics/mailit 2Files: bin/mailit apps/1Pim/mailit.desktop pics/mailit
3Priority: optional 3Priority: optional
4Section: opie 4Section: opie
5Maintainer: L.J. Potter <llornkcor@handhelds.org> 5Maintainer: L.J. Potter <llornkcor@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $OPIE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Description: EMail 8Description: EMail
9 A simple POP3 email client for the Opie environment. 9 A simple POP3 email client for the Opie environment.
diff --git a/noncore/net/opieftp/opie-ftp.control b/noncore/net/opieftp/opie-ftp.control
index 090e9a8..1e82523 100644
--- a/noncore/net/opieftp/opie-ftp.control
+++ b/noncore/net/opieftp/opie-ftp.control
@@ -1,11 +1,11 @@
1Package: opie-ftp 1Package: opie-ftp
2Files: bin/opieftp pics/opieftp apps/Applications/opieftp.desktop 2Files: bin/opieftp pics/opieftp apps/Applications/opieftp.desktop
3Priority: optional 3Priority: optional
4Section: Communications 4Section: Communications
5Maintainer: L.J. Potter <ljp@llornkcor.com> 5Maintainer: L.J. Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal, ftplib 7Depends: task-opie-minimal, ftplib
9Replaces: opieftp 8Replaces: opieftp
10Description: Opie-Ftp 9Description: Opie-Ftp
11 The ftp client for the Opie environment. 10 The ftp client for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/opieirc/opie-irc.control b/noncore/net/opieirc/opie-irc.control
index f1e6ff8..51a8049 100644
--- a/noncore/net/opieirc/opie-irc.control
+++ b/noncore/net/opieirc/opie-irc.control
@@ -1,9 +1,9 @@
1Package: opie-irc 1Package: opie-irc
2Files: bin/opieirc pics/opieirc apps/Applications/opieirc.desktop help/en/html/opieirc.html help/en/html/opieirc 2Files: bin/opieirc pics/opieirc apps/Applications/opieirc.desktop help/en/html/opieirc.html help/en/html/opieirc
3Priority: optional 3Priority: optional
4Section: Communications 4Section: Communications
5Maintainer: Wenzel Jakob <root@wazlaf.de> 5Maintainer: Wenzel Jakob <root@wazlaf.de>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal, libopie1 7Depends: task-opie-minimal, libopie1
9Description: The Opie IRC client lets you chat on your favorite IRC server using your handheld computer 8Description: The Opie IRC client lets you chat on your favorite IRC server using your handheld computer
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/opietooth/applet/opie-bluetoothapplet.control b/noncore/net/opietooth/applet/opie-bluetoothapplet.control
index b9bd63c..55b9ab0 100644
--- a/noncore/net/opietooth/applet/opie-bluetoothapplet.control
+++ b/noncore/net/opietooth/applet/opie-bluetoothapplet.control
@@ -1,10 +1,10 @@
1Package: opie-bluetoothapplet 1Package: opie-bluetoothapplet
2Files: plugins/applets/libbluetoothapplet.so* pics/bluetoothapplet/* 2Files: plugins/applets/libbluetoothapplet.so* pics/bluetoothapplet/*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Maximilian Reiss <max.reiss@gmx.de> 5Maintainer: Maximilian Reiss <max.reiss@gmx.de>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION.1
8Depends: task-opie-minimal, libopietooth1 7Depends: task-opie-minimal, libopietooth1
9Description: Bluetooth Applet 8Description: Bluetooth Applet
10 An bluetooth taskbar applet for the Opie environment 9 An bluetooth taskbar applet for the Opie environment
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/opietooth/lib/libopietooth1.control b/noncore/net/opietooth/lib/libopietooth1.control
index 041c9d5..850f0dc 100644
--- a/noncore/net/opietooth/lib/libopietooth1.control
+++ b/noncore/net/opietooth/lib/libopietooth1.control
@@ -1,10 +1,10 @@
1Package: libopietooth1 1Package: libopietooth1
2Files: $OPIEDIR/lib/libopietooth.so.1.0.0 $OPIEDIR/lib/libopietooth.so.1.0 $OPIEDIR/lib/libopietooth.so.1 2Files: $OPIEDIR/lib/libopietooth.so.1.0.0 $OPIEDIR/lib/libopietooth.so.1.0 $OPIEDIR/lib/libopietooth.so.1
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Maximilian Reiß <max.reiss@gmx.de> 5Maintainer: Maximilian Reiß <max.reiss@gmx.de>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Replaces: libopietooth 7Replaces: libopietooth
9Depends: libqte2 (>=2.3.4), libopie, task-bluez 8Depends: libqte2 (>=2.3.4), libopie, task-bluez
10Description: Opie bluetooth library 9Description: Opie bluetooth library
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/unsupported/gsmtool/gsmtool.pro b/noncore/unsupported/gsmtool/gsmtool.pro
index 180195f..40d5942 100644
--- a/noncore/unsupported/gsmtool/gsmtool.pro
+++ b/noncore/unsupported/gsmtool/gsmtool.pro
@@ -1,36 +1,36 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5 HEADERS = gsmtool.h 5 HEADERS = gsmtool.h
6 SOURCES = main.cpp gsmtool.cpp 6 SOURCES = main.cpp gsmtool.cpp
7# This doesn't actually work... 7# This doesn't actually work...
8TMAKE_CXXFLAGS += -fexceptions 8TMAKE_CXXFLAGS += -fexceptions
9 INCLUDEPATH+= $(OPIEDIR)/include 9 INCLUDEPATH+= $(OPIEDIR)/include
10 INCLUDEPATH+= $(GSMLIBDIR) 10 #INCLUDEPATH+= $(GSMLIBDIR)
11 DEPENDPATH+= $(OPIEDIR)/include 11 DEPENDPATH+= $(OPIEDIR)/include
12LIBS += -lqpe -L$(GSMLIBDIR)/gsmlib/.libs -lgsmme 12LIBS += -lqpe -L$(GSMLIBDIR)/gsmlib/.libs -lgsmme
13 INTERFACES= gsmtoolbase.ui 13 INTERFACES= gsmtoolbase.ui
14 TARGET = gsmtool 14 TARGET = gsmtool
15 15
16TRANSLATIONS = ../../../i18n/de/gsmtool.ts \ 16TRANSLATIONS = ../../../i18n/de/gsmtool.ts \
17 ../../../i18n/nl/gsmtool.ts \ 17 ../../../i18n/nl/gsmtool.ts \
18 ../../../i18n/da/gsmtool.ts \ 18 ../../../i18n/da/gsmtool.ts \
19 ../../../i18n/xx/gsmtool.ts \ 19 ../../../i18n/xx/gsmtool.ts \
20 ../../../i18n/en/gsmtool.ts \ 20 ../../../i18n/en/gsmtool.ts \
21 ../../../i18n/es/gsmtool.ts \ 21 ../../../i18n/es/gsmtool.ts \
22 ../../../i18n/fr/gsmtool.ts \ 22 ../../../i18n/fr/gsmtool.ts \
23 ../../../i18n/hu/gsmtool.ts \ 23 ../../../i18n/hu/gsmtool.ts \
24 ../../../i18n/ja/gsmtool.ts \ 24 ../../../i18n/ja/gsmtool.ts \
25 ../../../i18n/ko/gsmtool.ts \ 25 ../../../i18n/ko/gsmtool.ts \
26 ../../../i18n/no/gsmtool.ts \ 26 ../../../i18n/no/gsmtool.ts \
27 ../../../i18n/pl/gsmtool.ts \ 27 ../../../i18n/pl/gsmtool.ts \
28 ../../../i18n/pt/gsmtool.ts \ 28 ../../../i18n/pt/gsmtool.ts \
29 ../../../i18n/pt_BR/gsmtool.ts \ 29 ../../../i18n/pt_BR/gsmtool.ts \
30 ../../../i18n/sl/gsmtool.ts \ 30 ../../../i18n/sl/gsmtool.ts \
31 ../../../i18n/zh_CN/gsmtool.ts \ 31 ../../../i18n/zh_CN/gsmtool.ts \
32 ../../../i18n/zh_TW/gsmtool.ts 32 ../../../i18n/zh_TW/gsmtool.ts
33 33
34 34
35 35
36include ( $(OPIEDIR)/include.pro ) 36include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/unsupported/mail2/addresspicker.cpp b/noncore/unsupported/mail2/addresspicker.cpp
index 7f32725..a97b33f 100644
--- a/noncore/unsupported/mail2/addresspicker.cpp
+++ b/noncore/unsupported/mail2/addresspicker.cpp
@@ -1,117 +1,118 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qfile.h> 5#include <qfile.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8 8
9#include <stdlib.h> 9#include <stdlib.h>
10 10
11#include "addresspicker.h" 11#include "addresspicker.h"
12 12
13AddressPicker::AddressPicker(QWidget *parent, const char *name, bool modal, 13AddressPicker::AddressPicker(QWidget *parent, const char *name, bool modal,
14 WFlags fl) : AddressPickerBase(parent, name, modal, fl) 14 WFlags fl) : AddressPickerBase(parent, name, modal, fl)
15{ 15{
16 okButton->setIconSet(Resource::loadPixmap("enter")); 16 okButton->setIconSet(Resource::loadPixmap("enter"));
17 cancelButton->setIconSet(Resource::loadPixmap("editdelete")); 17 cancelButton->setIconSet(Resource::loadPixmap("editdelete"));
18 18
19 connect(okButton, SIGNAL(clicked()), SLOT(accept())); 19 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
20 connect(cancelButton, SIGNAL(clicked()), SLOT(close())); 20 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
21 21
22 QFile f((QString) getenv("HOME") + "/Applications/" 22 QFile f((QString) getenv("HOME") + "/Applications/"
23 + "addressbook/addressbook.xml"); 23 + "addressbook/addressbook.xml");
24 24
25 if (f.open(IO_ReadOnly)) { 25 if (f.open(IO_ReadOnly)) {
26 QTextStream stream(&f); 26 QTextStream stream(&f);
27 stream.setEncoding( QTextStream::UnicodeUTF8 );
27 QString content; 28 QString content;
28 while (!f.atEnd()) content += stream.readLine() + "\n"; 29 while (!f.atEnd()) content += stream.readLine() + "\n";
29 QStringList lines = QStringList::split(QRegExp("\\n"), content); 30 QStringList lines = QStringList::split(QRegExp("\\n"), content);
30 QStringList::Iterator it; 31 QStringList::Iterator it;
31 for (it = lines.begin(); it != lines.end(); it++) { 32 for (it = lines.begin(); it != lines.end(); it++) {
32 if ((*it).find(QRegExp("^<Contact.*")) != -1) { 33 if ((*it).find(QRegExp("^<Contact.*")) != -1) {
33 int pos = (*it).find("FirstName=\""); 34 int pos = (*it).find("FirstName=\"");
34 QString fname; 35 QString fname;
35 if (pos != -1) { 36 if (pos != -1) {
36 int i = 1; 37 int i = 1;
37 QChar c; 38 QChar c;
38 while (c != '"') { 39 while (c != '"') {
39 c = (*it)[pos + 10 + i]; 40 c = (*it)[pos + 10 + i];
40 if (c != '"') fname += c; 41 if (c != '"') fname += c;
41 i++; 42 i++;
42 } 43 }
43 } 44 }
44 pos = (*it).find("LastName=\""); 45 pos = (*it).find("LastName=\"");
45 QString lname; 46 QString lname;
46 if (pos != -1) { 47 if (pos != -1) {
47 int i = 1; 48 int i = 1;
48 QChar c; 49 QChar c;
49 while (c != '"') { 50 while (c != '"') {
50 c = (*it)[pos + 9 + i]; 51 c = (*it)[pos + 9 + i];
51 if (c != '"') lname += c; 52 if (c != '"') lname += c;
52 i++; 53 i++;
53 } 54 }
54 } 55 }
55 pos = (*it).find("DefaultEmail=\""); 56 pos = (*it).find("DefaultEmail=\"");
56 QString email; 57 QString email;
57 if (pos != -1) { 58 if (pos != -1) {
58 int i = 1; 59 int i = 1;
59 QChar c; 60 QChar c;
60 while (c != '"') { 61 while (c != '"') {
61 c = (*it)[pos + 13 + i]; 62 c = (*it)[pos + 13 + i];
62 if (c != '"') email += c; 63 if (c != '"') email += c;
63 i++; 64 i++;
64 } 65 }
65 } 66 }
66 QString tname, temail; 67 QString tname, temail;
67 if (!fname.isEmpty()) tname += fname; 68 if (!fname.isEmpty()) tname += fname;
68 if (!lname.isEmpty()) tname += fname.isEmpty() ? lname : (" " + lname); 69 if (!lname.isEmpty()) tname += fname.isEmpty() ? lname : (" " + lname);
69 if (!email.isEmpty()) temail += tname.isEmpty() ? email : (" <" + email + ">"); 70 if (!email.isEmpty()) temail += tname.isEmpty() ? email : (" <" + email + ">");
70 if (!email.isEmpty()) addressList->insertItem(tname + temail); 71 if (!email.isEmpty()) addressList->insertItem(tname + temail);
71 } 72 }
72 } 73 }
73 } 74 }
74 if (addressList->count() <= 0) { 75 if (addressList->count() <= 0) {
75 addressList->insertItem(tr("There are no entries in the addressbook.")); 76 addressList->insertItem(tr("There are no entries in the addressbook."));
76 addressList->setEnabled(false); 77 addressList->setEnabled(false);
77 okButton->setEnabled(false); 78 okButton->setEnabled(false);
78 } 79 }
79} 80}
80 81
81void AddressPicker::accept() 82void AddressPicker::accept()
82{ 83{
83 QListBoxItem *item = addressList->firstItem(); 84 QListBoxItem *item = addressList->firstItem();
84 QString names; 85 QString names;
85 86
86 while (item) { 87 while (item) {
87 if (item->selected()) 88 if (item->selected())
88 names += item->text() + ", "; 89 names += item->text() + ", ";
89 item = item->next(); 90 item = item->next();
90 } 91 }
91 names.replace(names.length() - 2, 2, ""); 92 names.replace(names.length() - 2, 2, "");
92 93
93 if (names.isEmpty()) { 94 if (names.isEmpty()) {
94 QMessageBox::information(this, tr("Error"), tr("<p>You have to select" 95 QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
95 " at least one address entry.</p>"), tr("Ok")); 96 " at least one address entry.</p>"), tr("Ok"));
96 return; 97 return;
97 } 98 }
98 99
99 selectedNames = names; 100 selectedNames = names;
100 QDialog::accept(); 101 QDialog::accept();
101} 102}
102 103
103QString AddressPicker::getNames() 104QString AddressPicker::getNames()
104{ 105{
105 QString names = 0; 106 QString names = 0;
106 107
107 AddressPicker picker(0, 0, true); 108 AddressPicker picker(0, 0, true);
108 picker.showMaximized(); 109 picker.showMaximized();
109 picker.show(); 110 picker.show();
110 111
111 int ret = picker.exec(); 112 int ret = picker.exec();
112 if (QDialog::Accepted == ret) { 113 if (QDialog::Accepted == ret) {
113 return picker.selectedNames; 114 return picker.selectedNames;
114 } 115 }
115 return 0; 116 return 0;
116} 117}
117 118
diff --git a/noncore/unsupported/mail2/bend/opie-mailapplet.control b/noncore/unsupported/mail2/bend/opie-mailapplet.control
index e5d3c6e..d618643 100644
--- a/noncore/unsupported/mail2/bend/opie-mailapplet.control
+++ b/noncore/unsupported/mail2/bend/opie-mailapplet.control
@@ -1,10 +1,10 @@
1Package: opie-mailapplet 1Package: opie-mailapplet
2Files: plugins/applets/libbend.so* 2Files: plugins/applets/libbend.so*
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Constantin Bergemann <cbergemann@lisa.de> 5Maintainer: Constantin Bergemann <cbergemann@lisa.de>
6Architecture: arm 6Architecture: arm
7Version: 0.0.9-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal libopie1 opie-mail2 8Depends: task-opie-minimal, libopie1, opie-mail2
9Description: A Biff-Like mailchecker 9Description: A Biff-Like mailchecker
10License: LGPL 10License: LGPL
diff --git a/noncore/unsupported/mail2/opie-mail2.control b/noncore/unsupported/mail2/opie-mail2.control
index 7f8aeb6..976dc0b 100644
--- a/noncore/unsupported/mail2/opie-mail2.control
+++ b/noncore/unsupported/mail2/opie-mail2.control
@@ -1,10 +1,10 @@
1Package: opie-mail2 1Package: opie-mail2
2Files: bin/mail $OPIEDIR/lib/libmail.so* apps/1Pim/mail.desktop pics/mail/*.png sounds/mail/*.wav 2Files: bin/mail $OPIEDIR/lib/libmail.so* apps/1Pim/mail.desktop pics/mail/*.png sounds/mail/*.wav
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Constantin Bergemann <cbergemann@lisa.de> 5Maintainer: Constantin Bergemann <cbergemann@lisa.de>
6Architecture: arm 6Architecture: arm
7Version: 0.0.9-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: task-opie-minimal, libopie1 8Depends: task-opie-minimal, libopie1
9Description: An IMAP mail client 9Description: An IMAP mail client
10License: LGPL 10License: LGPL
diff --git a/noncore/unsupported/mailit/opie-mailit.control b/noncore/unsupported/mailit/opie-mailit.control
index 65b5b36..77d4102 100644
--- a/noncore/unsupported/mailit/opie-mailit.control
+++ b/noncore/unsupported/mailit/opie-mailit.control
@@ -1,9 +1,9 @@
1Package: opie-mailit 1Package: opie-mailit
2Files: bin/mailit apps/1Pim/mailit.desktop pics/mailit 2Files: bin/mailit apps/1Pim/mailit.desktop pics/mailit
3Priority: optional 3Priority: optional
4Section: opie 4Section: opie
5Maintainer: L.J. Potter <llornkcor@handhelds.org> 5Maintainer: L.J. Potter <llornkcor@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $OPIE_VERSION-$SUB_VERSION 7Version: $QPE_VERSION$EXTRAVERSION
8Description: EMail 8Description: EMail
9 A simple POP3 email client for the Opie environment. 9 A simple POP3 email client for the Opie environment.
diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp
index 52237f5..022d938 100644
--- a/noncore/unsupported/qpdf/QOutputDev.cpp
+++ b/noncore/unsupported/qpdf/QOutputDev.cpp
@@ -1,1040 +1,1053 @@
1///======================================================================== 1///========================================================================
2// 2//
3// QOutputDev.cc 3// QOutputDev.cc
4// 4//
5// Copyright 1996 Derek B. Noonburg 5// Copyright 1996 Derek B. Noonburg
6// CopyRight 2002 Robert Griebl 6// CopyRight 2002 Robert Griebl
7// 7//
8//======================================================================== 8//========================================================================
9 9
10#ifdef __GNUC__ 10#ifdef __GNUC__
11#pragma implementation 11#pragma implementation
12#endif 12#endif
13 13
14#include <aconf.h> 14#include <aconf.h>
15#include <stdio.h> 15#include <stdio.h>
16#include <stdlib.h> 16#include <stdlib.h>
17#include <stddef.h> 17#include <stddef.h>
18#include <unistd.h> 18#include <unistd.h>
19#include <string.h> 19#include <string.h>
20#include <ctype.h> 20#include <ctype.h>
21#include <math.h> 21#include <math.h>
22#include <iostream> 22#include <iostream>
23 23
24#include "GString.h" 24#include "GString.h"
25#include "Object.h" 25#include "Object.h"
26#include "Stream.h" 26#include "Stream.h"
27#include "Link.h" 27#include "Link.h"
28#include "GfxState.h" 28#include "GfxState.h"
29#include "GfxFont.h" 29#include "GfxFont.h"
30#include "UnicodeMap.h" 30#include "UnicodeMap.h"
31#include "CharCodeToUnicode.h" 31#include "CharCodeToUnicode.h"
32#include "FontFile.h" 32#include "FontFile.h"
33#include "Error.h" 33#include "Error.h"
34#include "TextOutputDev.h" 34#include "TextOutputDev.h"
35#include "QOutputDev.h" 35#include "QOutputDev.h"
36 36
37 37
38#include <qpixmap.h> 38#include <qpixmap.h>
39#include <qimage.h> 39#include <qimage.h>
40#include <qpainter.h> 40#include <qpainter.h>
41#include <qdict.h> 41#include <qdict.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qclipboard.h> 44#include <qclipboard.h>
45 45
46 //#define QPDFDBG(x) x // special debug mode 46 //#define QPDFDBG(x) x // special debug mode
47 #define QPDFDBG(x) // normal compilation 47 #define QPDFDBG(x) // normal compilation
48 48
49 49
50//------------------------------------------------------------------------ 50//------------------------------------------------------------------------
51// Constants and macros 51// Constants and macros
52//------------------------------------------------------------------------ 52//------------------------------------------------------------------------
53 53
54 54
55static inline QColor q_col ( const GfxRGB &rgb ) 55static inline QColor q_col ( const GfxRGB &rgb )
56{ 56{
57 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 )); 57 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 ));
58} 58}
59 59
60 60
61//------------------------------------------------------------------------ 61//------------------------------------------------------------------------
62// Font substitutions 62// Font substitutions
63//------------------------------------------------------------------------ 63//------------------------------------------------------------------------
64 64
65struct QOutFontSubst { 65struct QOutFontSubst {
66 char * m_name; 66 char * m_name;
67 char * m_sname; 67 char * m_sname;
68 bool m_bold; 68 bool m_bold;
69 bool m_italic; 69 bool m_italic;
70 QFont::StyleHint m_hint; 70 QFont::StyleHint m_hint;
71}; 71};
72 72
73static QOutFontSubst qStdFonts [] = { 73static QOutFontSubst qStdFonts [] = {
74 { "Helvetica", "Helvetica", false, false, QFont::Helvetica }, 74 { "Helvetica", "Helvetica", false, false, QFont::Helvetica },
75 { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica }, 75 { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica },
76 { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica }, 76 { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica },
77 { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica }, 77 { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica },
78 { "Times-Roman", "Times", false, false, QFont::Times }, 78 { "Times-Roman", "Times", false, false, QFont::Times },
79 { "Times-Italic", "Times", false, true, QFont::Times }, 79 { "Times-Italic", "Times", false, true, QFont::Times },
80 { "Times-Bold", "Times", true, false, QFont::Times }, 80 { "Times-Bold", "Times", true, false, QFont::Times },
81 { "Times-BoldItalic", "Times", true, true, QFont::Times }, 81 { "Times-BoldItalic", "Times", true, true, QFont::Times },
82 { "Courier", "Courier", false, false, QFont::Courier }, 82 { "Courier", "Courier", false, false, QFont::Courier },
83 { "Courier-Oblique", "Courier", false, true, QFont::Courier }, 83 { "Courier-Oblique", "Courier", false, true, QFont::Courier },
84 { "Courier-Bold", "Courier", true, false, QFont::Courier }, 84 { "Courier-Bold", "Courier", true, false, QFont::Courier },
85 { "Courier-BoldOblique", "Courier", true, true, QFont::Courier }, 85 { "Courier-BoldOblique", "Courier", true, true, QFont::Courier },
86 86
87 { "Symbol", 0, false, false, QFont::AnyStyle }, 87 { "Symbol", 0, false, false, QFont::AnyStyle },
88 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle }, 88 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle },
89 89
90 { 0, 0, false, false, QFont::AnyStyle } 90 { 0, 0, false, false, QFont::AnyStyle }
91}; 91};
92 92
93 93
94 94
95 95
96 96
97 97
98 98
99QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 ) 99QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 )
100{ 100{
101 static QDict<QOutFontSubst> stdfonts; 101 static QDict<QOutFontSubst> stdfonts;
102 102
103 // build dict for std. fonts on first invocation 103 // build dict for std. fonts on first invocation
104 if ( stdfonts. isEmpty ( )) { 104 if ( stdfonts. isEmpty ( )) {
105 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) { 105 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) {
106 stdfonts. insert ( QString ( ptr-> m_name ), ptr ); 106 stdfonts. insert ( QString ( ptr-> m_name ), ptr );
107 } 107 }
108 } 108 }
109 109
110 // compute size and normalized transform matrix 110 // compute size and normalized transform matrix
111 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 )); 111 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 ));
112 112
113 QPDFDBG( printf ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n", 113 QPDFDBG( printf ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n",
114 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ), 114 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ),
115 size, 115 size,
116 gfxFont-> isBold ( ), 116 gfxFont-> isBold ( ),
117 gfxFont-> isItalic ( ), 117 gfxFont-> isItalic ( ),
118 gfxFont-> isFixedWidth ( ), 118 gfxFont-> isFixedWidth ( ),
119 gfxFont-> isSerif ( ), 119 gfxFont-> isSerif ( ),
120 gfxFont-> isSymbolic ( ), 120 gfxFont-> isSymbolic ( ),
121 gfxFont-> isCIDFont ( ), 121 gfxFont-> isCIDFont ( ),
122 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ), 122 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName()-> getCString ( ) : "<n/a>" ),
123 (double) m11, (double) m12, (double) m21, (double) m22 )); 123 (double) m11, (double) m12, (double) m21, (double) m22 ) );
124 124
125 125
126 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ); 126 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" );
127 127
128 QFont f; 128 QFont f;
129 f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes 129 f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes
130 130
131 // fast lookup for std. fonts 131 // fast lookup for std. fonts
132 QOutFontSubst *subst = stdfonts [fname]; 132 QOutFontSubst *subst = stdfonts [fname];
133 133
134 if ( subst ) { 134 if ( subst ) {
135 if ( subst-> m_sname ) 135 if ( subst-> m_sname )
136 f. setFamily ( subst-> m_sname ); 136 f. setFamily ( subst-> m_sname );
137 f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality )); 137 f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
138 f. setBold ( subst-> m_bold ); 138 f. setBold ( subst-> m_bold );
139 f. setItalic ( subst-> m_italic ); 139 f. setItalic ( subst-> m_italic );
140 } 140 }
141 else { 141 else {
142 QFont::StyleHint sty; 142 QFont::StyleHint sty;
143 143
144 if ( gfxFont-> isSerif ( )) 144 if ( gfxFont-> isSerif ( ))
145 sty = QFont::Serif; 145 sty = QFont::Serif;
146 else if ( gfxFont-> isFixedWidth ( )) 146 else if ( gfxFont-> isFixedWidth ( ))
147 sty = QFont::TypeWriter; 147 sty = QFont::TypeWriter;
148 else 148 else
149 sty = QFont::Helvetica; 149 sty = QFont::Helvetica;
150 150
151 f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality )); 151 f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
152 f. setBold ( gfxFont-> isBold ( ) > 0 ); 152 f. setBold ( gfxFont-> isBold ( ) > 0 );
153 f. setItalic ( gfxFont-> isItalic ( ) > 0 ); 153 f. setItalic ( gfxFont-> isItalic ( ) > 0 );
154 f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 ); 154 f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 );
155 155
156 // common specifiers in font names 156 // common specifiers in font names
157 if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" )) 157 if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" ))
158 f. setItalic ( true ); 158 f. setItalic ( true );
159 if ( fname. contains ( "Bold" )) 159 if ( fname. contains ( "Bold" ))
160 f. setWeight ( QFont::Bold ); 160 f. setWeight ( QFont::Bold );
161 if ( fname. contains ( "Demi" )) 161 if ( fname. contains ( "Demi" ))
162 f. setWeight ( QFont::DemiBold ); 162 f. setWeight ( QFont::DemiBold );
163 if ( fname. contains ( "Light" )) 163 if ( fname. contains ( "Light" ))
164 f. setWeight ( QFont::Light ); 164 f. setWeight ( QFont::Light );
165 if ( fname. contains ( "Black" )) 165 if ( fname. contains ( "Black" ))
166 f. setWeight ( QFont::Black ); 166 f. setWeight ( QFont::Black );
167 } 167 }
168 // Treat x-sheared fonts as italic 168 // Treat x-sheared fonts as italic
169 if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) { 169 if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) {
170 f. setItalic ( true ); 170 f. setItalic ( true );
171 } 171 }
172 return f; 172 return f;
173} 173}
174 174
175 175
176 176
177//------------------------------------------------------------------------ 177//------------------------------------------------------------------------
178// QOutputDev 178// QOutputDev
179//------------------------------------------------------------------------ 179//------------------------------------------------------------------------
180 180
181QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags ) 181QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags )
182{ 182{
183 m_pixmap = 0; 183 m_pixmap = 0;
184 m_painter = 0; 184 m_painter = 0;
185 185
186 // create text object 186 // create text object
187 m_text = new TextPage ( gFalse ); 187 m_text = new TextPage ( gFalse );
188} 188}
189 189
190QOutputDev::~QOutputDev ( ) 190QOutputDev::~QOutputDev ( )
191{ 191{
192 delete m_painter; 192 delete m_painter;
193 delete m_pixmap; 193 delete m_pixmap;
194 delete m_text; 194 delete m_text;
195} 195}
196 196
197 197
198void QOutputDev::startPage ( int /*pageNum*/, GfxState *state ) 198void QOutputDev::startPage ( int /*pageNum*/, GfxState *state )
199{ 199{
200 delete m_pixmap; 200 delete m_pixmap;
201 delete m_painter; 201 delete m_painter;
202 202
203 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))); 203 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )));
204 m_painter = new QPainter ( m_pixmap ); 204 m_painter = new QPainter ( m_pixmap );
205 205
206 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )))); 206 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))));
207 207
208 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( )); 208 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( ));
209 setContentsPos ( 0, 0 ); 209 setContentsPos ( 0, 0 );
210 210
211 m_pixmap-> fill ( white ); // clear window 211 m_pixmap-> fill ( white ); // clear window
212 m_text-> clear ( ); // cleat text object 212 m_text-> clear ( ); // cleat text object
213 viewport ( )-> repaint ( ); 213 viewport ( )-> repaint ( );
214} 214}
215 215
216void QOutputDev::endPage ( ) 216void QOutputDev::endPage ( )
217{ 217{
218 QPDFDBG( printf("End page\n") );
218 m_text-> coalesce ( ); 219 m_text-> coalesce ( );
219 220
221 /*
222 * I get stupid crashes after endPage is called and then we do clipping
223 * and other stuff.....
224 */
225#if 0
220 delete m_painter; 226 delete m_painter;
221 m_painter = 0; 227 m_painter = 0;
222 228#endif
229
223 updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( )); 230 updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( ));
224} 231}
225 232
226void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ ) 233void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ )
227{ 234{
228 fp_t x1, y1, x2, y2, w; 235 fp_t x1, y1, x2, y2, w;
229 236
230 link-> getBorder ( &x1, &y1, &x2, &y2, &w ); 237 link-> getBorder ( &x1, &y1, &x2, &y2, &w );
231 238
232 if ( w > 0 ) { 239 if ( w > 0 ) {
233 int x, y, dx, dy; 240 int x, y, dx, dy;
234 241
235 cvtUserToDev ( x1, y1, &x, &y ); 242 cvtUserToDev ( x1, y1, &x, &y );
236 cvtUserToDev ( x2, y2, &dx, &dy ); 243 cvtUserToDev ( x2, y2, &dx, &dy );
237 244
238 QPen oldpen = m_painter-> pen ( ); 245 QPen oldpen = m_painter-> pen ( );
239 m_painter-> setPen ( blue ); 246 m_painter-> setPen ( blue );
240 m_painter-> drawRect ( x, y, dx, dy ); 247 m_painter-> drawRect ( x, y, dx, dy );
241 m_painter-> setPen ( oldpen ); 248 m_painter-> setPen ( oldpen );
242 } 249 }
243} 250}
244 251
245void QOutputDev::saveState ( GfxState */*state*/ ) 252void QOutputDev::saveState ( GfxState */*state*/ )
246{ 253{
254 if ( ! m_painter )
255 return;
256
247 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( ))); 257 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
248 258
249 m_painter-> save ( ); 259 m_painter-> save ( );
250} 260}
251 261
252void QOutputDev::restoreState ( GfxState */*state*/ ) 262void QOutputDev::restoreState ( GfxState */*state*/ )
253{ 263{
264 if( ! m_painter )
265 return;
266
254 m_painter-> restore ( ); 267 m_painter-> restore ( );
255 268
256 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ))); 269 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( )));
257 //m_painter-> setClipping ( false ); 270 //m_painter-> setClipping ( false );
258 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( ))); 271 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
259} 272}
260 273
261void QOutputDev::updateAll ( GfxState *state ) 274void QOutputDev::updateAll ( GfxState *state )
262{ 275{
263 updateLineAttrs ( state, gTrue ); 276 updateLineAttrs ( state, gTrue );
264 //updateFlatness ( state ); 277 //updateFlatness ( state );
265 //updateMiterLimit ( state ); 278 //updateMiterLimit ( state );
266 updateFillColor ( state ); 279 updateFillColor ( state );
267 updateStrokeColor ( state ); 280 updateStrokeColor ( state );
268 updateFont ( state ); 281 updateFont ( state );
269} 282}
270 283
271void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ ) 284void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ )
272{ 285{
273 updateLineAttrs ( state, gTrue ); 286 updateLineAttrs ( state, gTrue );
274} 287}
275 288
276void QOutputDev::updateLineDash ( GfxState *state ) 289void QOutputDev::updateLineDash ( GfxState *state )
277{ 290{
278 updateLineAttrs ( state, gTrue ); 291 updateLineAttrs ( state, gTrue );
279} 292}
280 293
281void QOutputDev::updateFlatness ( GfxState */*state*/ ) 294void QOutputDev::updateFlatness ( GfxState */*state*/ )
282{ 295{
283 // not supported 296 // not supported
284 QPDFDBG( printf ( "updateFlatness not supported !\n" )); 297 QPDFDBG( printf ( "updateFlatness not supported !\n" ));
285} 298}
286 299
287void QOutputDev::updateLineJoin ( GfxState *state ) 300void QOutputDev::updateLineJoin ( GfxState *state )
288{ 301{
289 updateLineAttrs ( state, gFalse ); 302 updateLineAttrs ( state, gFalse );
290} 303}
291 304
292void QOutputDev::updateLineCap ( GfxState *state ) 305void QOutputDev::updateLineCap ( GfxState *state )
293{ 306{
294 updateLineAttrs ( state, gFalse ); 307 updateLineAttrs ( state, gFalse );
295} 308}
296 309
297// unimplemented 310// unimplemented
298void QOutputDev::updateMiterLimit ( GfxState */*state*/ ) 311void QOutputDev::updateMiterLimit ( GfxState */*state*/ )
299{ 312{
300 QPDFDBG( printf ( "updateMiterLimit not supported !\n" )); 313 QPDFDBG( printf ( "updateMiterLimit not supported !\n" ));
301} 314}
302 315
303void QOutputDev::updateLineWidth ( GfxState *state ) 316void QOutputDev::updateLineWidth ( GfxState *state )
304{ 317{
305 updateLineAttrs ( state, gFalse ); 318 updateLineAttrs ( state, gFalse );
306} 319}
307 320
308void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash ) 321void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
309{ 322{
310 fp_t *dashPattern; 323 fp_t *dashPattern;
311 int dashLength; 324 int dashLength;
312 fp_t dashStart; 325 fp_t dashStart;
313 326
314 Qt::PenCapStyle cap; 327 Qt::PenCapStyle cap;
315 Qt::PenJoinStyle join; 328 Qt::PenJoinStyle join;
316 int width; 329 int width;
317 330
318 width = lrint ( state-> getTransformedLineWidth ( )); 331 width = lrint ( state-> getTransformedLineWidth ( ));
319 332
320 switch ( state-> getLineCap ( )) { 333 switch ( state-> getLineCap ( )) {
321 case 0: cap = FlatCap; break; 334 case 0: cap = FlatCap; break;
322 case 1: cap = RoundCap; break; 335 case 1: cap = RoundCap; break;
323 case 2: cap = SquareCap; break; 336 case 2: cap = SquareCap; break;
324 default: 337 default:
325 qWarning ( "Bad line cap style (%d)\n", state-> getLineCap ( )); 338 qWarning ( "Bad line cap style (%d)\n", state-> getLineCap ( ));
326 cap = FlatCap; 339 cap = FlatCap;
327 break; 340 break;
328 } 341 }
329 342
330 switch (state->getLineJoin()) { 343 switch (state->getLineJoin()) {
331 case 0: join = MiterJoin; break; 344 case 0: join = MiterJoin; break;
332 case 1: join = RoundJoin; break; 345 case 1: join = RoundJoin; break;
333 case 2: join = BevelJoin; break; 346 case 2: join = BevelJoin; break;
334 default: 347 default:
335 qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( )); 348 qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( ));
336 join = MiterJoin; 349 join = MiterJoin;
337 break; 350 break;
338 } 351 }
339 352
340 state-> getLineDash ( &dashPattern, &dashLength, &dashStart ); 353 state-> getLineDash ( &dashPattern, &dashLength, &dashStart );
341 354
342 QColor oldcol = m_painter-> pen ( ). color ( ); 355 QColor oldcol = m_painter-> pen ( ). color ( );
343 GfxRGB rgb; 356 GfxRGB rgb;
344 357
345 state-> getStrokeRGB ( &rgb ); 358 state-> getStrokeRGB ( &rgb );
346 oldcol = q_col ( rgb ); 359 oldcol = q_col ( rgb );
347 360
348 m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join )); 361 m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join ));
349 362
350 if ( updateDash && ( dashLength > 0 )) { 363 if ( updateDash && ( dashLength > 0 )) {
351 // Not supported by QT 364 // Not supported by QT
352 /* 365/*
353 char dashList[20]; 366 char dashList[20];
354 if (dashLength > 20) 367 if (dashLength > 20)
355 dashLength = 20; 368 dashLength = 20;
356 for ( int i = 0; i < dashLength; ++i ) { 369 for ( int i = 0; i < dashLength; ++i ) {
357 dashList[i] = xoutRound(state->transformWidth(dashPattern[i])); 370 dashList[i] = xoutRound(state->transformWidth(dashPattern[i]));
358 if (dashList[i] == 0) 371 if (dashList[i] == 0)
359 dashList[i] = 1; 372 dashList[i] = 1;
360 } 373 }
361 XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength); 374 XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength);
362*/ 375*/
363 } 376 }
364} 377}
365 378
366void QOutputDev::updateFillColor ( GfxState *state ) 379void QOutputDev::updateFillColor ( GfxState *state )
367{ 380{
368 GfxRGB rgb; 381 GfxRGB rgb;
369 state-> getFillRGB ( &rgb ); 382 state-> getFillRGB ( &rgb );
370 383
371 m_painter-> setBrush ( q_col ( rgb )); 384 m_painter-> setBrush ( q_col ( rgb ));
372} 385}
373 386
374void QOutputDev::updateStrokeColor ( GfxState *state ) 387void QOutputDev::updateStrokeColor ( GfxState *state )
375{ 388{
376 GfxRGB rgb; 389 GfxRGB rgb;
377 state-> getStrokeRGB ( &rgb ); 390 state-> getStrokeRGB ( &rgb );
378 391
379 QPen pen = m_painter-> pen ( ); 392 QPen pen = m_painter-> pen ( );
380 pen. setColor ( q_col ( rgb )); 393 pen. setColor ( q_col ( rgb ));
381 m_painter-> setPen ( pen ); 394 m_painter-> setPen ( pen );
382} 395}
383 396
384void QOutputDev::updateFont ( GfxState *state ) 397void QOutputDev::updateFont ( GfxState *state )
385{ 398{
386 fp_t m11, m12, m21, m22; 399 fp_t m11, m12, m21, m22;
387 GfxFont *gfxFont = state-> getFont ( ); 400 GfxFont *gfxFont = state-> getFont ( );
388 401
389 if ( !gfxFont ) 402 if ( !gfxFont )
390 return; 403 return;
391 404
392 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 405 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
393 m11 *= state-> getHorizScaling ( ); 406 m11 *= state-> getHorizScaling ( );
394 m12 *= state-> getHorizScaling ( ); 407 m12 *= state-> getHorizScaling ( );
395 408
396 QFont font = matchFont ( gfxFont, m11, m12, m21, m22 ); 409 QFont font = matchFont ( gfxFont, m11, m12, m21, m22 );
397 410
398 m_painter-> setFont ( font ); 411 m_painter-> setFont ( font );
399 m_text-> updateFont ( state ); 412 m_text-> updateFont ( state );
400} 413}
401 414
402void QOutputDev::stroke ( GfxState *state ) 415void QOutputDev::stroke ( GfxState *state )
403{ 416{
404 QPointArray points; 417 QPointArray points;
405 QArray<int> lengths; 418 QArray<int> lengths;
406 419
407 // transform points 420 // transform points
408 int n = convertPath ( state, points, lengths ); 421 int n = convertPath ( state, points, lengths );
409 422
410 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n )); 423 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n ));
411 424
412 // draw each subpath 425 // draw each subpath
413 int j = 0; 426 int j = 0;
414 for ( int i = 0; i < n; i++ ) { 427 for ( int i = 0; i < n; i++ ) {
415 int len = lengths [i]; 428 int len = lengths [i];
416 429
417 if ( len >= 2 ) { 430 if ( len >= 2 ) {
418 QPDFDBG( printf ( " - POLY %d: ", i )); 431 QPDFDBG( printf ( " - POLY %d: ", i ));
419 QPDFDBG( for ( int ii = 0; ii < len; ii++ )) 432 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
420 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 433 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
421 QPDFDBG( printf ( "\n" )); 434 QPDFDBG( printf ( "\n" ));
422 435
423 m_painter-> drawPolyline ( points, j, len ); 436 m_painter-> drawPolyline ( points, j, len );
424 } 437 }
425 j += len; 438 j += len;
426 } 439 }
427 qApp-> processEvents ( ); 440 qApp-> processEvents ( );
428} 441}
429 442
430void QOutputDev::fill ( GfxState *state ) 443void QOutputDev::fill ( GfxState *state )
431{ 444{
432 doFill ( state, true ); 445 doFill ( state, true );
433} 446}
434 447
435void QOutputDev::eoFill ( GfxState *state ) 448void QOutputDev::eoFill ( GfxState *state )
436{ 449{
437 doFill ( state, false ); 450 doFill ( state, false );
438} 451}
439 452
440// 453//
441// X doesn't color the pixels on the right-most and bottom-most 454// X doesn't color the pixels on the right-most and bottom-most
442// borders of a polygon. This means that one-pixel-thick polygons 455// borders of a polygon. This means that one-pixel-thick polygons
443// are not colored at all. I think this is supposed to be a 456// are not colored at all. I think this is supposed to be a
444// feature, but I can't figure out why. So after it fills a 457// feature, but I can't figure out why. So after it fills a
445// polygon, it also draws lines around the border. This is done 458// polygon, it also draws lines around the border. This is done
446// only for single-component polygons, since it's not very 459// only for single-component polygons, since it's not very
447// compatible with the compound polygon kludge (see convertPath()). 460// compatible with the compound polygon kludge (see convertPath()).
448// 461//
449void QOutputDev::doFill ( GfxState *state, bool winding ) 462void QOutputDev::doFill ( GfxState *state, bool winding )
450{ 463{
451 QPointArray points; 464 QPointArray points;
452 QArray<int> lengths; 465 QArray<int> lengths;
453 466
454 // transform points 467 // transform points
455 int n = convertPath ( state, points, lengths ); 468 int n = convertPath ( state, points, lengths );
456 469
457 QPDFDBG( printf ( "FILLING: %d POLYS\n", n )); 470 QPDFDBG( printf ( "FILLING: %d POLYS\n", n ));
458 471
459 QPen oldpen = m_painter-> pen ( ); 472 QPen oldpen = m_painter-> pen ( );
460 m_painter-> setPen ( QPen ( NoPen )); 473 m_painter-> setPen ( QPen ( NoPen ));
461 474
462 // draw each subpath 475 // draw each subpath
463 int j = 0; 476 int j = 0;
464 for ( int i = 0; i < n; i++ ) { 477 for ( int i = 0; i < n; i++ ) {
465 int len = lengths [i]; 478 int len = lengths [i];
466 479
467 if ( len >= 3 ) { 480 if ( len >= 3 ) {
468 QPDFDBG( printf ( " - POLY %d: ", i )); 481 QPDFDBG( printf ( " - POLY %d: ", i ));
469 QPDFDBG( for ( int ii = 0; ii < len; ii++ )) 482 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
470 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 483 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
471 QPDFDBG( printf ( "\n" )); 484 QPDFDBG( printf ( "\n" ));
472 485
473 m_painter-> drawPolygon ( points, winding, j, len ); 486 m_painter-> drawPolygon ( points, winding, j, len );
474 } 487 }
475 j += len; 488 j += len;
476 } 489 }
477 m_painter-> setPen ( oldpen ); 490 m_painter-> setPen ( oldpen );
478 491
479 qApp-> processEvents ( ); 492 qApp-> processEvents ( );
480} 493}
481 494
482void QOutputDev::clip ( GfxState *state ) 495void QOutputDev::clip ( GfxState *state )
483{ 496{
484 doClip ( state, true ); 497 doClip ( state, true );
485} 498}
486 499
487void QOutputDev::eoClip ( GfxState *state ) 500void QOutputDev::eoClip ( GfxState *state )
488{ 501{
489 doClip ( state, false ); 502 doClip ( state, false );
490} 503}
491 504
492void QOutputDev::doClip ( GfxState *state, bool winding ) 505void QOutputDev::doClip ( GfxState *state, bool winding )
493{ 506{
494 QPointArray points; 507 QPointArray points;
495 QArray<int> lengths; 508 QArray<int> lengths;
496 509
497 // transform points 510 // transform points
498 int n = convertPath ( state, points, lengths ); 511 int n = convertPath ( state, points, lengths );
499 512
500 QRegion region; 513 QRegion region;
501 514
502 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n )); 515 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n ));
503 516
504 // draw each subpath 517 // draw each subpath
505 int j = 0; 518 int j = 0;
506 for ( int i = 0; i < n; i++ ) { 519 for ( int i = 0; i < n; i++ ) {
507 int len = lengths [i]; 520 int len = lengths [i];
508 521
509 if ( len >= 3 ) { 522 if ( len >= 3 ) {
510 QPointArray dummy; 523 QPointArray dummy;
511 dummy. setRawData ( points. data ( ) + j, len ); 524 dummy. setRawData ( points. data ( ) + j, len );
512 525
513 QPDFDBG( printf ( " - POLY %d: ", i )); 526 QPDFDBG( printf ( " - POLY %d: ", i ));
514 QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 527 QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
515 QPDFDBG( printf ( "\n" )); 528 QPDFDBG( printf ( "\n" ));
516 529
517 region |= QRegion ( dummy, winding ); 530 region |= QRegion ( dummy, winding );
518 531
519 dummy. resetRawData ( points. data ( ) + j, len ); 532 dummy. resetRawData ( points. data ( ) + j, len );
520 } 533 }
521 j += len; 534 j += len;
522 } 535 }
523 536
524 if ( m_painter-> hasClipping ( )) 537 if ( m_painter && m_painter-> hasClipping ( ))
525 region &= m_painter-> clipRegion ( ); 538 region &= m_painter-> clipRegion ( );
526 539
527 //m_painter-> setClipRegion ( region ); 540 //m_painter-> setClipRegion ( region );
528 //m_painter-> setClipping ( true ); 541 //m_painter-> setClipping ( true );
529 542
530 //m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red ); 543 //m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red );
531 //m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" ); 544 //m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" );
532 qApp-> processEvents ( ); 545 qApp-> processEvents ( );
533} 546}
534 547
535// 548//
536// Transform points in the path and convert curves to line segments. 549// Transform points in the path and convert curves to line segments.
537// Builds a set of subpaths and returns the number of subpaths. 550// Builds a set of subpaths and returns the number of subpaths.
538// If <fillHack> is set, close any unclosed subpaths and activate a 551// If <fillHack> is set, close any unclosed subpaths and activate a
539// kludge for polygon fills: First, it divides up the subpaths into 552// kludge for polygon fills: First, it divides up the subpaths into
540// non-overlapping polygons by simply comparing bounding rectangles. 553// non-overlapping polygons by simply comparing bounding rectangles.
541// Then it connects subaths within a single compound polygon to a single 554// Then it connects subaths within a single compound polygon to a single
542// point so that X can fill the polygon (sort of). 555// point so that X can fill the polygon (sort of).
543// 556//
544int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths ) 557int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths )
545{ 558{
546 GfxPath *path = state-> getPath ( ); 559 GfxPath *path = state-> getPath ( );
547 int n = path-> getNumSubpaths ( ); 560 int n = path-> getNumSubpaths ( );
548 561
549 lengths. resize ( n ); 562 lengths. resize ( n );
550 563
551 // do each subpath 564 // do each subpath
552 for ( int i = 0; i < n; i++ ) { 565 for ( int i = 0; i < n; i++ ) {
553 // transform the points 566 // transform the points
554 lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points ); 567 lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points );
555 } 568 }
556 569
557 return n; 570 return n;
558} 571}
559 572
560// 573//
561// Transform points in a single subpath and convert curves to line 574// Transform points in a single subpath and convert curves to line
562// segments. 575// segments.
563// 576//
564int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points ) 577int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points )
565{ 578{
566 int oldcnt = points. count ( ); 579 int oldcnt = points. count ( );
567 580
568 fp_t x0, y0, x1, y1, x2, y2, x3, y3; 581 fp_t x0, y0, x1, y1, x2, y2, x3, y3;
569 582
570 int m = subpath-> getNumPoints ( ); 583 int m = subpath-> getNumPoints ( );
571 int i = 0; 584 int i = 0;
572 585
573 while ( i < m ) { 586 while ( i < m ) {
574 if ( i >= 1 && subpath-> getCurve ( i )) { 587 if ( i >= 1 && subpath-> getCurve ( i )) {
575 state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 ); 588 state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 );
576 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 589 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
577 state-> transform ( subpath-> getX ( i + 1 ), subpath-> getY ( i + 1 ), &x2, &y2 ); 590 state-> transform ( subpath-> getX ( i + 1 ), subpath-> getY ( i + 1 ), &x2, &y2 );
578 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 ); 591 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 );
579 592
580 QPointArray tmp; 593 QPointArray tmp;
581 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ), 594 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ),
582 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 )); 595 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 ));
583 596
584#if QT_VERSION < 300 597#if QT_VERSION < 300
585 tmp = tmp. quadBezier ( ); 598 tmp = tmp. quadBezier ( );
586 599
587 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) { 600 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) {
588 QPoint p = tmp. point ( loop ); 601 QPoint p = tmp. point ( loop );
589 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( )); 602 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( ));
590 } 603 }
591#else 604#else
592 tmp = tmp. cubicBezier ( ); 605 tmp = tmp. cubicBezier ( );
593 points. putPoints ( points. count ( ), tmp. count ( ), tmp ); 606 points. putPoints ( points. count ( ), tmp. count ( ), tmp );
594#endif 607#endif
595 608
596 i += 3; 609 i += 3;
597 } 610 }
598 else { 611 else {
599 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 612 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
600 613
601 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 )); 614 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 ));
602 ++i; 615 ++i;
603 } 616 }
604 } 617 }
605 return points. count ( ) - oldcnt; 618 return points. count ( ) - oldcnt;
606} 619}
607 620
608 621
609void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) 622void QOutputDev::beginString ( GfxState *state, GString */*s*/ )
610{ 623{
611 m_text-> beginString ( state ); 624 m_text-> beginString ( state );
612} 625}
613 626
614void QOutputDev::endString ( GfxState */*state*/ ) 627void QOutputDev::endString ( GfxState */*state*/ )
615{ 628{
616 m_text-> endString ( ); 629 m_text-> endString ( );
617} 630}
618 631
619void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y, 632void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
620 fp_t dx, fp_t dy, fp_t originX, fp_t originY, 633 fp_t dx, fp_t dy, fp_t originX, fp_t originY,
621 CharCode code, Unicode *u, int uLen ) 634 CharCode code, Unicode *u, int uLen )
622{ 635{
623 fp_t x1, y1, dx1, dy1; 636 fp_t x1, y1, dx1, dy1;
624 637
625 if ( uLen > 0 ) 638 if ( uLen > 0 )
626 m_text-> addChar ( state, x, y, dx, dy, u, uLen ); 639 m_text-> addChar ( state, x, y, dx, dy, u, uLen );
627 640
628 // check for invisible text -- this is used by Acrobat Capture 641 // check for invisible text -- this is used by Acrobat Capture
629 if (( state-> getRender ( ) & 3 ) == 3 ) { 642 if (( state-> getRender ( ) & 3 ) == 3 ) {
630 return; 643 return;
631 } 644 }
632 645
633 x -= originX; 646 x -= originX;
634 y -= originY; 647 y -= originY;
635 state-> transform ( x, y, &x1, &y1 ); 648 state-> transform ( x, y, &x1, &y1 );
636 state-> transformDelta ( dx, dy, &dx1, &dy1 ); 649 state-> transformDelta ( dx, dy, &dx1, &dy1 );
637 650
638 651
639 if ( uLen > 0 ) { 652 if ( uLen > 0 ) {
640 QString str; 653 QString str;
641 QFontMetrics fm = m_painter-> fontMetrics ( ); 654 QFontMetrics fm = m_painter-> fontMetrics ( );
642 655
643 for ( int i = 0; i < uLen; i++ ) { 656 for ( int i = 0; i < uLen; i++ ) {
644 QChar c = QChar ( u [i] ); 657 QChar c = QChar ( u [i] );
645 658
646 if ( fm. inFont ( c )) { 659 if ( fm. inFont ( c )) {
647 str [i] = QChar ( u [i] ); 660 str [i] = QChar ( u [i] );
648 } 661 }
649 else { 662 else {
650 str [i] = ' '; 663 str [i] = ' ';
651 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( ))); 664 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( )));
652 } 665 }
653 } 666 }
654 667
655 if (( uLen == 1 ) && ( str [0] == ' ' )) 668 if (( uLen == 1 ) && ( str [0] == ' ' ))
656 return; 669 return;
657 670
658 671
659 fp_t m11, m12, m21, m22; 672 fp_t m11, m12, m21, m22;
660 673
661 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 674 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
662 m11 *= state-> getHorizScaling ( ); 675 m11 *= state-> getHorizScaling ( );
663 m12 *= state-> getHorizScaling ( ); 676 m12 *= state-> getHorizScaling ( );
664 677
665 fp_t fsize = m_painter-> font ( ). pixelSize ( ); 678 fp_t fsize = m_painter-> font ( ). pixelSize ( );
666 679
667#ifndef QT_NO_TRANSFORMATIONS 680#ifndef QT_NO_TRANSFORMATIONS
668 QWMatrix oldmat; 681 QWMatrix oldmat;
669
670 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 ));
671 682
672 if ( dorot ) { 683 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 ));
684
685 if ( dorot ) {
673 oldmat = m_painter-> worldMatrix ( ); 686 oldmat = m_painter-> worldMatrix ( );
674 687
675 std::cerr << std::endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl; 688 std::cerr << std::endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl;
676 689
677 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 )); 690 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 ));
678 691
679 m_painter-> setWorldMatrix ( mat ); 692 m_painter-> setWorldMatrix ( mat );
680 693
681 x1 = 0; 694 x1 = 0;
682 y1 = 0; 695 y1 = 0;
683 } 696 }
684#endif 697#endif
685 698
686 QPen oldpen = m_painter-> pen ( ); 699 QPen oldpen = m_painter-> pen ( );
687 700
688 if (!( state-> getRender ( ) & 1 )) { 701 if (!( state-> getRender ( ) & 1 )) {
689 QPen fillpen = oldpen; 702 QPen fillpen = oldpen;
690 703
691 fillpen. setColor ( m_painter-> brush ( ). color ( )); 704 fillpen. setColor ( m_painter-> brush ( ). color ( ));
692 m_painter-> setPen ( fillpen ); 705 m_painter-> setPen ( fillpen );
693 } 706 }
694 707
695 if ( fsize > 5 ) 708 if ( fsize > 5 )
696 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str ); 709 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str );
697 else 710 else
698 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( )); 711 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( ));
699 712
700 m_painter-> setPen ( oldpen ); 713 m_painter-> setPen ( oldpen );
701 714
702#ifndef QT_NO_TRANSFORMATIONS 715#ifndef QT_NO_TRANSFORMATIONS
703 if ( dorot ) 716 if ( dorot )
704 m_painter-> setWorldMatrix ( oldmat ); 717 m_painter-> setWorldMatrix ( oldmat );
705 #endif 718#endif
706 719
707 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 ))); 720 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 )));
708 } 721 }
709 else if ( code != 0 ) { 722 else if ( code != 0 ) {
710 // some PDF files use CID 0, which is .notdef, so just ignore it 723 // some PDF files use CID 0, which is .notdef, so just ignore it
711 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 )); 724 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 ));
712 } 725 }
713 qApp-> processEvents ( ); 726 qApp-> processEvents ( );
714} 727}
715 728
716 729
717 730
718void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg ) 731void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg )
719{ 732{
720 // get CTM, check for singular matrix 733 // get CTM, check for singular matrix
721 fp_t *ctm = state-> getCTM ( ); 734 fp_t *ctm = state-> getCTM ( );
722 735
723 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 736 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
724 qWarning ( "Singular CTM in drawImage\n" ); 737 qWarning ( "Singular CTM in drawImage\n" );
725 738
726 if ( inlineImg ) { 739 if ( inlineImg ) {
727 str-> reset ( ); 740 str-> reset ( );
728 int j = height * (( width + 7 ) / 8 ); 741 int j = height * (( width + 7 ) / 8 );
729 for ( int i = 0; i < j; i++ ) 742 for ( int i = 0; i < j; i++ )
730 str->getChar(); 743 str->getChar();
731 744
732 str->close(); 745 str->close();
733 } 746 }
734 return; 747 return;
735 } 748 }
736 749
737 GfxRGB rgb; 750 GfxRGB rgb;
738 state-> getFillRGB ( &rgb ); 751 state-> getFillRGB ( &rgb );
739 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 752 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
740 753
741 754
742 QImage img ( width, height, 32 ); 755 QImage img ( width, height, 32 );
743 img. setAlphaBuffer ( true ); 756 img. setAlphaBuffer ( true );
744 757
745 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height )); 758 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height ));
746 759
747 // initialize the image stream 760 // initialize the image stream
748 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); 761 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 );
749 imgStr-> reset ( ); 762 imgStr-> reset ( );
750 763
751 uchar **scanlines = img. jumpTable ( ); 764 uchar **scanlines = img. jumpTable ( );
752 765
753 if ( ctm [3] > 0 ) 766 if ( ctm [3] > 0 )
754 scanlines += ( height - 1 ); 767 scanlines += ( height - 1 );
755 768
756 for ( int y = 0; y < height; y++ ) { 769 for ( int y = 0; y < height; y++ ) {
757 QRgb *scanline = (QRgb *) *scanlines; 770 QRgb *scanline = (QRgb *) *scanlines;
758 771
759 if ( ctm [0] < 0 ) 772 if ( ctm [0] < 0 )
760 scanline += ( width - 1 ); 773 scanline += ( width - 1 );
761 774
762 for ( int x = 0; x < width; x++ ) { 775 for ( int x = 0; x < width; x++ ) {
763 Guchar alpha; 776 Guchar alpha;
764 777
765 imgStr-> getPixel ( &alpha ); 778 imgStr-> getPixel ( &alpha );
766 779
767 if ( invert ) 780 if ( invert )
768 alpha ^= 1; 781 alpha ^= 1;
769 782
770 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val; 783 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val;
771 784
772 ctm [0] < 0 ? scanline-- : scanline++; 785 ctm [0] < 0 ? scanline-- : scanline++;
773 } 786 }
774 ctm [3] > 0 ? scanlines-- : scanlines++; 787 ctm [3] > 0 ? scanlines-- : scanlines++;
775 788
776 qApp-> processEvents ( ); 789 qApp-> processEvents ( );
777 } 790 }
778 791
779 #ifndef QT_NO_TRANSFORMATIONS 792#ifndef QT_NO_TRANSFORMATIONS
780 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 793 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
781 794
782 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl 795 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl
783 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl; 796 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl;
784 797
785 QWMatrix oldmat = m_painter-> worldMatrix ( ); 798 QWMatrix oldmat = m_painter-> worldMatrix ( );
786 m_painter-> setWorldMatrix ( mat, true ); 799 m_painter-> setWorldMatrix ( mat, true );
787 800
788#ifdef QWS 801#ifdef QWS
789 QPixmap pm; 802 QPixmap pm;
790 pm. convertFromImage ( img ); 803 pm. convertFromImage ( img );
791 m_painter-> drawPixmap ( 0, 0, pm ); 804 m_painter-> drawPixmap ( 0, 0, pm );
792#else 805#else
793 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 806 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
794#endif 807#endif
795 808
796 m_painter-> setWorldMatrix ( oldmat ); 809 m_painter-> setWorldMatrix ( oldmat );
797 810
798#else 811#else
799 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 812 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
800 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); 813 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
801 } 814 }
802 else { 815 else {
803 int x = lrint ( ctm [4] ); 816 int x = lrint ( ctm [4] );
804 int y = lrint ( ctm [5] ); 817 int y = lrint ( ctm [5] );
805 818
806 int w = lrint ( ctm [0] ); 819 int w = lrint ( ctm [0] );
807 int h = lrint ( ctm [3] ); 820 int h = lrint ( ctm [3] );
808 821
809 if ( w < 0 ) { 822 if ( w < 0 ) {
810 x += w; 823 x += w;
811 w = -w; 824 w = -w;
812 } 825 }
813 if ( h < 0 ) { 826 if ( h < 0 ) {
814 y += h; 827 y += h;
815 h = -h; 828 h = -h;
816 } 829 }
817 830
818 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h )); 831 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h ));
819 832
820 img = img. smoothScale ( w, h ); 833 img = img. smoothScale ( w, h );
821 qApp-> processEvents ( ); 834 qApp-> processEvents ( );
822 m_painter-> drawImage ( x, y, img ); 835 m_painter-> drawImage ( x, y, img );
823 } 836 }
824 837
825#endif 838#endif
826 839
827 delete imgStr; 840 delete imgStr;
828 qApp-> processEvents ( ); 841 qApp-> processEvents ( );
829} 842}
830 843
831 844
832void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg ) 845void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg )
833{ 846{
834 int nComps, nVals, nBits; 847 int nComps, nVals, nBits;
835 848
836 // image parameters 849 // image parameters
837 nComps = colorMap->getNumPixelComps ( ); 850 nComps = colorMap->getNumPixelComps ( );
838 nVals = width * nComps; 851 nVals = width * nComps;
839 nBits = colorMap-> getBits ( ); 852 nBits = colorMap-> getBits ( );
840 853
841 // get CTM, check for singular matrix 854 // get CTM, check for singular matrix
842 fp_t *ctm = state-> getCTM ( ); 855 fp_t *ctm = state-> getCTM ( );
843 856
844 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 857 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
845 qWarning ( "Singular CTM in drawImage\n" ); 858 qWarning ( "Singular CTM in drawImage\n" );
846 859
847 if ( inlineImg ) { 860 if ( inlineImg ) {
848 str-> reset ( ); 861 str-> reset ( );
849 int j = height * (( nVals * nBits + 7 ) / 8 ); 862 int j = height * (( nVals * nBits + 7 ) / 8 );
850 for ( int i = 0; i < j; i++ ) 863 for ( int i = 0; i < j; i++ )
851 str->getChar(); 864 str->getChar();
852 865
853 str->close(); 866 str->close();
854 } 867 }
855 return; 868 return;
856 } 869 }
857 870
858 QImage img ( width, height, 32 ); 871 QImage img ( width, height, 32 );
859 872
860 if ( maskColors ) 873 if ( maskColors )
861 img. setAlphaBuffer ( true ); 874 img. setAlphaBuffer ( true );
862 875
863 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height )); 876 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height ));
864 877
865 // initialize the image stream 878 // initialize the image stream
866 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits ); 879 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits );
867 imgStr-> reset ( ); 880 imgStr-> reset ( );
868 881
869 Guchar pixBuf [gfxColorMaxComps]; 882 Guchar pixBuf [gfxColorMaxComps];
870 GfxRGB rgb; 883 GfxRGB rgb;
871 884
872 885
873 uchar **scanlines = img. jumpTable ( ); 886 uchar **scanlines = img. jumpTable ( );
874 887
875 if ( ctm [3] > 0 ) 888 if ( ctm [3] > 0 )
876 scanlines += ( height - 1 ); 889 scanlines += ( height - 1 );
877 890
878 for ( int y = 0; y < height; y++ ) { 891 for ( int y = 0; y < height; y++ ) {
879 QRgb *scanline = (QRgb *) *scanlines; 892 QRgb *scanline = (QRgb *) *scanlines;
880 893
881 if ( ctm [0] < 0 ) 894 if ( ctm [0] < 0 )
882 scanline += ( width - 1 ); 895 scanline += ( width - 1 );
883 896
884 for ( int x = 0; x < width; x++ ) { 897 for ( int x = 0; x < width; x++ ) {
885 imgStr-> getPixel ( pixBuf ); 898 imgStr-> getPixel ( pixBuf );
886 colorMap-> getRGB ( pixBuf, &rgb ); 899 colorMap-> getRGB ( pixBuf, &rgb );
887 900
888 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 901 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
889 902
890 if ( maskColors ) { 903 if ( maskColors ) {
891 for ( int k = 0; k < nComps; ++k ) { 904 for ( int k = 0; k < nComps; ++k ) {
892 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) { 905 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) {
893 val |= 0xff000000; 906 val |= 0xff000000;
894 break; 907 break;
895 } 908 }
896 } 909 }
897 } 910 }
898 *scanline = val; 911 *scanline = val;
899 912
900 ctm [0] < 0 ? scanline-- : scanline++; 913 ctm [0] < 0 ? scanline-- : scanline++;
901 } 914 }
902 ctm [3] > 0 ? scanlines-- : scanlines++; 915 ctm [3] > 0 ? scanlines-- : scanlines++;
903 916
904 qApp-> processEvents ( ); 917 qApp-> processEvents ( );
905 } 918 }
906 919
907 920
908 #ifndef QT_NO_TRANSFORMATIONS 921#ifndef QT_NO_TRANSFORMATIONS
909 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 922 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
910 923
911 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl 924 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl
912 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl; 925 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl;
913 926
914 QWMatrix oldmat = m_painter-> worldMatrix ( ); 927 QWMatrix oldmat = m_painter-> worldMatrix ( );
915 m_painter-> setWorldMatrix ( mat, true ); 928 m_painter-> setWorldMatrix ( mat, true );
916 929
917#ifdef QWS 930#ifdef QWS
918 QPixmap pm; 931 QPixmap pm;
919 pm. convertFromImage ( img ); 932 pm. convertFromImage ( img );
920 m_painter-> drawPixmap ( 0, 0, pm ); 933 m_painter-> drawPixmap ( 0, 0, pm );
921 #else 934#else
922 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 935 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
923#endif 936#endif
924 937
925 m_painter-> setWorldMatrix ( oldmat ); 938 m_painter-> setWorldMatrix ( oldmat );
926 939
927#else // QT_NO_TRANSFORMATIONS 940#else // QT_NO_TRANSFORMATIONS
928 941
929 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 942 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
930 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); 943 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
931 } 944 }
932 else { 945 else {
933 int x = lrint ( ctm [4] ); 946 int x = lrint ( ctm [4] );
934 int y = lrint ( ctm [5] ); 947 int y = lrint ( ctm [5] );
935 948
936 int w = lrint ( ctm [0] ); 949 int w = lrint ( ctm [0] );
937 int h = lrint ( ctm [3] ); 950 int h = lrint ( ctm [3] );
938 951
939 if ( w < 0 ) { 952 if ( w < 0 ) {
940 x += w; 953 x += w;
941 w = -w; 954 w = -w;
942 } 955 }
943 if ( h < 0 ) { 956 if ( h < 0 ) {
944 y += h; 957 y += h;
945 h = -h; 958 h = -h;
946 } 959 }
947 960
948 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h )); 961 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h ));
949 962
950 img = img. smoothScale ( w, h ); 963 img = img. smoothScale ( w, h );
951 qApp-> processEvents ( ); 964 qApp-> processEvents ( );
952 m_painter-> drawImage ( x, y, img ); 965 m_painter-> drawImage ( x, y, img );
953 } 966 }
954 967
955#endif 968#endif
956 969
957 970
958 delete imgStr; 971 delete imgStr;
959 qApp-> processEvents ( ); 972 qApp-> processEvents ( );
960} 973}
961 974
962 975
963 976
964bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom ) 977bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom )
965{ 978{
966 int l, t, w, h; 979 int l, t, w, h;
967 r. rect ( &l, &t, &w, &h ); 980 r. rect ( &l, &t, &w, &h );
968 981
969 bool res = findText ( str, l, t, w, h, top, bottom ); 982 bool res = findText ( str, l, t, w, h, top, bottom );
970 983
971 r. setRect ( l, t, w, h ); 984 r. setRect ( l, t, w, h );
972 return res; 985 return res;
973} 986}
974 987
975bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom ) 988bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom )
976{ 989{
977 bool found = false; 990 bool found = false;
978 uint len = str. length ( ); 991 uint len = str. length ( );
979 Unicode *s = new Unicode [len]; 992 Unicode *s = new Unicode [len];
980 993
981 for ( uint i = 0; i < len; i++ ) 994 for ( uint i = 0; i < len; i++ )
982 s [i] = str [i]. unicode ( ); 995 s [i] = str [i]. unicode ( );
983 996
984 fp_t x1 = (fp_t) l; 997 fp_t x1 = (fp_t) l;
985 fp_t y1 = (fp_t) t; 998 fp_t y1 = (fp_t) t;
986 fp_t x2 = (fp_t) l + w - 1; 999 fp_t x2 = (fp_t) l + w - 1;
987 fp_t y2 = (fp_t) t + h - 1; 1000 fp_t y2 = (fp_t) t + h - 1;
988 1001
989 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) { 1002 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) {
990 l = lrint ( x1 ); 1003 l = lrint ( x1 );
991 t = lrint ( y1 ); 1004 t = lrint ( y1 );
992 w = lrint ( x2 ) - l + 1; 1005 w = lrint ( x2 ) - l + 1;
993 h = lrint ( y2 ) - t + 1; 1006 h = lrint ( y2 ) - t + 1;
994 found = true; 1007 found = true;
995 } 1008 }
996 delete [] s; 1009 delete [] s;
997 1010
998 return found; 1011 return found;
999} 1012}
1000 1013
1001GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax ) 1014GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax )
1002{ 1015{
1003 bool found = false; 1016 bool found = false;
1004 fp_t xMin1 = (double) *xMin; 1017 fp_t xMin1 = (double) *xMin;
1005 fp_t yMin1 = (double) *yMin; 1018 fp_t yMin1 = (double) *yMin;
1006 fp_t xMax1 = (double) *xMax; 1019 fp_t xMax1 = (double) *xMax;
1007 fp_t yMax1 = (double) *yMax; 1020 fp_t yMax1 = (double) *yMax;
1008 1021
1009 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) { 1022 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) {
1010 *xMin = lrint ( xMin1 ); 1023 *xMin = lrint ( xMin1 );
1011 *xMax = lrint ( xMax1 ); 1024 *xMax = lrint ( xMax1 );
1012 *yMin = lrint ( yMin1 ); 1025 *yMin = lrint ( yMin1 );
1013 *yMax = lrint ( yMax1 ); 1026 *yMax = lrint ( yMax1 );
1014 found = true; 1027 found = true;
1015 } 1028 }
1016 return found; 1029 return found;
1017} 1030}
1018 1031
1019QString QOutputDev::getText ( int l, int t, int w, int h ) 1032QString QOutputDev::getText ( int l, int t, int w, int h )
1020{ 1033{
1021 GString *gstr = m_text-> getText ( l, t, l + w - 1, t + h - 1 ); 1034 GString *gstr = m_text-> getText ( l, t, l + w - 1, t + h - 1 );
1022 QString str = gstr-> getCString ( ); 1035 QString str = gstr-> getCString ( );
1023 delete gstr; 1036 delete gstr;
1024 return str; 1037 return str;
1025} 1038}
1026 1039
1027QString QOutputDev::getText ( const QRect &r ) 1040QString QOutputDev::getText ( const QRect &r )
1028{ 1041{
1029 return getText ( r. left ( ), r. top ( ), r. width ( ), r. height ( )); 1042 return getText ( r. left ( ), r. top ( ), r. width ( ), r. height ( ));
1030} 1043}
1031 1044
1032 1045
1033 1046
1034void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph ) 1047void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph )
1035{ 1048{
1036 if ( m_pixmap ) 1049 if ( m_pixmap )
1037 p-> drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph ); 1050 p-> drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph );
1038 else 1051 else
1039 p-> fillRect ( clipx, clipy, clipw, cliph, white ); 1052 p-> fillRect ( clipx, clipy, clipw, cliph, white );
1040} 1053}
diff --git a/noncore/unsupported/qpdf/opie-qpdf.control b/noncore/unsupported/qpdf/opie-qpdf.control
index 33df3e1..208dcb1 100644
--- a/noncore/unsupported/qpdf/opie-qpdf.control
+++ b/noncore/unsupported/qpdf/opie-qpdf.control
@@ -1,9 +1,9 @@
1Package: opie-qpdf 1Package: opie-qpdf
2Files: bin/qpdf apps/Applications/qpdf.desktop pics/qpdf/qpdf_icon.png 2Files: bin/qpdf apps/Applications/qpdf.desktop pics/qpdf/qpdf_icon.png
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Robert Griebl <sandman@handhelds.org> 5Maintainer: Robert Griebl <sandman@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal, gzip 7Depends: task-opie-minimal, gzip
9Description: A PDF viewer for OPIE. 8Description: A PDF viewer for OPIE.
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/unsupported/qpdf/qpdf.cpp b/noncore/unsupported/qpdf/qpdf.cpp
index 61f097b..de1dcf3 100644
--- a/noncore/unsupported/qpdf/qpdf.cpp
+++ b/noncore/unsupported/qpdf/qpdf.cpp
@@ -1,540 +1,540 @@
1//======================================================================== 1//========================================================================
2// 2//
3// qpdf.cc 3// qpdf.cc
4// 4//
5// Copyright 2001 Robert Griebl 5// Copyright 2001 Robert Griebl
6// 6//
7//======================================================================== 7//========================================================================
8 8
9#include "aconf.h" 9#include "aconf.h"
10#include "GString.h" 10#include "GString.h"
11#include "PDFDoc.h" 11#include "PDFDoc.h"
12#include "TextOutputDev.h" 12#include "TextOutputDev.h"
13 13
14#include "QPEOutputDev.h" 14#include "QPEOutputDev.h"
15 15
16#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/applnk.h> 18#include <qpe/applnk.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20 20
21 21
22#include <qclipboard.h> 22#include <qclipboard.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qtoolbutton.h> 24#include <qtoolbutton.h>
25#include <qpe/qpemenubar.h> 25#include <qpe/qpemenubar.h>
26#include <qpopupmenu.h> 26#include <qpopupmenu.h>
27#include <qwidgetstack.h> 27#include <qwidgetstack.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qfileinfo.h> 29#include <qfileinfo.h>
30#include <qstring.h> 30#include <qstring.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qdialog.h> 34#include <qdialog.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37 37
38#include "qpdf.h" 38#include "qpdf.h"
39 39
40#ifdef QPDF_QPE_ONLY 40#ifdef QPDF_QPE_ONLY
41#include <qpe/fileselector.h> 41#include <qpe/fileselector.h>
42#else 42#else
43#include <opie/ofileselector.h> 43#include <opie/ofileselector.h>
44#endif 44#endif
45 45
46 46
47int main ( int argc, char **argv ) 47int main ( int argc, char **argv )
48{ 48{
49 QPEApplication app ( argc, argv ); 49 QPEApplication app ( argc, argv );
50 50
51 // read config file 51 // read config file
52 globalParams = new GlobalParams ( "" ); 52 globalParams = new GlobalParams ( "" );
53 globalParams-> setErrQuiet ( true ); 53 globalParams-> setErrQuiet ( true );
54 54
55 QPdfDlg *dlg = new QPdfDlg ( ); 55 QPdfDlg *dlg = new QPdfDlg ( );
56 app. showMainDocumentWidget ( dlg ); 56 app. showMainDocumentWidget ( dlg );
57 57
58 if (( app. argc ( ) == 3 ) && ( app. argv ( ) [1] == QCString ( "-f" ))) 58 if (( app. argc ( ) == 3 ) && ( app. argv ( ) [1] == QCString ( "-f" )))
59 dlg-> openFile ( app. argv ( ) [2] ); 59 dlg-> openFile ( app. argv ( ) [2] );
60 60
61 return app. exec ( ); 61 return app. exec ( );
62} 62}
63 63
64 64
65QPdfDlg::QPdfDlg ( ) : QMainWindow ( ) 65QPdfDlg::QPdfDlg ( ) : QMainWindow ( )
66{ 66{
67 setCaption ( tr( "QPdf" )); 67 setCaption ( tr( "QPdf" ));
68 setIcon ( Resource::loadPixmap ( "qpdf_icon" )); 68 setIcon ( Resource::loadPixmap ( "qpdf_icon" ));
69 69
70 m_busy = false; 70 m_busy = false;
71 71
72 m_doc = 0; 72 m_doc = 0;
73 m_pages = 0; 73 m_pages = 0;
74 m_zoom = 72; 74 m_zoom = 72;
75 m_currentpage = 0; 75 m_currentpage = 0;
76 76
77 m_fullscreen = false; 77 m_fullscreen = false;
78 m_renderok = false; 78 m_renderok = false;
79 79
80 80
81 setToolBarsMovable ( false ); 81 setToolBarsMovable ( false );
82 82
83 m_stack = new QWidgetStack ( this ); 83 m_stack = new QWidgetStack ( this );
84 m_stack-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); 84 m_stack-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
85 setCentralWidget ( m_stack ); 85 setCentralWidget ( m_stack );
86 86
87 m_outdev = new QPEOutputDev ( m_stack ); 87 m_outdev = new QPEOutputDev ( m_stack );
88 connect ( m_outdev, SIGNAL( selectionChanged ( const QRect & )), this, SLOT( copyToClipboard ( const QRect & ))); 88 connect ( m_outdev, SIGNAL( selectionChanged ( const QRect & )), this, SLOT( copyToClipboard ( const QRect & )));
89 89
90#ifdef QPDF_QPE_ONLY 90#ifdef QPDF_QPE_ONLY
91 m_filesel = new FileSelector ( "application/pdf", m_stack, "fs", false, true ); 91 m_filesel = new FileSelector ( "application/pdf", m_stack, "fs", false, true );
92#else 92#else
93 m_filesel = new OFileSelector ( "application/pdf", m_stack, "fs", false, true ); 93 m_filesel = new OFileSelector ( "application/pdf", m_stack, "fs", false, true );
94#endif 94#endif
95 95
96 connect ( m_filesel, SIGNAL( closeMe ( )), this, SLOT( closeFileSelector ( ))); 96 connect ( m_filesel, SIGNAL( closeMe ( )), this, SLOT( closeFileSelector ( )));
97 connect ( m_filesel, SIGNAL( fileSelected ( const DocLnk & )), this, SLOT( openFile ( const DocLnk & ))); 97 connect ( m_filesel, SIGNAL( fileSelected ( const DocLnk & )), this, SLOT( openFile ( const DocLnk & )));
98 98
99 m_tb_menu = new QToolBar ( this ); 99 m_tb_menu = new QToolBar ( this );
100 m_tb_menu-> setHorizontalStretchable ( true ); 100 m_tb_menu-> setHorizontalStretchable ( true );
101 101
102 QMenuBar *mb = new QMenuBar ( m_tb_menu ); 102 QMenuBar *mb = new QMenuBar ( m_tb_menu );
103 103
104 m_pm_zoom = new QPopupMenu ( mb ); 104 m_pm_zoom = new QPopupMenu ( mb );
105 m_pm_zoom-> setCheckable ( true ); 105 m_pm_zoom-> setCheckable ( true );
106 106
107 mb-> insertItem ( tr( "Zoom" ), m_pm_zoom ); 107 mb-> insertItem ( tr( "Zoom" ), m_pm_zoom );
108 108
109 m_pm_zoom-> insertItem ( tr( "Fit to width" ), 1 ); 109 m_pm_zoom-> insertItem ( tr( "Fit to width" ), 1 );
110 m_pm_zoom-> insertItem ( tr( "Fit to page" ), 2 ); 110 m_pm_zoom-> insertItem ( tr( "Fit to page" ), 2 );
111 m_pm_zoom-> insertSeparator ( ); 111 m_pm_zoom-> insertSeparator ( );
112 m_pm_zoom-> insertItem ( tr( "50%" ), 50 ); 112 m_pm_zoom-> insertItem ( tr( "50%" ), 50 );
113 m_pm_zoom-> insertItem ( tr( "75%" ), 75 ); 113 m_pm_zoom-> insertItem ( tr( "75%" ), 75 );
114 m_pm_zoom-> insertItem ( tr( "100%" ), 100 ); 114 m_pm_zoom-> insertItem ( tr( "100%" ), 100 );
115 m_pm_zoom-> insertItem ( tr( "125%" ), 125 ); 115 m_pm_zoom-> insertItem ( tr( "125%" ), 125 );
116 m_pm_zoom-> insertItem ( tr( "150%" ), 150 ); 116 m_pm_zoom-> insertItem ( tr( "150%" ), 150 );
117 m_pm_zoom-> insertItem ( tr( "200%" ), 200 ); 117 m_pm_zoom-> insertItem ( tr( "200%" ), 200 );
118 118
119 connect ( m_pm_zoom, SIGNAL( activated ( int )), this, SLOT( setZoom ( int ))); 119 connect ( m_pm_zoom, SIGNAL( activated ( int )), this, SLOT( setZoom ( int )));
120 120
121 m_tb_tool = new QToolBar ( this ); 121 m_tb_tool = new QToolBar ( this );
122 122
123 new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile ( )), m_tb_tool, "open" ); 123 new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile ( )), m_tb_tool, "open" );
124 m_tb_tool-> addSeparator ( ); 124 m_tb_tool-> addSeparator ( );
125 m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar ( )), m_tb_tool, "find" ); 125 m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar ( )), m_tb_tool, "find" );
126 m_to_find-> setToggleButton ( true ); 126 m_to_find-> setToggleButton ( true );
127 m_tb_tool-> addSeparator ( ); 127 m_tb_tool-> addSeparator ( );
128 m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen ( )), m_tb_tool, "fullscreen" ); 128 m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen ( )), m_tb_tool, "fullscreen" );
129 m_to_full-> setToggleButton ( true ); 129 m_to_full-> setToggleButton ( true );
130 m_tb_tool-> addSeparator ( ); 130 m_tb_tool-> addSeparator ( );
131 new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage ( )), m_tb_tool, "first" ); 131 new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage ( )), m_tb_tool, "first" );
132 new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage ( )), m_tb_tool, "prev" ); 132 new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage ( )), m_tb_tool, "prev" );
133 new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog ( )), m_tb_tool, "goto" ); 133 new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog ( )), m_tb_tool, "goto" );
134 new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage ( )), m_tb_tool, "next" ); 134 new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage ( )), m_tb_tool, "next" );
135 new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage ( )), m_tb_tool, "last" ); 135 new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage ( )), m_tb_tool, "last" );
136 136
137 m_tb_find = new QToolBar ( this ); 137 m_tb_find = new QToolBar ( this );
138 addToolBar ( m_tb_find, "Search", QMainWindow::Top, true ); 138 addToolBar ( m_tb_find, "Search", QMainWindow::Top, true );
139 m_tb_find-> setHorizontalStretchable ( true ); 139 m_tb_find-> setHorizontalStretchable ( true );
140 m_tb_find-> hide ( ); 140 m_tb_find-> hide ( );
141 141
142 m_findedit = new QLineEdit ( m_tb_find, "findedit" ); 142 m_findedit = new QLineEdit ( m_tb_find, "findedit" );
143 m_tb_find-> setStretchableWidget ( m_findedit ); 143 m_tb_find-> setStretchableWidget ( m_findedit );
144 connect ( m_findedit, SIGNAL( textChanged ( const QString & )), this, SLOT( findText ( const QString & ))); 144 connect ( m_findedit, SIGNAL( textChanged ( const QString & )), this, SLOT( findText ( const QString & )));
145 145
146 new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText ( )), m_tb_find, "findnext" ); 146 new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText ( )), m_tb_find, "findnext" );
147 147
148 openFile ( ); 148 openFile ( );
149} 149}
150 150
151QPdfDlg::~QPdfDlg ( ) 151QPdfDlg::~QPdfDlg ( )
152{ 152{
153 delete m_doc; 153 delete m_doc;
154} 154}
155 155
156// vv Fullscreen handling (for broken QT-lib) [David Hedbor, www.eongames.com] 156// vv Fullscreen handling (for broken QT-lib) [David Hedbor, www.eongames.com]
157 157
158void QPdfDlg::resizeEvent ( QResizeEvent * ) 158void QPdfDlg::resizeEvent ( QResizeEvent * )
159{ 159{
160 if ( m_fullscreen && ( size ( ) != qApp-> desktop ( )-> size ( ))) 160 if ( m_fullscreen && ( size ( ) != qApp-> desktop ( )-> size ( )))
161 setFullscreen ( true ); 161 setFullscreen ( true );
162} 162}
163 163
164void QPdfDlg::focusInEvent ( QFocusEvent * ) 164void QPdfDlg::focusInEvent ( QFocusEvent * )
165{ 165{
166 if ( m_fullscreen ) 166 if ( m_fullscreen )
167 setFullscreen ( true ); 167 setFullscreen ( true );
168} 168}
169 169
170void QPdfDlg::toggleFullscreen ( ) 170void QPdfDlg::toggleFullscreen ( )
171{ 171{
172 if ( m_to_full-> isOn ( ) == m_fullscreen ) 172 if ( m_to_full-> isOn ( ) == m_fullscreen )
173 m_to_full-> setOn ( !m_fullscreen ); 173 m_to_full-> setOn ( !m_fullscreen );
174 174
175 m_fullscreen = !m_fullscreen; 175 m_fullscreen = !m_fullscreen;
176 setFullscreen ( m_fullscreen ); 176 setFullscreen ( m_fullscreen );
177} 177}
178 178
179void QPdfDlg::setFullscreen ( bool b ) 179void QPdfDlg::setFullscreen ( bool b )
180{ 180{
181 static QSize normalsize; 181 static QSize normalsize;
182 182
183 if ( b ) { 183 if ( b ) {
184 if ( !normalsize. isValid ( )) 184 if ( !normalsize. isValid ( ))
185 normalsize = size ( ); 185 normalsize = size ( );
186 186
187 setFixedSize ( qApp-> desktop ( )-> size ( )); 187 setFixedSize ( qApp-> desktop ( )-> size ( ));
188 showNormal ( ); 188 showNormal ( );
189 reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 )); 189 reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 ));
190 showFullScreen ( ); 190 showFullScreen ( );
191 } 191 }
192 else { 192 else {
193 showNormal ( ); 193 showNormal ( );
194 reparent ( 0, 0, QPoint ( 0, 0 )); 194 reparent ( 0, 0, QPoint ( 0, 0 ));
195 resize ( normalsize ); 195 resize ( normalsize );
196 showMaximized ( ); 196 showMaximized ( );
197 normalsize = QSize ( ); 197 normalsize = QSize ( );
198 } 198 }
199} 199}
200 200
201// ^^ Fullscreen handling (for broken QT-lib) 201// ^^ Fullscreen handling (for broken QT-lib)
202 202
203void QPdfDlg::setBusy ( bool b ) 203void QPdfDlg::setBusy ( bool b )
204{ 204{
205 if ( b != m_busy ) { 205 if ( b != m_busy ) {
206 m_busy = b; 206 m_busy = b;
207 207
208 m_outdev-> setBusy ( m_busy ); 208 m_outdev-> setBusy ( m_busy );
209 setEnabled ( !m_busy ); 209 setEnabled ( !m_busy );
210 } 210 }
211} 211}
212 212
213bool QPdfDlg::busy ( ) const 213bool QPdfDlg::busy ( ) const
214{ 214{
215 return m_busy; 215 return m_busy;
216} 216}
217 217
218 218
219void QPdfDlg::updateCaption ( ) 219void QPdfDlg::updateCaption ( )
220{ 220{
221 QString cap = ""; 221 QString cap = "";
222 222
223 if ( !m_currentdoc. isEmpty ( )) 223 if ( !m_currentdoc. isEmpty ( ))
224 cap = QString ( "%1 - " ). arg ( m_currentdoc ); 224 cap = QString ( "%1 - " ). arg ( m_currentdoc );
225 cap += "QPdf"; 225 cap += "QPdf";
226 226
227 setCaption ( cap ); 227 setCaption ( cap );
228} 228}
229 229
230 230
231void QPdfDlg::setZoom ( int id ) 231void QPdfDlg::setZoom ( int id )
232{ 232{
233 int dpi = 0; 233 int dpi = 0;
234 234
235 switch ( id ) { 235 switch ( id ) {
236 case 1: 236 case 1:
237 if ( m_doc && m_doc-> isOk ( )) 237 if ( m_doc && m_doc-> isOk ( ))
238 dpi = m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ); 238 dpi = m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage );
239 break; 239 break;
240 240
241 case 2: 241 case 2:
242 if ( m_doc && m_doc-> isOk ( )) 242 if ( m_doc && m_doc-> isOk ( ))
243 dpi = QMIN( m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ), \ 243 dpi = QMIN( m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ), \
244 m_outdev-> visibleHeight ( ) * 72 / m_doc-> getPageHeight ( m_currentpage )); 244 m_outdev-> visibleHeight ( ) * 72 / m_doc-> getPageHeight ( m_currentpage ));
245 break; 245 break;
246 246
247 default: 247 default:
248 dpi = id * 72 / 100; 248 dpi = id * 72 / 100;
249 break; 249 break;
250 } 250 }
251 251
252 if ( dpi < 18 ) 252 if ( dpi < 18 )
253 dpi = 18; 253 dpi = 18;
254 if ( dpi > 216 ) 254 if ( dpi > 216 )
255 dpi = 216; 255 dpi = 216;
256 256
257 for ( uint i = 0; i < m_pm_zoom-> count ( ); i++ ) { 257 for ( uint i = 0; i < m_pm_zoom-> count ( ); i++ ) {
258 int xid = m_pm_zoom-> idAt ( i ); 258 int xid = m_pm_zoom-> idAt ( i );
259 m_pm_zoom-> setItemChecked ( xid, xid == id ); 259 m_pm_zoom-> setItemChecked ( xid, xid == id );
260 } 260 }
261 261
262 if ( dpi != m_zoom ) { 262 if ( dpi != m_zoom ) {
263 m_zoom = dpi; 263 m_zoom = dpi;
264 264
265 renderPage ( ); 265 renderPage ( );
266 } 266 }
267} 267}
268 268
269 269
270void QPdfDlg::gotoPageDialog ( ) 270void QPdfDlg::gotoPageDialog ( )
271{ 271{
272 QDialog *d = new QDialog ( this, "gotodlg", true ); 272 QDialog *d = new QDialog ( this, "gotodlg", true );
273 d-> setCaption ( tr( "Goto page" )); 273 d-> setCaption ( tr( "Goto page" ));
274 274
275 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); 275 QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 );
276 276
277 QLabel *l = new QLabel ( tr( "Select from 1 .. %1:" ). arg ( m_pages ), d ); 277 QLabel *l = new QLabel ( tr( "Select from 1 .. %1:" ). arg ( m_pages ), d );
278 lay-> addWidget ( l ); 278 lay-> addWidget ( l );
279 279
280 QSpinBox *spin = new QSpinBox ( 1, m_pages, 1, d ); 280 QSpinBox *spin = new QSpinBox ( 1, m_pages, 1, d );
281 spin-> setValue ( m_currentpage ); 281 spin-> setValue ( m_currentpage );
282 spin-> setWrapping ( true ); 282 spin-> setWrapping ( true );
283 spin-> setButtonSymbols ( QSpinBox::PlusMinus ); 283 spin-> setButtonSymbols ( QSpinBox::PlusMinus );
284 lay-> addWidget ( spin ); 284 lay-> addWidget ( spin );
285 285
286 if ( d-> exec ( ) == QDialog::Accepted ) { 286 if ( d-> exec ( ) == QDialog::Accepted ) {
287 gotoPage ( spin-> value ( )); 287 gotoPage ( spin-> value ( ));
288 } 288 }
289 289
290 delete d; 290 delete d;
291} 291}
292 292
293void QPdfDlg::toggleFindBar ( ) 293void QPdfDlg::toggleFindBar ( )
294{ 294{
295 if ( m_to_find-> isOn ( ) == m_tb_find-> isVisible ( )) 295 if ( m_to_find-> isOn ( ) == m_tb_find-> isVisible ( ))
296 m_to_find-> setOn ( !m_tb_find-> isVisible ( )); 296 m_to_find-> setOn ( !m_tb_find-> isVisible ( ));
297 297
298 if ( m_tb_find-> isVisible ( )) { 298 if ( m_tb_find-> isVisible ( )) {
299 m_tb_find-> hide ( ); 299 m_tb_find-> hide ( );
300 m_outdev-> setFocus ( ); 300 m_outdev-> setFocus ( );
301 } 301 }
302 else { 302 else {
303 m_tb_find-> show ( ); 303 m_tb_find-> show ( );
304 m_findedit-> setFocus ( ); 304 m_findedit-> setFocus ( );
305 } 305 }
306} 306}
307 307
308void QPdfDlg::findText ( const QString &str ) 308void QPdfDlg::findText ( const QString &str )
309{ 309{
310 if ( !m_doc || !m_doc-> isOk ( ) || str. isEmpty ( )) 310 if ( !m_doc || !m_doc-> isOk ( ) || str. isEmpty ( ))
311 return; 311 return;
312 312
313 TextOutputDev *textOut = 0; 313 TextOutputDev *textOut = 0;
314 int pg = 0; 314 int pg = 0;
315 315
316 setBusy ( true ); 316 setBusy ( true );
317 317
318 int len = str. length ( ); 318 int len = str. length ( );
319 Unicode *u = new Unicode [len]; 319 Unicode *u = new Unicode [len];
320 for ( int i = 0; i < len; i++ ) 320 for ( int i = 0; i < len; i++ )
321 u [i] = str [i]. unicode ( ); 321 u [i] = str [i]. unicode ( );
322 322
323 int xMin = 0, yMin = 0, xMax = 0, yMax = 0; 323 int xMin = 0, yMin = 0, xMax = 0, yMax = 0;
324 QRect selr = m_outdev-> selection ( ); 324 QRect selr = m_outdev-> selection ( );
325 bool fromtop = true; 325 bool fromtop = true;
326 326
327 if ( selr. isValid ( )) { 327 if ( selr. isValid ( )) {
328 xMin = selr. right ( ); 328 xMin = selr. right ( );
329 yMin = selr. top ( ) + selr. height ( ) / 2; 329 yMin = selr. top ( ) + selr. height ( ) / 2;
330 fromtop = false; 330 fromtop = false;
331 } 331 }
332 332
333 if ( m_outdev-> findText ( u, len, fromtop, true, &xMin, &yMin, &xMax, &yMax )) 333 if ( m_outdev-> findText ( u, len, fromtop, true, &xMin, &yMin, &xMax, &yMax ))
334 goto found; 334 goto found;
335 335
336 qApp-> processEvents ( ); 336 qApp-> processEvents ( );
337 337
338 // search following pages 338 // search following pages
339 textOut = new TextOutputDev ( 0, gFalse, gFalse ); 339 textOut = new TextOutputDev ( 0, gFalse, gFalse );
340 if ( !textOut-> isOk ( )) 340 if ( !textOut-> isOk ( ))
341 goto done; 341 goto done;
342 342
343 qApp-> processEvents ( ); 343 qApp-> processEvents ( );
344 344
345 for ( pg = ( m_currentpage % m_pages ) + 1; pg != m_currentpage; pg = ( pg % m_pages ) + 1 ) { 345 for ( pg = ( m_currentpage % m_pages ) + 1; pg != m_currentpage; pg = ( pg % m_pages ) + 1 ) {
346 m_doc-> displayPage ( textOut, pg, 72, 0, gFalse ); 346 m_doc-> displayPage ( textOut, pg, 72, 0, gFalse );
347 347
348 fp_t xMin1, yMin1, xMax1, yMax1; 348 fp_t xMin1, yMin1, xMax1, yMax1;
349 349
350 qApp-> processEvents ( ); 350 qApp-> processEvents ( );
351 351
352 if ( textOut-> findText ( u, len, gTrue, gTrue, &xMin1, &yMin1, &xMax1, &yMax1 )) 352 if ( textOut-> findText ( u, len, gTrue, gTrue, &xMin1, &yMin1, &xMax1, &yMax1 ))
353 goto foundPage; 353 goto foundPage;
354 354
355 qApp-> processEvents ( ); 355 qApp-> processEvents ( );
356 } 356 }
357 357
358 // search current page ending at current selection 358 // search current page ending at current selection
359 if ( selr. isValid ( )) { 359 if ( selr. isValid ( )) {
360 xMax = selr. left ( ); 360 xMax = selr. left ( );
361 yMax = selr. top ( ) + selr. height ( ) / 2; 361 yMax = selr. top ( ) + selr. height ( ) / 2;
362 362
363 if ( m_outdev-> findText ( u, len, gTrue, gFalse, &xMin, &yMin, &xMax, &yMax )) 363 if ( m_outdev-> findText ( u, len, gTrue, gFalse, &xMin, &yMin, &xMax, &yMax ))
364 goto found; 364 goto found;
365 } 365 }
366 366
367 // not found 367 // not found
368 QMessageBox::information ( this, tr( "Find..." ), tr( "'%1' could not be found." ). arg ( str )); 368 QMessageBox::information ( this, tr( "Find..." ), tr( "'%1' could not be found." ). arg ( str ));
369 goto done; 369 goto done;
370 370
371foundPage: 371foundPage:
372 qApp-> processEvents ( ); 372 qApp-> processEvents ( );
373 373
374 gotoPage ( pg ); 374 gotoPage ( pg );
375 375
376 if ( !m_outdev-> findText ( u, len, gTrue, gTrue, &xMin, &yMin, &xMax, &yMax )) { 376 if ( !m_outdev-> findText ( u, len, gTrue, gTrue, &xMin, &yMin, &xMax, &yMax )) {
377 // this can happen if coalescing is bad 377 // this can happen if coalescing is bad
378 goto done; 378 goto done;
379 } 379 }
380 380
381found: 381found:
382 selr. setCoords ( xMin, yMin, xMax, yMax ); 382 selr. setCoords ( xMin, yMin, xMax, yMax );
383 m_outdev-> setSelection ( selr, true ); // this will emit QPEOutputDev::selectionChanged ( ) -> copyToClipboard ( ) 383 m_outdev-> setSelection ( selr, true ); // this will emit QPEOutputDev::selectionChanged ( ) -> copyToClipboard ( )
384 384
385 done: 385 done:
386 386
387 delete [] u; 387 delete [] u;
388 delete textOut; 388 delete textOut;
389 389
390 setBusy ( false ); 390 setBusy ( false );
391} 391}
392 392
393 393
394void QPdfDlg::findText ( ) 394void QPdfDlg::findText ( )
395{ 395{
396 findText ( m_findedit-> text ( )); 396 findText ( m_findedit-> text ( ));
397} 397}
398 398
399void QPdfDlg::copyToClipboard ( const QRect &r ) 399void QPdfDlg::copyToClipboard ( const QRect &r )
400{ 400{
401 if ( m_doc && m_doc-> isOk ( ) && m_doc-> okToCopy ( )) 401 if ( m_doc && m_doc-> isOk ( ) && m_doc-> okToCopy ( ))
402 qApp-> clipboard ( )-> setText ( m_outdev-> getText ( r )); 402 qApp-> clipboard ( )-> setText ( m_outdev-> getText ( r ));
403} 403}
404 404
405void QPdfDlg::firstPage ( ) 405void QPdfDlg::firstPage ( )
406{ 406{
407 gotoPage ( 1 ); 407 gotoPage ( 1 );
408} 408}
409 409
410void QPdfDlg::prevPage ( ) 410void QPdfDlg::prevPage ( )
411{ 411{
412 gotoPage ( m_currentpage - 1 ); 412 gotoPage ( m_currentpage - 1 );
413} 413}
414 414
415void QPdfDlg::nextPage ( ) 415void QPdfDlg::nextPage ( )
416{ 416{
417 gotoPage ( m_currentpage + 1 ); 417 gotoPage ( m_currentpage + 1 );
418} 418}
419 419
420void QPdfDlg::lastPage ( ) 420void QPdfDlg::lastPage ( )
421{ 421{
422 gotoPage ( m_pages ); 422 gotoPage ( m_pages );
423} 423}
424 424
425void QPdfDlg::gotoPage ( int n ) 425void QPdfDlg::gotoPage ( int n )
426{ 426{
427 if ( n < 1 ) 427 if ( n < 1 )
428 n = 1; 428 n = 1;
429 if ( n > m_pages ) 429 if ( n > m_pages )
430 n = m_pages; 430 n = m_pages;
431 431
432 if ( n != m_currentpage ) { 432 if ( n != m_currentpage ) {
433 m_currentpage = n; 433 m_currentpage = n;
434 434
435 renderPage ( ); 435 renderPage ( );
436 } 436 }
437} 437}
438 438
439void QPdfDlg::renderPage ( ) 439void QPdfDlg::renderPage ( )
440{ 440{
441 if ( m_renderok && m_doc && m_doc-> isOk ( )) { 441 if ( m_renderok && m_doc && m_doc-> isOk ( )) {
442 m_renderok = false; 442 m_renderok = false;
443 443
444 setBusy ( true ); 444 setBusy ( true );
445 m_doc-> displayPage ( m_outdev, m_currentpage, m_zoom, 0, true ); 445 m_doc-> displayPage ( m_outdev, m_currentpage, m_zoom, 0, true );
446 setBusy ( false ); 446 setBusy ( false );
447 447
448 m_outdev-> setPageCount ( m_currentpage, m_pages ); 448 m_outdev-> setPageCount ( m_currentpage, m_pages );
449 449
450 m_renderok = true; 450 m_renderok = true;
451 } 451 }
452} 452}
453 453
454void QPdfDlg::closeFileSelector ( ) 454void QPdfDlg::closeFileSelector ( )
455{ 455{
456 m_tb_menu-> show ( ); 456 m_tb_menu-> show ( );
457 m_tb_tool-> show ( ); 457 m_tb_tool-> show ( );
458 m_stack-> raiseWidget ( m_outdev ); 458 m_stack-> raiseWidget ( m_outdev );
459} 459}
460 460
461void QPdfDlg::openFile ( ) 461void QPdfDlg::openFile ( )
462{ 462{
463 m_tb_menu-> hide ( ); 463 m_tb_menu-> hide ( );
464 m_tb_tool-> hide ( ); 464 m_tb_tool-> hide ( );
465 m_tb_find-> hide ( ); 465 m_tb_find-> hide ( );
466 m_stack-> raiseWidget ( m_filesel ); 466 m_stack-> raiseWidget ( m_filesel );
467} 467}
468 468
469void QPdfDlg::openFile ( const QString &f ) 469void QPdfDlg::openFile ( const QString &f )
470{ 470{
471 DocLnk nf; 471 DocLnk nf;
472 nf. setType ( "application/pdf" ); 472 nf. setType ( "application/pdf" );
473 nf. setFile ( f ); 473 nf. setFile ( f );
474 QFileInfo fi ( f ); 474 QFileInfo fi ( f );
475 nf. setName ( fi. baseName ( )); 475 nf. setName ( fi. baseName ( ));
476 openFile ( nf ); 476 openFile ( nf );
477} 477}
478 478
479void QPdfDlg::openFile ( const DocLnk &f ) 479void QPdfDlg::openFile ( const DocLnk &f )
480{ 480{
481 QString fn = f. file ( ); 481 QString fn = f. file ( );
482 QFileInfo fi ( fn ); 482 QFileInfo fi ( fn );
483 483
484 if ( fi. exists ( )) { 484 if ( fi. exists ( )) {
485 delete m_doc; 485 delete m_doc;
486 486
487 m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 ); 487 m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 );
488 488
489 if ( m_doc-> isOk ( )) { 489 if ( m_doc-> isOk ( )) {
490 m_currentdoc = f. name ( ); 490 m_currentdoc = f. name ( );
491 int sep = m_currentdoc. findRev ( '/' ); 491 int sep = m_currentdoc. findRev ( '/' );
492 if ( sep > 0 ) 492 if ( sep > 0 )
493 m_currentdoc = m_currentdoc. mid ( sep + 1 ); 493 m_currentdoc = m_currentdoc. mid ( sep + 1 );
494 494
495 m_pages = m_doc-> getNumPages ( ); 495 m_pages = m_doc-> getNumPages ( );
496 m_currentpage = 0; 496 m_currentpage = 0;
497 497
498 QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); 498 QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
499 } 499 }
500 else { 500 else {
501 delete m_doc; 501 delete m_doc;
502 m_doc = 0; 502 m_doc = 0;
503 503
504 m_currentdoc = QString::null; 504 m_currentdoc = QString::null;
505 } 505 }
506 506
507 updateCaption ( ); 507 updateCaption ( );
508 } 508 }
509 else 509 else
510 QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist !" )); 510 QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist!" ));
511} 511}
512 512
513void QPdfDlg::setDocument ( const QString &f ) 513void QPdfDlg::setDocument ( const QString &f )
514{ 514{
515 if ( f. find ( ".desktop", 0, true ) == -1 ) 515 if ( f. find ( ".desktop", 0, true ) == -1 )
516 openFile ( f ); 516 openFile ( f );
517 else 517 else
518 openFile ( DocLnk ( f )); 518 openFile ( DocLnk ( f ));
519 519
520 closeFileSelector ( ); 520 closeFileSelector ( );
521} 521}
522 522
523void QPdfDlg::delayedInit ( ) 523void QPdfDlg::delayedInit ( )
524 { 524 {
525 closeFileSelector ( ); 525 closeFileSelector ( );
526 526
527 m_currentpage = 0; 527 m_currentpage = 0;
528 m_zoom = 0; 528 m_zoom = 0;
529 m_renderok = false; 529 m_renderok = false;
530 530
531 setZoom ( 100 ); 531 setZoom ( 100 );
532 gotoPage ( 1 ); 532 gotoPage ( 1 );
533 533
534 m_renderok = true; 534 m_renderok = true;
535 535
536 renderPage ( ); 536 renderPage ( );
537 537
538 m_outdev-> setFocus ( ); 538 m_outdev-> setFocus ( );
539} 539}
540 540