-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 87 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 9 |
3 files changed, 60 insertions, 37 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index b2b107e..e80168d 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,199 +1,198 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | 3 | ||
4 | #include "TEWidget.h" | 4 | #include "TEWidget.h" |
5 | #include "TEmuVt102.h" | 5 | #include "TEmuVt102.h" |
6 | 6 | ||
7 | #include "profile.h" | 7 | #include "profile.h" |
8 | #include "emulation_handler.h" | 8 | #include "emulation_handler.h" |
9 | #include "script.h" | 9 | #include "script.h" |
10 | 10 | ||
11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 11 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
12 | : QObject(0, name ) | 12 | : QObject(0, name ) |
13 | { | 13 | { |
14 | m_teWid = new TEWidget( parent, "TerminalMain"); | 14 | m_teWid = new TEWidget( parent, "TerminalMain"); |
15 | m_teWid->setMinimumSize(150, 70 ); | 15 | m_teWid->setMinimumSize(150, 70 ); |
16 | m_script = 0; | 16 | m_script = 0; |
17 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 17 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
18 | m_teEmu = new TEmuVt102(m_teWid ); | 18 | m_teEmu = new TEmuVt102(m_teWid ); |
19 | 19 | ||
20 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), | 20 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), |
21 | this, SIGNAL(changeSize(int, int) ) ); | 21 | this, SIGNAL(changeSize(int, int) ) ); |
22 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), | 22 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), |
23 | this, SLOT(recvEmulation(const char*, int) ) ); | 23 | this, SLOT(recvEmulation(const char*, int) ) ); |
24 | m_teEmu->setConnect( true ); | 24 | m_teEmu->setConnect( true ); |
25 | m_teEmu->setHistory( TRUE ); | 25 | m_teEmu->setHistory( TRUE ); |
26 | load( prof ); | 26 | load( prof ); |
27 | 27 | ||
28 | 28 | ||
29 | 29 | ||
30 | } | 30 | } |
31 | EmulationHandler::~EmulationHandler() { | 31 | EmulationHandler::~EmulationHandler() { |
32 | if (isRecording()) | 32 | if (isRecording()) |
33 | clearScript(); | 33 | clearScript(); |
34 | delete m_teEmu; | 34 | delete m_teEmu; |
35 | delete m_teWid; | 35 | delete m_teWid; |
36 | } | 36 | } |
37 | 37 | ||
38 | void EmulationHandler::load( const Profile& prof) { | 38 | void EmulationHandler::load( const Profile& prof) { |
39 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 39 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
40 | int num = prof.readNumEntry("Color"); | 40 | int num = prof.readNumEntry("Color"); |
41 | setColor( foreColor(num), backColor(num) ); | 41 | setColor( foreColor(num), backColor(num) ); |
42 | m_teWid->setBackgroundColor(backColor(num) ); | 42 | m_teWid->setBackgroundColor(backColor(num) ); |
43 | 43 | ||
44 | int term = prof.readNumEntry("Terminal", 0) ; | 44 | int term = prof.readNumEntry("Terminal", 0) ; |
45 | switch(term) { | 45 | switch(term) { |
46 | default: | 46 | default: |
47 | case Profile::VT102: | 47 | case Profile::VT102: |
48 | case Profile::VT100: | 48 | case Profile::VT100: |
49 | m_teEmu->setKeytrans("vt100.keytab"); | 49 | m_teEmu->setKeytrans("vt100.keytab"); |
50 | break; | 50 | break; |
51 | case Profile::Linux: | 51 | case Profile::Linux: |
52 | m_teEmu->setKeytrans("linux.keytab"); | 52 | m_teEmu->setKeytrans("linux.keytab"); |
53 | break; | 53 | break; |
54 | case Profile::XTerm: | 54 | case Profile::XTerm: |
55 | m_teEmu->setKeytrans("default.Keytab"); | 55 | m_teEmu->setKeytrans("default.Keytab"); |
56 | break; | 56 | break; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | void EmulationHandler::recv( const QByteArray& ar) { | 59 | void EmulationHandler::recv( const QByteArray& ar) { |
60 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 60 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
61 | } | 61 | } |
62 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 62 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
63 | QByteArray ar(len); | 63 | QByteArray ar(len); |
64 | 64 | ||
65 | memcpy(ar.data(), src, sizeof(char) * len ); | 65 | memcpy(ar.data(), src, sizeof(char) * len ); |
66 | |||
67 | if (isRecording()) | 66 | if (isRecording()) |
68 | m_script->append(ar); | 67 | m_script->append(ar); |
69 | emit send(ar); | 68 | emit send(ar); |
70 | } | 69 | } |
71 | QWidget* EmulationHandler::widget() { | 70 | QWidget* EmulationHandler::widget() { |
72 | return m_teWid; | 71 | return m_teWid; |
73 | } | 72 | } |
74 | /* | 73 | /* |
75 | * allocate a new table of colors | 74 | * allocate a new table of colors |
76 | */ | 75 | */ |
77 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 76 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
78 | ColorEntry table[TABLE_COLORS]; | 77 | ColorEntry table[TABLE_COLORS]; |
79 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 78 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
80 | 79 | ||
81 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 80 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
82 | if ( i == 0 || i == 10 ) { | 81 | if ( i == 0 || i == 10 ) { |
83 | table[i].color = fore; | 82 | table[i].color = fore; |
84 | }else if ( i == 1 || i == 11 ) { | 83 | }else if ( i == 1 || i == 11 ) { |
85 | table[i].color = back; | 84 | table[i].color = back; |
86 | table[i].transparent = 0; | 85 | table[i].transparent = 0; |
87 | }else { | 86 | }else { |
88 | table[i].color = defaultCt[i].color; | 87 | table[i].color = defaultCt[i].color; |
89 | } | 88 | } |
90 | } | 89 | } |
91 | m_teWid->setColorTable(table ); | 90 | m_teWid->setColorTable(table ); |
92 | m_teWid->update(); | 91 | m_teWid->update(); |
93 | } | 92 | } |
94 | QFont EmulationHandler::font( int id ) { | 93 | QFont EmulationHandler::font( int id ) { |
95 | QString name; | 94 | QString name; |
96 | int size = 0; | 95 | int size = 0; |
97 | switch(id ) { | 96 | switch(id ) { |
98 | default: // fall through | 97 | default: // fall through |
99 | case 0: | 98 | case 0: |
100 | name = QString::fromLatin1("Micro"); | 99 | name = QString::fromLatin1("Micro"); |
101 | size = 4; | 100 | size = 4; |
102 | break; | 101 | break; |
103 | case 1: | 102 | case 1: |
104 | name = QString::fromLatin1("Fixed"); | 103 | name = QString::fromLatin1("Fixed"); |
105 | size = 7; | 104 | size = 7; |
106 | break; | 105 | break; |
107 | case 2: | 106 | case 2: |
108 | name = QString::fromLatin1("Fixed"); | 107 | name = QString::fromLatin1("Fixed"); |
109 | size = 12; | 108 | size = 12; |
110 | break; | 109 | break; |
111 | } | 110 | } |
112 | QFont font(name, size, QFont::Normal ); | 111 | QFont font(name, size, QFont::Normal ); |
113 | font.setFixedPitch(TRUE ); | 112 | font.setFixedPitch(TRUE ); |
114 | return font; | 113 | return font; |
115 | } | 114 | } |
116 | QColor EmulationHandler::foreColor(int col) { | 115 | QColor EmulationHandler::foreColor(int col) { |
117 | QColor co; | 116 | QColor co; |
118 | /* we need to switch it */ | 117 | /* we need to switch it */ |
119 | switch( col ) { | 118 | switch( col ) { |
120 | default: | 119 | default: |
121 | case Profile::White: | 120 | case Profile::White: |
122 | /* color is black */ | 121 | /* color is black */ |
123 | co = Qt::white; | 122 | co = Qt::white; |
124 | break; | 123 | break; |
125 | case Profile::Black: | 124 | case Profile::Black: |
126 | co = Qt::black; | 125 | co = Qt::black; |
127 | break; | 126 | break; |
128 | case Profile::Green: | 127 | case Profile::Green: |
129 | qWarning("Foreground green"); | 128 | qWarning("Foreground green"); |
130 | co = Qt::green; | 129 | co = Qt::green; |
131 | break; | 130 | break; |
132 | case Profile::Orange: | 131 | case Profile::Orange: |
133 | qWarning("Foreground orange"); | 132 | qWarning("Foreground orange"); |
134 | co.setRgb( 231, 184, 98 ); | 133 | co.setRgb( 231, 184, 98 ); |
135 | break; | 134 | break; |
136 | } | 135 | } |
137 | 136 | ||
138 | return co; | 137 | return co; |
139 | } | 138 | } |
140 | QColor EmulationHandler::backColor(int col ) { | 139 | QColor EmulationHandler::backColor(int col ) { |
141 | QColor co; | 140 | QColor co; |
142 | /* we need to switch it */ | 141 | /* we need to switch it */ |
143 | switch( col ) { | 142 | switch( col ) { |
144 | default: | 143 | default: |
145 | case Profile::White: | 144 | case Profile::White: |
146 | /* color is white */ | 145 | /* color is white */ |
147 | co = Qt::black; | 146 | co = Qt::black; |
148 | break; | 147 | break; |
149 | case Profile::Black: | 148 | case Profile::Black: |
150 | co = Qt::white; | 149 | co = Qt::white; |
151 | break; | 150 | break; |
152 | case Profile::Green: | 151 | case Profile::Green: |
153 | qWarning("Background black"); | 152 | qWarning("Background black"); |
154 | co = Qt::black; | 153 | co = Qt::black; |
155 | break; | 154 | break; |
156 | case Profile::Orange: | 155 | case Profile::Orange: |
157 | qWarning("Background black"); | 156 | qWarning("Background black"); |
158 | co = Qt::black; | 157 | co = Qt::black; |
159 | break; | 158 | break; |
160 | } | 159 | } |
161 | 160 | ||
162 | return co; | 161 | return co; |
163 | } | 162 | } |
164 | 163 | ||
165 | QPushButton* EmulationHandler::cornerButton() { | 164 | QPushButton* EmulationHandler::cornerButton() { |
166 | return m_teWid->cornerButton(); | 165 | return m_teWid->cornerButton(); |
167 | } | 166 | } |
168 | 167 | ||
169 | 168 | ||
170 | Script *EmulationHandler::script() { | 169 | Script *EmulationHandler::script() { |
171 | return m_script; | 170 | return m_script; |
172 | } | 171 | } |
173 | 172 | ||
174 | bool EmulationHandler::isRecording() { | 173 | bool EmulationHandler::isRecording() { |
175 | return (m_script != 0); | 174 | return (m_script != 0); |
176 | } | 175 | } |
177 | 176 | ||
178 | void EmulationHandler::startRecording() { | 177 | void EmulationHandler::startRecording() { |
179 | if (!isRecording()) | 178 | if (!isRecording()) |
180 | m_script = new Script(); | 179 | m_script = new Script(); |
181 | } | 180 | } |
182 | 181 | ||
183 | void EmulationHandler::clearScript() { | 182 | void EmulationHandler::clearScript() { |
184 | if (isRecording()) { | 183 | if (isRecording()) { |
185 | delete m_script; | 184 | delete m_script; |
186 | m_script = 0; | 185 | m_script = 0; |
187 | } | 186 | } |
188 | } | 187 | } |
189 | 188 | ||
190 | void EmulationHandler::runScript(const Script *script) { | 189 | void EmulationHandler::runScript(const Script *script) { |
191 | emit send(script->script()); | 190 | emit send(script->script()); |
192 | } | 191 | } |
193 | 192 | ||
194 | void EmulationHandler::copy() { | 193 | void EmulationHandler::copy() { |
195 | m_teWid->emitSelection(); | 194 | m_teWid->emitSelection(); |
196 | } | 195 | } |
197 | void EmulationHandler::paste() { | 196 | void EmulationHandler::paste() { |
198 | m_teWid->pasteClipboard(); | 197 | m_teWid->pasteClipboard(); |
199 | } | 198 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 44ef458..2e00a07 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,584 +1,605 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | 11 | ||
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | #include <qpe/qpeapplication.h> | ||
14 | #include <qpe/filemanager.h> | ||
15 | #include <qpe/mimetype.h> | ||
13 | 16 | ||
14 | #include <opie/ofiledialog.h> | 17 | #include <opie/ofiledialog.h> |
15 | 18 | ||
16 | #include "keytrans.h" | 19 | #include "keytrans.h" |
17 | #include "profileeditordialog.h" | 20 | #include "profileeditordialog.h" |
18 | #include "configdialog.h" | 21 | #include "configdialog.h" |
19 | #include "default.h" | 22 | #include "default.h" |
20 | #include "metafactory.h" | 23 | #include "metafactory.h" |
21 | #include "profile.h" | 24 | #include "profile.h" |
22 | #include "profilemanager.h" | 25 | #include "profilemanager.h" |
23 | #include "mainwindow.h" | 26 | #include "mainwindow.h" |
24 | #include "tabwidget.h" | 27 | #include "tabwidget.h" |
25 | #include "transferdialog.h" | 28 | #include "transferdialog.h" |
26 | #include "function_keyboard.h" | 29 | #include "function_keyboard.h" |
27 | #include "emulation_handler.h" | 30 | #include "emulation_handler.h" |
28 | #include "script.h" | 31 | #include "script.h" |
29 | 32 | ||
30 | 33 | ||
31 | 34 | ||
32 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 35 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
33 | KeyTrans::loadAll(); | 36 | KeyTrans::loadAll(); |
34 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 37 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
35 | KeyTrans* s = KeyTrans::find(i ); | 38 | KeyTrans* s = KeyTrans::find(i ); |
36 | assert( s ); | 39 | assert( s ); |
37 | } | 40 | } |
38 | m_factory = new MetaFactory(); | 41 | m_factory = new MetaFactory(); |
39 | Default def(m_factory); | 42 | Default def(m_factory); |
40 | m_sessions.setAutoDelete( TRUE ); | 43 | m_sessions.setAutoDelete( TRUE ); |
41 | m_curSession = 0; | 44 | m_curSession = 0; |
42 | m_manager = new ProfileManager( m_factory ); | 45 | m_manager = new ProfileManager( m_factory ); |
43 | m_manager->load(); | 46 | m_manager->load(); |
44 | 47 | ||
45 | initUI(); | 48 | initUI(); |
46 | populateProfiles(); | 49 | populateProfiles(); |
50 | populateScripts(); | ||
47 | } | 51 | } |
48 | void MainWindow::initUI() { | 52 | void MainWindow::initUI() { |
49 | setToolBarsMovable( FALSE ); | 53 | setToolBarsMovable( FALSE ); |
50 | 54 | ||
51 | /* tool bar for the menu */ | 55 | /* tool bar for the menu */ |
52 | m_tool = new QToolBar( this ); | 56 | m_tool = new QToolBar( this ); |
53 | m_tool->setHorizontalStretchable( TRUE ); | 57 | m_tool->setHorizontalStretchable( TRUE ); |
54 | 58 | ||
55 | m_bar = new QMenuBar( m_tool ); | 59 | m_bar = new QMenuBar( m_tool ); |
56 | m_console = new QPopupMenu( this ); | 60 | m_console = new QPopupMenu( this ); |
57 | m_scripts = new QPopupMenu( this ); | 61 | m_scripts = new QPopupMenu( this ); |
58 | m_sessionsPop= new QPopupMenu( this ); | 62 | m_sessionsPop= new QPopupMenu( this ); |
63 | m_scriptsPop = new QPopupMenu( this ); | ||
59 | 64 | ||
60 | /* add a toolbar for icons */ | 65 | /* add a toolbar for icons */ |
61 | m_icons = new QToolBar(this); | 66 | m_icons = new QToolBar(this); |
62 | 67 | ||
63 | /* | 68 | /* |
64 | * the settings action | 69 | * the settings action |
65 | */ | 70 | */ |
66 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
67 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
68 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
69 | m_setProfiles->addTo( m_console ); | 74 | m_setProfiles->addTo( m_console ); |
70 | connect( m_setProfiles, SIGNAL(activated() ), | 75 | connect( m_setProfiles, SIGNAL(activated() ), |
71 | this, SLOT(slotConfigure() ) ); | 76 | this, SLOT(slotConfigure() ) ); |
72 | 77 | ||
73 | m_console->insertSeparator(); | 78 | m_console->insertSeparator(); |
74 | /* | 79 | /* |
75 | * new Action for new sessions | 80 | * new Action for new sessions |
76 | */ | 81 | */ |
77 | QAction* newCon = new QAction(tr("New Connection"), | 82 | QAction* newCon = new QAction(tr("New Connection"), |
78 | Resource::loadPixmap( "new" ), | 83 | Resource::loadPixmap( "new" ), |
79 | QString::null, 0, this, 0); | 84 | QString::null, 0, this, 0); |
80 | newCon->addTo( m_console ); | 85 | newCon->addTo( m_console ); |
81 | connect( newCon, SIGNAL(activated() ), | 86 | connect( newCon, SIGNAL(activated() ), |
82 | this, SLOT(slotNew() ) ); | 87 | this, SLOT(slotNew() ) ); |
83 | 88 | ||
84 | m_console->insertSeparator(); | 89 | m_console->insertSeparator(); |
85 | /* save icon is not available */ | 90 | /* save icon is not available */ |
86 | 91 | ||
87 | QAction *saveCon = new QAction(tr("Save Connection"), | 92 | QAction *saveCon = new QAction(tr("Save Connection"), |
88 | Resource::loadPixmap("save"), QString::null, | 93 | Resource::loadPixmap("save"), QString::null, |
89 | 0, this, 0 ); | 94 | 0, this, 0 ); |
90 | saveCon->addTo( m_console ); | 95 | saveCon->addTo( m_console ); |
91 | connect( saveCon, SIGNAL(activated() ), | 96 | connect( saveCon, SIGNAL(activated() ), |
92 | this, SLOT(slotSaveSession() ) ); | 97 | this, SLOT(slotSaveSession() ) ); |
93 | m_console->insertSeparator(); | 98 | m_console->insertSeparator(); |
94 | 99 | ||
95 | /* | 100 | /* |
96 | * connect action | 101 | * connect action |
97 | */ | 102 | */ |
98 | m_connect = new QAction(); | 103 | m_connect = new QAction(); |
99 | m_connect->setText( tr("Connect") ); | 104 | m_connect->setText( tr("Connect") ); |
100 | m_connect->addTo( m_console ); | 105 | m_connect->addTo( m_console ); |
101 | connect(m_connect, SIGNAL(activated() ), | 106 | connect(m_connect, SIGNAL(activated() ), |
102 | this, SLOT(slotConnect() ) ); | 107 | this, SLOT(slotConnect() ) ); |
103 | 108 | ||
104 | /* | 109 | /* |
105 | * disconnect action | 110 | * disconnect action |
106 | */ | 111 | */ |
107 | m_disconnect = new QAction(); | 112 | m_disconnect = new QAction(); |
108 | m_disconnect->setText( tr("Disconnect") ); | 113 | m_disconnect->setText( tr("Disconnect") ); |
109 | m_disconnect->addTo( m_console ); | 114 | m_disconnect->addTo( m_console ); |
110 | connect(m_disconnect, SIGNAL(activated() ), | 115 | connect(m_disconnect, SIGNAL(activated() ), |
111 | this, SLOT(slotDisconnect() ) ); | 116 | this, SLOT(slotDisconnect() ) ); |
112 | 117 | ||
113 | m_console->insertSeparator(); | 118 | m_console->insertSeparator(); |
114 | 119 | ||
115 | m_transfer = new QAction(); | 120 | m_transfer = new QAction(); |
116 | m_transfer->setText( tr("Transfer file...") ); | 121 | m_transfer->setText( tr("Transfer file...") ); |
117 | m_transfer->addTo( m_console ); | 122 | m_transfer->addTo( m_console ); |
118 | connect(m_transfer, SIGNAL(activated() ), | 123 | connect(m_transfer, SIGNAL(activated() ), |
119 | this, SLOT(slotTransfer() ) ); | 124 | this, SLOT(slotTransfer() ) ); |
120 | 125 | ||
121 | 126 | ||
122 | /* | 127 | /* |
123 | * fullscreen | 128 | * fullscreen |
124 | */ | 129 | */ |
125 | m_isFullscreen = false; | 130 | m_isFullscreen = false; |
126 | 131 | ||
127 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 132 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
128 | , QString::null, 0, this, 0); | 133 | , QString::null, 0, this, 0); |
129 | m_fullscreen->addTo( m_console ); | 134 | m_fullscreen->addTo( m_console ); |
130 | connect( m_fullscreen, SIGNAL( activated() ), | 135 | connect( m_fullscreen, SIGNAL( activated() ), |
131 | this, SLOT( slotFullscreen() ) ); | 136 | this, SLOT( slotFullscreen() ) ); |
132 | 137 | ||
133 | m_console->insertSeparator(); | 138 | m_console->insertSeparator(); |
134 | /* | 139 | /* |
135 | * terminate action | 140 | * terminate action |
136 | */ | 141 | */ |
137 | m_terminate = new QAction(); | 142 | m_terminate = new QAction(); |
138 | m_terminate->setText( tr("Terminate") ); | 143 | m_terminate->setText( tr("Terminate") ); |
139 | m_terminate->addTo( m_console ); | 144 | m_terminate->addTo( m_console ); |
140 | connect(m_terminate, SIGNAL(activated() ), | 145 | connect(m_terminate, SIGNAL(activated() ), |
141 | this, SLOT(slotTerminate() ) ); | 146 | this, SLOT(slotTerminate() ) ); |
142 | 147 | ||
143 | m_closewindow = new QAction(); | 148 | m_closewindow = new QAction(); |
144 | m_closewindow->setText( tr("Close Window") ); | 149 | m_closewindow->setText( tr("Close Window") ); |
145 | m_closewindow->addTo( m_console ); | 150 | m_closewindow->addTo( m_console ); |
146 | connect( m_closewindow, SIGNAL(activated() ), | 151 | connect( m_closewindow, SIGNAL(activated() ), |
147 | this, SLOT(slotClose() ) ); | 152 | this, SLOT(slotClose() ) ); |
148 | 153 | ||
149 | 154 | ||
150 | /* | 155 | /* |
151 | * script actions | 156 | * script actions |
152 | */ | 157 | */ |
158 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | ||
159 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | ||
160 | |||
153 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 161 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
154 | m_recordScript->addTo(m_scripts); | 162 | m_recordScript->addTo(m_scripts); |
155 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 163 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
156 | 164 | ||
157 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 165 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
158 | m_saveScript->addTo(m_scripts); | 166 | m_saveScript->addTo(m_scripts); |
159 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 167 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
160 | 168 | ||
161 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | ||
162 | m_runScript->addTo(m_scripts); | ||
163 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | ||
164 | 169 | ||
165 | /* | 170 | /* |
166 | * action that open/closes the keyboard | 171 | * action that open/closes the keyboard |
167 | */ | 172 | */ |
168 | m_openKeys = new QAction (tr("Open Keyboard..."), | 173 | m_openKeys = new QAction (tr("Open Keyboard..."), |
169 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 174 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
170 | QString::null, 0, this, 0); | 175 | QString::null, 0, this, 0); |
171 | m_openKeys->setToggleAction(true); | 176 | m_openKeys->setToggleAction(true); |
172 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 177 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
173 | 178 | ||
174 | /* insert the submenu */ | 179 | /* insert the submenu */ |
175 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 180 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
176 | -1, 0); | 181 | -1, 0); |
177 | 182 | ||
178 | /* insert the connection menu */ | 183 | /* insert the connection menu */ |
179 | m_bar->insertItem( tr("Connection"), m_console ); | 184 | m_bar->insertItem( tr("Connection"), m_console ); |
180 | 185 | ||
181 | /* the scripts menu */ | 186 | /* the scripts menu */ |
182 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 187 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
183 | 188 | ||
184 | /* and the keyboard */ | 189 | /* and the keyboard */ |
185 | m_keyBar = new QToolBar(this); | 190 | m_keyBar = new QToolBar(this); |
186 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 191 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
187 | m_keyBar->setHorizontalStretchable( TRUE ); | 192 | m_keyBar->setHorizontalStretchable( TRUE ); |
188 | m_keyBar->hide(); | 193 | m_keyBar->hide(); |
189 | 194 | ||
190 | m_kb = new FunctionKeyboard(m_keyBar); | 195 | m_kb = new FunctionKeyboard(m_keyBar); |
191 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 196 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
192 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 197 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
193 | 198 | ||
194 | 199 | ||
195 | QAction *a = new QAction(tr("Copy"), | 200 | QAction *a = new QAction(tr("Copy"), |
196 | Resource::loadPixmap("copy"), QString::null, | 201 | Resource::loadPixmap("copy"), QString::null, |
197 | 0, this, 0 ); | 202 | 0, this, 0 ); |
198 | //a->addTo( m_icons ); | 203 | //a->addTo( m_icons ); |
199 | connect( a, SIGNAL(activated() ), | 204 | connect( a, SIGNAL(activated() ), |
200 | this, SLOT(slotCopy() ) ); | 205 | this, SLOT(slotCopy() ) ); |
201 | 206 | ||
202 | QAction *paste = new QAction(tr("Paste"), | 207 | QAction *paste = new QAction(tr("Paste"), |
203 | Resource::loadPixmap("paste"), QString::null, | 208 | Resource::loadPixmap("paste"), QString::null, |
204 | 0, this, 0 ); | 209 | 0, this, 0 ); |
205 | connect( paste, SIGNAL(activated() ), | 210 | connect( paste, SIGNAL(activated() ), |
206 | this, SLOT(slotPaste() ) ); | 211 | this, SLOT(slotPaste() ) ); |
207 | 212 | ||
208 | 213 | ||
209 | newCon->addTo( m_icons ); | 214 | newCon->addTo( m_icons ); |
210 | m_setProfiles->addTo( m_icons ); | 215 | m_setProfiles->addTo( m_icons ); |
211 | paste->addTo( m_icons ); | 216 | paste->addTo( m_icons ); |
212 | m_openKeys->addTo(m_icons); | 217 | m_openKeys->addTo(m_icons); |
213 | m_fullscreen->addTo( m_icons ); | 218 | m_fullscreen->addTo( m_icons ); |
214 | 219 | ||
215 | m_connect->setEnabled( false ); | 220 | m_connect->setEnabled( false ); |
216 | m_disconnect->setEnabled( false ); | 221 | m_disconnect->setEnabled( false ); |
217 | m_terminate->setEnabled( false ); | 222 | m_terminate->setEnabled( false ); |
218 | m_transfer->setEnabled( false ); | 223 | m_transfer->setEnabled( false ); |
224 | m_scripts->setItemEnabled(m_runScript_id, false); | ||
219 | m_recordScript->setEnabled( false ); | 225 | m_recordScript->setEnabled( false ); |
220 | m_saveScript->setEnabled( false ); | 226 | m_saveScript->setEnabled( false ); |
221 | m_runScript->setEnabled( false ); | ||
222 | m_fullscreen->setEnabled( false ); | 227 | m_fullscreen->setEnabled( false ); |
223 | m_closewindow->setEnabled( false ); | 228 | m_closewindow->setEnabled( false ); |
224 | 229 | ||
225 | /* | 230 | /* |
226 | * connect to the menu activation | 231 | * connect to the menu activation |
227 | */ | 232 | */ |
228 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 233 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
229 | this, SLOT(slotProfile( int ) ) ); | 234 | this, SLOT(slotProfile( int ) ) ); |
230 | 235 | ||
231 | m_consoleWindow = new TabWidget( this, "blah"); | 236 | m_consoleWindow = new TabWidget( this, "blah"); |
232 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 237 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
233 | this, SLOT(slotSessionChanged(Session*) ) ); | 238 | this, SLOT(slotSessionChanged(Session*) ) ); |
234 | setCentralWidget( m_consoleWindow ); | 239 | setCentralWidget( m_consoleWindow ); |
235 | 240 | ||
236 | } | 241 | } |
237 | 242 | ||
238 | ProfileManager* MainWindow::manager() { | 243 | ProfileManager* MainWindow::manager() { |
239 | return m_manager; | 244 | return m_manager; |
240 | } | 245 | } |
241 | TabWidget* MainWindow::tabWidget() { | 246 | TabWidget* MainWindow::tabWidget() { |
242 | return m_consoleWindow; | 247 | return m_consoleWindow; |
243 | } | 248 | } |
244 | void MainWindow::populateProfiles() { | 249 | void MainWindow::populateProfiles() { |
245 | m_sessionsPop->clear(); | 250 | m_sessionsPop->clear(); |
246 | Profile::ValueList list = manager()->all(); | 251 | Profile::ValueList list = manager()->all(); |
247 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 252 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
248 | m_sessionsPop->insertItem( (*it).name() ); | 253 | m_sessionsPop->insertItem( (*it).name() ); |
249 | } | 254 | } |
250 | 255 | ||
251 | } | 256 | } |
257 | |||
258 | void MainWindow::populateScripts() { | ||
259 | m_scriptsPop->clear(); | ||
260 | m_scriptsData.clear(); | ||
261 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | ||
262 | QListIterator<DocLnk> dit(files.children()); | ||
263 | for (; dit.current(); ++dit) { | ||
264 | if (*dit && (*dit)->name().length()>0) { | ||
265 | m_scriptsData.append((*dit)); | ||
266 | m_scriptsPop->insertItem((*dit)->name()); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | } | ||
271 | |||
252 | MainWindow::~MainWindow() { | 272 | MainWindow::~MainWindow() { |
253 | delete m_factory; | 273 | delete m_factory; |
254 | manager()->save(); | 274 | manager()->save(); |
255 | } | 275 | } |
256 | 276 | ||
257 | MetaFactory* MainWindow::factory() { | 277 | MetaFactory* MainWindow::factory() { |
258 | return m_factory; | 278 | return m_factory; |
259 | } | 279 | } |
260 | 280 | ||
261 | Session* MainWindow::currentSession() { | 281 | Session* MainWindow::currentSession() { |
262 | return m_curSession; | 282 | return m_curSession; |
263 | } | 283 | } |
264 | 284 | ||
265 | QList<Session> MainWindow::sessions() { | 285 | QList<Session> MainWindow::sessions() { |
266 | return m_sessions; | 286 | return m_sessions; |
267 | } | 287 | } |
268 | 288 | ||
269 | void MainWindow::slotNew() { | 289 | void MainWindow::slotNew() { |
270 | ProfileEditorDialog dlg(factory() ); | 290 | ProfileEditorDialog dlg(factory() ); |
271 | dlg.showMaximized(); | 291 | dlg.showMaximized(); |
272 | int ret = dlg.exec(); | 292 | int ret = dlg.exec(); |
273 | 293 | ||
274 | if ( ret == QDialog::Accepted ) { | 294 | if ( ret == QDialog::Accepted ) { |
275 | create( dlg.profile() ); | 295 | create( dlg.profile() ); |
276 | } | 296 | } |
277 | } | 297 | } |
278 | 298 | ||
279 | void MainWindow::slotRecordScript() { | 299 | void MainWindow::slotRecordScript() { |
280 | if (currentSession()) { | 300 | if (currentSession()) { |
281 | currentSession()->emulationHandler()->startRecording(); | 301 | currentSession()->emulationHandler()->startRecording(); |
302 | m_saveScript->setEnabled(true); | ||
303 | m_recordScript->setEnabled(false); | ||
282 | } | 304 | } |
283 | } | 305 | } |
284 | 306 | ||
285 | void MainWindow::slotSaveScript() { | 307 | void MainWindow::slotSaveScript() { |
286 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 308 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
287 | MimeTypes types; | 309 | QMap<QString, QStringList> map; |
288 | QStringList script; | 310 | QStringList text; |
289 | script << "text/plain"; | 311 | text << "text/plain"; |
290 | script << "text/all"; | 312 | map.insert(tr("Script"), text ); |
291 | script << "application/octet-stream"; | 313 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
292 | types.insert("Script", script); | ||
293 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | ||
294 | if (!filename.isEmpty()) { | 314 | if (!filename.isEmpty()) { |
295 | currentSession()->emulationHandler()->script()->saveTo(filename); | 315 | DocLnk nf; |
316 | nf.setType("text/plain"); | ||
317 | nf.setFile(filename); | ||
318 | nf.setName(filename); | ||
319 | FileManager fm; | ||
320 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | ||
296 | currentSession()->emulationHandler()->clearScript(); | 321 | currentSession()->emulationHandler()->clearScript(); |
322 | m_saveScript->setEnabled(false); | ||
323 | m_recordScript->setEnabled(true); | ||
324 | populateScripts(); | ||
297 | } | 325 | } |
298 | } | 326 | } |
299 | } | 327 | } |
300 | 328 | ||
301 | void MainWindow::slotRunScript() { | 329 | void MainWindow::slotRunScript(int id) { |
302 | if (currentSession()) { | 330 | if (currentSession()) { |
303 | MimeTypes types; | 331 | DocLnk *lnk = m_scriptsData.at(m_scriptsPop->indexOf(id)); |
304 | QStringList script; | 332 | QString filePath = lnk->file(); |
305 | script << "text/plain"; | 333 | printf("path is : %s\n", filePath.latin1()); |
306 | script << "text/all"; | 334 | Script script(filePath); |
307 | script << "application/octet-stream"; | 335 | currentSession()->emulationHandler()->runScript(&script); |
308 | types.insert("Script", script); | ||
309 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | ||
310 | if (!filename.isEmpty()) { | ||
311 | Script script(DocLnk(filename).file()); | ||
312 | currentSession()->emulationHandler()->runScript(&script); | ||
313 | } | ||
314 | } | 336 | } |
315 | } | 337 | } |
316 | 338 | ||
317 | void MainWindow::slotConnect() { | 339 | void MainWindow::slotConnect() { |
318 | if ( currentSession() ) { | 340 | if ( currentSession() ) { |
319 | bool ret = currentSession()->layer()->open(); | 341 | bool ret = currentSession()->layer()->open(); |
320 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 342 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
321 | QObject::tr("Failed"), | 343 | QObject::tr("Failed"), |
322 | QObject::tr("Connecting failed for this session.")); | 344 | QObject::tr("Connecting failed for this session.")); |
323 | else { | 345 | else { |
324 | m_connect->setEnabled( false ); | 346 | m_connect->setEnabled( false ); |
325 | m_disconnect->setEnabled( true ); | 347 | m_disconnect->setEnabled( true ); |
326 | m_transfer->setEnabled( true ); | 348 | m_transfer->setEnabled( true ); |
327 | m_recordScript->setEnabled( true ); | 349 | m_recordScript->setEnabled( true ); |
328 | m_saveScript->setEnabled( true ); | 350 | m_scripts->setItemEnabled(m_runScript_id, true); |
329 | m_runScript->setEnabled( true ); | ||
330 | } | 351 | } |
331 | } | 352 | } |
332 | } | 353 | } |
333 | 354 | ||
334 | void MainWindow::slotDisconnect() { | 355 | void MainWindow::slotDisconnect() { |
335 | if ( currentSession() ) { | 356 | if ( currentSession() ) { |
336 | currentSession()->layer()->close(); | 357 | currentSession()->layer()->close(); |
337 | m_connect->setEnabled( true ); | 358 | m_connect->setEnabled( true ); |
338 | m_disconnect->setEnabled( false ); | 359 | m_disconnect->setEnabled( false ); |
339 | m_transfer->setEnabled( false ); | 360 | m_transfer->setEnabled( false ); |
340 | m_recordScript->setEnabled( false); | 361 | m_recordScript->setEnabled( false); |
341 | m_saveScript->setEnabled( false ); | 362 | m_saveScript->setEnabled( false ); |
342 | m_runScript->setEnabled( false ); | 363 | m_scripts->setItemEnabled(m_runScript_id, false); |
343 | } | 364 | } |
344 | } | 365 | } |
345 | 366 | ||
346 | void MainWindow::slotTerminate() { | 367 | void MainWindow::slotTerminate() { |
347 | if ( currentSession() ) | 368 | if ( currentSession() ) |
348 | currentSession()->layer()->close(); | 369 | currentSession()->layer()->close(); |
349 | 370 | ||
350 | slotClose(); | 371 | slotClose(); |
351 | /* FIXME move to the next session */ | 372 | /* FIXME move to the next session */ |
352 | } | 373 | } |
353 | 374 | ||
354 | void MainWindow::slotConfigure() { | 375 | void MainWindow::slotConfigure() { |
355 | ConfigDialog conf( manager()->all(), factory() ); | 376 | ConfigDialog conf( manager()->all(), factory() ); |
356 | conf.showMaximized(); | 377 | conf.showMaximized(); |
357 | 378 | ||
358 | int ret = conf.exec(); | 379 | int ret = conf.exec(); |
359 | 380 | ||
360 | if ( QDialog::Accepted == ret ) { | 381 | if ( QDialog::Accepted == ret ) { |
361 | manager()->setProfiles( conf.list() ); | 382 | manager()->setProfiles( conf.list() ); |
362 | manager()->save(); | 383 | manager()->save(); |
363 | populateProfiles(); | 384 | populateProfiles(); |
364 | } | 385 | } |
365 | } | 386 | } |
366 | /* | 387 | /* |
367 | * we will remove | 388 | * we will remove |
368 | * this window from the tabwidget | 389 | * this window from the tabwidget |
369 | * remove it from the list | 390 | * remove it from the list |
370 | * delete it | 391 | * delete it |
371 | * and set the currentSession() | 392 | * and set the currentSession() |
372 | */ | 393 | */ |
373 | void MainWindow::slotClose() { | 394 | void MainWindow::slotClose() { |
374 | if (!currentSession() ) | 395 | if (!currentSession() ) |
375 | return; | 396 | return; |
376 | 397 | ||
377 | Session* ses = currentSession(); | 398 | Session* ses = currentSession(); |
378 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 399 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
379 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 400 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
380 | m_curSession = NULL; | 401 | m_curSession = NULL; |
381 | tabWidget()->remove( /*currentSession()*/ses ); | 402 | tabWidget()->remove( /*currentSession()*/ses ); |
382 | /*it's autodelete */ | 403 | /*it's autodelete */ |
383 | m_sessions.remove( ses ); | 404 | m_sessions.remove( ses ); |
384 | qWarning("after remove!!"); | 405 | qWarning("after remove!!"); |
385 | 406 | ||
386 | if (!currentSession() ) { | 407 | if (!currentSession() ) { |
387 | m_connect->setEnabled( false ); | 408 | m_connect->setEnabled( false ); |
388 | m_disconnect->setEnabled( false ); | 409 | m_disconnect->setEnabled( false ); |
389 | m_terminate->setEnabled( false ); | 410 | m_terminate->setEnabled( false ); |
390 | m_transfer->setEnabled( false ); | 411 | m_transfer->setEnabled( false ); |
391 | m_recordScript->setEnabled( false ); | 412 | m_recordScript->setEnabled( false ); |
392 | m_saveScript->setEnabled( false ); | 413 | m_saveScript->setEnabled( false ); |
393 | m_runScript->setEnabled( false ); | 414 | m_scripts->setItemEnabled(m_runScript_id, false); |
394 | m_fullscreen->setEnabled( false ); | 415 | m_fullscreen->setEnabled( false ); |
395 | m_closewindow->setEnabled( false ); | 416 | m_closewindow->setEnabled( false ); |
396 | } | 417 | } |
397 | 418 | ||
398 | m_kb->loadDefaults(); | 419 | m_kb->loadDefaults(); |
399 | } | 420 | } |
400 | 421 | ||
401 | /* | 422 | /* |
402 | * We will get the name | 423 | * We will get the name |
403 | * Then the profile | 424 | * Then the profile |
404 | * and then we will make a profile | 425 | * and then we will make a profile |
405 | */ | 426 | */ |
406 | void MainWindow::slotProfile( int id) { | 427 | void MainWindow::slotProfile( int id) { |
407 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 428 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
408 | create( prof ); | 429 | create( prof ); |
409 | } | 430 | } |
410 | void MainWindow::create( const Profile& prof ) { | 431 | void MainWindow::create( const Profile& prof ) { |
411 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 432 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
412 | 433 | ||
413 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 434 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
414 | { | 435 | { |
415 | QMessageBox::warning(this, | 436 | QMessageBox::warning(this, |
416 | QObject::tr("Session failed"), | 437 | QObject::tr("Session failed"), |
417 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 438 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
418 | //if(ses) delete ses; | 439 | //if(ses) delete ses; |
419 | return; | 440 | return; |
420 | } | 441 | } |
421 | 442 | ||
422 | m_sessions.append( ses ); | 443 | m_sessions.append( ses ); |
423 | tabWidget()->add( ses ); | 444 | tabWidget()->add( ses ); |
424 | tabWidget()->repaint(); | 445 | tabWidget()->repaint(); |
425 | m_curSession = ses; | 446 | m_curSession = ses; |
426 | 447 | ||
427 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 448 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
428 | m_connect->setEnabled( true ); | 449 | m_connect->setEnabled( true ); |
429 | m_disconnect->setEnabled( false ); | 450 | m_disconnect->setEnabled( false ); |
430 | m_terminate->setEnabled( true ); | 451 | m_terminate->setEnabled( true ); |
431 | m_fullscreen->setEnabled( true ); | 452 | m_fullscreen->setEnabled( true ); |
432 | m_closewindow->setEnabled( true ); | 453 | m_closewindow->setEnabled( true ); |
433 | m_transfer->setEnabled( false ); | 454 | m_transfer->setEnabled( false ); |
434 | m_recordScript->setEnabled( false ); | 455 | m_recordScript->setEnabled( false ); |
435 | m_saveScript->setEnabled( false ); | 456 | m_saveScript->setEnabled( false ); |
436 | m_runScript->setEnabled( false ); | 457 | m_scripts->setItemEnabled(m_runScript_id, false); |
437 | 458 | ||
438 | // is io_layer wants direct connection, then autoconnect | 459 | // is io_layer wants direct connection, then autoconnect |
439 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 460 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
440 | if (prof.autoConnect()) { | 461 | if (prof.autoConnect()) { |
441 | slotConnect(); | 462 | slotConnect(); |
442 | } | 463 | } |
443 | 464 | ||
444 | 465 | ||
445 | 466 | ||
446 | QWidget *w = currentSession()->widget(); | 467 | QWidget *w = currentSession()->widget(); |
447 | if(w) w->setFocus(); | 468 | if(w) w->setFocus(); |
448 | 469 | ||
449 | m_kb->load(currentSession()->profile()); | 470 | m_kb->load(currentSession()->profile()); |
450 | } | 471 | } |
451 | 472 | ||
452 | void MainWindow::slotTransfer() | 473 | void MainWindow::slotTransfer() |
453 | { | 474 | { |
454 | if ( currentSession() ) { | 475 | if ( currentSession() ) { |
455 | TransferDialog dlg(currentSession()->widgetStack(), this); | 476 | TransferDialog dlg(currentSession()->widgetStack(), this); |
456 | dlg.showMaximized(); | 477 | dlg.showMaximized(); |
457 | //currentSession()->widgetStack()->add(dlg); | 478 | //currentSession()->widgetStack()->add(dlg); |
458 | dlg.exec(); | 479 | dlg.exec(); |
459 | } | 480 | } |
460 | } | 481 | } |
461 | 482 | ||
462 | 483 | ||
463 | void MainWindow::slotOpenKeb(bool state) { | 484 | void MainWindow::slotOpenKeb(bool state) { |
464 | 485 | ||
465 | if (state) m_keyBar->show(); | 486 | if (state) m_keyBar->show(); |
466 | else m_keyBar->hide(); | 487 | else m_keyBar->hide(); |
467 | 488 | ||
468 | } | 489 | } |
469 | 490 | ||
470 | 491 | ||
471 | void MainWindow::slotOpenButtons( bool state ) { | 492 | void MainWindow::slotOpenButtons( bool state ) { |
472 | 493 | ||
473 | if ( state ) { | 494 | if ( state ) { |
474 | m_buttonBar->show(); | 495 | m_buttonBar->show(); |
475 | } else { | 496 | } else { |
476 | m_buttonBar->hide(); | 497 | m_buttonBar->hide(); |
477 | } | 498 | } |
478 | } | 499 | } |
479 | 500 | ||
480 | 501 | ||
481 | 502 | ||
482 | void MainWindow::slotSessionChanged( Session* ses ) { | 503 | void MainWindow::slotSessionChanged( Session* ses ) { |
483 | qWarning("changed!"); | 504 | qWarning("changed!"); |
484 | if ( ses ) { | 505 | if ( ses ) { |
485 | m_curSession = ses; | 506 | m_curSession = ses; |
486 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 507 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
487 | if ( m_curSession->layer()->isConnected() ) { | 508 | if ( m_curSession->layer()->isConnected() ) { |
488 | m_connect->setEnabled( false ); | 509 | m_connect->setEnabled( false ); |
489 | m_disconnect->setEnabled( true ); | 510 | m_disconnect->setEnabled( true ); |
490 | m_recordScript->setEnabled( true ); | 511 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
491 | m_saveScript->setEnabled( true ); | 512 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
492 | m_runScript->setEnabled( true ); | 513 | m_scripts->setItemEnabled(m_runScript_id, true); |
493 | } else { | 514 | } else { |
494 | m_connect->setEnabled( true ); | 515 | m_connect->setEnabled( true ); |
495 | m_disconnect->setEnabled( false ); | 516 | m_disconnect->setEnabled( false ); |
496 | m_recordScript->setEnabled( false ); | 517 | m_recordScript->setEnabled( false ); |
497 | m_saveScript->setEnabled( false ); | 518 | m_saveScript->setEnabled( false ); |
498 | m_runScript->setEnabled( false ); | 519 | m_scripts->setItemEnabled(m_runScript_id, false); |
499 | } | 520 | } |
500 | 521 | ||
501 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 522 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
502 | m_transfer->setEnabled( false ); | 523 | m_transfer->setEnabled( false ); |
503 | } else { | 524 | } else { |
504 | m_transfer->setEnabled( true ); | 525 | m_transfer->setEnabled( true ); |
505 | } | 526 | } |
506 | 527 | ||
507 | 528 | ||
508 | 529 | ||
509 | 530 | ||
510 | 531 | ||
511 | QWidget *w = m_curSession->widget(); | 532 | QWidget *w = m_curSession->widget(); |
512 | if(w) w->setFocus(); | 533 | if(w) w->setFocus(); |
513 | 534 | ||
514 | m_kb->load(currentSession()->profile()); | 535 | m_kb->load(currentSession()->profile()); |
515 | } | 536 | } |
516 | } | 537 | } |
517 | 538 | ||
518 | void MainWindow::slotFullscreen() { | 539 | void MainWindow::slotFullscreen() { |
519 | 540 | ||
520 | 541 | ||
521 | 542 | ||
522 | if ( m_isFullscreen ) { | 543 | if ( m_isFullscreen ) { |
523 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 544 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
524 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 545 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
525 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 546 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
526 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 547 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
527 | 548 | ||
528 | } else { | 549 | } else { |
529 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 550 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
530 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 551 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
531 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 552 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
532 | , QPoint(0,0), false ); | 553 | , QPoint(0,0), false ); |
533 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 554 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
534 | ( m_curSession->widgetStack() )->setFocus(); | 555 | ( m_curSession->widgetStack() )->setFocus(); |
535 | ( m_curSession->widgetStack() )->show(); | 556 | ( m_curSession->widgetStack() )->show(); |
536 | 557 | ||
537 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 558 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
538 | 559 | ||
539 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 560 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
540 | } | 561 | } |
541 | 562 | ||
542 | m_isFullscreen = !m_isFullscreen; | 563 | m_isFullscreen = !m_isFullscreen; |
543 | } | 564 | } |
544 | 565 | ||
545 | 566 | ||
546 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 567 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
547 | 568 | ||
548 | if ( m_curSession ) { | 569 | if ( m_curSession ) { |
549 | 570 | ||
550 | QEvent::Type state; | 571 | QEvent::Type state; |
551 | 572 | ||
552 | if (pressed) state = QEvent::KeyPress; | 573 | if (pressed) state = QEvent::KeyPress; |
553 | else state = QEvent::KeyRelease; | 574 | else state = QEvent::KeyRelease; |
554 | 575 | ||
555 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 576 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
556 | 577 | ||
557 | // is this the best way to do this? cant figure out any other way to work | 578 | // is this the best way to do this? cant figure out any other way to work |
558 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 579 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
559 | ke.ignore(); | 580 | ke.ignore(); |
560 | } | 581 | } |
561 | } | 582 | } |
562 | void MainWindow::slotCopy() { | 583 | void MainWindow::slotCopy() { |
563 | if (!currentSession() ) return; | 584 | if (!currentSession() ) return; |
564 | currentSession()->emulationHandler()->copy(); | 585 | currentSession()->emulationHandler()->copy(); |
565 | } | 586 | } |
566 | void MainWindow::slotPaste() { | 587 | void MainWindow::slotPaste() { |
567 | if (!currentSession() ) return; | 588 | if (!currentSession() ) return; |
568 | currentSession()->emulationHandler()->paste(); | 589 | currentSession()->emulationHandler()->paste(); |
569 | } | 590 | } |
570 | 591 | ||
571 | /* | 592 | /* |
572 | * Save the session | 593 | * Save the session |
573 | */ | 594 | */ |
574 | 595 | ||
575 | void MainWindow::slotSaveSession() { | 596 | void MainWindow::slotSaveSession() { |
576 | if (!currentSession() ) { | 597 | if (!currentSession() ) { |
577 | QMessageBox::information(this, tr("Save Connection"), | 598 | QMessageBox::information(this, tr("Save Connection"), |
578 | tr("<qt>There is no Connection.</qt>"), 1 ); | 599 | tr("<qt>There is no Connection.</qt>"), 1 ); |
579 | return; | 600 | return; |
580 | } | 601 | } |
581 | manager()->add( currentSession()->profile() ); | 602 | manager()->add( currentSession()->profile() ); |
582 | manager()->save(); | 603 | manager()->save(); |
583 | populateProfiles(); | 604 | populateProfiles(); |
584 | } | 605 | } |
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 19d3a3d..3b16f0a 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,129 +1,132 @@ | |||
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 QToolButton; | 15 | class QToolButton; |
16 | class QMenuBar; | 16 | class QMenuBar; |
17 | class QAction; | 17 | class QAction; |
18 | class MetaFactory; | 18 | class MetaFactory; |
19 | class TabWidget; | 19 | class TabWidget; |
20 | class ProfileManager; | 20 | class ProfileManager; |
21 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | 22 | class FunctionKeyboard; |
23 | class FKey; | 23 | class FKey; |
24 | 24 | class DocLnk; | |
25 | 25 | ||
26 | class MainWindow : public QMainWindow { | 26 | class MainWindow : public QMainWindow { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | public: | 28 | public: |
29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); | 29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); |
30 | ~MainWindow(); | 30 | ~MainWindow(); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * our factory to generate IOLayer and so on | 33 | * our factory to generate IOLayer and so on |
34 | * | 34 | * |
35 | */ | 35 | */ |
36 | MetaFactory* factory(); | 36 | MetaFactory* factory(); |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * A session contains a QWidget*, | 39 | * A session contains a QWidget*, |
40 | * an IOLayer* and some infos for us | 40 | * an IOLayer* and some infos for us |
41 | */ | 41 | */ |
42 | Session* currentSession(); | 42 | Session* currentSession(); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * the session list | 45 | * the session list |
46 | */ | 46 | */ |
47 | QList<Session> sessions(); | 47 | QList<Session> sessions(); |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * | 50 | * |
51 | */ | 51 | */ |
52 | ProfileManager* manager(); | 52 | ProfileManager* manager(); |
53 | TabWidget* tabWidget(); | 53 | TabWidget* tabWidget(); |
54 | 54 | ||
55 | private slots: | 55 | private slots: |
56 | void slotNew(); | 56 | void slotNew(); |
57 | void slotConnect(); | 57 | void slotConnect(); |
58 | void slotDisconnect(); | 58 | void slotDisconnect(); |
59 | void slotTerminate(); | 59 | void slotTerminate(); |
60 | void slotConfigure(); | 60 | void slotConfigure(); |
61 | void slotClose(); | 61 | void slotClose(); |
62 | void slotProfile(int); | 62 | void slotProfile(int); |
63 | void slotTransfer(); | 63 | void slotTransfer(); |
64 | void slotOpenKeb(bool); | 64 | void slotOpenKeb(bool); |
65 | void slotOpenButtons(bool); | 65 | void slotOpenButtons(bool); |
66 | void slotRecordScript(); | 66 | void slotRecordScript(); |
67 | void slotSaveScript(); | 67 | void slotSaveScript(); |
68 | void slotRunScript(); | 68 | void slotRunScript(int); |
69 | void slotFullscreen(); | 69 | void slotFullscreen(); |
70 | void slotSessionChanged( Session* ); | 70 | void slotSessionChanged( Session* ); |
71 | void slotKeyReceived(FKey, ushort, ushort, bool); | 71 | void slotKeyReceived(FKey, ushort, ushort, bool); |
72 | 72 | ||
73 | /* what could these both slot do? */ | 73 | /* what could these both slot do? */ |
74 | void slotCopy(); | 74 | void slotCopy(); |
75 | void slotPaste(); | 75 | void slotPaste(); |
76 | 76 | ||
77 | /* save the currentSession() to Profiles */ | 77 | /* save the currentSession() to Profiles */ |
78 | void slotSaveSession(); | 78 | void slotSaveSession(); |
79 | 79 | ||
80 | private: | 80 | private: |
81 | void initUI(); | 81 | void initUI(); |
82 | void populateProfiles(); | 82 | void populateProfiles(); |
83 | void populateScripts(); | ||
83 | void create( const Profile& ); | 84 | void create( const Profile& ); |
84 | /** | 85 | /** |
85 | * the current session | 86 | * the current session |
86 | */ | 87 | */ |
87 | Session* m_curSession; | 88 | Session* m_curSession; |
88 | 89 | ||
89 | /** | 90 | /** |
90 | * the session list | 91 | * the session list |
91 | */ | 92 | */ |
92 | QList<Session> m_sessions; | 93 | QList<Session> m_sessions; |
94 | QList<DocLnk> m_scriptsData; | ||
93 | 95 | ||
94 | /** | 96 | /** |
95 | * the metafactory | 97 | * the metafactory |
96 | */ | 98 | */ |
97 | MetaFactory* m_factory; | 99 | MetaFactory* m_factory; |
98 | ProfileManager* m_manager; | 100 | ProfileManager* m_manager; |
99 | 101 | ||
100 | TabWidget* m_consoleWindow; | 102 | TabWidget* m_consoleWindow; |
101 | QToolBar* m_tool; | 103 | QToolBar* m_tool; |
102 | QToolBar* m_icons; | 104 | QToolBar* m_icons; |
103 | QToolBar* m_keyBar; | 105 | QToolBar* m_keyBar; |
104 | QToolBar* m_buttonBar; | 106 | QToolBar* m_buttonBar; |
105 | QMenuBar* m_bar; | 107 | QMenuBar* m_bar; |
106 | QPopupMenu* m_console; | 108 | QPopupMenu* m_console; |
107 | QPopupMenu* m_sessionsPop; | 109 | QPopupMenu* m_sessionsPop; |
110 | QPopupMenu* m_scriptsPop; | ||
108 | QPopupMenu* m_scripts; | 111 | QPopupMenu* m_scripts; |
109 | QAction* m_connect; | 112 | QAction* m_connect; |
110 | QAction* m_disconnect; | 113 | QAction* m_disconnect; |
111 | QAction* m_terminate; | 114 | QAction* m_terminate; |
112 | QAction* m_transfer; | 115 | QAction* m_transfer; |
113 | QAction* m_setProfiles; | 116 | QAction* m_setProfiles; |
114 | QAction* m_openKeys; | 117 | QAction* m_openKeys; |
115 | QAction* m_openButtons; | 118 | QAction* m_openButtons; |
116 | QAction* m_recordScript; | 119 | QAction* m_recordScript; |
117 | QAction* m_saveScript; | 120 | QAction* m_saveScript; |
118 | QAction* m_runScript; | ||
119 | QAction* m_fullscreen; | 121 | QAction* m_fullscreen; |
120 | QAction* m_closewindow; | 122 | QAction* m_closewindow; |
121 | 123 | ||
122 | FunctionKeyboard *m_kb; | 124 | FunctionKeyboard *m_kb; |
125 | int m_runScript_id; | ||
123 | bool m_isFullscreen; | 126 | bool m_isFullscreen; |
124 | 127 | ||
125 | QWidget* savedParentFullscreen; | 128 | QWidget* savedParentFullscreen; |
126 | }; | 129 | }; |
127 | 130 | ||
128 | 131 | ||
129 | #endif | 132 | #endif |