author | drw <drw> | 2005-05-23 23:25:38 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-23 23:25:38 (UTC) |
commit | 3e2acb4665ddcdb24e0749e3ebfc589313be0065 (patch) (unidiff) | |
tree | b7884a189d1b4928e61d71c1c4b5f908205a3655 | |
parent | 71ecaf241641c2c58b997df56074cf4849e6d6c5 (diff) | |
download | opie-3e2acb4665ddcdb24e0749e3ebfc589313be0065.zip opie-3e2acb4665ddcdb24e0749e3ebfc589313be0065.tar.gz opie-3e2acb4665ddcdb24e0749e3ebfc589313be0065.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/graphics/opie-eye/gui/filesystem.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 38 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 73 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.h | 2 |
7 files changed, 93 insertions, 64 deletions
diff --git a/noncore/graphics/opie-eye/gui/filesystem.cpp b/noncore/graphics/opie-eye/gui/filesystem.cpp index 8efcdf7..d84e9f8 100644 --- a/noncore/graphics/opie-eye/gui/filesystem.cpp +++ b/noncore/graphics/opie-eye/gui/filesystem.cpp | |||
@@ -1,65 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | 8 | ||
9 | #include <qpe/resource.h> | 9 | #include <opie2/oresource.h> |
10 | |||
10 | #include <qpe/storage.h> | 11 | #include <qpe/storage.h> |
11 | 12 | ||
12 | 13 | ||
13 | #include "filesystem.h" | 14 | #include "filesystem.h" |
14 | 15 | ||
15 | PFileSystem::PFileSystem( QToolBar* bar) | 16 | PFileSystem::PFileSystem( QToolBar* bar) |
16 | : QToolButton( bar ) | 17 | : QToolButton( bar ) |
17 | { | 18 | { |
18 | setIconSet( Resource::loadIconSet( "cardmon/pcmcia" ) ); | 19 | setIconSet( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); |
19 | 20 | ||
20 | m_pop = new QPopupMenu( this ); | 21 | m_pop = new QPopupMenu( this ); |
21 | connect( m_pop, SIGNAL( activated( int ) ), | 22 | connect( m_pop, SIGNAL( activated( int ) ), |
22 | this, SLOT(slotSelectDir( int ) ) ); | 23 | this, SLOT(slotSelectDir( int ) ) ); |
23 | 24 | ||
24 | m_storage = new StorageInfo(); | 25 | m_storage = new StorageInfo(); |
25 | connect(m_storage, SIGNAL(disksChanged() ), | 26 | connect(m_storage, SIGNAL(disksChanged() ), |
26 | this, SLOT( changed() ) ); | 27 | this, SLOT( changed() ) ); |
27 | changed(); | 28 | changed(); |
28 | 29 | ||
29 | connect(this,SIGNAL(pressed()),SLOT(slotPopUp())); | 30 | connect(this,SIGNAL(pressed()),SLOT(slotPopUp())); |
30 | } | 31 | } |
31 | 32 | ||
32 | PFileSystem::~PFileSystem() { | 33 | PFileSystem::~PFileSystem() { |
33 | delete m_storage; | 34 | delete m_storage; |
34 | } | 35 | } |
35 | 36 | ||
36 | 37 | ||
37 | void PFileSystem::changed() { | 38 | void PFileSystem::changed() { |
38 | m_pop->clear(); | 39 | m_pop->clear(); |
39 | m_dev.clear(); | 40 | m_dev.clear(); |
40 | 41 | ||
41 | /* home dir, too */ | 42 | /* home dir, too */ |
42 | QString f = getenv( "HOME" ); | 43 | QString f = getenv( "HOME" ); |
43 | if (!f.isEmpty()) { | 44 | if (!f.isEmpty()) { |
44 | m_dev.insert("Home directory",f); | 45 | m_dev.insert("Home directory",f); |
45 | m_pop->insertItem("Home directory"); | 46 | m_pop->insertItem("Home directory"); |
46 | } | 47 | } |
47 | 48 | ||
48 | const QList<FileSystem> &fs = m_storage->fileSystems(); | 49 | const QList<FileSystem> &fs = m_storage->fileSystems(); |
49 | QListIterator<FileSystem> it(fs ); | 50 | QListIterator<FileSystem> it(fs ); |
50 | for ( ; it.current(); ++it ) { | 51 | for ( ; it.current(); ++it ) { |
51 | const QString disk = (*it)->name(); | 52 | const QString disk = (*it)->name(); |
52 | const QString path = (*it)->path(); | 53 | const QString path = (*it)->path(); |
53 | m_dev.insert( disk, path ); | 54 | m_dev.insert( disk, path ); |
54 | m_pop->insertItem( disk ); | 55 | m_pop->insertItem( disk ); |
55 | } | 56 | } |
56 | } | 57 | } |
57 | 58 | ||
58 | void PFileSystem::slotPopUp() { | 59 | void PFileSystem::slotPopUp() { |
59 | m_pop->exec(QCursor::pos()); | 60 | m_pop->exec(QCursor::pos()); |
60 | setDown(false); | 61 | setDown(false); |
61 | } | 62 | } |
62 | 63 | ||
63 | void PFileSystem::slotSelectDir( int id ) { | 64 | void PFileSystem::slotSelectDir( int id ) { |
64 | emit changeDir( m_dev[m_pop->text(id )] ); | 65 | emit changeDir( m_dev[m_pop->text(id )] ); |
65 | } | 66 | } |
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 59091a8..9365932 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,913 +1,914 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "iconview.h" | 6 | #include "iconview.h" |
7 | #include "messagebox.h" | 7 | #include "messagebox.h" |
8 | 8 | ||
9 | #include <lib/imagecache.h> | 9 | #include <lib/imagecache.h> |
10 | #include <gui/imageinfoui.h> | 10 | #include <gui/imageinfoui.h> |
11 | 11 | ||
12 | #include <iface/dirview.h> | 12 | #include <iface/dirview.h> |
13 | #include <iface/dirlister.h> | 13 | #include <iface/dirlister.h> |
14 | 14 | ||
15 | #include <opie2/oconfig.h> | 15 | #include <opie2/oconfig.h> |
16 | #include <opie2/okeyconfigwidget.h> | 16 | #include <opie2/okeyconfigwidget.h> |
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <opie2/oimagescrollview.h> | 18 | #include <opie2/oimagescrollview.h> |
19 | #include <opie2/oresource.h> | ||
19 | 20 | ||
20 | #include <qpe/resource.h> | ||
21 | #include <qpe/qpemessagebox.h> | 21 | #include <qpe/qpemessagebox.h> |
22 | #include <qpe/ir.h> | 22 | #include <qpe/ir.h> |
23 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qhbox.h> | 28 | #include <qhbox.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | #include <qstyle.h> | 34 | #include <qstyle.h> |
35 | 35 | ||
36 | 36 | ||
37 | using Opie::Core::OKeyConfigItem; | 37 | using Opie::Core::OKeyConfigItem; |
38 | 38 | ||
39 | const int PIconView::sMAX_ICON_SIZE = 128; | 39 | const int PIconView::sMAX_ICON_SIZE = 128; |
40 | const int PIconView::sMIN_ICON_SIZE = 12; | 40 | const int PIconView::sMIN_ICON_SIZE = 12; |
41 | const int PIconView::sDEF_ICON_SIZE = 64; | 41 | const int PIconView::sDEF_ICON_SIZE = 64; |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * The Icons, Request Cache and IconViewItem for the IconView | 44 | * The Icons, Request Cache and IconViewItem for the IconView |
45 | */ | 45 | */ |
46 | namespace { | 46 | namespace { |
47 | static QPixmap* _dirPix = 0; | 47 | static QPixmap* _dirPix = 0; |
48 | static QPixmap* _unkPix = 0; | 48 | static QPixmap* _unkPix = 0; |
49 | static QPixmap* _cpyPix = 0; | 49 | static QPixmap* _cpyPix = 0; |
50 | static QPixmap* _emptyPix = 0; | 50 | static QPixmap* _emptyPix = 0; |
51 | class IconViewItem : public QIconViewItem { | 51 | class IconViewItem : public QIconViewItem { |
52 | public: | 52 | public: |
53 | IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); | 53 | IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); |
54 | QPixmap* pixmap()const; | 54 | QPixmap* pixmap()const; |
55 | QString path()const { return m_path; } | 55 | QString path()const { return m_path; } |
56 | bool isDir()const { return m_isDir; } | 56 | bool isDir()const { return m_isDir; } |
57 | void setText( const QString& ); | 57 | void setText( const QString& ); |
58 | bool textOnly()const{return m_textOnly;} | 58 | bool textOnly()const{return m_textOnly;} |
59 | void setTextOnly(bool how){m_textOnly=how;} | 59 | void setTextOnly(bool how){m_textOnly=how;} |
60 | /* just for starting recalc of item rect! */ | 60 | /* just for starting recalc of item rect! */ |
61 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 61 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
62 | /* just for starting recalc of item rect! */ | 62 | /* just for starting recalc of item rect! */ |
63 | virtual void setPixmap( const QPixmap & icon); | 63 | virtual void setPixmap( const QPixmap & icon); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | mutable QPixmap* m_pix; | 66 | mutable QPixmap* m_pix; |
67 | int m_iconsize; | 67 | int m_iconsize; |
68 | void check_pix()const; | 68 | void check_pix()const; |
69 | 69 | ||
70 | private: | 70 | private: |
71 | QString m_path; | 71 | QString m_path; |
72 | bool m_isDir : 1; | 72 | bool m_isDir : 1; |
73 | bool m_noInfo :1; | 73 | bool m_noInfo :1; |
74 | bool m_textOnly:1; | 74 | bool m_textOnly:1; |
75 | bool m_NameOnly:1; | 75 | bool m_NameOnly:1; |
76 | bool m_Pixset:1; | 76 | bool m_Pixset:1; |
77 | }; | 77 | }; |
78 | class TextViewItem : public IconViewItem { | 78 | class TextViewItem : public IconViewItem { |
79 | TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); | 79 | TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); |
80 | QPixmap *pixmap()const; | 80 | QPixmap *pixmap()const; |
81 | void setText( const QString& ); | 81 | void setText( const QString& ); |
82 | }; | 82 | }; |
83 | class ThumbViewItem : public IconViewItem { | 83 | class ThumbViewItem : public IconViewItem { |
84 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); | 84 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); |
85 | QPixmap *pixmap()const; | 85 | QPixmap *pixmap()const; |
86 | void setText( const QString& ); | 86 | void setText( const QString& ); |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | /* | 90 | /* |
91 | * If we request an Image or String | 91 | * If we request an Image or String |
92 | * we add it to the map | 92 | * we add it to the map |
93 | */ | 93 | */ |
94 | static QMap<QString, IconViewItem*> g_stringInf; | 94 | static QMap<QString, IconViewItem*> g_stringInf; |
95 | static QMap<QString, IconViewItem*> g_stringPix; | 95 | static QMap<QString, IconViewItem*> g_stringPix; |
96 | 96 | ||
97 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 97 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
98 | const QString& name, int a_iconsize, bool isDir) | 98 | const QString& name, int a_iconsize, bool isDir) |
99 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 99 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
100 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 100 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
101 | { | 101 | { |
102 | m_iconsize = a_iconsize; | 102 | m_iconsize = a_iconsize; |
103 | if ( isDir ) { | 103 | if ( isDir ) { |
104 | if (!_dirPix ) { | 104 | if (!_dirPix ) { |
105 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 105 | _dirPix = new QPixmap( Opie::Core::OResource::loadPixmap("advancedfm/FileBrowser", Opie::Core::OResource::SmallIcon)); |
106 | } | 106 | } |
107 | } else { | 107 | } else { |
108 | if (!_unkPix ) { | 108 | if (!_unkPix ) { |
109 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 109 | _unkPix = new QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ) ); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | check_pix(); | 112 | check_pix(); |
113 | } | 113 | } |
114 | 114 | ||
115 | inline void IconViewItem::check_pix()const | 115 | inline void IconViewItem::check_pix()const |
116 | { | 116 | { |
117 | if (_dirPix && _dirPix->width()>m_iconsize) { | 117 | if (_dirPix && _dirPix->width()>m_iconsize) { |
118 | QImage Pix = _dirPix->convertToImage(); | 118 | QImage Pix = _dirPix->convertToImage(); |
119 | *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); | 119 | *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); |
120 | } | 120 | } |
121 | if (!_cpyPix && _unkPix) { | 121 | if (!_cpyPix && _unkPix) { |
122 | if (_unkPix->width()>=m_iconsize) { | 122 | if (_unkPix->width()>=m_iconsize) { |
123 | QImage Pix = _unkPix->convertToImage(); | 123 | QImage Pix = _unkPix->convertToImage(); |
124 | _cpyPix = new QPixmap(); | 124 | _cpyPix = new QPixmap(); |
125 | if (_unkPix->width()>m_iconsize) { | 125 | if (_unkPix->width()>m_iconsize) { |
126 | *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); | 126 | *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); |
127 | } else { | 127 | } else { |
128 | _cpyPix->convertFromImage(Pix); | 128 | _cpyPix->convertFromImage(Pix); |
129 | } | 129 | } |
130 | 130 | ||
131 | } else { | 131 | } else { |
132 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); | 132 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); |
133 | _cpyPix->fill(); | 133 | _cpyPix->fill(); |
134 | QPainter pa(_cpyPix); | 134 | QPainter pa(_cpyPix); |
135 | int offset = (m_iconsize-_unkPix->width())/2; | 135 | int offset = (m_iconsize-_unkPix->width())/2; |
136 | int offy = (m_iconsize-_unkPix->height())/2; | 136 | int offy = (m_iconsize-_unkPix->height())/2; |
137 | if (offy<0) offy=0; | 137 | if (offy<0) offy=0; |
138 | pa.drawPixmap(offset,offy,*_unkPix); | 138 | pa.drawPixmap(offset,offy,*_unkPix); |
139 | pa.end(); | 139 | pa.end(); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) | 144 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) |
145 | { | 145 | { |
146 | m_Pixset = true; | 146 | m_Pixset = true; |
147 | calcRect(text()); | 147 | calcRect(text()); |
148 | } | 148 | } |
149 | inline void IconViewItem::setPixmap( const QPixmap & ) | 149 | inline void IconViewItem::setPixmap( const QPixmap & ) |
150 | { | 150 | { |
151 | m_Pixset = true; | 151 | m_Pixset = true; |
152 | calcRect(text()); | 152 | calcRect(text()); |
153 | } | 153 | } |
154 | 154 | ||
155 | inline QPixmap* IconViewItem::pixmap()const { | 155 | inline QPixmap* IconViewItem::pixmap()const { |
156 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() | 156 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() |
157 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() | 157 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() |
158 | // << " " << iconView()->contentsY() << oendl; | 158 | // << " " << iconView()->contentsY() << oendl; |
159 | 159 | ||
160 | if (textOnly()&&!m_isDir) { | 160 | if (textOnly()&&!m_isDir) { |
161 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | 161 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); |
162 | return _emptyPix; | 162 | return _emptyPix; |
163 | } | 163 | } |
164 | if ( m_isDir ) | 164 | if ( m_isDir ) |
165 | return _dirPix; | 165 | return _dirPix; |
166 | else{ | 166 | else{ |
167 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 167 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
168 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 168 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
169 | currentView()->dirLister()->imageInfo( m_path ); | 169 | currentView()->dirLister()->imageInfo( m_path ); |
170 | } | 170 | } |
171 | 171 | ||
172 | m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); | 172 | m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); |
173 | if (!m_pix && !g_stringPix.contains( m_path )) { | 173 | if (!m_pix && !g_stringPix.contains( m_path )) { |
174 | check_pix(); | 174 | check_pix(); |
175 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 175 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
176 | currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); | 176 | currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); |
177 | } | 177 | } |
178 | return m_pix ? m_pix : _cpyPix; | 178 | return m_pix ? m_pix : _cpyPix; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | inline void IconViewItem::setText( const QString& str ) { | 181 | inline void IconViewItem::setText( const QString& str ) { |
182 | QString text = QIconViewItem::text()+"\n"+str; | 182 | QString text = QIconViewItem::text()+"\n"+str; |
183 | m_noInfo = true; | 183 | m_noInfo = true; |
184 | QIconViewItem::setText( text ); | 184 | QIconViewItem::setText( text ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | /* | 189 | /* |
190 | * Set up the GUI.. initialize the slave set up gui | 190 | * Set up the GUI.. initialize the slave set up gui |
191 | * and also load a dir | 191 | * and also load a dir |
192 | */ | 192 | */ |
193 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 193 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
194 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 194 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
195 | { | 195 | { |
196 | { | 196 | { |
197 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 197 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
198 | } | 198 | } |
199 | m_path = QDir::homeDirPath(); | 199 | m_path = QDir::homeDirPath(); |
200 | m_mode = 0; | 200 | m_mode = 0; |
201 | m_iconsize = 32; | 201 | m_iconsize = 32; |
202 | m_internalReset = false; | 202 | m_internalReset = false; |
203 | m_customWidget = 0; | 203 | m_customWidget = 0; |
204 | m_setDocCalled = false; | 204 | m_setDocCalled = false; |
205 | 205 | ||
206 | m_hbox = new QHBox( this ); | 206 | m_hbox = new QHBox( this ); |
207 | QLabel* lbl = new QLabel( m_hbox ); | 207 | QLabel* lbl = new QLabel( m_hbox ); |
208 | lbl->setText( tr("View as" ) ); | 208 | lbl->setText( tr("View as" ) ); |
209 | 209 | ||
210 | m_views = new QComboBox( m_hbox, "View As" ); | 210 | m_views = new QComboBox( m_hbox, "View As" ); |
211 | 211 | ||
212 | m_view= new QIconView( this ); | 212 | m_view= new QIconView( this ); |
213 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 213 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
214 | this, SLOT(slotClicked(QIconViewItem*)) ); | 214 | this, SLOT(slotClicked(QIconViewItem*)) ); |
215 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 215 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
216 | this, SLOT(slotClicked(QIconViewItem*)) ); | 216 | this, SLOT(slotClicked(QIconViewItem*)) ); |
217 | 217 | ||
218 | m_view->setArrangement( QIconView::LeftToRight ); | 218 | m_view->setArrangement( QIconView::LeftToRight ); |
219 | 219 | ||
220 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); | 220 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
221 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 221 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
222 | m_view->setItemTextPos( QIconView::Right ); | 222 | m_view->setItemTextPos( QIconView::Right ); |
223 | if (m_mode >1) { | 223 | if (m_mode >1) { |
224 | m_view->setResizeMode(QIconView::Adjust); | 224 | m_view->setResizeMode(QIconView::Adjust); |
225 | } else { | 225 | } else { |
226 | m_view->setResizeMode(QIconView::Fixed); | 226 | m_view->setResizeMode(QIconView::Fixed); |
227 | } | 227 | } |
228 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 228 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
229 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; | 229 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; |
230 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; | 230 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; |
231 | 231 | ||
232 | calculateGrid(); | 232 | calculateGrid(); |
233 | initKeys(); | 233 | initKeys(); |
234 | loadViews(); | 234 | loadViews(); |
235 | } | 235 | } |
236 | 236 | ||
237 | void PIconView::setDoccalled(bool how) | 237 | void PIconView::setDoccalled(bool how) |
238 | { | 238 | { |
239 | m_setDocCalled = how; | 239 | m_setDocCalled = how; |
240 | } | 240 | } |
241 | 241 | ||
242 | /* | 242 | /* |
243 | * Unref the slave and save the keyboard manager | 243 | * Unref the slave and save the keyboard manager |
244 | */ | 244 | */ |
245 | PIconView::~PIconView() { | 245 | PIconView::~PIconView() { |
246 | { | 246 | { |
247 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 247 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
248 | } | 248 | } |
249 | m_viewManager->save(); | 249 | m_viewManager->save(); |
250 | delete m_viewManager; | 250 | delete m_viewManager; |
251 | } | 251 | } |
252 | 252 | ||
253 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 253 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
254 | return m_viewManager; | 254 | return m_viewManager; |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | /* | 258 | /* |
259 | * init the KeyBoard Shortcuts | 259 | * init the KeyBoard Shortcuts |
260 | * called from the c'tor | 260 | * called from the c'tor |
261 | */ | 261 | */ |
262 | void PIconView::initKeys() { | 262 | void PIconView::initKeys() { |
263 | Opie::Core::OKeyPair::List lst; | 263 | Opie::Core::OKeyPair::List lst; |
264 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 264 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
265 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 265 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
266 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 266 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
267 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 267 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
268 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 268 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
269 | 269 | ||
270 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 270 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
271 | lst, false,this, "keyconfig name" ); | 271 | lst, false,this, "keyconfig name" ); |
272 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 272 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
273 | Resource::loadPixmap("beam"), BeamItem, | 273 | Opie::Core::OResource::loadPixmap("beam", Opie::Core::OResource::SmallIcon), |
274 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 274 | BeamItem, Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
275 | this, SLOT(slotBeam())) ); | 275 | this, SLOT(slotBeam())) ); |
276 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 276 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
277 | Resource::loadPixmap("trash"), DeleteItem, | 277 | Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), |
278 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 278 | DeleteItem, Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
279 | this, SLOT(slotTrash())) ); | 279 | this, SLOT(slotTrash())) ); |
280 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 280 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
281 | Resource::loadPixmap("1to1"), ViewItem, | 281 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
282 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 282 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
283 | this, SLOT(slotShowImage()))); | 283 | this, SLOT(slotShowImage()))); |
284 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 284 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
285 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 285 | Opie::Core::OResource::loadPixmap("DocumentTypeWord", Opie::Core::OResource::SmallIcon), |
286 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 286 | InfoItem, Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
287 | this, SLOT(slotImageInfo()) ) ); | 287 | this, SLOT(slotImageInfo()) ) ); |
288 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", | 288 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", |
289 | Resource::loadPixmap("1to1"), SlideItem, | 289 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
290 | Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), | 290 | SlideItem, Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), |
291 | this, SLOT(slotStartSlide()))); | 291 | this, SLOT(slotStartSlide()))); |
292 | m_viewManager->load(); | 292 | m_viewManager->load(); |
293 | m_viewManager->handleWidget( m_view ); | 293 | m_viewManager->handleWidget( m_view ); |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | /* | 297 | /* |
298 | * change one dir up | 298 | * change one dir up |
299 | */ | 299 | */ |
300 | void PIconView::slotDirUp() | 300 | void PIconView::slotDirUp() |
301 | { | 301 | { |
302 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); | 302 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); |
303 | } | 303 | } |
304 | 304 | ||
305 | /* | 305 | /* |
306 | * change the dir | 306 | * change the dir |
307 | */ | 307 | */ |
308 | void PIconView::slotChangeDir(const QString& path) { | 308 | void PIconView::slotChangeDir(const QString& path) { |
309 | if ( !currentView() ) | 309 | if ( !currentView() ) |
310 | return; | 310 | return; |
311 | 311 | ||
312 | PDirLister *lister = currentView()->dirLister(); | 312 | PDirLister *lister = currentView()->dirLister(); |
313 | if (!lister ) | 313 | if (!lister ) |
314 | return; | 314 | return; |
315 | 315 | ||
316 | /* | 316 | /* |
317 | * Say what we want and take what we get | 317 | * Say what we want and take what we get |
318 | */ | 318 | */ |
319 | lister->setStartPath( path ); | 319 | lister->setStartPath( path ); |
320 | m_path = lister->currentPath(); | 320 | m_path = lister->currentPath(); |
321 | 321 | ||
322 | m_view->viewport()->setUpdatesEnabled( false ); | 322 | m_view->viewport()->setUpdatesEnabled( false ); |
323 | m_view->clear(); | 323 | m_view->clear(); |
324 | 324 | ||
325 | // Also invalidate the cache. We can't cancel the operations anyway | 325 | // Also invalidate the cache. We can't cancel the operations anyway |
326 | g_stringPix.clear(); | 326 | g_stringPix.clear(); |
327 | g_stringInf.clear(); | 327 | g_stringInf.clear(); |
328 | 328 | ||
329 | /* | 329 | /* |
330 | * add files and folders | 330 | * add files and folders |
331 | */ | 331 | */ |
332 | addFolders( lister->folders() ); | 332 | addFolders( lister->folders() ); |
333 | addFiles( lister->files() ); | 333 | addFiles( lister->files() ); |
334 | m_view->viewport()->setUpdatesEnabled( true ); | 334 | m_view->viewport()->setUpdatesEnabled( true ); |
335 | 335 | ||
336 | // looks ugly | 336 | // looks ugly |
337 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 337 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
338 | } | 338 | } |
339 | 339 | ||
340 | /** | 340 | /** |
341 | * get the current file name | 341 | * get the current file name |
342 | * @param isDir see if this is a dir or real file | 342 | * @param isDir see if this is a dir or real file |
343 | */ | 343 | */ |
344 | QString PIconView::currentFileName(bool &isDir)const { | 344 | QString PIconView::currentFileName(bool &isDir)const { |
345 | isDir = false; | 345 | isDir = false; |
346 | QIconViewItem* _it = m_view->currentItem(); | 346 | QIconViewItem* _it = m_view->currentItem(); |
347 | if ( !_it ) | 347 | if ( !_it ) |
348 | return QString::null; | 348 | return QString::null; |
349 | 349 | ||
350 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 350 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
351 | isDir = it->isDir(); | 351 | isDir = it->isDir(); |
352 | return it->path(); | 352 | return it->path(); |
353 | } | 353 | } |
354 | 354 | ||
355 | QString PIconView::nextFileName(bool &isDir)const | 355 | QString PIconView::nextFileName(bool &isDir)const |
356 | { | 356 | { |
357 | isDir = false; | 357 | isDir = false; |
358 | QIconViewItem* _it1 = m_view->currentItem(); | 358 | QIconViewItem* _it1 = m_view->currentItem(); |
359 | if ( !_it1 ) | 359 | if ( !_it1 ) |
360 | return QString::null; | 360 | return QString::null; |
361 | QIconViewItem* _it = _it1->nextItem(); | 361 | QIconViewItem* _it = _it1->nextItem(); |
362 | if ( !_it ) | 362 | if ( !_it ) |
363 | return QString::null; | 363 | return QString::null; |
364 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 364 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
365 | isDir = it->isDir(); | 365 | isDir = it->isDir(); |
366 | return it->path(); | 366 | return it->path(); |
367 | } | 367 | } |
368 | 368 | ||
369 | QString PIconView::prevFileName(bool &isDir)const{ | 369 | QString PIconView::prevFileName(bool &isDir)const{ |
370 | isDir = false; | 370 | isDir = false; |
371 | QIconViewItem* _it = m_view->currentItem(); | 371 | QIconViewItem* _it = m_view->currentItem(); |
372 | if ( !_it ) | 372 | if ( !_it ) |
373 | return QString::null; | 373 | return QString::null; |
374 | _it = _it->prevItem(); | 374 | _it = _it->prevItem(); |
375 | if ( !_it ) | 375 | if ( !_it ) |
376 | return QString::null; | 376 | return QString::null; |
377 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 377 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
378 | isDir = it->isDir(); | 378 | isDir = it->isDir(); |
379 | return it->path(); | 379 | return it->path(); |
380 | } | 380 | } |
381 | 381 | ||
382 | void PIconView::slotTrash() { | 382 | void PIconView::slotTrash() { |
383 | bool isDir; | 383 | bool isDir; |
384 | QString pa = currentFileName( isDir ); | 384 | QString pa = currentFileName( isDir ); |
385 | if ( isDir || pa.isEmpty() ) | 385 | if ( isDir || pa.isEmpty() ) |
386 | return; | 386 | return; |
387 | 387 | ||
388 | if (!OMessageBox::confirmDelete( this, tr("the Image"), | 388 | if (!OMessageBox::confirmDelete( this, tr("the Image"), |
389 | pa, tr("Delete Image" ))) | 389 | pa, tr("Delete Image" ))) |
390 | return; | 390 | return; |
391 | 391 | ||
392 | 392 | ||
393 | currentView()->dirLister()->deleteImage( pa ); | 393 | currentView()->dirLister()->deleteImage( pa ); |
394 | delete m_view->currentItem(); | 394 | delete m_view->currentItem(); |
395 | } | 395 | } |
396 | 396 | ||
397 | /* | 397 | /* |
398 | * see what views are available | 398 | * see what views are available |
399 | */ | 399 | */ |
400 | void PIconView::loadViews() { | 400 | void PIconView::loadViews() { |
401 | ViewMap::Iterator it; | 401 | ViewMap::Iterator it; |
402 | ViewMap* map = viewMap(); | 402 | ViewMap* map = viewMap(); |
403 | for ( it = map->begin(); it != map->end(); ++it ) | 403 | for ( it = map->begin(); it != map->end(); ++it ) |
404 | m_views->insertItem( it.key() ); | 404 | m_views->insertItem( it.key() ); |
405 | } | 405 | } |
406 | 406 | ||
407 | void PIconView::resetView() { | 407 | void PIconView::resetView() { |
408 | m_internalReset = true; | 408 | m_internalReset = true; |
409 | // Also invalidate the cache. We can't cancel the operations anyway | 409 | // Also invalidate the cache. We can't cancel the operations anyway |
410 | g_stringPix.clear(); | 410 | g_stringPix.clear(); |
411 | g_stringInf.clear(); | 411 | g_stringInf.clear(); |
412 | if (m_mode>1) { | 412 | if (m_mode>1) { |
413 | int osize = m_iconsize; | 413 | int osize = m_iconsize; |
414 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 414 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
415 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; | 415 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; |
416 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; | 416 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; |
417 | if (osize != m_iconsize) { | 417 | if (osize != m_iconsize) { |
418 | if (_dirPix){ | 418 | if (_dirPix){ |
419 | delete _dirPix; | 419 | delete _dirPix; |
420 | _dirPix = 0; | 420 | _dirPix = 0; |
421 | } | 421 | } |
422 | if (_cpyPix){ | 422 | if (_cpyPix){ |
423 | delete _cpyPix; | 423 | delete _cpyPix; |
424 | _cpyPix = 0; | 424 | _cpyPix = 0; |
425 | } | 425 | } |
426 | calculateGrid(); | 426 | calculateGrid(); |
427 | } | 427 | } |
428 | } else { | 428 | } else { |
429 | m_iconsize = sDEF_ICON_SIZE; | 429 | m_iconsize = sDEF_ICON_SIZE; |
430 | } | 430 | } |
431 | slotViewChanged(m_views->currentItem()); | 431 | slotViewChanged(m_views->currentItem()); |
432 | m_internalReset = false; | 432 | m_internalReset = false; |
433 | } | 433 | } |
434 | 434 | ||
435 | void PIconView::polish() | 435 | void PIconView::polish() |
436 | { | 436 | { |
437 | QVBox::polish(); | 437 | QVBox::polish(); |
438 | 438 | ||
439 | QString lastView = m_cfg->readEntry("LastView",""); | 439 | QString lastView = m_cfg->readEntry("LastView",""); |
440 | int cc=0; | 440 | int cc=0; |
441 | for (; cc<m_views->count();++cc) { | 441 | for (; cc<m_views->count();++cc) { |
442 | if (m_views->text(cc)==lastView) { | 442 | if (m_views->text(cc)==lastView) { |
443 | break; | 443 | break; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | if (cc<m_views->count()) { | 446 | if (cc<m_views->count()) { |
447 | m_views->setCurrentItem(cc); | 447 | m_views->setCurrentItem(cc); |
448 | slotViewChanged(cc); | 448 | slotViewChanged(cc); |
449 | } else { | 449 | } else { |
450 | slotViewChanged(m_views->currentItem()); | 450 | slotViewChanged(m_views->currentItem()); |
451 | } | 451 | } |
452 | connect( m_views, SIGNAL(activated(int)), | 452 | connect( m_views, SIGNAL(activated(int)), |
453 | this, SLOT(slotViewChanged(int)) ); | 453 | this, SLOT(slotViewChanged(int)) ); |
454 | } | 454 | } |
455 | 455 | ||
456 | /* | 456 | /* |
457 | *swicth view reloadDir and connect signals | 457 | *swicth view reloadDir and connect signals |
458 | */ | 458 | */ |
459 | void PIconView::slotViewChanged( int i) { | 459 | void PIconView::slotViewChanged( int i) { |
460 | if (!m_views->count() ) { | 460 | if (!m_views->count() ) { |
461 | setCurrentView( 0l); | 461 | setCurrentView( 0l); |
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | 464 | ||
465 | if (m_customWidget) { | 465 | if (m_customWidget) { |
466 | delete m_customWidget; | 466 | delete m_customWidget; |
467 | m_customWidget = 0; | 467 | m_customWidget = 0; |
468 | } | 468 | } |
469 | PDirView* cur = currentView(); | 469 | PDirView* cur = currentView(); |
470 | if (cur) { | 470 | if (cur) { |
471 | delete cur; | 471 | delete cur; |
472 | } | 472 | } |
473 | QString str = m_views->text(i); | 473 | QString str = m_views->text(i); |
474 | ViewMap* map = viewMap(); | 474 | ViewMap* map = viewMap(); |
475 | if (!map) { | 475 | if (!map) { |
476 | setCurrentView(0l); | 476 | setCurrentView(0l); |
477 | return; | 477 | return; |
478 | } | 478 | } |
479 | 479 | ||
480 | if (map->find(str) == map->end()) { | 480 | if (map->find(str) == map->end()) { |
481 | owarn << "Key not found" << oendl; | 481 | owarn << "Key not found" << oendl; |
482 | setCurrentView(0l); | 482 | setCurrentView(0l); |
483 | return; | 483 | return; |
484 | } | 484 | } |
485 | 485 | ||
486 | m_cfg->writeEntry("LastView",str); | 486 | m_cfg->writeEntry("LastView",str); |
487 | m_cfg->write(); | 487 | m_cfg->write(); |
488 | cur = (*(*map)[str])(*m_cfg); | 488 | cur = (*(*map)[str])(*m_cfg); |
489 | setCurrentView( cur ); | 489 | setCurrentView( cur ); |
490 | m_customWidget = cur->widget(m_hbox); | 490 | m_customWidget = cur->widget(m_hbox); |
491 | if (m_customWidget) { | 491 | if (m_customWidget) { |
492 | odebug << "Got a widget" << oendl; | 492 | odebug << "Got a widget" << oendl; |
493 | m_customWidget->show(); | 493 | m_customWidget->show(); |
494 | } | 494 | } |
495 | 495 | ||
496 | /* connect to the signals of the lister */ | 496 | /* connect to the signals of the lister */ |
497 | PDirLister* lis = cur->dirLister(); | 497 | PDirLister* lis = cur->dirLister(); |
498 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 498 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
499 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 499 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
500 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 500 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
501 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 501 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
502 | connect(lis, SIGNAL(sig_start()), | 502 | connect(lis, SIGNAL(sig_start()), |
503 | this, SLOT(slotStart())); | 503 | this, SLOT(slotStart())); |
504 | connect(lis, SIGNAL(sig_end()) , | 504 | connect(lis, SIGNAL(sig_end()) , |
505 | this, SLOT(slotEnd()) ); | 505 | this, SLOT(slotEnd()) ); |
506 | connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); | 506 | connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); |
507 | 507 | ||
508 | /* reload now with default Path | 508 | /* reload now with default Path |
509 | * but only if it isn't a reset like from setupdlg | 509 | * but only if it isn't a reset like from setupdlg |
510 | */ | 510 | */ |
511 | if (!m_internalReset) { | 511 | if (!m_internalReset) { |
512 | m_path = lis->defaultPath(); | 512 | m_path = lis->defaultPath(); |
513 | } | 513 | } |
514 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 514 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | void PIconView::slotReloadDir() { | 518 | void PIconView::slotReloadDir() { |
519 | slotChangeDir( m_path ); | 519 | slotChangeDir( m_path ); |
520 | } | 520 | } |
521 | 521 | ||
522 | 522 | ||
523 | /* | 523 | /* |
524 | * add files and folders | 524 | * add files and folders |
525 | */ | 525 | */ |
526 | void PIconView::addFolders( const QStringList& lst) { | 526 | void PIconView::addFolders( const QStringList& lst) { |
527 | QStringList::ConstIterator it; | 527 | QStringList::ConstIterator it; |
528 | IconViewItem * _iv; | 528 | IconViewItem * _iv; |
529 | 529 | ||
530 | for(it=lst.begin(); it != lst.end(); ++it ) { | 530 | for(it=lst.begin(); it != lst.end(); ++it ) { |
531 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); | 531 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); |
532 | if (m_mode==3) _iv->setTextOnly(true); | 532 | if (m_mode==3) _iv->setTextOnly(true); |
533 | } | 533 | } |
534 | } | 534 | } |
535 | 535 | ||
536 | void PIconView::addFiles( const QStringList& lst) { | 536 | void PIconView::addFiles( const QStringList& lst) { |
537 | QStringList::ConstIterator it; | 537 | QStringList::ConstIterator it; |
538 | IconViewItem * _iv; | 538 | IconViewItem * _iv; |
539 | QPixmap*m_pix = 0; | 539 | QPixmap*m_pix = 0; |
540 | QString pre = ""; | 540 | QString pre = ""; |
541 | if (!m_path.isEmpty()) { | 541 | if (!m_path.isEmpty()) { |
542 | pre = m_path+"/"; | 542 | pre = m_path+"/"; |
543 | } | 543 | } |
544 | QString s = ""; | 544 | QString s = ""; |
545 | int pos; | 545 | int pos; |
546 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 546 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
547 | s = (*it); | 547 | s = (*it); |
548 | pos = s.find(char(0)); | 548 | pos = s.find(char(0)); |
549 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); | 549 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); |
550 | if (pos>-1) { | 550 | if (pos>-1) { |
551 | _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); | 551 | _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); |
552 | } else { | 552 | } else { |
553 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); | 553 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); |
554 | } | 554 | } |
555 | if (m_mode==3) { | 555 | if (m_mode==3) { |
556 | _iv->setTextOnly(true); | 556 | _iv->setTextOnly(true); |
557 | _iv->setPixmap(QPixmap()); | 557 | _iv->setPixmap(QPixmap()); |
558 | } else { | 558 | } else { |
559 | if (m_pix) _iv->setPixmap(*m_pix); | 559 | if (m_pix) _iv->setPixmap(*m_pix); |
560 | } | 560 | } |
561 | } | 561 | } |
562 | 562 | ||
563 | } | 563 | } |
564 | 564 | ||
565 | /* | 565 | /* |
566 | * user clicked on the item. Change dir or view | 566 | * user clicked on the item. Change dir or view |
567 | */ | 567 | */ |
568 | void PIconView::slotClicked(QIconViewItem* _it) { | 568 | void PIconView::slotClicked(QIconViewItem* _it) { |
569 | if(!_it ) | 569 | if(!_it ) |
570 | return; | 570 | return; |
571 | 571 | ||
572 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 572 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
573 | if( it->isDir() ) | 573 | if( it->isDir() ) |
574 | slotChangeDir( it->path() ); | 574 | slotChangeDir( it->path() ); |
575 | else // view image | 575 | else // view image |
576 | slotShowImage(); | 576 | slotShowImage(); |
577 | } | 577 | } |
578 | 578 | ||
579 | /* | 579 | /* |
580 | * Return was pressed. which is triggered by the keydown | 580 | * Return was pressed. which is triggered by the keydown |
581 | * handler. The problem is that the key up will be handled | 581 | * handler. The problem is that the key up will be handled |
582 | * by the ImageDisplayer and goes to the next image | 582 | * by the ImageDisplayer and goes to the next image |
583 | */ | 583 | */ |
584 | void PIconView::slotRetrun( QIconViewItem *_it ) { | 584 | void PIconView::slotRetrun( QIconViewItem *_it ) { |
585 | if(!_it ) | 585 | if(!_it ) |
586 | return; | 586 | return; |
587 | 587 | ||
588 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 588 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
589 | if( it->isDir() ) | 589 | if( it->isDir() ) |
590 | slotChangeDir( it->path() ); | 590 | slotChangeDir( it->path() ); |
591 | else | 591 | else |
592 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); | 592 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); |
593 | } | 593 | } |
594 | 594 | ||
595 | /* | 595 | /* |
596 | * got thumb info add to the cache if items is visible | 596 | * got thumb info add to the cache if items is visible |
597 | * we later need update after processing of slave is done | 597 | * we later need update after processing of slave is done |
598 | */ | 598 | */ |
599 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 599 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
600 | IconViewItem* item = g_stringInf[_path]; | 600 | IconViewItem* item = g_stringInf[_path]; |
601 | if (!item ) | 601 | if (!item ) |
602 | return; | 602 | return; |
603 | 603 | ||
604 | if (m_mode == 2) { | 604 | if (m_mode == 2) { |
605 | return; | 605 | return; |
606 | } | 606 | } |
607 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 607 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
608 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 608 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
609 | m_updatet = true; | 609 | m_updatet = true; |
610 | 610 | ||
611 | item->setText( str ); | 611 | item->setText( str ); |
612 | g_stringInf.remove( _path ); | 612 | g_stringInf.remove( _path ); |
613 | } | 613 | } |
614 | 614 | ||
615 | /* | 615 | /* |
616 | * got thumbnail and see if it is visible so we need to update later | 616 | * got thumbnail and see if it is visible so we need to update later |
617 | */ | 617 | */ |
618 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 618 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
619 | IconViewItem* item = g_stringPix[_path]; | 619 | IconViewItem* item = g_stringPix[_path]; |
620 | if (!item ) | 620 | if (!item ) |
621 | return; | 621 | return; |
622 | 622 | ||
623 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 623 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
624 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 624 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
625 | m_updatet = true; | 625 | m_updatet = true; |
626 | 626 | ||
627 | if (pix.width()>0) { | 627 | if (pix.width()>0) { |
628 | if (pix.width()<m_iconsize) { | 628 | if (pix.width()<m_iconsize) { |
629 | QPixmap p(m_iconsize,m_iconsize); | 629 | QPixmap p(m_iconsize,m_iconsize); |
630 | p.fill(); | 630 | p.fill(); |
631 | QPainter pa(&p); | 631 | QPainter pa(&p); |
632 | int offset = (m_iconsize-pix.width())/2; | 632 | int offset = (m_iconsize-pix.width())/2; |
633 | int offy = (m_iconsize-pix.height())/2; | 633 | int offy = (m_iconsize-pix.height())/2; |
634 | if (offy<0) offy=0; | 634 | if (offy<0) offy=0; |
635 | pa.drawPixmap(offset,offy,pix); | 635 | pa.drawPixmap(offset,offy,pix); |
636 | pa.end(); | 636 | pa.end(); |
637 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); | 637 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); |
638 | item->setPixmap(p,true); | 638 | item->setPixmap(p,true); |
639 | } else { | 639 | } else { |
640 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); | 640 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); |
641 | item->setPixmap(pix,true); | 641 | item->setPixmap(pix,true); |
642 | } | 642 | } |
643 | 643 | ||
644 | } else { | 644 | } else { |
645 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); | 645 | PPixmapCache::self()->insertImage( _path, Opie::Core::OResource::loadPixmap( "UnknownDocument", |
646 | Opie::Core::OResource::SmallIcon ), m_iconsize, m_iconsize ); | ||
646 | } | 647 | } |
647 | g_stringPix.remove( _path ); | 648 | g_stringPix.remove( _path ); |
648 | m_view->arrangeItemsInGrid(true); | 649 | m_view->arrangeItemsInGrid(true); |
649 | } | 650 | } |
650 | 651 | ||
651 | 652 | ||
652 | /* | 653 | /* |
653 | * FIXME rename | 654 | * FIXME rename |
654 | */ | 655 | */ |
655 | void PIconView::slotRename() { | 656 | void PIconView::slotRename() { |
656 | 657 | ||
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | /* | 661 | /* |
661 | * BEAM the current file | 662 | * BEAM the current file |
662 | */ | 663 | */ |
663 | void PIconView::slotBeam() { | 664 | void PIconView::slotBeam() { |
664 | bool isDir; | 665 | bool isDir; |
665 | QString pa = currentFileName( isDir ); | 666 | QString pa = currentFileName( isDir ); |
666 | if ( isDir && pa.isEmpty() ) | 667 | if ( isDir && pa.isEmpty() ) |
667 | return; | 668 | return; |
668 | 669 | ||
669 | Ir* ir = new Ir( this ); | 670 | Ir* ir = new Ir( this ); |
670 | connect( ir, SIGNAL(done(Ir*)), | 671 | connect( ir, SIGNAL(done(Ir*)), |
671 | this, SLOT(slotBeamDone(Ir*))); | 672 | this, SLOT(slotBeamDone(Ir*))); |
672 | ir->send(pa, tr( "Image" ) ); | 673 | ir->send(pa, tr( "Image" ) ); |
673 | } | 674 | } |
674 | 675 | ||
675 | /* | 676 | /* |
676 | * BEAM done clean up | 677 | * BEAM done clean up |
677 | */ | 678 | */ |
678 | void PIconView::slotBeamDone( Ir* ir) { | 679 | void PIconView::slotBeamDone( Ir* ir) { |
679 | delete ir; | 680 | delete ir; |
680 | } | 681 | } |
681 | 682 | ||
682 | void PIconView::slotStart() { | 683 | void PIconView::slotStart() { |
683 | m_view->viewport()->setUpdatesEnabled( false ); | 684 | m_view->viewport()->setUpdatesEnabled( false ); |
684 | } | 685 | } |
685 | 686 | ||
686 | void PIconView::slotEnd() { | 687 | void PIconView::slotEnd() { |
687 | if ( m_updatet ) | 688 | if ( m_updatet ) |
688 | m_view->arrangeItemsInGrid( ); | 689 | m_view->arrangeItemsInGrid( ); |
689 | m_view->viewport()->setUpdatesEnabled( true ); | 690 | m_view->viewport()->setUpdatesEnabled( true ); |
690 | m_updatet = false; | 691 | m_updatet = false; |
691 | } | 692 | } |
692 | 693 | ||
693 | void PIconView::slotShowLast() | 694 | void PIconView::slotShowLast() |
694 | { | 695 | { |
695 | QIconViewItem* last_it = m_view->lastItem(); | 696 | QIconViewItem* last_it = m_view->lastItem(); |
696 | if (!last_it) return; | 697 | if (!last_it) return; |
697 | m_view->setCurrentItem(last_it); | 698 | m_view->setCurrentItem(last_it); |
698 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); | 699 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); |
699 | bool isDir = it->isDir(); | 700 | bool isDir = it->isDir(); |
700 | QString name = it->path(); | 701 | QString name = it->path(); |
701 | if (!isDir && !name.isEmpty()) { | 702 | if (!isDir && !name.isEmpty()) { |
702 | slotShowImage(name); | 703 | slotShowImage(name); |
703 | return; | 704 | return; |
704 | } | 705 | } |
705 | bool first_loop = true; | 706 | bool first_loop = true; |
706 | while(isDir==true) { | 707 | while(isDir==true) { |
707 | if (!first_loop) { | 708 | if (!first_loop) { |
708 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 709 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
709 | } else { | 710 | } else { |
710 | first_loop = false; | 711 | first_loop = false; |
711 | } | 712 | } |
712 | name = prevFileName(isDir); | 713 | name = prevFileName(isDir); |
713 | } | 714 | } |
714 | 715 | ||
715 | if (name.isEmpty()) return; | 716 | if (name.isEmpty()) return; |
716 | /* if we got a name we have a prev item */ | 717 | /* if we got a name we have a prev item */ |
717 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 718 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
718 | slotShowImage(name); | 719 | slotShowImage(name); |
719 | } | 720 | } |
720 | 721 | ||
721 | bool PIconView::slotShowFirst() | 722 | bool PIconView::slotShowFirst() |
722 | { | 723 | { |
723 | /* stop when reached - otherwise we may get an endless loop */ | 724 | /* stop when reached - otherwise we may get an endless loop */ |
724 | QIconViewItem* first_it = m_view->firstItem(); | 725 | QIconViewItem* first_it = m_view->firstItem(); |
725 | if (!first_it) return false; | 726 | if (!first_it) return false; |
726 | m_view->setCurrentItem(first_it); | 727 | m_view->setCurrentItem(first_it); |
727 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); | 728 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); |
728 | bool isDir = it->isDir(); | 729 | bool isDir = it->isDir(); |
729 | QString name = it->path(); | 730 | QString name = it->path(); |
730 | if (!isDir && !name.isEmpty()) { | 731 | if (!isDir && !name.isEmpty()) { |
731 | slotShowImage(name); | 732 | slotShowImage(name); |
732 | return false; | 733 | return false; |
733 | } | 734 | } |
734 | bool first_loop = true; | 735 | bool first_loop = true; |
735 | while(isDir==true) { | 736 | while(isDir==true) { |
736 | /* if name is empty isDir is false, too. */ | 737 | /* if name is empty isDir is false, too. */ |
737 | if (!first_loop) { | 738 | if (!first_loop) { |
738 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 739 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
739 | } else { | 740 | } else { |
740 | first_loop = false; | 741 | first_loop = false; |
741 | } | 742 | } |
742 | name = nextFileName(isDir); | 743 | name = nextFileName(isDir); |
743 | } | 744 | } |
744 | if (name.isEmpty()) return false; | 745 | if (name.isEmpty()) return false; |
745 | /* if we got a name we have a next item */ | 746 | /* if we got a name we have a next item */ |
746 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 747 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
747 | slotShowImage(name); | 748 | slotShowImage(name); |
748 | return true; | 749 | return true; |
749 | } | 750 | } |
750 | 751 | ||
751 | void PIconView::slotShowNext() | 752 | void PIconView::slotShowNext() |
752 | { | 753 | { |
753 | bool isDir = false; | 754 | bool isDir = false; |
754 | QString name = nextFileName(isDir); | 755 | QString name = nextFileName(isDir); |
755 | while (isDir==true) { | 756 | while (isDir==true) { |
756 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 757 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
757 | name = nextFileName(isDir); | 758 | name = nextFileName(isDir); |
758 | } | 759 | } |
759 | if (name.isEmpty()) { | 760 | if (name.isEmpty()) { |
760 | slotShowFirst(); | 761 | slotShowFirst(); |
761 | return; | 762 | return; |
762 | } | 763 | } |
763 | if (isDir) return; | 764 | if (isDir) return; |
764 | /* if we got a name we have a next item */ | 765 | /* if we got a name we have a next item */ |
765 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 766 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
766 | slotShowImage(name); | 767 | slotShowImage(name); |
767 | } | 768 | } |
768 | 769 | ||
769 | void PIconView::slotShowPrev() | 770 | void PIconView::slotShowPrev() |
770 | { | 771 | { |
771 | bool isDir = false; | 772 | bool isDir = false; |
772 | QString name = prevFileName(isDir); | 773 | QString name = prevFileName(isDir); |
773 | while (isDir==true) { | 774 | while (isDir==true) { |
774 | /* if name is empty isDir is false, too. */ | 775 | /* if name is empty isDir is false, too. */ |
775 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 776 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
776 | name = prevFileName(isDir); | 777 | name = prevFileName(isDir); |
777 | } | 778 | } |
778 | if (name.isEmpty()) { | 779 | if (name.isEmpty()) { |
779 | slotShowLast(); | 780 | slotShowLast(); |
780 | return; | 781 | return; |
781 | } | 782 | } |
782 | if (isDir) return; | 783 | if (isDir) return; |
783 | /* if we got a name we have a prev item */ | 784 | /* if we got a name we have a prev item */ |
784 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 785 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
785 | slotShowImage(name); | 786 | slotShowImage(name); |
786 | } | 787 | } |
787 | 788 | ||
788 | void PIconView::slotShowImage() | 789 | void PIconView::slotShowImage() |
789 | { | 790 | { |
790 | bool isDir = false; | 791 | bool isDir = false; |
791 | QString name = currentFileName(isDir); | 792 | QString name = currentFileName(isDir); |
792 | if (isDir) return; | 793 | if (isDir) return; |
793 | slotShowImage( name ); | 794 | slotShowImage( name ); |
794 | } | 795 | } |
795 | void PIconView::slotShowImage( const QString& name) { | 796 | void PIconView::slotShowImage( const QString& name) { |
796 | PDirLister *lister = currentView()->dirLister(); | 797 | PDirLister *lister = currentView()->dirLister(); |
797 | QString r_name = lister->nameToFname(name); | 798 | QString r_name = lister->nameToFname(name); |
798 | emit sig_display(r_name); | 799 | emit sig_display(r_name); |
799 | } | 800 | } |
800 | 801 | ||
801 | void PIconView::slotStartSlide() { | 802 | void PIconView::slotStartSlide() { |
802 | bool isDir = false; | 803 | bool isDir = false; |
803 | QString name = currentFileName(isDir); | 804 | QString name = currentFileName(isDir); |
804 | if (isDir) { | 805 | if (isDir) { |
805 | if (!slotShowFirst()) | 806 | if (!slotShowFirst()) |
806 | return; | 807 | return; |
807 | } else { | 808 | } else { |
808 | slotShowImage( name ); | 809 | slotShowImage( name ); |
809 | } | 810 | } |
810 | int t = m_cfg->readNumEntry("slideshowtimeout", 2); | 811 | int t = m_cfg->readNumEntry("slideshowtimeout", 2); |
811 | emit sig_startslide(t); | 812 | emit sig_startslide(t); |
812 | } | 813 | } |
813 | 814 | ||
814 | void PIconView::slotImageInfo() { | 815 | void PIconView::slotImageInfo() { |
815 | bool isDir = false; | 816 | bool isDir = false; |
816 | QString name = currentFileName(isDir); | 817 | QString name = currentFileName(isDir); |
817 | if (isDir) return; | 818 | if (isDir) return; |
818 | slotImageInfo( name ); | 819 | slotImageInfo( name ); |
819 | } | 820 | } |
820 | 821 | ||
821 | void PIconView::slotImageInfo( const QString& name) { | 822 | void PIconView::slotImageInfo( const QString& name) { |
822 | PDirLister *lister = currentView()->dirLister(); | 823 | PDirLister *lister = currentView()->dirLister(); |
823 | QString r_name = lister->nameToFname(name); | 824 | QString r_name = lister->nameToFname(name); |
824 | emit sig_showInfo(r_name ); | 825 | emit sig_showInfo(r_name ); |
825 | } | 826 | } |
826 | 827 | ||
827 | 828 | ||
828 | void PIconView::slotChangeMode( int mode ) { | 829 | void PIconView::slotChangeMode( int mode ) { |
829 | if ( mode >= 1 && mode <= 3 ) { | 830 | if ( mode >= 1 && mode <= 3 ) { |
830 | m_mode = mode; | 831 | m_mode = mode; |
831 | m_cfg->writeEntry("ListViewMode", m_mode); | 832 | m_cfg->writeEntry("ListViewMode", m_mode); |
832 | /* performance! */ | 833 | /* performance! */ |
833 | m_view->clear(); | 834 | m_view->clear(); |
834 | if (m_mode >1) { | 835 | if (m_mode >1) { |
835 | m_view->setResizeMode(QIconView::Adjust); | 836 | m_view->setResizeMode(QIconView::Adjust); |
836 | } else { | 837 | } else { |
837 | m_view->setResizeMode(QIconView::Fixed); | 838 | m_view->setResizeMode(QIconView::Fixed); |
838 | } | 839 | } |
839 | if (m_mode==1) { | 840 | if (m_mode==1) { |
840 | m_iconsize = sDEF_ICON_SIZE; | 841 | m_iconsize = sDEF_ICON_SIZE; |
841 | } else { | 842 | } else { |
842 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 843 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
843 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; | 844 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; |
844 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; | 845 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; |
845 | } | 846 | } |
846 | if (_dirPix){ | 847 | if (_dirPix){ |
847 | delete _dirPix; | 848 | delete _dirPix; |
848 | _dirPix = 0; | 849 | _dirPix = 0; |
849 | } | 850 | } |
850 | if (_cpyPix){ | 851 | if (_cpyPix){ |
851 | delete _cpyPix; | 852 | delete _cpyPix; |
852 | _cpyPix = 0; | 853 | _cpyPix = 0; |
853 | } | 854 | } |
854 | calculateGrid(); | 855 | calculateGrid(); |
855 | slotReloadDir(); | 856 | slotReloadDir(); |
856 | } | 857 | } |
857 | } | 858 | } |
858 | 859 | ||
859 | 860 | ||
860 | void PIconView::resizeEvent( QResizeEvent* re ) { | 861 | void PIconView::resizeEvent( QResizeEvent* re ) { |
861 | calculateGrid(re); | 862 | calculateGrid(re); |
862 | QVBox::resizeEvent( re ); | 863 | QVBox::resizeEvent( re ); |
863 | //calculateGrid(); | 864 | //calculateGrid(); |
864 | } | 865 | } |
865 | 866 | ||
866 | 867 | ||
867 | void PIconView::calculateGrid(QResizeEvent* re) | 868 | void PIconView::calculateGrid(QResizeEvent* re) |
868 | { | 869 | { |
869 | int viewerWidth; | 870 | int viewerWidth; |
870 | if (re) { | 871 | if (re) { |
871 | viewerWidth=re->size().width(); | 872 | viewerWidth=re->size().width(); |
872 | } else { | 873 | } else { |
873 | int dw = QApplication::desktop()->width(); | 874 | int dw = QApplication::desktop()->width(); |
874 | viewerWidth = dw-style().scrollBarExtent().width(); | 875 | viewerWidth = dw-style().scrollBarExtent().width(); |
875 | } | 876 | } |
876 | 877 | ||
877 | QIconView::ItemTextPos pos; | 878 | QIconView::ItemTextPos pos; |
878 | switch( m_mode ) { | 879 | switch( m_mode ) { |
879 | case 2: | 880 | case 2: |
880 | pos = QIconView::Bottom; | 881 | pos = QIconView::Bottom; |
881 | break; | 882 | break; |
882 | case 3: | 883 | case 3: |
883 | case 1: | 884 | case 1: |
884 | default: | 885 | default: |
885 | pos = QIconView::Right; | 886 | pos = QIconView::Right; |
886 | break; | 887 | break; |
887 | } | 888 | } |
888 | int cache = 0; | 889 | int cache = 0; |
889 | m_view->setItemTextPos( pos ); | 890 | m_view->setItemTextPos( pos ); |
890 | switch (m_mode) { | 891 | switch (m_mode) { |
891 | case 2: | 892 | case 2: |
892 | m_view->setSpacing(2); | 893 | m_view->setSpacing(2); |
893 | m_view->setGridX(m_iconsize); | 894 | m_view->setGridX(m_iconsize); |
894 | m_view->setGridY(-1); | 895 | m_view->setGridY(-1); |
895 | cache = (int)((double)sDEF_ICON_SIZE/(double)m_iconsize*80.0); | 896 | cache = (int)((double)sDEF_ICON_SIZE/(double)m_iconsize*80.0); |
896 | odebug << "cache size: " << cache << oendl; | 897 | odebug << "cache size: " << cache << oendl; |
897 | PPixmapCache::self()->setMaxImages(cache); | 898 | PPixmapCache::self()->setMaxImages(cache); |
898 | break; | 899 | break; |
899 | case 3: | 900 | case 3: |
900 | m_view->setSpacing(10); | 901 | m_view->setSpacing(10); |
901 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 902 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
902 | m_view->setGridY(8); | 903 | m_view->setGridY(8); |
903 | PPixmapCache::self()->setMaxImages(2); | 904 | PPixmapCache::self()->setMaxImages(2); |
904 | break; | 905 | break; |
905 | case 1: | 906 | case 1: |
906 | default: | 907 | default: |
907 | m_view->setSpacing(10); | 908 | m_view->setSpacing(10); |
908 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 909 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
909 | m_view->setGridY( fontMetrics().height()*2+40 ); | 910 | m_view->setGridY( fontMetrics().height()*2+40 ); |
910 | PPixmapCache::self()->setMaxImages(20); | 911 | PPixmapCache::self()->setMaxImages(20); |
911 | break; | 912 | break; |
912 | } | 913 | } |
913 | } | 914 | } |
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp index 7afb62d..8f70602 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp +++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp | |||
@@ -1,204 +1,204 @@ | |||
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 | 18 | ||
19 | #include <opie2/oconfig.h> | 19 | #include <opie2/oconfig.h> |
20 | #include <opie2/okeyconfigwidget.h> | 20 | #include <opie2/okeyconfigwidget.h> |
21 | #include <opie2/odebug.h> | 21 | #include <opie2/odebug.h> |
22 | #include <opie2/oresource.h> | ||
22 | 23 | ||
23 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
24 | #include <qpe/resource.h> | ||
25 | 25 | ||
26 | static const int THUMBSIZE = 128; | 26 | static const int THUMBSIZE = 128; |
27 | 27 | ||
28 | using namespace Opie::Core; | 28 | using namespace Opie::Core; |
29 | 29 | ||
30 | imageinfo::imageinfo(Opie::Core::OConfig *cfg,QWidget* parent, const char* name, WFlags fl ) | 30 | imageinfo::imageinfo(Opie::Core::OConfig *cfg,QWidget* parent, const char* name, WFlags fl ) |
31 | : QWidget( parent, name, fl ) | 31 | : QWidget( parent, name, fl ) |
32 | { | 32 | { |
33 | m_viewManager = 0; | 33 | m_viewManager = 0; |
34 | m_cfg = cfg; | 34 | m_cfg = cfg; |
35 | init(name); | 35 | init(name); |
36 | initKeys(); | 36 | initKeys(); |
37 | } | 37 | } |
38 | 38 | ||
39 | imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) | 39 | imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) |
40 | : QWidget( parent, name, fl ),currentFile(_path) | 40 | : QWidget( parent, name, fl ),currentFile(_path) |
41 | { | 41 | { |
42 | m_viewManager = 0; | 42 | m_viewManager = 0; |
43 | m_cfg = 0; | 43 | m_cfg = 0; |
44 | init(name); | 44 | init(name); |
45 | initKeys(); | 45 | initKeys(); |
46 | slotChangeName(_path); | 46 | slotChangeName(_path); |
47 | } | 47 | } |
48 | 48 | ||
49 | Opie::Core::OKeyConfigManager* imageinfo::manager() | 49 | Opie::Core::OKeyConfigManager* imageinfo::manager() |
50 | { | 50 | { |
51 | if (!m_viewManager) { | 51 | if (!m_viewManager) { |
52 | initKeys(); | 52 | initKeys(); |
53 | } | 53 | } |
54 | return m_viewManager; | 54 | return m_viewManager; |
55 | } | 55 | } |
56 | 56 | ||
57 | void imageinfo::initKeys() | 57 | void imageinfo::initKeys() |
58 | { | 58 | { |
59 | #if 0 | 59 | #if 0 |
60 | if (!m_cfg) { | 60 | if (!m_cfg) { |
61 | m_cfg = new Opie::Core::OConfig("phunkview"); | 61 | m_cfg = new Opie::Core::OConfig("phunkview"); |
62 | m_cfg->setGroup("imageinfo_keys" ); | 62 | m_cfg->setGroup("imageinfo_keys" ); |
63 | } | 63 | } |
64 | #endif | 64 | #endif |
65 | Opie::Core::OKeyPair::List lst; | 65 | Opie::Core::OKeyPair::List lst; |
66 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 66 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
67 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 67 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
68 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 68 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
69 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 69 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
70 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 70 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
71 | 71 | ||
72 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "imageinfo_keys", | 72 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "imageinfo_keys", |
73 | lst, false,this, "keyconfig name" ); | 73 | lst, false,this, "keyconfig name" ); |
74 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Full Image"), "infoview", | 74 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Full Image"), "infoview", |
75 | Resource::loadPixmap("1to1"), ViewItem, | 75 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
76 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 76 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
77 | this, SLOT(slotShowImage()))); | 77 | this, SLOT(slotShowImage()))); |
78 | m_viewManager->load(); | 78 | m_viewManager->load(); |
79 | m_viewManager->handleWidget( this ); | 79 | m_viewManager->handleWidget( this ); |
80 | m_viewManager->handleWidget( TextView1 ); | 80 | m_viewManager->handleWidget( TextView1 ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void imageinfo::slotShowImage() | 83 | void imageinfo::slotShowImage() |
84 | { | 84 | { |
85 | emit dispImage(currentFile); | 85 | emit dispImage(currentFile); |
86 | } | 86 | } |
87 | 87 | ||
88 | void imageinfo::init(const char* name) { | 88 | void imageinfo::init(const char* name) { |
89 | { | 89 | { |
90 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 90 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
91 | } | 91 | } |
92 | if ( !name ) | 92 | if ( !name ) |
93 | setName( "imageinfo" ); | 93 | setName( "imageinfo" ); |
94 | resize( 289, 335 ); | 94 | resize( 289, 335 ); |
95 | setCaption( tr( "Image info" ) ); | 95 | setCaption( tr( "Image info" ) ); |
96 | imageinfoLayout = new QVBoxLayout( this ); | 96 | imageinfoLayout = new QVBoxLayout( this ); |
97 | imageinfoLayout->setSpacing(2); | 97 | imageinfoLayout->setSpacing(2); |
98 | imageinfoLayout->setMargin(4); | 98 | imageinfoLayout->setMargin(4); |
99 | 99 | ||
100 | PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); | 100 | PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); |
101 | PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); | 101 | PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); |
102 | QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); | 102 | QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); |
103 | 103 | ||
104 | imageinfoLayout->addWidget( PixmapLabel1 ); | 104 | imageinfoLayout->addWidget( PixmapLabel1 ); |
105 | 105 | ||
106 | Line1 = new QFrame( this, "Line1" ); | 106 | Line1 = new QFrame( this, "Line1" ); |
107 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 107 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
108 | imageinfoLayout->addWidget( Line1 ); | 108 | imageinfoLayout->addWidget( Line1 ); |
109 | 109 | ||
110 | fnameLabel = new QLabel( this, "FnameLabel" ); | 110 | fnameLabel = new QLabel( this, "FnameLabel" ); |
111 | imageinfoLayout->addWidget( fnameLabel); | 111 | imageinfoLayout->addWidget( fnameLabel); |
112 | 112 | ||
113 | TextView1 = new QTextView( this, "TextView1" ); | 113 | TextView1 = new QTextView( this, "TextView1" ); |
114 | TextView1->setFrameShadow( QTextView::Sunken ); | 114 | TextView1->setFrameShadow( QTextView::Sunken ); |
115 | TextView1->setResizePolicy( QTextView::AutoOneFit ); | 115 | TextView1->setResizePolicy( QTextView::AutoOneFit ); |
116 | TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); | 116 | TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); |
117 | TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); | 117 | TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); |
118 | // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); | 118 | // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); |
119 | QWhatsThis::add( TextView1, tr("Displays info of selected image") ); | 119 | QWhatsThis::add( TextView1, tr("Displays info of selected image") ); |
120 | imageinfoLayout->addWidget( TextView1 ); | 120 | imageinfoLayout->addWidget( TextView1 ); |
121 | 121 | ||
122 | SlaveMaster* master = SlaveMaster::self(); | 122 | SlaveMaster* master = SlaveMaster::self(); |
123 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 123 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
124 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); | 124 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); |
125 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 125 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
126 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 126 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
127 | } | 127 | } |
128 | 128 | ||
129 | void imageinfo::slotChangeName(const QString&_path) | 129 | void imageinfo::slotChangeName(const QString&_path) |
130 | { | 130 | { |
131 | currentFile=_path; | 131 | currentFile=_path; |
132 | QFileInfo fi(_path); | 132 | QFileInfo fi(_path); |
133 | fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); | 133 | fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); |
134 | SlaveMaster::self()->imageInfo( currentFile ); | 134 | SlaveMaster::self()->imageInfo( currentFile ); |
135 | 135 | ||
136 | QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); | 136 | QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); |
137 | if (!m_pix) { | 137 | if (!m_pix) { |
138 | PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); | 138 | PixmapLabel1->setPixmap(QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ))); |
139 | SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); | 139 | SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); |
140 | } else { | 140 | } else { |
141 | PixmapLabel1->setPixmap(*m_pix); | 141 | PixmapLabel1->setPixmap(*m_pix); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | imageinfo::~imageinfo() | 145 | imageinfo::~imageinfo() |
146 | { | 146 | { |
147 | { | 147 | { |
148 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 148 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
149 | } | 149 | } |
150 | if (m_viewManager) { | 150 | if (m_viewManager) { |
151 | delete m_viewManager; | 151 | delete m_viewManager; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) | 155 | void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) |
156 | { | 156 | { |
157 | if (_path == currentFile) { | 157 | if (_path == currentFile) { |
158 | odebug << _t << oendl; | 158 | odebug << _t << oendl; |
159 | QString t = _t; | 159 | QString t = _t; |
160 | t.replace(QRegExp("\n"),"<br>"); | 160 | t.replace(QRegExp("\n"),"<br>"); |
161 | TextView1->setText(t); | 161 | TextView1->setText(t); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) | 165 | void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) |
166 | { | 166 | { |
167 | if (_path == currentFile) { | 167 | if (_path == currentFile) { |
168 | if (_pix.width()>0) { | 168 | if (_pix.width()>0) { |
169 | PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); | 169 | PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); |
170 | PixmapLabel1->setPixmap( _pix ); | 170 | PixmapLabel1->setPixmap( _pix ); |
171 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); | 171 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void imageinfo::setPath( const QString& str ) { | 176 | void imageinfo::setPath( const QString& str ) { |
177 | slotChangeName( str ); | 177 | slotChangeName( str ); |
178 | } | 178 | } |
179 | 179 | ||
180 | void imageinfo::setDestructiveClose() { | 180 | void imageinfo::setDestructiveClose() { |
181 | WFlags fl = getWFlags(); | 181 | WFlags fl = getWFlags(); |
182 | /* clear it just in case */ | 182 | /* clear it just in case */ |
183 | fl &= ~WDestructiveClose; | 183 | fl &= ~WDestructiveClose; |
184 | fl |= WDestructiveClose; | 184 | fl |= WDestructiveClose; |
185 | setWFlags( fl ); | 185 | setWFlags( fl ); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | /* for testing */ | 189 | /* for testing */ |
190 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) | 190 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) |
191 | :QDialog(parent,name,true,WStyle_ContextHelp) | 191 | :QDialog(parent,name,true,WStyle_ContextHelp) |
192 | { | 192 | { |
193 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 193 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
194 | dlglayout->setSpacing(2); | 194 | dlglayout->setSpacing(2); |
195 | dlglayout->setMargin(1); | 195 | dlglayout->setMargin(1); |
196 | imageinfo*inf = new imageinfo(fname,this); | 196 | imageinfo*inf = new imageinfo(fname,this); |
197 | dlglayout->addWidget(inf); | 197 | dlglayout->addWidget(inf); |
198 | } | 198 | } |
199 | 199 | ||
200 | infoDlg::~infoDlg() | 200 | infoDlg::~infoDlg() |
201 | { | 201 | { |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index b919ca8..cda1a96 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,318 +1,318 @@ | |||
1 | #include "imageview.h" | 1 | #include "imageview.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | 3 | #include <opie2/odebug.h> |
4 | #include <opie2/oconfig.h> | 4 | #include <opie2/oconfig.h> |
5 | #include <opie2/okeyconfigwidget.h> | 5 | #include <opie2/okeyconfigwidget.h> |
6 | #include <opie2/oresource.h> | ||
6 | 7 | ||
7 | #include <qpe/resource.h> | ||
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/qcopenvelope_qws.h> | 9 | #include <qpe/qcopenvelope_qws.h> |
10 | 10 | ||
11 | #include <qpopupmenu.h> | 11 | #include <qpopupmenu.h> |
12 | #include <qtimer.h> | 12 | #include <qtimer.h> |
13 | #include <qaction.h> | 13 | #include <qaction.h> |
14 | 14 | ||
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | ||
17 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 17 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
18 | : Opie::MM::OImageScrollView(parent,name,fl) | 18 | : Opie::MM::OImageScrollView(parent,name,fl) |
19 | { | 19 | { |
20 | m_viewManager = 0; | 20 | m_viewManager = 0; |
21 | focus_in_count = 0; | 21 | focus_in_count = 0; |
22 | m_cfg = cfg; | 22 | m_cfg = cfg; |
23 | m_isFullScreen = false; | 23 | m_isFullScreen = false; |
24 | m_ignore_next_in = false; | 24 | m_ignore_next_in = false; |
25 | m_slideTimer = 0; | 25 | m_slideTimer = 0; |
26 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); | 26 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); |
27 | initKeys(); | 27 | initKeys(); |
28 | m_slideValue = 5; | 28 | m_slideValue = 5; |
29 | m_gDisplayType = 0; | 29 | m_gDisplayType = 0; |
30 | m_gPrevNext = 0; | 30 | m_gPrevNext = 0; |
31 | m_hGroup = 0; | 31 | m_hGroup = 0; |
32 | m_gBright = 0; | 32 | m_gBright = 0; |
33 | m_Rotated = false; | 33 | m_Rotated = false; |
34 | closeIfHide = false; | 34 | closeIfHide = false; |
35 | int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? | 35 | int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? |
36 | QApplication::desktop()->size().height():QApplication::desktop()->size().width(); | 36 | QApplication::desktop()->size().height():QApplication::desktop()->size().width(); |
37 | if (min>320) { | 37 | if (min>320) { |
38 | // bigscreen | 38 | // bigscreen |
39 | setMinimumSize(min/3,min/3); | 39 | setMinimumSize(min/3,min/3); |
40 | } else { | 40 | } else { |
41 | setMinimumSize(10,10); | 41 | setMinimumSize(10,10); |
42 | } | 42 | } |
43 | connect(this,SIGNAL(incBrightness()),this,SLOT(slotIncBrightness())); | 43 | connect(this,SIGNAL(incBrightness()),this,SLOT(slotIncBrightness())); |
44 | connect(this,SIGNAL(decBrightness()),this,SLOT(slotDecBrightness())); | 44 | connect(this,SIGNAL(decBrightness()),this,SLOT(slotDecBrightness())); |
45 | 45 | ||
46 | m_sysChannel = new QCopChannel( "QPE/System", this ); | 46 | m_sysChannel = new QCopChannel( "QPE/System", this ); |
47 | connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 47 | connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
48 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 48 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
49 | setKeyCompression(true); | 49 | setKeyCompression(true); |
50 | } | 50 | } |
51 | 51 | ||
52 | void ImageView::slotIncBrightness() | 52 | void ImageView::slotIncBrightness() |
53 | { | 53 | { |
54 | int lb = Intensity()+5; | 54 | int lb = Intensity()+5; |
55 | if (lb>100) lb=100; | 55 | if (lb>100) lb=100; |
56 | setIntensity(lb,true); | 56 | setIntensity(lb,true); |
57 | } | 57 | } |
58 | 58 | ||
59 | void ImageView::slotDecBrightness() | 59 | void ImageView::slotDecBrightness() |
60 | { | 60 | { |
61 | int lb = Intensity()-5; | 61 | int lb = Intensity()-5; |
62 | if (lb<-100) lb=-100; | 62 | if (lb<-100) lb=-100; |
63 | setIntensity(lb,true); | 63 | setIntensity(lb,true); |
64 | } | 64 | } |
65 | 65 | ||
66 | void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) | 66 | void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) |
67 | { | 67 | { |
68 | int _newrotation; | 68 | int _newrotation; |
69 | QDataStream stream( data, IO_ReadOnly ); | 69 | QDataStream stream( data, IO_ReadOnly ); |
70 | if ( msg == "setCurrentRotation(int)" ) | 70 | if ( msg == "setCurrentRotation(int)" ) |
71 | { | 71 | { |
72 | stream >> _newrotation; | 72 | stream >> _newrotation; |
73 | if (!fullScreen()) { | 73 | if (!fullScreen()) { |
74 | m_rotation = _newrotation; | 74 | m_rotation = _newrotation; |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup,QActionGroup*brightGroup) | 80 | void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup,QActionGroup*brightGroup) |
81 | { | 81 | { |
82 | m_gDisplayType = disptypeGroup; | 82 | m_gDisplayType = disptypeGroup; |
83 | m_gPrevNext = nextprevGroup; | 83 | m_gPrevNext = nextprevGroup; |
84 | m_hGroup = hGroup; | 84 | m_hGroup = hGroup; |
85 | m_gBright = brightGroup; | 85 | m_gBright = brightGroup; |
86 | } | 86 | } |
87 | 87 | ||
88 | ImageView::~ImageView() | 88 | ImageView::~ImageView() |
89 | { | 89 | { |
90 | odebug << "Destructor imageview" << oendl; | 90 | odebug << "Destructor imageview" << oendl; |
91 | delete m_viewManager; | 91 | delete m_viewManager; |
92 | } | 92 | } |
93 | 93 | ||
94 | Opie::Core::OKeyConfigManager* ImageView::manager() | 94 | Opie::Core::OKeyConfigManager* ImageView::manager() |
95 | { | 95 | { |
96 | if (!m_viewManager) { | 96 | if (!m_viewManager) { |
97 | initKeys(); | 97 | initKeys(); |
98 | } | 98 | } |
99 | return m_viewManager; | 99 | return m_viewManager; |
100 | } | 100 | } |
101 | 101 | ||
102 | void ImageView::startSlide(int value) | 102 | void ImageView::startSlide(int value) |
103 | { | 103 | { |
104 | if (!m_slideTimer) { | 104 | if (!m_slideTimer) { |
105 | m_slideTimer = new QTimer(this); | 105 | m_slideTimer = new QTimer(this); |
106 | } | 106 | } |
107 | m_slideValue=value; | 107 | m_slideValue=value; |
108 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); | 108 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); |
109 | /* this "+1" is one millisecond. with that we can setup a slideshowvalue | 109 | /* this "+1" is one millisecond. with that we can setup a slideshowvalue |
110 | of 0. eg "as fast as possible". | 110 | of 0. eg "as fast as possible". |
111 | */ | 111 | */ |
112 | m_slideTimer->start(m_slideValue*1000+1,true); | 112 | m_slideTimer->start(m_slideValue*1000+1,true); |
113 | } | 113 | } |
114 | 114 | ||
115 | void ImageView::stopSlide() | 115 | void ImageView::stopSlide() |
116 | { | 116 | { |
117 | if (!m_slideTimer) { | 117 | if (!m_slideTimer) { |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | m_slideTimer->stop(); | 120 | m_slideTimer->stop(); |
121 | delete m_slideTimer; | 121 | delete m_slideTimer; |
122 | m_slideTimer = 0; | 122 | m_slideTimer = 0; |
123 | } | 123 | } |
124 | 124 | ||
125 | void ImageView::nextSlide() | 125 | void ImageView::nextSlide() |
126 | { | 126 | { |
127 | if (!m_slideTimer) { | 127 | if (!m_slideTimer) { |
128 | return; | 128 | return; |
129 | } | 129 | } |
130 | #if 0 | 130 | #if 0 |
131 | if (isHidden()) { | 131 | if (isHidden()) { |
132 | delete m_slideTimer; | 132 | delete m_slideTimer; |
133 | m_slideTimer = 0; | 133 | m_slideTimer = 0; |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | #endif | 136 | #endif |
137 | emit dispNext(); | 137 | emit dispNext(); |
138 | m_slideTimer->start(m_slideValue*1000,true); | 138 | m_slideTimer->start(m_slideValue*1000,true); |
139 | } | 139 | } |
140 | void ImageView::initKeys() | 140 | void ImageView::initKeys() |
141 | { | 141 | { |
142 | odebug << "init imageview keys" << oendl; | 142 | odebug << "init imageview keys" << oendl; |
143 | if (!m_cfg) { | 143 | if (!m_cfg) { |
144 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 144 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
145 | m_cfg->setGroup("image_view_keys" ); | 145 | m_cfg->setGroup("image_view_keys" ); |
146 | } | 146 | } |
147 | Opie::Core::OKeyPair::List lst; | 147 | Opie::Core::OKeyPair::List lst; |
148 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 148 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
149 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 149 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
150 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 150 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
151 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 151 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
152 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); | 152 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); |
153 | 153 | ||
154 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 154 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
155 | lst, false,this, "image_view_keys" ); | 155 | lst, false,this, "image_view_keys" ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * Handle KeyEvents when they're pressed. This avoids problems | 158 | * Handle KeyEvents when they're pressed. This avoids problems |
159 | * with 'double next' on Return. | 159 | * with 'double next' on Return. |
160 | * The Return press would switch to this view and the return | 160 | * The Return press would switch to this view and the return |
161 | * release would emit the dispNext Signal. | 161 | * release would emit the dispNext Signal. |
162 | */ | 162 | */ |
163 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); | 163 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); |
164 | 164 | ||
165 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 165 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
166 | Resource::loadPixmap("1to1"), ViewInfo, | 166 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
167 | Opie::Core::OKeyPair(Qt::Key_I,0), | 167 | ViewInfo, Opie::Core::OKeyPair(Qt::Key_I,0), |
168 | this, SLOT(slotShowImageInfo()))); | 168 | this, SLOT(slotShowImageInfo()))); |
169 | 169 | ||
170 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", | 170 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", |
171 | Resource::loadPixmap("rotate"), Autorotate, | 171 | Opie::Core::OResource::loadPixmap("rotate", Opie::Core::OResource::SmallIcon), |
172 | Opie::Core::OKeyPair(Qt::Key_R,0), | 172 | Autorotate, Opie::Core::OKeyPair(Qt::Key_R,0), |
173 | this, SIGNAL(toggleAutorotate()))); | 173 | this, SIGNAL(toggleAutorotate()))); |
174 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", | 174 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", |
175 | Resource::loadPixmap("1to1"), Autoscale, | 175 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
176 | Opie::Core::OKeyPair(Qt::Key_S,0), | 176 | Autoscale, Opie::Core::OKeyPair(Qt::Key_S,0), |
177 | this, SIGNAL(toggleAutoscale()))); | 177 | this, SIGNAL(toggleAutoscale()))); |
178 | 178 | ||
179 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", | 179 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", |
180 | Resource::loadPixmap("forward"), ShowNext, | 180 | Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), |
181 | Opie::Core::OKeyPair(Qt::Key_Return,0), | 181 | ShowNext, Opie::Core::OKeyPair(Qt::Key_Return,0), |
182 | this, SIGNAL(dispNext()))); | 182 | this, SIGNAL(dispNext()))); |
183 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", | 183 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", |
184 | Resource::loadPixmap("back"), ShowPrevious, | 184 | Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), |
185 | Opie::Core::OKeyPair(Qt::Key_P,0), | 185 | ShowPrevious, Opie::Core::OKeyPair(Qt::Key_P,0), |
186 | this, SIGNAL(dispPrev()))); | 186 | this, SIGNAL(dispPrev()))); |
187 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", | 187 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", |
188 | Resource::loadPixmap("fullscreen"), FullScreen, | 188 | Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), |
189 | Opie::Core::OKeyPair(Qt::Key_F,0), | 189 | FullScreen, Opie::Core::OKeyPair(Qt::Key_F,0), |
190 | this, SIGNAL(toggleFullScreen()))); | 190 | this, SIGNAL(toggleFullScreen()))); |
191 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", | 191 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", |
192 | Resource::loadPixmap("mag"), Zoomer, | 192 | Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), |
193 | Opie::Core::OKeyPair(Qt::Key_T,0), | 193 | Zoomer, Opie::Core::OKeyPair(Qt::Key_T,0), |
194 | this, SIGNAL(toggleZoomer()))); | 194 | this, SIGNAL(toggleZoomer()))); |
195 | 195 | ||
196 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness", | 196 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness", |
197 | Resource::loadPixmap("up"), Incbrightness, | 197 | Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon), |
198 | Opie::Core::OKeyPair(Qt::Key_B,0), | 198 | Incbrightness, Opie::Core::OKeyPair(Qt::Key_B,0), |
199 | this, SIGNAL(incBrightness()))); | 199 | this, SIGNAL(incBrightness()))); |
200 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness", | 200 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness", |
201 | Resource::loadPixmap("down"), Decbrightness, | 201 | Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon), |
202 | Opie::Core::OKeyPair(Qt::Key_D,0), | 202 | Decbrightness, Opie::Core::OKeyPair(Qt::Key_D,0), |
203 | this, SIGNAL(decBrightness()))); | 203 | this, SIGNAL(decBrightness()))); |
204 | m_viewManager->handleWidget( this ); | 204 | m_viewManager->handleWidget( this ); |
205 | m_viewManager->load(); | 205 | m_viewManager->load(); |
206 | } | 206 | } |
207 | 207 | ||
208 | void ImageView::keyReleaseEvent(QKeyEvent * e) | 208 | void ImageView::keyReleaseEvent(QKeyEvent * e) |
209 | { | 209 | { |
210 | if (!e || e->state()!=0) { | 210 | if (!e || e->state()!=0) { |
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | if (e->key()==Qt::Key_Escape) { | 213 | if (e->key()==Qt::Key_Escape) { |
214 | if (fullScreen()) { | 214 | if (fullScreen()) { |
215 | emit hideMe(); | 215 | emit hideMe(); |
216 | } | 216 | } |
217 | if (closeIfHide) { | 217 | if (closeIfHide) { |
218 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 218 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | void ImageView::setCloseIfHide(bool how) | 223 | void ImageView::setCloseIfHide(bool how) |
224 | { | 224 | { |
225 | closeIfHide = how; | 225 | closeIfHide = how; |
226 | } | 226 | } |
227 | 227 | ||
228 | void ImageView::slotShowImageInfo() | 228 | void ImageView::slotShowImageInfo() |
229 | { | 229 | { |
230 | emit dispImageInfo(m_lastName); | 230 | emit dispImageInfo(m_lastName); |
231 | } | 231 | } |
232 | 232 | ||
233 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) | 233 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) |
234 | { | 234 | { |
235 | if (e->button()==1) { | 235 | if (e->button()==1) { |
236 | return OImageScrollView::contentsMousePressEvent(e); | 236 | return OImageScrollView::contentsMousePressEvent(e); |
237 | } | 237 | } |
238 | QPopupMenu *m = new QPopupMenu(this); | 238 | QPopupMenu *m = new QPopupMenu(this); |
239 | if (!m) return; | 239 | if (!m) return; |
240 | if (m_hGroup) { | 240 | if (m_hGroup) { |
241 | m_hGroup->addTo(m); | 241 | m_hGroup->addTo(m); |
242 | } | 242 | } |
243 | if (fullScreen()) { | 243 | if (fullScreen()) { |
244 | if (m_gPrevNext) { | 244 | if (m_gPrevNext) { |
245 | m->insertSeparator(); | 245 | m->insertSeparator(); |
246 | m_gPrevNext->addTo(m); | 246 | m_gPrevNext->addTo(m); |
247 | } | 247 | } |
248 | if (m_gDisplayType) { | 248 | if (m_gDisplayType) { |
249 | m->insertSeparator(); | 249 | m->insertSeparator(); |
250 | m_gDisplayType->addTo(m); | 250 | m_gDisplayType->addTo(m); |
251 | } | 251 | } |
252 | if (m_gBright) { | 252 | if (m_gBright) { |
253 | m->insertSeparator(); | 253 | m->insertSeparator(); |
254 | m_gBright->addTo(m); | 254 | m_gBright->addTo(m); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | m->setFocus(); | 257 | m->setFocus(); |
258 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 258 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
259 | if (m_hGroup) { | 259 | if (m_hGroup) { |
260 | m_hGroup->removeFrom(m); | 260 | m_hGroup->removeFrom(m); |
261 | } | 261 | } |
262 | if (m_gPrevNext) { | 262 | if (m_gPrevNext) { |
263 | m_gPrevNext->removeFrom(m); | 263 | m_gPrevNext->removeFrom(m); |
264 | } | 264 | } |
265 | if (m_gDisplayType) { | 265 | if (m_gDisplayType) { |
266 | m_gDisplayType->removeFrom(m); | 266 | m_gDisplayType->removeFrom(m); |
267 | } | 267 | } |
268 | if (m_gBright) { | 268 | if (m_gBright) { |
269 | m_gBright->removeFrom(m); | 269 | m_gBright->removeFrom(m); |
270 | } | 270 | } |
271 | delete m; | 271 | delete m; |
272 | } | 272 | } |
273 | 273 | ||
274 | void ImageView::setFullScreen(bool how,bool force) | 274 | void ImageView::setFullScreen(bool how,bool force) |
275 | { | 275 | { |
276 | m_isFullScreen = how; | 276 | m_isFullScreen = how; |
277 | if (how) { | 277 | if (how) { |
278 | m_ignore_next_in = true; | 278 | m_ignore_next_in = true; |
279 | // setFixedSize(qApp->desktop()->size()); | 279 | // setFixedSize(qApp->desktop()->size()); |
280 | setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); | 280 | setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); |
281 | if (force) showFullScreen(); | 281 | if (force) showFullScreen(); |
282 | } else { | 282 | } else { |
283 | // setMinimumSize(10,10); | 283 | // setMinimumSize(10,10); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void ImageView::focusInEvent(QFocusEvent *) | 287 | void ImageView::focusInEvent(QFocusEvent *) |
288 | { | 288 | { |
289 | // Always do it here, no matter the size. | 289 | // Always do it here, no matter the size. |
290 | //if (fullScreen()) parentWidget()->showNormal(); | 290 | //if (fullScreen()) parentWidget()->showNormal(); |
291 | if (m_ignore_next_in){m_ignore_next_in=false;return;} | 291 | if (m_ignore_next_in){m_ignore_next_in=false;return;} |
292 | if (fullScreen()) enableFullscreen(); | 292 | if (fullScreen()) enableFullscreen(); |
293 | } | 293 | } |
294 | 294 | ||
295 | void ImageView::hide() | 295 | void ImageView::hide() |
296 | { | 296 | { |
297 | if (fullScreen()) { | 297 | if (fullScreen()) { |
298 | m_ignore_next_in = true; | 298 | m_ignore_next_in = true; |
299 | showNormal(); | 299 | showNormal(); |
300 | } | 300 | } |
301 | QWidget::hide(); | 301 | QWidget::hide(); |
302 | } | 302 | } |
303 | void ImageView::enableFullscreen() | 303 | void ImageView::enableFullscreen() |
304 | { | 304 | { |
305 | if (!fullScreen()) return; | 305 | if (!fullScreen()) return; |
306 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} | 306 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} |
307 | 307 | ||
308 | setUpdatesEnabled(false); | 308 | setUpdatesEnabled(false); |
309 | // This is needed because showNormal() forcefully changes the window | 309 | // This is needed because showNormal() forcefully changes the window |
310 | // style to WSTyle_TopLevel. | 310 | // style to WSTyle_TopLevel. |
311 | reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); | 311 | reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); |
312 | // Enable fullscreen. | 312 | // Enable fullscreen. |
313 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus | 313 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus |
314 | * so we must block it here! */ | 314 | * so we must block it here! */ |
315 | m_ignore_next_in = true; | 315 | m_ignore_next_in = true; |
316 | showFullScreen(); | 316 | showFullScreen(); |
317 | setUpdatesEnabled(true); | 317 | setUpdatesEnabled(true); |
318 | } | 318 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 3efbb53..d4c5b42 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -1,840 +1,867 @@ | |||
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 | #include "imageview.h" | 6 | #include "imageview.h" |
7 | 7 | ||
8 | #include "iconview.h" | 8 | #include "iconview.h" |
9 | #include "filesystem.h" | 9 | #include "filesystem.h" |
10 | #include "imageinfoui.h" | 10 | #include "imageinfoui.h" |
11 | #include "viewmodebutton.h" | 11 | #include "viewmodebutton.h" |
12 | #include "basesetup.h" | 12 | #include "basesetup.h" |
13 | 13 | ||
14 | #include <iface/ifaceinfo.h> | 14 | #include <iface/ifaceinfo.h> |
15 | #include <iface/dirview.h> | 15 | #include <iface/dirview.h> |
16 | 16 | ||
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <opie2/owidgetstack.h> | 18 | #include <opie2/owidgetstack.h> |
19 | #include <opie2/oapplicationfactory.h> | 19 | #include <opie2/oapplicationfactory.h> |
20 | #include <opie2/otabwidget.h> | 20 | #include <opie2/otabwidget.h> |
21 | #include <opie2/okeyconfigwidget.h> | 21 | #include <opie2/okeyconfigwidget.h> |
22 | #include <opie2/owait.h> | 22 | #include <opie2/owait.h> |
23 | #include <opie2/oapplication.h> | 23 | #include <opie2/oapplication.h> |
24 | #include <opie2/oresource.h> | ||
24 | 25 | ||
25 | #include <qpe/resource.h> | ||
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
28 | #include <qpe/storage.h> | 28 | #include <qpe/storage.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | 30 | ||
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qdialog.h> | 34 | #include <qdialog.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qframe.h> | 37 | #include <qframe.h> |
38 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
39 | #include <qaction.h> | 39 | #include <qaction.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | 41 | ||
42 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 42 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
43 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 43 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
44 | 44 | ||
45 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 45 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
46 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 46 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
47 | { | 47 | { |
48 | setCaption( QObject::tr("Opie Eye" ) ); | 48 | setCaption( QObject::tr("Opie Eye" ) ); |
49 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 49 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
50 | m_cfg->setGroup("main" ); | 50 | m_cfg->setGroup("main" ); |
51 | readConfig(); | 51 | readConfig(); |
52 | m_setDocCalled = false; | 52 | m_setDocCalled = false; |
53 | m_polishDone = false; | 53 | m_polishDone = false; |
54 | m_SmallWindow = QApplication::desktop()->size().width()<330; | 54 | m_SmallWindow = QApplication::desktop()->size().width()<330; |
55 | 55 | ||
56 | m_storage = new StorageInfo(); | 56 | m_storage = new StorageInfo(); |
57 | connect(m_storage, SIGNAL(disksChanged() ), | 57 | connect(m_storage, SIGNAL(disksChanged() ), |
58 | this, SLOT( dirChanged() ) ); | 58 | this, SLOT( dirChanged() ) ); |
59 | 59 | ||
60 | m_stack = new Opie::Ui::OWidgetStack( this ); | 60 | m_stack = new Opie::Ui::OWidgetStack( this ); |
61 | setCentralWidget( m_stack ); | 61 | setCentralWidget( m_stack ); |
62 | 62 | ||
63 | m_view = new PIconView( m_stack, m_cfg ); | 63 | m_view = new PIconView( m_stack, m_cfg ); |
64 | m_stack->addWidget( m_view, IconView ); | 64 | m_stack->addWidget( m_view, IconView ); |
65 | m_stack->raiseWidget( IconView ); | 65 | m_stack->raiseWidget( IconView ); |
66 | 66 | ||
67 | connect(m_view, SIGNAL(sig_display(const QString&)), | 67 | connect(m_view, SIGNAL(sig_display(const QString&)), |
68 | this, SLOT(slotDisplay(const QString&))); | 68 | this, SLOT(slotDisplay(const QString&))); |
69 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 69 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
70 | this, SLOT(slotShowInfo(const QString&)) ); | 70 | this, SLOT(slotShowInfo(const QString&)) ); |
71 | connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); | 71 | connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); |
72 | 72 | ||
73 | listviewMenu = 0; | 73 | listviewMenu = 0; |
74 | /* setup menu and toolbar */ | 74 | /* setup menu and toolbar */ |
75 | setupActions(); | 75 | setupActions(); |
76 | setupToolbar(); | 76 | setupToolbar(); |
77 | setupMenu(); | 77 | setupMenu(); |
78 | m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); | 78 | m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); |
79 | m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); | 79 | m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); |
80 | if (m_aForceSmall) { | 80 | if (m_aForceSmall) { |
81 | m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true)); | 81 | m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true)); |
82 | } | 82 | } |
83 | odebug << "mainwindow constructor done" << oendl; | 83 | odebug << "mainwindow constructor done" << oendl; |
84 | } | 84 | } |
85 | 85 | ||
86 | PMainWindow::~PMainWindow() { | 86 | PMainWindow::~PMainWindow() { |
87 | } | 87 | } |
88 | 88 | ||
89 | void PMainWindow::slotToggleZoomer() | 89 | void PMainWindow::slotToggleZoomer() |
90 | { | 90 | { |
91 | m_aZoomer->setOn(!m_aZoomer->isOn()); | 91 | m_aZoomer->setOn(!m_aZoomer->isOn()); |
92 | } | 92 | } |
93 | 93 | ||
94 | void PMainWindow::slotZoomerToggled(bool how) | 94 | void PMainWindow::slotZoomerToggled(bool how) |
95 | { | 95 | { |
96 | if (m_disp) { | 96 | if (m_disp) { |
97 | m_disp->setShowZoomer(how); | 97 | m_disp->setShowZoomer(how); |
98 | } | 98 | } |
99 | if (autoSave) { | 99 | if (autoSave) { |
100 | m_cfg->writeEntry("zoomeron",how); | 100 | m_cfg->writeEntry("zoomeron",how); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | void PMainWindow::slotToggleAutorotate() | 104 | void PMainWindow::slotToggleAutorotate() |
105 | { | 105 | { |
106 | if (!m_aAutoRotate->isEnabled()) return; | 106 | if (!m_aAutoRotate->isEnabled()) return; |
107 | m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); | 107 | m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); |
108 | } | 108 | } |
109 | 109 | ||
110 | void PMainWindow::slotToggleAutoscale() | 110 | void PMainWindow::slotToggleAutoscale() |
111 | { | 111 | { |
112 | m_aUnscaled->setOn(!m_aUnscaled->isOn()); | 112 | m_aUnscaled->setOn(!m_aUnscaled->isOn()); |
113 | } | 113 | } |
114 | 114 | ||
115 | void PMainWindow::slotRotateToggled(bool how) | 115 | void PMainWindow::slotRotateToggled(bool how) |
116 | { | 116 | { |
117 | if (autoSave) { | 117 | if (autoSave) { |
118 | m_cfg->writeEntry("autorotate",how); | 118 | m_cfg->writeEntry("autorotate",how); |
119 | } | 119 | } |
120 | if (m_disp) { | 120 | if (m_disp) { |
121 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); | 121 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | void PMainWindow::slotScaleToggled(bool how) | 125 | void PMainWindow::slotScaleToggled(bool how) |
126 | { | 126 | { |
127 | if (autoSave) { | 127 | if (autoSave) { |
128 | m_cfg->writeEntry("unscaled",how); | 128 | m_cfg->writeEntry("unscaled",how); |
129 | } | 129 | } |
130 | odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; | 130 | odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; |
131 | odebug << "How: " << how << oendl; | 131 | odebug << "How: " << how << oendl; |
132 | if (how) { | 132 | if (how) { |
133 | m_aAutoRotate->setOn(false); | 133 | m_aAutoRotate->setOn(false); |
134 | } | 134 | } |
135 | if (m_disp) { | 135 | if (m_disp) { |
136 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); | 136 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); |
137 | } | 137 | } |
138 | m_aAutoRotate->setEnabled(!how); | 138 | m_aAutoRotate->setEnabled(!how); |
139 | odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; | 139 | odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; |
140 | } | 140 | } |
141 | 141 | ||
142 | void PMainWindow::slotConfig() { | 142 | void PMainWindow::slotConfig() { |
143 | /* | 143 | /* |
144 | * have a tab with the possible views | 144 | * have a tab with the possible views |
145 | * a tab for globals image cache size.. scaled loading | 145 | * a tab for globals image cache size.. scaled loading |
146 | * and one tab for the KeyConfigs | 146 | * and one tab for the KeyConfigs |
147 | */ | 147 | */ |
148 | QDialog dlg(this, 0, true); | 148 | QDialog dlg(this, 0, true); |
149 | dlg.setCaption( tr("Opie Eye - Config" ) ); | 149 | dlg.setCaption( tr("Opie Eye - Config" ) ); |
150 | 150 | ||
151 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 151 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
152 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 152 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
153 | lay->addWidget( wid ); | 153 | lay->addWidget( wid ); |
154 | 154 | ||
155 | BaseSetup*bSetup = new BaseSetup(m_cfg,wid); | 155 | BaseSetup*bSetup = new BaseSetup(m_cfg,wid); |
156 | wid->addTab(bSetup,"SettingsIcon","Basics setup"); | 156 | wid->addTab(bSetup,"SettingsIcon","Basics setup"); |
157 | 157 | ||
158 | ViewMap *vM = viewMap(); | 158 | ViewMap *vM = viewMap(); |
159 | ViewMap::Iterator _it = vM->begin(); | 159 | ViewMap::Iterator _it = vM->begin(); |
160 | QMap<PDirView*, QWidget*> lst; | 160 | QMap<PDirView*, QWidget*> lst; |
161 | 161 | ||
162 | for( ; _it != vM->end(); ++_it ) { | 162 | for( ; _it != vM->end(); ++_it ) { |
163 | PDirView *view = (_it.data())(*m_cfg); | 163 | PDirView *view = (_it.data())(*m_cfg); |
164 | PInterfaceInfo *inf = view->interfaceInfo(); | 164 | PInterfaceInfo *inf = view->interfaceInfo(); |
165 | QWidget *_wid = inf->configWidget( *m_cfg ); | 165 | QWidget *_wid = inf->configWidget( *m_cfg ); |
166 | if (!_wid) continue; | 166 | if (!_wid) continue; |
167 | _wid->reparent(wid, QPoint() ); | 167 | _wid->reparent(wid, QPoint() ); |
168 | lst.insert( view, _wid ); | 168 | lst.insert( view, _wid ); |
169 | wid->addTab( _wid, "fileopen", inf->name() ); | 169 | wid->addTab( _wid, "fileopen", inf->name() ); |
170 | } | 170 | } |
171 | 171 | ||
172 | /* | 172 | /* |
173 | * Add the KeyConfigWidget | 173 | * Add the KeyConfigWidget |
174 | */ | 174 | */ |
175 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 175 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
176 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 176 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
177 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 177 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
178 | QWidget*w = m_stack->visibleWidget(); | 178 | QWidget*w = m_stack->visibleWidget(); |
179 | 179 | ||
180 | bool reminfo = false; | 180 | bool reminfo = false; |
181 | if ( !m_info ) { | 181 | if ( !m_info ) { |
182 | reminfo = true; | 182 | reminfo = true; |
183 | initInfo(); | 183 | initInfo(); |
184 | m_info->hide(); | 184 | m_info->hide(); |
185 | } | 185 | } |
186 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 186 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
187 | 187 | ||
188 | bool remdisp = false; | 188 | bool remdisp = false; |
189 | if ( !m_disp ) { | 189 | if ( !m_disp ) { |
190 | remdisp = true; | 190 | remdisp = true; |
191 | initDisp(); | 191 | initDisp(); |
192 | m_disp->hide(); | 192 | m_disp->hide(); |
193 | } | 193 | } |
194 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 194 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
195 | 195 | ||
196 | keyWid->load(); | 196 | keyWid->load(); |
197 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 197 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
198 | wid->setCurrentTab(0); | 198 | wid->setCurrentTab(0); |
199 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 199 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
200 | 200 | ||
201 | /* | 201 | /* |
202 | * clean up | 202 | * clean up |
203 | *apply changes | 203 | *apply changes |
204 | */ | 204 | */ |
205 | 205 | ||
206 | QMap<PDirView*, QWidget*>::Iterator it; | 206 | QMap<PDirView*, QWidget*>::Iterator it; |
207 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 207 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
208 | if ( act ) | 208 | if ( act ) |
209 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 209 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
210 | delete it.key(); | 210 | delete it.key(); |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | if ( act ) { | 214 | if ( act ) { |
215 | keyWid->save(); | 215 | keyWid->save(); |
216 | m_disp->manager()->save(); | 216 | m_disp->manager()->save(); |
217 | m_info->manager()->save(); | 217 | m_info->manager()->save(); |
218 | m_view->manager()->save(); | 218 | m_view->manager()->save(); |
219 | bSetup->save_values(); | 219 | bSetup->save_values(); |
220 | m_view->resetView(); | 220 | m_view->resetView(); |
221 | readConfig(); | 221 | readConfig(); |
222 | } | 222 | } |
223 | delete keyWid; | 223 | delete keyWid; |
224 | 224 | ||
225 | m_stack->raiseWidget(w); | 225 | m_stack->raiseWidget(w); |
226 | if (remdisp) { | 226 | if (remdisp) { |
227 | m_disp->hide(); | 227 | m_disp->hide(); |
228 | } | 228 | } |
229 | if (reminfo) { | 229 | if (reminfo) { |
230 | m_info->hide(); | 230 | m_info->hide(); |
231 | } | 231 | } |
232 | if (m_disp) { | 232 | if (m_disp) { |
233 | m_disp->setIntensity(m_Intensity,true); | 233 | m_disp->setIntensity(m_Intensity,true); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | /* | 237 | /* |
238 | * create a new image info component | 238 | * create a new image info component |
239 | * and detach the current one | 239 | * and detach the current one |
240 | * we will make the other delete on exit | 240 | * we will make the other delete on exit |
241 | */ | 241 | */ |
242 | template<class T> | 242 | template<class T> |
243 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 243 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
244 | if ( *ptr ) { | 244 | if ( *ptr ) { |
245 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 245 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
246 | (*ptr)->setDestructiveClose(); | 246 | (*ptr)->setDestructiveClose(); |
247 | m_stack->removeWidget( *ptr ); | 247 | m_stack->removeWidget( *ptr ); |
248 | } | 248 | } |
249 | *ptr = new T(m_cfg, m_stack, name ); | 249 | *ptr = new T(m_cfg, m_stack, name ); |
250 | m_stack->addWidget( *ptr, id ); | 250 | m_stack->addWidget( *ptr, id ); |
251 | 251 | ||
252 | connect(*ptr, SIGNAL(sig_return()), | 252 | connect(*ptr, SIGNAL(sig_return()), |
253 | this,SLOT(slotReturn())); | 253 | this,SLOT(slotReturn())); |
254 | 254 | ||
255 | } | 255 | } |
256 | 256 | ||
257 | void PMainWindow::initInfo() { | 257 | void PMainWindow::initInfo() { |
258 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 258 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
259 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 259 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
260 | } | 260 | } |
261 | 261 | ||
262 | void PMainWindow::initDisp() { | 262 | void PMainWindow::initDisp() { |
263 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 263 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
264 | if (m_disp) { | 264 | if (m_disp) { |
265 | // if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 265 | // if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
266 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 266 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
267 | // } | 267 | // } |
268 | m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType,m_hBright); | 268 | m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType,m_hBright); |
269 | m_disp->setAutoScale(!m_aUnscaled->isOn()); | 269 | m_disp->setAutoScale(!m_aUnscaled->isOn()); |
270 | m_disp->setAutoRotate(m_aAutoRotate->isOn()); | 270 | m_disp->setAutoRotate(m_aAutoRotate->isOn()); |
271 | m_disp->setShowZoomer(m_aZoomer->isOn()); | 271 | m_disp->setShowZoomer(m_aZoomer->isOn()); |
272 | m_disp->setBackgroundColor(white); | 272 | m_disp->setBackgroundColor(white); |
273 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 273 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
274 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 274 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
275 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 275 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
276 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); | 276 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); |
277 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 277 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
278 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 278 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
279 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | 279 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); |
280 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | 280 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); |
281 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); | 281 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); |
282 | connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness())); | 282 | connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness())); |
283 | connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness())); | 283 | connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness())); |
284 | slotFullScreenToggled(m_aFullScreen->isOn()); | 284 | slotFullScreenToggled(m_aFullScreen->isOn()); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | void PMainWindow::slotToggleFullScreen() | 288 | void PMainWindow::slotToggleFullScreen() |
289 | { | 289 | { |
290 | bool current = !m_aFullScreen->isOn(); | 290 | bool current = !m_aFullScreen->isOn(); |
291 | m_aFullScreen->setOn(current); | 291 | m_aFullScreen->setOn(current); |
292 | } | 292 | } |
293 | 293 | ||
294 | void PMainWindow::slotFullScreenButton(bool current) | 294 | void PMainWindow::slotFullScreenButton(bool current) |
295 | { | 295 | { |
296 | if (autoSave) { | 296 | if (autoSave) { |
297 | m_cfg->writeEntry("fullscreen",current); | 297 | m_cfg->writeEntry("fullscreen",current); |
298 | } | 298 | } |
299 | if (!m_disp) return; | 299 | if (!m_disp) return; |
300 | if (m_disp->isVisible()) { | 300 | if (m_disp->isVisible()) { |
301 | setupViewWindow(current, true); | 301 | setupViewWindow(current, true); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | void PMainWindow::setupViewWindow(bool current, bool forceDisplay) | 305 | void PMainWindow::setupViewWindow(bool current, bool forceDisplay) |
306 | { | 306 | { |
307 | if (!m_disp) { | 307 | if (!m_disp) { |
308 | return; | 308 | return; |
309 | } | 309 | } |
310 | if (current) { | 310 | if (current) { |
311 | m_disp->setBackgroundColor(black); | 311 | m_disp->setBackgroundColor(black); |
312 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); | 312 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); |
313 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); | 313 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); |
314 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); | 314 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); |
315 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 315 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
316 | m_disp->setFullScreen(current,forceDisplay); | 316 | m_disp->setFullScreen(current,forceDisplay); |
317 | } else { | 317 | } else { |
318 | setUpdatesEnabled(false); | 318 | setUpdatesEnabled(false); |
319 | #if 0 | 319 | #if 0 |
320 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 320 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
321 | 321 | ||
322 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 322 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
323 | } else { | 323 | } else { |
324 | //m_disp->setMinimumSize(10,10); | 324 | //m_disp->setMinimumSize(10,10); |
325 | } | 325 | } |
326 | #endif | 326 | #endif |
327 | m_disp->setBackgroundColor(white); | 327 | m_disp->setBackgroundColor(white); |
328 | m_stack->addWidget(m_disp,ImageDisplay); | 328 | m_stack->addWidget(m_disp,ImageDisplay); |
329 | m_disp->setVScrollBarMode(QScrollView::Auto); | 329 | m_disp->setVScrollBarMode(QScrollView::Auto); |
330 | m_disp->setHScrollBarMode(QScrollView::Auto); | 330 | m_disp->setHScrollBarMode(QScrollView::Auto); |
331 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 331 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
332 | m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); | 332 | m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); |
333 | } | 333 | } |
334 | if (forceDisplay || m_disp->isVisible()) { | 334 | if (forceDisplay || m_disp->isVisible()) { |
335 | m_stack->raiseWidget(m_disp); | 335 | m_stack->raiseWidget(m_disp); |
336 | m_disp->setFocus(); | 336 | m_disp->setFocus(); |
337 | } | 337 | } |
338 | setUpdatesEnabled(true); | 338 | setUpdatesEnabled(true); |
339 | } | 339 | } |
340 | m_disp->setFullScreen(current,forceDisplay); | 340 | m_disp->setFullScreen(current,forceDisplay); |
341 | } | 341 | } |
342 | 342 | ||
343 | void PMainWindow::slotFullScreenToggled(bool current) | 343 | void PMainWindow::slotFullScreenToggled(bool current) |
344 | { | 344 | { |
345 | setupViewWindow(current,true); | 345 | setupViewWindow(current,true); |
346 | } | 346 | } |
347 | 347 | ||
348 | /** | 348 | /** |
349 | * With big Screen the plan could be to 'detach' the image | 349 | * With big Screen the plan could be to 'detach' the image |
350 | * window if visible and to create a ne wone | 350 | * window if visible and to create a ne wone |
351 | * init* already supports it but I make no use of it for | 351 | * init* already supports it but I make no use of it for |
352 | * now. We set filename and raise | 352 | * now. We set filename and raise |
353 | * | 353 | * |
354 | * ### FIXME and talk to alwin | 354 | * ### FIXME and talk to alwin |
355 | */ | 355 | */ |
356 | void PMainWindow::slotShowInfo( const QString& inf ) { | 356 | void PMainWindow::slotShowInfo( const QString& inf ) { |
357 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 357 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
358 | return; | 358 | return; |
359 | } | 359 | } |
360 | if ( !m_info ) { | 360 | if ( !m_info ) { |
361 | initInfo(); | 361 | initInfo(); |
362 | } | 362 | } |
363 | m_info->setPath( inf ); | 363 | m_info->setPath( inf ); |
364 | if (m_SmallWindow) { | 364 | if (m_SmallWindow) { |
365 | m_aNext->removeFrom(toolBar); | 365 | m_aNext->removeFrom(toolBar); |
366 | m_aPrevious->removeFrom(toolBar); | 366 | m_aPrevious->removeFrom(toolBar); |
367 | fsButton->hide(); | 367 | fsButton->hide(); |
368 | } | 368 | } |
369 | m_aNext->setEnabled(false); | 369 | m_aNext->setEnabled(false); |
370 | m_aPrevious->setEnabled(false); | 370 | m_aPrevious->setEnabled(false); |
371 | m_aDirUp->setEnabled(false); | 371 | m_aDirUp->setEnabled(false); |
372 | m_aShowInfo->setEnabled(false); | 372 | m_aShowInfo->setEnabled(false); |
373 | m_aViewfile->setEnabled(true); | 373 | m_aViewfile->setEnabled(true); |
374 | m_aStartSlide->setEnabled(false); | 374 | m_aStartSlide->setEnabled(false); |
375 | m_stack->raiseWidget( ImageInfo ); | 375 | m_stack->raiseWidget( ImageInfo ); |
376 | } | 376 | } |
377 | 377 | ||
378 | void PMainWindow::slotDisplay( const QString& inf ) { | 378 | void PMainWindow::slotDisplay( const QString& inf ) { |
379 | bool nwindow = false; | 379 | bool nwindow = false; |
380 | if ( !m_disp ) { | 380 | if ( !m_disp ) { |
381 | nwindow = true; | 381 | nwindow = true; |
382 | initDisp(); | 382 | initDisp(); |
383 | m_disp->setIntensity(m_Intensity); | 383 | m_disp->setIntensity(m_Intensity); |
384 | m_setCurrentBrightness->setEnabled(true); | 384 | m_setCurrentBrightness->setEnabled(true); |
385 | m_hBright->setEnabled(true); | 385 | m_hBright->setEnabled(true); |
386 | } | 386 | } |
387 | m_disp->setImage( inf ); | 387 | m_disp->setImage( inf ); |
388 | if (m_SmallWindow) { | 388 | if (m_SmallWindow) { |
389 | if (m_gPrevNext->isEnabled()==false) { | 389 | if (m_gPrevNext->isEnabled()==false) { |
390 | m_gPrevNext->addTo(toolBar); | 390 | m_gPrevNext->addTo(toolBar); |
391 | fsButton->hide(); | 391 | fsButton->hide(); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | m_gPrevNext->setEnabled(true); | 394 | m_gPrevNext->setEnabled(true); |
395 | m_aDirUp->setEnabled(false); | 395 | m_aDirUp->setEnabled(false); |
396 | m_aShowInfo->setEnabled(true); | 396 | m_aShowInfo->setEnabled(true); |
397 | m_aViewfile->setEnabled(false); | 397 | m_aViewfile->setEnabled(false); |
398 | m_aStartSlide->setEnabled(false); | 398 | m_aStartSlide->setEnabled(false); |
399 | 399 | ||
400 | if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { | 400 | if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { |
401 | slotFullScreenToggled(m_aFullScreen->isOn()); | 401 | slotFullScreenToggled(m_aFullScreen->isOn()); |
402 | } | 402 | } |
403 | if (m_disp->fullScreen()) { | 403 | if (m_disp->fullScreen()) { |
404 | if (!m_disp->isVisible()) { | 404 | if (!m_disp->isVisible()) { |
405 | m_disp->showFullScreen(); | 405 | m_disp->showFullScreen(); |
406 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 406 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
407 | } | 407 | } |
408 | } else { | 408 | } else { |
409 | m_stack->raiseWidget( ImageDisplay ); | 409 | m_stack->raiseWidget( ImageDisplay ); |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | void PMainWindow::raiseIconView() { | 413 | void PMainWindow::raiseIconView() { |
414 | setUpdatesEnabled(false); | 414 | setUpdatesEnabled(false); |
415 | if (m_SmallWindow) { | 415 | if (m_SmallWindow) { |
416 | m_gPrevNext->removeFrom(toolBar); | 416 | m_gPrevNext->removeFrom(toolBar); |
417 | fsButton->show(); | 417 | fsButton->show(); |
418 | } | 418 | } |
419 | m_gPrevNext->setEnabled(false); | 419 | m_gPrevNext->setEnabled(false); |
420 | m_aDirUp->setEnabled(true); | 420 | m_aDirUp->setEnabled(true); |
421 | m_aShowInfo->setEnabled(true); | 421 | m_aShowInfo->setEnabled(true); |
422 | m_aViewfile->setEnabled(true); | 422 | m_aViewfile->setEnabled(true); |
423 | m_aStartSlide->setEnabled(true); | 423 | m_aStartSlide->setEnabled(true); |
424 | 424 | ||
425 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 425 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
426 | m_disp->stopSlide(); | 426 | m_disp->stopSlide(); |
427 | m_disp->hide(); | 427 | m_disp->hide(); |
428 | } | 428 | } |
429 | m_stack->raiseWidget( IconView ); | 429 | m_stack->raiseWidget( IconView ); |
430 | setUpdatesEnabled(true); | 430 | setUpdatesEnabled(true); |
431 | repaint(); | 431 | repaint(); |
432 | } | 432 | } |
433 | 433 | ||
434 | void PMainWindow::slotReturn() { | 434 | void PMainWindow::slotReturn() { |
435 | raiseIconView(); | 435 | raiseIconView(); |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 439 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
440 | /* | 440 | /* |
441 | * return from view | 441 | * return from view |
442 | * or properly quit | 442 | * or properly quit |
443 | */ | 443 | */ |
444 | if (!m_setDocCalled) { | 444 | if (!m_setDocCalled) { |
445 | if ( m_stack->visibleWidget() == m_info || | 445 | if ( m_stack->visibleWidget() == m_info || |
446 | m_stack->visibleWidget() == m_disp ) { | 446 | m_stack->visibleWidget() == m_disp ) { |
447 | ev->ignore(); | 447 | ev->ignore(); |
448 | raiseIconView(); | 448 | raiseIconView(); |
449 | return; | 449 | return; |
450 | } | 450 | } |
451 | } | 451 | } |
452 | if (m_disp && m_disp->fullScreen()) { | 452 | if (m_disp && m_disp->fullScreen()) { |
453 | /* otherwise opie-eye crashes in bigscreen mode! */ | 453 | /* otherwise opie-eye crashes in bigscreen mode! */ |
454 | m_disp->reparent(0,QPoint(0,0)); | 454 | m_disp->reparent(0,QPoint(0,0)); |
455 | m_stack->addWidget(m_disp,ImageDisplay); | 455 | m_stack->addWidget(m_disp,ImageDisplay); |
456 | } | 456 | } |
457 | ev->accept(); | 457 | ev->accept(); |
458 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 458 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
459 | } | 459 | } |
460 | 460 | ||
461 | void PMainWindow::setDocument( const QString& showImg ) | 461 | void PMainWindow::setDocument( const QString& showImg ) |
462 | { | 462 | { |
463 | QString file = showImg; | 463 | QString file = showImg; |
464 | DocLnk lnk(showImg); | 464 | DocLnk lnk(showImg); |
465 | if (lnk.isValid() ) | 465 | if (lnk.isValid() ) |
466 | file = lnk.file(); | 466 | file = lnk.file(); |
467 | slotDisplay( file ); | 467 | slotDisplay( file ); |
468 | #if 0 | 468 | #if 0 |
469 | if (!m_polishDone) { | 469 | if (!m_polishDone) { |
470 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | 470 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | } | 473 | } |
474 | 474 | ||
475 | void PMainWindow::check_view_fullscreen() | 475 | void PMainWindow::check_view_fullscreen() |
476 | { | 476 | { |
477 | if (!m_view) return; | 477 | if (!m_view) return; |
478 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { | 478 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { |
479 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 479 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | void PMainWindow::slotSelectDir(int id) | 483 | void PMainWindow::slotSelectDir(int id) |
484 | { | 484 | { |
485 | emit changeDir( m_dev[fsMenu->text(id )] ); | 485 | emit changeDir( m_dev[fsMenu->text(id )] ); |
486 | } | 486 | } |
487 | 487 | ||
488 | void PMainWindow::dirChanged() | 488 | void PMainWindow::dirChanged() |
489 | { | 489 | { |
490 | fsMenu->clear(); | 490 | fsMenu->clear(); |
491 | m_dev.clear(); | 491 | m_dev.clear(); |
492 | 492 | ||
493 | /* home dir, too */ | 493 | /* home dir, too */ |
494 | QString f = getenv( "HOME" ); | 494 | QString f = getenv( "HOME" ); |
495 | if (!f.isEmpty()) { | 495 | if (!f.isEmpty()) { |
496 | m_dev.insert("Home directory",f); | 496 | m_dev.insert("Home directory",f); |
497 | fsMenu->insertItem("Home directory"); | 497 | fsMenu->insertItem("Home directory"); |
498 | } | 498 | } |
499 | const QList<FileSystem> &fs = m_storage->fileSystems(); | 499 | const QList<FileSystem> &fs = m_storage->fileSystems(); |
500 | QListIterator<FileSystem> it(fs ); | 500 | QListIterator<FileSystem> it(fs ); |
501 | for ( ; it.current(); ++it ) { | 501 | for ( ; it.current(); ++it ) { |
502 | const QString disk = (*it)->name(); | 502 | const QString disk = (*it)->name(); |
503 | const QString path = (*it)->path(); | 503 | const QString path = (*it)->path(); |
504 | m_dev.insert( disk, path ); | 504 | m_dev.insert( disk, path ); |
505 | fsMenu->insertItem( disk ); | 505 | fsMenu->insertItem( disk ); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | void PMainWindow::showToolbar(bool how) | 509 | void PMainWindow::showToolbar(bool how) |
510 | { | 510 | { |
511 | if (!how) toolBar->hide(); | 511 | if (!how) toolBar->hide(); |
512 | else toolBar->show(); | 512 | else toolBar->show(); |
513 | if (autoSave) { | 513 | if (autoSave) { |
514 | m_cfg->writeEntry("showtoolbar",how); | 514 | m_cfg->writeEntry("showtoolbar",how); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | void PMainWindow::setupActions() | 518 | void PMainWindow::setupActions() |
519 | { | 519 | { |
520 | m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); | 520 | m_aDirUp = new QAction( tr( "Go dir up" ), Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), |
521 | 0, 0, this, 0, true ); | ||
521 | m_aDirUp->setToggleAction(false); | 522 | m_aDirUp->setToggleAction(false); |
522 | connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); | 523 | connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); |
523 | 524 | ||
524 | if ( Ir::supported() ) { | 525 | if ( Ir::supported() ) { |
525 | m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); | 526 | m_aBeam = new QAction( tr( "Beam file" ), Opie::Core::OResource::loadPixmap( "beam", Opie::Core::OResource::SmallIcon ), |
527 | 0, 0, this, 0, true ); | ||
526 | m_aBeam->setToggleAction(false); | 528 | m_aBeam->setToggleAction(false); |
527 | connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); | 529 | connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); |
528 | } else { | 530 | } else { |
529 | m_aBeam = 0; | 531 | m_aBeam = 0; |
530 | } | 532 | } |
531 | 533 | ||
532 | m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); | 534 | m_aShowInfo = new QAction( tr( "Show imageinfo" ), Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), |
535 | 0, 0, this, 0, true ); | ||
533 | m_aShowInfo->setToggleAction(false); | 536 | m_aShowInfo->setToggleAction(false); |
534 | connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); | 537 | connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); |
535 | 538 | ||
536 | m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); | 539 | m_aTrash = new QAction( tr( "Delete file" ), Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), |
540 | 0, 0, this, 0, true ); | ||
537 | m_aTrash->setToggleAction(false); | 541 | m_aTrash->setToggleAction(false); |
538 | connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); | 542 | connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); |
539 | 543 | ||
540 | m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); | 544 | m_aViewfile = new QAction( tr( "Display image" ), Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), |
545 | 0, 0, this, 0, true ); | ||
541 | m_aViewfile->setToggleAction(false); | 546 | m_aViewfile->setToggleAction(false); |
542 | connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); | 547 | connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); |
543 | 548 | ||
544 | m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); | 549 | m_aStartSlide = new QAction( tr( "Start slideshow" ), Opie::Core::OResource::loadPixmap("play", Opie::Core::OResource::SmallIcon), |
550 | 0, 0, this, 0, true ); | ||
545 | m_aStartSlide->setToggleAction(false); | 551 | m_aStartSlide->setToggleAction(false); |
546 | connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); | 552 | connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); |
547 | 553 | ||
548 | m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); | 554 | m_aHideToolbar = new QAction( tr( "Show toolbar" ), Opie::Core::OResource::loadPixmap( "UtilsIcon", |
555 | Opie::Core::OResource::SmallIcon ), 0, 0, this, 0, true ); | ||
549 | m_aHideToolbar->setOn (true); | 556 | m_aHideToolbar->setOn (true); |
550 | connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); | 557 | connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); |
551 | 558 | ||
552 | m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); | 559 | m_aSetup = new QAction( tr( "Settings" ), Opie::Core::OResource::loadPixmap("SettingsIcon", Opie::Core::OResource::SmallIcon), |
560 | 0, 0, this, 0, true ); | ||
553 | m_aSetup->setToggleAction(false); | 561 | m_aSetup->setToggleAction(false); |
554 | connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); | 562 | connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); |
555 | 563 | ||
556 | m_gListViewMode = new QActionGroup(this,"Select listmode",true); | 564 | m_gListViewMode = new QActionGroup(this,"Select listmode",true); |
557 | connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); | 565 | connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); |
558 | 566 | ||
559 | m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); | 567 | m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", |
568 | Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); | ||
560 | m_aDirLong->setToggleAction(true); | 569 | m_aDirLong->setToggleAction(true); |
561 | m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); | 570 | m_aDirShort = new QAction( tr( "Thumbnail and name" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumbonly", |
571 | Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); | ||
562 | m_aDirShort->setToggleAction(true); | 572 | m_aDirShort->setToggleAction(true); |
563 | m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); | 573 | m_aDirName = new QAction( tr( "Name only" ), Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-textview", |
574 | Opie::Core::OResource::SmallIcon),0, 0, this, 0, true ); | ||
564 | m_aDirName->setToggleAction(true); | 575 | m_aDirName->setToggleAction(true); |
565 | int mode = m_cfg->readNumEntry("ListViewMode", 1); | 576 | int mode = m_cfg->readNumEntry("ListViewMode", 1); |
566 | if (mode < 1 || mode>3) mode = 1; | 577 | if (mode < 1 || mode>3) mode = 1; |
567 | switch (mode) { | 578 | switch (mode) { |
568 | case 3: | 579 | case 3: |
569 | m_aDirName->setOn(true); | 580 | m_aDirName->setOn(true); |
570 | break; | 581 | break; |
571 | case 2: | 582 | case 2: |
572 | m_aDirShort->setOn(true); | 583 | m_aDirShort->setOn(true); |
573 | break; | 584 | break; |
574 | case 1: | 585 | case 1: |
575 | default: | 586 | default: |
576 | m_aDirLong->setOn(true); | 587 | m_aDirLong->setOn(true); |
577 | } | 588 | } |
578 | m_gListViewMode->insert(m_aDirLong); | 589 | m_gListViewMode->insert(m_aDirLong); |
579 | m_gListViewMode->insert(m_aDirShort); | 590 | m_gListViewMode->insert(m_aDirShort); |
580 | m_gListViewMode->insert(m_aDirName); | 591 | m_gListViewMode->insert(m_aDirName); |
581 | 592 | ||
582 | m_gPrevNext = new QActionGroup(this,"imageprevnext",false); | 593 | m_gPrevNext = new QActionGroup(this,"imageprevnext",false); |
583 | m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); | 594 | m_aNext = new QAction( tr( "Next image" ),Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), |
595 | 0, 0, this, 0, true ); | ||
584 | m_aNext->setToggleAction(false); | 596 | m_aNext->setToggleAction(false); |
585 | connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); | 597 | connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); |
586 | m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); | 598 | m_aPrevious = new QAction( tr( "Previous image" ),Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), |
599 | 0, 0, this, 0, true ); | ||
587 | m_aPrevious->setToggleAction(false); | 600 | m_aPrevious->setToggleAction(false); |
588 | connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); | 601 | connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); |
589 | m_gPrevNext->insert(m_aPrevious); | 602 | m_gPrevNext->insert(m_aPrevious); |
590 | m_gPrevNext->insert(m_aNext); | 603 | m_gPrevNext->insert(m_aNext); |
591 | 604 | ||
592 | m_aFullScreen = new QAction( tr( "Show images fullscreen" ), | 605 | m_aFullScreen = new QAction( tr( "Show images fullscreen" ), |
593 | Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); | 606 | Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); |
594 | m_aFullScreen->setToggleAction(true); | 607 | m_aFullScreen->setToggleAction(true); |
595 | if (autoSave) { | 608 | if (autoSave) { |
596 | m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); | 609 | m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); |
597 | } else { | 610 | } else { |
598 | m_aFullScreen->setOn(false); | 611 | m_aFullScreen->setOn(false); |
599 | } | 612 | } |
600 | connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); | 613 | connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); |
601 | 614 | ||
602 | m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); | 615 | m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); |
603 | m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); | 616 | m_aAutoRotate = new QAction( tr( "Auto rotate images" ), |
617 | Opie::Core::OResource::loadPixmap( "rotate", Opie::Core::OResource::SmallIcon ), | ||
618 | 0, 0, this, 0, true ); | ||
604 | m_aAutoRotate->setToggleAction(true); | 619 | m_aAutoRotate->setToggleAction(true); |
605 | 620 | ||
606 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 621 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
607 | m_aAutoRotate->setOn(true); | 622 | m_aAutoRotate->setOn(true); |
608 | } else { | 623 | } else { |
609 | m_aAutoRotate->setOn(false); | 624 | m_aAutoRotate->setOn(false); |
610 | } | 625 | } |
611 | if (autoSave) { | 626 | if (autoSave) { |
612 | m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); | 627 | m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); |
613 | } | 628 | } |
614 | connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 629 | connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
615 | 630 | ||
616 | m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); | 631 | m_aUnscaled = new QAction( tr( "Show images unscaled" ), |
632 | Opie::Core::OResource::loadPixmap( "1to1", Opie::Core::OResource::SmallIcon ), | ||
633 | 0, 0, this, 0, true ); | ||
617 | m_aUnscaled->setToggleAction(true); | 634 | m_aUnscaled->setToggleAction(true); |
618 | connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 635 | connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
619 | if (autoSave) { | 636 | if (autoSave) { |
620 | m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); | 637 | m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); |
621 | } else { | 638 | } else { |
622 | m_aUnscaled->setOn(false); | 639 | m_aUnscaled->setOn(false); |
623 | } | 640 | } |
624 | 641 | ||
625 | m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); | 642 | m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), |
643 | Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ), | ||
644 | 0, 0, this, 0, true ); | ||
626 | m_aZoomer->setToggleAction(true); | 645 | m_aZoomer->setToggleAction(true); |
627 | if (autoSave) { | 646 | if (autoSave) { |
628 | m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); | 647 | m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); |
629 | } else { | 648 | } else { |
630 | m_aZoomer->setOn (true); | 649 | m_aZoomer->setOn (true); |
631 | } | 650 | } |
632 | connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 651 | connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
633 | m_gDisplayType->insert(m_aAutoRotate); | 652 | m_gDisplayType->insert(m_aAutoRotate); |
634 | m_gDisplayType->insert(m_aUnscaled); | 653 | m_gDisplayType->insert(m_aUnscaled); |
635 | m_gDisplayType->insert(m_aZoomer); | 654 | m_gDisplayType->insert(m_aZoomer); |
636 | 655 | ||
637 | m_hGroup = new QActionGroup(this,"actioncollection",false); | 656 | m_hGroup = new QActionGroup(this,"actioncollection",false); |
638 | m_hGroup->insert(m_aFullScreen); | 657 | m_hGroup->insert(m_aFullScreen); |
639 | 658 | ||
640 | if (!m_SmallWindow) { | 659 | if (!m_SmallWindow) { |
641 | m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true); | 660 | m_aForceSmall = new QAction(tr("Dont show seperate windows"), |
661 | Opie::Core::OResource::loadPixmap( "AppsIcon", Opie::Core::OResource::SmallIcon ), | ||
662 | 0, 0, this, 0, true); | ||
642 | m_aForceSmall->setToggleAction(true); | 663 | m_aForceSmall->setToggleAction(true); |
643 | connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); | 664 | connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); |
644 | } else { | 665 | } else { |
645 | m_aForceSmall = 0; | 666 | m_aForceSmall = 0; |
646 | } | 667 | } |
647 | m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); | 668 | m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); |
648 | connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); | 669 | connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); |
649 | m_IncBrightness = new QAction(tr("Increase brightness by 5"),Resource::loadIconSet( "up" ),0, 0, this, 0, false); | 670 | m_IncBrightness = new QAction(tr("Increase brightness by 5"), |
650 | m_DecBrightness = new QAction(tr("Decrease brightness by 5"),Resource::loadIconSet( "down" ),0, 0, this, 0, false); | 671 | Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), |
672 | 0, 0, this, 0, false); | ||
673 | m_DecBrightness = new QAction(tr("Decrease brightness by 5"), | ||
674 | Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ), | ||
675 | 0, 0, this, 0, false); | ||
651 | m_hBright = new QActionGroup(this,"actioncollection",false), | 676 | m_hBright = new QActionGroup(this,"actioncollection",false), |
652 | m_hBright->insert(m_setCurrentBrightness); | 677 | m_hBright->insert(m_setCurrentBrightness); |
653 | m_hBright->insert(m_IncBrightness); | 678 | m_hBright->insert(m_IncBrightness); |
654 | m_hBright->insert(m_DecBrightness); | 679 | m_hBright->insert(m_DecBrightness); |
655 | } | 680 | } |
656 | 681 | ||
657 | void PMainWindow::setupBrightness() | 682 | void PMainWindow::setupBrightness() |
658 | { | 683 | { |
659 | if (!m_disp) { | 684 | if (!m_disp) { |
660 | return; | 685 | return; |
661 | } | 686 | } |
662 | bool reshow=false; | 687 | bool reshow=false; |
663 | if (m_disp->isVisible()&&m_disp->fullScreen()) { | 688 | if (m_disp->isVisible()&&m_disp->fullScreen()) { |
664 | m_disp->hide(); | 689 | m_disp->hide(); |
665 | reshow = true; | 690 | reshow = true; |
666 | } | 691 | } |
667 | int lb = m_disp->Intensity(); | 692 | int lb = m_disp->Intensity(); |
668 | if (Valuebox(0,-100,100,lb,lb)) { | 693 | if (Valuebox(0,-100,100,lb,lb)) { |
669 | m_disp->setIntensity(lb,true); | 694 | m_disp->setIntensity(lb,true); |
670 | } | 695 | } |
671 | if (reshow) { | 696 | if (reshow) { |
672 | m_disp->showFullScreen(); | 697 | m_disp->showFullScreen(); |
673 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 698 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
674 | } | 699 | } |
675 | } | 700 | } |
676 | 701 | ||
677 | void PMainWindow::setupToolbar() | 702 | void PMainWindow::setupToolbar() |
678 | { | 703 | { |
679 | toolBar = new QToolBar( this ); | 704 | toolBar = new QToolBar( this ); |
680 | addToolBar(toolBar); | 705 | addToolBar(toolBar); |
681 | toolBar->setHorizontalStretchable( true ); | 706 | toolBar->setHorizontalStretchable( true ); |
682 | setToolBarsMovable( false ); | 707 | setToolBarsMovable( false ); |
683 | m_aDirUp->addTo( toolBar ); | 708 | m_aDirUp->addTo( toolBar ); |
684 | 709 | ||
685 | fsButton = new PFileSystem( toolBar ); | 710 | fsButton = new PFileSystem( toolBar ); |
686 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 711 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
687 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 712 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
688 | connect( this, SIGNAL( changeDir( const QString& ) ), | 713 | connect( this, SIGNAL( changeDir( const QString& ) ), |
689 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 714 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
690 | 715 | ||
691 | if (m_aBeam) { | 716 | if (m_aBeam) { |
692 | m_aBeam->addTo( toolBar ); | 717 | m_aBeam->addTo( toolBar ); |
693 | } | 718 | } |
694 | m_aShowInfo->addTo(toolBar); | 719 | m_aShowInfo->addTo(toolBar); |
695 | m_aTrash->addTo(toolBar); | 720 | m_aTrash->addTo(toolBar); |
696 | 721 | ||
697 | m_gDisplayType->addTo(toolBar); | 722 | m_gDisplayType->addTo(toolBar); |
698 | 723 | ||
699 | if (!m_SmallWindow) { | 724 | if (!m_SmallWindow) { |
700 | m_gPrevNext->addTo(toolBar); | 725 | m_gPrevNext->addTo(toolBar); |
701 | } else { | 726 | } else { |
702 | m_gPrevNext->setEnabled(false); | 727 | m_gPrevNext->setEnabled(false); |
703 | } | 728 | } |
704 | } | 729 | } |
705 | 730 | ||
706 | void PMainWindow::setupMenu() | 731 | void PMainWindow::setupMenu() |
707 | { | 732 | { |
708 | fileMenu = new QPopupMenu( menuBar() ); | 733 | fileMenu = new QPopupMenu( menuBar() ); |
709 | menuBar()->insertItem( tr( "File" ), fileMenu ); | 734 | menuBar()->insertItem( tr( "File" ), fileMenu ); |
710 | dispMenu = new QPopupMenu( menuBar() ); | 735 | dispMenu = new QPopupMenu( menuBar() ); |
711 | menuBar()->insertItem( tr( "Show" ), dispMenu ); | 736 | menuBar()->insertItem( tr( "Show" ), dispMenu ); |
712 | settingsMenu = new QPopupMenu( menuBar() ); | 737 | settingsMenu = new QPopupMenu( menuBar() ); |
713 | menuBar()->insertItem( tr( "Settings" ), settingsMenu ); | 738 | menuBar()->insertItem( tr( "Settings" ), settingsMenu ); |
714 | 739 | ||
715 | m_aViewfile->addTo(fileMenu); | 740 | m_aViewfile->addTo(fileMenu); |
716 | m_aShowInfo->addTo(fileMenu); | 741 | m_aShowInfo->addTo(fileMenu); |
717 | m_aStartSlide->addTo(fileMenu); | 742 | m_aStartSlide->addTo(fileMenu); |
718 | 743 | ||
719 | fileMenu->insertSeparator(); | 744 | fileMenu->insertSeparator(); |
720 | m_aDirUp->addTo( fileMenu ); | 745 | m_aDirUp->addTo( fileMenu ); |
721 | 746 | ||
722 | fsMenu = new QPopupMenu(fileMenu); | 747 | fsMenu = new QPopupMenu(fileMenu); |
723 | fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); | 748 | fileMenu->insertItem(Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ), |
749 | tr("Select filesystem"),fsMenu); | ||
724 | connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); | 750 | connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); |
725 | dirChanged(); | 751 | dirChanged(); |
726 | 752 | ||
727 | if ( m_aBeam ) { | 753 | if ( m_aBeam ) { |
728 | fileMenu->insertSeparator(); | 754 | fileMenu->insertSeparator(); |
729 | m_aBeam->addTo( fileMenu ); | 755 | m_aBeam->addTo( fileMenu ); |
730 | } | 756 | } |
731 | fileMenu->insertSeparator(); | 757 | fileMenu->insertSeparator(); |
732 | m_aTrash->addTo(fileMenu); | 758 | m_aTrash->addTo(fileMenu); |
733 | 759 | ||
734 | listviewMenu = new QPopupMenu(dispMenu); | 760 | listviewMenu = new QPopupMenu(dispMenu); |
735 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); | 761 | dispMenu->insertItem(Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", Opie::Core::OResource::SmallIcon), |
762 | tr("Listview mode"),listviewMenu); | ||
736 | m_gListViewMode->addTo(listviewMenu); | 763 | m_gListViewMode->addTo(listviewMenu); |
737 | dispMenu->insertSeparator(); | 764 | dispMenu->insertSeparator(); |
738 | m_aFullScreen->addTo(dispMenu); | 765 | m_aFullScreen->addTo(dispMenu); |
739 | m_gDisplayType->addTo(dispMenu); | 766 | m_gDisplayType->addTo(dispMenu); |
740 | dispMenu->insertSeparator(); | 767 | dispMenu->insertSeparator(); |
741 | m_gPrevNext->addTo(dispMenu); | 768 | m_gPrevNext->addTo(dispMenu); |
742 | dispMenu->insertSeparator(); | 769 | dispMenu->insertSeparator(); |
743 | m_hBright->addTo(dispMenu); | 770 | m_hBright->addTo(dispMenu); |
744 | m_hBright->setEnabled(false); | 771 | m_hBright->setEnabled(false); |
745 | 772 | ||
746 | if (m_aForceSmall) { | 773 | if (m_aForceSmall) { |
747 | dispMenu->insertSeparator(); | 774 | dispMenu->insertSeparator(); |
748 | m_aForceSmall->addTo(dispMenu); | 775 | m_aForceSmall->addTo(dispMenu); |
749 | } | 776 | } |
750 | 777 | ||
751 | m_aSetup->addTo(settingsMenu); | 778 | m_aSetup->addTo(settingsMenu); |
752 | m_aHideToolbar->addTo(settingsMenu); | 779 | m_aHideToolbar->addTo(settingsMenu); |
753 | } | 780 | } |
754 | 781 | ||
755 | void PMainWindow::listviewselected(QAction*which) | 782 | void PMainWindow::listviewselected(QAction*which) |
756 | { | 783 | { |
757 | if (!which || which->isOn()==false) return; | 784 | if (!which || which->isOn()==false) return; |
758 | int val = 1; | 785 | int val = 1; |
759 | 786 | ||
760 | if (which==m_aDirName) { | 787 | if (which==m_aDirName) { |
761 | val = 3; | 788 | val = 3; |
762 | } else if (which==m_aDirShort) { | 789 | } else if (which==m_aDirShort) { |
763 | val = 2; | 790 | val = 2; |
764 | } else if (which==m_aDirLong) { | 791 | } else if (which==m_aDirLong) { |
765 | val = 1; | 792 | val = 1; |
766 | } | 793 | } |
767 | emit changeListMode(val); | 794 | emit changeListMode(val); |
768 | } | 795 | } |
769 | 796 | ||
770 | void PMainWindow::readConfig() | 797 | void PMainWindow::readConfig() |
771 | { | 798 | { |
772 | autoSave =m_cfg->readBoolEntry("savestatus",true); | 799 | autoSave =m_cfg->readBoolEntry("savestatus",true); |
773 | m_Intensity = m_cfg->readNumEntry("intensity",0); | 800 | m_Intensity = m_cfg->readNumEntry("intensity",0); |
774 | } | 801 | } |
775 | 802 | ||
776 | void PMainWindow::polish() | 803 | void PMainWindow::polish() |
777 | { | 804 | { |
778 | if (m_disp) { | 805 | if (m_disp) { |
779 | odebug << "======================\n" | 806 | odebug << "======================\n" |
780 | << "Called via setdocument\n" | 807 | << "Called via setdocument\n" |
781 | << "======================" << oendl; | 808 | << "======================" << oendl; |
782 | m_setDocCalled = true; | 809 | m_setDocCalled = true; |
783 | m_view->setDoccalled(true); | 810 | m_view->setDoccalled(true); |
784 | m_disp->setCloseIfHide(true); | 811 | m_disp->setCloseIfHide(true); |
785 | } else { | 812 | } else { |
786 | m_setDocCalled = false; | 813 | m_setDocCalled = false; |
787 | m_view->setDoccalled(false); | 814 | m_view->setDoccalled(false); |
788 | } | 815 | } |
789 | m_polishDone = true; | 816 | m_polishDone = true; |
790 | QMainWindow::polish(); | 817 | QMainWindow::polish(); |
791 | if (m_setDocCalled) { | 818 | if (m_setDocCalled) { |
792 | if (m_aFullScreen->isOn()) { | 819 | if (m_aFullScreen->isOn()) { |
793 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | 820 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); |
794 | } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 821 | } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
795 | } | 822 | } |
796 | } | 823 | } |
797 | } | 824 | } |
798 | 825 | ||
799 | void PMainWindow::slotForceSmall(bool how) | 826 | void PMainWindow::slotForceSmall(bool how) |
800 | { | 827 | { |
801 | odebug << "Disable separate windows: " << how << oendl; | 828 | odebug << "Disable separate windows: " << how << oendl; |
802 | if (m_stack) { | 829 | if (m_stack) { |
803 | if (how) { | 830 | if (how) { |
804 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); | 831 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); |
805 | } else { | 832 | } else { |
806 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 833 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
807 | } | 834 | } |
808 | } | 835 | } |
809 | if (autoSave) { | 836 | if (autoSave) { |
810 | m_cfg->writeEntry("dontshowseperate",how); | 837 | m_cfg->writeEntry("dontshowseperate",how); |
811 | } | 838 | } |
812 | } | 839 | } |
813 | 840 | ||
814 | bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) | 841 | bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) |
815 | { | 842 | { |
816 | QDialog dlg(parent,"brightnessbox",true); | 843 | QDialog dlg(parent,"brightnessbox",true); |
817 | QVBoxLayout * m_MainLayout; | 844 | QVBoxLayout * m_MainLayout; |
818 | QGridLayout * m_IntensityLayout; | 845 | QGridLayout * m_IntensityLayout; |
819 | QSpinBox * m_Intensity; | 846 | QSpinBox * m_Intensity; |
820 | QLabel * m_IntensityLabel; | 847 | QLabel * m_IntensityLabel; |
821 | 848 | ||
822 | m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); | 849 | m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); |
823 | m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); | 850 | m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); |
824 | m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); | 851 | m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); |
825 | m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); | 852 | m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); |
826 | m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); | 853 | m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); |
827 | m_Intensity->setMaxValue( max ); | 854 | m_Intensity->setMaxValue( max ); |
828 | m_Intensity->setMinValue(min); | 855 | m_Intensity->setMinValue(min); |
829 | m_Intensity->setValue( current ); | 856 | m_Intensity->setValue( current ); |
830 | m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); | 857 | m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); |
831 | m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); | 858 | m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); |
832 | m_IntensityLabel->setText(QObject::tr("Display brightness:")); | 859 | m_IntensityLabel->setText(QObject::tr("Display brightness:")); |
833 | m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); | 860 | m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); |
834 | m_MainLayout->addLayout(m_IntensityLayout); | 861 | m_MainLayout->addLayout(m_IntensityLayout); |
835 | if (dlg.exec()) { | 862 | if (dlg.exec()) { |
836 | store = m_Intensity->value(); | 863 | store = m_Intensity->value(); |
837 | return true; | 864 | return true; |
838 | } | 865 | } |
839 | return false; | 866 | return false; |
840 | } | 867 | } |
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp index aa15d31..5680454 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp | |||
@@ -1,48 +1,48 @@ | |||
1 | #include "viewmodebutton.h" | 1 | #include "viewmodebutton.h" |
2 | 2 | ||
3 | /* OPIE */ | 3 | /* OPIE */ |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | using namespace Opie::Core; | 5 | using namespace Opie::Core; |
6 | 6 | ||
7 | /* QT */ | 7 | /* QT */ |
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | 10 | ||
11 | ViewModeButton::ViewModeButton( QToolBar* bar,int def ) | 11 | ViewModeButton::ViewModeButton( QToolBar* bar,int def ) |
12 | : QToolButton( bar ) | 12 | : QToolButton( bar ) |
13 | { | 13 | { |
14 | slotChange( def ); | 14 | slotChange( def ); |
15 | QPopupMenu *pop= new QPopupMenu( this ); | 15 | QPopupMenu *pop= new QPopupMenu( this ); |
16 | pop->setCheckable( true ); | 16 | pop->setCheckable( true ); |
17 | pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); | 17 | pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); |
18 | pop->insertItem( tr("Thumbnail and Name" ), 2 ); | 18 | pop->insertItem( tr("Thumbnail and Name" ), 2 ); |
19 | pop->insertItem( tr("Name Only" ), 3 ); | 19 | pop->insertItem( tr("Name Only" ), 3 ); |
20 | connect(pop, SIGNAL(activated(int)), | 20 | connect(pop, SIGNAL(activated(int)), |
21 | this, SIGNAL(changeMode(int)) ); | 21 | this, SIGNAL(changeMode(int)) ); |
22 | connect(pop, SIGNAL(activated(int)), | 22 | connect(pop, SIGNAL(activated(int)), |
23 | this, SLOT(slotChange(int)) ); | 23 | this, SLOT(slotChange(int)) ); |
24 | 24 | ||
25 | 25 | ||
26 | setPopup( pop ); | 26 | setPopup( pop ); |
27 | } | 27 | } |
28 | 28 | ||
29 | ViewModeButton::~ViewModeButton() { | 29 | ViewModeButton::~ViewModeButton() { |
30 | } | 30 | } |
31 | 31 | ||
32 | void ViewModeButton::slotChange( int i ) { | 32 | void ViewModeButton::slotChange( int i ) { |
33 | QString name; | 33 | QString name; |
34 | switch( i ) { | 34 | switch( i ) { |
35 | case 1: | 35 | case 1: |
36 | name = "opie-eye/opie-eye-thumb"; | 36 | name = "opie-eye/opie-eye-thumb"; |
37 | break; | 37 | break; |
38 | case 2: | 38 | case 2: |
39 | name = "opie-eye/opie-eye-thumbonly"; | 39 | name = "opie-eye/opie-eye-thumbonly"; |
40 | break; | 40 | break; |
41 | case 3: | 41 | case 3: |
42 | name = "opie-eye/opie-eye-textview"; | 42 | name = "opie-eye/opie-eye-textview"; |
43 | break; | 43 | break; |
44 | } | 44 | } |
45 | 45 | ||
46 | owarn << "foo " << name << oendl; | 46 | owarn << "foo " << name << oendl; |
47 | setIconSet( Resource::loadIconSet( name ) ); | 47 | setIconSet( Opie::Core::OResource::loadPixmap( name, Opie::Core::OResource::SmallIcon ) ); |
48 | } | 48 | } |
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.h b/noncore/graphics/opie-eye/gui/viewmodebutton.h index 48f0e67..1637888 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.h +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.h | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 only | 2 | * GPLv2 only |
3 | * zecke@handhelds.org | 3 | * zecke@handhelds.org |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_VIEW_MODE_BUTTON_H | 6 | #ifndef PHUNK_VIEW_MODE_BUTTON_H |
7 | #define PHUNK_VIEW_MODE_BUTTON_H | 7 | #define PHUNK_VIEW_MODE_BUTTON_H |
8 | 8 | ||
9 | #include <qpe/resource.h> | 9 | #include <opie2/oresource.h> |
10 | 10 | ||
11 | #include <qtoolbutton.h> | 11 | #include <qtoolbutton.h> |
12 | 12 | ||
13 | class ViewModeButton : public QToolButton { | 13 | class ViewModeButton : public QToolButton { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | ViewModeButton( QToolBar*,int def=1 ); | 16 | ViewModeButton( QToolBar*,int def=1 ); |
17 | ~ViewModeButton(); | 17 | ~ViewModeButton(); |
18 | 18 | ||
19 | signals: | 19 | signals: |
20 | void changeMode( int ); | 20 | void changeMode( int ); |
21 | private slots: | 21 | private slots: |
22 | void slotChange( int i ); | 22 | void slotChange( int i ); |
23 | }; | 23 | }; |
24 | 24 | ||
25 | #endif | 25 | #endif |