-rw-r--r-- | noncore/apps/opie-console/TEWidget.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEWidget.h | 28 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_bt.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 36 |
6 files changed, 57 insertions, 32 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index 75c438c..f3f462f 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp @@ -1,169 +1,172 @@ /* ------------------------------------------------------------------------ */ /* */ /* [TEWidget.C] Terminal Emulation Widget */ /* */ /* ------------------------------------------------------------------------ */ /* */ /* 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> */ /* */ /* -------------------------------------------------------------------------- */ /*! \class TEWidget \brief Visible screen contents This class is responsible to map the `image' of a terminal emulation to the display. All the dependency of the emulation to a specific GUI or toolkit is localized here. Further, this widget has no knowledge about being part of an emulation, it simply work within the terminal emulation framework by exposing size and key events and by being ordered to show a new image. <ul> <li> The internal image has the size of the widget (evtl. rounded up) <li> The external image used in setImage can have any size. <li> (internally) the external image is simply copied to the internal when a setImage happens. During a resizeEvent no painting is done a paintEvent is expected to follow anyway. </ul> \sa TEScreen \sa Emulation */ /* FIXME: - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent - 'font_a' not used in mouse events - add destructor */ /* TODO - evtl. be sensitive to `paletteChange' while using default colors. - set different 'rounding' styles? I.e. have a mode to show clipped chars? */ // #include "config.h" #include "TEWidget.h" #include "session.h" #include <qpe/config.h> #include <qapplication.h> #include <qcursor.h> #include <qregexp.h> #include <qpainter.h> #include <qclipboard.h> #include <qstyle.h> #include <qfile.h> #include <qdragobject.h> +#include <qvbox.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <sys/stat.h> #include <sys/types.h> #include <signal.h> #include <assert.h> + + // #include "TEWidget.moc" //#include <kapp.h> //#include <kcursor.h> //#include <kurl.h> //#include <kdebug.h> //#include <klocale.h> #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } #define loc(X,Y) ((Y)*columns+(X)) //FIXME: the rim should normally be 1, 0 only when running in full screen mode. #define rimX 0 // left/right rim width #define rimY 0 // top/bottom rim high #define SCRWIDTH 16 // width of the scrollbar #define yMouseScroll 1 // scroll increment used when dragging selection at top/bottom of window. /* ------------------------------------------------------------------------- */ /* */ /* Colors */ /* */ /* ------------------------------------------------------------------------- */ //FIXME: the default color table is in session.C now. // We need a way to get rid of this one, here. static const ColorEntry base_color_table[TABLE_COLORS] = // The following are almost IBM standard color codes, with some slight // gamma correction for the dim colors to compensate for bright X screens. // It contains the 8 ansiterm/xterm colors in 2 intensities. { // Fixme: could add faint colors here, also. // normal ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White // intensiv ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) }; /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) Code 0 1 2 3 4 5 6 7 ----------- ------- ------- ------- ------- ------- ------- ------- ------- ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White */ QColor TEWidget::getDefaultBackColor() { return color_table[DEFAULT_BACK_COLOR].color; } const ColorEntry* TEWidget::getColorTable() const { return color_table; } const ColorEntry* TEWidget::getdefaultColorTable() const { return base_color_table; } const QPixmap *TEWidget::backgroundPixmap() { static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); const QPixmap *pm = bg; return pm; } void TEWidget::setColorTable(const ColorEntry table[]) { for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; const QPixmap* pm = backgroundPixmap(); if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); update(); } //FIXME: add backgroundPixmapChanged. /* ------------------------------------------------------------------------- */ /* */ /* Font */ /* */ /* ------------------------------------------------------------------------- */ @@ -181,206 +184,214 @@ void TEWidget::setColorTable(const ColorEntry table[]) */ // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. unsigned short vt100_graphics[32] = { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 }; static QChar vt100extended(QChar c) { switch (c.unicode()) { case 0x25c6 : return 1; case 0x2592 : return 2; case 0x2409 : return 3; case 0x240c : return 4; case 0x240d : return 5; case 0x240a : return 6; case 0x00b0 : return 7; case 0x00b1 : return 8; case 0x2424 : return 9; case 0x240b : return 10; case 0x2518 : return 11; case 0x2510 : return 12; case 0x250c : return 13; case 0x2514 : return 14; case 0x253c : return 15; case 0xf800 : return 16; case 0xf801 : return 17; case 0x2500 : return 18; case 0xf803 : return 19; case 0xf804 : return 20; case 0x251c : return 21; case 0x2524 : return 22; case 0x2534 : return 23; case 0x252c : return 24; case 0x2502 : return 25; case 0x2264 : return 26; case 0x2265 : return 27; case 0x03c0 : return 28; case 0x2260 : return 29; case 0x00a3 : return 30; case 0x00b7 : return 31; } return c; } static QChar identicalMap(QChar c) { return c; } void TEWidget::fontChange(const QFont &) { QFontMetrics fm(font()); font_h = fm.height(); font_w = fm.maxWidth(); font_a = fm.ascent(); //printf("font_h: %d\n",font_h); //printf("font_w: %d\n",font_w); //printf("font_a: %d\n",font_a); //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); //printf("rawname: %s\n",font().rawName().ascii()); fontMap = #if QT_VERSION < 300 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") ? vt100extended : #endif identicalMap; propagateSize(); update(); } void TEWidget::setVTFont(const QFont& f) { QFrame::setFont(f); } QFont TEWidget::getVTFont() { return font(); } void TEWidget::setFont(const QFont &) { // ignore font change request if not coming from konsole itself } /* ------------------------------------------------------------------------- */ /* */ /* Constructor / Destructor */ /* */ -/* ------------------------------------------------------------------------- */ +/* ----------------------------------------------------------------------- */ + + TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) { #ifndef QT_NO_CLIPBOARD cb = QApplication::clipboard(); QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), this, SLOT(onClearSelection()) ); #endif + scrollbar = new QScrollBar(this); scrollbar->setCursor( arrowCursor ); connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); + m_cornerButton = new QPushButton( this ); + m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); + m_cornerButton->setMaximumSize( 14, 14 ); + m_cornerButton->hide(); + Config cfg("Konsole"); cfg.setGroup("ScrollBar"); switch( cfg.readNumEntry("Position",2)){ case 0: scrollLoc = SCRNONE; break; case 1: scrollLoc = SCRLEFT; break; case 2: scrollLoc = SCRRIGHT; break; }; blinkT = new QTimer(this); connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); // blinking = FALSE; blinking = TRUE; resizing = FALSE; actSel = 0; image = 0; lines = 1; columns = 1; font_w = 1; font_h = 1; font_a = 1; word_selection_mode = FALSE; setMouseMarks(TRUE); setVTFont( QFont("fixed") ); setColorTable(base_color_table); // init color table qApp->installEventFilter( this ); //FIXME: see below // KCursor::setAutoHideCursor( this, true ); // Init DnD //////////////////////////////////////////////////////////////// currentSession = NULL; // setAcceptDrops(true); // attempt // m_drop = new QPopupMenu(this); // m_drop->insertItem( QString("Paste"), 0); // m_drop->insertItem( QString("cd"), 1); // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); // we need focus so that the auto-hide cursor feature works setFocus(); setFocusPolicy( WheelFocus ); } //FIXME: make proper destructor // Here's a start (David) TEWidget::~TEWidget() { qApp->removeEventFilter( this ); if (image) free(image); } /* ------------------------------------------------------------------------- */ /* */ /* Display Operations */ /* */ /* ------------------------------------------------------------------------- */ /*! attributed string draw primitive */ void TEWidget::drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear) { if (pm && color_table[attr.b].transparent) { paint.setBackgroundMode( TransparentMode ); if (clear) erase(rect); } else { if (blinking) paint.fillRect(rect, color_table[attr.b].color); else { paint.setBackgroundMode( OpaqueMode ); paint.setBackgroundColor( color_table[attr.b].color ); } } if (color_table[attr.f].bold) paint.setPen(QColor( 0x8F, 0x00, 0x00 )); else paint.setPen(color_table[attr.f].color); paint.drawText(rect.x(),rect.y()+font_a, str); if (attr.r & RE_UNDERLINE) paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); } @@ -1169,96 +1180,99 @@ void TEWidget::styleChange(QStyle &) /* --------------------------------------------------------------------- */ void TEWidget::dragEnterEvent(QDragEnterEvent* e) { e->accept(QTextDrag::canDecode(e) || QUriDrag::canDecode(e)); } void TEWidget::dropEvent(QDropEvent* event) { // The current behaviour when url(s) are dropped is // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd // * in all other cases, just paste // (for non-local ones, or for a list of URLs, 'cd' is nonsense) QStrList strlist; int file_count = 0; dropText = ""; bool bPopup = true; if(QUriDrag::decode(event, strlist)) { if (strlist.count()) { for(const char* p = strlist.first(); p; p = strlist.next()) { if(file_count++ > 0) { dropText += " "; bPopup = false; // more than one file, don't popup } /* KURL url(p); if (url.isLocalFile()) { dropText += url.path(); // local URL : remove protocol } else { dropText += url.prettyURL(); bPopup = false; // a non-local file, don't popup } */ } if (bPopup) // m_drop->popup(pos() + event->pos()); m_drop->popup(mapToGlobal(event->pos())); else { if (currentSession) { currentSession->getEmulation()->sendString(dropText.local8Bit()); } // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; } } } else if(QTextDrag::decode(event, dropText)) { // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; if (currentSession) { currentSession->getEmulation()->sendString(dropText.local8Bit()); } // Paste it } } #endif void TEWidget::drop_menu_activated(int item) { #ifndef QT_NO_DRAGANDDROP switch (item) { case 0: // paste currentSession->getEmulation()->sendString(dropText.local8Bit()); // KWM::activate((Window)this->winId()); break; case 1: // cd ... currentSession->getEmulation()->sendString("cd "); struct stat statbuf; if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) { if ( !S_ISDIR(statbuf.st_mode) ) { /* KURL url; url.setPath( dropText ); dropText = url.directory( true, false ); // remove filename */ } } dropText.replace(QRegExp(" "), "\\ "); // escape spaces currentSession->getEmulation()->sendString(dropText.local8Bit()); currentSession->getEmulation()->sendString("\n"); // KWM::activate((Window)this->winId()); break; } #endif } +QPushButton* TEWidget::cornerButton() { + return m_cornerButton; +} diff --git a/noncore/apps/opie-console/TEWidget.h b/noncore/apps/opie-console/TEWidget.h index 40e1aea..1b5300f 100644 --- a/noncore/apps/opie-console/TEWidget.h +++ b/noncore/apps/opie-console/TEWidget.h @@ -1,202 +1,228 @@ /* ----------------------------------------------------------------------- */ /* */ /* [te_widget.h] Terminal Emulation Widget */ /* */ /* ----------------------------------------------------------------------- */ /* */ /* 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 TE_WIDGET_H #define TE_WIDGET_H #include <qwidget.h> #include <qlabel.h> #include <qtimer.h> #include <qcolor.h> #include <qkeycode.h> #include <qscrollbar.h> #include <qpopupmenu.h> +#include <qpushbutton.h> #include "TECommon.h" extern unsigned short vt100_graphics[32]; + + +static char * menu_xpm[] = { +"12 12 5 1", +" c None", +". c #000000", +"+ c #FFFDAD", +"@ c #FFFF00", +"# c #E5E100", +" ", +" ", +" ......... ", +" .+++++++. ", +" .+@@@@#. ", +" .+@@@#. ", +" .+@@#. ", +" .+@#. ", +" .+#. ", +" .+. ", +" .. ", +" "}; + class TESession; // class Konsole; class TEWidget : public QFrame // a widget representing attributed text -{ Q_OBJECT +{ + Q_OBJECT // friend class Konsole; public: TEWidget(QWidget *parent=0, const char *name=0); virtual ~TEWidget(); public: QColor getDefaultBackColor(); + QPushButton *cornerButton(); const ColorEntry* getColorTable() const; const ColorEntry* getdefaultColorTable() const; void setColorTable(const ColorEntry table[]); void setScrollbarLocation(int loc); enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; void setScroll(int cursor, int lines); void doScroll(int lines); void emitSelection(); public: void setImage(const ca* const newimg, int lines, int columns); int Lines() { return lines; } int Columns() { return columns; } void calcGeometry(); void propagateSize(); QSize calcSize(int cols, int lins) const; QSize sizeHint() const; public: void Bell(); void emitText(QString text); void pasteClipboard(); signals: void keyPressedSignal(QKeyEvent *e); void mouseSignal(int cb, int cx, int cy); void changedImageSizeSignal(int lines, int columns); void changedHistoryCursor(int value); void configureRequest( TEWidget*, int state, int x, int y ); void clearSelectionSignal(); void beginSelectionSignal( const int x, const int y ); void extendSelectionSignal( const int x, const int y ); void endSelectionSignal(const BOOL preserve_line_breaks); protected: virtual void styleChange( QStyle& ); bool eventFilter( QObject *, QEvent * ); void drawAttrStr(QPainter &paint, QRect rect, QString& str, ca attr, BOOL pm, BOOL clear); void paintEvent( QPaintEvent * ); void resizeEvent(QResizeEvent*); void fontChange(const QFont &font); void frameChanged(); void mouseDoubleClickEvent(QMouseEvent* ev); void mousePressEvent( QMouseEvent* ); void mouseReleaseEvent( QMouseEvent* ); void mouseMoveEvent( QMouseEvent* ); void focusInEvent( QFocusEvent * ); void focusOutEvent( QFocusEvent * ); bool focusNextPrevChild( bool next ); #ifndef QT_NO_DRAGANDDROP // Dnd void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); #endif virtual int charClass(char) const; void clearImage(); public: const QPixmap *backgroundPixmap(); void setSelection(const QString &t); virtual void setFont(const QFont &); void setVTFont(const QFont &); QFont getVTFont(); void setMouseMarks(bool on); public slots: void onClearSelection(); protected slots: void scrollChanged(int value); void blinkEvent(); private: QChar (*fontMap)(QChar); // possible vt100 font extention bool fixed_font; // has fixed pitch int font_h; // height int font_w; // width int font_a; // ascend int blX; // actual offset (left) int brX; // actual offset (right) int bY; // actual offset int lines; int columns; ca *image; // [lines][columns] ColorEntry color_table[TABLE_COLORS]; BOOL resizing; bool mouse_marks; void makeImage(); QPoint iPntSel; // initial selection point QPoint pntSel; // current selection point int actSel; // selection state BOOL word_selection_mode; BOOL preserve_line_breaks; + QPushButton *m_cornerButton; QClipboard* cb; QScrollBar* scrollbar; int scrollLoc; //#define SCRNONE 0 //#define SCRLEFT 1 //#define SCRRIGHT 2 BOOL blinking; // hide text in paintEvent BOOL hasBlinker; // has characters to blink QTimer* blinkT; // active when hasBlinker QPopupMenu* m_drop; QString dropText; public: // current session in this widget TESession *currentSession; private slots: void drop_menu_activated(int item); }; #endif // TE_WIDGET_H diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index b2cd348..8846959 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -1,142 +1,147 @@ #include <qwidget.h> +#include <qpushbutton.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) { 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 ); 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: qWarning("Background black"); co = Qt::black; break; case Profile::Orange: qWarning("Background black"); co = Qt::black; break; } return co; } + +QPushButton* EmulationHandler::cornerButton() { + return m_teWid->cornerButton(); +} diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 9af7680..9ceafc6 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h @@ -1,70 +1,73 @@ #ifndef OPIE_EMULATION_HANDLER_H #define OPIE_EMULATION_HANDLER_H #include <qobject.h> #include <qcolor.h> #include <qcstring.h> /* * Badly ibotty lacks the time to finish * his widget in time.. * Never the less we've to have an EmulationWidget * This is why I'm taking the inferior not cleaned * up TE* KDE STUFF */ /** * This is the layer above the IOLayer* * This nice QObject here will get stuff from * got a slot and a signal * the signal for data * the slot for receiving * it'll set up the widget internally * and manage the communication between * the pre QByteArray world! */ class Profile; class QWidget; +class QPushButton; class TEWidget; class TEmulation; class QFont; class EmulationHandler : public QObject { Q_OBJECT public: /** * simple c'tor the parent of the TEWdiget * and a name * and a Profile */ EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); /** * delete all components */ ~EmulationHandler(); void load( const Profile& ); QWidget* widget(); void setColor( const QColor& fore, const QColor& back ); + QPushButton* cornerButton(); + signals: void send( const QByteArray& ); void changeSize(int rows, int cols ); public slots: void recv( const QByteArray& ); private slots: void recvEmulation( const char*, int len ); private: QFont font( int ); QColor foreColor(int ); QColor backColor(int ); private: TEWidget* m_teWid; TEmulation* m_teEmu; }; #endif diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index d71aacc..4486eea 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp @@ -1,78 +1,77 @@ #include "io_bt.h" IOBt::IOBt( const Profile &config ) : IOSerial( config ) { m_attach = 0; } IOBt::~IOBt() { if ( m_attach ) { delete m_attach; } } void IOBt::close() { IOSerial::close(); // still need error handling if ( m_attach ) { delete m_attach; m_attach = 0; } } bool IOBt::open() { // only set up bt stuff if mac address was set, otherwise use the device set if ( !m_mac.isEmpty() ) { // now it should also be checked, if there is a connection to the device with that mac allready - // hciattach here m_attach = new OProcess(); *m_attach << "hciattach /dev/ttyS2 any 57600"; // then start hcid, then rcfomm handling (m_mac) connect( m_attach, SIGNAL( processExited( OProcess* ) ), this, SLOT( slotExited( OProcess* ) ) ); if ( m_attach->start() ) { IOSerial::open(); } else { qWarning("could not attach to device"); delete m_attach; m_attach = 0; } } else { // directly to the normal serial // TODO: look first if the connection really exists. ( is set up ) IOSerial::open(); } } void IOBt::reload( const Profile &config ) { m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); } QString IOBt::identifier() const { return "bluetooth"; } QString IOBt::name() const { return "BLuetooth IO Layer"; } void IOBt::slotExited( OProcess* proc ){ close(); } diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 5295600..408d3dd 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,149 +1,129 @@ #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 <qwhatsthis.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 "emulation_handler.h" #include "script.h" -static char * menu_xpm[] = { -"12 12 5 1", -" c None", -". c #000000", -"+ c #FFFDAD", -"@ c #FFFF00", -"# c #E5E100", -" ", -" ", -" ......... ", -" .+++++++. ", -" .+@@@@#. ", -" .+@@@#. ", -" .+@@#. ", -" .+@#. ", -" .+#. ", -" .+. ", -" .. ", -" "}; - - MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 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() ) ); /* @@ -369,130 +349,128 @@ void MainWindow::slotClose() { qWarning("removing! currentSession %s", currentSession()->name().latin1() ); /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ m_curSession = NULL; tabWidget()->remove( /*currentSession()*/ses ); /*it's autodelete */ m_sessions.remove( ses ); qWarning("after remove!!"); 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("<qt>Cannot open session: Not all components were found.</qt>")); //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( 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() ) { 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 ) { qWarning("changed!"); if ( ses ) { m_curSession = ses; qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); if ( m_curSession->layer()->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") ); + ( m_curSession->emulationHandler() )->cornerButton()->hide(); + disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } 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( m_curSession->widgetStack() ); - cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); - connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); - // would need a scrollview - // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); - m_fullscreen->setText( tr("Stop full screen") ); + ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); + + connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } - m_isFullscreen = !m_isFullscreen; + m_isFullscreen = !m_isFullscreen; } void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { qWarning("received key event! relay to TE widget"); if ( m_curSession ) { QKeyEvent ke(QEvent::KeyPress, q, u, 0); ke.ignore(); // where should i send this event? doesnt work sending it here QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); } } |