author | hrw <hrw> | 2005-10-12 21:05:47 (UTC) |
---|---|---|
committer | hrw <hrw> | 2005-10-12 21:05:47 (UTC) |
commit | 6d3c752d2e93f5a43a4b5156f9968e07b3144c0a (patch) (side-by-side diff) | |
tree | 0bdc7f3c4db68a21c266993a96bc428dc96bcbfa /noncore | |
parent | d5beae7038e36633480cc3e17134a85b6d68fbc7 (diff) | |
download | opie-6d3c752d2e93f5a43a4b5156f9968e07b3144c0a.zip opie-6d3c752d2e93f5a43a4b5156f9968e07b3144c0a.tar.gz opie-6d3c752d2e93f5a43a4b5156f9968e07b3144c0a.tar.bz2 |
fixed bug #1686: opie-console lack U I setting for switching scrollbar
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 41 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 9 |
4 files changed, 54 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 2087f57..d5a435e 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -205,48 +205,51 @@ bool EmulationHandler::isRecording() { bool EmulationHandler::isLogging() { return (m_log != 0); } void EmulationHandler::startRecording() { if (!isRecording()) m_script = new Script(); } void EmulationHandler::startLogging(const QString fileName) { m_logFileName = fileName; if (!isLogging()) m_log = new Logger(m_logFileName); } QString EmulationHandler::logFileName() { return m_logFileName; } void EmulationHandler::clearScript() { if (isRecording()) { delete m_script; m_script = 0; } } void EmulationHandler::clearLog() { if (isLogging()) { delete m_log; m_log = 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); } +void EmulationHandler::setScrollbarLocation(int index) { + m_teWid->setScrollbarLocation(index); +} diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 1092c82..dabdb15 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h @@ -38,74 +38,75 @@ 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(); TEmulation *emulation(); void setColor( const QColor& fore, const QColor& back ); QPushButton* cornerButton(); /* Scripts */ /* Create a new script and record all typed characters */ void startRecording(); void startLogging(const QString); /* Return whether we are currently recording a script */ bool isRecording(); /* Return whether we are currently recording a log */ bool isLogging(); QString logFileName(); /* Return the current script (or NULL) */ Script *script(); /* Stop recording and remove the current script from memory */ void clearScript(); /* Stop logging and remove the current log from memory */ void clearLog(); /* Run a script by forwarding its keys to the EmulationLayer */ void runScript(const Script *); /* Propagate change to widget */ void setWrap(int columns); + void setScrollbarLocation(int index); 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; Logger *m_log; QString m_logFileName; }; #endif diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 45a662c..18c0434 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -24,191 +24,203 @@ using namespace Opie::Ui; #include <qmessagebox.h> #include <qwhatsthis.h> #include <qfileinfo.h> /* STD */ #include <assert.h> #include <opie2/oconfig.h> MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { #ifdef FSCKED_DISTRI FixIt fix; fix.fixIt(); #endif setCaption(QObject::tr("Opie Console") ); 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(); m_scriptsData.setAutoDelete(TRUE); initUI(); populateProfiles(); populateScripts(); } 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_scriptsPop = new QPopupMenu( this ); + m_scrollbar = new QPopupMenu( this ); /* add a toolbar for icons */ m_icons = new QToolBar(this); /* * the settings action */ m_setProfiles = new QAction(tr("Configure Profiles"), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0); m_setProfiles->addTo( m_console ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); m_console->insertSeparator(); /* * new Action for new sessions */ QAction* newCon = new QAction(tr("New Profile"), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0); newCon->addTo( m_console ); connect( newCon, SIGNAL(activated() ), this, SLOT(slotNew() ) ); m_console->insertSeparator(); QAction *saveCon = new QAction( tr("Save Profile" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), QString::null, 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"), Opie::Core::OResource::loadPixmap("console/connected", Opie::Core::OResource::SmallIcon ), 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"), Opie::Core::OResource::loadPixmap("console/notconnected", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); m_console->insertSeparator(); #ifndef EAST m_quickLaunch = new QAction( tr("QuickLaunch"), Opie::Core::OResource::loadPixmap("console/konsole_mini", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 ); m_quickLaunch->addTo( m_icons ); connect( m_quickLaunch, SIGNAL( activated() ), this, SLOT( slotQuickLaunch() ) ); #endif QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); m_transfer = new QAction( tr("Transfer file..."), Opie::Core::OResource::loadPixmap("pass", Opie::Core::OResource::SmallIcon ), 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 = true; m_wrap = new QAction( tr("Line wrap"), Opie::Core::OResource::loadPixmap( "linewrap", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0, true ); m_wrap->addTo( m_console ); m_wrap->setOn( true ); connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); /* * fullscreen */ m_isFullscreen = false; m_fullscreen = new QAction( tr("Full screen"), Opie::Core::OResource::loadPixmap( "fullscreen", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 ); m_fullscreen->addTo( m_console ); connect( m_fullscreen, SIGNAL( activated() ), this, SLOT( slotFullscreen() ) ); + /* + * scrollbar + */ + sm_none = m_scrollbar->insertItem(tr( "None" )); + sm_left = m_scrollbar->insertItem(tr( "Left" )); + sm_right = m_scrollbar->insertItem(tr( "Right" )); + + m_console->insertItem(tr("Scrollbar"), m_scrollbar, -1, 0); + connect( m_scrollbar, SIGNAL(activated(int)), + this, SLOT(slotScrollbarSelected(int))); + m_console->insertSeparator(); m_recordLog = new QAction(); m_recordLog->setText( tr("Start log") ); m_recordLog->addTo( m_console ); connect(m_recordLog, SIGNAL(activated() ), this, SLOT( slotSaveLog() ) ); m_recordingLog = false; QAction *a = new QAction(); a->setText( tr("Save history") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotSaveHistory() ) ); /* * 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 */ m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 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())); /* @@ -648,96 +660,125 @@ void MainWindow::slotSessionChanged( Session* ses ) { } else { m_isWrapped = false; } m_kb->load(currentSession()->profile()); } } void MainWindow::slotWrap() { if(m_curSession) { EmulationHandler *e = m_curSession->emulationHandler(); if(e) { e->setWrap( m_isWrapped ? 80:0 ); m_isWrapped = !m_isWrapped; } } } 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::slotScrollbarSelected(int index) +{ + int loc; + + Config cfg( "Konsole" ); + cfg.setGroup("ScrollBar"); + if(index == sm_none) + { + loc = 0; + } + else if(index == sm_left) + { + loc = 1; + } + else if(index == sm_right) + { + loc = 2; + } + + cfg.writeEntry("Position", loc); + + if (currentSession()) { + currentSession()->emulationHandler()->setScrollbarLocation(loc); + } + + m_scrollbar->setItemChecked(sm_none, index == sm_none); + m_scrollbar->setItemChecked(sm_left, index == sm_left); + m_scrollbar->setItemChecked(sm_right, index == sm_right); +} void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { if ( m_curSession ) { QEvent::Type state; if (pressed) state = QEvent::KeyPress; else state = QEvent::KeyRelease; QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); // is this the best way to do this? cant figure out any other way to work QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); ke.ignore(); } } void MainWindow::slotCopy() { if (!currentSession() ) return; currentSession()->emulationHandler()->copy(); } void MainWindow::slotPaste() { if (!currentSession() ) return; currentSession()->emulationHandler()->paste(); } /* * Save the session */ void MainWindow::slotSaveSession() { if (!currentSession() ) { QMessageBox::information(this, tr("Save Connection"), tr("<qt>There is no Connection.</qt>"), 1 ); return; } manager()->add( currentSession()->profile() ); manager()->save(); populateProfiles(); } void MainWindow::slotSaveLog() { if( currentSession()->emulationHandler()->isLogging() ) { DocLnk nf; QString m_logName = currentSession()->emulationHandler()->logFileName(); diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index f3c8b81..abdf6ee 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -1,143 +1,152 @@ #ifndef OPIE_MAIN_WINDOW_H #define OPIE_MAIN_WINDOW_H #include <qmainwindow.h> #include <qlist.h> #include <qfile.h> #include "session.h" /** * this is the MainWindow of the new opie console * it's also the dispatcher between the different * actions supported by the gui */ class QToolBar; class QToolButton; class QMenuBar; class QAction; class MetaFactory; class TabWidget; class ProfileManager; class Profile; class FunctionKeyboard; class FKey; class DocLnk; + class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); ~MainWindow(); static QString appName() {return QString::fromLatin1("opie-console"); } /** * our factory to generate IOLayer and so on * */ MetaFactory* factory(); /** * 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 slotQuickLaunch(); void slotWrap(); void slotSessionChanged( Session* ); void slotKeyReceived(FKey, ushort, ushort, bool); void slotSaveHistory(); void slotSaveLog(); + void slotScrollbarSelected(int); /* 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; + /* + * scrollbar + */ + + int sm_none, sm_left, sm_right; + 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; + QPopupMenu* m_scrollbar; QAction* m_connect; QAction* m_disconnect; QAction* m_quickLaunch; 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; QAction* m_recordLog; FunctionKeyboard *m_kb; int m_runScript_id; bool m_isFullscreen; bool m_isWrapped; bool m_recordingLog; QWidget* savedParentFullscreen; }; #endif |