-rw-r--r-- | noncore/graphics/opie-eye/gui/gui.pro | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/messagebox.cpp | 119 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/messagebox.h | 57 |
4 files changed, 185 insertions, 10 deletions
diff --git a/noncore/graphics/opie-eye/gui/gui.pro b/noncore/graphics/opie-eye/gui/gui.pro index 2759dd5..250c8b1 100644 --- a/noncore/graphics/opie-eye/gui/gui.pro +++ b/noncore/graphics/opie-eye/gui/gui.pro | |||
@@ -1,17 +1,19 @@ | |||
1 | HEADERS += gui/filesystem.h \ | 1 | HEADERS += gui/filesystem.h \ |
2 | gui/iconview.h \ | 2 | gui/iconview.h \ |
3 | gui/imageinfoui.h \ | 3 | gui/imageinfoui.h \ |
4 | gui/imageview.h \ | 4 | gui/imageview.h \ |
5 | gui/mainwindow.h \ | 5 | gui/mainwindow.h \ |
6 | gui/viewmodebutton.h \ | 6 | gui/viewmodebutton.h \ |
7 | gui/basesetup.h | 7 | gui/basesetup.h \ |
8 | gui/messagebox.h | ||
8 | 9 | ||
9 | SOURCES += gui/filesystem.cpp \ | 10 | SOURCES += gui/filesystem.cpp \ |
10 | gui/iconview.cpp \ | 11 | gui/iconview.cpp \ |
11 | gui/imageinfoui.cpp \ | 12 | gui/imageinfoui.cpp \ |
12 | gui/imageview.cpp \ | 13 | gui/imageview.cpp \ |
13 | gui/mainwindow.cpp \ | 14 | gui/mainwindow.cpp \ |
14 | gui/viewmodebutton.cpp \ | 15 | gui/viewmodebutton.cpp \ |
15 | gui/basesetup.cpp | 16 | gui/basesetup.cpp \ |
17 | gui/messagebox.cpp | ||
16 | 18 | ||
17 | 19 | ||
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 138e661..b2443e8 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,18 +1,19 @@ | |||
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 | 8 | ||
8 | #include <lib/imagecache.h> | 9 | #include <lib/imagecache.h> |
9 | #include <gui/imageinfoui.h> | 10 | #include <gui/imageinfoui.h> |
10 | 11 | ||
11 | #include <iface/dirview.h> | 12 | #include <iface/dirview.h> |
12 | #include <iface/dirlister.h> | 13 | #include <iface/dirlister.h> |
13 | 14 | ||
14 | #include <opie2/oconfig.h> | 15 | #include <opie2/oconfig.h> |
15 | #include <opie2/okeyconfigwidget.h> | 16 | #include <opie2/okeyconfigwidget.h> |
16 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
17 | #include <opie2/oimagescrollview.h> | 18 | #include <opie2/oimagescrollview.h> |
18 | 19 | ||
@@ -368,31 +369,30 @@ QString PIconView::prevFileName(bool &isDir)const{ | |||
368 | return QString::null; | 369 | return QString::null; |
369 | _it = _it->prevItem(); | 370 | _it = _it->prevItem(); |
370 | if ( !_it ) | 371 | if ( !_it ) |
371 | return QString::null; | 372 | return QString::null; |
372 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 373 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
373 | isDir = it->isDir(); | 374 | isDir = it->isDir(); |
374 | return it->path(); | 375 | return it->path(); |
375 | } | 376 | } |
376 | 377 | ||
377 | void PIconView::slotTrash() { | 378 | void PIconView::slotTrash() { |
378 | bool isDir; | 379 | bool isDir; |
379 | QString pa = currentFileName( isDir ); | 380 | QString pa = currentFileName( isDir ); |
380 | if ( isDir && pa.isEmpty() ) | 381 | if ( isDir || pa.isEmpty() ) |
381 | return; | 382 | return; |
382 | 383 | ||
383 | if (!QPEMessageBox::confirmDelete( this, | 384 | if (!OMessageBox::confirmDelete( this, tr("the Image"), |
384 | tr("Delete Image" ), | 385 | pa, tr("Delete Image" ))) |
385 | tr("the Image %1" ).arg(pa))) | 386 | return; |
386 | return | ||
387 | 387 | ||
388 | 388 | ||
389 | currentView()->dirLister()->deleteImage( pa ); | 389 | currentView()->dirLister()->deleteImage( pa ); |
390 | delete m_view->currentItem(); | 390 | delete m_view->currentItem(); |
391 | } | 391 | } |
392 | 392 | ||
393 | /* | 393 | /* |
394 | * see what views are available | 394 | * see what views are available |
395 | */ | 395 | */ |
396 | void PIconView::loadViews() { | 396 | void PIconView::loadViews() { |
397 | ViewMap::Iterator it; | 397 | ViewMap::Iterator it; |
398 | ViewMap* map = viewMap(); | 398 | ViewMap* map = viewMap(); |
@@ -421,27 +421,24 @@ void PIconView::resetView() { | |||
421 | } | 421 | } |
422 | calculateGrid(); | 422 | calculateGrid(); |
423 | } | 423 | } |
424 | } else { | 424 | } else { |
425 | m_iconsize = 64; | 425 | m_iconsize = 64; |
426 | } | 426 | } |
427 | slotViewChanged(m_views->currentItem()); | 427 | slotViewChanged(m_views->currentItem()); |
428 | m_internalReset = false; | 428 | m_internalReset = false; |
429 | } | 429 | } |
430 | 430 | ||
431 | void PIconView::polish() | 431 | void PIconView::polish() |
432 | { | 432 | { |
433 | odebug << "===\n" | ||
434 | << "PIconView::polish()\n" | ||
435 | << "====" << oendl; | ||
436 | QVBox::polish(); | 433 | QVBox::polish(); |
437 | 434 | ||
438 | QString lastView = m_cfg->readEntry("LastView",""); | 435 | QString lastView = m_cfg->readEntry("LastView",""); |
439 | int cc=0; | 436 | int cc=0; |
440 | for (; cc<m_views->count();++cc) { | 437 | for (; cc<m_views->count();++cc) { |
441 | if (m_views->text(cc)==lastView) { | 438 | if (m_views->text(cc)==lastView) { |
442 | break; | 439 | break; |
443 | } | 440 | } |
444 | } | 441 | } |
445 | if (cc<m_views->count()) { | 442 | if (cc<m_views->count()) { |
446 | m_views->setCurrentItem(cc); | 443 | m_views->setCurrentItem(cc); |
447 | slotViewChanged(cc); | 444 | slotViewChanged(cc); |
diff --git a/noncore/graphics/opie-eye/gui/messagebox.cpp b/noncore/graphics/opie-eye/gui/messagebox.cpp new file mode 100644 index 0000000..c84e4e1 --- a/dev/null +++ b/noncore/graphics/opie-eye/gui/messagebox.cpp | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2004 Holger Hans Peter <freyther@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "messagebox.h" | ||
30 | |||
31 | #include <qapplication.h> | ||
32 | #include <qmessagebox.h> | ||
33 | |||
34 | /* | ||
35 | * LGPLv2 KDE Project kstringhandler.cpp | ||
36 | */ | ||
37 | template<class T> | ||
38 | inline const T& kClamp( const T& x, const T& low, const T& high ) | ||
39 | { | ||
40 | if ( x < low ) return low; | ||
41 | else if ( high < x ) return high; | ||
42 | else return x; | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * dependant on the screen rotation place the dots | ||
47 | */ | ||
48 | static QString g_insert_ldot( const QString& name, const QFontMetrics& fontMetrics ) { | ||
49 | uint maxPixels = qApp->desktop()->width()-90; | ||
50 | uint nameWidth = fontMetrics.width(name); | ||
51 | |||
52 | if (maxPixels < nameWidth) { | ||
53 | QString tmp = name; | ||
54 | const uint em = fontMetrics.maxWidth(); | ||
55 | maxPixels -= fontMetrics.width("..."); | ||
56 | |||
57 | while (maxPixels < nameWidth && !tmp.isEmpty()) { | ||
58 | int delta = (nameWidth - maxPixels) / em; | ||
59 | delta = kClamp(delta, 1, delta); // no max | ||
60 | |||
61 | tmp.remove(0, delta); | ||
62 | nameWidth = fontMetrics.width(tmp); | ||
63 | } | ||
64 | |||
65 | return ("..." + tmp); | ||
66 | } | ||
67 | |||
68 | return name; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * | ||
73 | * #FIXME Write Own message box to be more independant on sizes | ||
74 | * #FIXME Ask translator how to make the sentence more robust | ||
75 | * | ||
76 | * \brief replacement for QPEMessageBox::confirmDelete | ||
77 | * | ||
78 | * If you want to delete a file and the path is too long to fit | ||
79 | * on the screen \ldots is inserted in the middle of the string | ||
80 | * to fit on the screen. This allows the user still to identify | ||
81 | * the file. | ||
82 | * | ||
83 | * @param parent The parent of this MessageBox | ||
84 | * @param type The type of the object to delte. i.e 'the image' | ||
85 | * @param object The 'object' to be deleted | ||
86 | * @param caption An optional caption for the box | ||
87 | * | ||
88 | */ | ||
89 | bool OMessageBox::confirmDelete( QWidget* parent, const QString& type, const QString& object, | ||
90 | const QString& _caption ) { | ||
91 | /* | ||
92 | * create a messagebox to get the font metrics | ||
93 | */ | ||
94 | QMessageBox msg( QString::null, QString::null, | ||
95 | QMessageBox::Warning, QMessageBox::Yes, | ||
96 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, | ||
97 | QMessageBox::NoButton, | ||
98 | parent, "OMessageBox::confirmDelete" ); | ||
99 | |||
100 | /* | ||
101 | * Create the Message and Caption | ||
102 | */ | ||
103 | QString msga = QObject::tr("<qt>Are you sure you want to delete %1<br> %2?</qt>" ) | ||
104 | .arg( type ) | ||
105 | .arg( g_insert_ldot( object, msg.fontMetrics() ) ); | ||
106 | QString caption = _caption.isEmpty() ? | ||
107 | QObject::tr( "Confirm Deletion" ) : _caption; | ||
108 | |||
109 | msg.setText( msga ); | ||
110 | msg.setCaption( caption ); | ||
111 | msg.setIcon( QMessageBox::Warning ); | ||
112 | msg.adjustSize(); | ||
113 | |||
114 | /* | ||
115 | * Warn the user that he will delete | ||
116 | */ | ||
117 | int ret = msg.exec(); | ||
118 | return ( ret == QMessageBox::Yes ); | ||
119 | } | ||
diff --git a/noncore/graphics/opie-eye/gui/messagebox.h b/noncore/graphics/opie-eye/gui/messagebox.h new file mode 100644 index 0000000..a0e6fa0 --- a/dev/null +++ b/noncore/graphics/opie-eye/gui/messagebox.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2004 Holger Hans Peter <freyther@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef OPIE_UI_OMESSAGE_BOX_H | ||
30 | #define OPIE_UI_OMEESAGE_BOX_H | ||
31 | |||
32 | #include <qstring.h> | ||
33 | |||
34 | class QWidget; | ||
35 | |||
36 | /* | ||
37 | * ### to be moved to OpieUI | ||
38 | * ### move KDEs KStringHandler to OpieCore | ||
39 | * ### once done | ||
40 | * FIXME | ||
41 | */ | ||
42 | |||
43 | /** | ||
44 | * \brief Custom and common Opie MessageBoxes | ||
45 | * | ||
46 | * A set of static methods to open special MessageBoxes. | ||
47 | */ | ||
48 | class OMessageBox { | ||
49 | public: | ||
50 | static bool confirmDelete(QWidget *parent, | ||
51 | const QString& type, | ||
52 | const QString& object, | ||
53 | const QString & caption = QString::null); | ||
54 | |||
55 | }; | ||
56 | |||
57 | #endif | ||