-rw-r--r-- | noncore/apps/opie-console/TEScreen.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 31 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.cpp | 18 |
7 files changed, 77 insertions, 16 deletions
diff --git a/noncore/apps/opie-console/TEScreen.h b/noncore/apps/opie-console/TEScreen.h index ba47ee5..473ce79 100644 --- a/noncore/apps/opie-console/TEScreen.h +++ b/noncore/apps/opie-console/TEScreen.h @@ -1,259 +1,259 @@ /* -------------------------------------------------------------------------- */ /* */ /* [te_screen.h] Screen Data Type */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole - an X terminal for KDE */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ #ifndef TESCREEN_H #define TESCREEN_H /*! \file */ #include "TECommon.h" #include "TEHistory.h" #define MODE_Origin 0 #define MODE_Wrap 1 #define MODE_Insert 2 #define MODE_Screen 3 #define MODE_Cursor 4 #define MODE_NewLine 5 #define MODES_SCREEN 6 /*! */ struct ScreenParm { int mode[MODES_SCREEN]; }; class TEScreen { public: TEScreen(int lines, int columns); ~TEScreen(); public: // these are all `Screen' operations // // VT100/2 Operations ------------------ // // Cursor Movement // void cursorUp (int n); void cursorDown (int n); void cursorLeft (int n); void cursorRight (int n); void setCursorY (int y); void setCursorX (int x); void setCursorYX (int y, int x); void setMargins (int t, int b); // // Cursor Movement with Scrolling // void NewLine (); void NextLine (); void index (); void reverseIndex(); // void Return (); void BackSpace (); void Tabulate (); // // Editing // void eraseChars (int n); void deleteChars (int n); void insertChars (int n); void deleteLines (int n); void insertLines (int n); // // ------------------------------------- // void clearTabStops(); void changeTabStop(bool set); // void resetMode (int n); void setMode (int n); void saveMode (int n); void restoreMode (int n); // void saveCursor (); void restoreCursor(); // // ------------------------------------- // void clearEntireScreen(); void clearToEndOfScreen(); void clearToBeginOfScreen(); // void clearEntireLine(); void clearToEndOfLine(); void clearToBeginOfLine(); // void helpAlign (); // // ------------------------------------- // void setRendition (int rendition); void resetRendition(int rendition); void setForeColor (int fgcolor); void setBackColor (int bgcolor); // void setDefaultRendition(); void setForeColorToDefault(); void setBackColorToDefault(); // // ------------------------------------- // BOOL getMode (int n); // // only for report cursor position // int getCursorX(); int getCursorY(); // // ------------------------------------- // void clear(); void home(); void reset(); // void ShowCharacter(unsigned short c); // void resizeImage(int new_lines, int new_columns); // ca* getCookedImage(); - + /*! return the number of lines. */ int getLines() { return lines; } /*! return the number of columns. */ int getColumns() { return columns; } /*! set the position of the history cursor. */ void setHistCursor(int cursor); /*! return the position of the history cursor. */ int getHistCursor(); int getHistLines (); void setScroll(bool on); bool hasScroll(); // // Selection // void setSelBeginXY(const int x, const int y); void setSelExtentXY(const int x, const int y); void clearSelection(); QString getSelText(const BOOL preserve_line_breaks); void checkSelection(int from, int to); private: // helper void clearImage(int loca, int loce, char c); void moveImage(int dst, int loca, int loce); - + void scrollUp(int from, int i); void scrollDown(int from, int i); void addHistLine(); void initTabStops(); void effectiveRendition(); void reverseRendition(ca* p); private: /* The state of the screen is more complex as one would expect first. The screem does really do part of the emulation providing state informations in form of modes, margins, tabulators, cursor etc. Even more unexpected are variables to save and restore parts of the state. */ // screen image ---------------- int lines; int columns; ca *image; // [lines][columns] // history buffer --------------- int histCursor; // display position relative to start of the history buffer HistoryScroll hist; - + // cursor location int cuX; int cuY; // cursor color and rendition info UINT8 cu_fg; // foreground UINT8 cu_bg; // background UINT8 cu_re; // rendition // margins ---------------- int tmargin; // top margin int bmargin; // bottom margin // states ---------------- ScreenParm currParm; // ---------------------------- bool* tabstops; // selection ------------------- int sel_begin; // The first location selected. int sel_TL; // TopLeft Location. int sel_BR; // Bottom Right Location. // effective colors and rendition ------------ UINT8 ef_fg; // These are derived from UINT8 ef_bg; // the cu_* variables above UINT8 ef_re; // to speed up operation // // save cursor, rendition & states ------------ - // + // // cursor location int sa_cuX; int sa_cuY; // rendition info UINT8 sa_cu_re; UINT8 sa_cu_fg; UINT8 sa_cu_bg; // modes ScreenParm saveParm; }; #endif // TESCREEN_H diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 9f34d2c..836a05b 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -1,131 +1,148 @@ #include <qwidget.h> #include "TEWidget.h" #include "TEmuVt102.h" #include "profile.h" #include "emulation_handler.h" EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) : QObject(0, name ) { m_teWid = new TEWidget( parent, "TerminalMain"); m_teWid->setMinimumSize(150, 70 ); parent->resize( m_teWid->calcSize(80, 24 ) ); m_teEmu = new TEmuVt102(m_teWid ); connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), this, SIGNAL(changeSize(int, int) ) ); connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), this, SLOT(recvEmulation(const char*, int) ) ); m_teEmu->setConnect( true ); m_teEmu->setHistory( TRUE ); load( prof ); } EmulationHandler::~EmulationHandler() { delete m_teEmu; delete m_teWid; } void EmulationHandler::load( const Profile& prof) { m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); int num = prof.readNumEntry("Color"); setColor( foreColor(num), backColor(num) ); m_teWid->setBackgroundColor(backColor(num) ); } void EmulationHandler::recv( const QByteArray& ar) { qWarning("received in EmulationHandler!"); m_teEmu->onRcvBlock(ar.data(), ar.count() ); } void EmulationHandler::recvEmulation(const char* src, int len ) { qWarning("received from te "); QByteArray ar(len); memcpy(ar.data(), src, sizeof(char) * len ); emit send(ar); } QWidget* EmulationHandler::widget() { return m_teWid; } /* * allocate a new table of colors */ void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { ColorEntry table[TABLE_COLORS]; const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); for (int i = 0; i < TABLE_COLORS; i++ ) { if ( i == 0 || i == 10 ) { table[i].color = fore; }else if ( i == 1 || i == 11 ) { table[i].color = back; table[i].transparent = 0; }else { table[i].color = defaultCt[i].color; } } m_teWid->setColorTable(table ); m_teWid->update(); } QFont EmulationHandler::font( int id ) { QString name; int size = 0; switch(id ) { default: // fall through case 0: name = QString::fromLatin1("Micro"); size = 4; break; case 1: name = QString::fromLatin1("Fixed"); size = 7; break; case 2: name = QString::fromLatin1("Fixed"); size = 12; break; } QFont font(name, size, QFont::Normal ); font.setFixedPitch(TRUE ); return font; } QColor EmulationHandler::foreColor(int col) { QColor co; /* we need to switch it */ switch( col ) { default: case Profile::White: qWarning("Foreground black"); /* color is black */ co = Qt::white; break; case Profile::Black: qWarning("Foreground white"); co = Qt::black; break; + case Profile::Green: + qWarning("Foreground green"); + co = Qt::green; + break; + case Profile::Orange: + qWarning("Foreground orange"); + // FIXME needs better color here + co = Qt::darkYellow; + break; } return co; } QColor EmulationHandler::backColor(int col ) { QColor co; /* we need to switch it */ switch( col ) { default: case Profile::White: qWarning("Background white"); /* color is white */ co = Qt::black; break; case Profile::Black: qWarning("Background black"); co = Qt::white; break; + case Profile::Green: + qWarning("Background black"); + co = Qt::black; + break; + case Profile::Orange: + qWarning("Background black"); + co = Qt::black; + break; } return co; } diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 6dc9e6e..b770551 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,468 +1,481 @@ #include <assert.h> #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qpe/resource.h> #include <opie/ofiledialog.h> #include "keytrans.h" #include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "metafactory.h" #include "profile.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" #include "transferdialog.h" #include "function_keyboard.h" #include "script.h" static char * menu_xpm[] = { "12 12 5 1", " c None", ". c #000000", "+ c #FFFDAD", "@ c #FFFF00", "# c #E5E100", " ", " ", " ......... ", " .+++++++. ", " .+@@@@#. ", " .+@@@#. ", " .+@@#. ", " .+@#. ", " .+#. ", " .+. ", " .. ", " "}; MainWindow::MainWindow() { KeyTrans::loadAll(); for (int i = 0; i < KeyTrans::count(); i++ ) { KeyTrans* s = KeyTrans::find(i ); assert( s ); } 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 ); /* tool bar for the menu */ m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); m_console = new QPopupMenu( this ); m_scripts = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); m_settings = new QPopupMenu( this ); /* add a toolbar for icons */ m_icons = new QToolBar(this); /* * new Action for new sessions */ QAction* a = new QAction(tr("New Connection"), Resource::loadPixmap( "new" ), QString::null, 0, this, 0); a->addTo( m_console ); a->addTo( m_icons ); 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() ) ); m_transfer = new QAction(); m_transfer->setText( tr("Transfer file...") ); m_transfer->addTo( m_console ); connect(m_transfer, SIGNAL(activated() ), this, SLOT(slotTransfer() ) ); /* * fullscreen */ m_isFullscreen = false; m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) , QString::null, 0, this, 0); m_fullscreen->addTo( m_console ); m_fullscreen->addTo( m_icons ); connect( m_fullscreen, SIGNAL( activated() ), this, SLOT( slotFullscreen() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_terminate, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); m_closewindow = new QAction(); m_closewindow->setText( tr("Close Window") ); m_closewindow->addTo( m_console ); connect( m_closewindow, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * the settings action */ m_setProfiles = new QAction(tr("Configure Profiles"), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0); m_setProfiles->addTo( m_settings ); m_setProfiles->addTo( m_icons ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); /* * script actions */ m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); m_recordScript->addTo(m_scripts); connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); m_saveScript->addTo(m_scripts); connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); m_runScript->addTo(m_scripts); connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); /* * action that open/closes the keyboard */ m_openKeys = new QAction (tr("Open Keyboard..."), Resource::loadPixmap( "down" ), QString::null, 0, this, 0); m_openKeys->setToggleAction(true); connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); m_openKeys->addTo(m_icons); /* 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 scripts menu */ m_bar->insertItem( tr("Scripts"), m_scripts ); /* the settings menu */ m_bar->insertItem( tr("Settings"), m_settings ); /* and the keyboard */ m_keyBar = new QToolBar(this); addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); m_keyBar->setHorizontalStretchable( TRUE ); m_keyBar->hide(); m_kb = new FunctionKeyboard(m_keyBar); m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_runScript->setEnabled( false ); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated( int ) ), this, SLOT(slotProfile( int ) ) ); m_consoleWindow = new TabWidget( this, "blah"); connect(m_consoleWindow, SIGNAL(activated(Session*) ), this, SLOT(slotSessionChanged(Session*) ) ); setCentralWidget( m_consoleWindow ); } ProfileManager* MainWindow::manager() { return m_manager; } TabWidget* MainWindow::tabWidget() { return m_consoleWindow; } 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"); ProfileEditorDialog dlg(factory() ); dlg.showMaximized(); int ret = dlg.exec(); if ( ret == QDialog::Accepted ) { create( dlg.profile() ); } } void MainWindow::slotRecordScript() { /* if (currentSession()) { currentSession()->emulationLayer()->startRecording(); } */ } void MainWindow::slotSaveScript() { /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { MimeTypes types; QStringList script; script << "text/plain"; types.insert("Script", script); QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); if (!filename.isEmpty()) { currentSession()->emulationLayer()->script()->saveTo(filename); currentSession()->emulationLayer()->clearScript(); } } */ } void MainWindow::slotRunScript() { /* if (currentSession()) { MimeTypes types; QStringList script; script << "text/plain"; types.insert("Script", script); QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); if (!filename.isEmpty()) { Script script(DocLnk(filename).file()); currentSession()->emulationLayer()->runScript(&script); } } */ } void MainWindow::slotConnect() { if ( currentSession() ) { bool ret = currentSession()->layer()->open(); - if(!ret) QMessageBox::warning(currentSession()->widgetStack(), - QObject::tr("Failed"), - QObject::tr("Connecting failed for this session.")); - } + if(!ret) QMessageBox::warning(currentSession()->widgetStack(), + QObject::tr("Failed"), + QObject::tr("Connecting failed for this session.")); + m_connect->setEnabled( false ); + m_disconnect->setEnabled( true ); + } } void MainWindow::slotDisconnect() { - if ( currentSession() ) + if ( currentSession() ) { currentSession()->layer()->close(); + m_connect->setEnabled( true ); + m_disconnect->setEnabled( false ); + } } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); slotClose(); /* 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 ) { qWarning("conf %d", conf.list().count() ); manager()->setProfiles( conf.list() ); manager()->save(); populateProfiles(); } } /* * we will remove * this window from the tabwidget * remove it from the list * delete it * and set the currentSession() */ void MainWindow::slotClose() { qWarning("close"); if (!currentSession() ) return; tabWidget()->remove( currentSession() ); /*it's autodelete */ m_sessions.remove( m_curSession ); m_curSession = m_sessions.first(); tabWidget()->setCurrent( m_curSession ); if (!currentSession() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_runScript->setEnabled( false ); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); } } /* * We will get the name * Then the profile * and then we will make a profile */ void MainWindow::slotProfile( int id) { Profile prof = manager()->profile( m_sessionsPop->text( id) ); create( prof ); } void MainWindow::create( const Profile& prof ) { Session *ses = manager()->fromProfile( prof, tabWidget() ); if((!ses) || (!ses->layer()) || (!ses->widgetStack())) { QMessageBox::warning(this, QObject::tr("Session failed"), QObject::tr("Cannot open session: Not all components were found.")); //if(ses) delete ses; return; } m_sessions.append( ses ); tabWidget()->add( ses ); m_curSession = ses; // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it m_connect->setEnabled( true ); - m_disconnect->setEnabled( true ); + m_disconnect->setEnabled( false ); m_terminate->setEnabled( true ); m_transfer->setEnabled( true ); m_recordScript->setEnabled( true ); m_saveScript->setEnabled( true ); m_runScript->setEnabled( true ); m_fullscreen->setEnabled( true ); m_closewindow->setEnabled( true ); } void MainWindow::slotTransfer() { - // if ( currentSession() ) { + if ( currentSession() ) { TransferDialog dlg(this); dlg.showMaximized(); dlg.exec(); - // } + } } void MainWindow::slotOpenKeb(bool state) { if (state) m_keyBar->show(); else m_keyBar->hide(); } void MainWindow::slotSessionChanged( Session* ses ) { if ( ses ) { qWarning("changing %s", ses->name().latin1() ); m_curSession = ses; + + if ( m_curSession->isConnected() ) { + m_connect->setEnabled( false ); + m_disconnect->setEnabled( true ); + } else { + m_connect->setEnabled( true ); + m_disconnect->setEnabled( false ); + } } } void MainWindow::slotFullscreen() { if ( m_isFullscreen ) { ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); setCentralWidget( m_consoleWindow ); ( m_curSession->widgetStack() )->show(); m_fullscreen->setText( tr("Full screen") ); } else { ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, QPoint(0,0), false); ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); ( m_curSession->widgetStack() )->setFocus(); ( m_curSession->widgetStack() )->show(); - // QPushButton *cornerButton = new QPushButton( this ); + //QPushButton *cornerButton = new QPushButton( ); //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); // need teh scrollbar // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); m_fullscreen->setText( tr("Stop full screen") ); } m_isFullscreen = !m_isFullscreen; } diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h index 1b71cda..64eb022 100644 --- a/noncore/apps/opie-console/profile.h +++ b/noncore/apps/opie-console/profile.h @@ -1,71 +1,73 @@ #ifndef OPIE_PROFILE_H #define OPIE_PROFILE_H #include <qmap.h> #include <qstring.h> #include <qstringlist.h> #include <qvaluelist.h> /** * A session will be generated from a saved * profile. A profile contains the iolayername * a name. * We can generate a Session from a Profile * Configuration is contained here too */ class Profile { public: typedef QValueList<Profile> ValueList; enum Color { Black = 0, White, - Gray }; + Gray, + Green, + Orange}; enum Terminal {VT102 = 0, VT100 }; enum Font { Micro = 0, Small, Medium }; Profile(); Profile( const QString& name, const QCString& iolayerName, const QCString& termName, int background, int foreground, int terminal); Profile( const Profile& ); Profile &operator=( const Profile& ); bool operator==( const Profile& prof ); ~Profile(); QString name()const; QCString ioLayerName()const; QCString terminalName()const; int foreground()const; int background()const; int terminal()const; /* * config stuff */ QMap<QString, QString> conf()const; void clearConf(); void writeEntry( const QString& key, const QString& value ); void writeEntry( const QString& key, int num ); void writeEntry( const QString& key, bool b ); void writeEntry( const QString& key, const QStringList&, const QChar& ); QString readEntry( const QString& key, const QString& deflt = QString::null)const; int readNumEntry( const QString& key, int = -1 )const; bool readBoolEntry( const QString& key, bool = FALSE )const; void setName( const QString& ); void setIOLayer( const QCString& ); void setTerminalName( const QCString& ); void setBackground( int back ); void setForeground( int fore ); void setTerminal( int term ); void setConf( const QMap<QString, QString>& ); private: QMap<QString, QString> m_conf; QString m_name; QCString m_ioLayer, m_term; int m_back; int m_fore; int m_terminal; }; #endif diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index f4fbcf2..d0ace6c 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp @@ -1,90 +1,100 @@ #include "io_layer.h" #include "file_layer.h" #include "emulation_handler.h" #include "session.h" Session::Session() { m_widget = 0l; m_layer = 0l; m_emu = 0l; } Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) : m_name( na ), m_widget( widget ), m_layer( lay ) { // m_widLay = 0l; // m_emLay = 0l; m_emu = 0l; } Session::~Session() { delete m_layer; delete m_emu; delete m_widget; /* the widget layer should be deleted by the m_widget */ } QString Session::name()const { return m_name; } QWidgetStack* Session::widgetStack() { return m_widget; } IOLayer* Session::layer() { return m_layer; } EmulationHandler* Session::emulationHandler() { return m_emu; } /* WidgetLayer* Session::emulationWidget() { return m_widLay; } */ void Session::connect() { if ( !m_layer || !m_emu ) return; + m_connected = true; + qWarning("connection in session"); QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), m_emu, SLOT(recv(const QByteArray&) ) ); QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), m_layer, SLOT(send(const QByteArray&) ) ); - } + void Session::disconnect() { if ( !m_layer || !m_emu ) return; + m_connected = false; + QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), m_emu, SLOT(recv(const QByteArray&) ) ); QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), m_layer, SLOT(send(const QByteArray&) ) ); } + void Session::setName( const QString& na){ m_name = na; } + void Session::setWidgetStack( QWidgetStack* wid ) { delete m_emu; m_emu = 0l; delete m_widget; /* the EmulationLayer was destroyed... */ m_widget = wid; } void Session::setIOLayer( IOLayer* lay ) { delete m_layer; m_layer = lay; } void Session::setEmulationHandler( EmulationHandler* lay ) { delete m_emu; m_emu = lay; } /* void Session::setEmulationWidget( WidgetLayer* lay ) { delete m_widLay; m_widLay = lay; } */ + +bool Session::isConnected() { + return m_connected; +} diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index c3f3661..a1121d3 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h @@ -1,70 +1,73 @@ #ifndef OPIE_SESSION_H #define OPIE_SESSION_H #include <qwidgetstack.h> class IOLayer; class EmulationHandler; /** * This is a Session. A session contains * a QWidget pointer and a IOLayer * Imagine a session like a collection of what * is needed to show your widget in a tab ;) */ class Session { public: /** * c'tor with widget and layer * ownership get's transfered */ Session(); Session( const QString&, QWidgetStack* widget, IOLayer* ); ~Session(); /** * return the name of the session */ QString name()const; /** * return the widgetstack * this is used to be semi modal * for FileTransfer * * semi modal == SessionModal */ QWidgetStack* widgetStack(); /** * return the layer */ IOLayer* layer(); EmulationHandler* emulationHandler(); /* * connects the data flow from * the IOLayer to the EmulationLayer */ void connect(); /* * disconnect the dataflow * this will be done for ft */ void disconnect(); void setWidgetStack( QWidgetStack* widget ); void setEmulationHandler( EmulationHandler* lay ); void setIOLayer( IOLayer* ); void setName( const QString& ); + bool isConnected(); + private: QString m_name; QWidgetStack* m_widget; IOLayer* m_layer; EmulationHandler* m_emu; + bool m_connected; }; #endif diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp index 2d37be2..8badf96 100644 --- a/noncore/apps/opie-console/terminalwidget.cpp +++ b/noncore/apps/opie-console/terminalwidget.cpp @@ -1,194 +1,210 @@ #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_vt102, id_term_ansi }; enum ColourIds { id_term_black, - id_term_white + id_term_white, + id_term_green, + id_term_orange }; 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 102"), id_term_vt102 ); //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 ); + m_colorCmb->insertItem( tr("green on black"), id_term_green ); + m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); // 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::VT100: m_terminalBox->setCurrentItem(id_term_vt100 ); break; case Profile::VT102: m_terminalBox->setCurrentItem(id_term_vt102 ); 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; + case Profile::Green: + m_colorCmb->setCurrentItem(id_term_green ); + break; + case Profile::Orange: + m_colorCmb->setCurrentItem(id_term_orange ); + 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::VT100 ); break; case id_term_vt102: 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; + case id_term_green: + profile.writeEntry("Color", Profile::Green ); + break; + case id_term_orange: + profile.writeEntry("Color", Profile::Orange ); + 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() ); } |