1 /****************************************************************************
3 ** Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
5 ** This file is part of KDE.
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
22 ****************************************************************************/
24 #include "mainwindow.h"
26 #include "remoteview.h"
28 #include "config/preferencesdialog.h"
29 #include "floatingtoolbar.h"
30 #include "bookmarkmanager.h"
31 #include "specialkeysdialog.h"
43 #include <KActionCollection>
44 #include <KActionMenu>
45 #include <KApplication>
46 #include <KEditToolBar>
50 #include <KMessageBox>
51 #include <KNotifyConfigWidget>
52 #include <KPushButton>
54 #include <KShortcutsDialog>
57 #include <KToggleAction>
58 #include <KUrlNavigator>
61 #include <QCloseEvent>
62 #include <QDesktopWidget>
65 #include <QScrollArea>
67 #include <QToolButton>
70 MainWindow::MainWindow(QWidget
*parent
)
71 : KXmlGuiWindow(parent
),
72 m_fullscreenWindow(0),
76 m_currentRemoteView(-1),
77 m_showStartPage(false)
81 createGUI("krdcui.rc");
83 setStandardToolBarMenuEnabled(true);
85 m_tabWidget
= new KTabWidget(this);
86 m_tabWidget
->setMinimumSize(600, 400);
87 setCentralWidget(m_tabWidget
);
89 connect(m_tabWidget
, SIGNAL(currentChanged(int)), SLOT(tabChanged(int)));
91 statusBar()->showMessage(i18n("KDE Remote Desktop Client started"));
93 updateActionStatus(); // disable remote view actions
95 if (Settings::showStartPage())
98 setAutoSaveSettings(); // e.g toolbar position, mainwindow size, ...
100 if (Settings::rememberSessions()) // give some time to create and show the window first
101 QTimer::singleShot(100, this, SLOT(restoreOpenSessions()));
104 MainWindow::~MainWindow()
108 void MainWindow::setupActions()
110 QAction
*vncConnectionAction
= actionCollection()->addAction("new_vnc_connection");
111 vncConnectionAction
->setText(i18n("New VNC Connection..."));
112 vncConnectionAction
->setIcon(KIcon("krdc"));
113 connect(vncConnectionAction
, SIGNAL(triggered()), SLOT(newVncConnection()));
115 vncConnectionAction
->setVisible(false);
118 QAction
*nxConnectionAction
= actionCollection()->addAction("new_nx_connection");
119 nxConnectionAction
->setText(i18n("New NX Connection..."));
120 nxConnectionAction
->setIcon(KIcon("krdc"));
121 connect(nxConnectionAction
, SIGNAL(triggered()), SLOT(newNxConnection()));
123 nxConnectionAction
->setVisible(false);
126 QAction
*rdpConnectionAction
= actionCollection()->addAction("new_rdp_connection");
127 rdpConnectionAction
->setText(i18n("New RDP Connection..."));
128 rdpConnectionAction
->setIcon(KIcon("krdc"));
129 connect(rdpConnectionAction
, SIGNAL(triggered()), SLOT(newRdpConnection()));
131 rdpConnectionAction
->setVisible(false);
134 QAction
*screenshotAction
= actionCollection()->addAction("take_screenshot");
135 screenshotAction
->setText(i18n("Copy Screenshot to Clipboard"));
136 screenshotAction
->setIcon(KIcon("ksnapshot"));
137 connect(screenshotAction
, SIGNAL(triggered()), SLOT(takeScreenshot()));
139 QAction
*fullscreenAction
= actionCollection()->addAction("switch_fullscreen");
140 fullscreenAction
->setText(i18n("Switch to Fullscreen Mode"));
141 fullscreenAction
->setIcon(KIcon("view-fullscreen"));
142 connect(fullscreenAction
, SIGNAL(triggered()), SLOT(switchFullscreen()));
144 QAction
*viewOnlyAction
= actionCollection()->addAction("view_only");
145 viewOnlyAction
->setCheckable(true);
146 viewOnlyAction
->setText(i18n("View Only"));
147 viewOnlyAction
->setIcon(KIcon("kgpg-sign-kgpg"));
148 connect(viewOnlyAction
, SIGNAL(triggered(bool)), SLOT(viewOnly(bool)));
150 QAction
*logoutAction
= actionCollection()->addAction("logout");
151 logoutAction
->setText(i18n("Log Out"));
152 logoutAction
->setIcon(KIcon("system-log-out"));
153 connect(logoutAction
, SIGNAL(triggered()), SLOT(logout()));
155 QAction
*showLocalCursorAction
= actionCollection()->addAction("show_local_cursor");
156 showLocalCursorAction
->setCheckable(true);
157 showLocalCursorAction
->setIcon(KIcon("input-mouse"));
158 showLocalCursorAction
->setText(i18n("Show Local Cursor"));
159 connect(showLocalCursorAction
, SIGNAL(triggered(bool)), SLOT(showLocalCursor(bool)));
161 QAction
*specialKeysDialogAction
= actionCollection()->addAction("special_keys_dialog");
162 specialKeysDialogAction
->setIcon(KIcon("go-jump-locationbar"));
163 specialKeysDialogAction
->setText(i18n("Open Special Keys Dialog..."));
164 connect(specialKeysDialogAction
, SIGNAL(triggered()), SLOT(specialKeyDialog()));
166 QAction
*quitAction
= KStandardAction::quit(this, SLOT(quit()), actionCollection());
167 actionCollection()->addAction("quit", quitAction
);
168 QAction
*preferencesAction
= KStandardAction::preferences(this, SLOT(preferences()), actionCollection());
169 actionCollection()->addAction("preferences", preferencesAction
);
170 QAction
*configToolbarAction
= KStandardAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection());
171 actionCollection()->addAction("configure_toolbars", configToolbarAction
);
172 QAction
*keyBindingsAction
= KStandardAction::keyBindings(this, SLOT(configureKeys()), actionCollection());
173 actionCollection()->addAction("configure_keys", keyBindingsAction
);
174 QAction
*cinfigNotifyAction
= KStandardAction::configureNotifications(this, SLOT(configureNotifications()), actionCollection());
175 cinfigNotifyAction
->setVisible(false);
176 actionCollection()->addAction("configure_notifications", cinfigNotifyAction
);
177 m_menubarAction
= KStandardAction::showMenubar(this, SLOT(showMenubar()), actionCollection());
178 m_menubarAction
->setChecked(!menuBar()->isHidden());
179 actionCollection()->addAction("settings_showmenubar", m_menubarAction
);
181 QString initialProtocol
;
183 initialProtocol
= "rdp";
186 initialProtocol
= "nx";
189 initialProtocol
= "vnc";
192 m_addressNavigator
= new KUrlNavigator(0, KUrl(initialProtocol
+ "://"), this);
193 m_addressNavigator
->setCustomProtocols(QStringList()
204 m_addressNavigator
->setUrlEditable(Settings::normalUrlInputLine());
205 connect(m_addressNavigator
, SIGNAL(returnPressed()), SLOT(newConnection()));
207 QLabel
*addressLabel
= new QLabel(i18n("Remote desktop:"), this);
209 QWidget
*addressWidget
= new QWidget(this);
210 QHBoxLayout
*addressLayout
= new QHBoxLayout(addressWidget
);
211 addressLayout
->setMargin(0);
212 addressLayout
->addWidget(addressLabel
);
213 addressLayout
->addWidget(m_addressNavigator
, 1);
215 KAction
*addressLineAction
= new KAction(i18nc("Title for remote address input action", "Address"), this);
216 actionCollection()->addAction("address_line", addressLineAction
);
217 addressLineAction
->setDefaultWidget(addressWidget
);
219 QAction
*gotoAction
= actionCollection()->addAction("goto_address");
220 gotoAction
->setText(i18n("Goto Address"));
221 gotoAction
->setIcon(KIcon("go-jump-locationbar"));
222 connect(gotoAction
, SIGNAL(triggered()), SLOT(newConnection()));
224 KActionMenu
*bookmarkMenu
= new KActionMenu(i18n("Bookmarks"), actionCollection());
225 m_bookmarkManager
= new BookmarkManager(actionCollection(), bookmarkMenu
->menu(), this);
226 actionCollection()->addAction("bookmark" , bookmarkMenu
);
227 connect(m_bookmarkManager
, SIGNAL(openUrl(KUrl
)), SLOT(newConnection(KUrl
)));
230 void MainWindow::restoreOpenSessions()
232 QStringList list
= Settings::openSessions();
233 QStringList::Iterator it
= list
.begin();
234 QStringList::Iterator end
= list
.end();
241 void MainWindow::newConnection(const KUrl
&newUrl
, bool switchFullscreenWhenConnected
)
243 m_switchFullscreenWhenConnected
= switchFullscreenWhenConnected
;
245 KUrl url
= newUrl
.isEmpty() ? m_addressNavigator
->uncommittedUrl() : newUrl
;
247 if (!url
.isValid() || (url
.host().isEmpty() && url
.port() < 0)
248 || !url
.path().isEmpty()) {
249 KMessageBox::error(this,
250 i18n("The entered address does not have the required form."),
251 i18n("Malformed URL"));
255 m_addressNavigator
->setUrl(KUrl(url
.scheme().toLower() + "://"));
257 QScrollArea
*scrollArea
= createScrollArea(m_tabWidget
, 0);
262 if (url
.scheme().toLower() == "vnc") {
263 view
= new VncView(scrollArea
, url
);
268 if (url
.scheme().toLower() == "nx") {
269 view
= new NxView(scrollArea
, url
);
274 if (url
.scheme().toLower() == "rdp") {
275 view
= new RdpView(scrollArea
, url
);
279 KMessageBox::error(this,
280 i18n("The entered address cannot be handled."),
281 i18n("Unusable URL"));
285 connect(view
, SIGNAL(changeSize(int, int)), this, SLOT(resizeTabWidget(int, int)));
286 connect(view
, SIGNAL(statusChanged(RemoteView::RemoteStatus
)), this, SLOT(statusChanged(RemoteView::RemoteStatus
)));
288 m_remoteViewList
.append(view
);
292 scrollArea
->setWidget(m_remoteViewList
.at(m_tabWidget
->count() - (m_showStartPage
? 1 : 0)));
294 int newIndex
= m_tabWidget
->addTab(scrollArea
, KIcon("krdc"), url
.prettyUrl(KUrl::RemoveTrailingSlash
));
295 m_tabWidget
->setCurrentIndex(newIndex
);
300 void MainWindow::resizeTabWidget(int w
, int h
)
302 kDebug(5010) << "tabwidget resize: w: " << w
<< ", h: " << h
;
304 if (m_topBottomBorder
== 0) { // the values are not cached yet
305 QScrollArea
*tmp
= qobject_cast
<QScrollArea
*>(m_tabWidget
->currentWidget());
307 m_leftRightBorder
= m_tabWidget
->width() - m_tabWidget
->currentWidget()->width() + (2 * tmp
->frameWidth());
308 m_topBottomBorder
= m_tabWidget
->height() - m_tabWidget
->currentWidget()->height() + (2 * tmp
->frameWidth());
310 kDebug(5010) << "tabwidget border: w: " << m_leftRightBorder
<< ", h: " << m_topBottomBorder
;
313 int newTabWidth
= w
+ m_leftRightBorder
;
314 int newTabHeight
= h
+ m_topBottomBorder
;
316 QSize newWindowSize
= size() - m_tabWidget
->size() + QSize(newTabWidth
, newTabHeight
);
318 QSize desktopSize
= QSize(QApplication::desktop()->availableGeometry().width(),
319 QApplication::desktop()->availableGeometry().height());
321 if ((newWindowSize
.height() >= desktopSize
.height()) || (newWindowSize
.width() >= desktopSize
.width())) {
322 kDebug(5010) << "remote desktop needs more place than available -> show window maximized";
324 QCoreApplication::processEvents();
328 //WORKAROUND: QTabWidget resize problem. Let's see if there is a clean solution for this issue.
329 m_tabWidget
->setMinimumSize(newTabWidth
, newTabHeight
);
330 m_tabWidget
->adjustSize();
331 QCoreApplication::processEvents();
332 m_tabWidget
->setMinimumSize(500, 400);
335 void MainWindow::statusChanged(RemoteView::RemoteStatus status
)
337 kDebug(5010) << status
;
339 // the remoteview is already deleted, so don't show it; otherwise it would crash
340 if (status
== RemoteView::Disconnecting
|| status
== RemoteView::Disconnected
)
343 QString host
= m_remoteViewList
.at(m_currentRemoteView
)->host();
345 QString iconName
= "krdc";
349 case RemoteView::Connecting
:
350 iconName
= "network";
351 message
= i18n("Connecting to %1", host
);
353 case RemoteView::Authenticating
:
354 iconName
= "dialog-password";
355 message
= i18n("Authenticating at %1", host
);
357 case RemoteView::Preparing
:
358 iconName
= "history";
359 message
= i18n("Preparing connection to %1", host
);
361 case RemoteView::Connected
:
363 message
= i18n("Connected to %1", host
);
365 // when started with command line fullscreen argument
366 if (m_switchFullscreenWhenConnected
) {
367 m_switchFullscreenWhenConnected
= false;
371 m_bookmarkManager
->addHistoryBookmark();
379 m_tabWidget
->setTabIcon(m_tabWidget
->currentIndex(), KIcon(iconName
));
380 statusBar()->showMessage(message
);
383 void MainWindow::takeScreenshot()
385 QPixmap snapshot
= QPixmap::grabWidget(m_remoteViewList
.at(m_currentRemoteView
));
387 QApplication::clipboard()->setPixmap(snapshot
);
390 void MainWindow::switchFullscreen()
394 if (m_fullscreenWindow
) {
396 restoreGeometry(m_mainWindowGeometry
);
398 m_fullscreenWindow
->setWindowState(0);
399 m_fullscreenWindow
->hide();
401 QScrollArea
*scrollArea
= createScrollArea(m_tabWidget
, m_remoteViewList
.at(m_currentRemoteView
));
403 int currentTab
= m_tabWidget
->currentIndex();
404 m_tabWidget
->insertTab(currentTab
, scrollArea
, m_tabWidget
->tabIcon(currentTab
), m_tabWidget
->tabText(currentTab
));
405 m_tabWidget
->removeTab(m_tabWidget
->currentIndex());
406 m_tabWidget
->setCurrentIndex(currentTab
);
408 resizeTabWidget(m_remoteViewList
.at(m_currentRemoteView
)->sizeHint().width(),
409 m_remoteViewList
.at(m_currentRemoteView
)->sizeHint().height());
412 m_toolBar
->hideAndDestroy();
416 actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-fullscreen"));
417 actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to Fullscreen Mode"));
419 m_fullscreenWindow
->deleteLater();
421 m_fullscreenWindow
= 0;
423 m_fullscreenWindow
= new QWidget(this, Qt::Window
);
424 m_fullscreenWindow
->setWindowTitle(i18n("KDE Remote Desktop Client (Fullscreen)"));
426 QScrollArea
*scrollArea
= createScrollArea(m_fullscreenWindow
, m_remoteViewList
.at(m_currentRemoteView
));
427 scrollArea
->setFrameShape(QFrame::NoFrame
);
429 QVBoxLayout
*fullscreenLayout
= new QVBoxLayout(m_fullscreenWindow
);
430 fullscreenLayout
->setMargin(0);
431 fullscreenLayout
->addWidget(scrollArea
);
433 MinimizePixel
*minimizePixel
= new MinimizePixel(m_fullscreenWindow
);
434 connect(minimizePixel
, SIGNAL(rightClicked()), m_fullscreenWindow
, SLOT(showMinimized()));
436 m_fullscreenWindow
->show();
438 m_fullscreenWindow
->setWindowState(Qt::WindowFullScreen
);
440 // show the toolbar after we have switched to fullscreen mode
441 QTimer::singleShot(100, this, SLOT(showRemoteViewToolbar()));
443 m_mainWindowGeometry
= saveGeometry();
448 QScrollArea
*MainWindow::createScrollArea(QWidget
*parent
, RemoteView
*remoteView
)
450 QScrollArea
*scrollArea
= new QScrollArea(parent
);
451 scrollArea
->setAlignment(Qt::AlignHCenter
| Qt::AlignVCenter
);
453 QPalette palette
= scrollArea
->palette();
454 palette
.setColor(QPalette::Dark
, Settings::backgroundColor());
455 scrollArea
->setPalette(palette
);
457 scrollArea
->setBackgroundRole(QPalette::Dark
);
458 scrollArea
->setWidget(remoteView
);
463 void MainWindow::logout()
467 if (m_fullscreenWindow
) { // first close fullscreen view
471 QWidget
*tmp
= m_tabWidget
->currentWidget();
473 m_remoteViewList
.removeAt(m_currentRemoteView
);
475 m_tabWidget
->removeTab(m_tabWidget
->currentIndex());
479 updateActionStatus();
482 void MainWindow::showLocalCursor(bool showLocalCursor
)
484 kDebug(5010) << showLocalCursor
;
486 m_remoteViewList
.at(m_currentRemoteView
)->showDotCursor(showLocalCursor
? RemoteView::CursorOn
: RemoteView::CursorOff
);
489 void MainWindow::viewOnly(bool viewOnly
)
491 kDebug(5010) << viewOnly
;
493 m_remoteViewList
.at(m_currentRemoteView
)->setViewOnly(viewOnly
);
496 void MainWindow::specialKeyDialog()
500 SpecialKeysDialog
dialog(this, m_remoteViewList
.at(m_currentRemoteView
));
504 void MainWindow::showRemoteViewToolbar()
509 actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-restore"));
510 actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to Window Mode"));
512 m_toolBar
= new FloatingToolBar(m_fullscreenWindow
, m_fullscreenWindow
);
513 m_toolBar
->setSide(FloatingToolBar::Top
);
514 m_toolBar
->addAction(actionCollection()->action("switch_fullscreen"));
516 QAction
*minimizeAction
= new QAction(m_toolBar
);
517 minimizeAction
->setIcon(KIcon("window-suppressed"));
518 minimizeAction
->setText(i18n("Minimize Fullscreen Window"));
519 connect(minimizeAction
, SIGNAL(triggered()), m_fullscreenWindow
, SLOT(showMinimized()));
520 m_toolBar
->addAction(minimizeAction
);
522 m_toolBar
->addAction(actionCollection()->action("take_screenshot"));
523 m_toolBar
->addAction(actionCollection()->action("view_only"));
524 m_toolBar
->addAction(actionCollection()->action("show_local_cursor"));
525 m_toolBar
->addAction(actionCollection()->action("special_keys_dialog"));
526 m_toolBar
->addAction(actionCollection()->action("logout"));
528 QAction
*stickToolBarAction
= new QAction(m_toolBar
);
529 stickToolBarAction
->setCheckable(true);
530 stickToolBarAction
->setIcon(KIcon("document-encrypt"));
531 stickToolBarAction
->setText(i18n("Stick Toolbar"));
532 connect(stickToolBarAction
, SIGNAL(triggered(bool)), m_toolBar
, SLOT(setSticky(bool)));
533 m_toolBar
->addAction(stickToolBarAction
);
536 m_toolBar
->showAndAnimate();
539 void MainWindow::updateActionStatus()
541 kDebug(5010) << m_tabWidget
->currentIndex();
545 if ((m_showStartPage
&& (m_tabWidget
->currentIndex() == 0)) ||
546 (!m_showStartPage
&& (m_tabWidget
->currentIndex() < 0)))
551 actionCollection()->action("switch_fullscreen")->setEnabled(enabled
);
552 actionCollection()->action("take_screenshot")->setEnabled(enabled
);
553 actionCollection()->action("view_only")->setEnabled(enabled
);
554 actionCollection()->action("special_keys_dialog")->setEnabled(enabled
);
555 actionCollection()->action("logout")->setEnabled(enabled
);
557 bool viewOnlyChecked
= false;
558 if (m_currentRemoteView
>= 0)
559 viewOnlyChecked
= enabled
&& m_remoteViewList
.at(m_currentRemoteView
)->viewOnly();
560 actionCollection()->action("view_only")->setChecked(viewOnlyChecked
);
562 bool showLocalCursorChecked
= false;
563 if (m_currentRemoteView
>= 0)
564 showLocalCursorChecked
= enabled
&& m_remoteViewList
.at(m_currentRemoteView
)->dotCursorState() == RemoteView::CursorOn
;
565 actionCollection()->action("show_local_cursor")->setChecked(showLocalCursorChecked
);
567 bool showLocalCursorVisible
= false;
568 if (m_currentRemoteView
>= 0)
569 showLocalCursorVisible
= enabled
&& m_remoteViewList
.at(m_currentRemoteView
)->supportsLocalCursor();
570 actionCollection()->action("show_local_cursor")->setVisible(showLocalCursorVisible
);
573 void MainWindow::preferences()
575 // An instance of your dialog could be already created and could be
576 // cached, in which case you want to display the cached dialog
577 // instead of creating another one
578 if (PreferencesDialog::showDialog("preferences"))
581 // KConfigDialog didn't find an instance of this dialog, so lets
583 PreferencesDialog
*dialog
= new PreferencesDialog(this, Settings::self());
585 // User edited the configuration - update your local copies of the
586 // configuration data
587 connect(dialog
, SIGNAL(settingsChanged(const QString
&)),
588 this, SLOT(updateConfiguration()));
593 void MainWindow::updateConfiguration()
595 m_addressNavigator
->setUrlEditable(Settings::normalUrlInputLine());
597 if (Settings::showStartPage() && !m_showStartPage
)
599 else if (!Settings::showStartPage() && m_showStartPage
) {
600 m_tabWidget
->removeTab(0);
601 m_showStartPage
= false;
603 updateActionStatus();
605 // update the scroll areas background color
606 for (int i
= (m_showStartPage
? 1 : 0); i
< m_tabWidget
->count(); i
++) {
607 QPalette palette
= m_tabWidget
->widget(i
)->palette();
608 palette
.setColor(QPalette::Dark
, Settings::backgroundColor());
609 m_tabWidget
->widget(i
)->setPalette(palette
);
613 void MainWindow::quit()
618 void MainWindow::configureNotifications()
620 KNotifyConfigWidget::configure(this);
623 void MainWindow::configureKeys()
625 KShortcutsDialog::configure(actionCollection());
628 void MainWindow::configureToolbars()
630 KEditToolBar
edit(actionCollection());
631 connect(&edit
, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig()));
635 void MainWindow::showMenubar()
637 if (m_menubarAction
->isChecked())
643 void MainWindow::closeEvent(QCloseEvent
*event
)
645 if (KMessageBox::warningYesNoCancel(this,
646 i18n("Are you sure you want to close the KDE Remote Desktop Client?"),
647 i18n("Confirm Quit"),
648 KStandardGuiItem::yes(), KStandardGuiItem::no(), KStandardGuiItem::cancel(),
649 "AskBeforeExit") == KMessageBox::Yes
) {
651 if (Settings::rememberSessions()) { // remember open remote views for next startup
653 for (int i
= (m_showStartPage
? 1 : 0); i
< m_tabWidget
->count(); i
++) {
654 kDebug(5010) << m_remoteViewList
.at(i
- 1)->url();
655 list
.append(m_remoteViewList
.at(i
- 1)->url().prettyUrl(KUrl::RemoveTrailingSlash
));
657 Settings::setOpenSessions(list
);
660 Settings::self()->writeConfig();
667 void MainWindow::tabChanged(int index
)
669 kDebug(5010) << index
;
671 m_currentRemoteView
= index
- (m_showStartPage
? 1 : 0);
673 QString tabTitle
= m_tabWidget
->tabText(index
).remove('&');
675 setCaption(tabTitle
== i18n("Start Page") ? QString() : tabTitle
);
677 updateActionStatus();
680 void MainWindow::createStartPage()
682 m_showStartPage
= true;
684 QWidget
*startWidget
= new QWidget(this);
685 startWidget
->setStyleSheet("QWidget { background-color: palette(base) }");
687 QVBoxLayout
*startLayout
= new QVBoxLayout(startWidget
);
689 QLabel
*headerLabel
= new QLabel(this);
690 headerLabel
->setText(i18n("<h1>KDE Remote Desktop Client</h1><br /><br />What would you like to do?<br />"));
692 QLabel
*headerIconLabel
= new QLabel(this);
693 headerIconLabel
->setPixmap(KIcon("krdc").pixmap(128));
695 QHBoxLayout
*headerLayout
= new QHBoxLayout
;
696 headerLayout
->setMargin(20);
697 headerLayout
->addWidget(headerLabel
, 1, Qt::AlignTop
);
698 headerLayout
->addWidget(headerIconLabel
);
700 KPushButton
*vncConnectButton
= new KPushButton(this);
701 vncConnectButton
->setStyleSheet("KPushButton { padding: 12px; margin: 10px; }");
702 vncConnectButton
->setIcon(KIcon(actionCollection()->action("new_vnc_connection")->icon()));
703 vncConnectButton
->setText(i18n("Connect to a VNC Remote Desktop"));
704 connect(vncConnectButton
, SIGNAL(clicked()), SLOT(newVncConnection()));
706 vncConnectButton
->setVisible(false);
709 KPushButton
*nxConnectButton
= new KPushButton(this);
710 nxConnectButton
->setStyleSheet("KPushButton { padding: 12px; margin: 10px; }");
711 nxConnectButton
->setIcon(KIcon(actionCollection()->action("new_nx_connection")->icon()));
712 nxConnectButton
->setText(i18n("Connect to a NX Remote Desktop"));
713 connect(nxConnectButton
, SIGNAL(clicked()), SLOT(newNxConnection()));
715 nxConnectButton
->setVisible(false);
718 KPushButton
*rdpConnectButton
= new KPushButton(this);
719 rdpConnectButton
->setStyleSheet("KPushButton { padding: 12px; margin: 10px; }");
720 rdpConnectButton
->setIcon(KIcon(actionCollection()->action("new_rdp_connection")->icon()));
721 rdpConnectButton
->setText(i18n("Connect to a Windows Remote Desktop (RDP)"));
722 connect(rdpConnectButton
, SIGNAL(clicked()), SLOT(newRdpConnection()));
724 rdpConnectButton
->setVisible(false);
727 startLayout
->addLayout(headerLayout
);
728 startLayout
->addWidget(vncConnectButton
);
729 startLayout
->addWidget(nxConnectButton
);
730 startLayout
->addWidget(rdpConnectButton
);
731 startLayout
->addStretch();
733 m_tabWidget
->insertTab(0, startWidget
, KIcon("krdc"), i18n("Start Page"));
736 void MainWindow::newVncConnection()
738 m_addressNavigator
->setUrl(KUrl("vnc://"));
739 m_addressNavigator
->setFocus();
741 QToolTip::showText(m_addressNavigator
->pos() + pos() + QPoint(m_addressNavigator
->width(),
742 m_addressNavigator
->height() + 20),
743 i18n("<html>Enter here the address.<br />"
744 "<i>Example: vncserver:1 (host:port / screen)</i></html>"), this);
747 void MainWindow::newNxConnection()
749 m_addressNavigator
->setUrl(KUrl("nx://"));
750 m_addressNavigator
->setFocus();
752 QToolTip::showText(m_addressNavigator
->pos() + pos() + QPoint(m_addressNavigator
->width(),
753 m_addressNavigator
->height() + 20),
754 i18n("<html>Enter here the address.<br />"
755 "<i>Example: nxserver (host)</i></html>"), this);
758 void MainWindow::newRdpConnection()
760 m_addressNavigator
->setUrl(KUrl("rdp://"));
761 m_addressNavigator
->setFocus();
763 QToolTip::showText(m_addressNavigator
->pos() + pos() + QPoint(m_addressNavigator
->width(),
764 m_addressNavigator
->height() + 20),
765 i18n("<html>Enter here the address. Port is optional.<br />"
766 "<i>Example: rdpserver:3389 (host:port)</i></html>"), this);
769 QList
<RemoteView
*> MainWindow::remoteViewList() const
771 return m_remoteViewList
;
774 int MainWindow::currentRemoteView() const
776 return m_currentRemoteView
;
779 #include "mainwindow.moc"