summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp13
-rw-r--r--noncore/apps/opie-console/opie-console.pro8
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp20
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h28
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp15
-rw-r--r--noncore/apps/opie-console/profilemanager.h2
-rw-r--r--noncore/apps/opie-console/settings.ui23
7 files changed, 104 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 3c1c8ea..88d5823 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,156 +1,167 @@
1 1
2#include <qaction.h> 2#include <qaction.h>
3#include <qmenubar.h> 3#include <qmenubar.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qtoolbar.h> 6#include <qtoolbar.h>
7 7
8#include "configdialog.h"
8#include "metafactory.h" 9#include "metafactory.h"
9#include "profilemanager.h" 10#include "profilemanager.h"
10#include "mainwindow.h" 11#include "mainwindow.h"
11 12
12MainWindow::MainWindow() { 13MainWindow::MainWindow() {
13 m_factory = new MetaFactory(); 14 m_factory = new MetaFactory();
14 m_sessions.setAutoDelete( TRUE ); 15 m_sessions.setAutoDelete( TRUE );
15 m_curSession = 0; 16 m_curSession = 0;
16 m_manager = new ProfileManager(m_factory); 17 m_manager = new ProfileManager(m_factory);
18 m_manager->load();
17 19
18 initUI(); 20 initUI();
19 populateProfiles(); 21 populateProfiles();
20} 22}
21void MainWindow::initUI() { 23void MainWindow::initUI() {
22 setToolBarsMovable( FALSE ); 24 setToolBarsMovable( FALSE );
23 25
24 m_tool = new QToolBar( this ); 26 m_tool = new QToolBar( this );
25 m_tool->setHorizontalStretchable( TRUE ); 27 m_tool->setHorizontalStretchable( TRUE );
26 28
27 m_bar = new QMenuBar( m_tool ); 29 m_bar = new QMenuBar( m_tool );
28 m_console = new QPopupMenu( this ); 30 m_console = new QPopupMenu( this );
29 m_sessionsPop= new QPopupMenu( this ); 31 m_sessionsPop= new QPopupMenu( this );
30 m_settings = new QPopupMenu( this ); 32 m_settings = new QPopupMenu( this );
31 33
32 /* 34 /*
33 * new Action for new sessions 35 * new Action for new sessions
34 */ 36 */
35 QAction* a = new QAction(); 37 QAction* a = new QAction();
36 a->setText( tr("New Connection") ); 38 a->setText( tr("New Connection") );
37 a->addTo( m_console ); 39 a->addTo( m_console );
38 connect(a, SIGNAL(activated() ), 40 connect(a, SIGNAL(activated() ),
39 this, SLOT(slotNew() ) ); 41 this, SLOT(slotNew() ) );
40 42
41 43
42 44
43 /* 45 /*
44 * connect action 46 * connect action
45 */ 47 */
46 m_connect = new QAction(); 48 m_connect = new QAction();
47 m_connect->setText( tr("Connect") ); 49 m_connect->setText( tr("Connect") );
48 m_connect->addTo( m_console ); 50 m_connect->addTo( m_console );
49 connect(m_connect, SIGNAL(activated() ), 51 connect(m_connect, SIGNAL(activated() ),
50 this, SLOT(slotConnect() ) ); 52 this, SLOT(slotConnect() ) );
51 53
52 54
53 /* 55 /*
54 * disconnect action 56 * disconnect action
55 */ 57 */
56 m_disconnect = new QAction(); 58 m_disconnect = new QAction();
57 m_disconnect->setText( tr("Disconnect") ); 59 m_disconnect->setText( tr("Disconnect") );
58 m_disconnect->addTo( m_console ); 60 m_disconnect->addTo( m_console );
59 connect(m_disconnect, SIGNAL(activated() ), 61 connect(m_disconnect, SIGNAL(activated() ),
60 this, SLOT(slotDisconnect() ) ); 62 this, SLOT(slotDisconnect() ) );
61 63
62 /* 64 /*
63 * terminate action 65 * terminate action
64 */ 66 */
65 m_terminate = new QAction(); 67 m_terminate = new QAction();
66 m_terminate->setText( tr("Terminate") ); 68 m_terminate->setText( tr("Terminate") );
67 m_terminate->addTo( m_console ); 69 m_terminate->addTo( m_console );
68 connect(m_disconnect, SIGNAL(activated() ), 70 connect(m_disconnect, SIGNAL(activated() ),
69 this, SLOT(slotTerminate() ) ); 71 this, SLOT(slotTerminate() ) );
70 72
71 a = new QAction(); 73 a = new QAction();
72 a->setText( tr("Close Window") ); 74 a->setText( tr("Close Window") );
73 a->addTo( m_console ); 75 a->addTo( m_console );
74 connect(a, SIGNAL(activated() ), 76 connect(a, SIGNAL(activated() ),
75 this, SLOT(slotClose() ) ); 77 this, SLOT(slotClose() ) );
76 78
77 /* 79 /*
78 * the settings action 80 * the settings action
79 */ 81 */
80 m_setProfiles = new QAction(); 82 m_setProfiles = new QAction();
81 m_setProfiles->setText( tr("Configure Profiles") ); 83 m_setProfiles->setText( tr("Configure Profiles") );
82 m_setProfiles->addTo( m_settings ); 84 m_setProfiles->addTo( m_settings );
83 connect( m_setProfiles, SIGNAL(activated() ), 85 connect( m_setProfiles, SIGNAL(activated() ),
84 this, SLOT(slotConfigure() ) ); 86 this, SLOT(slotConfigure() ) );
85 87
86 /* insert the submenu */ 88 /* insert the submenu */
87 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 89 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
88 -1, 0); 90 -1, 0);
89 91
90 /* insert the connection menu */ 92 /* insert the connection menu */
91 m_bar->insertItem( tr("Connection"), m_console ); 93 m_bar->insertItem( tr("Connection"), m_console );
92 94
93 /* the settings menu */ 95 /* the settings menu */
94 m_bar->insertItem( tr("Settings"), m_settings ); 96 m_bar->insertItem( tr("Settings"), m_settings );
95 97
96 /* 98 /*
97 * connect to the menu activation 99 * connect to the menu activation
98 */ 100 */
99 connect( m_sessionsPop, SIGNAL(activated(int) ), 101 connect( m_sessionsPop, SIGNAL(activated(int) ),
100 this, SLOT(slotProfile(int) ) ); 102 this, SLOT(slotProfile(int) ) );
101 103
102} 104}
103ProfileManager* MainWindow::manager() { 105ProfileManager* MainWindow::manager() {
104 return m_manager; 106 return m_manager;
105} 107}
106void MainWindow::populateProfiles() { 108void MainWindow::populateProfiles() {
107 manager()->load(); 109 m_sessionsPop->clear();
108 Profile::ValueList list = manager()->all(); 110 Profile::ValueList list = manager()->all();
109 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); 111 for (Profile::ValueList::Iterator it = list.begin(); it != list.end();
110 ++it ) { 112 ++it ) {
111 m_sessionsPop->insertItem( (*it).name() ); 113 m_sessionsPop->insertItem( (*it).name() );
112 } 114 }
113 115
114} 116}
115MainWindow::~MainWindow() { 117MainWindow::~MainWindow() {
116 delete m_factory; 118 delete m_factory;
117} 119}
118 120
119MetaFactory* MainWindow::factory() { 121MetaFactory* MainWindow::factory() {
120 return m_factory; 122 return m_factory;
121} 123}
122 124
123Session* MainWindow::currentSession() { 125Session* MainWindow::currentSession() {
124 return m_curSession; 126 return m_curSession;
125} 127}
126 128
127QList<Session> MainWindow::sessions() { 129QList<Session> MainWindow::sessions() {
128 return m_sessions; 130 return m_sessions;
129} 131}
130void MainWindow::slotNew() { 132void MainWindow::slotNew() {
131 qWarning("New Connection"); 133 qWarning("New Connection");
132} 134}
133void MainWindow::slotConnect() { 135void MainWindow::slotConnect() {
134 if ( currentSession() ) 136 if ( currentSession() )
135 currentSession()->layer()->open(); 137 currentSession()->layer()->open();
136} 138}
137void MainWindow::slotDisconnect() { 139void MainWindow::slotDisconnect() {
138 if ( currentSession() ) 140 if ( currentSession() )
139 currentSession()->layer()->close(); 141 currentSession()->layer()->close();
140} 142}
141void MainWindow::slotTerminate() { 143void MainWindow::slotTerminate() {
142 if ( currentSession() ) 144 if ( currentSession() )
143 currentSession()->layer()->close(); 145 currentSession()->layer()->close();
144 delete m_curSession; 146 delete m_curSession;
145 m_curSession = 0l; 147 m_curSession = 0l;
146 /* FIXME move to the next session */ 148 /* FIXME move to the next session */
147} 149}
148void MainWindow::slotConfigure() { 150void MainWindow::slotConfigure() {
149 qWarning("configure"); 151 qWarning("configure");
152 ConfigDialog conf( manager()->all() );
153 conf.showMaximized();
154
155 int ret = conf.exec();
156
157 if ( QDialog::Accepted == ret ) {
158 manager()->setProfiles( conf.list() );
159 populateProfiles();
160 }
150} 161}
151void MainWindow::slotClose() { 162void MainWindow::slotClose() {
152 163
153} 164}
154void MainWindow::slotProfile(int) { 165void MainWindow::slotProfile(int) {
155 166
156} 167}
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index e045a48..9e44ab0 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,28 +1,30 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = io_layer.h io_serial.h \ 4HEADERS = io_layer.h io_serial.h \
5 file_layer.h \ 5 file_layer.h \
6 metafactory.h \ 6 metafactory.h \
7 session.h \ 7 session.h \
8 mainwindow.h \ 8 mainwindow.h \
9 profile.h \ 9 profile.h \
10 profileconfig.h \ 10 profileconfig.h \
11 profilemanager.h \ 11 profilemanager.h \
12 configwidget.h \ 12 configwidget.h \
13 tabwidget.h 13 tabwidget.h \
14 configdialog.h
14SOURCES = io_layer.cpp io_serial.cpp \ 15SOURCES = io_layer.cpp io_serial.cpp \
15 file_layer.cpp main.cpp \ 16 file_layer.cpp main.cpp \
16 metafactory.cpp \ 17 metafactory.cpp \
17 session.cpp \ 18 session.cpp \
18 mainwindow.cpp \ 19 mainwindow.cpp \
19 profile.cpp \ 20 profile.cpp \
20 profileconfig.cpp \ 21 profileconfig.cpp \
21 profilemanager.cpp \ 22 profilemanager.cpp \
22 tabwidget.cpp 23 tabwidget.cpp \
23INTERFACES = 24 configdialog.cpp
25INTERFACES = configurebase.ui editbase.ui
24INCLUDEPATH += $(OPIEDIR)/include 26INCLUDEPATH += $(OPIEDIR)/include
25DEPENDPATH += $(OPIEDIR)/include 27DEPENDPATH += $(OPIEDIR)/include
26LIBS += -lqpe -lopie 28LIBS += -lqpe -lopie
27TARGET = opie-console 29TARGET = opie-console
28 30
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
new file mode 100644
index 0000000..a4246e1
--- a/dev/null
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -0,0 +1,20 @@
1
2#include "profileeditordialog.h"
3
4
5ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
6 const Profile& prof )
7 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
8{
9 initUI();
10 /* now set the widgets */
11}
12ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
13 : QDialog(0, 0, TRUE), m_fact( fact )
14{
15
16}
17ProfileEditorDialog::~ProfileEditorDialog() {
18
19}
20
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
new file mode 100644
index 0000000..5ccc691
--- a/dev/null
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -0,0 +1,28 @@
1#ifndef PROFILE_EDITOR_DIALOG
2#define PROFILE_EDITOR_DIALOG
3
4#include <qdialog.h>
5
6#include "profile.h"
7
8class MetaFactory;
9class EditBase;
10class QTabWidget;
11class QHBoxLayout;
12class ProfileEditorDialog : public QDialog {
13 Q_OBJECT
14public:
15 ProfileEditorDialog(MetaFactory* fact,
16 const Profile& prof );
17 ProfileEditorDialog(MetaFactory* fact );
18 Profile profile()const;
19private:
20 void initUI();
21 MetaFactory* m_fact;
22 EditBase* m_base;
23 QTabWidget* m_tab;
24 QHBoxLayout* m_lay;
25 Profile m_prof;
26};
27
28#endif
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 24256a5..72a5117 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -31,50 +31,63 @@ void ProfileManager::load() {
31 prof.setIOLayer( conf.readEntry("iolayer") ); 31 prof.setIOLayer( conf.readEntry("iolayer") );
32 prof.setBackground( conf.readNumEntry("back") ); 32 prof.setBackground( conf.readNumEntry("back") );
33 prof.setForeground( conf.readNumEntry("fore") ); 33 prof.setForeground( conf.readNumEntry("fore") );
34 prof.setTerminal( conf.readNumEntry("terminal") ); 34 prof.setTerminal( conf.readNumEntry("terminal") );
35 prof.setConf( conf.items( (*it) ) ); 35 prof.setConf( conf.items( (*it) ) );
36 36
37 /* now add it */ 37 /* now add it */
38 m_list.append( prof ); 38 m_list.append( prof );
39 } 39 }
40 40
41} 41}
42void ProfileManager::clear() { 42void ProfileManager::clear() {
43 m_list.clear(); 43 m_list.clear();
44} 44}
45Profile::ValueList ProfileManager::all()const { 45Profile::ValueList ProfileManager::all()const {
46 return m_list; 46 return m_list;
47} 47}
48Session* ProfileManager::fromProfile( const Profile& prof) { 48Session* ProfileManager::fromProfile( const Profile& prof) {
49 Session* session = new Session(); 49 Session* session = new Session();
50 session->setName( prof.name() ); 50 session->setName( prof.name() );
51 session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), 51 session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(),
52 prof) ); 52 prof) );
53 /* 53 /*
54 * FIXME 54 * FIXME
55 * load emulation 55 * load emulation
56 * load widget? 56 * load widget?
57 * set colors + fonts 57 * set colors + fonts
58 */ 58 */
59 return session; 59 return session;
60} 60}
61void ProfileManager::save( ) { 61void ProfileManager::save( ) {
62 ProfileConfig conf("opie-console-profiles"); 62 ProfileConfig conf("opie-console-profiles");
63 conf.clearAll(); 63 conf.clearAll();
64 Profile::ValueList::Iterator it; 64 Profile::ValueList::Iterator it;
65 for (it = m_list.begin(); it != m_list.end(); ++it ) { 65 for (it = m_list.begin(); it != m_list.end(); ++it ) {
66 conf.setGroup( (*it).name() ); 66 conf.setGroup( (*it).name() );
67 conf.writeEntry( "name", (*it).name() ); 67 conf.writeEntry( "name", (*it).name() );
68 conf.writeEntry( "ioplayer", (*it).ioLayerName() ); 68 conf.writeEntry( "ioplayer", (*it).ioLayerName() );
69 conf.writeEntry( "back", (*it).background() ); 69 conf.writeEntry( "back", (*it).background() );
70 conf.writeEntry( "fore", (*it).foreground() ); 70 conf.writeEntry( "fore", (*it).foreground() );
71 conf.writeEntry( "terminal", (*it).terminal() ); 71 conf.writeEntry( "terminal", (*it).terminal() );
72 /* now the config stuff */ 72 /* now the config stuff */
73 QMap<QString, QString> map = (*it).conf(); 73 QMap<QString, QString> map = (*it).conf();
74 QMap<QString, QString>::Iterator it; 74 QMap<QString, QString>::Iterator it;
75 for ( it = map.begin(); it != map.end(); ++it ) { 75 for ( it = map.begin(); it != map.end(); ++it ) {
76 conf.writeEntry( it.key(), it.data() ); 76 conf.writeEntry( it.key(), it.data() );
77 } 77 }
78 } 78 }
79 // FIXME save 79}
80void ProfileManager::setProfiles( const Profile::ValueList& list ) {
81 m_list = list;
82};
83Profile ProfileManager::profile( const QString& name )const {
84 Profile prof;
85 Profile::ValueList::ConstIterator it;
86 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
87 if ( name == (*it).name() ) {
88 prof = (*it);
89 break;
90 }
91 }
92 return prof;
80} 93}
diff --git a/noncore/apps/opie-console/profilemanager.h b/noncore/apps/opie-console/profilemanager.h
index d4d0fd0..1387247 100644
--- a/noncore/apps/opie-console/profilemanager.h
+++ b/noncore/apps/opie-console/profilemanager.h
@@ -1,30 +1,32 @@
1#ifndef OPIE_PROFILE_MANAGER_H 1#ifndef OPIE_PROFILE_MANAGER_H
2#define OPIE_PROFILE_MANAGER_H 2#define OPIE_PROFILE_MANAGER_H
3 3
4#include <qlist.h> 4#include <qlist.h>
5 5
6#include "session.h" 6#include "session.h"
7#include "profile.h" 7#include "profile.h"
8 8
9class MetaFactory; 9class MetaFactory;
10class ConfigWidget; 10class ConfigWidget;
11class ProfileManager { 11class ProfileManager {
12public: 12public:
13 ProfileManager(MetaFactory*); 13 ProfileManager(MetaFactory*);
14 ~ProfileManager(); 14 ~ProfileManager();
15 15
16 void load(); 16 void load();
17 Profile::ValueList all()const; 17 Profile::ValueList all()const;
18 void clear(); 18 void clear();
19 /** 19 /**
20 * also replaces the item 20 * also replaces the item
21 */ 21 */
22 void add( const Profile& prof ); 22 void add( const Profile& prof );
23 void remove( const Profile& prof ); 23 void remove( const Profile& prof );
24 Profile profile(const QString& name )const;
24 Session* fromProfile( const Profile& ); 25 Session* fromProfile( const Profile& );
26 void setProfiles( const Profile::ValueList& );
25 void save(); 27 void save();
26private: 28private:
27 MetaFactory* m_fact; 29 MetaFactory* m_fact;
28 Profile::ValueList m_list; 30 Profile::ValueList m_list;
29}; 31};
30#endif 32#endif
diff --git a/noncore/apps/opie-console/settings.ui b/noncore/apps/opie-console/settings.ui
new file mode 100644
index 0000000..6944dd0
--- a/dev/null
+++ b/noncore/apps/opie-console/settings.ui
@@ -0,0 +1,23 @@
1<!DOCTYPE UI><UI>
2<class>Settings</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Settings</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>596</width>
15 <height>480</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Settings</string>
21 </property>
22</widget>
23</UI>