author | zecke <zecke> | 2005-06-14 21:29:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-06-14 21:29:17 (UTC) |
commit | 1c8aab0c489b9d469646a0e0ab08f500f1bbb507 (patch) (unidiff) | |
tree | 899752b16b9c00029ffd76696e6d87096a1e6d2e | |
parent | dc9c09480660793768851e36d089e0c36e7f3eae (diff) | |
download | opie-1c8aab0c489b9d469646a0e0ab08f500f1bbb507.zip opie-1c8aab0c489b9d469646a0e0ab08f500f1bbb507.tar.gz opie-1c8aab0c489b9d469646a0e0ab08f500f1bbb507.tar.bz2 |
Opie Eye:
-Change the keyboard shortcut configuration to not blacklist
keys found on the joypad (up,down,left,right,enter).
This was done on request of Gints Polis
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 4 |
3 files changed, 0 insertions, 15 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 9365932..ca5746d 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,780 +1,775 @@ | |||
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 | #include <opie2/oresource.h> |
20 | 20 | ||
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( Opie::Core::OResource::loadPixmap("advancedfm/FileBrowser", Opie::Core::OResource::SmallIcon)); | 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( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ) ); | 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() ); | ||
265 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | ||
266 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | ||
267 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | ||
268 | lst.append( Opie::Core::OKeyPair::returnKey() ); | ||
269 | 264 | ||
270 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 265 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
271 | lst, false,this, "keyconfig name" ); | 266 | lst, false,this, "keyconfig name" ); |
272 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 267 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
273 | Opie::Core::OResource::loadPixmap("beam", Opie::Core::OResource::SmallIcon), | 268 | Opie::Core::OResource::loadPixmap("beam", Opie::Core::OResource::SmallIcon), |
274 | BeamItem, Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 269 | BeamItem, Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
275 | this, SLOT(slotBeam())) ); | 270 | this, SLOT(slotBeam())) ); |
276 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 271 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
277 | Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), | 272 | Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), |
278 | DeleteItem, Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 273 | DeleteItem, Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
279 | this, SLOT(slotTrash())) ); | 274 | this, SLOT(slotTrash())) ); |
280 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 275 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
281 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), | 276 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
282 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 277 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
283 | this, SLOT(slotShowImage()))); | 278 | this, SLOT(slotShowImage()))); |
284 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 279 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
285 | Opie::Core::OResource::loadPixmap("DocumentTypeWord", Opie::Core::OResource::SmallIcon), | 280 | Opie::Core::OResource::loadPixmap("DocumentTypeWord", Opie::Core::OResource::SmallIcon), |
286 | InfoItem, Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 281 | InfoItem, Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
287 | this, SLOT(slotImageInfo()) ) ); | 282 | this, SLOT(slotImageInfo()) ) ); |
288 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", | 283 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", |
289 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), | 284 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
290 | SlideItem, Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), | 285 | SlideItem, Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), |
291 | this, SLOT(slotStartSlide()))); | 286 | this, SLOT(slotStartSlide()))); |
292 | m_viewManager->load(); | 287 | m_viewManager->load(); |
293 | m_viewManager->handleWidget( m_view ); | 288 | m_viewManager->handleWidget( m_view ); |
294 | } | 289 | } |
295 | 290 | ||
296 | 291 | ||
297 | /* | 292 | /* |
298 | * change one dir up | 293 | * change one dir up |
299 | */ | 294 | */ |
300 | void PIconView::slotDirUp() | 295 | void PIconView::slotDirUp() |
301 | { | 296 | { |
302 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); | 297 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); |
303 | } | 298 | } |
304 | 299 | ||
305 | /* | 300 | /* |
306 | * change the dir | 301 | * change the dir |
307 | */ | 302 | */ |
308 | void PIconView::slotChangeDir(const QString& path) { | 303 | void PIconView::slotChangeDir(const QString& path) { |
309 | if ( !currentView() ) | 304 | if ( !currentView() ) |
310 | return; | 305 | return; |
311 | 306 | ||
312 | PDirLister *lister = currentView()->dirLister(); | 307 | PDirLister *lister = currentView()->dirLister(); |
313 | if (!lister ) | 308 | if (!lister ) |
314 | return; | 309 | return; |
315 | 310 | ||
316 | /* | 311 | /* |
317 | * Say what we want and take what we get | 312 | * Say what we want and take what we get |
318 | */ | 313 | */ |
319 | lister->setStartPath( path ); | 314 | lister->setStartPath( path ); |
320 | m_path = lister->currentPath(); | 315 | m_path = lister->currentPath(); |
321 | 316 | ||
322 | m_view->viewport()->setUpdatesEnabled( false ); | 317 | m_view->viewport()->setUpdatesEnabled( false ); |
323 | m_view->clear(); | 318 | m_view->clear(); |
324 | 319 | ||
325 | // Also invalidate the cache. We can't cancel the operations anyway | 320 | // Also invalidate the cache. We can't cancel the operations anyway |
326 | g_stringPix.clear(); | 321 | g_stringPix.clear(); |
327 | g_stringInf.clear(); | 322 | g_stringInf.clear(); |
328 | 323 | ||
329 | /* | 324 | /* |
330 | * add files and folders | 325 | * add files and folders |
331 | */ | 326 | */ |
332 | addFolders( lister->folders() ); | 327 | addFolders( lister->folders() ); |
333 | addFiles( lister->files() ); | 328 | addFiles( lister->files() ); |
334 | m_view->viewport()->setUpdatesEnabled( true ); | 329 | m_view->viewport()->setUpdatesEnabled( true ); |
335 | 330 | ||
336 | // looks ugly | 331 | // looks ugly |
337 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 332 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
338 | } | 333 | } |
339 | 334 | ||
340 | /** | 335 | /** |
341 | * get the current file name | 336 | * get the current file name |
342 | * @param isDir see if this is a dir or real file | 337 | * @param isDir see if this is a dir or real file |
343 | */ | 338 | */ |
344 | QString PIconView::currentFileName(bool &isDir)const { | 339 | QString PIconView::currentFileName(bool &isDir)const { |
345 | isDir = false; | 340 | isDir = false; |
346 | QIconViewItem* _it = m_view->currentItem(); | 341 | QIconViewItem* _it = m_view->currentItem(); |
347 | if ( !_it ) | 342 | if ( !_it ) |
348 | return QString::null; | 343 | return QString::null; |
349 | 344 | ||
350 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 345 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
351 | isDir = it->isDir(); | 346 | isDir = it->isDir(); |
352 | return it->path(); | 347 | return it->path(); |
353 | } | 348 | } |
354 | 349 | ||
355 | QString PIconView::nextFileName(bool &isDir)const | 350 | QString PIconView::nextFileName(bool &isDir)const |
356 | { | 351 | { |
357 | isDir = false; | 352 | isDir = false; |
358 | QIconViewItem* _it1 = m_view->currentItem(); | 353 | QIconViewItem* _it1 = m_view->currentItem(); |
359 | if ( !_it1 ) | 354 | if ( !_it1 ) |
360 | return QString::null; | 355 | return QString::null; |
361 | QIconViewItem* _it = _it1->nextItem(); | 356 | QIconViewItem* _it = _it1->nextItem(); |
362 | if ( !_it ) | 357 | if ( !_it ) |
363 | return QString::null; | 358 | return QString::null; |
364 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 359 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
365 | isDir = it->isDir(); | 360 | isDir = it->isDir(); |
366 | return it->path(); | 361 | return it->path(); |
367 | } | 362 | } |
368 | 363 | ||
369 | QString PIconView::prevFileName(bool &isDir)const{ | 364 | QString PIconView::prevFileName(bool &isDir)const{ |
370 | isDir = false; | 365 | isDir = false; |
371 | QIconViewItem* _it = m_view->currentItem(); | 366 | QIconViewItem* _it = m_view->currentItem(); |
372 | if ( !_it ) | 367 | if ( !_it ) |
373 | return QString::null; | 368 | return QString::null; |
374 | _it = _it->prevItem(); | 369 | _it = _it->prevItem(); |
375 | if ( !_it ) | 370 | if ( !_it ) |
376 | return QString::null; | 371 | return QString::null; |
377 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 372 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
378 | isDir = it->isDir(); | 373 | isDir = it->isDir(); |
379 | return it->path(); | 374 | return it->path(); |
380 | } | 375 | } |
381 | 376 | ||
382 | void PIconView::slotTrash() { | 377 | void PIconView::slotTrash() { |
383 | bool isDir; | 378 | bool isDir; |
384 | QString pa = currentFileName( isDir ); | 379 | QString pa = currentFileName( isDir ); |
385 | if ( isDir || pa.isEmpty() ) | 380 | if ( isDir || pa.isEmpty() ) |
386 | return; | 381 | return; |
387 | 382 | ||
388 | if (!OMessageBox::confirmDelete( this, tr("the Image"), | 383 | if (!OMessageBox::confirmDelete( this, tr("the Image"), |
389 | pa, tr("Delete Image" ))) | 384 | pa, tr("Delete Image" ))) |
390 | return; | 385 | return; |
391 | 386 | ||
392 | 387 | ||
393 | currentView()->dirLister()->deleteImage( pa ); | 388 | currentView()->dirLister()->deleteImage( pa ); |
394 | delete m_view->currentItem(); | 389 | delete m_view->currentItem(); |
395 | } | 390 | } |
396 | 391 | ||
397 | /* | 392 | /* |
398 | * see what views are available | 393 | * see what views are available |
399 | */ | 394 | */ |
400 | void PIconView::loadViews() { | 395 | void PIconView::loadViews() { |
401 | ViewMap::Iterator it; | 396 | ViewMap::Iterator it; |
402 | ViewMap* map = viewMap(); | 397 | ViewMap* map = viewMap(); |
403 | for ( it = map->begin(); it != map->end(); ++it ) | 398 | for ( it = map->begin(); it != map->end(); ++it ) |
404 | m_views->insertItem( it.key() ); | 399 | m_views->insertItem( it.key() ); |
405 | } | 400 | } |
406 | 401 | ||
407 | void PIconView::resetView() { | 402 | void PIconView::resetView() { |
408 | m_internalReset = true; | 403 | m_internalReset = true; |
409 | // Also invalidate the cache. We can't cancel the operations anyway | 404 | // Also invalidate the cache. We can't cancel the operations anyway |
410 | g_stringPix.clear(); | 405 | g_stringPix.clear(); |
411 | g_stringInf.clear(); | 406 | g_stringInf.clear(); |
412 | if (m_mode>1) { | 407 | if (m_mode>1) { |
413 | int osize = m_iconsize; | 408 | int osize = m_iconsize; |
414 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 409 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
415 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; | 410 | if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; |
416 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; | 411 | if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; |
417 | if (osize != m_iconsize) { | 412 | if (osize != m_iconsize) { |
418 | if (_dirPix){ | 413 | if (_dirPix){ |
419 | delete _dirPix; | 414 | delete _dirPix; |
420 | _dirPix = 0; | 415 | _dirPix = 0; |
421 | } | 416 | } |
422 | if (_cpyPix){ | 417 | if (_cpyPix){ |
423 | delete _cpyPix; | 418 | delete _cpyPix; |
424 | _cpyPix = 0; | 419 | _cpyPix = 0; |
425 | } | 420 | } |
426 | calculateGrid(); | 421 | calculateGrid(); |
427 | } | 422 | } |
428 | } else { | 423 | } else { |
429 | m_iconsize = sDEF_ICON_SIZE; | 424 | m_iconsize = sDEF_ICON_SIZE; |
430 | } | 425 | } |
431 | slotViewChanged(m_views->currentItem()); | 426 | slotViewChanged(m_views->currentItem()); |
432 | m_internalReset = false; | 427 | m_internalReset = false; |
433 | } | 428 | } |
434 | 429 | ||
435 | void PIconView::polish() | 430 | void PIconView::polish() |
436 | { | 431 | { |
437 | QVBox::polish(); | 432 | QVBox::polish(); |
438 | 433 | ||
439 | QString lastView = m_cfg->readEntry("LastView",""); | 434 | QString lastView = m_cfg->readEntry("LastView",""); |
440 | int cc=0; | 435 | int cc=0; |
441 | for (; cc<m_views->count();++cc) { | 436 | for (; cc<m_views->count();++cc) { |
442 | if (m_views->text(cc)==lastView) { | 437 | if (m_views->text(cc)==lastView) { |
443 | break; | 438 | break; |
444 | } | 439 | } |
445 | } | 440 | } |
446 | if (cc<m_views->count()) { | 441 | if (cc<m_views->count()) { |
447 | m_views->setCurrentItem(cc); | 442 | m_views->setCurrentItem(cc); |
448 | slotViewChanged(cc); | 443 | slotViewChanged(cc); |
449 | } else { | 444 | } else { |
450 | slotViewChanged(m_views->currentItem()); | 445 | slotViewChanged(m_views->currentItem()); |
451 | } | 446 | } |
452 | connect( m_views, SIGNAL(activated(int)), | 447 | connect( m_views, SIGNAL(activated(int)), |
453 | this, SLOT(slotViewChanged(int)) ); | 448 | this, SLOT(slotViewChanged(int)) ); |
454 | } | 449 | } |
455 | 450 | ||
456 | /* | 451 | /* |
457 | *swicth view reloadDir and connect signals | 452 | *swicth view reloadDir and connect signals |
458 | */ | 453 | */ |
459 | void PIconView::slotViewChanged( int i) { | 454 | void PIconView::slotViewChanged( int i) { |
460 | if (!m_views->count() ) { | 455 | if (!m_views->count() ) { |
461 | setCurrentView( 0l); | 456 | setCurrentView( 0l); |
462 | return; | 457 | return; |
463 | } | 458 | } |
464 | 459 | ||
465 | if (m_customWidget) { | 460 | if (m_customWidget) { |
466 | delete m_customWidget; | 461 | delete m_customWidget; |
467 | m_customWidget = 0; | 462 | m_customWidget = 0; |
468 | } | 463 | } |
469 | PDirView* cur = currentView(); | 464 | PDirView* cur = currentView(); |
470 | if (cur) { | 465 | if (cur) { |
471 | delete cur; | 466 | delete cur; |
472 | } | 467 | } |
473 | QString str = m_views->text(i); | 468 | QString str = m_views->text(i); |
474 | ViewMap* map = viewMap(); | 469 | ViewMap* map = viewMap(); |
475 | if (!map) { | 470 | if (!map) { |
476 | setCurrentView(0l); | 471 | setCurrentView(0l); |
477 | return; | 472 | return; |
478 | } | 473 | } |
479 | 474 | ||
480 | if (map->find(str) == map->end()) { | 475 | if (map->find(str) == map->end()) { |
481 | owarn << "Key not found" << oendl; | 476 | owarn << "Key not found" << oendl; |
482 | setCurrentView(0l); | 477 | setCurrentView(0l); |
483 | return; | 478 | return; |
484 | } | 479 | } |
485 | 480 | ||
486 | m_cfg->writeEntry("LastView",str); | 481 | m_cfg->writeEntry("LastView",str); |
487 | m_cfg->write(); | 482 | m_cfg->write(); |
488 | cur = (*(*map)[str])(*m_cfg); | 483 | cur = (*(*map)[str])(*m_cfg); |
489 | setCurrentView( cur ); | 484 | setCurrentView( cur ); |
490 | m_customWidget = cur->widget(m_hbox); | 485 | m_customWidget = cur->widget(m_hbox); |
491 | if (m_customWidget) { | 486 | if (m_customWidget) { |
492 | odebug << "Got a widget" << oendl; | 487 | odebug << "Got a widget" << oendl; |
493 | m_customWidget->show(); | 488 | m_customWidget->show(); |
494 | } | 489 | } |
495 | 490 | ||
496 | /* connect to the signals of the lister */ | 491 | /* connect to the signals of the lister */ |
497 | PDirLister* lis = cur->dirLister(); | 492 | PDirLister* lis = cur->dirLister(); |
498 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 493 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
499 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 494 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
500 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 495 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
501 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 496 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
502 | connect(lis, SIGNAL(sig_start()), | 497 | connect(lis, SIGNAL(sig_start()), |
503 | this, SLOT(slotStart())); | 498 | this, SLOT(slotStart())); |
504 | connect(lis, SIGNAL(sig_end()) , | 499 | connect(lis, SIGNAL(sig_end()) , |
505 | this, SLOT(slotEnd()) ); | 500 | this, SLOT(slotEnd()) ); |
506 | connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); | 501 | connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); |
507 | 502 | ||
508 | /* reload now with default Path | 503 | /* reload now with default Path |
509 | * but only if it isn't a reset like from setupdlg | 504 | * but only if it isn't a reset like from setupdlg |
510 | */ | 505 | */ |
511 | if (!m_internalReset) { | 506 | if (!m_internalReset) { |
512 | m_path = lis->defaultPath(); | 507 | m_path = lis->defaultPath(); |
513 | } | 508 | } |
514 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 509 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
515 | } | 510 | } |
516 | 511 | ||
517 | 512 | ||
518 | void PIconView::slotReloadDir() { | 513 | void PIconView::slotReloadDir() { |
519 | slotChangeDir( m_path ); | 514 | slotChangeDir( m_path ); |
520 | } | 515 | } |
521 | 516 | ||
522 | 517 | ||
523 | /* | 518 | /* |
524 | * add files and folders | 519 | * add files and folders |
525 | */ | 520 | */ |
526 | void PIconView::addFolders( const QStringList& lst) { | 521 | void PIconView::addFolders( const QStringList& lst) { |
527 | QStringList::ConstIterator it; | 522 | QStringList::ConstIterator it; |
528 | IconViewItem * _iv; | 523 | IconViewItem * _iv; |
529 | 524 | ||
530 | for(it=lst.begin(); it != lst.end(); ++it ) { | 525 | for(it=lst.begin(); it != lst.end(); ++it ) { |
531 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); | 526 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); |
532 | if (m_mode==3) _iv->setTextOnly(true); | 527 | if (m_mode==3) _iv->setTextOnly(true); |
533 | } | 528 | } |
534 | } | 529 | } |
535 | 530 | ||
536 | void PIconView::addFiles( const QStringList& lst) { | 531 | void PIconView::addFiles( const QStringList& lst) { |
537 | QStringList::ConstIterator it; | 532 | QStringList::ConstIterator it; |
538 | IconViewItem * _iv; | 533 | IconViewItem * _iv; |
539 | QPixmap*m_pix = 0; | 534 | QPixmap*m_pix = 0; |
540 | QString pre = ""; | 535 | QString pre = ""; |
541 | if (!m_path.isEmpty()) { | 536 | if (!m_path.isEmpty()) { |
542 | pre = m_path+"/"; | 537 | pre = m_path+"/"; |
543 | } | 538 | } |
544 | QString s = ""; | 539 | QString s = ""; |
545 | int pos; | 540 | int pos; |
546 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 541 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
547 | s = (*it); | 542 | s = (*it); |
548 | pos = s.find(char(0)); | 543 | pos = s.find(char(0)); |
549 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); | 544 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); |
550 | if (pos>-1) { | 545 | if (pos>-1) { |
551 | _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); | 546 | _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); |
552 | } else { | 547 | } else { |
553 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); | 548 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); |
554 | } | 549 | } |
555 | if (m_mode==3) { | 550 | if (m_mode==3) { |
556 | _iv->setTextOnly(true); | 551 | _iv->setTextOnly(true); |
557 | _iv->setPixmap(QPixmap()); | 552 | _iv->setPixmap(QPixmap()); |
558 | } else { | 553 | } else { |
559 | if (m_pix) _iv->setPixmap(*m_pix); | 554 | if (m_pix) _iv->setPixmap(*m_pix); |
560 | } | 555 | } |
561 | } | 556 | } |
562 | 557 | ||
563 | } | 558 | } |
564 | 559 | ||
565 | /* | 560 | /* |
566 | * user clicked on the item. Change dir or view | 561 | * user clicked on the item. Change dir or view |
567 | */ | 562 | */ |
568 | void PIconView::slotClicked(QIconViewItem* _it) { | 563 | void PIconView::slotClicked(QIconViewItem* _it) { |
569 | if(!_it ) | 564 | if(!_it ) |
570 | return; | 565 | return; |
571 | 566 | ||
572 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 567 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
573 | if( it->isDir() ) | 568 | if( it->isDir() ) |
574 | slotChangeDir( it->path() ); | 569 | slotChangeDir( it->path() ); |
575 | else // view image | 570 | else // view image |
576 | slotShowImage(); | 571 | slotShowImage(); |
577 | } | 572 | } |
578 | 573 | ||
579 | /* | 574 | /* |
580 | * Return was pressed. which is triggered by the keydown | 575 | * Return was pressed. which is triggered by the keydown |
581 | * handler. The problem is that the key up will be handled | 576 | * handler. The problem is that the key up will be handled |
582 | * by the ImageDisplayer and goes to the next image | 577 | * by the ImageDisplayer and goes to the next image |
583 | */ | 578 | */ |
584 | void PIconView::slotRetrun( QIconViewItem *_it ) { | 579 | void PIconView::slotRetrun( QIconViewItem *_it ) { |
585 | if(!_it ) | 580 | if(!_it ) |
586 | return; | 581 | return; |
587 | 582 | ||
588 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 583 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
589 | if( it->isDir() ) | 584 | if( it->isDir() ) |
590 | slotChangeDir( it->path() ); | 585 | slotChangeDir( it->path() ); |
591 | else | 586 | else |
592 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); | 587 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); |
593 | } | 588 | } |
594 | 589 | ||
595 | /* | 590 | /* |
596 | * got thumb info add to the cache if items is visible | 591 | * got thumb info add to the cache if items is visible |
597 | * we later need update after processing of slave is done | 592 | * we later need update after processing of slave is done |
598 | */ | 593 | */ |
599 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 594 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
600 | IconViewItem* item = g_stringInf[_path]; | 595 | IconViewItem* item = g_stringInf[_path]; |
601 | if (!item ) | 596 | if (!item ) |
602 | return; | 597 | return; |
603 | 598 | ||
604 | if (m_mode == 2) { | 599 | if (m_mode == 2) { |
605 | return; | 600 | return; |
606 | } | 601 | } |
607 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 602 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
608 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 603 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
609 | m_updatet = true; | 604 | m_updatet = true; |
610 | 605 | ||
611 | item->setText( str ); | 606 | item->setText( str ); |
612 | g_stringInf.remove( _path ); | 607 | g_stringInf.remove( _path ); |
613 | } | 608 | } |
614 | 609 | ||
615 | /* | 610 | /* |
616 | * got thumbnail and see if it is visible so we need to update later | 611 | * got thumbnail and see if it is visible so we need to update later |
617 | */ | 612 | */ |
618 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 613 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
619 | IconViewItem* item = g_stringPix[_path]; | 614 | IconViewItem* item = g_stringPix[_path]; |
620 | if (!item ) | 615 | if (!item ) |
621 | return; | 616 | return; |
622 | 617 | ||
623 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 618 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
624 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 619 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
625 | m_updatet = true; | 620 | m_updatet = true; |
626 | 621 | ||
627 | if (pix.width()>0) { | 622 | if (pix.width()>0) { |
628 | if (pix.width()<m_iconsize) { | 623 | if (pix.width()<m_iconsize) { |
629 | QPixmap p(m_iconsize,m_iconsize); | 624 | QPixmap p(m_iconsize,m_iconsize); |
630 | p.fill(); | 625 | p.fill(); |
631 | QPainter pa(&p); | 626 | QPainter pa(&p); |
632 | int offset = (m_iconsize-pix.width())/2; | 627 | int offset = (m_iconsize-pix.width())/2; |
633 | int offy = (m_iconsize-pix.height())/2; | 628 | int offy = (m_iconsize-pix.height())/2; |
634 | if (offy<0) offy=0; | 629 | if (offy<0) offy=0; |
635 | pa.drawPixmap(offset,offy,pix); | 630 | pa.drawPixmap(offset,offy,pix); |
636 | pa.end(); | 631 | pa.end(); |
637 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); | 632 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); |
638 | item->setPixmap(p,true); | 633 | item->setPixmap(p,true); |
639 | } else { | 634 | } else { |
640 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); | 635 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); |
641 | item->setPixmap(pix,true); | 636 | item->setPixmap(pix,true); |
642 | } | 637 | } |
643 | 638 | ||
644 | } else { | 639 | } else { |
645 | PPixmapCache::self()->insertImage( _path, Opie::Core::OResource::loadPixmap( "UnknownDocument", | 640 | PPixmapCache::self()->insertImage( _path, Opie::Core::OResource::loadPixmap( "UnknownDocument", |
646 | Opie::Core::OResource::SmallIcon ), m_iconsize, m_iconsize ); | 641 | Opie::Core::OResource::SmallIcon ), m_iconsize, m_iconsize ); |
647 | } | 642 | } |
648 | g_stringPix.remove( _path ); | 643 | g_stringPix.remove( _path ); |
649 | m_view->arrangeItemsInGrid(true); | 644 | m_view->arrangeItemsInGrid(true); |
650 | } | 645 | } |
651 | 646 | ||
652 | 647 | ||
653 | /* | 648 | /* |
654 | * FIXME rename | 649 | * FIXME rename |
655 | */ | 650 | */ |
656 | void PIconView::slotRename() { | 651 | void PIconView::slotRename() { |
657 | 652 | ||
658 | } | 653 | } |
659 | 654 | ||
660 | 655 | ||
661 | /* | 656 | /* |
662 | * BEAM the current file | 657 | * BEAM the current file |
663 | */ | 658 | */ |
664 | void PIconView::slotBeam() { | 659 | void PIconView::slotBeam() { |
665 | bool isDir; | 660 | bool isDir; |
666 | QString pa = currentFileName( isDir ); | 661 | QString pa = currentFileName( isDir ); |
667 | if ( isDir && pa.isEmpty() ) | 662 | if ( isDir && pa.isEmpty() ) |
668 | return; | 663 | return; |
669 | 664 | ||
670 | Ir* ir = new Ir( this ); | 665 | Ir* ir = new Ir( this ); |
671 | connect( ir, SIGNAL(done(Ir*)), | 666 | connect( ir, SIGNAL(done(Ir*)), |
672 | this, SLOT(slotBeamDone(Ir*))); | 667 | this, SLOT(slotBeamDone(Ir*))); |
673 | ir->send(pa, tr( "Image" ) ); | 668 | ir->send(pa, tr( "Image" ) ); |
674 | } | 669 | } |
675 | 670 | ||
676 | /* | 671 | /* |
677 | * BEAM done clean up | 672 | * BEAM done clean up |
678 | */ | 673 | */ |
679 | void PIconView::slotBeamDone( Ir* ir) { | 674 | void PIconView::slotBeamDone( Ir* ir) { |
680 | delete ir; | 675 | delete ir; |
681 | } | 676 | } |
682 | 677 | ||
683 | void PIconView::slotStart() { | 678 | void PIconView::slotStart() { |
684 | m_view->viewport()->setUpdatesEnabled( false ); | 679 | m_view->viewport()->setUpdatesEnabled( false ); |
685 | } | 680 | } |
686 | 681 | ||
687 | void PIconView::slotEnd() { | 682 | void PIconView::slotEnd() { |
688 | if ( m_updatet ) | 683 | if ( m_updatet ) |
689 | m_view->arrangeItemsInGrid( ); | 684 | m_view->arrangeItemsInGrid( ); |
690 | m_view->viewport()->setUpdatesEnabled( true ); | 685 | m_view->viewport()->setUpdatesEnabled( true ); |
691 | m_updatet = false; | 686 | m_updatet = false; |
692 | } | 687 | } |
693 | 688 | ||
694 | void PIconView::slotShowLast() | 689 | void PIconView::slotShowLast() |
695 | { | 690 | { |
696 | QIconViewItem* last_it = m_view->lastItem(); | 691 | QIconViewItem* last_it = m_view->lastItem(); |
697 | if (!last_it) return; | 692 | if (!last_it) return; |
698 | m_view->setCurrentItem(last_it); | 693 | m_view->setCurrentItem(last_it); |
699 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); | 694 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); |
700 | bool isDir = it->isDir(); | 695 | bool isDir = it->isDir(); |
701 | QString name = it->path(); | 696 | QString name = it->path(); |
702 | if (!isDir && !name.isEmpty()) { | 697 | if (!isDir && !name.isEmpty()) { |
703 | slotShowImage(name); | 698 | slotShowImage(name); |
704 | return; | 699 | return; |
705 | } | 700 | } |
706 | bool first_loop = true; | 701 | bool first_loop = true; |
707 | while(isDir==true) { | 702 | while(isDir==true) { |
708 | if (!first_loop) { | 703 | if (!first_loop) { |
709 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 704 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
710 | } else { | 705 | } else { |
711 | first_loop = false; | 706 | first_loop = false; |
712 | } | 707 | } |
713 | name = prevFileName(isDir); | 708 | name = prevFileName(isDir); |
714 | } | 709 | } |
715 | 710 | ||
716 | if (name.isEmpty()) return; | 711 | if (name.isEmpty()) return; |
717 | /* if we got a name we have a prev item */ | 712 | /* if we got a name we have a prev item */ |
718 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 713 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
719 | slotShowImage(name); | 714 | slotShowImage(name); |
720 | } | 715 | } |
721 | 716 | ||
722 | bool PIconView::slotShowFirst() | 717 | bool PIconView::slotShowFirst() |
723 | { | 718 | { |
724 | /* stop when reached - otherwise we may get an endless loop */ | 719 | /* stop when reached - otherwise we may get an endless loop */ |
725 | QIconViewItem* first_it = m_view->firstItem(); | 720 | QIconViewItem* first_it = m_view->firstItem(); |
726 | if (!first_it) return false; | 721 | if (!first_it) return false; |
727 | m_view->setCurrentItem(first_it); | 722 | m_view->setCurrentItem(first_it); |
728 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); | 723 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); |
729 | bool isDir = it->isDir(); | 724 | bool isDir = it->isDir(); |
730 | QString name = it->path(); | 725 | QString name = it->path(); |
731 | if (!isDir && !name.isEmpty()) { | 726 | if (!isDir && !name.isEmpty()) { |
732 | slotShowImage(name); | 727 | slotShowImage(name); |
733 | return false; | 728 | return false; |
734 | } | 729 | } |
735 | bool first_loop = true; | 730 | bool first_loop = true; |
736 | while(isDir==true) { | 731 | while(isDir==true) { |
737 | /* if name is empty isDir is false, too. */ | 732 | /* if name is empty isDir is false, too. */ |
738 | if (!first_loop) { | 733 | if (!first_loop) { |
739 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 734 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
740 | } else { | 735 | } else { |
741 | first_loop = false; | 736 | first_loop = false; |
742 | } | 737 | } |
743 | name = nextFileName(isDir); | 738 | name = nextFileName(isDir); |
744 | } | 739 | } |
745 | if (name.isEmpty()) return false; | 740 | if (name.isEmpty()) return false; |
746 | /* if we got a name we have a next item */ | 741 | /* if we got a name we have a next item */ |
747 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 742 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
748 | slotShowImage(name); | 743 | slotShowImage(name); |
749 | return true; | 744 | return true; |
750 | } | 745 | } |
751 | 746 | ||
752 | void PIconView::slotShowNext() | 747 | void PIconView::slotShowNext() |
753 | { | 748 | { |
754 | bool isDir = false; | 749 | bool isDir = false; |
755 | QString name = nextFileName(isDir); | 750 | QString name = nextFileName(isDir); |
756 | while (isDir==true) { | 751 | while (isDir==true) { |
757 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 752 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
758 | name = nextFileName(isDir); | 753 | name = nextFileName(isDir); |
759 | } | 754 | } |
760 | if (name.isEmpty()) { | 755 | if (name.isEmpty()) { |
761 | slotShowFirst(); | 756 | slotShowFirst(); |
762 | return; | 757 | return; |
763 | } | 758 | } |
764 | if (isDir) return; | 759 | if (isDir) return; |
765 | /* if we got a name we have a next item */ | 760 | /* if we got a name we have a next item */ |
766 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 761 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
767 | slotShowImage(name); | 762 | slotShowImage(name); |
768 | } | 763 | } |
769 | 764 | ||
770 | void PIconView::slotShowPrev() | 765 | void PIconView::slotShowPrev() |
771 | { | 766 | { |
772 | bool isDir = false; | 767 | bool isDir = false; |
773 | QString name = prevFileName(isDir); | 768 | QString name = prevFileName(isDir); |
774 | while (isDir==true) { | 769 | while (isDir==true) { |
775 | /* if name is empty isDir is false, too. */ | 770 | /* if name is empty isDir is false, too. */ |
776 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 771 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
777 | name = prevFileName(isDir); | 772 | name = prevFileName(isDir); |
778 | } | 773 | } |
779 | if (name.isEmpty()) { | 774 | if (name.isEmpty()) { |
780 | slotShowLast(); | 775 | slotShowLast(); |
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp index 8f70602..8e31521 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp +++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp | |||
@@ -1,204 +1,198 @@ | |||
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 | #include <opie2/oresource.h> |
23 | 23 | ||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.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() ); | ||
67 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | ||
68 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | ||
69 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | ||
70 | lst.append( Opie::Core::OKeyPair::returnKey() ); | ||
71 | |||
72 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "imageinfo_keys", | 66 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "imageinfo_keys", |
73 | lst, false,this, "keyconfig name" ); | 67 | lst, false,this, "keyconfig name" ); |
74 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Full Image"), "infoview", | 68 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Full Image"), "infoview", |
75 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), | 69 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
76 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 70 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
77 | this, SLOT(slotShowImage()))); | 71 | this, SLOT(slotShowImage()))); |
78 | m_viewManager->load(); | 72 | m_viewManager->load(); |
79 | m_viewManager->handleWidget( this ); | 73 | m_viewManager->handleWidget( this ); |
80 | m_viewManager->handleWidget( TextView1 ); | 74 | m_viewManager->handleWidget( TextView1 ); |
81 | } | 75 | } |
82 | 76 | ||
83 | void imageinfo::slotShowImage() | 77 | void imageinfo::slotShowImage() |
84 | { | 78 | { |
85 | emit dispImage(currentFile); | 79 | emit dispImage(currentFile); |
86 | } | 80 | } |
87 | 81 | ||
88 | void imageinfo::init(const char* name) { | 82 | void imageinfo::init(const char* name) { |
89 | { | 83 | { |
90 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 84 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
91 | } | 85 | } |
92 | if ( !name ) | 86 | if ( !name ) |
93 | setName( "imageinfo" ); | 87 | setName( "imageinfo" ); |
94 | resize( 289, 335 ); | 88 | resize( 289, 335 ); |
95 | setCaption( tr( "Image info" ) ); | 89 | setCaption( tr( "Image info" ) ); |
96 | imageinfoLayout = new QVBoxLayout( this ); | 90 | imageinfoLayout = new QVBoxLayout( this ); |
97 | imageinfoLayout->setSpacing(2); | 91 | imageinfoLayout->setSpacing(2); |
98 | imageinfoLayout->setMargin(4); | 92 | imageinfoLayout->setMargin(4); |
99 | 93 | ||
100 | PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); | 94 | PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); |
101 | PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); | 95 | PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); |
102 | QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); | 96 | QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); |
103 | 97 | ||
104 | imageinfoLayout->addWidget( PixmapLabel1 ); | 98 | imageinfoLayout->addWidget( PixmapLabel1 ); |
105 | 99 | ||
106 | Line1 = new QFrame( this, "Line1" ); | 100 | Line1 = new QFrame( this, "Line1" ); |
107 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 101 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
108 | imageinfoLayout->addWidget( Line1 ); | 102 | imageinfoLayout->addWidget( Line1 ); |
109 | 103 | ||
110 | fnameLabel = new QLabel( this, "FnameLabel" ); | 104 | fnameLabel = new QLabel( this, "FnameLabel" ); |
111 | imageinfoLayout->addWidget( fnameLabel); | 105 | imageinfoLayout->addWidget( fnameLabel); |
112 | 106 | ||
113 | TextView1 = new QTextView( this, "TextView1" ); | 107 | TextView1 = new QTextView( this, "TextView1" ); |
114 | TextView1->setFrameShadow( QTextView::Sunken ); | 108 | TextView1->setFrameShadow( QTextView::Sunken ); |
115 | TextView1->setResizePolicy( QTextView::AutoOneFit ); | 109 | TextView1->setResizePolicy( QTextView::AutoOneFit ); |
116 | TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); | 110 | TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); |
117 | TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); | 111 | TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); |
118 | // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); | 112 | // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); |
119 | QWhatsThis::add( TextView1, tr("Displays info of selected image") ); | 113 | QWhatsThis::add( TextView1, tr("Displays info of selected image") ); |
120 | imageinfoLayout->addWidget( TextView1 ); | 114 | imageinfoLayout->addWidget( TextView1 ); |
121 | 115 | ||
122 | SlaveMaster* master = SlaveMaster::self(); | 116 | SlaveMaster* master = SlaveMaster::self(); |
123 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 117 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
124 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); | 118 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); |
125 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 119 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
126 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 120 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
127 | } | 121 | } |
128 | 122 | ||
129 | void imageinfo::slotChangeName(const QString&_path) | 123 | void imageinfo::slotChangeName(const QString&_path) |
130 | { | 124 | { |
131 | currentFile=_path; | 125 | currentFile=_path; |
132 | QFileInfo fi(_path); | 126 | QFileInfo fi(_path); |
133 | fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); | 127 | fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); |
134 | SlaveMaster::self()->imageInfo( currentFile ); | 128 | SlaveMaster::self()->imageInfo( currentFile ); |
135 | 129 | ||
136 | QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); | 130 | QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); |
137 | if (!m_pix) { | 131 | if (!m_pix) { |
138 | PixmapLabel1->setPixmap(QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ))); | 132 | PixmapLabel1->setPixmap(QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ))); |
139 | SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); | 133 | SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); |
140 | } else { | 134 | } else { |
141 | PixmapLabel1->setPixmap(*m_pix); | 135 | PixmapLabel1->setPixmap(*m_pix); |
142 | } | 136 | } |
143 | } | 137 | } |
144 | 138 | ||
145 | imageinfo::~imageinfo() | 139 | imageinfo::~imageinfo() |
146 | { | 140 | { |
147 | { | 141 | { |
148 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 142 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
149 | } | 143 | } |
150 | if (m_viewManager) { | 144 | if (m_viewManager) { |
151 | delete m_viewManager; | 145 | delete m_viewManager; |
152 | } | 146 | } |
153 | } | 147 | } |
154 | 148 | ||
155 | void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) | 149 | void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) |
156 | { | 150 | { |
157 | if (_path == currentFile) { | 151 | if (_path == currentFile) { |
158 | odebug << _t << oendl; | 152 | odebug << _t << oendl; |
159 | QString t = _t; | 153 | QString t = _t; |
160 | t.replace(QRegExp("\n"),"<br>"); | 154 | t.replace(QRegExp("\n"),"<br>"); |
161 | TextView1->setText(t); | 155 | TextView1->setText(t); |
162 | } | 156 | } |
163 | } | 157 | } |
164 | 158 | ||
165 | void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) | 159 | void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) |
166 | { | 160 | { |
167 | if (_path == currentFile) { | 161 | if (_path == currentFile) { |
168 | if (_pix.width()>0) { | 162 | if (_pix.width()>0) { |
169 | PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); | 163 | PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); |
170 | PixmapLabel1->setPixmap( _pix ); | 164 | PixmapLabel1->setPixmap( _pix ); |
171 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); | 165 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); |
172 | } | 166 | } |
173 | } | 167 | } |
174 | } | 168 | } |
175 | 169 | ||
176 | void imageinfo::setPath( const QString& str ) { | 170 | void imageinfo::setPath( const QString& str ) { |
177 | slotChangeName( str ); | 171 | slotChangeName( str ); |
178 | } | 172 | } |
179 | 173 | ||
180 | void imageinfo::setDestructiveClose() { | 174 | void imageinfo::setDestructiveClose() { |
181 | WFlags fl = getWFlags(); | 175 | WFlags fl = getWFlags(); |
182 | /* clear it just in case */ | 176 | /* clear it just in case */ |
183 | fl &= ~WDestructiveClose; | 177 | fl &= ~WDestructiveClose; |
184 | fl |= WDestructiveClose; | 178 | fl |= WDestructiveClose; |
185 | setWFlags( fl ); | 179 | setWFlags( fl ); |
186 | } | 180 | } |
187 | 181 | ||
188 | 182 | ||
189 | /* for testing */ | 183 | /* for testing */ |
190 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) | 184 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) |
191 | :QDialog(parent,name,true,WStyle_ContextHelp) | 185 | :QDialog(parent,name,true,WStyle_ContextHelp) |
192 | { | 186 | { |
193 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 187 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
194 | dlglayout->setSpacing(2); | 188 | dlglayout->setSpacing(2); |
195 | dlglayout->setMargin(1); | 189 | dlglayout->setMargin(1); |
196 | imageinfo*inf = new imageinfo(fname,this); | 190 | imageinfo*inf = new imageinfo(fname,this); |
197 | dlglayout->addWidget(inf); | 191 | dlglayout->addWidget(inf); |
198 | } | 192 | } |
199 | 193 | ||
200 | infoDlg::~infoDlg() | 194 | infoDlg::~infoDlg() |
201 | { | 195 | { |
202 | } | 196 | } |
203 | 197 | ||
204 | 198 | ||
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index cda1a96..ec891a8 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,318 +1,314 @@ | |||
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 | #include <opie2/oresource.h> |
7 | 7 | ||
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() ); | ||
149 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | ||
150 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | ||
151 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | ||
152 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); | 148 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); |
153 | 149 | ||
154 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 150 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
155 | lst, false,this, "image_view_keys" ); | 151 | lst, false,this, "image_view_keys" ); |
156 | 152 | ||
157 | /** | 153 | /** |
158 | * Handle KeyEvents when they're pressed. This avoids problems | 154 | * Handle KeyEvents when they're pressed. This avoids problems |
159 | * with 'double next' on Return. | 155 | * with 'double next' on Return. |
160 | * The Return press would switch to this view and the return | 156 | * The Return press would switch to this view and the return |
161 | * release would emit the dispNext Signal. | 157 | * release would emit the dispNext Signal. |
162 | */ | 158 | */ |
163 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); | 159 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); |
164 | 160 | ||
165 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 161 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
166 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), | 162 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
167 | ViewInfo, Opie::Core::OKeyPair(Qt::Key_I,0), | 163 | ViewInfo, Opie::Core::OKeyPair(Qt::Key_I,0), |
168 | this, SLOT(slotShowImageInfo()))); | 164 | this, SLOT(slotShowImageInfo()))); |
169 | 165 | ||
170 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", | 166 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", |
171 | Opie::Core::OResource::loadPixmap("rotate", Opie::Core::OResource::SmallIcon), | 167 | Opie::Core::OResource::loadPixmap("rotate", Opie::Core::OResource::SmallIcon), |
172 | Autorotate, Opie::Core::OKeyPair(Qt::Key_R,0), | 168 | Autorotate, Opie::Core::OKeyPair(Qt::Key_R,0), |
173 | this, SIGNAL(toggleAutorotate()))); | 169 | this, SIGNAL(toggleAutorotate()))); |
174 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", | 170 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", |
175 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), | 171 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
176 | Autoscale, Opie::Core::OKeyPair(Qt::Key_S,0), | 172 | Autoscale, Opie::Core::OKeyPair(Qt::Key_S,0), |
177 | this, SIGNAL(toggleAutoscale()))); | 173 | this, SIGNAL(toggleAutoscale()))); |
178 | 174 | ||
179 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", | 175 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", |
180 | Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), | 176 | Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), |
181 | ShowNext, Opie::Core::OKeyPair(Qt::Key_Return,0), | 177 | ShowNext, Opie::Core::OKeyPair(Qt::Key_Return,0), |
182 | this, SIGNAL(dispNext()))); | 178 | this, SIGNAL(dispNext()))); |
183 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", | 179 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", |
184 | Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), | 180 | Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), |
185 | ShowPrevious, Opie::Core::OKeyPair(Qt::Key_P,0), | 181 | ShowPrevious, Opie::Core::OKeyPair(Qt::Key_P,0), |
186 | this, SIGNAL(dispPrev()))); | 182 | this, SIGNAL(dispPrev()))); |
187 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", | 183 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", |
188 | Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), | 184 | Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), |
189 | FullScreen, Opie::Core::OKeyPair(Qt::Key_F,0), | 185 | FullScreen, Opie::Core::OKeyPair(Qt::Key_F,0), |
190 | this, SIGNAL(toggleFullScreen()))); | 186 | this, SIGNAL(toggleFullScreen()))); |
191 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", | 187 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", |
192 | Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), | 188 | Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), |
193 | Zoomer, Opie::Core::OKeyPair(Qt::Key_T,0), | 189 | Zoomer, Opie::Core::OKeyPair(Qt::Key_T,0), |
194 | this, SIGNAL(toggleZoomer()))); | 190 | this, SIGNAL(toggleZoomer()))); |
195 | 191 | ||
196 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness", | 192 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness", |
197 | Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon), | 193 | Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon), |
198 | Incbrightness, Opie::Core::OKeyPair(Qt::Key_B,0), | 194 | Incbrightness, Opie::Core::OKeyPair(Qt::Key_B,0), |
199 | this, SIGNAL(incBrightness()))); | 195 | this, SIGNAL(incBrightness()))); |
200 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness", | 196 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness", |
201 | Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon), | 197 | Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon), |
202 | Decbrightness, Opie::Core::OKeyPair(Qt::Key_D,0), | 198 | Decbrightness, Opie::Core::OKeyPair(Qt::Key_D,0), |
203 | this, SIGNAL(decBrightness()))); | 199 | this, SIGNAL(decBrightness()))); |
204 | m_viewManager->handleWidget( this ); | 200 | m_viewManager->handleWidget( this ); |
205 | m_viewManager->load(); | 201 | m_viewManager->load(); |
206 | } | 202 | } |
207 | 203 | ||
208 | void ImageView::keyReleaseEvent(QKeyEvent * e) | 204 | void ImageView::keyReleaseEvent(QKeyEvent * e) |
209 | { | 205 | { |
210 | if (!e || e->state()!=0) { | 206 | if (!e || e->state()!=0) { |
211 | return; | 207 | return; |
212 | } | 208 | } |
213 | if (e->key()==Qt::Key_Escape) { | 209 | if (e->key()==Qt::Key_Escape) { |
214 | if (fullScreen()) { | 210 | if (fullScreen()) { |
215 | emit hideMe(); | 211 | emit hideMe(); |
216 | } | 212 | } |
217 | if (closeIfHide) { | 213 | if (closeIfHide) { |
218 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 214 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
219 | } | 215 | } |
220 | } | 216 | } |
221 | } | 217 | } |
222 | 218 | ||
223 | void ImageView::setCloseIfHide(bool how) | 219 | void ImageView::setCloseIfHide(bool how) |
224 | { | 220 | { |
225 | closeIfHide = how; | 221 | closeIfHide = how; |
226 | } | 222 | } |
227 | 223 | ||
228 | void ImageView::slotShowImageInfo() | 224 | void ImageView::slotShowImageInfo() |
229 | { | 225 | { |
230 | emit dispImageInfo(m_lastName); | 226 | emit dispImageInfo(m_lastName); |
231 | } | 227 | } |
232 | 228 | ||
233 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) | 229 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) |
234 | { | 230 | { |
235 | if (e->button()==1) { | 231 | if (e->button()==1) { |
236 | return OImageScrollView::contentsMousePressEvent(e); | 232 | return OImageScrollView::contentsMousePressEvent(e); |
237 | } | 233 | } |
238 | QPopupMenu *m = new QPopupMenu(this); | 234 | QPopupMenu *m = new QPopupMenu(this); |
239 | if (!m) return; | 235 | if (!m) return; |
240 | if (m_hGroup) { | 236 | if (m_hGroup) { |
241 | m_hGroup->addTo(m); | 237 | m_hGroup->addTo(m); |
242 | } | 238 | } |
243 | if (fullScreen()) { | 239 | if (fullScreen()) { |
244 | if (m_gPrevNext) { | 240 | if (m_gPrevNext) { |
245 | m->insertSeparator(); | 241 | m->insertSeparator(); |
246 | m_gPrevNext->addTo(m); | 242 | m_gPrevNext->addTo(m); |
247 | } | 243 | } |
248 | if (m_gDisplayType) { | 244 | if (m_gDisplayType) { |
249 | m->insertSeparator(); | 245 | m->insertSeparator(); |
250 | m_gDisplayType->addTo(m); | 246 | m_gDisplayType->addTo(m); |
251 | } | 247 | } |
252 | if (m_gBright) { | 248 | if (m_gBright) { |
253 | m->insertSeparator(); | 249 | m->insertSeparator(); |
254 | m_gBright->addTo(m); | 250 | m_gBright->addTo(m); |
255 | } | 251 | } |
256 | } | 252 | } |
257 | m->setFocus(); | 253 | m->setFocus(); |
258 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 254 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
259 | if (m_hGroup) { | 255 | if (m_hGroup) { |
260 | m_hGroup->removeFrom(m); | 256 | m_hGroup->removeFrom(m); |
261 | } | 257 | } |
262 | if (m_gPrevNext) { | 258 | if (m_gPrevNext) { |
263 | m_gPrevNext->removeFrom(m); | 259 | m_gPrevNext->removeFrom(m); |
264 | } | 260 | } |
265 | if (m_gDisplayType) { | 261 | if (m_gDisplayType) { |
266 | m_gDisplayType->removeFrom(m); | 262 | m_gDisplayType->removeFrom(m); |
267 | } | 263 | } |
268 | if (m_gBright) { | 264 | if (m_gBright) { |
269 | m_gBright->removeFrom(m); | 265 | m_gBright->removeFrom(m); |
270 | } | 266 | } |
271 | delete m; | 267 | delete m; |
272 | } | 268 | } |
273 | 269 | ||
274 | void ImageView::setFullScreen(bool how,bool force) | 270 | void ImageView::setFullScreen(bool how,bool force) |
275 | { | 271 | { |
276 | m_isFullScreen = how; | 272 | m_isFullScreen = how; |
277 | if (how) { | 273 | if (how) { |
278 | m_ignore_next_in = true; | 274 | m_ignore_next_in = true; |
279 | // setFixedSize(qApp->desktop()->size()); | 275 | // setFixedSize(qApp->desktop()->size()); |
280 | setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); | 276 | setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); |
281 | if (force) showFullScreen(); | 277 | if (force) showFullScreen(); |
282 | } else { | 278 | } else { |
283 | // setMinimumSize(10,10); | 279 | // setMinimumSize(10,10); |
284 | } | 280 | } |
285 | } | 281 | } |
286 | 282 | ||
287 | void ImageView::focusInEvent(QFocusEvent *) | 283 | void ImageView::focusInEvent(QFocusEvent *) |
288 | { | 284 | { |
289 | // Always do it here, no matter the size. | 285 | // Always do it here, no matter the size. |
290 | //if (fullScreen()) parentWidget()->showNormal(); | 286 | //if (fullScreen()) parentWidget()->showNormal(); |
291 | if (m_ignore_next_in){m_ignore_next_in=false;return;} | 287 | if (m_ignore_next_in){m_ignore_next_in=false;return;} |
292 | if (fullScreen()) enableFullscreen(); | 288 | if (fullScreen()) enableFullscreen(); |
293 | } | 289 | } |
294 | 290 | ||
295 | void ImageView::hide() | 291 | void ImageView::hide() |
296 | { | 292 | { |
297 | if (fullScreen()) { | 293 | if (fullScreen()) { |
298 | m_ignore_next_in = true; | 294 | m_ignore_next_in = true; |
299 | showNormal(); | 295 | showNormal(); |
300 | } | 296 | } |
301 | QWidget::hide(); | 297 | QWidget::hide(); |
302 | } | 298 | } |
303 | void ImageView::enableFullscreen() | 299 | void ImageView::enableFullscreen() |
304 | { | 300 | { |
305 | if (!fullScreen()) return; | 301 | if (!fullScreen()) return; |
306 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} | 302 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} |
307 | 303 | ||
308 | setUpdatesEnabled(false); | 304 | setUpdatesEnabled(false); |
309 | // This is needed because showNormal() forcefully changes the window | 305 | // This is needed because showNormal() forcefully changes the window |
310 | // style to WSTyle_TopLevel. | 306 | // style to WSTyle_TopLevel. |
311 | reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); | 307 | reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); |
312 | // Enable fullscreen. | 308 | // Enable fullscreen. |
313 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus | 309 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus |
314 | * so we must block it here! */ | 310 | * so we must block it here! */ |
315 | m_ignore_next_in = true; | 311 | m_ignore_next_in = true; |
316 | showFullScreen(); | 312 | showFullScreen(); |
317 | setUpdatesEnabled(true); | 313 | setUpdatesEnabled(true); |
318 | } | 314 | } |