-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 19 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 20 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 6 |
5 files changed, 31 insertions, 18 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp index 822fd88..0b3250c 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp +++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp @@ -1,202 +1,205 @@ #include "imageinfoui.h" #include <qframe.h> #include <qlabel.h> #include <qpushbutton.h> #include <qtextview.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include <qstring.h> #include <qfileinfo.h> #include "lib/slavemaster.h" #include "lib/imagecache.h" #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> #include <opie2/odebug.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> static const int THUMBSIZE = 128; using namespace Opie::Core; -imageinfo::imageinfo(QWidget* parent, const char* name, WFlags fl ) +imageinfo::imageinfo(Opie::Core::OConfig *cfg,QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { m_viewManager = 0; + m_cfg = cfg; init(name); initKeys(); } imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ),currentFile(_path) { m_viewManager = 0; + m_cfg = 0; init(name); initKeys(); slotChangeName(_path); } Opie::Ui::OKeyConfigManager* imageinfo::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void imageinfo::initKeys() { odebug << "init imageinfo keys" << oendl; - m_cfg = new Opie::Core::OConfig("phunkview"); - m_cfg->setGroup("Zecke_view" ); +#if 0 + if (!m_cfg) { + m_cfg = new Opie::Core::OConfig("phunkview"); + m_cfg->setGroup("imageinfo_keys" ); + } +#endif Opie::Ui::OKeyPair::List lst; lst.append( Opie::Ui::OKeyPair::upArrowKey() ); lst.append( Opie::Ui::OKeyPair::downArrowKey() ); lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); lst.append( Opie::Ui::OKeyPair::returnKey() ); - m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "Imageinfo-KeyBoard-Config", + m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "imageinfo_keys", lst, false,this, "keyconfig name" ); - m_viewManager->addKeyConfig( Opie::Ui::OKeyConfigItem(tr("View Full Image"), "view", + m_viewManager->addKeyConfig( Opie::Ui::OKeyConfigItem(tr("View Full Image"), "infoview", Resource::loadPixmap("1to1"), ViewItem, Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), this, SLOT(slotShowImage()))); m_viewManager->load(); m_viewManager->handleWidget( this ); m_viewManager->handleWidget( TextView1 ); } void imageinfo::slotShowImage() { emit dispImage(currentFile); } void imageinfo::init(const char* name) { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); } if ( !name ) setName( "imageinfo" ); resize( 289, 335 ); setCaption( tr( "Image info" ) ); imageinfoLayout = new QVBoxLayout( this ); imageinfoLayout->setSpacing(2); imageinfoLayout->setMargin(4); PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); imageinfoLayout->addWidget( PixmapLabel1 ); Line1 = new QFrame( this, "Line1" ); Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); imageinfoLayout->addWidget( Line1 ); fnameLabel = new QLabel( this, "FnameLabel" ); imageinfoLayout->addWidget( fnameLabel); TextView1 = new QTextView( this, "TextView1" ); TextView1->setFrameShadow( QTextView::Sunken ); TextView1->setResizePolicy( QTextView::AutoOneFit ); TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); QWhatsThis::add( TextView1, tr("Displays info of selected image") ); imageinfoLayout->addWidget( TextView1 ); SlaveMaster* master = SlaveMaster::self(); connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), this, SLOT(slot_fullInfo(const QString&, const QString&)) ); connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), this, SLOT(slotThumbNail(const QString&, const QPixmap&))); } void imageinfo::slotChangeName(const QString&_path) { currentFile=_path; QFileInfo fi(_path); fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); SlaveMaster::self()->imageInfo( currentFile ); QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); if (!m_pix) { PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); } else { PixmapLabel1->setPixmap(*m_pix); } } imageinfo::~imageinfo() { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); } if (m_viewManager) { - m_viewManager->save(); delete m_viewManager; } } void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) { if (_path == currentFile) { qDebug(_t); QString t = _t; t.replace(QRegExp("\n"),"<br>"); -/* t.replace(QRegeExp("<qt>",""); - t.replace(QRegeExp("</qt>","");*/ TextView1->setText(t); } } void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) { if (_path == currentFile) { if (_pix.width()>0) { PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); PixmapLabel1->setPixmap( _pix ); PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); } } } void imageinfo::setPath( const QString& str ) { slotChangeName( str ); } void imageinfo::setDestructiveClose() { WFlags fl = getWFlags(); /* clear it just in case */ fl &= ~WDestructiveClose; fl |= WDestructiveClose; setWFlags( fl ); } /* for testing */ infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) :QDialog(parent,name,true,WStyle_ContextHelp) { QVBoxLayout*dlglayout = new QVBoxLayout(this); dlglayout->setSpacing(2); dlglayout->setMargin(1); imageinfo*inf = new imageinfo(fname,this); dlglayout->addWidget(inf); } infoDlg::~infoDlg() { } diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.h b/noncore/graphics/opie-eye/gui/imageinfoui.h index 0ffa423..c9b83a1 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.h +++ b/noncore/graphics/opie-eye/gui/imageinfoui.h @@ -1,78 +1,78 @@ #ifndef IMAGEINFO_H #define IMAGEINFO_H #include <qvariant.h> #include <qwidget.h> #include <qdialog.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QFrame; class QLabel; class QTextView; namespace Opie { namespace Core { class OConfig; } namespace Ui { class OKeyConfigManager; } } class imageinfo : public QWidget { Q_OBJECT enum ActionIds { ViewItem }; public: - imageinfo( QWidget* parent = 0, const char* name = 0, WFlags fl =0); + imageinfo(Opie::Core::OConfig *cfg, QWidget* parent = 0, const char* name = 0, WFlags fl =0); imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); virtual ~imageinfo(); void setDestructiveClose(); Opie::Ui::OKeyConfigManager* manager(); signals: void dispImage(const QString&); void sig_return(); public slots: virtual void setPath( const QString& path ); virtual void slotShowImage(); private: void init(const char* name); protected: QLabel* PixmapLabel1; QLabel* fnameLabel; QFrame* Line1; QTextView* TextView1; QVBoxLayout* imageinfoLayout; QString currentFile; Opie::Core::OConfig * m_cfg; Opie::Ui::OKeyConfigManager*m_viewManager; void initKeys(); protected slots: virtual void slot_fullInfo(const QString&, const QString&); virtual void slotThumbNail(const QString&, const QPixmap&); virtual void slotChangeName(const QString&); }; /* for testing purpose */ class infoDlg:public QDialog { Q_OBJECT public: infoDlg(const QString&,QWidget * parent=0, const char * name=0); virtual ~infoDlg(); }; #endif // IMAGEINFO_H diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 8fc258e..e43bbff 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -1,55 +1,61 @@ #include "imageview.h" #include <opie2/odebug.h> #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> using namespace Opie::Core; -ImageView::ImageView( QWidget* parent, const char* name, WFlags fl ) +ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) : ImageScrollView(parent,name,fl) { m_viewManager = 0; + m_cfg = cfg; initKeys(); } ImageView::~ImageView() { + if (m_viewManager) { + delete m_viewManager; + } } Opie::Ui::OKeyConfigManager* ImageView::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void ImageView::initKeys() { odebug << "init imageview keys" << oendl; - m_cfg = new Opie::Core::OConfig("phunkview"); - m_cfg->setGroup("Zecke_view" ); + if (!m_cfg) { + m_cfg = new Opie::Core::OConfig("phunkview"); + m_cfg->setGroup("image_view_keys" ); + } Opie::Ui::OKeyPair::List lst; lst.append( Opie::Ui::OKeyPair::upArrowKey() ); lst.append( Opie::Ui::OKeyPair::downArrowKey() ); lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); lst.append( Opie::Ui::OKeyPair::returnKey() ); - m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "Imageview-KeyBoard-Config", - lst, false,this, "keyconfig name" ); - m_viewManager->addKeyConfig( Opie::Ui::OKeyConfigItem(tr("View Image Info"), "view", + m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "image_view_keys", + lst, false,this, "image_view_keys" ); + m_viewManager->addKeyConfig( Opie::Ui::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", Resource::loadPixmap("1to1"), ViewInfo, Opie::Ui::OKeyPair(Qt::Key_I,Qt::ShiftButton), this, SLOT(slotShowImageInfo()))); - m_viewManager->load(); m_viewManager->handleWidget( this ); + m_viewManager->load(); } void ImageView::slotShowImageInfo() { emit dispImageInfo(m_lastName); } diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 5ee0d7d..f61c93f 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,40 +1,40 @@ #ifndef _IMAGE_VIEW_H #define _IMAGE_VIEW_H /* must be changed when it will moved to Opie::MM */ #include "imagescrollview.h" namespace Opie { namespace Core { class OConfig; } namespace Ui { class OKeyConfigManager; } } class ImageView:public ImageScrollView { Q_OBJECT enum ActionIds { ViewInfo }; public: - ImageView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); + ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); virtual ~ImageView(); Opie::Ui::OKeyConfigManager* manager(); signals: void dispImageInfo(const QString&); void sig_return(); protected: Opie::Core::OConfig * m_cfg; Opie::Ui::OKeyConfigManager*m_viewManager; void initKeys(); protected slots: virtual void slotShowImageInfo(); }; #endif diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 529bee4..21a668a 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -102,178 +102,182 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) btn->setIconSet( Resource::loadIconSet( "1to1" ) ); btn->setToggleButton(true); btn->setOn(false); connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); autoScale = true; } PMainWindow::~PMainWindow() { odebug << "Shutting down" << oendl; } void PMainWindow::slotRotateToggled(bool how) { autoRotate = how; if (m_disp) { m_disp->setAutoRotate(how); } } void PMainWindow::slotScaleToggled(bool how) { autoScale = !how; if (m_disp) { m_disp->setAutoScale(autoScale); } if (!autoScale && autoRotate) { rotateButton->setOn(false); } rotateButton->setEnabled(!how); } void PMainWindow::slotConfig() { /* * have a tab with the possible views * a tab for globals image cache size.. scaled loading * and one tab for the KeyConfigs */ QDialog dlg(this, 0, true); dlg.setCaption( tr("Phunk View - Config" ) ); QHBoxLayout *lay = new QHBoxLayout(&dlg); Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); lay->addWidget( wid ); ViewMap *vM = viewMap(); ViewMap::Iterator _it = vM->begin(); QMap<PDirView*, QWidget*> lst; for( ; _it != vM->end(); ++_it ) { PDirView *view = (_it.data())(*m_cfg); PInterfaceInfo *inf = view->interfaceInfo(); QWidget *_wid = inf->configWidget( *m_cfg ); _wid->reparent(wid, QPoint() ); lst.insert( view, _wid ); wid->addTab( _wid, "fileopen", inf->name() ); } /* * Add the KeyConfigWidget */ Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); if ( !m_info ) { initInfo(); } keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); if ( !m_disp ) { initDisp(); } keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); keyWid->load(); wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); /* * clean up *apply changes */ QMap<PDirView*, QWidget*>::Iterator it; for ( it = lst.begin(); it != lst.end(); ++it ) { if ( act ) it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); delete it.key(); } if ( act ) { m_view->resetView(); keyWid->save(); + m_disp->manager()->save(); + m_info->manager()->save(); + m_view->manager()->save(); } + delete keyWid; } /* * create a new image info component * and detach the current one * we will make the other delete on exit */ template<class T> void PMainWindow::initT( const char* name, T** ptr, int id) { if ( *ptr ) { (*ptr)->disconnect(this, SLOT(slotReturn())); (*ptr)->setDestructiveClose(); m_stack->removeWidget( *ptr ); } - *ptr = new T( m_stack, name ); + *ptr = new T(m_cfg, m_stack, name ); m_stack->addWidget( *ptr, id ); connect(*ptr, SIGNAL(sig_return()), this,SLOT(slotReturn())); } void PMainWindow::initInfo() { initT<imageinfo>( "Image Info", &m_info, ImageInfo ); connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); } void PMainWindow::initDisp() { initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); if (m_disp) { m_disp->setAutoScale(autoScale); m_disp->setAutoRotate(autoRotate); connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); } } /** * With big Screen the plan could be to 'detach' the image * window if visible and to create a ne wone * init* already supports it but I make no use of it for * now. We set filename and raise * * ### FIXME and talk to alwin */ void PMainWindow::slotShowInfo( const QString& inf ) { if ( !m_info ) { initInfo(); } m_info->setPath( inf ); m_stack->raiseWidget( ImageInfo ); } void PMainWindow::slotDisplay( const QString& inf ) { if ( !m_disp ) { initDisp(); } m_disp->setImage( inf ); m_stack->raiseWidget( ImageDisplay ); } void PMainWindow::slotReturn() { raiseIconView(); } void PMainWindow::closeEvent( QCloseEvent* ev ) { /* * return from view * or properly quit */ if ( m_stack->visibleWidget() == m_info || m_stack->visibleWidget() == m_disp ) { raiseIconView(); ev->ignore(); return; } ev->accept(); QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } void PMainWindow::raiseIconView() { m_stack->raiseWidget( IconView ); } |