-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 43 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 3 |
4 files changed, 54 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index e0f63cd..7924568 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -1,49 +1,49 @@ #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"); // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) // use setWrapAt(80) for normal console with scrollbar - m_teWid->setWrapAt(prof.readNumEntry("Wrap", 0) ? 0 : 80); + setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); 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) ); int term = prof.readNumEntry("Terminal", 0) ; switch(term) { default: @@ -170,32 +170,37 @@ QPushButton* EmulationHandler::cornerButton() { Script *EmulationHandler::script() { return m_script; } bool EmulationHandler::isRecording() { return (m_script != 0); } void EmulationHandler::startRecording() { if (!isRecording()) m_script = new Script(); } void EmulationHandler::clearScript() { if (isRecording()) { delete m_script; m_script = 0; } } void EmulationHandler::runScript(const Script *script) { emit send(script->script()); } void EmulationHandler::copy() { m_teWid->emitSelection(); } void EmulationHandler::paste() { m_teWid->pasteClipboard(); } + +void EmulationHandler::setWrap(int columns) { + m_teWid->setWrapAt(columns); +} + diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 12abbc5..7bc6f16 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h @@ -37,56 +37,58 @@ 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(); /* Scripts */ /* Create a new script and record all typed characters */ void startRecording(); /* Return whether we are currently recording a script */ bool isRecording(); /* Return the current script (or NULL) */ Script *script(); /* Stop recording and remove the current script from memory */ void clearScript(); /* Run a script by forwarding its keys to the EmulationLayer */ void runScript(const Script *); + /* Propagate change to widget */ + void setWrap(int columns); signals: void send( const QByteArray& ); void changeSize(int rows, int cols ); public slots: void recv( const QByteArray& ); void paste(); void copy(); 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; Script * m_script; }; #endif diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 936b1b2..d221715 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -192,64 +192,71 @@ void MainWindow::initUI() { 0, this, 0 ); saveCon->addTo( m_console ); connect( saveCon, SIGNAL(activated() ), this, SLOT(slotSaveSession() ) ); m_console->insertSeparator(); /* * connect action */ m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), QString::null, 0, this, 0 ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), QString::null, 0, this, 0 ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); m_console->insertSeparator(); m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 0, this, 0 ); m_transfer->addTo( m_console ); connect(m_transfer, SIGNAL(activated() ), this, SLOT(slotTransfer() ) ); + /* + * immediate change of line wrap policy + */ + m_isWrapped = false; + m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); + m_wrap->addTo( m_console ); + connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); /* * fullscreen */ m_isFullscreen = false; m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) , QString::null, 0, this, 0); m_fullscreen->addTo( m_console ); connect( m_fullscreen, SIGNAL( activated() ), this, SLOT( slotFullscreen() ) ); m_console->insertSeparator(); /* * 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() ) ); /* * script actions */ @@ -295,64 +302,65 @@ void MainWindow::initUI() { this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); QAction *a = new QAction(tr("Copy"), Resource::loadPixmap("copy"), QString::null, 0, this, 0 ); //a->addTo( m_icons ); connect( a, SIGNAL(activated() ), this, SLOT(slotCopy() ) ); QAction *paste = new QAction(tr("Paste"), Resource::loadPixmap("paste"), QString::null, 0, this, 0 ); connect( paste, SIGNAL(activated() ), this, SLOT(slotPaste() ) ); newCon->addTo( m_icons ); m_setProfiles->addTo( m_icons ); paste->addTo( m_icons ); m_openKeys->addTo(m_icons); m_fullscreen->addTo( m_icons ); m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); + m_wrap->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() ); } } void MainWindow::populateScripts() { m_scriptsPop->clear(); m_scriptsData.clear(); @@ -496,120 +504,128 @@ void MainWindow::slotConfigure() { populateProfiles(); } } /* * we will remove * this window from the tabwidget * remove it from the list * delete it * and set the currentSession() */ void MainWindow::slotClose() { if (!currentSession() ) return; Session* ses = currentSession(); 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_scripts->setItemEnabled(m_runScript_id, false); m_fullscreen->setEnabled( false ); + m_wrap->setEnabled( false ); m_closewindow->setEnabled( false ); } m_kb->loadDefaults(); } /* * 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 ) { if(m_curSession) if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 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 ); tabWidget()->repaint(); 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_fullscreen->setEnabled( true ); + m_wrap->setEnabled( true ); m_closewindow->setEnabled( true ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); // is io_layer wants direct connection, then autoconnect //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { if (prof.autoConnect()) { slotConnect(); } QWidget *w = currentSession()->widget(); if(w) w->setFocus(); + if(currentSession()->profile().readNumEntry("Wrap", 80)){ + m_isWrapped = true; + } else { + m_isWrapped = false; + } + m_kb->load(currentSession()->profile()); } void MainWindow::slotTransfer() { if ( currentSession() ) { Session *mysession = currentSession(); TransferDialog dlg(/*mysession->widgetStack()*/this, this); mysession->setTransferDialog(&dlg); //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); //dlg.showMaximized(); currentSession()->widgetStack()->addWidget(&dlg, -1); dlg.show(); //dlg.exec(); while(dlg.isRunning()) qApp->processEvents(); mysession->setTransferDialog(0l); } } void MainWindow::slotOpenKeb(bool state) { if (state) m_keyBar->show(); else m_keyBar->hide(); } void MainWindow::slotOpenButtons( bool state ) { if ( state ) { m_buttonBar->show(); @@ -625,68 +641,95 @@ void MainWindow::slotSessionChanged( Session* ses ) { if(m_curSession) if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); if(ses) if(ses->transferDialog()) ses->transferDialog()->show(); 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 ); m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); m_scripts->setItemEnabled(m_runScript_id, true); } else { m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); } if ( ( m_curSession->layer() )->supports()[1] == 0 ) { m_transfer->setEnabled( false ); } else { m_transfer->setEnabled( true ); } QWidget *w = m_curSession->widget(); if(w) w->setFocus(); + if(currentSession()->profile().readNumEntry("Wrap", 80)){ + m_isWrapped = true; + } else { + m_isWrapped = false; + } + m_kb->load(currentSession()->profile()); } } +void MainWindow::slotWrap() +{ + if(m_curSession) + { + EmulationHandler *e = m_curSession->emulationHandler(); + if(e) + { + if(m_isWrapped) + { + e->setWrap(80); + m_isWrapped = false; + } + else + { + e->setWrap(0); + m_isWrapped = true; + } + } + } +} + void MainWindow::slotFullscreen() { if ( m_isFullscreen ) { ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); ( m_curSession->emulationHandler() )->cornerButton()->hide(); disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } else { savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); ( 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(); ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } m_isFullscreen = !m_isFullscreen; } void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { if ( m_curSession ) { diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 3b16f0a..37219c5 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -38,95 +38,98 @@ public: /** * A session contains a QWidget*, * an IOLayer* and some infos for us */ Session* currentSession(); /** * the session list */ QList<Session> sessions(); /** * */ ProfileManager* manager(); TabWidget* tabWidget(); private slots: void slotNew(); void slotConnect(); void slotDisconnect(); void slotTerminate(); void slotConfigure(); void slotClose(); void slotProfile(int); void slotTransfer(); void slotOpenKeb(bool); void slotOpenButtons(bool); void slotRecordScript(); void slotSaveScript(); void slotRunScript(int); void slotFullscreen(); + void slotWrap(); void slotSessionChanged( Session* ); void slotKeyReceived(FKey, ushort, ushort, bool); /* what could these both slot do? */ void slotCopy(); void slotPaste(); /* save the currentSession() to Profiles */ void slotSaveSession(); private: void initUI(); void populateProfiles(); void populateScripts(); void create( const Profile& ); /** * the current session */ Session* m_curSession; /** * the session list */ QList<Session> m_sessions; QList<DocLnk> m_scriptsData; /** * the metafactory */ MetaFactory* m_factory; ProfileManager* m_manager; TabWidget* m_consoleWindow; QToolBar* m_tool; QToolBar* m_icons; QToolBar* m_keyBar; QToolBar* m_buttonBar; QMenuBar* m_bar; QPopupMenu* m_console; QPopupMenu* m_sessionsPop; QPopupMenu* m_scriptsPop; QPopupMenu* m_scripts; QAction* m_connect; QAction* m_disconnect; QAction* m_terminate; QAction* m_transfer; QAction* m_setProfiles; QAction* m_openKeys; QAction* m_openButtons; QAction* m_recordScript; QAction* m_saveScript; QAction* m_fullscreen; + QAction* m_wrap; QAction* m_closewindow; FunctionKeyboard *m_kb; int m_runScript_id; bool m_isFullscreen; + bool m_isWrapped; QWidget* savedParentFullscreen; }; #endif |