summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/mainwindow.cpp
blob: 0a2fcab289922ee15d4ae1e56fa97214e86b39ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * GPLv2 zecke@handhelds.org
 * No WArranty...
 */

#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 <opie/oapplicationfactory.h>
#include <opie/otabwidget.h>

#include <iface/ifaceinfo.h>
#include <iface/dirview.h>

#include "iconview.h"
#include "filesystem.h"

#include "mainwindow.h"

OPIE_EXPORT_APP( OApplicationFactory<PMainWindow> )

PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
    : QMainWindow( wid, name, style ), m_cfg("phunkview")
{
    setCaption( QObject::tr("Opie Eye Caramba" ) );
    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 );
    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() {
    QDialog dlg(this, 0, true);
    dlg.setCaption( tr("Phunk View - Config" ) );

    QHBoxLayout *lay = new QHBoxLayout(&dlg);
    OTabWidget *wid = new 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, QString::null, inf->name() );
    }

    dlg.showMaximized();
    bool act = ( dlg.exec() == 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);
        delete it.key();
    }

    if ( act )
        m_view->resetView();
}