author | alwin <alwin> | 2004-10-30 19:07:22 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-30 19:07:22 (UTC) |
commit | 193bbcdfb160a1a1dbb59078ae262c1a98207808 (patch) (side-by-side diff) | |
tree | 9d2cc5e2501cc94b4e61e1edffa421b4886aaa6c | |
parent | 0fc9ce0c22bad09470a18eb6d084c6042c914ed8 (diff) | |
download | opie-193bbcdfb160a1a1dbb59078ae262c1a98207808.zip opie-193bbcdfb160a1a1dbb59078ae262c1a98207808.tar.gz opie-193bbcdfb160a1a1dbb59078ae262c1a98207808.tar.bz2 |
most part of menu implemented
all buttons etc. should become a QAction inserted into menu and toolbar
toolbar may be hidden
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 173 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 20 |
5 files changed, 159 insertions, 40 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 0499af9..a41ce9f 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -660,52 +660,51 @@ void PIconView::slotShowPrev() if (isDir) return; /* if we got a name we have a prev item */ m_view->setCurrentItem(m_view->currentItem()->prevItem()); slotShowImage(name); } void PIconView::slotShowImage() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) return; slotShowImage( name ); } void PIconView::slotShowImage( const QString& name) { PDirLister *lister = currentView()->dirLister(); QString r_name = lister->nameToFname(name); - emit sig_display( r_name ); + emit sig_display(r_name); } void PIconView::slotStartSlide() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) { if (!slotShowFirst()) return; } else { slotShowImage( name ); } emit sig_startslide(2); } void PIconView::slotImageInfo() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) return; - slotImageInfo( name ); } void PIconView::slotImageInfo( const QString& name) { PDirLister *lister = currentView()->dirLister(); QString r_name = lister->nameToFname(name); emit sig_showInfo(r_name ); } void PIconView::slotChangeMode( int mode ) { if ( mode >= 1 && mode <= 3 ) m_mode = mode; m_cfg->writeEntry("ListViewMode", m_mode); /* performance! */ diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index bccbb0e..dff55ed 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h @@ -24,33 +24,33 @@ namespace Core{ } class PIconView : public QVBox { Q_OBJECT friend class PIconViewItem; enum ActionIds { BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem }; public: PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); ~PIconView(); void resetView(); Opie::Core::OKeyConfigManager* manager(); signals: void sig_showInfo( const QString& ); - void sig_display( const QString& ); + void sig_display(const QString&); void sig_startslide(int timeout); public slots: virtual void slotShowNext(); virtual void slotShowPrev(); virtual void slotShowLast(); virtual bool slotShowFirst(); protected: void resizeEvent( QResizeEvent* ); private: void initKeys(); QString currentFileName(bool &isDir)const; QString nextFileName(bool &isDir)const; QString prevFileName(bool &isDir)const; diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index b699aa1..a20c879 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -190,17 +190,16 @@ void ImageView::enableFullscreen() { if (!fullScreen()) return; if (m_ignore_next_in) {m_ignore_next_in = false;return;} setUpdatesEnabled(false); // This is needed because showNormal() forcefully changes the window // style to WSTyle_TopLevel. reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); // Enable fullscreen. /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus * so we must block it here! */ m_ignore_next_in = true; showFullScreen(); setUpdatesEnabled(true); } - diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 3c946b6..a1349a8 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -9,150 +9,210 @@ #include "filesystem.h" #include "imageinfoui.h" #include "viewmodebutton.h" #include <iface/ifaceinfo.h> #include <iface/dirview.h> #include <opie2/odebug.h> #include <opie2/owidgetstack.h> #include <opie2/oapplicationfactory.h> #include <opie2/otabwidget.h> #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/ir.h> +#include <qpe/storage.h> #include <qpe/applnk.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qmap.h> #include <qtimer.h> #include <qframe.h> - +#include <qmenubar.h> +#include <qaction.h> //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) { setCaption( QObject::tr("Opie Eye Caramba" ) ); m_cfg = new Opie::Core::OConfig("phunkview"); m_cfg->setGroup("Zecke_view" ); + + m_storage = new StorageInfo(); + connect(m_storage, SIGNAL(disksChanged() ), + this, SLOT( dirChanged() ) ); + /* * Initialize ToolBar and IconView * And Connect Them */ - QToolBar *bar = new QToolBar( this ); - bar->setHorizontalStretchable( true ); + toolBar = new QToolBar( this ); + menuBar = new QMenuBar( this ); + fileMenu = new QPopupMenu( menuBar ); + menuBar->insertItem( tr( "File" ), fileMenu ); + dispMenu = new QPopupMenu( menuBar ); + menuBar->insertItem( tr( "Show" ), dispMenu ); + + addToolBar(toolBar); + toolBar->setHorizontalStretchable( true ); setToolBarsMovable( false ); m_stack = new Opie::Ui::OWidgetStack( this ); setCentralWidget( m_stack ); m_view = new PIconView( m_stack, m_cfg ); m_stack->addWidget( m_view, IconView ); m_stack->raiseWidget( IconView ); + connect(m_view, SIGNAL(sig_display(const QString&)), this, SLOT(slotDisplay(const QString&))); connect(m_view, SIGNAL(sig_showInfo(const QString&)), this, SLOT(slotShowInfo(const QString&)) ); m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); - upButton = new QToolButton( bar ); - upButton->setIconSet( Resource::loadIconSet( "up" ) ); - connect( upButton, SIGNAL(clicked()), - m_view, SLOT(slotDirUp()) ); + m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), + 0, 0, this, 0, true ); + m_aDirUp->setToggleAction(false); + connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); + m_aDirUp->addTo( toolBar ); - fsButton = new PFileSystem( bar ); + QToolButton*btn; + + fsButton = new PFileSystem( toolBar ); connect( fsButton, SIGNAL( changeDir( const QString& ) ), m_view, SLOT(slotChangeDir( const QString& ) ) ); + connect( this, SIGNAL( changeDir( const QString& ) ), + m_view, SLOT(slotChangeDir( const QString& ) ) ); - QToolButton*btn = new QToolButton( bar ); - btn->setIconSet( Resource::loadIconSet( "edit" ) ); - connect( btn, SIGNAL(clicked()), - m_view, SLOT(slotImageInfo()) ); + m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), + 0, 0, this, 0, true ); + m_aShowInfo->setToggleAction(false); + connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); + m_aShowInfo->addTo( toolBar ); if ( Ir::supported() ) { - btn = new QToolButton( bar ); - btn->setIconSet( Resource::loadIconSet( "beam" ) ); - connect( btn, SIGNAL(clicked()), - m_view, SLOT(slotBeam()) ); + m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ), + 0, 0, this, 0, true ); + m_aBeam->setToggleAction(false); + connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); + m_aBeam->addTo( toolBar ); } + m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet( "trash" ), + 0, 0, this, 0, true ); + m_aTrash->setToggleAction(false); + connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); + m_aTrash->addTo( toolBar ); - btn = new QToolButton( bar ); - btn->setIconSet( Resource::loadIconSet( "trash" ) ); - connect( btn, SIGNAL(clicked() ), - m_view, SLOT(slotTrash() ) ); + m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet( "mag" ), + 0, 0, this, 0, true ); + m_aViewfile->setToggleAction(false); + connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); + + m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet( "play" ), + 0, 0, this, 0, true ); + m_aStartSlide->setToggleAction(false); + + connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); int mode = m_cfg->readNumEntry("ListViewMode", 1); if (mode < 1 || mode>3) mode = 1; - viewModeButton = new ViewModeButton( bar,mode ); + viewModeButton = new ViewModeButton( toolBar,mode ); connect( viewModeButton, SIGNAL(changeMode(int)), m_view, SLOT(slotChangeMode(int))); - btn = new QToolButton( bar ); + btn = new QToolButton( toolBar ); btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); connect( btn, SIGNAL(clicked() ), this, SLOT(slotConfig() ) ); - - - prevButton = new QToolButton(bar); + prevButton = new QToolButton(toolBar); prevButton->setIconSet( Resource::loadIconSet( "back" ) ); connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); - nextButton = new QToolButton(bar); + nextButton = new QToolButton(toolBar); nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); - rotateButton = new QToolButton(bar); +/* filemenu start */ + m_aViewfile->addTo(fileMenu); + m_aShowInfo->addTo(fileMenu); + m_aStartSlide->addTo(fileMenu); + + fileMenu->insertSeparator(); + m_aDirUp->addTo( fileMenu ); + + fsMenu = new QPopupMenu(fileMenu); + fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); + connect( fsMenu, SIGNAL( activated( int ) ), + this, SLOT(slotSelectDir( int ) ) ); + dirChanged(); + + fileMenu->insertSeparator(); + if ( Ir::supported() ) { + m_aBeam->addTo( fileMenu ); + } + fileMenu->insertSeparator(); + m_aTrash->addTo( fileMenu ); +/* filemenu end */ + + rotateButton = new QToolButton(toolBar); rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); rotateButton->setToggleButton(true); - if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { rotateButton->setOn(true); autoRotate = true; prevButton->hide(); nextButton->hide(); } else { rotateButton->setOn(false); autoRotate = false; } - connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); - scaleButton = new QToolButton(bar); + scaleButton = new QToolButton(toolBar); scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); scaleButton->setToggleButton(true); scaleButton->setOn(false); connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); autoScale = true; - zoomButton = new QToolButton(bar); + zoomButton = new QToolButton(toolBar); zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); zoomButton->setToggleButton(true); zoomButton->setOn(true); connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); zoomerOn = true; + +/* showmenu */ + m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), + 0, 0, this, 0, true ); + m_aHideToolbar->setOn (true); + m_aHideToolbar->addTo(dispMenu); + connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); +/* showmenu end*/ + } PMainWindow::~PMainWindow() { } void PMainWindow::slotToggleZoomer() { if (!m_disp) return; bool cur = zoomButton->isOn(); zoomButton->setOn(!cur); } void PMainWindow::slotZoomerToggled(bool how) { zoomerOn = how; if (m_disp) { @@ -164,35 +224,36 @@ void PMainWindow::slotToggleAutorotate() { if (!m_disp) return; if (!rotateButton->isEnabled()) return; bool cur = rotateButton->isOn(); rotateButton->setOn(!cur); } void PMainWindow::slotToggleAutoscale() { if (!m_disp) return; bool cur = scaleButton->isOn(); scaleButton->setOn(!cur); } void PMainWindow::slotRotateToggled(bool how) { + odebug << "Autorotate: " << how << oendl; autoRotate = how; if (m_disp) { - m_disp->setAutoRotate(how); + m_disp->setAutoScaleRotate(autoScale,autoRotate); } } void PMainWindow::slotScaleToggled(bool how) { autoScale = !how; if (!how) { autoRotate = how; } if (m_disp) { m_disp->setAutoScaleRotate(autoScale,autoRotate); } if (!autoScale) { rotateButton->setOn(false); } rotateButton->setEnabled(!how); @@ -354,48 +415,55 @@ void PMainWindow::slotToggleFullScreen() * 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_disp && m_disp->fullScreen() && m_disp->isVisible()) { return; } if ( !m_info ) { initInfo(); } m_info->setPath( inf ); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { prevButton->hide(); nextButton->hide(); - upButton->hide(); + m_aDirUp->setEnabled(false); + m_aShowInfo->setEnabled(false); + m_aViewfile->setEnabled(true); + m_aStartSlide->setEnabled(false); fsButton->hide(); viewModeButton->hide(); } m_stack->raiseWidget( ImageInfo ); } void PMainWindow::slotDisplay( const QString& inf ) { + odebug << "slotDisplay: " << inf << oendl; if ( !m_disp ) { initDisp(); } m_disp->setImage( inf ); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { prevButton->show(); nextButton->show(); - upButton->hide(); + m_aDirUp->setEnabled(false); + m_aShowInfo->setEnabled(true); + m_aViewfile->setEnabled(false); + m_aStartSlide->setEnabled(false); fsButton->hide(); viewModeButton->hide(); } if (m_disp->fullScreen()) { //m_disp->showFullScreen(); qwsDisplay()->requestFocus( m_disp->winId(), TRUE); } else { m_stack->raiseWidget( ImageDisplay ); } } void PMainWindow::slotReturn() { raiseIconView(); } @@ -411,36 +479,71 @@ void PMainWindow::closeEvent( QCloseEvent* ev ) { return; } if (m_disp && m_disp->fullScreen()) { /* otherwise opie-eye crashes in bigscreen mode! */ m_disp->reparent(0,QPoint(0,0)); m_stack->addWidget(m_disp,ImageDisplay); } ev->accept(); QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } void PMainWindow::raiseIconView() { setUpdatesEnabled(false); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { prevButton->hide(); nextButton->hide(); - upButton->show(); + m_aDirUp->setEnabled(true); + m_aShowInfo->setEnabled(true); + m_aViewfile->setEnabled(true); + m_aStartSlide->setEnabled(true); fsButton->show(); viewModeButton->show(); } if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { m_disp->hide(); } m_stack->raiseWidget( IconView ); setUpdatesEnabled(true); repaint(); } void PMainWindow::setDocument( const QString& showImg ) { QString file = showImg; DocLnk lnk(showImg); if (lnk.isValid() ) file = lnk.file(); slotDisplay( file ); } + +void PMainWindow::slotSelectDir(int id) +{ + emit changeDir( m_dev[fsMenu->text(id )] ); +} + +void PMainWindow::dirChanged() +{ + fsMenu->clear(); + m_dev.clear(); + + /* home dir, too */ + QString f = getenv( "HOME" ); + if (!f.isEmpty()) { + m_dev.insert("Home directory",f); + fsMenu->insertItem("Home directory"); + } + const QList<FileSystem> &fs = m_storage->fileSystems(); + QListIterator<FileSystem> it(fs ); + for ( ; it.current(); ++it ) { + const QString disk = (*it)->name(); + const QString path = (*it)->path(); + m_dev.insert( disk, path ); + fsMenu->insertItem( disk ); + } +} + +void PMainWindow::showToolbar(bool how) +{ + if (!how) toolBar->hide(); + else toolBar->show(); +}
\ No newline at end of file diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 6fa1ab6..ae1cc09 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h @@ -12,67 +12,85 @@ namespace Opie { namespace Ui{ class OWidgetStack; } namespace Core{ class OKeyConfigManager; } } class ImageView; class ImageWidget; class PIconView; class imageinfo; +class QMenuBar; +class QToolBar; +class QPopupMenu; +class QAction; +class StorageInfo; class PMainWindow : public QMainWindow { Q_OBJECT enum Views { IconView, ImageInfo, ImageDisplay }; public: static QString appName() { return QString::fromLatin1("opie-eye" ); } PMainWindow(QWidget*, const char*, WFlags ); ~PMainWindow(); signals: void configChanged(); + void changeDir( const QString& ); public slots: void slotShowInfo( const QString& inf ); void slotDisplay( const QString& inf ); void slotReturn(); void slotRotateToggled(bool); void slotScaleToggled(bool); void slotZoomerToggled(bool); void slotToggleZoomer(); void slotToggleAutorotate(); void slotToggleAutoscale(); void setDocument( const QString& ); virtual void slotToggleFullScreen(); protected slots: void raiseIconView(); void closeEvent( QCloseEvent* ); + void showToolbar(bool); private: template<class T> void initT( const char* name, T**, int ); void initInfo(); void initDisp(); private: Opie::Core::OConfig *m_cfg; Opie::Ui::OWidgetStack *m_stack; PIconView* m_view; imageinfo *m_info; ImageView *m_disp; bool autoRotate; bool autoScale; bool zoomerOn; - QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton; + QToolButton*rotateButton,*fsButton,*viewModeButton; QToolButton*nextButton,*prevButton,*zoomButton,*scaleButton; + QMenuBar *menuBar; + QToolBar *toolBar; + QPopupMenu *fileMenu,*dispMenu,*fsMenu; + QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide; + QAction*m_aHideToolbar; + + /* for the device submenu - ToDo: Merge with the special button */ + StorageInfo *m_storage; + QMap<QString, QString> m_dev; private slots: void slotConfig(); + void slotSelectDir(int); + void dirChanged(); }; #endif |