summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-06 15:36:15 (UTC)
committer alwin <alwin>2004-04-06 15:36:15 (UTC)
commita0f97fe74df5e6ec3ceea771380a3c61acb2f96c (patch) (unidiff)
tree1d0819d5ffdf9f212829c35db579695bfe0b4b11
parent9273c064f2ae699885ddef32155df4f5aab9d574 (diff)
downloadopie-a0f97fe74df5e6ec3ceea771380a3c61acb2f96c.zip
opie-a0f97fe74df5e6ec3ceea771380a3c61acb2f96c.tar.gz
opie-a0f97fe74df5e6ec3ceea771380a3c61acb2f96c.tar.bz2
added keyboard handler for info window
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.cpp57
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.h23
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp16
3 files changed, 85 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
index 74a9ea4..039dfa3 100644
--- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
@@ -1,146 +1,197 @@
1#include "imageinfoui.h" 1#include "imageinfoui.h"
2 2
3#include <qframe.h> 3#include <qframe.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qtextview.h> 6#include <qtextview.h>
7#include <qlayout.h> 7#include <qlayout.h>
8#include <qvariant.h> 8#include <qvariant.h>
9#include <qtooltip.h> 9#include <qtooltip.h>
10#include <qwhatsthis.h> 10#include <qwhatsthis.h>
11#include <qimage.h> 11#include <qimage.h>
12#include <qpixmap.h> 12#include <qpixmap.h>
13#include <qstring.h> 13#include <qstring.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15 15
16#include <lib/slavemaster.h> 16#include "lib/slavemaster.h"
17#include <lib/imagecache.h> 17#include "lib/imagecache.h"
18
19#include <opie2/oconfig.h>
20#include <opie2/oconfig.h>
21#include <opie2/okeyconfigwidget.h>
22#include <opie2/odebug.h>
18 23
19#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
20#include <qpe/resource.h> 25#include <qpe/resource.h>
21 26
22static const int THUMBSIZE = 128; 27static const int THUMBSIZE = 128;
23 28
29using namespace Opie::Core;
24 30
25imageinfo::imageinfo(QWidget* parent, const char* name, WFlags fl ) 31imageinfo::imageinfo(QWidget* parent, const char* name, WFlags fl )
26 : QWidget( parent, name, fl ) 32 : QWidget( parent, name, fl )
27{ 33{
34 m_viewManager = 0;
28 init(name); 35 init(name);
36 initKeys();
29} 37}
30 38
31imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) 39imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl )
32 : QWidget( parent, name, fl ),currentFile(_path) 40 : QWidget( parent, name, fl ),currentFile(_path)
33{ 41{
42 m_viewManager = 0;
34 init(name); 43 init(name);
44 initKeys();
35 slotChangeName(_path); 45 slotChangeName(_path);
36} 46}
47
48Opie::Ui::OKeyConfigManager* imageinfo::manager()
49{
50 if (!m_viewManager) {
51 initKeys();
52 }
53 return m_viewManager;
54}
55
56void imageinfo::initKeys()
57{
58 odebug << "init imageinfo keys" << oendl;
59 m_cfg = new Opie::Core::OConfig("phunkview");
60 m_cfg->setGroup("Zecke_view" );
61 Opie::Ui::OKeyPair::List lst;
62 lst.append( Opie::Ui::OKeyPair::upArrowKey() );
63 lst.append( Opie::Ui::OKeyPair::downArrowKey() );
64 lst.append( Opie::Ui::OKeyPair::leftArrowKey() );
65 lst.append( Opie::Ui::OKeyPair::rightArrowKey() );
66// lst.append( Opie::Ui::OKeyPair::returnKey() );
67
68 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "Imageinfo-KeyBoard-Config",
69 lst, false,this, "keyconfig name" );
70 m_viewManager->addKeyConfig( Opie::Ui::OKeyConfigItem(tr("View Full Image"), "view",
71 Resource::loadPixmap("1to1"), ViewItem,
72 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
73 this, SLOT(slotShowImage())));
74 m_viewManager->load();
75 m_viewManager->handleWidget( this );
76 m_viewManager->handleWidget( TextView1 );
77}
78
79void imageinfo::slotShowImage()
80{
81 emit dispImage(currentFile);
82}
83
37void imageinfo::init(const char* name) { 84void imageinfo::init(const char* name) {
38 { 85 {
39 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 86 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
40 } 87 }
41 if ( !name ) 88 if ( !name )
42 setName( "imageinfo" ); 89 setName( "imageinfo" );
43 resize( 289, 335 ); 90 resize( 289, 335 );
44 setCaption( tr( "Image info" ) ); 91 setCaption( tr( "Image info" ) );
45 imageinfoLayout = new QVBoxLayout( this ); 92 imageinfoLayout = new QVBoxLayout( this );
46 imageinfoLayout->setSpacing(2); 93 imageinfoLayout->setSpacing(2);
47 imageinfoLayout->setMargin(4); 94 imageinfoLayout->setMargin(4);
48 95
49 PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); 96 PixmapLabel1 = new QLabel( this, "PixmapLabel1" );
50 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); 97 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) );
51 QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); 98 QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") );
52 99
53 imageinfoLayout->addWidget( PixmapLabel1 ); 100 imageinfoLayout->addWidget( PixmapLabel1 );
54 101
55 Line1 = new QFrame( this, "Line1" ); 102 Line1 = new QFrame( this, "Line1" );
56 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 103 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
57 imageinfoLayout->addWidget( Line1 ); 104 imageinfoLayout->addWidget( Line1 );
58 105
59 fnameLabel = new QLabel( this, "FnameLabel" ); 106 fnameLabel = new QLabel( this, "FnameLabel" );
60 imageinfoLayout->addWidget( fnameLabel); 107 imageinfoLayout->addWidget( fnameLabel);
61 108
62 TextView1 = new QTextView( this, "TextView1" ); 109 TextView1 = new QTextView( this, "TextView1" );
63 TextView1->setFrameShadow( QTextView::Sunken ); 110 TextView1->setFrameShadow( QTextView::Sunken );
64 TextView1->setResizePolicy( QTextView::AutoOneFit ); 111 TextView1->setResizePolicy( QTextView::AutoOneFit );
65 TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); 112 TextView1->setBackgroundOrigin( QTextView::ParentOrigin );
66 TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); 113 TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) );
67// TextView1->setVScrollBarMode(QScrollView::AlwaysOn); 114// TextView1->setVScrollBarMode(QScrollView::AlwaysOn);
68 QWhatsThis::add( TextView1, tr("Displays info of selected image") ); 115 QWhatsThis::add( TextView1, tr("Displays info of selected image") );
69 imageinfoLayout->addWidget( TextView1 ); 116 imageinfoLayout->addWidget( TextView1 );
70 117
71 SlaveMaster* master = SlaveMaster::self(); 118 SlaveMaster* master = SlaveMaster::self();
72 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), 119 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
73 this, SLOT(slot_fullInfo(const QString&, const QString&)) ); 120 this, SLOT(slot_fullInfo(const QString&, const QString&)) );
74 connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 121 connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
75 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 122 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
76} 123}
77 124
78void imageinfo::slotChangeName(const QString&_path) 125void imageinfo::slotChangeName(const QString&_path)
79{ 126{
80 currentFile=_path; 127 currentFile=_path;
81 QFileInfo fi(_path); 128 QFileInfo fi(_path);
82 fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); 129 fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>");
83 SlaveMaster::self()->imageInfo( currentFile ); 130 SlaveMaster::self()->imageInfo( currentFile );
84 131
85 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); 132 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE );
86 if (!m_pix) { 133 if (!m_pix) {
87 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); 134 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" )));
88 SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); 135 SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE);
89 } else { 136 } else {
90 PixmapLabel1->setPixmap(*m_pix); 137 PixmapLabel1->setPixmap(*m_pix);
91 } 138 }
92} 139}
93 140
94imageinfo::~imageinfo() 141imageinfo::~imageinfo()
95{ 142{
96 { 143 {
97 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 144 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
98 } 145 }
146 if (m_viewManager) {
147 m_viewManager->save();
148 delete m_viewManager;
149 }
99} 150}
100 151
101void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) 152void imageinfo::slot_fullInfo(const QString&_path, const QString&_t)
102{ 153{
103 if (_path == currentFile) { 154 if (_path == currentFile) {
104 qDebug(_t); 155 qDebug(_t);
105 QString t = _t; 156 QString t = _t;
106 t.replace(QRegExp("\n"),"<br>"); 157 t.replace(QRegExp("\n"),"<br>");
107/* t.replace(QRegeExp("<qt>",""); 158/* t.replace(QRegeExp("<qt>","");
108 t.replace(QRegeExp("</qt>","");*/ 159 t.replace(QRegeExp("</qt>","");*/
109 TextView1->setText(t); 160 TextView1->setText(t);
110 } 161 }
111} 162}
112 163
113void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) 164void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix)
114{ 165{
115 if (_path == currentFile) { 166 if (_path == currentFile) {
116 if (_pix.width()>0) { 167 if (_pix.width()>0) {
117 PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); 168 PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE );
118 PixmapLabel1->setPixmap( _pix ); 169 PixmapLabel1->setPixmap( _pix );
119 PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); 170 PixmapLabel1->resize(QSize(_pix.width(),_pix.height()));
120 } 171 }
121 } 172 }
122} 173}
123 174
124void imageinfo::setPath( const QString& str ) { 175void imageinfo::setPath( const QString& str ) {
125 slotChangeName( str ); 176 slotChangeName( str );
126} 177}
127 178
128void imageinfo::setDestructiveClose() { 179void imageinfo::setDestructiveClose() {
129 WFlags fl = getWFlags(); 180 WFlags fl = getWFlags();
130 /* clear it just in case */ 181 /* clear it just in case */
131 fl &= ~WDestructiveClose; 182 fl &= ~WDestructiveClose;
132 fl |= WDestructiveClose; 183 fl |= WDestructiveClose;
133 setWFlags( fl ); 184 setWFlags( fl );
134} 185}
135 186
136 187
137/* for testing */ 188/* for testing */
138infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) 189infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name)
139 :QDialog(parent,name,true,WStyle_ContextHelp) 190 :QDialog(parent,name,true,WStyle_ContextHelp)
140{ 191{
141 QVBoxLayout*dlglayout = new QVBoxLayout(this); 192 QVBoxLayout*dlglayout = new QVBoxLayout(this);
142 dlglayout->setSpacing(2); 193 dlglayout->setSpacing(2);
143 dlglayout->setMargin(1); 194 dlglayout->setMargin(1);
144 imageinfo*inf = new imageinfo(fname,this); 195 imageinfo*inf = new imageinfo(fname,this);
145 dlglayout->addWidget(inf); 196 dlglayout->addWidget(inf);
146} 197}
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.h b/noncore/graphics/opie-eye/gui/imageinfoui.h
index 300c92a..0a5e183 100644
--- a/noncore/graphics/opie-eye/gui/imageinfoui.h
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.h
@@ -1,58 +1,77 @@
1#ifndef IMAGEINFO_H 1#ifndef IMAGEINFO_H
2#define IMAGEINFO_H 2#define IMAGEINFO_H
3 3
4#include <qvariant.h> 4#include <qvariant.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qdialog.h> 6#include <qdialog.h>
7 7
8class QVBoxLayout; 8class QVBoxLayout;
9class QHBoxLayout; 9class QHBoxLayout;
10class QGridLayout; 10class QGridLayout;
11class QFrame; 11class QFrame;
12class QLabel; 12class QLabel;
13class QTextView; 13class QTextView;
14 14
15namespace Opie {
16 namespace Core {
17 class OConfig;
18 }
19 namespace Ui {
20 class OKeyConfigManager;
21 }
22}
23
15class imageinfo : public QWidget 24class imageinfo : public QWidget
16{ 25{
17 Q_OBJECT 26 Q_OBJECT
27 enum ActionIds {
28 ViewItem
29 };
18 30
19public: 31public:
20 imageinfo( QWidget* parent = 0, const char* name = 0, WFlags fl =0); 32 imageinfo( QWidget* parent = 0, const char* name = 0, WFlags fl =0);
21 imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 33 imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
22 ~imageinfo(); 34 ~imageinfo();
23 35
24 void setDestructiveClose(); 36 void setDestructiveClose();
37 Opie::Ui::OKeyConfigManager* manager();
38
39signals:
40 void dispImage(const QString&);
25 41
26public slots: 42public slots:
27 void setPath( const QString& path ); 43 void setPath( const QString& path );
44 void slotShowImage();
28 45
29private: 46private:
30 void init(const char* name); 47 void init(const char* name);
31 48
32protected: 49protected:
33 QLabel* PixmapLabel1; 50 QLabel* PixmapLabel1;
34 QLabel* fnameLabel; 51 QLabel* fnameLabel;
35 QFrame* Line1; 52 QFrame* Line1;
36 QTextView* TextView1; 53 QTextView* TextView1;
37
38protected:
39 QVBoxLayout* imageinfoLayout; 54 QVBoxLayout* imageinfoLayout;
40 QString currentFile; 55 QString currentFile;
41 56
57 Opie::Core::OConfig * m_cfg;
58 Opie::Ui::OKeyConfigManager*m_viewManager;
59 void initKeys();
60
42protected slots: 61protected slots:
43 virtual void slot_fullInfo(const QString&, const QString&); 62 virtual void slot_fullInfo(const QString&, const QString&);
44 virtual void slotThumbNail(const QString&, const QPixmap&); 63 virtual void slotThumbNail(const QString&, const QPixmap&);
45 64
46 virtual void slotChangeName(const QString&); 65 virtual void slotChangeName(const QString&);
47}; 66};
48 67
49/* for testing purpose */ 68/* for testing purpose */
50class infoDlg:public QDialog 69class infoDlg:public QDialog
51{ 70{
52 Q_OBJECT 71 Q_OBJECT
53public: 72public:
54 infoDlg(const QString&,QWidget * parent=0, const char * name=0); 73 infoDlg(const QString&,QWidget * parent=0, const char * name=0);
55 virtual ~infoDlg(); 74 virtual ~infoDlg();
56}; 75};
57 76
58#endif // IMAGEINFO_H 77#endif // IMAGEINFO_H
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 88acd59..5e94f93 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,268 +1,272 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5#include "mainwindow.h" 5#include "mainwindow.h"
6 6
7#include "iconview.h" 7#include "iconview.h"
8#include "filesystem.h" 8#include "filesystem.h"
9#include "imageinfoui.h" 9#include "imageinfoui.h"
10#include "imagescrollview.h" 10#include "imagescrollview.h"
11 11
12#include <iface/ifaceinfo.h> 12#include <iface/ifaceinfo.h>
13#include <iface/dirview.h> 13#include <iface/dirview.h>
14 14
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <opie2/owidgetstack.h> 16#include <opie2/owidgetstack.h>
17#include <opie2/oapplicationfactory.h> 17#include <opie2/oapplicationfactory.h>
18#include <opie2/otabwidget.h> 18#include <opie2/otabwidget.h>
19#include <opie2/okeyconfigwidget.h> 19#include <opie2/okeyconfigwidget.h>
20 20
21
22#include <qpe/resource.h> 21#include <qpe/resource.h>
23#include <qpe/config.h> 22#include <qpe/config.h>
24#include <qpe/ir.h> 23#include <qpe/ir.h>
25 24
26#include <qtoolbar.h> 25#include <qtoolbar.h>
27#include <qtoolbutton.h> 26#include <qtoolbutton.h>
28#include <qlayout.h> 27#include <qlayout.h>
29#include <qdialog.h> 28#include <qdialog.h>
30#include <qmap.h> 29#include <qmap.h>
31#include <qtimer.h> 30#include <qtimer.h>
32 31
33 32
34 33
35 34
36OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) 35OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
37 36
38PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 37PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
39 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 38 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
40{ 39{
41 setCaption( QObject::tr("Opie Eye Caramba" ) ); 40 setCaption( QObject::tr("Opie Eye Caramba" ) );
42 m_cfg = new Opie::Core::OConfig("phunkview"); 41 m_cfg = new Opie::Core::OConfig("phunkview");
43 m_cfg->setGroup("Zecke_view" ); 42 m_cfg->setGroup("Zecke_view" );
44 43// qDebug( "Process-wide OApplication object @ %0x", oApp );
45
46 /* 44 /*
47 * Initialize ToolBar and IconView 45 * Initialize ToolBar and IconView
48 * And Connect Them 46 * And Connect Them
49 */ 47 */
50 QToolBar *bar = new QToolBar( this ); 48 QToolBar *bar = new QToolBar( this );
51 bar->setHorizontalStretchable( true ); 49 bar->setHorizontalStretchable( true );
52 setToolBarsMovable( false ); 50 setToolBarsMovable( false );
53 51
54 m_stack = new Opie::Ui::OWidgetStack( this ); 52 m_stack = new Opie::Ui::OWidgetStack( this );
55 setCentralWidget( m_stack ); 53 setCentralWidget( m_stack );
56 54
57 m_view = new PIconView( m_stack, m_cfg ); 55 m_view = new PIconView( m_stack, m_cfg );
58 m_stack->addWidget( m_view, IconView ); 56 m_stack->addWidget( m_view, IconView );
59 m_stack->raiseWidget( IconView ); 57 m_stack->raiseWidget( IconView );
60 connect(m_view, SIGNAL(sig_display(const QString&)), 58 connect(m_view, SIGNAL(sig_display(const QString&)),
61 this, SLOT(slotDisplay(const QString&))); 59 this, SLOT(slotDisplay(const QString&)));
62 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 60 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
63 this, SLOT(slotShowInfo(const QString&)) ); 61 this, SLOT(slotShowInfo(const QString&)) );
64 62
65 QToolButton *btn = new QToolButton( bar ); 63 QToolButton *btn = new QToolButton( bar );
66 btn->setIconSet( Resource::loadIconSet( "up" ) ); 64 btn->setIconSet( Resource::loadIconSet( "up" ) );
67 connect( btn, SIGNAL(clicked()), 65 connect( btn, SIGNAL(clicked()),
68 m_view, SLOT(slotDirUp()) ); 66 m_view, SLOT(slotDirUp()) );
69 67
70 btn = new PFileSystem( bar ); 68 btn = new PFileSystem( bar );
71 connect( btn, SIGNAL( changeDir( const QString& ) ), 69 connect( btn, SIGNAL( changeDir( const QString& ) ),
72 m_view, SLOT(slotChangeDir( const QString& ) ) ); 70 m_view, SLOT(slotChangeDir( const QString& ) ) );
73 71
74 btn = new QToolButton( bar ); 72 btn = new QToolButton( bar );
75 btn->setIconSet( Resource::loadIconSet( "edit" ) ); 73 btn->setIconSet( Resource::loadIconSet( "edit" ) );
76 connect( btn, SIGNAL(clicked()), 74 connect( btn, SIGNAL(clicked()),
77 m_view, SLOT(slotRename()) ); 75 m_view, SLOT(slotRename()) );
78 76
79 if ( Ir::supported() ) { 77 if ( Ir::supported() ) {
80 btn = new QToolButton( bar ); 78 btn = new QToolButton( bar );
81 btn->setIconSet( Resource::loadIconSet( "beam" ) ); 79 btn->setIconSet( Resource::loadIconSet( "beam" ) );
82 connect( btn, SIGNAL(clicked()), 80 connect( btn, SIGNAL(clicked()),
83 m_view, SLOT(slotBeam()) ); 81 m_view, SLOT(slotBeam()) );
84 } 82 }
85 83
86 btn = new QToolButton( bar ); 84 btn = new QToolButton( bar );
87 btn->setIconSet( Resource::loadIconSet( "trash" ) ); 85 btn->setIconSet( Resource::loadIconSet( "trash" ) );
88 connect( btn, SIGNAL(clicked() ), 86 connect( btn, SIGNAL(clicked() ),
89 m_view, SLOT(slotTrash() ) ); 87 m_view, SLOT(slotTrash() ) );
90 88
91 btn = new QToolButton( bar ); 89 btn = new QToolButton( bar );
92 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); 90 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
93 connect( btn, SIGNAL(clicked() ), 91 connect( btn, SIGNAL(clicked() ),
94 this, SLOT(slotConfig() ) ); 92 this, SLOT(slotConfig() ) );
95 93
96 rotateButton = new QToolButton(bar); 94 rotateButton = new QToolButton(bar);
97 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); 95 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
98 rotateButton->setToggleButton(true); 96 rotateButton->setToggleButton(true);
99 rotateButton->setOn(true); 97 rotateButton->setOn(true);
100 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 98 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
101 autoRotate = true; 99 autoRotate = true;
102 100
103 btn = new QToolButton(bar); 101 btn = new QToolButton(bar);
104 btn->setIconSet( Resource::loadIconSet( "1to1" ) ); 102 btn->setIconSet( Resource::loadIconSet( "1to1" ) );
105 btn->setToggleButton(true); 103 btn->setToggleButton(true);
106 btn->setOn(false); 104 btn->setOn(false);
107 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 105 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
108 autoScale = true; 106 autoScale = true;
109 107
110} 108}
111 109
112PMainWindow::~PMainWindow() { 110PMainWindow::~PMainWindow() {
113 odebug << "Shutting down" << oendl; 111 odebug << "Shutting down" << oendl;
114} 112}
115 113
116void PMainWindow::slotRotateToggled(bool how) 114void PMainWindow::slotRotateToggled(bool how)
117{ 115{
118 autoRotate = how; 116 autoRotate = how;
119 if (m_disp) { 117 if (m_disp) {
120 m_disp->setAutoRotate(how); 118 m_disp->setAutoRotate(how);
121 } 119 }
122} 120}
123 121
124void PMainWindow::slotScaleToggled(bool how) 122void PMainWindow::slotScaleToggled(bool how)
125{ 123{
126 autoScale = !how; 124 autoScale = !how;
127 if (m_disp) { 125 if (m_disp) {
128 m_disp->setAutoScale(autoScale); 126 m_disp->setAutoScale(autoScale);
129 } 127 }
130 if (!autoScale && autoRotate) { 128 if (!autoScale && autoRotate) {
131 rotateButton->setOn(false); 129 rotateButton->setOn(false);
132 } 130 }
133 rotateButton->setEnabled(!how); 131 rotateButton->setEnabled(!how);
134} 132}
135 133
136void PMainWindow::slotConfig() { 134void PMainWindow::slotConfig() {
137 /* 135 /*
138 * have a tab with the possible views 136 * have a tab with the possible views
139 * a tab for globals image cache size.. scaled loading 137 * a tab for globals image cache size.. scaled loading
140 * and one tab for the KeyConfigs 138 * and one tab for the KeyConfigs
141 */ 139 */
142 QDialog dlg(this, 0, true); 140 QDialog dlg(this, 0, true);
143 dlg.setCaption( tr("Phunk View - Config" ) ); 141 dlg.setCaption( tr("Phunk View - Config" ) );
144 142
145 QHBoxLayout *lay = new QHBoxLayout(&dlg); 143 QHBoxLayout *lay = new QHBoxLayout(&dlg);
146 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 144 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
147 lay->addWidget( wid ); 145 lay->addWidget( wid );
148 ViewMap *vM = viewMap(); 146 ViewMap *vM = viewMap();
149 ViewMap::Iterator _it = vM->begin(); 147 ViewMap::Iterator _it = vM->begin();
150 QMap<PDirView*, QWidget*> lst; 148 QMap<PDirView*, QWidget*> lst;
151 149
152 for( ; _it != vM->end(); ++_it ) { 150 for( ; _it != vM->end(); ++_it ) {
153 PDirView *view = (_it.data())(*m_cfg); 151 PDirView *view = (_it.data())(*m_cfg);
154 PInterfaceInfo *inf = view->interfaceInfo(); 152 PInterfaceInfo *inf = view->interfaceInfo();
155 QWidget *_wid = inf->configWidget( *m_cfg ); 153 QWidget *_wid = inf->configWidget( *m_cfg );
156 _wid->reparent(wid, QPoint() ); 154 _wid->reparent(wid, QPoint() );
157 lst.insert( view, _wid ); 155 lst.insert( view, _wid );
158 wid->addTab( _wid, "fileopen", inf->name() ); 156 wid->addTab( _wid, "fileopen", inf->name() );
159 } 157 }
160 158
161/* 159/*
162 * Add the KeyConfigWidget 160 * Add the KeyConfigWidget
163 */ 161 */
164 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 162 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
165 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 163 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
166 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 164 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
165 if ( !m_info ) {
166 initInfo();
167 }
168 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
167 keyWid->load(); 169 keyWid->load();
168 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 170 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
169 171
170 172
171 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 173 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
172 174
173/* 175/*
174 * clean up 176 * clean up
175 *apply changes 177 *apply changes
176 */ 178 */
177 179
178 QMap<PDirView*, QWidget*>::Iterator it; 180 QMap<PDirView*, QWidget*>::Iterator it;
179 for ( it = lst.begin(); it != lst.end(); ++it ) { 181 for ( it = lst.begin(); it != lst.end(); ++it ) {
180 if ( act ) 182 if ( act )
181 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 183 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
182 delete it.key(); 184 delete it.key();
183 } 185 }
184 186
185 187
186 if ( act ) { 188 if ( act ) {
187 m_view->resetView(); 189 m_view->resetView();
188 keyWid->save(); 190 keyWid->save();
189 } 191 }
190} 192}
191 193
192/* 194/*
193 * create a new image info component 195 * create a new image info component
194 * and detach the current one 196 * and detach the current one
195 * we will make the other delete on exit 197 * we will make the other delete on exit
196 */ 198 */
197template<class T> 199template<class T>
198void PMainWindow::initT( const char* name, T** ptr, int id) { 200void PMainWindow::initT( const char* name, T** ptr, int id) {
199 if ( *ptr ) { 201 if ( *ptr ) {
200 (*ptr)->disconnect(this, SLOT(slotReturn())); 202 (*ptr)->disconnect(this, SLOT(slotReturn()));
201 (*ptr)->setDestructiveClose(); 203 (*ptr)->setDestructiveClose();
202 m_stack->removeWidget( *ptr ); 204 m_stack->removeWidget( *ptr );
203 } 205 }
204 *ptr = new T( m_stack, name ); 206 *ptr = new T( m_stack, name );
205 m_stack->addWidget( *ptr, id ); 207 m_stack->addWidget( *ptr, id );
206 208
207 connect(*ptr, SIGNAL(sig_return()), 209 connect(*ptr, SIGNAL(sig_return()),
208 this,SLOT(slotReturn())); 210 this,SLOT(slotReturn()));
209 211
210} 212}
211void PMainWindow::initInfo() { 213void PMainWindow::initInfo() {
212 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 214 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
215 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
213} 216}
214void PMainWindow::initDisp() { 217void PMainWindow::initDisp() {
215 initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay ); 218 initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay );
216 if (m_disp) { 219 if (m_disp) {
217 m_disp->setAutoScale(autoScale); 220 m_disp->setAutoScale(autoScale);
218 m_disp->setAutoRotate(autoRotate); 221 m_disp->setAutoRotate(autoRotate);
219 } 222 }
220 223
221} 224}
222 225
223/** 226/**
224 * With big Screen the plan could be to 'detach' the image 227 * With big Screen the plan could be to 'detach' the image
225 * window if visible and to create a ne wone 228 * window if visible and to create a ne wone
226 * init* already supports it but I make no use of it for 229 * init* already supports it but I make no use of it for
227 * now. We set filename and raise 230 * now. We set filename and raise
228 * 231 *
229 * ### FIXME and talk to alwin 232 * ### FIXME and talk to alwin
230 */ 233 */
231void PMainWindow::slotShowInfo( const QString& inf ) { 234void PMainWindow::slotShowInfo( const QString& inf ) {
232 if ( !m_info ) 235 if ( !m_info ) {
233 initInfo(); 236 initInfo();
237 }
234 m_info->setPath( inf ); 238 m_info->setPath( inf );
235 m_stack->raiseWidget( ImageInfo ); 239 m_stack->raiseWidget( ImageInfo );
236} 240}
237 241
238void PMainWindow::slotDisplay( const QString& inf ) { 242void PMainWindow::slotDisplay( const QString& inf ) {
239 if ( !m_disp ) { 243 if ( !m_disp ) {
240 initDisp(); 244 initDisp();
241 } 245 }
242 m_disp->setImage( inf ); 246 m_disp->setImage( inf );
243 m_stack->raiseWidget( ImageDisplay ); 247 m_stack->raiseWidget( ImageDisplay );
244} 248}
245 249
246void PMainWindow::slotReturn() { 250void PMainWindow::slotReturn() {
247 raiseIconView(); 251 raiseIconView();
248} 252}
249 253
250 254
251void PMainWindow::closeEvent( QCloseEvent* ev ) { 255void PMainWindow::closeEvent( QCloseEvent* ev ) {
252 /* 256 /*
253 * return from view 257 * return from view
254 * or properly quit 258 * or properly quit
255 */ 259 */
256 if ( m_stack->visibleWidget() == m_info || 260 if ( m_stack->visibleWidget() == m_info ||
257 m_stack->visibleWidget() == m_disp ) { 261 m_stack->visibleWidget() == m_disp ) {
258 raiseIconView(); 262 raiseIconView();
259 ev->ignore(); 263 ev->ignore();
260 return; 264 return;
261 } 265 }
262 ev->accept(); 266 ev->accept();
263 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 267 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
264} 268}
265 269
266void PMainWindow::raiseIconView() { 270void PMainWindow::raiseIconView() {
267 m_stack->raiseWidget( IconView ); 271 m_stack->raiseWidget( IconView );
268} 272}