Diffstat (limited to 'noncore/graphics/opie-eye/gui/imageinfoui.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp index 3463ba6..74a9ea4 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp +++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp | |||
@@ -6,37 +6,48 @@ | |||
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 <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | 21 | ||
22 | #define THUMBSIZE 128 | 22 | static const int THUMBSIZE = 128; |
23 | |||
24 | |||
25 | imageinfo::imageinfo(QWidget* parent, const char* name, WFlags fl ) | ||
26 | : QWidget( parent, name, fl ) | ||
27 | { | ||
28 | init(name); | ||
29 | } | ||
23 | 30 | ||
24 | imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) | 31 | imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) |
25 | : QWidget( parent, name, fl ),currentFile(_path) | 32 | : QWidget( parent, name, fl ),currentFile(_path) |
26 | { | 33 | { |
34 | init(name); | ||
35 | slotChangeName(_path); | ||
36 | } | ||
37 | void imageinfo::init(const char* name) { | ||
27 | { | 38 | { |
28 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 39 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
29 | } | 40 | } |
30 | if ( !name ) | 41 | if ( !name ) |
31 | setName( "imageinfo" ); | 42 | setName( "imageinfo" ); |
32 | resize( 289, 335 ); | 43 | resize( 289, 335 ); |
33 | setCaption( tr( "Image info" ) ); | 44 | setCaption( tr( "Image info" ) ); |
34 | imageinfoLayout = new QVBoxLayout( this ); | 45 | imageinfoLayout = new QVBoxLayout( this ); |
35 | imageinfoLayout->setSpacing(2); | 46 | imageinfoLayout->setSpacing(2); |
36 | imageinfoLayout->setMargin(4); | 47 | imageinfoLayout->setMargin(4); |
37 | 48 | ||
38 | PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); | 49 | PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); |
39 | PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); | 50 | PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); |
40 | QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); | 51 | QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); |
41 | 52 | ||
42 | imageinfoLayout->addWidget( PixmapLabel1 ); | 53 | imageinfoLayout->addWidget( PixmapLabel1 ); |
@@ -49,33 +60,32 @@ imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WF | |||
49 | imageinfoLayout->addWidget( fnameLabel); | 60 | imageinfoLayout->addWidget( fnameLabel); |
50 | 61 | ||
51 | TextView1 = new QTextView( this, "TextView1" ); | 62 | TextView1 = new QTextView( this, "TextView1" ); |
52 | TextView1->setFrameShadow( QTextView::Sunken ); | 63 | TextView1->setFrameShadow( QTextView::Sunken ); |
53 | TextView1->setResizePolicy( QTextView::AutoOneFit ); | 64 | TextView1->setResizePolicy( QTextView::AutoOneFit ); |
54 | TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); | 65 | TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); |
55 | TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); | 66 | TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); |
56 | // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); | 67 | // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); |
57 | QWhatsThis::add( TextView1, tr("Displays info of selected image") ); | 68 | QWhatsThis::add( TextView1, tr("Displays info of selected image") ); |
58 | imageinfoLayout->addWidget( TextView1 ); | 69 | imageinfoLayout->addWidget( TextView1 ); |
59 | 70 | ||
60 | SlaveMaster* master = SlaveMaster::self(); | 71 | SlaveMaster* master = SlaveMaster::self(); |
61 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 72 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
62 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); | 73 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); |
63 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 74 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
64 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 75 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
65 | slotChangeName(_path); | ||
66 | } | 76 | } |
67 | 77 | ||
68 | void imageinfo::slotChangeName(const QString&_path) | 78 | void imageinfo::slotChangeName(const QString&_path) |
69 | { | 79 | { |
70 | currentFile=_path; | 80 | currentFile=_path; |
71 | QFileInfo fi(_path); | 81 | QFileInfo fi(_path); |
72 | fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); | 82 | fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); |
73 | SlaveMaster::self()->imageInfo( currentFile ); | 83 | SlaveMaster::self()->imageInfo( currentFile ); |
74 | 84 | ||
75 | QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); | 85 | QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); |
76 | if (!m_pix) { | 86 | if (!m_pix) { |
77 | PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); | 87 | PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); |
78 | SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); | 88 | SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); |
79 | } else { | 89 | } else { |
80 | PixmapLabel1->setPixmap(*m_pix); | 90 | PixmapLabel1->setPixmap(*m_pix); |
81 | } | 91 | } |
@@ -98,30 +108,45 @@ void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) | |||
98 | t.replace(QRegeExp("</qt>","");*/ | 108 | t.replace(QRegeExp("</qt>","");*/ |
99 | TextView1->setText(t); | 109 | TextView1->setText(t); |
100 | } | 110 | } |
101 | } | 111 | } |
102 | 112 | ||
103 | void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) | 113 | void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) |
104 | { | 114 | { |
105 | if (_path == currentFile) { | 115 | if (_path == currentFile) { |
106 | if (_pix.width()>0) { | 116 | if (_pix.width()>0) { |
107 | PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); | 117 | PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); |
108 | PixmapLabel1->setPixmap( _pix ); | 118 | PixmapLabel1->setPixmap( _pix ); |
109 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); | 119 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); |
110 | } | 120 | } |
111 | } | 121 | } |
112 | } | 122 | } |
113 | 123 | ||
124 | void imageinfo::setPath( const QString& str ) { | ||
125 | slotChangeName( str ); | ||
126 | } | ||
127 | |||
128 | void imageinfo::setDestructiveClose() { | ||
129 | WFlags fl = getWFlags(); | ||
130 | /* clear it just in case */ | ||
131 | fl &= ~WDestructiveClose; | ||
132 | fl |= WDestructiveClose; | ||
133 | setWFlags( fl ); | ||
134 | } | ||
135 | |||
136 | |||
114 | /* for testing */ | 137 | /* for testing */ |
115 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) | 138 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) |
116 | :QDialog(parent,name,true,WStyle_ContextHelp) | 139 | :QDialog(parent,name,true,WStyle_ContextHelp) |
117 | { | 140 | { |
118 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 141 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
119 | dlglayout->setSpacing(2); | 142 | dlglayout->setSpacing(2); |
120 | dlglayout->setMargin(1); | 143 | dlglayout->setMargin(1); |
121 | imageinfo*inf = new imageinfo(fname,this); | 144 | imageinfo*inf = new imageinfo(fname,this); |
122 | dlglayout->addWidget(inf); | 145 | dlglayout->addWidget(inf); |
123 | } | 146 | } |
124 | 147 | ||
125 | infoDlg::~infoDlg() | 148 | infoDlg::~infoDlg() |
126 | { | 149 | { |
127 | } | 150 | } |
151 | |||
152 | |||