-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index b709cf3..5c5c2b3 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -1,193 +1,193 @@ #include <qlayout.h> #include <qlineedit.h> #include <qlabel.h> #include <qmessagebox.h> #include <qstringlist.h> #include <qcombobox.h> -#include <opie/otabwidget.h> - #include "profileeditorplugins.h" #include "metafactory.h" #include "profileeditordialog.h" namespace { void setCurrent( const QString& str, QComboBox* bo ) { for (uint i = 0; i < bo->count(); i++ ) { if ( bo->text(i) == str ) { bo->setCurrentItem( i ); } } } } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, const Profile& prof ) : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) { initUI(); // Apply current profile // plugin_plugin->load(profile); // ... (reset profile name line edit etc.) } ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) : QDialog(0, 0, TRUE), m_fact( fact ) { // Default profile m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); initUI(); // Apply current profile // plugin_plugin->load(profile); } Profile ProfileEditorDialog::profile() const { return m_prof; } void ProfileEditorDialog::initUI() { m_con = m_term = 0l; QVBoxLayout *mainLayout = new QVBoxLayout( this ); - OTabWidget *tabWidget = new OTabWidget( this ); + tabWidget = new OTabWidget( this ); tabWidget->setTabStyle(OTabWidget::TextTab); mainLayout->add(tabWidget); QWidget *tabprof; /* base tabs */ tabprof = new QWidget(this); m_tabTerm = new QWidget(this); m_tabCon = new QWidget(this); /* base layout for tabs */ m_layCon = new QHBoxLayout( m_tabCon , 2 ); m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); // profile tab QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); m_name = new QLineEdit(tabprof); QLabel *con = new QLabel(tr("Connection"), tabprof ); QLabel *term = new QLabel(tr("Terminal"), tabprof ); m_conCmb = new QComboBox( tabprof ); m_termCmb = new QComboBox( tabprof ); // layouting QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); vbox3->add(name); vbox3->add(m_name); vbox3->add(con ); vbox3->add(m_conCmb ); vbox3->add(term ); vbox3->add(m_termCmb ); vbox3->addStretch(1); tabWidget->addTab(tabprof, "", QObject::tr("Profile")); tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); tabWidget->setCurrentTab( tabprof ); // fill the comboboxes QStringList list = m_fact->connectionWidgets(); QStringList::Iterator it; for (it =list.begin(); it != list.end(); ++it ) { m_conCmb->insertItem( (*it) ); } list = m_fact->terminalWidgets(); for (it =list.begin(); it != list.end(); ++it ) { m_termCmb->insertItem( (*it) ); } // load profile values m_name->setText(m_prof.name()); slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); slotTermActivated( m_fact->external(m_prof.terminalName() ) ); setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); // signal and slots connect(m_conCmb, SIGNAL(activated(const QString& ) ), this, SLOT(slotConActivated(const QString&) ) ); connect(m_termCmb, SIGNAL(activated(const QString& ) ), this, SLOT(slotTermActivated(const QString& ) ) ); } ProfileEditorDialog::~ProfileEditorDialog() { } void ProfileEditorDialog::accept() { if(profName().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(profName()); m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); if (m_con ) m_con->save( m_prof ); if (m_term ) m_term->save( m_prof ); QDialog::accept(); } QString ProfileEditorDialog::profName()const { return m_name->text(); } QCString ProfileEditorDialog::profType()const { /*QStringList w = m_fact->configWidgets(); for(QStringList::Iterator it = w.begin(); it != w.end(); it++) if(device_box->currentText() == m_fact->name((*it))) return (*it); */ return QCString(); } /* * we need to switch the widget */ void ProfileEditorDialog::slotConActivated( const QString& str ) { delete m_con; m_con = m_fact->newConnectionPlugin( str, m_tabCon ); - if (m_con ) { + if ( m_con ) { m_con->load( m_prof ); m_layCon->addWidget( m_con ); + } else { + tabWidget->removePage( m_tabCon ); } } /* * we need to switch the widget */ void ProfileEditorDialog::slotTermActivated( const QString& str ) { delete m_term; m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); if (m_term) { m_term->load(m_prof ); m_layTerm->addWidget( m_term ); } } diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index 3b67bb3..6fde839 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h @@ -1,51 +1,53 @@ #ifndef PROFILE_EDITOR_DIALOG #define PROFILE_EDITOR_DIALOG #include <qdialog.h> +#include <opie/otabwidget.h> #include "profile.h" class MetaFactory; class EditBase; class QTabWidget; class QHBoxLayout; class QLineEdit; class QComboBox; class QLabel; class ProfileDialogWidget; class ProfileEditorDialog : public QDialog { Q_OBJECT public: ProfileEditorDialog(MetaFactory* fact, const Profile& prof ); ProfileEditorDialog(MetaFactory* fact ); ~ProfileEditorDialog(); Profile profile()const; public slots: void accept(); private slots: void slotConActivated(const QString& ); void slotTermActivated( const QString& ); private: void initUI(); QString profName()const; QCString profType()const; MetaFactory* m_fact; QHBoxLayout* m_lay; Profile m_prof; QLineEdit *m_name; QComboBox *m_conCmb, *m_termCmb; QWidget *m_tabCon, *m_tabTerm; ProfileDialogWidget* m_con, *m_term; QHBoxLayout *m_layCon, *m_layTerm; + OTabWidget *tabWidget; }; #endif diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp index d216c92..1e97a24 100644 --- a/noncore/apps/opie-console/serialconfigwidget.cpp +++ b/noncore/apps/opie-console/serialconfigwidget.cpp @@ -1,147 +1,147 @@ #include <qlabel.h> #include <qlayout.h> #include <qcombobox.h> #include "iolayerbase.h" #include "serialconfigwidget.h" namespace { void setCurrent( const QString& str, QComboBox* bo ) { uint b = bo->count(); for (uint i = 0; i < bo->count(); i++ ) { if ( bo->text(i) == str ) { bo->setCurrentItem( i ); return; } } bo->insertItem( str ); bo->setCurrentItem( b ); } } SerialConfigWidget::SerialConfigWidget( const QString& name, QWidget* parent, const char* na ) : ProfileDialogConnectionWidget( name, parent, na ) { m_lay = new QVBoxLayout(this ); m_device = new QLabel(tr("Device"), this ); m_deviceCmb = new QComboBox(this ); m_deviceCmb->setEditable( TRUE ); m_base = new IOLayerBase(this, "base"); m_lay->addWidget( m_device ); m_lay->addWidget( m_deviceCmb ); m_lay->addWidget( m_base ); m_deviceCmb->insertItem( "/dev/ttyS0" ); m_deviceCmb->insertItem( "/dev/ttyS1" ); m_deviceCmb->insertItem( "/dev/ttySA0"); m_deviceCmb->insertItem( "/dev/ttySA1"); } SerialConfigWidget::~SerialConfigWidget() { } void SerialConfigWidget::load( const Profile& prof ) { int rad_flow = prof.readNumEntry("Flow"); int rad_parity = prof.readNumEntry("Parity"); int speed = prof.readNumEntry("Speed"); if (rad_flow == 1) { m_base->setFlow( IOLayerBase::Hardware ); } else if (rad_flow == 2) { m_base->setFlow( IOLayerBase::Software ); } else { - m_base->setFlow( IOLayerBase::None ); + m_base->setFlow( IOLayerBase::None ); } if (rad_parity == 1) { m_base->setParity( IOLayerBase::Even ); } else if ( rad_parity == 2 ) { m_base->setParity( IOLayerBase::Odd ); } else { m_base->setParity( IOLayerBase::NonePar ); } switch( speed ) { case 115200: m_base->setSpeed(IOLayerBase::Baud_115200 ); break; case 57600: m_base->setSpeed( IOLayerBase::Baud_57600 ); break; case 38400: m_base->setSpeed(IOLayerBase::Baud_38400 ); break; case 19200: m_base->setSpeed( IOLayerBase::Baud_19200 ); break; case 9600: default: m_base->setSpeed(IOLayerBase::Baud_9600 ); break; } if ( prof.readEntry("Device").isEmpty() ) return; setCurrent( prof.readEntry("Device"), m_deviceCmb ); } /* * save speed, * flow, * parity */ void SerialConfigWidget::save( Profile& prof ) { int flow, parity, speed; prof.writeEntry("Device", m_deviceCmb->currentText() ); switch( m_base->flow() ) { case IOLayerBase::None: flow = 0; break; case IOLayerBase::Software: flow = 2; break; case IOLayerBase::Hardware: flow = 1; break; } switch( m_base->parity() ) { case IOLayerBase::Odd: parity = 2; break; case IOLayerBase::Even: parity = 1; break; case IOLayerBase::NonePar: parity = 0; break; } switch( m_base->speed() ) { case IOLayerBase::Baud_115200: speed = 115200; break; case IOLayerBase::Baud_57600: speed = 57600; break; case IOLayerBase::Baud_38400: speed = 38400; break; case IOLayerBase::Baud_19200: speed = 19200; break; case IOLayerBase::Baud_9600: speed = 9600; break; } prof.writeEntry("Flow", flow); prof.writeEntry("Parity", parity); prof.writeEntry("Speed", speed); } |