Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 88d5823..dce08ca 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,23 +1,24 @@ | |||
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 "configdialog.h" |
9 | #include "metafactory.h" | 9 | #include "metafactory.h" |
10 | #include "profilemanager.h" | 10 | #include "profilemanager.h" |
11 | #include "mainwindow.h" | 11 | #include "mainwindow.h" |
12 | #include "tabwidget.h" | ||
12 | 13 | ||
13 | MainWindow::MainWindow() { | 14 | MainWindow::MainWindow() { |
14 | m_factory = new MetaFactory(); | 15 | m_factory = new MetaFactory(); |
15 | m_sessions.setAutoDelete( TRUE ); | 16 | m_sessions.setAutoDelete( TRUE ); |
16 | m_curSession = 0; | 17 | m_curSession = 0; |
17 | m_manager = new ProfileManager(m_factory); | 18 | m_manager = new ProfileManager(m_factory); |
18 | m_manager->load(); | 19 | m_manager->load(); |
19 | 20 | ||
20 | initUI(); | 21 | initUI(); |
21 | populateProfiles(); | 22 | populateProfiles(); |
22 | } | 23 | } |
23 | void MainWindow::initUI() { | 24 | void MainWindow::initUI() { |
@@ -31,36 +32,33 @@ void MainWindow::initUI() { | |||
31 | m_sessionsPop= new QPopupMenu( this ); | 32 | m_sessionsPop= new QPopupMenu( this ); |
32 | m_settings = new QPopupMenu( this ); | 33 | m_settings = new QPopupMenu( this ); |
33 | 34 | ||
34 | /* | 35 | /* |
35 | * new Action for new sessions | 36 | * new Action for new sessions |
36 | */ | 37 | */ |
37 | QAction* a = new QAction(); | 38 | QAction* a = new QAction(); |
38 | a->setText( tr("New Connection") ); | 39 | a->setText( tr("New Connection") ); |
39 | a->addTo( m_console ); | 40 | a->addTo( m_console ); |
40 | connect(a, SIGNAL(activated() ), | 41 | connect(a, SIGNAL(activated() ), |
41 | this, SLOT(slotNew() ) ); | 42 | this, SLOT(slotNew() ) ); |
42 | 43 | ||
43 | |||
44 | |||
45 | /* | 44 | /* |
46 | * connect action | 45 | * connect action |
47 | */ | 46 | */ |
48 | m_connect = new QAction(); | 47 | m_connect = new QAction(); |
49 | m_connect->setText( tr("Connect") ); | 48 | m_connect->setText( tr("Connect") ); |
50 | m_connect->addTo( m_console ); | 49 | m_connect->addTo( m_console ); |
51 | connect(m_connect, SIGNAL(activated() ), | 50 | connect(m_connect, SIGNAL(activated() ), |
52 | this, SLOT(slotConnect() ) ); | 51 | this, SLOT(slotConnect() ) ); |
53 | 52 | ||
54 | |||
55 | /* | 53 | /* |
56 | * disconnect action | 54 | * disconnect action |
57 | */ | 55 | */ |
58 | m_disconnect = new QAction(); | 56 | m_disconnect = new QAction(); |
59 | m_disconnect->setText( tr("Disconnect") ); | 57 | m_disconnect->setText( tr("Disconnect") ); |
60 | m_disconnect->addTo( m_console ); | 58 | m_disconnect->addTo( m_console ); |
61 | connect(m_disconnect, SIGNAL(activated() ), | 59 | connect(m_disconnect, SIGNAL(activated() ), |
62 | this, SLOT(slotDisconnect() ) ); | 60 | this, SLOT(slotDisconnect() ) ); |
63 | 61 | ||
64 | /* | 62 | /* |
65 | * terminate action | 63 | * terminate action |
66 | */ | 64 | */ |
@@ -92,76 +90,87 @@ void MainWindow::initUI() { | |||
92 | /* insert the connection menu */ | 90 | /* insert the connection menu */ |
93 | m_bar->insertItem( tr("Connection"), m_console ); | 91 | m_bar->insertItem( tr("Connection"), m_console ); |
94 | 92 | ||
95 | /* the settings menu */ | 93 | /* the settings menu */ |
96 | m_bar->insertItem( tr("Settings"), m_settings ); | 94 | m_bar->insertItem( tr("Settings"), m_settings ); |
97 | 95 | ||
98 | /* | 96 | /* |
99 | * connect to the menu activation | 97 | * connect to the menu activation |
100 | */ | 98 | */ |
101 | connect( m_sessionsPop, SIGNAL(activated(int) ), | 99 | connect( m_sessionsPop, SIGNAL(activated(int) ), |
102 | this, SLOT(slotProfile(int) ) ); | 100 | this, SLOT(slotProfile(int) ) ); |
103 | 101 | ||
102 | m_consoleWindow = new TabWidget( this, "blah"); | ||
103 | setCentralWidget( m_consoleWindow ); | ||
104 | |||
104 | } | 105 | } |
106 | |||
105 | ProfileManager* MainWindow::manager() { | 107 | ProfileManager* MainWindow::manager() { |
106 | return m_manager; | 108 | return m_manager; |
107 | } | 109 | } |
110 | |||
108 | void MainWindow::populateProfiles() { | 111 | void MainWindow::populateProfiles() { |
109 | m_sessionsPop->clear(); | 112 | m_sessionsPop->clear(); |
110 | Profile::ValueList list = manager()->all(); | 113 | Profile::ValueList list = manager()->all(); |
111 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); | 114 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
112 | ++it ) { | ||
113 | m_sessionsPop->insertItem( (*it).name() ); | 115 | m_sessionsPop->insertItem( (*it).name() ); |
114 | } | 116 | } |
115 | 117 | ||
116 | } | 118 | } |
117 | MainWindow::~MainWindow() { | 119 | MainWindow::~MainWindow() { |
118 | delete m_factory; | 120 | delete m_factory; |
119 | } | 121 | } |
120 | 122 | ||
121 | MetaFactory* MainWindow::factory() { | 123 | MetaFactory* MainWindow::factory() { |
122 | return m_factory; | 124 | return m_factory; |
123 | } | 125 | } |
124 | 126 | ||
125 | Session* MainWindow::currentSession() { | 127 | Session* MainWindow::currentSession() { |
126 | return m_curSession; | 128 | return m_curSession; |
127 | } | 129 | } |
128 | 130 | ||
129 | QList<Session> MainWindow::sessions() { | 131 | QList<Session> MainWindow::sessions() { |
130 | return m_sessions; | 132 | return m_sessions; |
131 | } | 133 | } |
134 | |||
132 | void MainWindow::slotNew() { | 135 | void MainWindow::slotNew() { |
133 | qWarning("New Connection"); | 136 | qWarning("New Connection"); |
134 | } | 137 | } |
138 | |||
135 | void MainWindow::slotConnect() { | 139 | void MainWindow::slotConnect() { |
136 | if ( currentSession() ) | 140 | if ( currentSession() ) |
137 | currentSession()->layer()->open(); | 141 | currentSession()->layer()->open(); |
138 | } | 142 | } |
143 | |||
139 | void MainWindow::slotDisconnect() { | 144 | void MainWindow::slotDisconnect() { |
140 | if ( currentSession() ) | 145 | if ( currentSession() ) |
141 | currentSession()->layer()->close(); | 146 | currentSession()->layer()->close(); |
142 | } | 147 | } |
148 | |||
143 | void MainWindow::slotTerminate() { | 149 | void MainWindow::slotTerminate() { |
144 | if ( currentSession() ) | 150 | if ( currentSession() ) |
145 | currentSession()->layer()->close(); | 151 | currentSession()->layer()->close(); |
146 | delete m_curSession; | 152 | delete m_curSession; |
147 | m_curSession = 0l; | 153 | m_curSession = 0l; |
148 | /* FIXME move to the next session */ | 154 | /* FIXME move to the next session */ |
149 | } | 155 | } |
156 | |||
150 | void MainWindow::slotConfigure() { | 157 | void MainWindow::slotConfigure() { |
151 | qWarning("configure"); | 158 | qWarning("configure"); |
152 | ConfigDialog conf( manager()->all() ); | 159 | ConfigDialog conf( manager()->all() ); |
153 | conf.showMaximized(); | 160 | conf.showMaximized(); |
154 | 161 | ||
155 | int ret = conf.exec(); | 162 | int ret = conf.exec(); |
156 | 163 | ||
157 | if ( QDialog::Accepted == ret ) { | 164 | if ( QDialog::Accepted == ret ) { |
158 | manager()->setProfiles( conf.list() ); | 165 | manager()->setProfiles( conf.list() ); |
159 | populateProfiles(); | 166 | populateProfiles(); |
160 | } | 167 | } |
161 | } | 168 | } |
169 | |||
162 | void MainWindow::slotClose() { | 170 | void MainWindow::slotClose() { |
163 | 171 | ||
164 | } | 172 | } |
173 | |||
165 | void MainWindow::slotProfile(int) { | 174 | void MainWindow::slotProfile(int) { |
166 | 175 | ||
167 | } | 176 | } |