summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-05 16:28:16 (UTC)
committer alwin <alwin>2005-03-05 16:28:16 (UTC)
commitc017febf6f4092bb968d12df5a30a0af30066048 (patch) (side-by-side diff)
treecfeefc7fc3c2ee8a4485219e5dea502783f3db36
parent206e91c510caba81f41704f11b097307d8daa6cb (diff)
downloadopie-c017febf6f4092bb968d12df5a30a0af30066048.zip
opie-c017febf6f4092bb968d12df5a30a0af30066048.tar.gz
opie-c017febf6f4092bb968d12df5a30a0af30066048.tar.bz2
prepare for toggle of display mode of the different views
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp67
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h6
2 files changed, 52 insertions, 21 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 90e2e99..a96bfbd 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -35,59 +35,63 @@
#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" ) );
m_cfg = new Opie::Core::OConfig("opie-eye");
m_cfg->setGroup("main" );
readConfig();
m_setDocCalled = false;
m_polishDone = false;
+ m_SmallWindow = QApplication::desktop()->size().width()<330;
m_storage = new StorageInfo();
connect(m_storage, SIGNAL(disksChanged() ),
this, SLOT( dirChanged() ) );
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&)) );
connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
listviewMenu = 0;
/* setup menu and toolbar */
setupActions();
setupToolbar();
setupMenu();
m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
+ if (m_aForceSmall) {
+ m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true));
+ }
odebug << "mainwindow constructor done" << oendl;
}
PMainWindow::~PMainWindow() {
}
void PMainWindow::slotToggleZoomer()
{
m_aZoomer->setOn(!m_aZoomer->isOn());
}
void PMainWindow::slotZoomerToggled(bool how)
{
if (m_disp) {
m_disp->setShowZoomer(how);
}
@@ -241,35 +245,35 @@ void PMainWindow::initT( const char* name, T** ptr, int id) {
*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) {
- if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
+// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
//m_disp->setMinimumSize(QApplication::desktop()->size()/2);
- }
+// }
m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
m_disp->setAutoScale(!m_aUnscaled->isOn());
m_disp->setAutoRotate(m_aAutoRotate->isOn());
m_disp->setShowZoomer(m_aZoomer->isOn());
m_disp->setBackgroundColor(white);
connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
slotFullScreenToggled(m_aFullScreen->isOn());
}
@@ -293,43 +297,40 @@ void PMainWindow::slotFullScreenButton(bool current)
}
void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
{
if (!m_disp) {
return;
}
if (current) {
m_disp->setBackgroundColor(black);
m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
m_disp->setFullScreen(current,forceDisplay);
} else {
setUpdatesEnabled(false);
+#if 0
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
//m_disp->setMinimumSize(QApplication::desktop()->size()/2);
} else {
//m_disp->setMinimumSize(10,10);
}
- if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
- m_disp->reparent(0,QPoint(10,10));
- } else {
- m_disp->reparent(0,QPoint(0,0));
- }
+#endif
m_disp->setBackgroundColor(white);
m_stack->addWidget(m_disp,ImageDisplay);
m_disp->setVScrollBarMode(QScrollView::Auto);
m_disp->setHScrollBarMode(QScrollView::Auto);
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60);
}
if (forceDisplay || m_disp->isVisible()) {
m_stack->raiseWidget(m_disp);
m_disp->setFocus();
}
setUpdatesEnabled(true);
}
m_disp->setFullScreen(current,forceDisplay);
}
@@ -341,86 +342,87 @@ void PMainWindow::slotFullScreenToggled(bool current)
/**
* 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_disp && m_disp->fullScreen() && m_disp->isVisible()) {
return;
}
if ( !m_info ) {
initInfo();
}
m_info->setPath( inf );
- if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
+ if (m_SmallWindow) {
m_aNext->removeFrom(toolBar);
m_aPrevious->removeFrom(toolBar);
+ fsButton->hide();
+ }
m_aNext->setEnabled(false);
m_aPrevious->setEnabled(false);
m_aDirUp->setEnabled(false);
m_aShowInfo->setEnabled(false);
m_aViewfile->setEnabled(true);
m_aStartSlide->setEnabled(false);
- fsButton->hide();
- }
m_stack->raiseWidget( ImageInfo );
}
void PMainWindow::slotDisplay( const QString& inf ) {
bool nwindow = false;
if ( !m_disp ) {
nwindow = true;
initDisp();
}
m_disp->setImage( inf );
- if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
+ if (m_SmallWindow) {
if (m_gPrevNext->isEnabled()==false) {
m_gPrevNext->addTo(toolBar);
+ fsButton->hide();
+ }
+ }
m_gPrevNext->setEnabled(true);
-
m_aDirUp->setEnabled(false);
m_aShowInfo->setEnabled(true);
m_aViewfile->setEnabled(false);
m_aStartSlide->setEnabled(false);
- fsButton->hide();
- }
- }
+
if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
slotFullScreenToggled(m_aFullScreen->isOn());
}
if (m_disp->fullScreen()) {
qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
} else {
m_stack->raiseWidget( ImageDisplay );
}
}
void PMainWindow::raiseIconView() {
setUpdatesEnabled(false);
- if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
+ if (m_SmallWindow) {
m_gPrevNext->removeFrom(toolBar);
+ fsButton->show();
+ }
m_gPrevNext->setEnabled(false);
m_aDirUp->setEnabled(true);
m_aShowInfo->setEnabled(true);
m_aViewfile->setEnabled(true);
m_aStartSlide->setEnabled(true);
- fsButton->show();
- }
+
if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
m_disp->stopSlide();
m_disp->hide();
}
m_stack->raiseWidget( IconView );
setUpdatesEnabled(true);
repaint();
}
void PMainWindow::slotReturn() {
raiseIconView();
}
void PMainWindow::closeEvent( QCloseEvent* ev ) {
/*
@@ -609,58 +611,66 @@ void PMainWindow::setupActions()
}
m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true );
m_aZoomer->setToggleAction(true);
if (autoSave) {
m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true));
} else {
m_aZoomer->setOn (true);
}
connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
m_gDisplayType->insert(m_aAutoRotate);
m_gDisplayType->insert(m_aUnscaled);
m_gDisplayType->insert(m_aZoomer);
m_hGroup = new QActionGroup(this,"actioncollection",false);
m_hGroup->insert(m_aFullScreen);
+
+ if (!m_SmallWindow) {
+ m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true);
+ m_aForceSmall->setToggleAction(true);
+ connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool)));
+ } else {
+ m_aForceSmall = 0;
+ }
}
void PMainWindow::setupToolbar()
{
toolBar = new QToolBar( this );
addToolBar(toolBar);
toolBar->setHorizontalStretchable( true );
setToolBarsMovable( false );
m_aDirUp->addTo( toolBar );
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& ) ) );
if (m_aBeam) {
m_aBeam->addTo( toolBar );
}
m_aShowInfo->addTo(toolBar);
m_aTrash->addTo(toolBar);
// m_aSetup->addTo(toolBar);
m_gDisplayType->addTo(toolBar);
- if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
+ if (!m_SmallWindow) {
m_gPrevNext->addTo(toolBar);
} else {
m_gPrevNext->setEnabled(false);
}
}
void PMainWindow::setupMenu()
{
fileMenu = new QPopupMenu( menuBar() );
menuBar()->insertItem( tr( "File" ), fileMenu );
dispMenu = new QPopupMenu( menuBar() );
menuBar()->insertItem( tr( "Show" ), dispMenu );
settingsMenu = new QPopupMenu( menuBar() );
menuBar()->insertItem( tr( "Settings" ), settingsMenu );
m_aViewfile->addTo(fileMenu);
@@ -677,32 +687,36 @@ void PMainWindow::setupMenu()
if ( m_aBeam ) {
fileMenu->insertSeparator();
m_aBeam->addTo( fileMenu );
}
fileMenu->insertSeparator();
m_aTrash->addTo(fileMenu);
listviewMenu = new QPopupMenu(dispMenu);
dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
m_gListViewMode->addTo(listviewMenu);
dispMenu->insertSeparator();
m_aFullScreen->addTo(dispMenu);
m_gDisplayType->addTo(dispMenu);
dispMenu->insertSeparator();
m_gPrevNext->addTo(dispMenu);
+ if (m_aForceSmall) {
+ dispMenu->insertSeparator();
+ m_aForceSmall->addTo(dispMenu);
+ }
m_aSetup->addTo(settingsMenu);
m_aHideToolbar->addTo(settingsMenu);
}
void PMainWindow::listviewselected(QAction*which)
{
if (!which || which->isOn()==false) return;
int val = 1;
if (which==m_aDirName) {
val = 3;
} else if (which==m_aDirShort) {
val = 2;
} else if (which==m_aDirLong) {
val = 1;
@@ -724,16 +738,31 @@ void PMainWindow::polish()
m_setDocCalled = true;
m_view->setDoccalled(true);
m_disp->setCloseIfHide(true);
} else {
m_setDocCalled = false;
m_view->setDoccalled(false);
}
m_polishDone = true;
QMainWindow::polish();
if (m_setDocCalled) {
if (m_aFullScreen->isOn()) {
QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
} else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
}
}
}
+
+void PMainWindow::slotForceSmall(bool how)
+{
+ odebug << "Disable separate windows: " << how << oendl;
+ if (m_stack) {
+ if (how) {
+ m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
+ } else {
+ m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
+ }
+ }
+ if (autoSave) {
+ m_cfg->writeEntry("dontshowseperate",how);
+ }
+}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 2f54090..a49a9d3 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -67,44 +67,46 @@ protected slots:
void listviewselected(QAction*);
void slotFullScreenButton(bool);
void check_view_fullscreen();
private:
template<class T> void initT( const char* name, T**, int );
void initInfo();
void initDisp();
void setupViewWindow(bool full, bool forceDisplay);
private:
Opie::Core::OConfig *m_cfg;
Opie::Ui::OWidgetStack *m_stack;
PIconView* m_view;
imageinfo *m_info;
ImageView *m_disp;
- bool autoSave;
+ bool autoSave:1;
bool m_setDocCalled:1;
bool m_polishDone:1;
+ bool m_SmallWindow:1;
QToolButton*fsButton;
QToolBar *toolBar;
QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu,*settingsMenu;
QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide;
QAction*m_aHideToolbar,*m_aSetup,*m_aDirName,*m_aDirShort,*m_aDirLong;
QActionGroup *m_gListViewMode,*m_gDisplayType,*m_gPrevNext,*m_hGroup;
QAction *m_aNext,*m_aPrevious,*m_aFullScreen;
- QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer;
+ QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer,*m_aForceSmall;
/* init funs */
void readConfig();
void setupActions();
void setupToolbar();
void setupMenu();
/* 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();
+ void slotForceSmall(bool);
};
#endif