summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
index 177df77..2580215 100644
--- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
@@ -1,114 +1,127 @@
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 15
15#include <lib/slavemaster.h> 16#include <lib/slavemaster.h>
16#include <lib/imagecache.h> 17#include <lib/imagecache.h>
17 18
18#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
19#include <qpe/resource.h> 20#include <qpe/resource.h>
20 21
22#define THUMBSIZE 128
23
21imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) 24imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl )
22 : QWidget( parent, name, fl ),currentFile(_path) 25 : QWidget( parent, name, fl ),currentFile(_path)
23{ 26{
24 { 27 {
25 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 28 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
26 } 29 }
27 if ( !name ) 30 if ( !name )
28 setName( "imageinfo" ); 31 setName( "imageinfo" );
29 resize( 289, 335 ); 32 resize( 289, 335 );
30 setCaption( tr( "Image info" ) ); 33 setCaption( tr( "Image info" ) );
31 imageinfoLayout = new QVBoxLayout( this ); 34 imageinfoLayout = new QVBoxLayout( this );
32 imageinfoLayout->setSpacing(2); 35 imageinfoLayout->setSpacing(2);
33 imageinfoLayout->setMargin(2); 36 imageinfoLayout->setMargin(4);
34 37
35 PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); 38 PixmapLabel1 = new QLabel( this, "PixmapLabel1" );
36 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); 39 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) );
37 PixmapLabel1->setScaledContents( TRUE ); 40 QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") );
41
38 imageinfoLayout->addWidget( PixmapLabel1 ); 42 imageinfoLayout->addWidget( PixmapLabel1 );
39 43
40 Line1 = new QFrame( this, "Line1" ); 44 Line1 = new QFrame( this, "Line1" );
41 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 45 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
42 imageinfoLayout->addWidget( Line1 ); 46 imageinfoLayout->addWidget( Line1 );
43 47
44 fnameLabel = new QLabel( this, "FnameLabel" ); 48 fnameLabel = new QLabel( this, "FnameLabel" );
45 imageinfoLayout->addWidget( fnameLabel); 49 imageinfoLayout->addWidget( fnameLabel);
46 50
47 TextView1 = new QTextView( this, "TextView1" ); 51 TextView1 = new QTextView( this, "TextView1" );
48 TextView1->setFrameShadow( QTextView::Plain ); 52 TextView1->setFrameShadow( QTextView::Sunken );
49 QToolTip::add( TextView1, tr( "Displays info of selected image" ) ); 53 TextView1->setResizePolicy( QTextView::AutoOneFit );
50 QWhatsThis::add( TextView1, tr( "Displays info of selected image" ) ); 54 TextView1->setBackgroundOrigin( QTextView::ParentOrigin );
55 TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) );
56// TextView1->setVScrollBarMode(QScrollView::AlwaysOn);
57 QWhatsThis::add( TextView1, tr("Displays info of selected image") );
51 imageinfoLayout->addWidget( TextView1 ); 58 imageinfoLayout->addWidget( TextView1 );
52 59
53 SlaveMaster* master = SlaveMaster::self(); 60 SlaveMaster* master = SlaveMaster::self();
54 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), 61 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
55 this, SLOT(slot_fullInfo(const QString&, const QString&)) ); 62 this, SLOT(slot_fullInfo(const QString&, const QString&)) );
56 connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 63 connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
57 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 64 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
58 slotChangeName(_path); 65 slotChangeName(_path);
59} 66}
60 67
61void imageinfo::slotChangeName(const QString&_path) 68void imageinfo::slotChangeName(const QString&_path)
62{ 69{
63 currentFile=_path; 70 currentFile=_path;
64 fnameLabel->setText("<qt><center><b>"+currentFile+"</b></center></qt>"); 71 QFileInfo fi(_path);
72 fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>");
65 SlaveMaster::self()->imageInfo( currentFile ); 73 SlaveMaster::self()->imageInfo( currentFile );
66 74
67 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, 64, 64 ); 75 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE );
68 if (!m_pix) { 76 if (!m_pix) {
69 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); 77 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" )));
78 SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE);
70 } else { 79 } else {
71 PixmapLabel1->setPixmap(*m_pix); 80 PixmapLabel1->setPixmap(*m_pix);
72 } 81 }
73} 82}
74 83
75imageinfo::~imageinfo() 84imageinfo::~imageinfo()
76{ 85{
77 { 86 {
78 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 87 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
79 } 88 }
80} 89}
81 90
82void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) 91void imageinfo::slot_fullInfo(const QString&_path, const QString&_t)
83{ 92{
84 if (_path == currentFile) { 93 if (_path == currentFile) {
85 qDebug(_t); 94 qDebug(_t);
86 QString t = _t; 95 QString t = _t;
87 t.replace(QRegExp("\n"),"<br>"); 96 t.replace(QRegExp("\n"),"<br>");
97/* t.replace(QRegeExp("<qt>","");
98 t.replace(QRegeExp("</qt>","");*/
88 TextView1->setText(t); 99 TextView1->setText(t);
89 } 100 }
90} 101}
91 102
92void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) 103void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix)
93{ 104{
94 if (_pix.width()>0)
95 PPixmapCache::self()->insertImage( _path, _pix, 64, 64 );
96 if (_path == currentFile) { 105 if (_path == currentFile) {
97 PixmapLabel1->setPixmap( _pix ); 106 if (_pix.width()>0) {
107 PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE );
108 PixmapLabel1->setPixmap( _pix );
109 PixmapLabel1->resize(QSize(_pix.width(),_pix.height()));
110 }
98 } 111 }
99} 112}
100 113
101/* for testing */ 114/* for testing */
102infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) 115infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name)
103 :QDialog(parent,name,true,WStyle_ContextHelp) 116 :QDialog(parent,name,true,WStyle_ContextHelp)
104{ 117{
105 QVBoxLayout*dlglayout = new QVBoxLayout(this); 118 QVBoxLayout*dlglayout = new QVBoxLayout(this);
106 dlglayout->setSpacing(2); 119 dlglayout->setSpacing(2);
107 dlglayout->setMargin(1); 120 dlglayout->setMargin(1);
108 imageinfo*inf = new imageinfo(fname,this); 121 imageinfo*inf = new imageinfo(fname,this);
109 dlglayout->addWidget(inf); 122 dlglayout->addWidget(inf);
110} 123}
111 124
112infoDlg::~infoDlg() 125infoDlg::~infoDlg()
113{ 126{
114} 127}