-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 36 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 25 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 139 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 22 |
5 files changed, 110 insertions, 122 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index dce08ca..31f1138 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,176 +1,176 @@ | |||
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 | #include "tabwidget.h" |
13 | 13 | ||
14 | MainWindow::MainWindow() { | 14 | MainWindow::MainWindow() { |
15 | m_factory = new MetaFactory(); | 15 | m_factory = new MetaFactory(); |
16 | m_sessions.setAutoDelete( TRUE ); | 16 | m_sessions.setAutoDelete( TRUE ); |
17 | m_curSession = 0; | 17 | m_curSession = 0; |
18 | m_manager = new ProfileManager(m_factory); | 18 | m_manager = new ProfileManager( m_factory ); |
19 | m_manager->load(); | 19 | m_manager->load(); |
20 | 20 | ||
21 | initUI(); | 21 | initUI(); |
22 | populateProfiles(); | 22 | populateProfiles(); |
23 | } | 23 | } |
24 | void MainWindow::initUI() { | 24 | void MainWindow::initUI() { |
25 | setToolBarsMovable( FALSE ); | 25 | setToolBarsMovable( FALSE ); |
26 | 26 | ||
27 | m_tool = new QToolBar( this ); | 27 | m_tool = new QToolBar( this ); |
28 | m_tool->setHorizontalStretchable( TRUE ); | 28 | m_tool->setHorizontalStretchable( TRUE ); |
29 | 29 | ||
30 | m_bar = new QMenuBar( m_tool ); | 30 | m_bar = new QMenuBar( m_tool ); |
31 | m_console = new QPopupMenu( this ); | 31 | m_console = new QPopupMenu( this ); |
32 | m_sessionsPop= new QPopupMenu( this ); | 32 | m_sessionsPop= new QPopupMenu( this ); |
33 | m_settings = new QPopupMenu( this ); | 33 | m_settings = new QPopupMenu( this ); |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * new Action for new sessions | 36 | * new Action for new sessions |
37 | */ | 37 | */ |
38 | QAction* a = new QAction(); | 38 | QAction* a = new QAction(); |
39 | a->setText( tr("New Connection") ); | 39 | a->setText( tr("New Connection") ); |
40 | a->addTo( m_console ); | 40 | a->addTo( m_console ); |
41 | connect(a, SIGNAL(activated() ), | 41 | connect(a, SIGNAL(activated() ), |
42 | this, SLOT(slotNew() ) ); | 42 | this, SLOT(slotNew() ) ); |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * connect action | 45 | * connect action |
46 | */ | 46 | */ |
47 | m_connect = new QAction(); | 47 | m_connect = new QAction(); |
48 | m_connect->setText( tr("Connect") ); | 48 | m_connect->setText( tr("Connect") ); |
49 | m_connect->addTo( m_console ); | 49 | m_connect->addTo( m_console ); |
50 | connect(m_connect, SIGNAL(activated() ), | 50 | connect(m_connect, SIGNAL(activated() ), |
51 | this, SLOT(slotConnect() ) ); | 51 | this, SLOT(slotConnect() ) ); |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * disconnect action | 54 | * disconnect action |
55 | */ | 55 | */ |
56 | m_disconnect = new QAction(); | 56 | m_disconnect = new QAction(); |
57 | m_disconnect->setText( tr("Disconnect") ); | 57 | m_disconnect->setText( tr("Disconnect") ); |
58 | m_disconnect->addTo( m_console ); | 58 | m_disconnect->addTo( m_console ); |
59 | connect(m_disconnect, SIGNAL(activated() ), | 59 | connect(m_disconnect, SIGNAL(activated() ), |
60 | this, SLOT(slotDisconnect() ) ); | 60 | this, SLOT(slotDisconnect() ) ); |
61 | 61 | ||
62 | /* | 62 | /* |
63 | * terminate action | 63 | * terminate action |
64 | */ | 64 | */ |
65 | m_terminate = new QAction(); | 65 | m_terminate = new QAction(); |
66 | m_terminate->setText( tr("Terminate") ); | 66 | m_terminate->setText( tr("Terminate") ); |
67 | m_terminate->addTo( m_console ); | 67 | m_terminate->addTo( m_console ); |
68 | connect(m_disconnect, SIGNAL(activated() ), | 68 | connect(m_disconnect, SIGNAL(activated() ), |
69 | this, SLOT(slotTerminate() ) ); | 69 | this, SLOT(slotTerminate() ) ); |
70 | 70 | ||
71 | a = new QAction(); | 71 | a = new QAction(); |
72 | a->setText( tr("Close Window") ); | 72 | a->setText( tr("Close Window") ); |
73 | a->addTo( m_console ); | 73 | a->addTo( m_console ); |
74 | connect(a, SIGNAL(activated() ), | 74 | connect(a, SIGNAL(activated() ), |
75 | this, SLOT(slotClose() ) ); | 75 | this, SLOT(slotClose() ) ); |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * the settings action | 78 | * the settings action |
79 | */ | 79 | */ |
80 | m_setProfiles = new QAction(); | 80 | m_setProfiles = new QAction(); |
81 | m_setProfiles->setText( tr("Configure Profiles") ); | 81 | m_setProfiles->setText( tr("Configure Profiles") ); |
82 | m_setProfiles->addTo( m_settings ); | 82 | m_setProfiles->addTo( m_settings ); |
83 | connect( m_setProfiles, SIGNAL(activated() ), | 83 | connect( m_setProfiles, SIGNAL(activated() ), |
84 | this, SLOT(slotConfigure() ) ); | 84 | this, SLOT(slotConfigure() ) ); |
85 | 85 | ||
86 | /* insert the submenu */ | 86 | /* insert the submenu */ |
87 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 87 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
88 | -1, 0); | 88 | -1, 0); |
89 | 89 | ||
90 | /* insert the connection menu */ | 90 | /* insert the connection menu */ |
91 | m_bar->insertItem( tr("Connection"), m_console ); | 91 | m_bar->insertItem( tr("Connection"), m_console ); |
92 | 92 | ||
93 | /* the settings menu */ | 93 | /* the settings menu */ |
94 | m_bar->insertItem( tr("Settings"), m_settings ); | 94 | m_bar->insertItem( tr("Settings"), m_settings ); |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * connect to the menu activation | 97 | * connect to the menu activation |
98 | */ | 98 | */ |
99 | connect( m_sessionsPop, SIGNAL(activated(int) ), | 99 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
100 | this, SLOT(slotProfile(int) ) ); | 100 | this, SLOT(slotProfile( int ) ) ); |
101 | 101 | ||
102 | m_consoleWindow = new TabWidget( this, "blah"); | 102 | m_consoleWindow = new TabWidget( this, "blah"); |
103 | setCentralWidget( m_consoleWindow ); | 103 | setCentralWidget( m_consoleWindow ); |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | ProfileManager* MainWindow::manager() { | 107 | ProfileManager* MainWindow::manager() { |
108 | return m_manager; | 108 | return m_manager; |
109 | } | 109 | } |
110 | 110 | ||
111 | void MainWindow::populateProfiles() { | 111 | void MainWindow::populateProfiles() { |
112 | m_sessionsPop->clear(); | 112 | m_sessionsPop->clear(); |
113 | Profile::ValueList list = manager()->all(); | 113 | Profile::ValueList list = manager()->all(); |
114 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 114 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
115 | m_sessionsPop->insertItem( (*it).name() ); | 115 | m_sessionsPop->insertItem( (*it).name() ); |
116 | } | 116 | } |
117 | 117 | ||
118 | } | 118 | } |
119 | MainWindow::~MainWindow() { | 119 | MainWindow::~MainWindow() { |
120 | delete m_factory; | 120 | delete m_factory; |
121 | } | 121 | } |
122 | 122 | ||
123 | MetaFactory* MainWindow::factory() { | 123 | MetaFactory* MainWindow::factory() { |
124 | return m_factory; | 124 | return m_factory; |
125 | } | 125 | } |
126 | 126 | ||
127 | Session* MainWindow::currentSession() { | 127 | Session* MainWindow::currentSession() { |
128 | return m_curSession; | 128 | return m_curSession; |
129 | } | 129 | } |
130 | 130 | ||
131 | QList<Session> MainWindow::sessions() { | 131 | QList<Session> MainWindow::sessions() { |
132 | return m_sessions; | 132 | return m_sessions; |
133 | } | 133 | } |
134 | 134 | ||
135 | void MainWindow::slotNew() { | 135 | void MainWindow::slotNew() { |
136 | qWarning("New Connection"); | 136 | qWarning("New Connection"); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::slotConnect() { | 139 | void MainWindow::slotConnect() { |
140 | if ( currentSession() ) | 140 | if ( currentSession() ) |
141 | currentSession()->layer()->open(); | 141 | currentSession()->layer()->open(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void MainWindow::slotDisconnect() { | 144 | void MainWindow::slotDisconnect() { |
145 | if ( currentSession() ) | 145 | if ( currentSession() ) |
146 | currentSession()->layer()->close(); | 146 | currentSession()->layer()->close(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void MainWindow::slotTerminate() { | 149 | void MainWindow::slotTerminate() { |
150 | if ( currentSession() ) | 150 | if ( currentSession() ) |
151 | currentSession()->layer()->close(); | 151 | currentSession()->layer()->close(); |
152 | delete m_curSession; | 152 | delete m_curSession; |
153 | m_curSession = 0l; | 153 | m_curSession = 0l; |
154 | /* FIXME move to the next session */ | 154 | /* FIXME move to the next session */ |
155 | } | 155 | } |
156 | 156 | ||
157 | void MainWindow::slotConfigure() { | 157 | void MainWindow::slotConfigure() { |
158 | qWarning("configure"); | 158 | qWarning("configure"); |
159 | ConfigDialog conf( manager()->all() ); | 159 | ConfigDialog conf( manager()->all() ); |
160 | conf.showMaximized(); | 160 | conf.showMaximized(); |
161 | 161 | ||
162 | int ret = conf.exec(); | 162 | int ret = conf.exec(); |
163 | 163 | ||
164 | if ( QDialog::Accepted == ret ) { | 164 | if ( QDialog::Accepted == ret ) { |
165 | manager()->setProfiles( conf.list() ); | 165 | manager()->setProfiles( conf.list() ); |
166 | populateProfiles(); | 166 | populateProfiles(); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | void MainWindow::slotClose() { | 170 | void MainWindow::slotClose() { |
171 | |||
172 | } | 171 | } |
173 | 172 | ||
174 | void MainWindow::slotProfile(int) { | 173 | void MainWindow::slotProfile( int ) { |
174 | |||
175 | 175 | ||
176 | } | 176 | } |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 8e63429..be23eff 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,188 +1,188 @@ | |||
1 | 1 | ||
2 | #include <opie/otabwidget.h> | ||
2 | #include "profileeditordialog.h" | 3 | #include "profileeditordialog.h" |
3 | 4 | ||
4 | #include "qlayout.h" | 5 | #include "qlayout.h" |
5 | #include "qlineedit.h" | 6 | #include "qlineedit.h" |
6 | #include "qlabel.h" | 7 | #include "qlabel.h" |
7 | #include "qmessagebox.h" | 8 | #include "qmessagebox.h" |
8 | #include "qstringlist.h" | 9 | #include "qstringlist.h" |
9 | #include "qcombobox.h" | 10 | #include "qcombobox.h" |
10 | 11 | ||
11 | #include "profileeditorplugins.h" | 12 | #include "profileeditorplugins.h" |
12 | #include "metafactory.h" | 13 | #include "metafactory.h" |
13 | 14 | ||
14 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 15 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
15 | const Profile& prof ) | 16 | const Profile& prof ) |
16 | : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 17 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
17 | { | 18 | { |
18 | initUI(); | 19 | initUI(); |
19 | 20 | ||
20 | // Apply current profile | 21 | // Apply current profile |
21 | // plugin_plugin->load(profile); | 22 | // plugin_plugin->load(profile); |
22 | // ... (reset profile name line edit etc.) | 23 | // ... (reset profile name line edit etc.) |
23 | } | 24 | } |
24 | 25 | ||
25 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
26 | : QTabDialog(0, 0, TRUE), m_fact( fact ) | 27 | : QDialog(0, 0, TRUE), m_fact( fact ) |
27 | { | 28 | { |
28 | // Default profile | 29 | // Default profile |
29 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); | 30 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); |
30 | 31 | ||
31 | initUI(); | 32 | initUI(); |
32 | 33 | ||
33 | // Apply current profile | 34 | // Apply current profile |
34 | // plugin_plugin->load(profile); | 35 | // plugin_plugin->load(profile); |
35 | } | 36 | } |
36 | 37 | ||
37 | Profile ProfileEditorDialog::profile() const | 38 | Profile ProfileEditorDialog::profile() const |
38 | { | 39 | { |
39 | return m_prof; | 40 | return m_prof; |
40 | } | 41 | } |
41 | 42 | ||
42 | void ProfileEditorDialog::initUI() | 43 | void ProfileEditorDialog::initUI() |
43 | { | 44 | { |
44 | QWidget *tabterm, *tabconn, *tabprof; | 45 | |
46 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | ||
47 | OTabWidget *tabWidget = new OTabWidget( this ); | ||
48 | mainLayout->add(tabWidget); | ||
49 | |||
50 | QWidget *tabterm, *tabconn, *tabprof; | ||
45 | 51 | ||
46 | tabprof = new QWidget(this); | 52 | tabprof = new QWidget(this); |
47 | tabterm = new QWidget(this); | 53 | tabterm = new QWidget(this); |
48 | tabconn = new QWidget(this); | 54 | tabconn = new QWidget(this); |
49 | 55 | ||
50 | // for the time being: fake factory | 56 | // for the time being: fake factory |
51 | 57 | ||
52 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); | 58 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); |
53 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); | 59 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); |
54 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); | 60 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); |
55 | 61 | ||
56 | // profile tab | 62 | // profile tab |
57 | 63 | ||
58 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 64 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
59 | 65 | ||
60 | name_line = new QLineEdit(tabprof); | 66 | name_line = new QLineEdit(tabprof); |
61 | 67 | ||
62 | // connection tab, fixed part | 68 | // connection tab, fixed part |
63 | 69 | ||
64 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); | 70 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); |
65 | 71 | ||
66 | device_box = new QComboBox(tabconn); | 72 | device_box = new QComboBox(tabconn); |
67 | 73 | ||
68 | QStringList w = m_fact->configWidgets(); | 74 | QStringList w = m_fact->configWidgets(); |
69 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 75 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
70 | device_box->insertItem(m_fact->name((*it))); | 76 | device_box->insertItem(m_fact->name((*it))); |
71 | 77 | ||
72 | // connection tab, factory part | 78 | // connection tab, factory part |
73 | plugin_base = new QWidget(tabconn); | 79 | plugin_base = new QWidget(tabconn); |
74 | plugin_layout = new QHBoxLayout(plugin_base, 0); | 80 | plugin_layout = new QHBoxLayout(plugin_base, 0); |
75 | 81 | ||
76 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof); | 82 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof); |
77 | plugin_layout->add(plugin_plugin->widget()); | 83 | plugin_layout->add(plugin_plugin->widget()); |
78 | 84 | ||
79 | // connection tab, general part | 85 | // connection tab, general part |
80 | 86 | ||
81 | QWidget *conn_widget = plugin_plugin->connection_widget(); | 87 | QWidget *conn_widget = plugin_plugin->connection_widget(); |
82 | conn_widget->reparent(tabconn, 0, QPoint(), true); | 88 | conn_widget->reparent(tabconn, 0, QPoint(), true); |
83 | 89 | ||
84 | // terminal tab | 90 | // terminal tab |
85 | 91 | ||
86 | QWidget *term_widget = plugin_plugin->terminal_widget(); | 92 | QWidget *term_widget = plugin_plugin->terminal_widget(); |
87 | term_widget->reparent(tabterm, 0, QPoint(), true); | 93 | term_widget->reparent(tabterm, 0, QPoint(), true); |
88 | 94 | ||
89 | // layouting | 95 | // layouting |
90 | 96 | ||
91 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 97 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
92 | vbox3->add(name); | 98 | vbox3->add(name); |
93 | vbox3->add(name_line); | 99 | vbox3->add(name_line); |
94 | vbox3->addStretch(1); | 100 | vbox3->addStretch(1); |
95 | 101 | ||
96 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); | 102 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); |
97 | vbox->add(device); | 103 | vbox->add(device); |
98 | vbox->add(device_box); | 104 | vbox->add(device_box); |
99 | vbox->add(plugin_base); | 105 | vbox->add(plugin_base); |
100 | vbox->add(conn_widget); | 106 | vbox->add(conn_widget); |
107 | vbox->setStretchFactor(device, 1); | ||
108 | vbox->setStretchFactor(device_box, 1); | ||
109 | vbox->setStretchFactor(plugin_base, 1); | ||
110 | vbox->setStretchFactor(conn_widget, 7); | ||
101 | 111 | ||
102 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); | 112 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); |
103 | vbox2->add(term_widget); | 113 | vbox2->add(term_widget); |
104 | 114 | ||
105 | addTab(tabprof, QObject::tr("Profile")); | 115 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
106 | addTab(tabconn, QObject::tr("Connection")); | 116 | tabWidget->addTab(tabconn, "", QObject::tr("Connection")); |
107 | addTab(tabterm, QObject::tr("Terminal")); | 117 | tabWidget->addTab(tabterm, "", QObject::tr("Terminal")); |
108 | |||
109 | setOkButton(QObject::tr("OK")); | ||
110 | setCancelButton(QObject::tr("Cancel")); | ||
111 | 118 | ||
112 | // load profile values | 119 | // load profile values |
113 | |||
114 | name_line->setText(m_prof.name()); | 120 | name_line->setText(m_prof.name()); |
115 | for(int i = 0; i < device_box->count(); i++) | 121 | for(int i = 0; i < device_box->count(); i++) |
116 | { | 122 | { |
117 | device_box->setCurrentItem(i); | 123 | device_box->setCurrentItem(i); |
118 | if(prof_type() == m_prof.ioLayerName()) | 124 | if(prof_type() == m_prof.ioLayerName()) |
119 | { | 125 | { |
120 | slotDevice(i); | 126 | slotDevice(i); |
121 | break; | 127 | break; |
122 | } | 128 | } |
123 | } | 129 | } |
124 | 130 | ||
125 | // signals | 131 | // signals |
126 | 132 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); | |
127 | connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); | ||
128 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); | ||
129 | } | 133 | } |
130 | 134 | ||
131 | ProfileEditorDialog::~ProfileEditorDialog() { | 135 | ProfileEditorDialog::~ProfileEditorDialog() { |
132 | 136 | ||
133 | } | 137 | } |
134 | 138 | ||
135 | void ProfileEditorDialog::slotDevice(int id) | 139 | void ProfileEditorDialog::slotDevice(int id) |
136 | { | 140 | { |
137 | delete plugin_plugin; | 141 | delete plugin_plugin; |
138 | 142 | ||
139 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof); | 143 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof); |
140 | plugin_layout->add(plugin_plugin->widget()); | 144 | plugin_layout->add(plugin_plugin->widget()); |
141 | 145 | ||
142 | // Reload profile associated to device, including e.g. conn_device() | 146 | // Reload profile associated to device, including e.g. conn_device() |
143 | // m_prof = plugin_plugin->profile() | 147 | // m_prof = plugin_plugin->profile() |
144 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) | 148 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) |
145 | 149 | ||
146 | //plugin_plugin->show(); | 150 | //plugin_plugin->show(); |
147 | plugin_plugin->widget()->show(); | 151 | plugin_plugin->widget()->show(); |
148 | } | 152 | } |
149 | 153 | ||
150 | void ProfileEditorDialog::accept() | 154 | void ProfileEditorDialog::accept() |
151 | { | 155 | { |
152 | if(prof_name().isEmpty()) | 156 | if(prof_name().isEmpty()) |
153 | { | 157 | { |
154 | QMessageBox::information(this, | 158 | QMessageBox::information(this, |
155 | QObject::tr("Invalid profile"), | 159 | QObject::tr("Invalid profile"), |
156 | QObject::tr("Please enter a profile name.")); | 160 | QObject::tr("Please enter a profile name.")); |
157 | return; | 161 | return; |
158 | } | 162 | } |
159 | // Save profile and plugin profile | 163 | // Save profile and plugin profile |
160 | if(plugin_plugin) plugin_plugin->save(); | 164 | if(plugin_plugin) plugin_plugin->save(); |
161 | 165 | ||
162 | // Save general values | 166 | // Save general values |
163 | m_prof.setName(prof_name()); | 167 | m_prof.setName(prof_name()); |
164 | m_prof.setIOLayer(prof_type()); | 168 | m_prof.setIOLayer(prof_type()); |
165 | 169 | ||
166 | QDialog::accept(); | 170 | QDialog::accept(); |
167 | } | 171 | } |
168 | 172 | ||
169 | void ProfileEditorDialog::slotCancel() | ||
170 | { | ||
171 | reject(); | ||
172 | } | ||
173 | 173 | ||
174 | QString ProfileEditorDialog::prof_name() | 174 | QString ProfileEditorDialog::prof_name() |
175 | { | 175 | { |
176 | return name_line->text(); | 176 | return name_line->text(); |
177 | } | 177 | } |
178 | 178 | ||
179 | QString ProfileEditorDialog::prof_type() | 179 | QString ProfileEditorDialog::prof_type() |
180 | { | 180 | { |
181 | QStringList w = m_fact->configWidgets(); | 181 | QStringList w = m_fact->configWidgets(); |
182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
184 | 184 | ||
185 | return QString::null; | 185 | return QString::null; |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index 18e2ec0..8e830f1 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h | |||
@@ -1,53 +1,50 @@ | |||
1 | #ifndef PROFILE_EDITOR_DIALOG | 1 | #ifndef PROFILE_EDITOR_DIALOG |
2 | #define PROFILE_EDITOR_DIALOG | 2 | #define PROFILE_EDITOR_DIALOG |
3 | 3 | ||
4 | #include <qtabdialog.h> | 4 | #include <qdialog.h> |
5 | 5 | ||
6 | #include "profile.h" | 6 | #include "profile.h" |
7 | 7 | ||
8 | class MetaFactory; | 8 | class MetaFactory; |
9 | class EditBase; | 9 | class EditBase; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | class QHBoxLayout; | 11 | class QHBoxLayout; |
12 | class QLineEdit; | 12 | class QLineEdit; |
13 | class QComboBox; | 13 | class QComboBox; |
14 | class QLabel; | 14 | class QLabel; |
15 | class ProfileEditorPlugin; | 15 | class ProfileEditorPlugin; |
16 | 16 | ||
17 | class ProfileEditorDialog : public QTabDialog { | 17 | class ProfileEditorDialog : public QDialog { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | ProfileEditorDialog(MetaFactory* fact, | 20 | ProfileEditorDialog(MetaFactory* fact, |
21 | const Profile& prof ); | 21 | const Profile& prof ); |
22 | ProfileEditorDialog(MetaFactory* fact ); | 22 | ProfileEditorDialog(MetaFactory* fact ); |
23 | ~ProfileEditorDialog(); | 23 | ~ProfileEditorDialog(); |
24 | Profile profile()const; | 24 | Profile profile()const; |
25 | 25 | ||
26 | QString prof_name(); | 26 | QString prof_name(); |
27 | QString prof_type(); | 27 | QString prof_type(); |
28 | 28 | ||
29 | public slots: | 29 | public slots: |
30 | void accept(); | 30 | void accept(); |
31 | //void slotOk(); | 31 | void slotDevice(int id); |
32 | void slotCancel(); | ||
33 | |||
34 | void slotDevice(int id); | ||
35 | 32 | ||
36 | private: | 33 | private: |
37 | void initUI(); | 34 | void initUI(); |
38 | 35 | ||
39 | MetaFactory* m_fact; | 36 | MetaFactory* m_fact; |
40 | EditBase* m_base; | 37 | EditBase* m_base; |
41 | QTabWidget* m_tab; | 38 | QTabWidget* m_tab; |
42 | QHBoxLayout* m_lay; | 39 | QHBoxLayout* m_lay; |
43 | Profile m_prof; | 40 | Profile m_prof; |
44 | 41 | ||
45 | QLineEdit *name_line; | 42 | QLineEdit *name_line; |
46 | QComboBox *device_box; | 43 | QComboBox *device_box; |
47 | 44 | ||
48 | QWidget *plugin_base; | 45 | QWidget *plugin_base; |
49 | ProfileEditorPlugin *plugin_plugin; | 46 | ProfileEditorPlugin *plugin_plugin; |
50 | QHBoxLayout *plugin_layout; | 47 | QHBoxLayout *plugin_layout; |
51 | }; | 48 | }; |
52 | 49 | ||
53 | #endif | 50 | #endif |
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp index b63fa1c..c11c854 100644 --- a/noncore/apps/opie-console/profileeditorplugins.cpp +++ b/noncore/apps/opie-console/profileeditorplugins.cpp | |||
@@ -1,484 +1,475 @@ | |||
1 | 1 | ||
2 | #include "profileeditorplugins.h" | 2 | #include "profileeditorplugins.h" |
3 | #include "profile.h" | 3 | #include "profile.h" |
4 | 4 | ||
5 | #include "qframe.h" | 5 | #include "qframe.h" |
6 | #include "qlabel.h" | 6 | #include "qlabel.h" |
7 | #include "qlineedit.h" | 7 | #include "qlineedit.h" |
8 | #include "qlayout.h" | 8 | #include "qlayout.h" |
9 | #include "qcombobox.h" | 9 | #include "qcombobox.h" |
10 | #include "qradiobutton.h" | 10 | #include "qradiobutton.h" |
11 | #include "qcheckbox.h" | 11 | #include "qcheckbox.h" |
12 | #include "qbuttongroup.h" | 12 | #include "qbuttongroup.h" |
13 | #include "qhgroupbox.h" | ||
14 | #include "qvbox.h" | ||
13 | 15 | ||
14 | #include "io_serial.h" | 16 | #include "io_serial.h" |
15 | 17 | ||
16 | // Base class | 18 | // Base class |
17 | 19 | ||
18 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile *p) | 20 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile *p) |
19 | : QObject() | 21 | : QObject() |
20 | { | 22 | { |
21 | m_parent = parent; | 23 | m_parent = parent; |
22 | m_profile = p; | 24 | m_profile = p; |
23 | m_widget = NULL; | 25 | m_widget = NULL; |
24 | } | 26 | } |
25 | 27 | ||
26 | ProfileEditorPlugin::~ProfileEditorPlugin() | 28 | ProfileEditorPlugin::~ProfileEditorPlugin() |
27 | { | 29 | { |
28 | if(m_widget) delete m_widget; | 30 | if(m_widget) delete m_widget; |
29 | } | 31 | } |
30 | 32 | ||
31 | QWidget *ProfileEditorPlugin::connection_widget() | 33 | QWidget *ProfileEditorPlugin::connection_widget() |
32 | { | 34 | { |
33 | QWidget *root; | 35 | QWidget *root; |
34 | QVBoxLayout *lroot; | 36 | QVBoxLayout *lroot; |
35 | 37 | ||
36 | root = new QWidget(); | 38 | root = new QWidget(); |
37 | 39 | ||
38 | // Build GUI | 40 | // Build GUI |
41 | QLabel *speedlabel = new QLabel(QObject::tr("Speed"), root); | ||
39 | 42 | ||
40 | QComboBox *speed_box = new QComboBox(root); | 43 | QComboBox *speed_box = new QComboBox(root); |
41 | speed_box->insertItem("115200 baud", id_baud_115200); | 44 | speed_box->insertItem("115200 baud", id_baud_115200); |
42 | speed_box->insertItem("57600 baud", id_baud_57600); | 45 | speed_box->insertItem("57600 baud", id_baud_57600); |
43 | speed_box->insertItem("38400 baud", id_baud_38400); | 46 | speed_box->insertItem("38400 baud", id_baud_38400); |
44 | speed_box->insertItem("19200 baud", id_baud_19200); | 47 | speed_box->insertItem("19200 baud", id_baud_19200); |
45 | speed_box->insertItem("9600 baud", id_baud_9600); | 48 | speed_box->insertItem("9600 baud", id_baud_9600); |
46 | 49 | ||
47 | QLabel *speedlabel = new QLabel(QObject::tr("Speed"), root); | 50 | QButtonGroup *group_flow = new QButtonGroup(QObject::tr("Flow control"), root); |
48 | QLabel *flow = new QLabel(QObject::tr("Flow control"), root); | ||
49 | QLabel *parity = new QLabel(QObject::tr("Parity"), root); | ||
50 | |||
51 | QButtonGroup *group_flow = new QButtonGroup(root); | ||
52 | group_flow->hide(); | ||
53 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), root); | ||
54 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), root); | ||
55 | group_flow->insert(flow_hw, id_flow_hw); | ||
56 | group_flow->insert(flow_sw, id_flow_sw); | ||
57 | |||
58 | QButtonGroup *group_parity = new QButtonGroup(root); | ||
59 | group_parity->hide(); | ||
60 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), root); | ||
61 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), root); | ||
62 | group_parity->insert(parity_odd, id_parity_odd); | ||
63 | group_parity->insert(parity_even, id_parity_even); | ||
64 | 51 | ||
65 | // Build Layout | 52 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), group_flow); |
53 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), group_flow); | ||
54 | |||
55 | QButtonGroup *group_parity = new QButtonGroup(QObject::tr("Parity"), root); | ||
56 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), group_parity); | ||
57 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), group_parity); | ||
66 | 58 | ||
59 | // Build Layout | ||
67 | lroot = new QVBoxLayout(root); | 60 | lroot = new QVBoxLayout(root); |
68 | lroot->add(speedlabel); | 61 | lroot->add(speedlabel); |
69 | lroot->add(speed_box); | 62 | lroot->add(speed_box); |
70 | lroot->add(flow); | 63 | lroot->setStretchFactor(speedlabel, 1); |
71 | QHBoxLayout *hbox = new QHBoxLayout(lroot, 2); | 64 | lroot->setStretchFactor(speed_box, 1); |
65 | |||
66 | QHBoxLayout *hbox = new QHBoxLayout(group_flow, 2); | ||
72 | hbox->add(flow_hw); | 67 | hbox->add(flow_hw); |
73 | hbox->add(flow_sw); | 68 | hbox->add(flow_sw); |
74 | lroot->add(parity); | 69 | lroot->add(group_flow); |
75 | QHBoxLayout *hbox2 = new QHBoxLayout(lroot, 2); | 70 | lroot->setStretchFactor(group_flow, 2); |
76 | hbox2->add(parity_odd); | 71 | |
77 | hbox2->add(parity_even); | 72 | QHBoxLayout *hboxPar = new QHBoxLayout( group_parity, 2); |
78 | 73 | hboxPar->add(parity_odd); | |
74 | hboxPar->add(parity_even); | ||
75 | lroot->add(group_parity); | ||
76 | lroot->setStretchFactor(group_parity, 2); | ||
79 | // Apply profile settings | 77 | // Apply profile settings |
80 | 78 | ||
81 | int rad_flow = m_profile->readNumEntry("Flow"); | 79 | int rad_flow = m_profile->readNumEntry("Flow"); |
82 | int rad_parity = m_profile->readNumEntry("Parity"); | 80 | int rad_parity = m_profile->readNumEntry("Parity"); |
83 | int speed = m_profile->readNumEntry("Speed"); | 81 | int speed = m_profile->readNumEntry("Speed"); |
84 | 82 | ||
85 | if(rad_flow == IOSerial::FlowHW) flow_hw->setChecked(true); | 83 | if(rad_flow == IOSerial::FlowHW) flow_hw->setChecked(true); |
86 | else flow_sw->setChecked(true); | 84 | else flow_sw->setChecked(true); |
87 | if(rad_parity == IOSerial::ParityEven) parity_even->setChecked(true); | 85 | if(rad_parity == IOSerial::ParityEven) parity_even->setChecked(true); |
88 | else parity_odd->setChecked(true); | 86 | else parity_odd->setChecked(true); |
89 | if(speed == 115200) speed_box->setCurrentItem(id_baud_115200); | 87 | if(speed == 115200) speed_box->setCurrentItem(id_baud_115200); |
90 | if(speed == 57600) speed_box->setCurrentItem(id_baud_57600); | 88 | if(speed == 57600) speed_box->setCurrentItem(id_baud_57600); |
91 | if(speed == 38400) speed_box->setCurrentItem(id_baud_38400); | 89 | if(speed == 38400) speed_box->setCurrentItem(id_baud_38400); |
92 | if(speed == 19200) speed_box->setCurrentItem(id_baud_19200); | 90 | if(speed == 19200) speed_box->setCurrentItem(id_baud_19200); |
93 | if(speed == 9600) speed_box->setCurrentItem(id_baud_9600); | 91 | if(speed == 9600) speed_box->setCurrentItem(id_baud_9600); |
94 | 92 | ||
95 | // Signals | 93 | // Signals |
96 | 94 | ||
97 | connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConnFlow(int))); | 95 | connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConnFlow(int))); |
98 | connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConnParity(int))); | 96 | connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConnParity(int))); |
99 | connect(speed_box, SIGNAL(activated(int)), SLOT(slotConnSpeed(int))); | 97 | connect(speed_box, SIGNAL(activated(int)), SLOT(slotConnSpeed(int))); |
100 | 98 | ||
101 | return root; | 99 | return root; |
102 | } | 100 | } |
103 | 101 | ||
104 | QWidget *ProfileEditorPlugin::terminal_widget() | 102 | QWidget *ProfileEditorPlugin::terminal_widget() |
105 | { | 103 | { |
106 | QWidget *root; | 104 | QWidget *root; |
107 | QVBoxLayout *lroot; | 105 | QVBoxLayout *lroot; |
108 | 106 | ||
109 | root = new QWidget(); | 107 | root = new QWidget(); |
110 | 108 | ||
111 | // Build GUI | 109 | // Build GUI |
112 | 110 | ||
111 | |||
112 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), root); | ||
113 | |||
113 | QComboBox *terminal_box = new QComboBox(root); | 114 | QComboBox *terminal_box = new QComboBox(root); |
114 | terminal_box->insertItem("VT 100", id_term_vt100); | 115 | terminal_box->insertItem("VT 100", id_term_vt100); |
115 | terminal_box->insertItem("VT 220", id_term_vt220); | 116 | terminal_box->insertItem("VT 220", id_term_vt220); |
116 | terminal_box->insertItem("ANSI", id_term_ansi); | 117 | terminal_box->insertItem("ANSI", id_term_ansi); |
117 | 118 | ||
118 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), root); | 119 | QLabel *colourlabel = new QLabel(QObject::tr("Colour scheme"), root); |
119 | QLabel *colourlabel = new QLabel(QObject::tr("Colour scheme"), root); | ||
120 | QLabel *sizelabel = new QLabel(QObject::tr("Font size"), root); | ||
121 | QLabel *options = new QLabel(QObject::tr("Options"), root); | ||
122 | QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), root); | ||
123 | |||
124 | QComboBox *colour_box = new QComboBox(root); | 120 | QComboBox *colour_box = new QComboBox(root); |
125 | colour_box->insertItem(QObject::tr("black on white"), id_term_black); | 121 | colour_box->insertItem(QObject::tr("black on white"), id_term_black); |
126 | colour_box->insertItem(QObject::tr("white on black"), id_term_white); | 122 | colour_box->insertItem(QObject::tr("white on black"), id_term_white); |
127 | 123 | ||
128 | QButtonGroup *group_size = new QButtonGroup(root); | 124 | QButtonGroup *group_size = new QButtonGroup( QObject::tr("Font size"), root ); |
129 | group_size->hide(); | 125 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), group_size ); |
130 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), root); | 126 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), group_size ); |
131 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), root); | 127 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), group_size ); |
132 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), root); | ||
133 | group_size->insert(size_small); | ||
134 | group_size->insert(size_medium); | ||
135 | group_size->insert(size_large); | ||
136 | 128 | ||
137 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), root); | 129 | QHGroupBox *group_conv = new QHGroupBox( QObject::tr("Line-break conversions"), root ); |
138 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), root); | 130 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), group_conv); |
131 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), group_conv); | ||
139 | 132 | ||
140 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), root); | 133 | QHGroupBox *group_options = new QHGroupBox( QObject::tr("Options"), root ); |
141 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), root); | 134 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), group_options); |
135 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), group_options); | ||
142 | 136 | ||
143 | // Build Layout | 137 | // Build Layout |
144 | |||
145 | lroot = new QVBoxLayout(root, 2); | 138 | lroot = new QVBoxLayout(root, 2); |
146 | lroot->add(terminal); | 139 | |
147 | lroot->add(terminal_box); | 140 | QVBoxLayout *typeBox = new QVBoxLayout( lroot ); |
148 | lroot->add(sizelabel); | 141 | typeBox->add(terminal); |
149 | QHBoxLayout *hbox = new QHBoxLayout(lroot, 2); | 142 | typeBox->add(terminal_box); |
143 | |||
144 | QHBoxLayout *hbox = new QHBoxLayout( group_size, 2); | ||
150 | hbox->add(size_small); | 145 | hbox->add(size_small); |
151 | hbox->add(size_medium); | 146 | hbox->add(size_medium); |
152 | hbox->add(size_large); | 147 | hbox->add(size_large); |
153 | lroot->add(colourlabel); | 148 | lroot->add( group_size ); |
154 | lroot->add(colour_box); | 149 | |
155 | lroot->add(conversions); | 150 | QVBoxLayout *colourBox = new QVBoxLayout( lroot ); |
156 | QHBoxLayout *hbox2 = new QHBoxLayout(lroot, 2); | 151 | colourBox->add(colourlabel); |
157 | hbox2->add(conv_inbound); | 152 | colourBox->add(colour_box); |
158 | hbox2->add(conv_outbound); | 153 | |
159 | lroot->add(options); | 154 | lroot->add(group_conv); |
160 | QHBoxLayout *hbox3 = new QHBoxLayout(lroot, 2); | 155 | lroot->add(group_options); |
161 | hbox3->add(option_wrap); | ||
162 | hbox3->add(option_echo); | ||
163 | 156 | ||
164 | // Apply profile settings | 157 | // Apply profile settings |
165 | 158 | ||
166 | int term = m_profile->readNumEntry("Terminal"); | 159 | int term = m_profile->readNumEntry("Terminal"); |
167 | int colour = m_profile->readNumEntry("Colour"); | 160 | int colour = m_profile->readNumEntry("Colour"); |
168 | int fontsize = m_profile->readNumEntry("Font"); | 161 | int fontsize = m_profile->readNumEntry("Font"); |
169 | int opt_echo = m_profile->readNumEntry("Echo"); | 162 | int opt_echo = m_profile->readNumEntry("Echo"); |
170 | int opt_wrap = m_profile->readNumEntry("Wrap"); | 163 | int opt_wrap = m_profile->readNumEntry("Wrap"); |
171 | int opt_inbound = m_profile->readNumEntry("Inbound"); | 164 | int opt_inbound = m_profile->readNumEntry("Inbound"); |
172 | int opt_outbound = m_profile->readNumEntry("Outbound"); | 165 | int opt_outbound = m_profile->readNumEntry("Outbound"); |
173 | 166 | ||
174 | if(term == Profile::VT102) terminal_box->setCurrentItem(id_term_vt100); | 167 | if(term == Profile::VT102) terminal_box->setCurrentItem(id_term_vt100); |
175 | 168 | ||
176 | if(colour == Profile::Black) colour_box->setCurrentItem(id_term_black); | 169 | if(colour == Profile::Black) colour_box->setCurrentItem(id_term_black); |
177 | if(colour == Profile::White) colour_box->setCurrentItem(id_term_white); | 170 | if(colour == Profile::White) colour_box->setCurrentItem(id_term_white); |
178 | 171 | ||
179 | if(fontsize == Profile::Micro) size_small->setChecked(true); | 172 | if(fontsize == Profile::Micro) size_small->setChecked(true); |
180 | if(fontsize == Profile::Small) size_medium->setChecked(true); | 173 | if(fontsize == Profile::Small) size_medium->setChecked(true); |
181 | if(fontsize == Profile::Medium) size_large->setChecked(true); | 174 | if(fontsize == Profile::Medium) size_large->setChecked(true); |
182 | 175 | ||
183 | if(opt_echo) option_echo->setChecked(true); | 176 | if(opt_echo) option_echo->setChecked(true); |
184 | if(opt_wrap) option_wrap->setChecked(true); | 177 | if(opt_wrap) option_wrap->setChecked(true); |
185 | if(opt_inbound) conv_inbound->setChecked(true); | 178 | if(opt_inbound) conv_inbound->setChecked(true); |
186 | if(opt_outbound) conv_outbound->setChecked(true); | 179 | if(opt_outbound) conv_outbound->setChecked(true); |
187 | 180 | ||
188 | // Signals | 181 | // Signals |
189 | 182 | ||
190 | connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int))); | 183 | connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int))); |
191 | connect(colour_box, SIGNAL(activated(int)), SLOT(slotTermColour(int))); | 184 | connect(colour_box, SIGNAL(activated(int)), SLOT(slotTermColour(int))); |
192 | connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int))); | 185 | connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int))); |
193 | 186 | ||
194 | connect(option_echo, SIGNAL(toggled(bool)), SLOT(slotTermEcho(bool))); | 187 | connect(option_echo, SIGNAL(toggled(bool)), SLOT(slotTermEcho(bool))); |
195 | connect(option_wrap, SIGNAL(toggled(bool)), SLOT(slotTermWrap(bool))); | 188 | connect(option_wrap, SIGNAL(toggled(bool)), SLOT(slotTermWrap(bool))); |
196 | connect(conv_inbound, SIGNAL(toggled(bool)), SLOT(slotTermInbound(bool))); | 189 | connect(conv_inbound, SIGNAL(toggled(bool)), SLOT(slotTermInbound(bool))); |
197 | connect(conv_outbound, SIGNAL(toggled(bool)), SLOT(slotTermOutbound(bool))); | 190 | connect(conv_outbound, SIGNAL(toggled(bool)), SLOT(slotTermOutbound(bool))); |
198 | 191 | ||
199 | return root; | 192 | return root; |
200 | } | 193 | } |
201 | 194 | ||
202 | void ProfileEditorPlugin::slotConnFlow(int id) | 195 | void ProfileEditorPlugin::slotConnFlow(int id) |
203 | { | 196 | { |
204 | switch(id) | 197 | switch(id) |
205 | { | 198 | { |
206 | case id_flow_hw: | 199 | case id_flow_hw: |
207 | m_profile->writeEntry("Flow", IOSerial::FlowHW); | 200 | m_profile->writeEntry("Flow", IOSerial::FlowHW); |
208 | break; | 201 | break; |
209 | case id_flow_sw: | 202 | case id_flow_sw: |
210 | m_profile->writeEntry("Flow", IOSerial::FlowSW); | 203 | m_profile->writeEntry("Flow", IOSerial::FlowSW); |
211 | break; | 204 | break; |
212 | } | 205 | } |
213 | } | 206 | } |
214 | 207 | ||
215 | void ProfileEditorPlugin::slotConnParity(int id) | 208 | void ProfileEditorPlugin::slotConnParity(int id) |
216 | { | 209 | { |
217 | switch(id) | 210 | switch(id) |
218 | { | 211 | { |
219 | case id_parity_odd: | 212 | case id_parity_odd: |
220 | m_profile->writeEntry("Parity", IOSerial::ParityEven); | 213 | m_profile->writeEntry("Parity", IOSerial::ParityEven); |
221 | break; | 214 | break; |
222 | case id_parity_even: | 215 | case id_parity_even: |
223 | m_profile->writeEntry("Parity", IOSerial::ParityOdd); | 216 | m_profile->writeEntry("Parity", IOSerial::ParityOdd); |
224 | break; | 217 | break; |
225 | } | 218 | } |
226 | } | 219 | } |
227 | 220 | ||
228 | void ProfileEditorPlugin::slotConnSpeed(int id) | 221 | void ProfileEditorPlugin::slotConnSpeed(int id) |
229 | { | 222 | { |
230 | switch(id) | 223 | switch(id) |
231 | { | 224 | { |
232 | 225 | ||
233 | case id_baud_115200: | 226 | case id_baud_115200: |
234 | m_profile->writeEntry("Speed", 115200); | 227 | m_profile->writeEntry("Speed", 115200); |
235 | break; | 228 | break; |
236 | case id_baud_57600: | 229 | case id_baud_57600: |
237 | m_profile->writeEntry("Speed", 57600); | 230 | m_profile->writeEntry("Speed", 57600); |
238 | break; | 231 | break; |
239 | case id_baud_38400: | 232 | case id_baud_38400: |
240 | m_profile->writeEntry("Speed", 38400); | 233 | m_profile->writeEntry("Speed", 38400); |
241 | break; | 234 | break; |
242 | case id_baud_19200: | 235 | case id_baud_19200: |
243 | m_profile->writeEntry("Speed", 19200); | 236 | m_profile->writeEntry("Speed", 19200); |
244 | break; | 237 | break; |
245 | case id_baud_9600: | 238 | case id_baud_9600: |
246 | m_profile->writeEntry("Speed", 9600); | 239 | m_profile->writeEntry("Speed", 9600); |
247 | break; | 240 | break; |
248 | } | 241 | } |
249 | } | 242 | } |
250 | 243 | ||
251 | void ProfileEditorPlugin::slotTermTerm(int id) | 244 | void ProfileEditorPlugin::slotTermTerm(int id) |
252 | { | 245 | { |
253 | switch(id) | 246 | switch(id) |
254 | { | 247 | { |
255 | case id_term_vt100: | 248 | case id_term_vt100: |
256 | m_profile->writeEntry("Terminal", Profile::VT102); | 249 | m_profile->writeEntry("Terminal", Profile::VT102); |
257 | break; | 250 | break; |
258 | case id_term_vt220: | 251 | case id_term_vt220: |
259 | m_profile->writeEntry("Terminal", Profile::VT102); | 252 | m_profile->writeEntry("Terminal", Profile::VT102); |
260 | break; | 253 | break; |
261 | case id_term_ansi: | 254 | case id_term_ansi: |
262 | m_profile->writeEntry("Terminal", Profile::VT102); | 255 | m_profile->writeEntry("Terminal", Profile::VT102); |
263 | break; | 256 | break; |
264 | } | 257 | } |
265 | } | 258 | } |
266 | 259 | ||
267 | void ProfileEditorPlugin::slotTermColour(int id) | 260 | void ProfileEditorPlugin::slotTermColour(int id) |
268 | { | 261 | { |
269 | switch(id) | 262 | switch(id) |
270 | { | 263 | { |
271 | case id_term_black: | 264 | case id_term_black: |
272 | m_profile->writeEntry("Colour", Profile::Black); | 265 | m_profile->writeEntry("Colour", Profile::Black); |
273 | break; | 266 | break; |
274 | case id_term_white: | 267 | case id_term_white: |
275 | m_profile->writeEntry("Colour", Profile::White); | 268 | m_profile->writeEntry("Colour", Profile::White); |
276 | break; | 269 | break; |
277 | } | 270 | } |
278 | } | 271 | } |
279 | 272 | ||
280 | void ProfileEditorPlugin::slotTermFont(int id) | 273 | void ProfileEditorPlugin::slotTermFont(int id) |
281 | { | 274 | { |
282 | switch(id) | 275 | switch(id) |
283 | { | 276 | { |
284 | case id_size_small: | 277 | case id_size_small: |
285 | m_profile->writeEntry("Font", Profile::Micro); | 278 | m_profile->writeEntry("Font", Profile::Micro); |
286 | break; | 279 | break; |
287 | case id_size_medium: | 280 | case id_size_medium: |
288 | m_profile->writeEntry("Font", Profile::Small); | 281 | m_profile->writeEntry("Font", Profile::Small); |
289 | break; | 282 | break; |
290 | case id_size_large: | 283 | case id_size_large: |
291 | m_profile->writeEntry("Font", Profile::Medium); | 284 | m_profile->writeEntry("Font", Profile::Medium); |
292 | break; | 285 | break; |
293 | } | 286 | } |
294 | } | 287 | } |
295 | 288 | ||
296 | void ProfileEditorPlugin::slotTermEcho(bool on) | 289 | void ProfileEditorPlugin::slotTermEcho(bool on) |
297 | { | 290 | { |
298 | m_profile->writeEntry("Echo", on ? 1 : 0); | 291 | m_profile->writeEntry("Echo", on ? 1 : 0); |
299 | } | 292 | } |
300 | 293 | ||
301 | void ProfileEditorPlugin::slotTermWrap(bool on) | 294 | void ProfileEditorPlugin::slotTermWrap(bool on) |
302 | { | 295 | { |
303 | m_profile->writeEntry("Wrap", on ? 1 : 0); | 296 | m_profile->writeEntry("Wrap", on ? 1 : 0); |
304 | } | 297 | } |
305 | 298 | ||
306 | void ProfileEditorPlugin::slotTermInbound(bool on) | 299 | void ProfileEditorPlugin::slotTermInbound(bool on) |
307 | { | 300 | { |
308 | m_profile->writeEntry("Inbound", on ? 1 : 0); | 301 | m_profile->writeEntry("Inbound", on ? 1 : 0); |
309 | } | 302 | } |
310 | 303 | ||
311 | void ProfileEditorPlugin::slotTermOutbound(bool on) | 304 | void ProfileEditorPlugin::slotTermOutbound(bool on) |
312 | { | 305 | { |
313 | m_profile->writeEntry("Outbound", on ? 1 : 0); | 306 | m_profile->writeEntry("Outbound", on ? 1 : 0); |
314 | } | 307 | } |
315 | 308 | ||
316 | // Inherited classes | 309 | // Inherited classes |
317 | 310 | ||
318 | class ProfileEditorPluginSerial : public ProfileEditorPlugin | 311 | class ProfileEditorPluginSerial : public ProfileEditorPlugin |
319 | { | 312 | { |
320 | public: | 313 | public: |
321 | 314 | ||
322 | ProfileEditorPluginSerial(QWidget *parent, Profile *p) | 315 | ProfileEditorPluginSerial(QWidget *parent, Profile *p) |
323 | : ProfileEditorPlugin(parent, p) | 316 | : ProfileEditorPlugin(parent, p) |
324 | { | 317 | { |
325 | } | 318 | } |
326 | 319 | ||
327 | ~ProfileEditorPluginSerial() | 320 | ~ProfileEditorPluginSerial() |
328 | { | 321 | { |
329 | } | 322 | } |
330 | 323 | ||
331 | QWidget *widget() | 324 | QWidget *widget() |
332 | { | 325 | { |
333 | if(!m_widget) | 326 | if(!m_widget) |
334 | { | 327 | { |
335 | QFrame *device_frame = new QFrame(m_parent); | ||
336 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
337 | 328 | ||
338 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 329 | QWidget *device_frame = new QWidget( m_parent ); |
330 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
339 | 331 | ||
340 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | 332 | device_line = new QLineEdit("/dev/ttyS0", device_frame); |
341 | 333 | ||
342 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 334 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); |
343 | vbox_frame->add(frame_device); | 335 | vbox_frame->add(frame_device); |
344 | vbox_frame->add(device_line); | 336 | vbox_frame->add(device_line); |
345 | 337 | ||
346 | m_widget = device_frame; | 338 | m_widget = device_frame; |
347 | 339 | ||
348 | // Load special settings | 340 | // Load special settings |
349 | 341 | ||
350 | QString dev = m_profile->readEntry("Device"); | 342 | QString dev = m_profile->readEntry("Device"); |
351 | if(!dev.isNull()) device_line->setText(dev); | 343 | if(!dev.isNull()) device_line->setText(dev); |
352 | } | 344 | } |
353 | 345 | ||
354 | return m_widget; | 346 | return m_widget; |
355 | } | 347 | } |
356 | 348 | ||
357 | void save() | 349 | void save() |
358 | { | 350 | { |
359 | // special settings | 351 | // special settings |
360 | m_profile->writeEntry("Device", device_line->text()); | 352 | m_profile->writeEntry("Device", device_line->text()); |
361 | } | 353 | } |
362 | 354 | ||
363 | private: | 355 | private: |
364 | QLineEdit *device_line; | 356 | QLineEdit *device_line; |
365 | }; | 357 | }; |
366 | 358 | ||
367 | class ProfileEditorPluginIrda : public ProfileEditorPlugin | 359 | class ProfileEditorPluginIrda : public ProfileEditorPlugin |
368 | { | 360 | { |
369 | public: | 361 | public: |
370 | 362 | ||
371 | ProfileEditorPluginIrda(QWidget *parent, Profile *p) | 363 | ProfileEditorPluginIrda(QWidget *parent, Profile *p) |
372 | : ProfileEditorPlugin(parent, p) | 364 | : ProfileEditorPlugin(parent, p) |
373 | { | 365 | { |
374 | } | 366 | } |
375 | 367 | ||
376 | ~ProfileEditorPluginIrda() | 368 | ~ProfileEditorPluginIrda() |
377 | { | 369 | { |
378 | } | 370 | } |
379 | 371 | ||
380 | QWidget *widget() | 372 | QWidget *widget() |
381 | { | 373 | { |
382 | if(!m_widget) | 374 | if(!m_widget) |
383 | { | 375 | { |
384 | QFrame *device_frame = new QFrame(m_parent); | 376 | QWidget *device_frame = new QWidget(m_parent); |
385 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 377 | |
386 | 378 | ||
387 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 379 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); |
388 | 380 | ||
389 | device_line = new QLineEdit("/dev/ircomm0", device_frame); | 381 | device_line = new QLineEdit("/dev/ircomm0", device_frame); |
390 | 382 | ||
391 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 383 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); |
392 | vbox_frame->add(frame_device); | 384 | vbox_frame->add(frame_device); |
393 | vbox_frame->add(device_line); | 385 | vbox_frame->add(device_line); |
394 | 386 | ||
395 | m_widget = device_frame; | 387 | m_widget = device_frame; |
396 | 388 | ||
397 | // Load special settings | 389 | // Load special settings |
398 | QString dev = m_profile->readEntry("Device"); | 390 | QString dev = m_profile->readEntry("Device"); |
399 | if(!dev.isNull()) device_line->setText(dev); | 391 | if(!dev.isNull()) device_line->setText(dev); |
400 | } | 392 | } |
401 | 393 | ||
402 | return m_widget; | 394 | return m_widget; |
403 | } | 395 | } |
404 | 396 | ||
405 | void save() | 397 | void save() |
406 | { | 398 | { |
407 | // special settings | 399 | // special settings |
408 | m_profile->writeEntry("Device", device_line->text()); | 400 | m_profile->writeEntry("Device", device_line->text()); |
409 | } | 401 | } |
410 | 402 | ||
411 | private: | 403 | private: |
412 | QLineEdit *device_line; | 404 | QLineEdit *device_line; |
413 | }; | 405 | }; |
414 | 406 | ||
415 | class ProfileEditorPluginModem : public ProfileEditorPlugin | 407 | class ProfileEditorPluginModem : public ProfileEditorPlugin |
416 | { | 408 | { |
417 | public: | 409 | public: |
418 | 410 | ||
419 | ProfileEditorPluginModem(QWidget *parent, Profile *p) | 411 | ProfileEditorPluginModem(QWidget *parent, Profile *p) |
420 | : ProfileEditorPlugin(parent, p) | 412 | : ProfileEditorPlugin(parent, p) |
421 | { | 413 | { |
422 | } | 414 | } |
423 | 415 | ||
424 | ~ProfileEditorPluginModem() | 416 | ~ProfileEditorPluginModem() |
425 | { | 417 | { |
426 | } | 418 | } |
427 | 419 | ||
428 | QWidget *widget() | 420 | QWidget *widget() |
429 | { | 421 | { |
430 | if(!m_widget) | 422 | if(!m_widget) |
431 | { | 423 | { |
432 | QFrame *device_frame = new QFrame(m_parent); | 424 | QWidget *device_frame = new QWidget(m_parent); |
433 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
434 | 425 | ||
435 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 426 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); |
436 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); | 427 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); |
437 | 428 | ||
438 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | 429 | device_line = new QLineEdit("/dev/ttyS0", device_frame); |
439 | number_line = new QLineEdit(device_frame); | 430 | number_line = new QLineEdit(device_frame); |
440 | 431 | ||
441 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 432 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); |
442 | vbox_frame->add(frame_device); | 433 | vbox_frame->add(frame_device); |
443 | vbox_frame->add(device_line); | 434 | vbox_frame->add(device_line); |
444 | vbox_frame->add(frame_number); | 435 | vbox_frame->add(frame_number); |
445 | vbox_frame->add(number_line); | 436 | vbox_frame->add(number_line); |
446 | 437 | ||
447 | m_widget = device_frame; | 438 | m_widget = device_frame; |
448 | 439 | ||
449 | // Load special settings | 440 | // Load special settings |
450 | QString dev = m_profile->readEntry("Device"); | 441 | QString dev = m_profile->readEntry("Device"); |
451 | QString num = m_profile->readEntry("Number"); | 442 | QString num = m_profile->readEntry("Number"); |
452 | if(!dev.isNull()) device_line->setText(dev); | 443 | if(!dev.isNull()) device_line->setText(dev); |
453 | number_line->setText(num); | 444 | number_line->setText(num); |
454 | } | 445 | } |
455 | 446 | ||
456 | return m_widget; | 447 | return m_widget; |
457 | } | 448 | } |
458 | 449 | ||
459 | void save() | 450 | void save() |
460 | { | 451 | { |
461 | // special settings | 452 | // special settings |
462 | m_profile->writeEntry("Device", device_line->text()); | 453 | m_profile->writeEntry("Device", device_line->text()); |
463 | m_profile->writeEntry("Number", number_line->text()); | 454 | m_profile->writeEntry("Number", number_line->text()); |
464 | } | 455 | } |
465 | 456 | ||
466 | private: | 457 | private: |
467 | QLineEdit *device_line, *number_line; | 458 | QLineEdit *device_line, *number_line; |
468 | }; | 459 | }; |
469 | 460 | ||
470 | ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p) | 461 | ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p) |
471 | { | 462 | { |
472 | return new ProfileEditorPluginSerial(parent, p); | 463 | return new ProfileEditorPluginSerial(parent, p); |
473 | } | 464 | } |
474 | 465 | ||
475 | ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p) | 466 | ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p) |
476 | { | 467 | { |
477 | return new ProfileEditorPluginIrda(parent, p); | 468 | return new ProfileEditorPluginIrda(parent, p); |
478 | } | 469 | } |
479 | 470 | ||
480 | ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p) | 471 | ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p) |
481 | { | 472 | { |
482 | return new ProfileEditorPluginModem(parent, p); | 473 | return new ProfileEditorPluginModem(parent, p); |
483 | } | 474 | } |
484 | 475 | ||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 99d248e..adf2038 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -1,217 +1,217 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [widget_layer.h] Widget Layer */ | 3 | /* [widget_layer.h] Widget Layer */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | 6 | ||
7 | // proposal of a widget Layer in opie-console | 7 | // proposal of a widget Layer in opie-console |
8 | // | 8 | // |
9 | // fellow devels: | 9 | // fellow devels: |
10 | // just mail me (ibotty@web.de), what you additionally need from the main widget | 10 | // just mail me (ibotty@web.de), what you additionally need from the main widget |
11 | // (or say in chat) | 11 | // (or say in chat) |
12 | 12 | ||
13 | #ifndef WIDGET_LAYER_H | 13 | #ifndef WIDGET_LAYER_H |
14 | #define WIDGET_LAYER_H | 14 | #define WIDGET_LAYER_H |
15 | 15 | ||
16 | // qt includes | 16 | // qt includes |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #include <qframe.h> | 18 | #include <qframe.h> |
19 | #include <qarray.h> | 19 | #include <qarray.h> |
20 | #include <qtimer.h> | 20 | #include <qtimer.h> |
21 | #include <qkeycode.h> | 21 | #include <qkeycode.h> |
22 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
23 | 23 | ||
24 | 24 | ||
25 | // opie-console includes | 25 | // opie-console includes |
26 | #include "session.h" | 26 | #include "session.h" |
27 | #include "common.h" | 27 | #include "common.h" |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * given a pseudo location ( column, line ), | 30 | * given a pseudo location ( column, line ), |
31 | * returns the actual index, in the QArray<Character> | 31 | * returns the actual index, in the QArray<Character> |
32 | */ | 32 | */ |
33 | #define loc(X,Y) ((Y)*m_columns+(X)) | 33 | #define loc(X,Y) ((Y)*m_columns+(X)) |
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | 37 | ||
38 | class WidgetLayer : public QFrame | 38 | class WidgetLayer : public QFrame |
39 | { Q_OBJECT | 39 | { Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * constructor | 44 | * constructor |
45 | */ | 45 | */ |
46 | WidgetLayer( QWidget *parent=0, const char *name=0 ); | 46 | WidgetLayer( QWidget *parent=0, const char *name=0 ); |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * destructor | 49 | * destructor |
50 | */ | 50 | */ |
51 | virtual ~WidgetLayer(); | 51 | virtual ~WidgetLayer(); |
52 | 52 | ||
53 | public: | 53 | public: |
54 | /** | 54 | /** |
55 | * sets the image | 55 | * sets the image |
56 | */ | 56 | */ |
57 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ); | 57 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * annoy the user | 60 | * annoy the user |
61 | */ | 61 | */ |
62 | void bell(); | 62 | void bell(); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * return the lines count | 65 | * return the lines count |
66 | */ | 66 | */ |
67 | int lines(){ return m_lines; } | 67 | int lines(){ return m_lines; } |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * return the columns count | 70 | * return the columns count |
71 | */ | 71 | */ |
72 | int columns(){ return m_columns; } | 72 | int columns(){ return m_columns; } |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * insert current selection (currently this is only the clipboard) | 75 | * insert current selection (currently this is only the clipboard) |
76 | */ | 76 | */ |
77 | void insertSelection(); | 77 | void insertSelection(); |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * insert text | 80 | * insert text |
81 | */ | 81 | */ |
82 | void insertText( QString text ); | 82 | void insertText( QString text ); |
83 | /** | 83 | /** |
84 | * set selection (clipboard) to text | 84 | * set selection (clipboard) to text |
85 | */ | 85 | */ |
86 | void setSelection( const QString &text ); | 86 | void setSelection( const QString &text ); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * paste content of clipboard | 89 | * paste content of clipboard |
90 | */ | 90 | */ |
91 | void pasteClipboard(); | 91 | void pasteClipboard(); |
92 | 92 | ||
93 | 93 | ||
94 | signals: | 94 | signals: |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * key was pressed | 97 | * key was pressed |
98 | */ | 98 | */ |
99 | void keyPressed( QKeyEvent *e ); | 99 | void keyPressed( QKeyEvent *e ); |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * whenever Mouse selects something | 102 | * whenever Mouse selects something |
103 | * 0left Button | 103 | * 0left Button |
104 | * 3Button released | 104 | * 3Button released |
105 | * // numbering due to layout in old TEWidget | 105 | * // numbering due to layout in old TEWidget |
106 | */ | 106 | */ |
107 | void mousePressed( int button, int x, int y ); | 107 | void mousePressed( int button, int x, int y ); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * size of image changed | 110 | * size of image changed |
111 | */ | 111 | */ |
112 | void imageSizeChanged( int lines, int columns ); | 112 | void imageSizeChanged( int lines, int columns ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * cursor in history changed | 115 | * cursor in history changed |
116 | */ | 116 | */ |
117 | void historyCursorChanged( int value ); | 117 | void historyCursorChanged( int value ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * selection should be cleared | 120 | * selection should be cleared |
121 | */ | 121 | */ |
122 | void selectionCleared(); | 122 | void selectionCleared(); |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * selection begin | 125 | * selection begin |
126 | */ | 126 | */ |
127 | void selectionBegin( const int x, const int y ); | 127 | void selectionBegin( const int x, const int y ); |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * selection extended | 130 | * selection extended |
131 | * (from begin (s.a.) to x, y) | 131 | * (from begin (s.a.) to x, y) |
132 | */ | 132 | */ |
133 | void selectionExtended( const int x, const int y ); | 133 | void selectionExtended( const int x, const int y ); |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * selection end | 136 | * selection end |
137 | * bool: preserve line breaks in selection | 137 | * bool: preserve line breaks in selection |
138 | */ | 138 | */ |
139 | void selectionEnd( const bool lineBreakPreserve ); | 139 | void selectionEnd( const bool lineBreakPreserve ); |
140 | 140 | ||
141 | 141 | ||
142 | 142 | ||
143 | // protected methods | 143 | // protected methods |
144 | protected: | 144 | protected: |
145 | 145 | ||
146 | // image operations | 146 | // image operations |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * changes image, to suit new size | 149 | * changes image, to suit new size |
150 | * TODO: find meaningful name! | 150 | * TODO: find meaningful name! |
151 | */ | 151 | */ |
152 | void propagateSize(); | 152 | void propagateSize(); |
153 | 153 | ||
154 | /** | 154 | /** |
155 | *determines count of lines and columns | 155 | *determines count of lines and columns |
156 | */ | 156 | */ |
157 | virtual void calcGeometry() = 0; | 157 | virtual void calcGeometry() = 0; |
158 | 158 | ||
159 | /** | 159 | /** |
160 | * makes an empty image | 160 | * makes an empty image |
161 | */ | 161 | */ |
162 | void makeImage(); | 162 | void makeImage(); |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * clears the image | 165 | * clears the image |
166 | */ | 166 | */ |
167 | void clearImage(); | 167 | void clearImage(); |
168 | 168 | ||
169 | protected slots: | 169 | protected slots: |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * clear selection | 172 | * clear selection |
173 | */ | 173 | */ |
174 | void onClearSelection(); | 174 | void onClearSelection(); |
175 | 175 | ||
176 | 176 | ||
177 | // protected vars | 177 | // protected vars |
178 | protected: | 178 | protected: |
179 | 179 | ||
180 | /** | 180 | /** |
181 | * current Session | 181 | * current Session |
182 | */ | 182 | */ |
183 | Session *m_session; | 183 | Session *m_session; |
184 | 184 | ||
185 | /** | 185 | /** |
186 | * current character image | 186 | * current character image |
187 | * | 187 | * |
188 | * a Character at loc( column, line ) | 188 | * a Character at loc( column, line ) |
189 | * has the actual index: | 189 | * has the actual index: |
190 | * ix = line * m_columns + column; | 190 | * ix = line * m_columns + column; |
191 | * | 191 | * |
192 | * use loc( x, y ) macro to access. | 192 | * use loc( x, y ) macro to access. |
193 | */ | 193 | */ |
194 | QArray<Character> m_image; | 194 | QArray<Character> m_image; |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * lines count | 197 | * lines count |
198 | */ | 198 | */ |
199 | int m_lines; | 199 | int m_lines; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * columns count | 202 | * columns count |
203 | */ | 203 | */ |
204 | int m_columns; | 204 | int m_columns; |
205 | 205 | ||
206 | /** | 206 | /** |
207 | * clipboard | 207 | * clipboard |
208 | */ | 208 | */ |
209 | QClipboard* m_clipboard; | 209 | QClipboard* m_clipboard; |
210 | 210 | ||
211 | /** | 211 | /** |
212 | * whether widget is resizing | 212 | * whether widget is resizing |
213 | */ | 213 | */ |
214 | bool m_resizing; | 214 | bool m_resizing; |
215 | }; | 215 | }; |
216 | 216 | ||
217 | #endif // WIDGET_LAYER_H | 217 | #endif // WIDGET_LAYER_H |