summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/metafactory.cpp2
-rw-r--r--noncore/apps/opie-console/metafactory.h4
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp14
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.cpp102
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.h10
5 files changed, 73 insertions, 59 deletions
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index c5e614d..b69d6da 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -51,25 +51,25 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
QMap<QString, iolayer>::Iterator it;
it = m_layerFact.find( str );
if ( it != m_layerFact.end() ) {
lay = (*(it.data()))(prof);
/*
iolayer laye = it.data();
lay = (*laye )(conf);*/
}
return lay;
}
-ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, const Profile& prof) {
+ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, Profile *prof) {
ProfileEditorPlugin *p = NULL;
configWidget c;
c = m_confFact[str];
if(c) p = c(parent, prof);
return p;
}
QString MetaFactory::name( const QString& str ) {
return m_namemap[str];
}
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 8c714b3..216de03 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -9,43 +9,43 @@
#include <qwidget.h>
#include <qmap.h>
#include <qpe/config.h>
#include "io_layer.h"
#include "file_layer.h"
#include "profile.h"
#include "profileeditorplugins.h"
class MetaFactory {
public:
- typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, const Profile&);
+ typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, Profile* prof);
typedef IOLayer* (*iolayer)(const Profile& );
typedef FileTransferLayer* (*filelayer)(IOLayer*);
MetaFactory();
~MetaFactory();
void addConfigWidgetFactory( const QString&,
const QString&,
configWidget );
void addIOLayerFactory(const QString&,
iolayer );
void addFileTransferLayer( const QString&,
filelayer );
QStringList ioLayers()const;
QStringList configWidgets()const;
QStringList fileTransferLayers()const;
IOLayer* newIOLayer( const QString&,const Profile& );
- ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, const Profile& );
+ ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, Profile* );
QString name( const QString& );
private:
QMap<QString, configWidget> m_confFact;
QMap<QString, iolayer> m_layerFact;
QMap<QString, filelayer> m_fileFact;
QMap<QString, QString> m_namemap;
};
#endif
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index d98e589..8e63429 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -64,25 +64,25 @@ void ProfileEditorDialog::initUI()
QLabel *device = new QLabel(QObject::tr("Device"), tabconn);
device_box = new QComboBox(tabconn);
QStringList w = m_fact->configWidgets();
for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
device_box->insertItem(m_fact->name((*it)));
// connection tab, factory part
plugin_base = new QWidget(tabconn);
plugin_layout = new QHBoxLayout(plugin_base, 0);
- plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, m_prof);
+ plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof);
plugin_layout->add(plugin_plugin->widget());
// connection tab, general part
QWidget *conn_widget = plugin_plugin->connection_widget();
conn_widget->reparent(tabconn, 0, QPoint(), true);
// terminal tab
QWidget *term_widget = plugin_plugin->terminal_widget();
term_widget->reparent(tabterm, 0, QPoint(), true);
@@ -103,64 +103,74 @@ void ProfileEditorDialog::initUI()
vbox2->add(term_widget);
addTab(tabprof, QObject::tr("Profile"));
addTab(tabconn, QObject::tr("Connection"));
addTab(tabterm, QObject::tr("Terminal"));
setOkButton(QObject::tr("OK"));
setCancelButton(QObject::tr("Cancel"));
// load profile values
name_line->setText(m_prof.name());
+ for(int i = 0; i < device_box->count(); i++)
+ {
+ device_box->setCurrentItem(i);
+ if(prof_type() == m_prof.ioLayerName())
+ {
+ slotDevice(i);
+ break;
+ }
+ }
// signals
connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
}
ProfileEditorDialog::~ProfileEditorDialog() {
}
void ProfileEditorDialog::slotDevice(int id)
{
delete plugin_plugin;
- plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof);
+ plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof);
plugin_layout->add(plugin_plugin->widget());
// Reload profile associated to device, including e.g. conn_device()
// m_prof = plugin_plugin->profile()
// or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
//plugin_plugin->show();
plugin_plugin->widget()->show();
}
void ProfileEditorDialog::accept()
{
if(prof_name().isEmpty())
{
QMessageBox::information(this,
QObject::tr("Invalid profile"),
QObject::tr("Please enter a profile name."));
return;
}
// Save profile and plugin profile
if(plugin_plugin) plugin_plugin->save();
// Save general values
m_prof.setName(prof_name());
+ m_prof.setIOLayer(prof_type());
QDialog::accept();
}
void ProfileEditorDialog::slotCancel()
{
reject();
}
QString ProfileEditorDialog::prof_name()
{
return name_line->text();
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp
index 32e8235..a0bcab8 100644
--- a/noncore/apps/opie-console/profileeditorplugins.cpp
+++ b/noncore/apps/opie-console/profileeditorplugins.cpp
@@ -6,25 +6,25 @@
#include "qlabel.h"
#include "qlineedit.h"
#include "qlayout.h"
#include "qcombobox.h"
#include "qradiobutton.h"
#include "qcheckbox.h"
#include "qbuttongroup.h"
#include "io_serial.h"
// Base class
-ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p)
+ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile *p)
{
m_parent = parent;
m_profile = p;
m_widget = NULL;
}
ProfileEditorPlugin::~ProfileEditorPlugin()
{
if(m_widget) delete m_widget;
}
QWidget *ProfileEditorPlugin::connection_widget()
@@ -67,27 +67,28 @@ QWidget *ProfileEditorPlugin::connection_widget()
lroot->add(speedlabel);
lroot->add(speed_box);
lroot->add(flow);
QHBoxLayout *hbox = new QHBoxLayout(lroot, 2);
hbox->add(flow_hw);
hbox->add(flow_sw);
lroot->add(parity);
QHBoxLayout *hbox2 = new QHBoxLayout(lroot, 2);
hbox2->add(parity_odd);
hbox2->add(parity_even);
// Apply profile settings
- int rad_flow = m_profile.readNumEntry("Flow");
- int rad_parity = m_profile.readNumEntry("Parity");
- int speed = m_profile.readNumEntry("Speed");
+
+ int rad_flow = m_profile->readNumEntry("Flow");
+ int rad_parity = m_profile->readNumEntry("Parity");
+ int speed = m_profile->readNumEntry("Speed");
if(rad_flow == IOSerial::FlowHW) flow_hw->setChecked(true);
else flow_sw->setChecked(true);
if(rad_parity == IOSerial::ParityEven) parity_even->setChecked(true);
else parity_odd->setChecked(true);
if(speed == 115200) speed_box->setCurrentItem(id_baud_115200);
if(speed == 57600) speed_box->setCurrentItem(id_baud_57600);
if(speed == 38400) speed_box->setCurrentItem(id_baud_38400);
if(speed == 19200) speed_box->setCurrentItem(id_baud_19200);
if(speed == 9600) speed_box->setCurrentItem(id_baud_9600);
// Signals
@@ -151,31 +152,32 @@ QWidget *ProfileEditorPlugin::terminal_widget()
lroot->add(colourlabel);
lroot->add(colour_box);
lroot->add(conversions);
QHBoxLayout *hbox2 = new QHBoxLayout(lroot, 2);
hbox2->add(conv_inbound);
hbox2->add(conv_outbound);
lroot->add(options);
QHBoxLayout *hbox3 = new QHBoxLayout(lroot, 2);
hbox3->add(option_wrap);
hbox3->add(option_echo);
// Apply profile settings
- int term = m_profile.readNumEntry("Terminal");
- int colour = m_profile.readNumEntry("Colour");
- int fontsize = m_profile.readNumEntry("Font");
- int opt_echo = m_profile.readNumEntry("Echo");
- int opt_wrap = m_profile.readNumEntry("Wrap");
- int opt_inbound = m_profile.readNumEntry("Inbound");
- int opt_outbound = m_profile.readNumEntry("Outbound");
+
+ int term = m_profile->readNumEntry("Terminal");
+ int colour = m_profile->readNumEntry("Colour");
+ int fontsize = m_profile->readNumEntry("Font");
+ int opt_echo = m_profile->readNumEntry("Echo");
+ int opt_wrap = m_profile->readNumEntry("Wrap");
+ int opt_inbound = m_profile->readNumEntry("Inbound");
+ int opt_outbound = m_profile->readNumEntry("Outbound");
if(term == Profile::VT102) terminal_box->setCurrentItem(id_term_vt100);
if(colour == Profile::Black) colour_box->setCurrentItem(id_term_black);
if(colour == Profile::White) colour_box->setCurrentItem(id_term_white);
if(fontsize == Profile::Micro) size_small->setChecked(true);
if(fontsize == Profile::Small) size_medium->setChecked(true);
if(fontsize == Profile::Medium) size_large->setChecked(true);
if(opt_echo) option_echo->setChecked(true);
if(opt_wrap) option_wrap->setChecked(true);
@@ -192,140 +194,140 @@ QWidget *ProfileEditorPlugin::terminal_widget()
connect(option_wrap, SIGNAL(toggled(bool)), SLOT(slotTermWrap(bool)));
connect(conv_inbound, SIGNAL(toggled(bool)), SLOT(slotTermInbound(bool)));
connect(conv_outbound, SIGNAL(toggled(bool)), SLOT(slotTermOutbound(bool)));
return root;
}
void ProfileEditorPlugin::slotConnFlow(int id)
{
switch(id)
{
case id_flow_hw:
- m_profile.writeEntry("Flow", IOSerial::FlowHW);
+ m_profile->writeEntry("Flow", IOSerial::FlowHW);
break;
case id_flow_sw:
- m_profile.writeEntry("Flow", IOSerial::FlowSW);
+ m_profile->writeEntry("Flow", IOSerial::FlowSW);
break;
}
}
void ProfileEditorPlugin::slotConnParity(int id)
{
switch(id)
{
case id_parity_odd:
- m_profile.writeEntry("Parity", IOSerial::ParityEven);
+ m_profile->writeEntry("Parity", IOSerial::ParityEven);
break;
case id_parity_even:
- m_profile.writeEntry("Parity", IOSerial::ParityOdd);
+ m_profile->writeEntry("Parity", IOSerial::ParityOdd);
break;
}
}
void ProfileEditorPlugin::slotConnSpeed(int id)
{
switch(id)
{
case id_baud_115200:
- m_profile.writeEntry("Speed", 115200);
+ m_profile->writeEntry("Speed", 115200);
break;
case id_baud_57600:
- m_profile.writeEntry("Speed", 57600);
+ m_profile->writeEntry("Speed", 57600);
break;
case id_baud_38400:
- m_profile.writeEntry("Speed", 38400);
+ m_profile->writeEntry("Speed", 38400);
break;
case id_baud_19200:
- m_profile.writeEntry("Speed", 19200);
+ m_profile->writeEntry("Speed", 19200);
break;
case id_baud_9600:
- m_profile.writeEntry("Speed", 9600);
+ m_profile->writeEntry("Speed", 9600);
break;
}
}
void ProfileEditorPlugin::slotTermTerm(int id)
{
switch(id)
{
case id_term_vt100:
- m_profile.writeEntry("Terminal", Profile::VT102);
+ m_profile->writeEntry("Terminal", Profile::VT102);
break;
case id_term_vt220:
- m_profile.writeEntry("Terminal", Profile::VT102);
+ m_profile->writeEntry("Terminal", Profile::VT102);
break;
case id_term_ansi:
- m_profile.writeEntry("Terminal", Profile::VT102);
+ m_profile->writeEntry("Terminal", Profile::VT102);
break;
}
}
void ProfileEditorPlugin::slotTermColour(int id)
{
switch(id)
{
case id_term_black:
- m_profile.writeEntry("Colour", Profile::Black);
+ m_profile->writeEntry("Colour", Profile::Black);
break;
case id_term_white:
- m_profile.writeEntry("Colour", Profile::White);
+ m_profile->writeEntry("Colour", Profile::White);
break;
}
}
void ProfileEditorPlugin::slotTermFont(int id)
{
switch(id)
{
case id_size_small:
- m_profile.writeEntry("Font", Profile::Micro);
+ m_profile->writeEntry("Font", Profile::Micro);
break;
case id_size_medium:
- m_profile.writeEntry("Font", Profile::Small);
+ m_profile->writeEntry("Font", Profile::Small);
break;
case id_size_large:
- m_profile.writeEntry("Font", Profile::Medium);
+ m_profile->writeEntry("Font", Profile::Medium);
break;
}
}
void ProfileEditorPlugin::slotTermEcho(bool on)
{
- m_profile.writeEntry("Echo", on ? 1 : 0);
+ m_profile->writeEntry("Echo", on ? 1 : 0);
}
void ProfileEditorPlugin::slotTermWrap(bool on)
{
- m_profile.writeEntry("Wrap", on ? 1 : 0);
+ m_profile->writeEntry("Wrap", on ? 1 : 0);
}
void ProfileEditorPlugin::slotTermInbound(bool on)
{
- m_profile.writeEntry("Inbound", on ? 1 : 0);
+ m_profile->writeEntry("Inbound", on ? 1 : 0);
}
void ProfileEditorPlugin::slotTermOutbound(bool on)
{
- m_profile.writeEntry("Outbound", on ? 1 : 0);
+ m_profile->writeEntry("Outbound", on ? 1 : 0);
}
// Inherited classes
class ProfileEditorPluginSerial : public ProfileEditorPlugin
{
public:
- ProfileEditorPluginSerial(QWidget *parent, Profile p)
+ ProfileEditorPluginSerial(QWidget *parent, Profile *p)
: ProfileEditorPlugin(parent, p)
{
}
~ProfileEditorPluginSerial()
{
}
QWidget *widget()
{
if(!m_widget)
{
@@ -334,46 +336,47 @@ class ProfileEditorPluginSerial : public ProfileEditorPlugin
QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
device_line = new QLineEdit("/dev/ttyS0", device_frame);
QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
vbox_frame->add(frame_device);
vbox_frame->add(device_line);
m_widget = device_frame;
// Load special settings
- device_line->setText(m_profile.readEntry("Device"));
+
+ QString dev = m_profile->readEntry("Device");
+ if(!dev.isNull()) device_line->setText(dev);
}
return m_widget;
}
void save()
{
// special settings
- Profile p = m_profile;
- p.writeEntry("Device", device_line->text());
+ m_profile->writeEntry("Device", device_line->text());
}
private:
QLineEdit *device_line;
};
class ProfileEditorPluginIrda : public ProfileEditorPlugin
{
public:
- ProfileEditorPluginIrda(QWidget *parent, Profile p)
+ ProfileEditorPluginIrda(QWidget *parent, Profile *p)
: ProfileEditorPlugin(parent, p)
{
}
~ProfileEditorPluginIrda()
{
}
QWidget *widget()
{
if(!m_widget)
{
@@ -382,46 +385,46 @@ class ProfileEditorPluginIrda : public ProfileEditorPlugin
QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
device_line = new QLineEdit("/dev/ircomm0", device_frame);
QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
vbox_frame->add(frame_device);
vbox_frame->add(device_line);
m_widget = device_frame;
// Load special settings
- device_line->setText(m_profile.readEntry("Device"));
+ QString dev = m_profile->readEntry("Device");
+ if(!dev.isNull()) device_line->setText(dev);
}
return m_widget;
}
void save()
{
// special settings
- Profile p = m_profile;
- p.writeEntry("Device", device_line->text());
+ m_profile->writeEntry("Device", device_line->text());
}
private:
QLineEdit *device_line;
};
class ProfileEditorPluginModem : public ProfileEditorPlugin
{
public:
- ProfileEditorPluginModem(QWidget *parent, Profile p)
+ ProfileEditorPluginModem(QWidget *parent, Profile *p)
: ProfileEditorPlugin(parent, p)
{
}
~ProfileEditorPluginModem()
{
}
QWidget *widget()
{
if(!m_widget)
{
@@ -434,46 +437,47 @@ class ProfileEditorPluginModem : public ProfileEditorPlugin
device_line = new QLineEdit("/dev/ttyS0", device_frame);
number_line = new QLineEdit(device_frame);
QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
vbox_frame->add(frame_device);
vbox_frame->add(device_line);
vbox_frame->add(frame_number);
vbox_frame->add(number_line);
m_widget = device_frame;
// Load special settings
- device_line->setText(m_profile.readEntry("Device"));
- number_line->setText(m_profile.readEntry("Number"));
+ QString dev = m_profile->readEntry("Device");
+ QString num = m_profile->readEntry("Number");
+ if(!dev.isNull()) device_line->setText(dev);
+ number_line->setText(num);
}
return m_widget;
}
void save()
{
// special settings
- Profile p = m_profile;
- p.writeEntry("Device", device_line->text());
- p.writeEntry("Number", number_line->text());
+ m_profile->writeEntry("Device", device_line->text());
+ m_profile->writeEntry("Number", number_line->text());
}
private:
QLineEdit *device_line, *number_line;
};
-ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p)
+ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p)
{
return new ProfileEditorPluginSerial(parent, p);
}
-ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p)
+ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p)
{
return new ProfileEditorPluginIrda(parent, p);
}
-ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p)
+ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p)
{
return new ProfileEditorPluginModem(parent, p);
}
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h
index caec7ba..591163a 100644
--- a/noncore/apps/opie-console/profileeditorplugins.h
+++ b/noncore/apps/opie-console/profileeditorplugins.h
@@ -2,50 +2,50 @@
#define PROFILE_EDITOR_PLUGINS_H
#include "profile.h"
#include "qobject.h"
class QWidget;
class ProfileEditorPlugin : public QObject
{
Q_OBJECT
public:
- ProfileEditorPlugin(QWidget *parent, Profile p);
+ ProfileEditorPlugin(QWidget *parent, Profile *p);
virtual ~ProfileEditorPlugin();
virtual void save() = 0;
virtual QWidget *widget() = 0;
QWidget *connection_widget();
QWidget *terminal_widget();
public slots:
void slotConnFlow(int id);
void slotConnParity(int id);
void slotConnSpeed(int id);
void slotTermTerm(int id);
void slotTermColour(int id);
void slotTermFont(int id);
void slotTermEcho(bool on);
void slotTermWrap(bool on);
void slotTermInbound(bool on);
void slotTermOutbound(bool on);
protected:
QWidget *m_parent, *m_widget;
- Profile m_profile;
+ Profile *m_profile;
private:
enum ParityIds
{
id_parity_odd,
id_parity_even
};
enum FlowIds
{
id_flow_hw,
id_flow_sw
@@ -76,22 +76,22 @@ class ProfileEditorPlugin : public QObject
enum FontIds
{
id_size_small,
id_size_medium,
id_size_large
};
};
//#ifdef __cplusplus
//extern "C" {
//#endif
-ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p);
-ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p);
-ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p);
+ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p);
+ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p);
+ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p);
//#ifdef __cplusplus
//}
//#endif
#endif