author | zecke <zecke> | 2002-09-28 20:45:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-28 20:45:11 (UTC) |
commit | 7980189a2cb34e2864c339ef68bfbe7fb4910750 (patch) (unidiff) | |
tree | a14028faccc70982d105c229f84d77e13741e987 /noncore/apps | |
parent | b6df65ad2ffb50f029b96ebf9d0d78dfa23f3f19 (diff) | |
download | opie-7980189a2cb34e2864c339ef68bfbe7fb4910750.zip opie-7980189a2cb34e2864c339ef68bfbe7fb4910750.tar.gz opie-7980189a2cb34e2864c339ef68bfbe7fb4910750.tar.bz2 |
Add profiles and the profilemanager to the mainwindow
if one would have a ConfigureDialog one could see it....
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 33 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileconfig.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 2 |
4 files changed, 46 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 1ae4a20..3c1c8ea 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,40 +1,43 @@ | |||
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 "metafactory.h" | 8 | #include "metafactory.h" |
9 | #include "profilemanager.h" | ||
9 | #include "mainwindow.h" | 10 | #include "mainwindow.h" |
10 | 11 | ||
11 | MainWindow::MainWindow() { | 12 | MainWindow::MainWindow() { |
12 | m_factory = new MetaFactory(); | 13 | m_factory = new MetaFactory(); |
13 | m_sessions.setAutoDelete( TRUE ); | 14 | m_sessions.setAutoDelete( TRUE ); |
14 | m_curSession = 0; | 15 | m_curSession = 0; |
16 | m_manager = new ProfileManager(m_factory); | ||
15 | 17 | ||
16 | initUI(); | 18 | initUI(); |
19 | populateProfiles(); | ||
17 | } | 20 | } |
18 | void MainWindow::initUI() { | 21 | void MainWindow::initUI() { |
19 | setToolBarsMovable( FALSE ); | 22 | setToolBarsMovable( FALSE ); |
20 | 23 | ||
21 | m_tool = new QToolBar( this ); | 24 | m_tool = new QToolBar( this ); |
22 | m_tool->setHorizontalStretchable( TRUE ); | 25 | m_tool->setHorizontalStretchable( TRUE ); |
23 | 26 | ||
24 | m_bar = new QMenuBar( m_tool ); | 27 | m_bar = new QMenuBar( m_tool ); |
25 | m_console = new QPopupMenu( this ); | 28 | m_console = new QPopupMenu( this ); |
26 | m_sessionsPop= new QPopupMenu( this ); | 29 | m_sessionsPop= new QPopupMenu( this ); |
27 | m_settings = new QPopupMenu( this ); | 30 | m_settings = new QPopupMenu( this ); |
28 | 31 | ||
29 | /* | 32 | /* |
30 | * new Action for new sessions | 33 | * new Action for new sessions |
31 | */ | 34 | */ |
32 | QAction* a = new QAction(); | 35 | QAction* a = new QAction(); |
33 | a->setText( tr("New Connection") ); | 36 | a->setText( tr("New Connection") ); |
34 | a->addTo( m_console ); | 37 | a->addTo( m_console ); |
35 | connect(a, SIGNAL(activated() ), | 38 | connect(a, SIGNAL(activated() ), |
36 | this, SLOT(slotNew() ) ); | 39 | this, SLOT(slotNew() ) ); |
37 | 40 | ||
38 | 41 | ||
39 | 42 | ||
40 | /* | 43 | /* |
@@ -44,80 +47,110 @@ void MainWindow::initUI() { | |||
44 | m_connect->setText( tr("Connect") ); | 47 | m_connect->setText( tr("Connect") ); |
45 | m_connect->addTo( m_console ); | 48 | m_connect->addTo( m_console ); |
46 | connect(m_connect, SIGNAL(activated() ), | 49 | connect(m_connect, SIGNAL(activated() ), |
47 | this, SLOT(slotConnect() ) ); | 50 | this, SLOT(slotConnect() ) ); |
48 | 51 | ||
49 | 52 | ||
50 | /* | 53 | /* |
51 | * disconnect action | 54 | * disconnect action |
52 | */ | 55 | */ |
53 | m_disconnect = new QAction(); | 56 | m_disconnect = new QAction(); |
54 | m_disconnect->setText( tr("Disconnect") ); | 57 | m_disconnect->setText( tr("Disconnect") ); |
55 | m_disconnect->addTo( m_console ); | 58 | m_disconnect->addTo( m_console ); |
56 | connect(m_disconnect, SIGNAL(activated() ), | 59 | connect(m_disconnect, SIGNAL(activated() ), |
57 | this, SLOT(slotDisconnect() ) ); | 60 | this, SLOT(slotDisconnect() ) ); |
58 | 61 | ||
59 | /* | 62 | /* |
60 | * terminate action | 63 | * terminate action |
61 | */ | 64 | */ |
62 | m_terminate = new QAction(); | 65 | m_terminate = new QAction(); |
63 | m_terminate->setText( tr("Terminate") ); | 66 | m_terminate->setText( tr("Terminate") ); |
64 | m_terminate->addTo( m_console ); | 67 | m_terminate->addTo( m_console ); |
65 | connect(m_disconnect, SIGNAL(activated() ), | 68 | connect(m_disconnect, SIGNAL(activated() ), |
66 | this, SLOT(slotTerminate() ) ); | 69 | this, SLOT(slotTerminate() ) ); |
67 | 70 | ||
71 | a = new QAction(); | ||
72 | a->setText( tr("Close Window") ); | ||
73 | a->addTo( m_console ); | ||
74 | connect(a, SIGNAL(activated() ), | ||
75 | this, SLOT(slotClose() ) ); | ||
76 | |||
68 | /* | 77 | /* |
69 | * the settings action | 78 | * the settings action |
70 | */ | 79 | */ |
71 | m_setProfiles = new QAction(); | 80 | m_setProfiles = new QAction(); |
72 | m_setProfiles->setText( tr("Configure Profiles") ); | 81 | m_setProfiles->setText( tr("Configure Profiles") ); |
73 | m_setProfiles->addTo( m_settings ); | 82 | m_setProfiles->addTo( m_settings ); |
74 | connect( m_setProfiles, SIGNAL(activated() ), | 83 | connect( m_setProfiles, SIGNAL(activated() ), |
75 | this, SLOT(slotConfigure() ) ); | 84 | this, SLOT(slotConfigure() ) ); |
76 | 85 | ||
77 | /* insert the submenu */ | 86 | /* insert the submenu */ |
78 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 87 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
79 | -1, 0); | 88 | -1, 0); |
80 | 89 | ||
81 | /* insert the connection menu */ | 90 | /* insert the connection menu */ |
82 | m_bar->insertItem( tr("Connection"), m_console ); | 91 | m_bar->insertItem( tr("Connection"), m_console ); |
83 | 92 | ||
84 | /* the settings menu */ | 93 | /* the settings menu */ |
85 | m_bar->insertItem( tr("Settings"), m_settings ); | 94 | m_bar->insertItem( tr("Settings"), m_settings ); |
86 | 95 | ||
96 | /* | ||
97 | * connect to the menu activation | ||
98 | */ | ||
99 | connect( m_sessionsPop, SIGNAL(activated(int) ), | ||
100 | this, SLOT(slotProfile(int) ) ); | ||
101 | |||
102 | } | ||
103 | ProfileManager* MainWindow::manager() { | ||
104 | return m_manager; | ||
105 | } | ||
106 | void MainWindow::populateProfiles() { | ||
107 | manager()->load(); | ||
108 | Profile::ValueList list = manager()->all(); | ||
109 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); | ||
110 | ++it ) { | ||
111 | m_sessionsPop->insertItem( (*it).name() ); | ||
112 | } | ||
113 | |||
87 | } | 114 | } |
88 | MainWindow::~MainWindow() { | 115 | MainWindow::~MainWindow() { |
89 | delete m_factory; | 116 | delete m_factory; |
90 | } | 117 | } |
91 | 118 | ||
92 | MetaFactory* MainWindow::factory() { | 119 | MetaFactory* MainWindow::factory() { |
93 | return m_factory; | 120 | return m_factory; |
94 | } | 121 | } |
95 | 122 | ||
96 | Session* MainWindow::currentSession() { | 123 | Session* MainWindow::currentSession() { |
97 | return m_curSession; | 124 | return m_curSession; |
98 | } | 125 | } |
99 | 126 | ||
100 | QList<Session> MainWindow::sessions() { | 127 | QList<Session> MainWindow::sessions() { |
101 | return m_sessions; | 128 | return m_sessions; |
102 | } | 129 | } |
103 | void MainWindow::slotNew() { | 130 | void MainWindow::slotNew() { |
104 | qWarning("New Connection"); | 131 | qWarning("New Connection"); |
105 | } | 132 | } |
106 | void MainWindow::slotConnect() { | 133 | void MainWindow::slotConnect() { |
107 | if ( currentSession() ) | 134 | if ( currentSession() ) |
108 | currentSession()->layer()->open(); | 135 | currentSession()->layer()->open(); |
109 | } | 136 | } |
110 | void MainWindow::slotDisconnect() { | 137 | void MainWindow::slotDisconnect() { |
111 | if ( currentSession() ) | 138 | if ( currentSession() ) |
112 | currentSession()->layer()->close(); | 139 | currentSession()->layer()->close(); |
113 | } | 140 | } |
114 | void MainWindow::slotTerminate() { | 141 | void MainWindow::slotTerminate() { |
115 | if ( currentSession() ) | 142 | if ( currentSession() ) |
116 | currentSession()->layer()->close(); | 143 | currentSession()->layer()->close(); |
117 | delete m_curSession; | 144 | delete m_curSession; |
118 | m_curSession = 0l; | 145 | m_curSession = 0l; |
119 | /* FIXME move to the next session */ | 146 | /* FIXME move to the next session */ |
120 | } | 147 | } |
121 | void MainWindow::slotConfigure() { | 148 | void MainWindow::slotConfigure() { |
122 | qWarning("configure"); | 149 | qWarning("configure"); |
123 | } | 150 | } |
151 | void MainWindow::slotClose() { | ||
152 | |||
153 | } | ||
154 | void MainWindow::slotProfile(int) { | ||
155 | |||
156 | } | ||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index b6a8419..be4b469 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,79 +1,89 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * this is the MainWindow of the new opie console | 10 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 11 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 12 | * actions supported by the gui |
13 | */ | 13 | */ |
14 | class QToolBar; | 14 | class QToolBar; |
15 | class QMenuBar; | 15 | class QMenuBar; |
16 | class QAction; | 16 | class QAction; |
17 | class MetaFactory; | 17 | class MetaFactory; |
18 | 18 | ||
19 | class ProfileManager; | ||
19 | class MainWindow : public QMainWindow { | 20 | class MainWindow : public QMainWindow { |
20 | Q_OBJECT | 21 | Q_OBJECT |
21 | public: | 22 | public: |
22 | MainWindow( ); | 23 | MainWindow( ); |
23 | ~MainWindow(); | 24 | ~MainWindow(); |
24 | 25 | ||
25 | /** | 26 | /** |
26 | * our factory to generate IOLayer and so on | 27 | * our factory to generate IOLayer and so on |
27 | * | 28 | * |
28 | */ | 29 | */ |
29 | MetaFactory* factory(); | 30 | MetaFactory* factory(); |
30 | 31 | ||
31 | /** | 32 | /** |
32 | * A session contains a QWidget*, | 33 | * A session contains a QWidget*, |
33 | * an IOLayer* and some infos for us | 34 | * an IOLayer* and some infos for us |
34 | */ | 35 | */ |
35 | Session* currentSession(); | 36 | Session* currentSession(); |
36 | 37 | ||
37 | /** | 38 | /** |
38 | * the session list | 39 | * the session list |
39 | */ | 40 | */ |
40 | QList<Session> sessions(); | 41 | QList<Session> sessions(); |
41 | 42 | ||
43 | /** | ||
44 | * | ||
45 | */ | ||
46 | ProfileManager* manager(); | ||
47 | |||
42 | private slots: | 48 | private slots: |
43 | void slotNew(); | 49 | void slotNew(); |
44 | void slotConnect(); | 50 | void slotConnect(); |
45 | void slotDisconnect(); | 51 | void slotDisconnect(); |
46 | void slotTerminate(); | 52 | void slotTerminate(); |
47 | void slotConfigure(); | 53 | void slotConfigure(); |
54 | void slotClose(); | ||
55 | void slotProfile(int); | ||
48 | 56 | ||
49 | private: | 57 | private: |
50 | void initUI(); | 58 | void initUI(); |
59 | void populateProfiles(); | ||
51 | /** | 60 | /** |
52 | * the current session | 61 | * the current session |
53 | */ | 62 | */ |
54 | Session* m_curSession; | 63 | Session* m_curSession; |
55 | 64 | ||
56 | /** | 65 | /** |
57 | * the session list | 66 | * the session list |
58 | */ | 67 | */ |
59 | QList<Session> m_sessions; | 68 | QList<Session> m_sessions; |
60 | 69 | ||
61 | /** | 70 | /** |
62 | * the metafactory | 71 | * the metafactory |
63 | */ | 72 | */ |
64 | MetaFactory* m_factory; | 73 | MetaFactory* m_factory; |
74 | ProfileManager* m_manager; | ||
65 | 75 | ||
66 | QToolBar* m_tool; | 76 | QToolBar* m_tool; |
67 | QMenuBar* m_bar; | 77 | QMenuBar* m_bar; |
68 | QPopupMenu* m_console; | 78 | QPopupMenu* m_console; |
69 | QPopupMenu* m_settings; | 79 | QPopupMenu* m_settings; |
70 | QPopupMenu* m_sessionsPop; | 80 | QPopupMenu* m_sessionsPop; |
71 | QAction* m_connect; | 81 | QAction* m_connect; |
72 | QAction* m_disconnect; | 82 | QAction* m_disconnect; |
73 | QAction* m_terminate; | 83 | QAction* m_terminate; |
74 | QAction* m_setProfiles; | 84 | QAction* m_setProfiles; |
75 | 85 | ||
76 | }; | 86 | }; |
77 | 87 | ||
78 | 88 | ||
79 | #endif | 89 | #endif |
diff --git a/noncore/apps/opie-console/profileconfig.cpp b/noncore/apps/opie-console/profileconfig.cpp index bd089c8..732fae7 100644 --- a/noncore/apps/opie-console/profileconfig.cpp +++ b/noncore/apps/opie-console/profileconfig.cpp | |||
@@ -1,38 +1,39 @@ | |||
1 | 1 | ||
2 | #include "profileconfig.h" | 2 | #include "profileconfig.h" |
3 | 3 | ||
4 | ProfileConfig::ProfileConfig( const QString& prof ) | 4 | ProfileConfig::ProfileConfig( const QString& prof ) |
5 | : Config( prof ) | 5 | : Config( prof ) |
6 | { | 6 | { |
7 | } | 7 | } |
8 | ProfileConfig::~ProfileConfig() { | 8 | ProfileConfig::~ProfileConfig() { |
9 | 9 | ||
10 | } | 10 | } |
11 | QStringList ProfileConfig::groups()const { | 11 | QStringList ProfileConfig::groups()const { |
12 | QStringList list; | 12 | QStringList list; |
13 | QMap<QString, ConfigGroup>::ConstIterator it; | 13 | QMap<QString, ConfigGroup>::ConstIterator it; |
14 | it= Config::groups.begin(); | 14 | it= Config::groups.begin(); |
15 | qWarning("config %d", Config::groups.count() ); | ||
15 | 16 | ||
16 | for (; it != Config::groups.end(); ++it ) | 17 | for (; it != Config::groups.end(); ++it ) |
17 | list << it.key(); | 18 | list << it.key(); |
18 | 19 | ||
19 | 20 | ||
20 | return list; | 21 | return list; |
21 | 22 | ||
22 | } | 23 | } |
23 | void ProfileConfig::clearAll() { | 24 | void ProfileConfig::clearAll() { |
24 | QMap<QString, ConfigGroup>::ConstIterator it; | 25 | QMap<QString, ConfigGroup>::ConstIterator it; |
25 | it = Config::groups.begin(); | 26 | it = Config::groups.begin(); |
26 | 27 | ||
27 | for ( ; it != Config::groups.end(); ++it ) | 28 | for ( ; it != Config::groups.end(); ++it ) |
28 | clearGroup( it.key() ); | 29 | clearGroup( it.key() ); |
29 | } | 30 | } |
30 | void ProfileConfig::clearGroup( const QString& str ) { | 31 | void ProfileConfig::clearGroup( const QString& str ) { |
31 | QString cur =git.key(); | 32 | QString cur =git.key(); |
32 | setGroup( str ); | 33 | setGroup( str ); |
33 | Config::clearGroup(); | 34 | Config::clearGroup(); |
34 | setGroup( cur ); | 35 | setGroup( cur ); |
35 | } | 36 | } |
36 | QMap<QString, QString> ProfileConfig::items( const QString& group )const { | 37 | QMap<QString, QString> ProfileConfig::items( const QString& group )const { |
37 | QMap<QString, QString> map; | 38 | QMap<QString, QString> map; |
38 | QMap<QString, ConfigGroup>::ConstIterator it; | 39 | QMap<QString, ConfigGroup>::ConstIterator it; |
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index c8a4db5..24256a5 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -1,49 +1,51 @@ | |||
1 | 1 | ||
2 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
3 | 3 | ||
4 | #include "metafactory.h" | 4 | #include "metafactory.h" |
5 | #include "profileconfig.h" | 5 | #include "profileconfig.h" |
6 | #include "profilemanager.h" | 6 | #include "profilemanager.h" |
7 | 7 | ||
8 | ProfileManager::ProfileManager( MetaFactory* fact ) | 8 | ProfileManager::ProfileManager( MetaFactory* fact ) |
9 | : m_fact( fact ) | 9 | : m_fact( fact ) |
10 | { | 10 | { |
11 | 11 | ||
12 | } | 12 | } |
13 | ProfileManager::~ProfileManager() { | 13 | ProfileManager::~ProfileManager() { |
14 | 14 | ||
15 | } | 15 | } |
16 | void ProfileManager::load() { | 16 | void ProfileManager::load() { |
17 | m_list.clear(); | 17 | m_list.clear(); |
18 | qWarning("load"); | ||
18 | ProfileConfig conf("opie-console-profiles"); | 19 | ProfileConfig conf("opie-console-profiles"); |
19 | QStringList groups = conf.groups(); | 20 | QStringList groups = conf.groups(); |
20 | QStringList::Iterator it; | 21 | QStringList::Iterator it; |
21 | 22 | ||
22 | /* | 23 | /* |
23 | * for each profile | 24 | * for each profile |
24 | */ | 25 | */ |
25 | for ( it = groups.begin(); it != groups.end(); ++it ) { | 26 | for ( it = groups.begin(); it != groups.end(); ++it ) { |
27 | qWarning("group " + (*it) ); | ||
26 | conf.setGroup( (*it) ); | 28 | conf.setGroup( (*it) ); |
27 | Profile prof; | 29 | Profile prof; |
28 | prof.setName( conf.readEntry("name") ); | 30 | prof.setName( conf.readEntry("name") ); |
29 | prof.setIOLayer( conf.readEntry("iolayer") ); | 31 | prof.setIOLayer( conf.readEntry("iolayer") ); |
30 | prof.setBackground( conf.readNumEntry("back") ); | 32 | prof.setBackground( conf.readNumEntry("back") ); |
31 | prof.setForeground( conf.readNumEntry("fore") ); | 33 | prof.setForeground( conf.readNumEntry("fore") ); |
32 | prof.setTerminal( conf.readNumEntry("terminal") ); | 34 | prof.setTerminal( conf.readNumEntry("terminal") ); |
33 | prof.setConf( conf.items( (*it) ) ); | 35 | prof.setConf( conf.items( (*it) ) ); |
34 | 36 | ||
35 | /* now add it */ | 37 | /* now add it */ |
36 | m_list.append( prof ); | 38 | m_list.append( prof ); |
37 | } | 39 | } |
38 | 40 | ||
39 | } | 41 | } |
40 | void ProfileManager::clear() { | 42 | void ProfileManager::clear() { |
41 | m_list.clear(); | 43 | m_list.clear(); |
42 | } | 44 | } |
43 | Profile::ValueList ProfileManager::all()const { | 45 | Profile::ValueList ProfileManager::all()const { |
44 | return m_list; | 46 | return m_list; |
45 | } | 47 | } |
46 | Session* ProfileManager::fromProfile( const Profile& prof) { | 48 | Session* ProfileManager::fromProfile( const Profile& prof) { |
47 | Session* session = new Session(); | 49 | Session* session = new Session(); |
48 | session->setName( prof.name() ); | 50 | session->setName( prof.name() ); |
49 | session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), | 51 | session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), |