author | treke <treke> | 2002-09-04 17:53:12 (UTC) |
---|---|---|
committer | treke <treke> | 2002-09-04 17:53:12 (UTC) |
commit | 605d854057eb470a1d75210193b82eb0b1ad6b53 (patch) (side-by-side diff) | |
tree | c411b661d5211fefbd83a7c8f63eef8c9cca72ee /noncore/comm/keypebble/kvnc.cpp | |
parent | c35a5eabd8f5ed18e4216f6c88ee6794bacfb491 (diff) | |
download | opie-605d854057eb470a1d75210193b82eb0b1ad6b53.zip opie-605d854057eb470a1d75210193b82eb0b1ad6b53.tar.gz opie-605d854057eb470a1d75210193b82eb0b1ad6b53.tar.bz2 |
Major modifications to the User Interface
1) Bookmark support added, all options are stored on a per bookmark basis
2) 16 Bit color is now a supported bit depth for the server
Diffstat (limited to 'noncore/comm/keypebble/kvnc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/comm/keypebble/kvnc.cpp | 168 |
1 files changed, 125 insertions, 43 deletions
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp index 43cffc5..aa46e2f 100644 --- a/noncore/comm/keypebble/kvnc.cpp +++ b/noncore/comm/keypebble/kvnc.cpp @@ -11,12 +11,25 @@ #include <qtimer.h> #include <qmessagebox.h> +#include <qspinbox.h> +#include <qlistbox.h> +#include <qlineedit.h> #include <qpe/qpeapplication.h> #include <qpe/global.h> +#include <qpe/qpetoolbar.h> +#include <qpe/resource.h> + #include <assert.h> #include "kvnc.h" #include "krfbcanvas.h" -#include "kvncoptionsdlg.h" #include "krfbconnection.h" +#include "kvncconndlg.h" +#include "krfbserver.h" + +static int u_id = 1; +static int get_unique_id() +{ + return u_id++; +} @@ -49,7 +62,17 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name ) fullscreen = false; - canvas = new KRFBCanvas( this, "canvas" ); - setCentralWidget( canvas ); + stack = new QWidgetStack( this ); + setCentralWidget( stack ); + bookmarkSelector=new KVNCBookmarkDlg(); + stack->addWidget(bookmarkSelector,get_unique_id()); + stack->raiseWidget( bookmarkSelector ); + + canvas = new KRFBCanvas( stack, "canvas" ); + stack->addWidget(canvas,get_unique_id()); + setCentralWidget( stack ); + + connect( bookmarkSelector->bookmarkList, SIGNAL(doubleClicked(QListBoxItem *)), + this, SLOT(openConnection(QListBoxItem *)) ); connect( canvas->connection(), SIGNAL(statusChanged(const QString &)), this, SLOT(statusMessage(const QString &)) ); @@ -67,14 +90,71 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name ) canvas->setCornerWidget( cornerButton ); - QTimer::singleShot( 0, canvas, SLOT(openConnection()) ); + stack->raiseWidget( bookmarkSelector ); + + + QPEToolBar *bar = new QPEToolBar( this ); + + QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), + QString::null, 0, this, 0 ); + connect( n, SIGNAL( activated() ), + this, SLOT( newConnection() ) ); + n->addTo( bar ); + + QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "edit" ), + QString::null, 0, this, 0 ); + connect( o, SIGNAL( activated() ), + this, SLOT( openConnection() ) ); + o->addTo( bar ); + + QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ), + QString::null, 0, this, 0 ); + connect( d, SIGNAL( activated() ), + this, SLOT( deleteBookmark() ) ); + d->addTo( bar ); } KVNC::~KVNC() { + +} + +void KVNC::newConnection() +{ + curServer=new KRFBServer; + + KVNCConnDlg dlg( curServer,this); + dlg.showMaximized(); + if ( dlg.exec()) { + if (!curServer->name.isEmpty()) + bookmarkSelector->addBookmark(curServer); + canvas->openConnection(*curServer); + } else + curServer=0; +} + +void KVNC::openConnection( QString name) +{ + curServer=bookmarkSelector->getServer(name); + + if (curServer) { + KVNCConnDlg dlg( curServer,this); + dlg.showMaximized(); + + if ( dlg.exec() ) { + canvas->openConnection(*curServer); + bookmarkSelector->writeBookmarks(); + } else + curServer=0; + } +} + +void KVNC::openConnection( void ) +{ + openConnection( bookmarkSelector->selectedBookmark()); } -void KVNC::openURL( const QUrl &url ) +void KVNC::openConnection( QListBoxItem * item) { - canvas->openURL( url ); + openConnection(item->text()); } @@ -89,12 +169,9 @@ void KVNC::setupActions() fullScreenAction->setEnabled( false ); - optionsAction = new QAction( tr("Settings"), QString::null, 0, 0 ); - connect( optionsAction, SIGNAL(activated()), this, SLOT( showOptions() ) ); - optionsAction->addTo( cornerMenu ); - - connectAction = new QAction( tr("Connect..."), QString::null, 0, 0 ); - connect( connectAction, SIGNAL(activated()), - canvas, SLOT( openConnection() ) ); - connectAction->addTo( cornerMenu ); + ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 ); + connect( ctlAltDelAction, SIGNAL(activated()), + canvas, SLOT( sendCtlAltDel() ) ); + ctlAltDelAction->addTo( cornerMenu ); + ctlAltDelAction->setEnabled( false ); disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 ); @@ -107,24 +184,29 @@ void KVNC::setupActions() void KVNC::toggleFullScreen() { - if ( fullscreen ) { - canvas->releaseKeyboard(); - canvas->reparent( this, 0, QPoint(0,0), false ); - canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); - setCentralWidget( canvas ); - canvas->show(); - fullScreenAction->setText( tr("Full Screen") ); - } else { - canvas->setFrameStyle( QFrame::NoFrame ); - canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, - QPoint(0,0),false); - canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); - canvas->raise(); - canvas->setFocus(); - canvas->grabKeyboard(); - canvas->show(); - - fullScreenAction->setText( tr("Stop Full Screen") ); - } - + if ( fullscreen ) { + canvas->releaseKeyboard(); + canvas->reparent( stack, 0, QPoint(0,0), false ); + canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + setCentralWidget( stack ); + stack->addWidget(canvas,get_unique_id()); + stack->raiseWidget(canvas); + canvas->show(); + stack->show(); + fullScreenAction->setText( tr("Full Screen") ); + } else { + canvas->setFrameStyle( QFrame::NoFrame ); + stack->removeWidget(canvas); + canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, + QPoint(0,0),false); + canvas->resize(qApp->desktop()->width(), qApp->desktop()->height()); + canvas->raise(); + canvas->setFocus(); + canvas->grabKeyboard(); + canvas->show(); + + fullScreenAction->setText( tr("Stop Full Screen") ); + } + + fullscreen = !fullscreen; } @@ -150,7 +232,8 @@ void KVNC::connected() static QString msg = tr( "Connected to remote host" ); statusMessage( msg ); - connectAction->setEnabled( false ); + ctlAltDelAction->setEnabled(true); disconnectAction->setEnabled( true ); fullScreenAction->setEnabled( true ); + stack->raiseWidget(canvas); } @@ -163,9 +246,13 @@ void KVNC::loggedIn() void KVNC::disconnected() { + + if ( fullscreen ) + toggleFullScreen(); static QString msg = tr( "Connection closed" ); statusMessage( msg ); - connectAction->setEnabled( true ); + ctlAltDelAction->setEnabled(false); disconnectAction->setEnabled( false ); fullScreenAction->setEnabled( false ); + stack->raiseWidget(bookmarkSelector); } @@ -180,11 +267,6 @@ void KVNC::error( const QString &msg ) QMessageBox::warning( this, tr("VNC Viewer"), msg ); } - -void KVNC::showOptions() +void KVNC::deleteBookmark(void) { - KVNCOptionsDlg *wdg = new KVNCOptionsDlg( canvas->connection()->options(), this ); - wdg->showMaximized(); - wdg->exec(); - delete wdg; + bookmarkSelector->deleteBookmark(bookmarkSelector->selectedBookmark()); } - |