-rw-r--r-- | noncore/apps/opie-console/default.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.cpp | 123 | ||||
-rw-r--r-- | noncore/apps/opie-console/iolayerbase.h | 47 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.cpp | 191 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.h | 46 |
9 files changed, 427 insertions, 7 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index 78495d2..4ab4695 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp @@ -1,65 +1,66 @@ #include "io_serial.h" #include "sz_transfer.h" +#include "terminalwidget.h" #include "default.h" extern "C" { // FILE Transfer Stuff FileTransferLayer* newSZTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SZ, lay ); } FileTransferLayer* newSYTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SY, lay ); } FileTransferLayer* newSXTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SX, lay ); } // Layer stuff IOLayer* newSerialLayer( const Profile& prof) { return new IOSerial( prof ); } IOLayer* newBTLayer( const Profile& ) { return 0l; } IOLayer* newIrDaLayer( const Profile& ) { return 0l; } // Connection Widgets ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) { return 0l; } ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid); } ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid ); } // Terminal Widget(s) - ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ) { - return 0l; + ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { + return new TerminalWidget(na, wid,0 ); } }; Default::Default( MetaFactory* fact ) { fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); } Default::~Default() { } diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp new file mode 100644 index 0000000..1e164fe --- a/dev/null +++ b/noncore/apps/opie-console/iolayerbase.cpp @@ -0,0 +1,123 @@ +#include <qlabel.h> +#include <qlayout.h> +#include <qcombobox.h> +#include <qbuttongroup.h> +#include <qhbuttongroup.h> +#include <qradiobutton.h> + +#include "iolayerbase.h" + +namespace { + enum ParityIds { + id_parity_odd, + id_parity_even + }; + + enum FlowIds { + id_flow_hw, + id_flow_sw + }; + + enum SpeedIds { + id_baud_115200, + id_baud_57600, + id_baud_38400, + id_baud_19200, + id_baud_9600 + }; + +} + + +IOLayerBase::IOLayerBase( QWidget* par, const char* name ) + : QWidget( par, name ) +{ + m_speedLabel = new QLabel(tr("Speed"), this ); + m_speedBox = new QComboBox(this ); + + m_groupFlow = new QButtonGroup(tr("Flow control") ); + m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow ); + m_flowSw = new QRadioButton(tr("Software"), m_groupFlow ); + + m_groupParity = new QButtonGroup(tr("Parity"), this ); + m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity ); + m_parityEven = new QRadioButton(tr("Even"), m_groupParity ); + + m_lroot = new QVBoxLayout(this ); + m_lroot->add(m_speedLabel ); + m_lroot->add(m_speedBox ); + m_lroot->setStretchFactor(m_speedLabel, 1); + m_lroot->setStretchFactor(m_speedBox, 1 ); + + m_hbox = new QHBoxLayout(m_groupFlow, 2 ); + m_hbox->add(m_flowHw ); + m_hbox->add(m_flowSw ); + m_lroot->add(m_groupFlow ); + m_lroot->setStretchFactor(m_groupFlow, 2 ); + + m_hboxPar = new QHBoxLayout( m_groupParity, 2 ); + m_hboxPar->add(m_parityOdd ); + m_hboxPar->add(m_parityEven ); + m_lroot->add(m_groupParity ); + m_lroot->setStretchFactor(m_groupParity, 2 ); + + // profiles + m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 ); + m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 ); + m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 ); + m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 ); + m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 ); +}; +IOLayerBase::~IOLayerBase() { + +} +void IOLayerBase::setFlow( Flow flo ) { + switch ( flo ) { + case Software: + m_flowSw->setChecked( true ); + break; + case Hardware: + m_flowHw->setChecked( true ); + break; + } +} +void IOLayerBase::setParity( Parity par ) { + switch( par ) { + case Odd: + m_parityOdd->setChecked( true ); + break; + case Even: + m_parityEven->setChecked( true ); + break; + } +} +void IOLayerBase::setSpeed( Speed sp ) { + int index; + switch( sp ) { + case Baud_115200: + index = id_baud_115200; + break; + case Baud_57600: + index = id_baud_57600; + break; + case Baud_38400: + index = id_baud_38400; + break; + case Baud_19200: + index = id_baud_19200; + break; + case Baud_9600: + index = id_baud_9600; + break; + } + m_speedBox->setCurrentItem(index ); +} +IOLayerBase::Flow IOLayerBase::flow()const { + return Hardware; +} +IOLayerBase::Parity IOLayerBase::parity()const { + return Odd; +} +IOLayerBase::Speed IOLayerBase::speed()const{ + return Baud_9600; +} diff --git a/noncore/apps/opie-console/iolayerbase.h b/noncore/apps/opie-console/iolayerbase.h new file mode 100644 index 0000000..7ef3f4d --- a/dev/null +++ b/noncore/apps/opie-console/iolayerbase.h @@ -0,0 +1,47 @@ +#ifndef OPIE_IO_LAYER_BASE_H +#define OPIE_IO_LAYER_BASE_H + + +#include <qwidget.h> + +class QLabel; +class QComboBox; +class QVBoxLayout; +class QButtonGroup; +class QRadioButton; +class QHBoxLayout; +class IOLayerBase : public QWidget { + Q_OBJECT +public: + enum Flow { Software, Hardware }; + enum Parity{ Odd, Even }; + enum Speed{ Baud_115200, + Baud_57600, + Baud_38400, + Baud_19200, + Baud_9600 }; + IOLayerBase( QWidget* base, const char* name = 0l); + ~IOLayerBase(); + + void setFlow( Flow flo ); + void setParity( Parity par ); + void setSpeed( Speed speed ); + + Flow flow()const; + Parity parity()const; + Speed speed()const; +private: + QVBoxLayout* m_lroot; + QLabel* m_speedLabel; + QComboBox* m_speedBox; + QButtonGroup* m_groupFlow; + QRadioButton *m_flowHw, *m_flowSw; + + QButtonGroup* m_groupParity; + QRadioButton *m_parityOdd, *m_parityEven; + QHBoxLayout* m_hbox; + QHBoxLayout* m_hboxPar; +}; + + +#endif diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 647a331..a414bdb 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,178 +1,179 @@ #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> #include "configdialog.h" #include "default.h" #include "metafactory.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" MainWindow::MainWindow() { m_factory = new MetaFactory(); Default def(m_factory); m_sessions.setAutoDelete( TRUE ); m_curSession = 0; m_manager = new ProfileManager( m_factory ); m_manager->load(); initUI(); populateProfiles(); } void MainWindow::initUI() { setToolBarsMovable( FALSE ); m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); m_console = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); m_settings = new QPopupMenu( this ); /* * new Action for new sessions */ QAction* a = new QAction(); a->setText( tr("New Connection") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotNew() ) ); /* * connect action */ m_connect = new QAction(); m_connect->setText( tr("Connect") ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction(); m_disconnect->setText( tr("Disconnect") ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); a = new QAction(); a->setText( tr("Close Window") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * the settings action */ m_setProfiles = new QAction(); m_setProfiles->setText( tr("Configure Profiles") ); m_setProfiles->addTo( m_settings ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the settings menu */ m_bar->insertItem( tr("Settings"), m_settings ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated( int ) ), this, SLOT(slotProfile( int ) ) ); m_consoleWindow = new TabWidget( this, "blah"); setCentralWidget( m_consoleWindow ); } ProfileManager* MainWindow::manager() { return m_manager; } void MainWindow::populateProfiles() { m_sessionsPop->clear(); Profile::ValueList list = manager()->all(); for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { m_sessionsPop->insertItem( (*it).name() ); } } MainWindow::~MainWindow() { delete m_factory; + manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { qWarning("New Connection"); } void MainWindow::slotConnect() { if ( currentSession() ) currentSession()->layer()->open(); } void MainWindow::slotDisconnect() { if ( currentSession() ) currentSession()->layer()->close(); } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); delete m_curSession; m_curSession = 0l; /* FIXME move to the next session */ } void MainWindow::slotConfigure() { qWarning("configure"); ConfigDialog conf( manager()->all(), factory() ); conf.showMaximized(); int ret = conf.exec(); if ( QDialog::Accepted == ret ) { manager()->setProfiles( conf.list() ); populateProfiles(); } } void MainWindow::slotClose() { } void MainWindow::slotProfile( int ) { } diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 077b418..4501ec2 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -1,114 +1,114 @@ #include <qpe/config.h> #include "metafactory.h" MetaFactory::MetaFactory() { } MetaFactory::~MetaFactory() { } void MetaFactory::addConnectionWidgetFactory( const QCString& name, const QString& str, configWidget wid) { m_strings.insert( str, name ); m_conFact.insert( str, wid ); } void MetaFactory::addTerminalWidgetFactory( const QCString& name, const QString& str, configWidget wid ) { m_strings.insert( str, name ); m_termFact.insert( str, wid ); } void MetaFactory::addIOLayerFactory( const QCString& name, const QString& str, iolayer lay) { m_strings.insert( str, name ); m_layerFact.insert( str, lay ); } void MetaFactory::addFileTransferLayer( const QCString& name, const QString& str, filelayer lay) { m_strings.insert(str, name ); m_fileFact.insert( str, lay ); } QStringList MetaFactory::ioLayers()const { QStringList list; QMap<QString, iolayer>::ConstIterator it; for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::connectionWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::terminalWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::fileTransferLayers()const { QStringList list; QMap<QString, filelayer>::ConstIterator it; for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { list << it.key(); } return list; } IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { IOLayer* lay = 0l; 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; } ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { ProfileDialogWidget* wid = 0l; QMap<QString, configWidget>::Iterator it; it = m_conFact.find( str ); if ( it != m_conFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { if (str.isEmpty() ) return 0l; ProfileDialogWidget* wid = 0l; qWarning("new terminalPlugin %s %l", str.latin1(), parent ); QMap<QString, configWidget>::Iterator it; it = m_termFact.find( str ); - if ( it != m_conFact.end() ) { + if ( it != m_termFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } QCString MetaFactory::internal( const QString& str )const { return m_strings[str]; } QString MetaFactory::external( const QCString& str )const { QMap<QString, QCString>::ConstIterator it; for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { if ( it.data() == str ) return it.key(); } return QString::null; } diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 984072a..9e25e8f 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro @@ -1,57 +1,61 @@ TEMPLATE = app #CONFIG = qt warn_on release CONFIG = qt debug DESTDIR = $(OPIEDIR)/bin HEADERS = io_layer.h io_serial.h \ file_layer.h sz_transfer.h \ metafactory.h \ session.h \ mainwindow.h \ profile.h \ profileconfig.h \ profilemanager.h \ configwidget.h \ tabwidget.h \ configdialog.h \ emulation_layer.h \ widget.h \ vt102emulation.h \ common.h \ history.h \ screen.h \ keytrans.h \ widget_layer.h \ transferdialog.h \ profiledialogwidget.h \ profileeditordialog.h \ - default.h + default.h \ + terminalwidget.h \ + iolayerbase.h SOURCES = io_layer.cpp io_serial.cpp \ file_layer.cpp sz_transfer.cpp \ main.cpp \ metafactory.cpp \ session.cpp \ mainwindow.cpp \ profile.cpp \ profileconfig.cpp \ profilemanager.cpp \ tabwidget.cpp \ configdialog.cpp \ emulation_layer.cpp \ widget.cpp \ vt102emulation.cpp \ history.cpp \ screen.cpp \ keytrans.cpp \ widget_layer.cpp \ transferdialog.cpp \ profiledialogwidget.cpp \ profileeditordialog.cpp \ - default.cpp + default.cpp \ + terminalwidget.cpp \ + iolayerbase.cpp INTERFACES = configurebase.ui editbase.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = opie-console diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 061b1c2..c5c6248 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -24,167 +24,174 @@ namespace { } 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 ); 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 ); qWarning("Layer: %s %s", m_prof.ioLayerName().data(), m_fact->external(m_prof.ioLayerName() ).latin1() ); qWarning("Term: %s %s", m_prof.terminalName().data(), m_fact->external(m_prof.terminalName() ).latin1() ); // 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() ) ); qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(), m_termCmb->currentText().latin1() ); + 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 ) m_layCon->addWidget( m_con ); } /* * we need to switch the widget */ void ProfileEditorDialog::slotTermActivated( const QString& str ) { delete m_term; - m_term = m_fact->newTerminalPlugin( str, 0l ); + m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); qWarning("past"); - if (m_term) + if (m_term) { + m_term->load(m_prof ); m_layTerm->addWidget( m_term ); + } } diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp new file mode 100644 index 0000000..80627c4 --- a/dev/null +++ b/noncore/apps/opie-console/terminalwidget.cpp @@ -0,0 +1,191 @@ +#include <qbuttongroup.h> +#include <qlabel.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qradiobutton.h> +#include <qgroupbox.h> +#include <qvbox.h> +#include <qhgroupbox.h> +#include <qlayout.h> + +#include "terminalwidget.h" + +namespace { + enum TermIds { + id_term_vt100, + id_term_vt220, + id_term_ansi + }; + + enum ColourIds { + id_term_black, + id_term_white + }; + + enum FontIds { + id_size_small, + id_size_medium, + id_size_large + }; +}; + +TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, + const char* na ) + : ProfileDialogTerminalWidget( name, parent, na ) { + + m_terminal = new QLabel(tr("Terminal Type"), this ); + m_terminalBox = new QComboBox(this); + m_colorLabel = new QLabel(tr("Color scheme"), this); + m_colorCmb = new QComboBox(this ); + + m_groupSize = new QButtonGroup(tr("Font size"), this ); + m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); + m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); + m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); + + m_groupConv = new QHGroupBox(tr("Line-break conversions"), this ); + m_convInbound = new QCheckBox(tr("Inbound"), m_groupConv ); + m_convOutbound = new QCheckBox(tr("Outbound"), m_groupConv ); + + m_groupOptions = new QHGroupBox( tr("Options"), this ); + m_optionEcho = new QCheckBox(tr("Local echo"), m_groupOptions ); + m_optionWrap = new QCheckBox(tr("Line wrap"), m_groupOptions ); + + m_lroot = new QVBoxLayout(this, 2 ); + m_typeBox = new QVBoxLayout( m_lroot ); + m_hbox = new QHBoxLayout( m_groupSize, 2 ); + m_colorBox = new QVBoxLayout( m_lroot ); + + // Layout + m_typeBox->add(m_terminal ); + m_typeBox->add(m_terminalBox ); + + m_hbox->add(m_sizeSmall ); + m_hbox->add(m_sizeMedium ); + m_hbox->add(m_sizeLarge ); + m_lroot->add(m_groupSize ); + + m_colorBox->add( m_colorLabel ); + m_colorBox->add( m_colorCmb ); + + m_lroot->add(m_groupConv ); + m_lroot->add(m_groupOptions ); + + // Fill in some options + m_terminalBox->insertItem( tr("VT 100"), id_term_vt100 ); + m_terminalBox->insertItem( tr("VT 220"), id_term_vt220 ); + m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); + + m_colorCmb->insertItem( tr("black on white"), id_term_black ); + m_colorCmb->insertItem( tr("white on black"), id_term_white ); + + // signals + slots + /* + connect(m_terminalBox, SIGNAL(activated(int) ), + this, SLOT(slotTermTerm(int) ) ); + connect(m_colorBox, SIGNAL(activated(int) ), + tis, SLOT(slotTermColor(int) ) ); + connect(m_groupSize, SIGNAL(activated(int) ), + this, SLOT(slotTermFont(int) ) ); + + connect(m_optionEcho, SIGNAL(toggled(bool) ), + this, SLOT(slotTermEcho(bool) ) ); + connect(m_optionWrap, SIGNAL(toggled(bool) ), + this, SLOT(slotTermWrap(bool) ) ); + connect(m_convInbound, SIGNAL(toggled(bool) ), + this, SLOT(slotTermInbound(bool) ) ); + connect(m_convOutbound, SIGNAL(toggled(bool) ), + this, SLOT(slotTermOutbound(bool) ) ); +*/ +} +TerminalWidget::~TerminalWidget() { +} +void TerminalWidget::load( const Profile& prof ) { + int term = prof.readNumEntry("Terminal"); + int color = prof.readNumEntry("Color"); + int fontsize = prof.readNumEntry("Font"); + int opt_echo = prof.readNumEntry("Echo"); + int opt_wrap = prof.readNumEntry("Wrap"); + int opt_inbound = prof.readNumEntry("Inbound"); + int opt_outbound = prof.readNumEntry("Outbound"); + + switch( term ) { + case Profile::VT102: + m_terminalBox->setCurrentItem(id_term_vt100 ); + break; + default: + break; + }; + + switch( color ) { + case Profile::Black: + m_colorCmb->setCurrentItem(id_term_black ); + break; + case Profile::White: + m_colorCmb->setCurrentItem(id_term_white ); + break; + default: + break; + }; + + switch( fontsize ) { + case Profile::Micro: + m_sizeSmall->setChecked(true ); + break; + case Profile::Small: + m_sizeMedium->setChecked(true ); + break; + case Profile::Medium: + m_sizeLarge->setChecked( true ); + break; + m_sizeSmall->setChecked(true); + default: + break; + }; + + if (opt_echo) m_optionEcho->setChecked( true ); + if (opt_wrap) m_optionWrap->setChecked( true ); + if (opt_inbound) m_convInbound->setChecked( true ); + if (opt_outbound) m_convOutbound->setChecked( true ); + +} +void TerminalWidget::save( Profile& profile ) { + switch(m_terminalBox->currentItem() ) { + case id_term_vt100: + profile.writeEntry("Terminal", Profile::VT102 ); + break; + case id_term_vt220: + profile.writeEntry("Terminal", Profile::VT102 ); + break; + case id_term_ansi: + profile.writeEntry("Terminal", Profile::VT102 ); + break; + default: + break; + }; + + // color + switch(m_colorCmb->currentItem() ) { + case id_term_black: + profile.writeEntry("Color", Profile::Black ); + break; + case id_term_white: + profile.writeEntry("Color", Profile::White ); + break; + default: + break; + }; + + if (m_sizeSmall->isChecked() ) { + profile.writeEntry("Font", Profile::Micro ); + }else if (m_sizeMedium->isChecked() ) { + profile.writeEntry("Font", Profile::Small ); + }else { + profile.writeEntry("Font", Profile::Medium ); + } + + profile.writeEntry("Echo", m_optionEcho->isChecked() ); + profile.writeEntry("Wrap", m_optionWrap->isChecked() ); + profile.writeEntry("Inbound", m_convInbound->isChecked() ); + profile.writeEntry("Outbound",m_convOutbound->isChecked() ); +} diff --git a/noncore/apps/opie-console/terminalwidget.h b/noncore/apps/opie-console/terminalwidget.h new file mode 100644 index 0000000..c6c2be2 --- a/dev/null +++ b/noncore/apps/opie-console/terminalwidget.h @@ -0,0 +1,46 @@ +#ifndef OPIE_TERMINAL_WIDGET_H +#define OPIE_TERMINAL_WIDGET_H + +#include "profiledialogwidget.h" + +class QComboBox; +class QLabel; +class QVBoxLayout; +class QHBoxLayout; +class QButtonGroup; +class QRadioButton; +class QCheckBox; +class QHGroupBox; + +class TerminalWidget : public ProfileDialogTerminalWidget { + Q_OBJECT +public: + TerminalWidget(const QString& name, QWidget* wid, + const char* na ) ; + ~TerminalWidget(); + + void load( const Profile& ); + void save( Profile& ); +private: + QVBoxLayout* m_lroot, *m_typeBox, *m_colorBox; + + QHBoxLayout* m_hbox; + + QLabel* m_terminal, *m_colorLabel; + + QComboBox* m_terminalBox, *m_colorCmb; + + QButtonGroup* m_groupSize; + + QRadioButton* m_sizeSmall, *m_sizeMedium, + *m_sizeLarge; + + QHGroupBox *m_groupConv, *m_groupOptions; + + QCheckBox *m_convInbound, + *m_convOutbound, *m_optionEcho, + *m_optionWrap; + +}; + +#endif |