summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp3
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp24
2 files changed, 12 insertions, 15 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index be58c72..ebdfc60 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,132 +1,135 @@
#include "imageview.h"
#include <opie2/odebug.h>
#include <opie2/oconfig.h>
#include <opie2/okeyconfigwidget.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qaction.h>
using namespace Opie::Core;
ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
: Opie::MM::OImageScrollView(parent,name,fl)
{
m_viewManager = 0;
focus_in_count = 0;
m_cfg = cfg;
m_isFullScreen = false;
m_ignore_next_in = false;
m_slideTimer = 0;
QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
initKeys();
m_slideValue = 5;
m_gDisplayType = 0;
m_gPrevNext = 0;
m_hGroup = 0;
}
void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup)
{
m_gDisplayType = disptypeGroup;
m_gPrevNext = nextprevGroup;
m_hGroup = hGroup;
}
ImageView::~ImageView()
{
+ odebug << "Destructor imageview" << oendl;
delete m_viewManager;
}
Opie::Core::OKeyConfigManager* ImageView::manager()
{
if (!m_viewManager) {
initKeys();
}
return m_viewManager;
}
void ImageView::startSlide(int value)
{
if (!m_slideTimer) {
m_slideTimer = new QTimer(this);
}
m_slideValue=value;
connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide()));
/* this "+1" is one millisecond. with that we can setup a slideshowvalue
of 0. eg "as fast as possible".
*/
m_slideTimer->start(m_slideValue*1000+1,true);
}
void ImageView::stopSlide()
{
if (!m_slideTimer) {
return;
}
m_slideTimer->stop();
delete m_slideTimer;
m_slideTimer = 0;
}
void ImageView::nextSlide()
{
if (!m_slideTimer) {
return;
}
+#if 0
if (isHidden()) {
delete m_slideTimer;
m_slideTimer = 0;
return;
}
+#endif
emit dispNext();
m_slideTimer->start(m_slideValue*1000,true);
}
void ImageView::initKeys()
{
odebug << "init imageview keys" << oendl;
if (!m_cfg) {
m_cfg = new Opie::Core::OConfig("opie-eye");
m_cfg->setGroup("image_view_keys" );
}
Opie::Core::OKeyPair::List lst;
lst.append( Opie::Core::OKeyPair::upArrowKey() );
lst.append( Opie::Core::OKeyPair::downArrowKey() );
lst.append( Opie::Core::OKeyPair::leftArrowKey() );
lst.append( Opie::Core::OKeyPair::rightArrowKey() );
lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0));
m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
lst, false,this, "image_view_keys" );
/**
* Handle KeyEvents when they're pressed. This avoids problems
* with 'double next' on Return.
* The Return press would switch to this view and the return
* release would emit the dispNext Signal.
*/
m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed );
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
Resource::loadPixmap("1to1"), ViewInfo,
Opie::Core::OKeyPair(Qt::Key_I,0),
this, SLOT(slotShowImageInfo())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
Resource::loadPixmap("rotate"), Autorotate,
Opie::Core::OKeyPair(Qt::Key_R,0),
this, SIGNAL(toggleAutorotate())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale",
Resource::loadPixmap("1to1"), Autoscale,
Opie::Core::OKeyPair(Qt::Key_S,0),
this, SIGNAL(toggleAutoscale())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext",
Resource::loadPixmap("forward"), ShowNext,
Opie::Core::OKeyPair(Qt::Key_Return,0),
this, SIGNAL(dispNext())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev",
Resource::loadPixmap("back"), ShowPrevious,
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 5eb065f..6660eb2 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -169,267 +169,261 @@ void PMainWindow::slotConfig() {
keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
QWidget*w = m_stack->visibleWidget();
bool reminfo = false;
if ( !m_info ) {
reminfo = true;
initInfo();
}
keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
bool remdisp = false;
if ( !m_disp ) {
remdisp = true;
initDisp();
}
keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
keyWid->load();
wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
wid->setCurrentTab(0);
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();
bSetup->save_values();
readConfig();
}
delete keyWid;
m_stack->raiseWidget(w);
if (remdisp) {
- m_disp->disconnect(this, SLOT(slotReturn()));
- m_disp->setDestructiveClose();
- m_stack->removeWidget(m_disp);
- m_disp = 0;
+ m_disp->hide();
}
if (reminfo) {
- m_info->disconnect(this, SLOT(slotReturn()));
- m_info->setDestructiveClose();
- m_stack->removeWidget(m_info);
- m_info = 0;
+ m_info->hide();
}
}
/*
* 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_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) {
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());
}
}
void PMainWindow::slotToggleFullScreen()
{
bool current = !m_aFullScreen->isOn();
m_aFullScreen->setOn(current);
}
void PMainWindow::slotFullScreenButton(bool current)
{
if (autoSave) {
m_cfg->writeEntry("fullscreen",current);
}
if (!m_disp) return;
-
- if (m_disp->isHidden()) {
- /* it must get some setups for switch we can just do if the window is visible.
- so we must delete the imageview window and re-create it when displaying new
- image */
- return;
+ if (m_disp->isVisible()) {
+ setupViewWindow(current, true);
}
- setupViewWindow(current, true);
}
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());
} else {
setUpdatesEnabled(false);
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(50,50));
} else {
m_disp->reparent(0,QPoint(0,0));
}
m_disp->setBackgroundColor(white);
m_stack->addWidget(m_disp,ImageDisplay);
m_disp->setVScrollBarMode(QScrollView::Auto);
m_disp->setHScrollBarMode(QScrollView::Auto);
if (forceDisplay || m_disp->isVisible())
m_stack->raiseWidget(m_disp);
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->resize(m_disp->minimumSize());
}
setUpdatesEnabled(true);
}
m_disp->setFullScreen(current,forceDisplay);
}
void PMainWindow::slotFullScreenToggled(bool current)
{
setupViewWindow(current,true);
}
/**
* 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) {
m_aNext->removeFrom(toolBar);
m_aPrevious->removeFrom(toolBar);
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_gPrevNext->isEnabled()==false) {
m_gPrevNext->addTo(toolBar);
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) {
m_gPrevNext->removeFrom(toolBar);
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 ) {
/*
* return from view
* or properly quit
*/
if ( m_stack->visibleWidget() == m_info ||
m_stack->visibleWidget() == m_disp ) {
ev->ignore();
raiseIconView();
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);
}