summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp63
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h26
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp64
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h13
4 files changed, 139 insertions, 27 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 74a8d0f..b3f0006 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,53 +1,57 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#include "iconview.h"
#include <lib/imagecache.h>
#include <iface/dirview.h>
#include <iface/dirlister.h>
-#include <qpe/config.h>
+#include <opie2/oconfig.h>
+#include <opie2/okeyconfigwidget.h>
+
#include <qpe/resource.h>
#include <qpe/qpemessagebox.h>
#include <qpe/ir.h>
#include <qpe/qcopenvelope_qws.h>
+
#include <qiconview.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qcombobox.h>
#include <qdir.h>
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtimer.h>
#include <qstyle.h>
+using Opie::Ui::OKeyConfigItem;
namespace {
QPixmap* _dirPix = 0;
QPixmap* _unkPix = 0;
class IconViewItem : public QIconViewItem {
public:
IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
QPixmap* pixmap()const;
QString path()const { return m_path; }
bool isDir()const { return m_isDir; }
void setText( const QString& );
void reCalc();
private:
mutable QPixmap* m_pix;
QString m_path;
bool m_isDir : 1;
bool m_noInfo :1;
};
/*
* If we request an Image or String
* we add it to the map
*/
@@ -75,107 +79,149 @@ namespace {
}
m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
if ( !m_pix && !g_stringPix.contains( m_path )) {
currentView()->dirLister()->thumbNail( m_path, 64, 64 );
g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
}
return m_pix ? m_pix : _unkPix;
}
}
inline void IconViewItem::setText( const QString& str ) {
QString text = QIconViewItem::text()+"\n"+str;
m_noInfo = true;
QIconViewItem::setText( text );
reCalc();
}
inline void IconViewItem::reCalc()
{
calcRect();
}
}
-PIconView::PIconView( QWidget* wid, Config* cfg )
+PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
: QVBox( wid ), m_cfg( cfg )
{
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
}
m_path = QDir::homeDirPath();
QHBox *hbox = new QHBox( this );
QLabel* lbl = new QLabel( hbox );
lbl->setText( tr("View as" ) );
m_views = new QComboBox( hbox, "View As" );
connect( m_views, SIGNAL(activated(int)),
this, SLOT(slotViewChanged(int)) );
m_view= new QIconView( this );
connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
this, SLOT(slotClicked(QIconViewItem*)) );
m_view->setArrangement( QIconView::LeftToRight );
m_view->setItemTextPos( QIconView::Right );
m_view->setResizeMode(QIconView::Adjust);
int dw = QApplication::desktop()->width();
int viewerWidth = dw-style().scrollBarExtent().width();
m_view->setGridX( viewerWidth-2*m_view->spacing() );
m_view->setGridY( fontMetrics().height()*2+40 );
+
+
+ initKeys();
+
loadViews();
slotViewChanged( m_views->currentItem() );
}
PIconView::~PIconView() {
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
}
+ m_viewManager->save();
+ delete m_viewManager;
+}
+
+Opie::Ui::OKeyConfigManager* PIconView::manager() {
+ return m_viewManager;
+}
+
+void PIconView::initKeys() {
+ 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, "View-KeyBoard-Config",
+ lst, false,this, "keyconfig name" );
+ m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
+ QString::fromLatin1("beam"), BeamItem,
+ Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
+ this, SLOT(slotBeam())) );
+ m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
+ QString::fromLatin1("trash"), DeleteItem,
+ Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
+ this, SLOT(slotTrash())) );
+ m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
+ QString::fromLatin1("1to1"), ViewItem,
+ Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
+ this, SLOT(slotShowImage())));
+ m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
+ QString::fromLatin1("DocumentTypeWord"), InfoItem,
+ Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
+ this, SLOT(slotImageInfo()) ) );
+ m_viewManager->load();
+ m_viewManager->handleWidget( m_view );
}
void PIconView::slotDirUp() {
QDir dir( m_path );
dir.cdUp();
slotChangeDir( dir.absPath() );
}
void PIconView::slotChangeDir(const QString& path) {
if ( !currentView() )
return;
PDirLister *lister = currentView()->dirLister();
if (!lister )
return;
lister->setStartPath( path );
m_path = lister->currentPath();
+ m_view->setUpdatesEnabled( false );
m_view->clear();
addFolders( lister->folders() );
addFiles( lister->files() );
+ m_view->setUpdatesEnabled( true );
// Also invalidate the cache. We can't cancel the operations anyway
g_stringPix.clear();
g_stringInf.clear();
// looks ugly
static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
}
QString PIconView::currentFileName(bool &isDir)const {
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
void PIconView::slotTrash() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
@@ -296,24 +342,37 @@ void PIconView::slotRename() {
void PIconView::slotBeam() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
Ir* ir = new Ir( this );
connect( ir, SIGNAL(done(Ir*)),
this, SLOT(slotBeamDone(Ir*)));
ir->send(pa, tr( "Image" ) );
}
void PIconView::slotBeamDone( Ir* ir) {
delete ir;
}
void PIconView::slotStart() {
m_view->setUpdatesEnabled( false );
}
void PIconView::slotEnd() {
m_view->setUpdatesEnabled( true );
}
+
+void PIconView::slotShowImage() {
+
+}
+void PIconView::slotShowImage( const QString& ) {
+
+}
+void PIconView::slotImageInfo() {
+
+}
+void PIconView::slotImageInfo( const QString& ) {
+
+}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index 439833a..0fba327 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,59 +1,79 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#ifndef PHUNK_ICON_VIEW_H
#define PHUNK_ICON_VIEW_H
#include <qvbox.h>
-#include <qpe/config.h>
class QIconView;
class QIconViewItem;
class QComboBox;
class PIconViewItem;
class PDirLister;
class Ir;
+
+namespace Opie {
+namespace Core{
+ class OConfig;
+}
+namespace Ui {
+ class OKeyConfigManager;
+}
+}
+
class PIconView : public QVBox {
Q_OBJECT
friend class PIconViewItem;
+ enum ActionIds {
+ BeamItem, DeleteItem, ViewItem, InfoItem
+ };
public:
- PIconView( QWidget* wid, Config *cfg );
+ PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
~PIconView();
void resetView();
+ Opie::Ui::OKeyConfigManager* manager();
private:
+ void initKeys();
QString currentFileName(bool &isDir)const;
void loadViews();
private slots:
void slotDirUp();
void slotChangeDir(const QString&);
void slotTrash();
void slotViewChanged( int );
void slotReloadDir();
void slotRename();
void slotBeam();
void slotBeamDone( Ir* );
+ void slotShowImage();
+ void slotShowImage( const QString& );
+ void slotImageInfo();
+ void slotImageInfo( const QString& );
+
void slotStart();
void slotEnd();
/* for performance reasons make it inline in the future */
void addFolders( const QStringList& );
void addFiles( const QStringList& );
void slotClicked(QIconViewItem* );
/**/
void slotThumbInfo(const QString&, const QString&);
void slotThumbNail(const QString&, const QPixmap&);
private:
- Config *m_cfg;
+ Opie::Ui::OKeyConfigManager *m_viewManager;
+ Opie::Core::OConfig *m_cfg;
QComboBox* m_views;
QIconView* m_view;
QString m_path;
};
#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index ea765d1..0314659 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,114 +1,138 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
+#include "mainwindow.h"
+
+#include "iconview.h"
+#include "filesystem.h"
+
+#include <iface/ifaceinfo.h>
+#include <iface/dirview.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 <qtoolbar.h>
#include <qtoolbutton.h>
#include <qlayout.h>
#include <qdialog.h>
#include <qmap.h>
-#include <qpe/resource.h>
-#include <qpe/config.h>
-#include <qpe/ir.h>
-#include <opie2/oapplicationfactory.h>
-#include <opie2/otabwidget.h>
-#include <iface/ifaceinfo.h>
-#include <iface/dirview.h>
-#include "iconview.h"
-#include "filesystem.h"
-
-#include "mainwindow.h"
OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> )
PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
- : QMainWindow( wid, name, style ), m_cfg("phunkview")
+ : QMainWindow( wid, name, style )
{
setCaption( QObject::tr("Opie Eye Caramba" ) );
- m_cfg.setGroup("Zecke_view" );
+ m_cfg = new Opie::Core::OConfig("phunkview");
+ m_cfg->setGroup("Zecke_view" );
+
+
/*
* Initialize ToolBar and IconView
* And Connect Them
*/
QToolBar *bar = new QToolBar( this );
bar->setHorizontalStretchable( true );
setToolBarsMovable( false );
- m_view = new PIconView( this, &m_cfg );
+ m_view = new PIconView( this, m_cfg );
setCentralWidget( m_view );
QToolButton *btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "up" ) );
connect( btn, SIGNAL(clicked()),
m_view, SLOT(slotDirUp()) );
btn = new PFileSystem( bar );
connect( btn, SIGNAL( changeDir( const QString& ) ),
m_view, SLOT(slotChangeDir( const QString& ) ) );
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "edit" ) );
connect( btn, SIGNAL(clicked()),
m_view, SLOT(slotRename()) );
if ( Ir::supported() ) {
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "beam" ) );
connect( btn, SIGNAL(clicked()),
m_view, SLOT(slotBeam()) );
}
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "trash" ) );
connect( btn, SIGNAL(clicked() ),
m_view, SLOT(slotTrash() ) );
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
connect( btn, SIGNAL(clicked() ),
this, SLOT(slotConfig() ) );
}
PMainWindow::~PMainWindow() {
}
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);
+ PDirView *view = (_it.data())(*m_cfg);
PInterfaceInfo *inf = view->interfaceInfo();
- QWidget *_wid = inf->configWidget( m_cfg );
+ QWidget *_wid = inf->configWidget( *m_cfg );
_wid->reparent(wid, QPoint() );
lst.insert( view, _wid );
wid->addTab( _wid, QString::null, inf->name() );
}
- dlg.showMaximized();
- bool act = ( dlg.exec() == QDialog::Accepted );
+/*
+ * 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() );
+ keyWid->load();
+ wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
+
+
+ bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
QMap<PDirView*, QWidget*>::Iterator it;
for ( it = lst.begin(); it != lst.end(); ++it ) {
if ( act )
- it.key()->interfaceInfo()->writeConfig(it.data(), m_cfg);
+ it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
delete it.key();
}
- if ( act )
+ if ( act ) {
m_view->resetView();
+ keyWid->save();
+ }
}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 408fe32..317a51e 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -1,29 +1,38 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#ifndef PHUNK_MAIN_WINDOW_H
#define PHUNK_MAIN_WINDOW_H
+#include <opie2/oconfig.h>
+
#include <qmainwindow.h>
-#include <qpe/config.h>
+
+
+namespace Opie {
+namespace Ui{
+ class OKeyConfigManager;
+}
+}
class PIconView;
class PMainWindow : public QMainWindow {
Q_OBJECT
public:
static QString appName() { return QString::fromLatin1("opie-eye" ); }
PMainWindow(QWidget*, const char*, WFlags );
~PMainWindow();
private:
- Config m_cfg;
+ Opie::Core::OConfig *m_cfg;
PIconView* m_view;
+
private slots:
void slotConfig();
};
#endif