-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 19 | ||||
-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/terminalwidget.cpp | 24 |
7 files changed, 61 insertions, 16 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 6b0d6f2..16bb5ff 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp @@ -82,246 +82,261 @@ #include <pty.h> #endif #include "procctl.h" #include "MyPty.h" #undef VERBOSE_DEBUG /* -------------------------------------------------------------------------- */ /*! Informs the client program about the actual size of the window. */ void MyPty::setSize(int lines, int columns) { qWarning("setting size"); struct winsize wsize; wsize.ws_row = (unsigned short)lines; wsize.ws_col = (unsigned short)columns; if(m_fd < 0) return; ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); } void MyPty::donePty() { // This is code from the Qt DumbTerminal example int status = 0; ::close(m_fd); if (m_cpid) { kill(m_cpid, SIGHUP); //waitpid(m_cpid, &status, 0); delete m_sn_e; delete m_sn_r; m_sn_e = 0l; m_sn_r = 0l; } m_cpid = 0; m_fd = -1; // emit done(status); } const char* MyPty::deviceName() { return m_ttynam; } void MyPty::error() { // This is code from the Qt DumbTerminal example donePty(); } void MyPty::start() { char* cmd = "/bin/sh"; QStrList lis; int r =run(cmd, lis, 0, 0); r = r; } /*! start the client program. */ int MyPty::run(const char* cmd, QStrList &, const char*, int) { // This is code from the Qt DumbTerminal example m_cpid = fork(); if ( !m_cpid ) { // child - exec shell on tty for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); int ttyfd = ::open(m_ttynam, O_RDWR); dup2(ttyfd, STDIN_FILENO); dup2(ttyfd, STDOUT_FILENO); dup2(ttyfd, STDERR_FILENO); // should be done with tty, so close it ::close(ttyfd); static struct termios ttmode; if ( setsid() < 0 ) perror( "failed to set process group" ); #if defined (TIOCSCTTY) // grabbed from APUE by Stevens ioctl(STDIN_FILENO, TIOCSCTTY, 0); #endif tcgetattr( STDIN_FILENO, &ttmode ); ttmode.c_cc[VINTR] = 3; ttmode.c_cc[VERASE] = 8; tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); - setenv("TERM","vt100",1); + setenv("TERM",m_term,1); setenv("COLORTERM","0",1); if (getuid() == 0) { char msg[] = "WARNING: You are running this shell as root!\n"; write(ttyfd, msg, sizeof(msg)); } execl(cmd, cmd, 0); donePty(); exit(-1); } // parent - continue as a widget delete m_sn_r; m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); delete m_sn_e; m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); return 0; } int MyPty::openPty() { // This is code from the Qt DumbTerminal example int ptyfd = -1; #ifdef HAVE_OPENPTY int ttyfd; if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) ptyfd = -1; else close(ttyfd); // we open the ttynam ourselves. #else for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { ::close(ptyfd); ptyfd = -1; } } } } #endif if ( ptyfd < 0 ) { // qApp->exit(1); return -1; } return ptyfd; } /*! Create an instance. */ -MyPty::MyPty(const Profile&) : m_cpid(0) +MyPty::MyPty(const Profile& prof) : m_cpid(0) { + + int term = prof.readNumEntry("Terminal", Profile::VT100 ); + switch( term ) { + default: + case Profile::VT100: + case Profile::VT102: + m_term = "vt100"; + break; + case Profile::Linux: + m_term = "linux"; + break; + case Profile::XTerm: + m_term = "xterm"; + break; + } m_sn_e = 0l; m_sn_r = 0l; m_fd = openPty(); ProcCtl* ctl = ProcCtl::self(); } /*! Destructor. Note that the related client program is not killed (yet) when a instance is deleted. */ MyPty::~MyPty() { donePty(); } QString MyPty::identifier()const { return QString::fromLatin1("term"); } QString MyPty::name()const{ return identifier(); } bool MyPty::open() { if (m_fd < 0) m_fd = openPty(); start(); return true; } void MyPty::close() { donePty(); m_fd = openPty(); } void MyPty::reload( const Profile& ) { } /*! sends len bytes through the line */ void MyPty::send(const QByteArray& ar) { #ifdef VERBOSE_DEBUG // verbose debug printf("sending bytes:\n"); for (uint i = 0; i < ar.count(); i++) printf("%c", ar[i]); printf("\n"); #endif ::write(m_fd, ar.data(), ar.count()); } /*! indicates that a block of data is received */ void MyPty::readPty() { QByteArray buf(4096); int len = ::read( m_fd, buf.data(), 4096 ); if (len == -1 || len == 0) { donePty(); return; } if (len < 0) return; buf.resize(len); emit received(buf); #ifdef VERBOSE_DEBUG // verbose debug printf("read bytes:\n"); for (uint i = 0; i < buf.count(); i++) printf("%c", buf[i]); printf("\n"); #endif } QBitArray MyPty::supports()const { QBitArray ar(3); //autoconnect ar[0] = 1; // ar[1] = 0; ar[2] = 0; return ar; } diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h index 81abad5..7561ca3 100644 --- a/noncore/apps/opie-console/MyPty.h +++ b/noncore/apps/opie-console/MyPty.h @@ -1,99 +1,100 @@ /* -------------------------------------------------------------------------- */ /* */ /* [MyPty.h] Pseudo Terminal Device */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* 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> */ /* */ /* -------------------------------------------------------------------------- */ /*! \file */ #ifndef MY_PTY_H #define MY_PTY_H #include <qobject.h> #include <qstrlist.h> #include "io_layer.h" class Profile; class QSocketNotifier; class MyPty : public IOLayer { Q_OBJECT public: MyPty(const Profile&); ~MyPty(); QString identifier()const; QString name()const; QBitArray supports()const; public slots: /*! having a `run' separate from the constructor allows to make the necessary connections to the signals and slots of the instance before starting the execution of the client. */ void start(); int run(const char* pgm, QStrList & args , const char* term, int addutmp); bool open(); void close(); void reload( const Profile& ); void setSize(int lines, int columns); void error(); bool isConnected() { return true; }; signals: /*! emitted when the client program terminates. \param status the wait(2) status code of the terminated client program. */ void done(int status); /*! emitted when a new block of data comes in. \param s - the data \param len - the length of the block */ void received(const QByteArray&); public slots: void send(const QByteArray& ); private: const char* deviceName(); protected slots: void readPty(); void donePty(); private: int openPty(); private: char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." int m_fd; int m_cpid; QSocketNotifier* m_sn_e; QSocketNotifier* m_sn_r; + char* m_term; }; #endif diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index df8e573..bdc8b43 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -1,138 +1,153 @@ #include <qwidget.h> #include <qpushbutton.h> #include "TEWidget.h" #include "TEmuVt102.h" #include "profile.h" #include "emulation_handler.h" #include "script.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 ); m_script = 0; 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() { if (isRecording()) clearScript(); 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) ); + m_teWid->setBackgroundColor(backColor(num) ); + + int term = prof.readNumEntry("Terminal", 0) ; + switch(term) { + default: + case Profile::VT102: + case Profile::VT100: + m_teEmu->setKeytrans("vt100.keytab"); + break; + case Profile::Linux: + m_teEmu->setKeytrans("linux.keytab"); + break; + case Profile::XTerm: + m_teEmu->setKeytrans("default.Keytab"); + break; + } } void EmulationHandler::recv( const QByteArray& ar) { m_teEmu->onRcvBlock(ar.data(), ar.count() ); } void EmulationHandler::recvEmulation(const char* src, int len ) { QByteArray ar(len); memcpy(ar.data(), src, sizeof(char) * len ); if (isRecording()) m_script->append(ar); 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: /* color is black */ co = Qt::white; break; case Profile::Black: 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: /* color is white */ co = Qt::black; break; case Profile::Black: co = Qt::white; break; case Profile::Green: diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index b81c2a2..221838c 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp @@ -1,250 +1,251 @@ #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <qcstring.h> #include <qsocketnotifier.h> #include <opie/oprocess.h> #include "procctl.h" #include "filetransfer.h" FileTransfer::FileTransfer( Type t, IOLayer* lay ) : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { signal(SIGPIPE, SIG_IGN ); m_pid = 0; m_not = 0l; m_proc = 0l; } FileTransfer::~FileTransfer() { } /** * now we will send the file. * * we request an fd. The IOLayer should be closed * then we will setup a pipe for progress communication * then we will dup2 the m_fd in the forked process * to do direct IO from and to the fd */ void FileTransfer::sendFile( const QString& file ) { m_prog =-1; m_fd = layer()->rawIO(); // // m_fd = ::open("/dev/ttyS0", O_RDWR); m_file = file; if ( pipe( m_comm ) < 0 ) m_comm[0] = m_comm[1] = 0; if ( pipe( m_info ) < 0 ) m_info[0] = m_info[1] = 0; m_pid = fork(); switch( m_pid ) { case -1: emit error( StartError, tr("Was not able to fork") ); slotExec(); break; case 0:{ setupChild(); /* exec */ char* verbose = "-vv"; char* binray = "-b"; char* typus; switch(m_type ) { + default: case SZ: typus = ""; break; case SX: typus = "-X"; break; case SY: typus = "--ymodem"; break; } /* we should never return from here */ execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); /* communication for error!*/ char resultByte =1; if (m_info[1] ) write(m_info[1], &resultByte, 1 ); _exit( -1 ); break; } default:{ if ( m_info[1] ) close( m_info[1] ); if ( m_info[0] ) for (;;) { char resultByte; int len; len = read(m_info[0], &resultByte, 1 ); /* len == 1 start up failed */ if ( len == 1 ) { emit error( StartError, tr("Could not start") ); return; } if ( len == -1 ) if ( (errno == ECHILD ) || (errno == EINTR ) ) continue; // len == 0 or something like this break; } if ( m_info[0] ) close( m_info[0] ); /* replace by QSocketNotifier!!! */ m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); connect(m_not, SIGNAL(activated(int) ), this, SLOT(slotRead() ) ); if ( pipe(m_term) < 0 ) m_term[0] = m_term[1] = 0; ProcCtl::self()->add(m_pid, m_term[1] ); m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); connect(m_proc, SIGNAL(activated(int) ), this, SLOT(slotExec() ) ); } break; } } /* * let's call the one with the filename */ void FileTransfer::sendFile( const QFile& file ) { sendFile( file.name() ); } /* * setting up communication * between parent child and ioLayer */ void FileTransfer::setupChild() { /* * we do not want to read from our * information channel */ if (m_info[0] ) close(m_info[0] ); /* * FD_CLOEXEC will close the * fd on successfull exec */ if (m_info[1] ) fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); if (m_comm[0] ) close( m_comm[0] ); /* * now set the communication * m_fd STDIN_FILENO * STDOUT_FILENO * STDERR_FILENO */ dup2( m_fd, STDIN_FILENO ); dup2( m_fd, STDOUT_FILENO ); dup2( m_comm[1], STDERR_FILENO ); } /* * read from the stderr of the child * process */ void FileTransfer::slotRead() { QByteArray ar(4096); int len = read(m_comm[0], ar.data(), 4096 ); for (int i = 0; i < len; i++ ) { // printf("%c", ar[i] ); } ar.resize( len ); QString str( ar ); QStringList lis = QStringList::split(' ', str ); /* * Transfer finished.. either complete or incomplete */ if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { return; } /* * do progress reading */ slotProgress( lis ); } /* * find the progress */ void FileTransfer::slotProgress( const QStringList& list ) { if ( m_type != SZ ) return; bool complete = true; int min, sec; int bps; unsigned long sent, total; min = sec = bps = -1; sent = total = 0; // Data looks like this // 0 1 2 3 4 5 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); sent = progi[0].toULong(&complete ); if (!complete ) return; total = progi[1].toULong(&complete ); if (!complete || total == 0) { return; } double pro = (double)sent/total; int prog = pro * 100; // speed progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); bps = progi[1].toInt(); // time progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); min = progi[0].toInt(); sec = progi[1].toInt(); if ( prog > m_prog ) { m_prog = prog; emit progress(m_file, m_prog, bps, -1, min , sec ); } } void FileTransfer::cancel() { if(m_pid > 0) ::kill(m_pid,9 ); - + } void FileTransfer::slotExec() { char buf[2]; ::read(m_term[0], buf, 1 ); delete m_proc; delete m_not; m_proc = m_not = 0l; close( m_term[0] ); close( m_term[1] ); close( m_comm[0] ); close( m_comm[1] ); layer()->closeRawIO( m_fd ); emit sent(); m_pid = 0; } diff --git a/noncore/apps/opie-console/filetransfer.h b/noncore/apps/opie-console/filetransfer.h index 9cc1e8d..8f55041 100644 --- a/noncore/apps/opie-console/filetransfer.h +++ b/noncore/apps/opie-console/filetransfer.h @@ -1,54 +1,48 @@ #ifndef OPIE_FILE_TRANSFER_H #define OPIE_FILE_TRANSFER_H #include <sys/types.h> #include <qfile.h> #include <qstringlist.h> #include "file_layer.h" class QSocketNotifier; class OProcess; class FileTransferControl; class FileTransfer : public FileTransferLayer{ Q_OBJECT friend class FileTransferControl; public: enum Type { SZ = 0, SX, SY }; FileTransfer( Type t, IOLayer* ); ~FileTransfer(); void sendFile( const QString& file ); void sendFile( const QFile& ); void cancel(); private slots: void setupChild(); void slotRead(); void slotProgress( const QStringList& ); void slotExec(); private: - /* - * FIXME? What does happen if we've - * two FileTransfers at a time? - * Have a procctl which does listen - * for termination and then send a signal - */ + Type m_type; pid_t m_pid; int m_fd; int m_prog; int m_info[2]; int m_comm[2]; int m_term[2]; QString m_file; - Type m_type; QSocketNotifier *m_not; QSocketNotifier* m_proc; }; #endif diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h index 4f9e9c2..eeda1b6 100644 --- a/noncore/apps/opie-console/profile.h +++ b/noncore/apps/opie-console/profile.h @@ -1,76 +1,79 @@ #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, Green, Orange}; - enum Terminal {VT102 = 0, VT100 }; + enum Terminal {VT102 = 0, VT100, + Ansi, + Linux, + XTerm }; 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; bool autoConnect()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 setAutoConnect( const bool ); 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; bool m_autoConnect; int m_back; int m_fore; int m_terminal; }; #endif diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp index 8badf96..eae94c3 100644 --- a/noncore/apps/opie-console/terminalwidget.cpp +++ b/noncore/apps/opie-console/terminalwidget.cpp @@ -1,210 +1,226 @@ #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_vt100 = 0, id_term_vt102, - id_term_ansi + id_term_linux, + id_term_xterm }; enum ColourIds { id_term_black, 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 ); + qWarning("Options for terminal box"); + m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); + m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); + m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); + m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); //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; + case Profile::Linux: + m_terminalBox->setCurrentItem(id_term_linux ); + break; + case Profile::XTerm: + m_terminalBox->setCurrentItem(id_term_xterm ); + 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_linux: + profile.writeEntry("Terminal", Profile::Linux ); + break; + case id_term_xterm: + profile.writeEntry("Terminal", Profile::XTerm ); + 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() ); } |