Implement new send-special-keys-to-remote-desktop action.
[kdenetwork.git] / krdc / mainwindow.cpp
blob5eb8ca48e4b8569cc5b9bca1bac8074221eafab2
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
4 **
5 ** This file is part of KDE.
6 **
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"
27 #include "settings.h"
28 #include "config/preferencesdialog.h"
29 #include "floatingtoolbar.h"
30 #include "bookmarkmanager.h"
31 #include "specialkeysdialog.h"
32 #ifdef BUILD_RDP
33 #include "rdpview.h"
34 #endif
35 #ifdef BUILD_VNC
36 #include "vncview.h"
37 #endif
39 #include <KAction>
40 #include <KActionCollection>
41 #include <KActionMenu>
42 #include <KApplication>
43 #include <KEditToolBar>
44 #include <KIcon>
45 #include <KLocale>
46 #include <KMenuBar>
47 #include <KMessageBox>
48 #include <KNotifyConfigWidget>
49 #include <KPushButton>
50 #include <KShortcut>
51 #include <KShortcutsDialog>
52 #include <KStatusBar>
53 #include <KTabWidget>
54 #include <KToggleAction>
55 #include <KUrlNavigator>
57 #include <QClipboard>
58 #include <QCloseEvent>
59 #include <QDesktopWidget>
60 #include <QLabel>
61 #include <QLayout>
62 #include <QScrollArea>
63 #include <QTimer>
64 #include <QToolButton>
65 #include <QToolTip>
67 MainWindow::MainWindow(QWidget *parent)
68 : KXmlGuiWindow(parent),
69 m_fullscreenWindow(0),
70 m_toolBar(0),
71 m_topBottomBorder(0),
72 m_leftRightBorder(0),
73 m_currentRemoteView(-1),
74 m_showStartPage(false)
76 setupActions();
78 createGUI("krdcui.rc");
80 setStandardToolBarMenuEnabled(true);
82 m_tabWidget = new KTabWidget(this);
83 m_tabWidget->setMinimumSize(600, 400);
84 setCentralWidget(m_tabWidget);
86 connect(m_tabWidget, SIGNAL(currentChanged(int)), SLOT(tabChanged(int)));
88 statusBar()->showMessage(i18n("KDE Remote Desktop Client started"));
90 updateActionStatus(); // disable remote view actions
92 if (Settings::showStartPage())
93 createStartPage();
96 MainWindow::~MainWindow()
100 void MainWindow::setupActions()
102 QAction *vncConnectionAction = actionCollection()->addAction("new_vnc_connection");
103 vncConnectionAction->setText(i18n("&New VNC Connection..."));
104 vncConnectionAction->setIcon(KIcon("krdc"));
105 connect(vncConnectionAction, SIGNAL(triggered()), SLOT(newVncConnection()));
106 #ifndef BUILD_VNC
107 vncConnectionAction->setVisible(false);
108 #endif
110 QAction *rdpConnectionAction = actionCollection()->addAction("new_rdp_connection");
111 rdpConnectionAction->setText(i18n("&New RDP Connection..."));
112 rdpConnectionAction->setIcon(KIcon("krdc"));
113 connect(rdpConnectionAction, SIGNAL(triggered()), SLOT(newRdpConnection()));
114 #ifndef BUILD_RDP
115 rdpConnectionAction->setVisible(false);
116 #endif
118 QAction *screenshotAction = actionCollection()->addAction("take_screenshot");
119 screenshotAction->setText(i18n("&Copy Screenshot to Clipboard"));
120 screenshotAction->setIcon(KIcon("ksnapshot"));
121 connect(screenshotAction, SIGNAL(triggered()), SLOT(slotTakeScreenshot()));
123 QAction *fullscreenAction = actionCollection()->addAction("switch_fullscreen");
124 fullscreenAction->setText(i18n("&Switch to Fullscreen Mode"));
125 fullscreenAction->setIcon(KIcon("view-fullscreen"));
126 connect(fullscreenAction, SIGNAL(triggered()), SLOT(slotSwitchFullscreen()));
128 QAction *viewOnlyAction = actionCollection()->addAction("view_only");
129 viewOnlyAction->setCheckable(true);
130 viewOnlyAction->setText(i18n("&View Only"));
131 viewOnlyAction->setIcon(KIcon("kgpg-sign-kgpg"));
132 connect(viewOnlyAction, SIGNAL(triggered(bool)), SLOT(slotViewOnly(bool)));
134 QAction *logoutAction = actionCollection()->addAction("logout");
135 logoutAction->setText(i18n("&Log Out"));
136 logoutAction->setIcon(KIcon("system-log-out"));
137 connect(logoutAction, SIGNAL(triggered()), SLOT(slotLogout()));
139 QAction *showLocalCursorAction = actionCollection()->addAction("show_local_cursor");
140 showLocalCursorAction->setCheckable(true);
141 showLocalCursorAction->setIcon(KIcon("input-mouse"));
142 showLocalCursorAction->setText(i18n("S&how Local Cursor"));
143 connect(showLocalCursorAction, SIGNAL(triggered(bool)), SLOT(slotShowLocalCursor(bool)));
145 QAction *specialKeysDialogAction = actionCollection()->addAction("special_keys_dialog");
146 specialKeysDialogAction->setIcon(KIcon("browser-go"));
147 specialKeysDialogAction->setText(i18n("Open Special Keys Dialog..."));
148 connect(specialKeysDialogAction, SIGNAL(triggered()), SLOT(slotSpecialKeyDialog()));
150 QAction *quitAction = KStandardAction::quit(this, SLOT(slotQuit()), actionCollection());
151 actionCollection()->addAction("quit", quitAction);
152 QAction *preferencesAction = KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection());
153 actionCollection()->addAction("preferences", preferencesAction);
154 QAction *configToolbarAction = KStandardAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
155 actionCollection()->addAction("configure_toolbars", configToolbarAction);
156 QAction *keyBindingsAction = KStandardAction::keyBindings(this, SLOT(slotConfigureKeys()), actionCollection());
157 actionCollection()->addAction("configure_keys", keyBindingsAction);
158 QAction *cinfigNotifyAction = KStandardAction::configureNotifications(this, SLOT(slotConfigureNotifications()), actionCollection());
159 actionCollection()->addAction("configure_notifications", cinfigNotifyAction);
160 m_menubarAction = KStandardAction::showMenubar(this, SLOT(slotShowMenubar()), actionCollection());
161 m_menubarAction->setChecked(!menuBar()->isHidden());
162 actionCollection()->addAction("settings_showmenubar", m_menubarAction);
164 m_addressNavigator = new KUrlNavigator(0, KUrl("vnc://"), this);
165 m_addressNavigator->setCustomProtocols(QStringList()
166 #ifdef BUILD_VNC
167 << "vnc"
168 #endif
169 #ifdef BUILD_RDP
170 << "rdp"
171 #endif
173 m_addressNavigator->setUrlEditable(Settings::normalUrlInputLine());
174 connect(m_addressNavigator, SIGNAL(returnPressed()), SLOT(slotNewConnection()));
176 QLabel *addressLabel = new QLabel(i18n("Remote desktop:"), this);
178 QWidget *addressWidget = new QWidget(this);
179 QHBoxLayout *addressLayout = new QHBoxLayout(addressWidget);
180 addressLayout->setMargin(0);
181 addressLayout->addWidget(addressLabel);
182 addressLayout->addWidget(m_addressNavigator, 1);
184 KAction *addressLineAction = new KAction(i18n("Address"), this);
185 actionCollection()->addAction("address_line", addressLineAction);
186 addressLineAction->setDefaultWidget(addressWidget);
188 QAction *gotoAction = actionCollection()->addAction("goto_address");
189 gotoAction->setText(i18n("&Goto Address"));
190 gotoAction->setIcon(KIcon("browser-go"));
191 connect(gotoAction, SIGNAL(triggered()), SLOT(slotNewConnection()));
193 KActionMenu *bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection());
194 m_bookmarkManager = new BookmarkManager(actionCollection(), bookmarkMenu->menu(), this);
195 actionCollection()->addAction("bookmark" , bookmarkMenu);
196 connect(m_bookmarkManager, SIGNAL(openUrl(KUrl)), SLOT(slotNewConnection(KUrl)));
199 void MainWindow::slotNewConnection(const KUrl &newUrl, bool switchFullscreenWhenConnected)
201 m_switchFullscreenWhenConnected = switchFullscreenWhenConnected;
203 KUrl url = newUrl.isEmpty() ? m_addressNavigator->uncommittedUrl() : newUrl;
205 if (!url.isValid()) {
206 KMessageBox::error(this,
207 i18n("The entered address does not have the required form."),
208 i18n("Malformed URL"));
209 return;
212 m_addressNavigator->setUrl(KUrl(url.scheme().toLower() + "://"));
214 QScrollArea *scrollArea = createScrollArea(m_tabWidget, 0);
216 RemoteView *view;
218 #ifdef BUILD_VNC
219 if (url.scheme().toLower() == "vnc") {
220 view = new VncView(scrollArea, url);
222 else
223 #endif
225 #ifdef BUILD_RDP
226 if (url.scheme().toLower() == "rdp") {
227 view = new RdpView(scrollArea, url);
229 else
230 #endif
232 KMessageBox::error(this,
233 i18n("The entered address cannot be handled."),
234 i18n("Unusable URL"));
235 return;
238 connect(view, SIGNAL(changeSize(int, int)), this, SLOT(resizeTabWidget(int, int)));
239 connect(view, SIGNAL(statusChanged(RemoteView::RemoteStatus)), this, SLOT(statusChanged(RemoteView::RemoteStatus)));
241 m_remoteViewList.append(view);
243 view->resize(0, 0);
245 scrollArea->setWidget(m_remoteViewList.at(m_tabWidget->count() - m_showStartPage ? 1 : 0));
247 int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), url.prettyUrl(KUrl::RemoveTrailingSlash));
248 m_tabWidget->setCurrentIndex(newIndex);
250 view->start();
253 void MainWindow::resizeTabWidget(int w, int h)
255 kDebug(5010) << "tabwidget resize: w: " << w << ", h: " << h;
257 if (m_topBottomBorder == 0) { // the values are not cached yet
258 QScrollArea *tmp = qobject_cast<QScrollArea *>(m_tabWidget->currentWidget());
260 m_leftRightBorder = m_tabWidget->width() - m_tabWidget->currentWidget()->width() + (2 * tmp->frameWidth());
261 m_topBottomBorder = m_tabWidget->height() - m_tabWidget->currentWidget()->height() + (2 * tmp->frameWidth());
263 kDebug(5010) << "tabwidget border: w: " << m_leftRightBorder << ", h: " << m_topBottomBorder;
266 int newTabWidth = w + m_leftRightBorder;
267 int newTabHeight = h + m_topBottomBorder;
269 QSize newWindowSize = size() - m_tabWidget->size() + QSize(newTabWidth, newTabHeight);
271 QSize desktopSize = QSize(QApplication::desktop()->availableGeometry().width(),
272 QApplication::desktop()->availableGeometry().height());
274 if ((newWindowSize.height() >= desktopSize.height()) || (newWindowSize.width() >= desktopSize.width())) {
275 kDebug(5010) << "remote desktop needs more place than available -> show window maximized";
276 showMaximized();
277 return;
280 //WORKAROUND: QTabWidget resize problem. Let's see if there is a clean solution for this issue.
281 m_tabWidget->setMinimumSize(newTabWidth, newTabHeight);
282 m_tabWidget->adjustSize();
283 QCoreApplication::processEvents();
284 m_tabWidget->setMinimumSize(500, 400);
287 void MainWindow::statusChanged(RemoteView::RemoteStatus status)
289 kDebug(5010) << "statusChanged: " << status;
291 // the remoteview is already deleted, so don't show it; otherwise it would crash
292 if (status == RemoteView::Disconnecting || status == RemoteView::Disconnected)
293 return;
295 QString host = m_remoteViewList.at(m_currentRemoteView)->host();
297 QString iconName = "krdc";
298 QString message;
300 switch (status) {
301 case RemoteView::Connecting:
302 iconName = "network";
303 message = i18n("Connecting to %1", host);
304 break;
305 case RemoteView::Authenticating:
306 iconName = "password";
307 message = i18n("Authenticating at %1", host);
308 break;
309 case RemoteView::Preparing:
310 iconName = "history";
311 message = i18n("Preparing connection to %1", host);
312 break;
313 case RemoteView::Connected:
314 iconName = "krdc";
315 message = i18n("Connected to %1", host);
317 // when started with command line fullscreen argument
318 if (m_switchFullscreenWhenConnected) {
319 m_switchFullscreenWhenConnected = false;
320 slotSwitchFullscreen();
323 m_bookmarkManager->addHistoryBookmark();
325 break;
326 default:
327 iconName = "krdc";
328 message = QString();
331 m_tabWidget->setTabIcon(m_tabWidget->currentIndex(), KIcon(iconName));
332 statusBar()->showMessage(message);
335 void MainWindow::slotTakeScreenshot()
337 QPixmap snapshot = QPixmap::grabWidget(m_remoteViewList.at(m_currentRemoteView));
339 QApplication::clipboard()->setPixmap(snapshot);
342 void MainWindow::slotSwitchFullscreen()
344 kDebug(5010) << "slotSwitchFullscreen";
346 if (m_fullscreenWindow) {
347 show();
348 restoreGeometry(m_mainWindowGeometry);
350 m_fullscreenWindow->setWindowState(0);
351 m_fullscreenWindow->hide();
353 QScrollArea *scrollArea = createScrollArea(m_tabWidget, m_remoteViewList.at(m_currentRemoteView));
355 int currentTab = m_tabWidget->currentIndex();
356 m_tabWidget->insertTab(currentTab, scrollArea, m_tabWidget->tabIcon(currentTab), m_tabWidget->tabText(currentTab));
357 m_tabWidget->removeTab(m_tabWidget->currentIndex());
358 m_tabWidget->setCurrentIndex(currentTab);
360 resizeTabWidget(m_remoteViewList.at(m_currentRemoteView)->sizeHint().width(),
361 m_remoteViewList.at(m_currentRemoteView)->sizeHint().height());
363 if (m_toolBar) {
364 m_toolBar->hideAndDestroy();
365 m_toolBar = 0;
368 actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-fullscreen"));
369 actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to Fullscreen Mode"));
371 m_fullscreenWindow->deleteLater();
373 m_fullscreenWindow = 0;
374 } else {
375 m_fullscreenWindow = new QWidget(this, Qt::Window);
376 m_fullscreenWindow->setWindowTitle(i18n("KDE Remote Desktop Client (Fullscreen)"));
378 QScrollArea *scrollArea = createScrollArea(m_fullscreenWindow, m_remoteViewList.at(m_currentRemoteView));
379 scrollArea->setFrameShape(QFrame::NoFrame);
381 QVBoxLayout *fullscreenLayout = new QVBoxLayout();
382 fullscreenLayout->setMargin(0);
383 fullscreenLayout->addWidget(scrollArea);
384 m_fullscreenWindow->setLayout(fullscreenLayout);
386 m_fullscreenWindow->show();
388 m_fullscreenWindow->setWindowState(Qt::WindowFullScreen);
390 // show the toolbar after we have switched to fullscreen mode
391 QTimer::singleShot(100, this, SLOT(showRemoteViewToolbar()));
393 m_mainWindowGeometry = saveGeometry();
394 hide();
398 QScrollArea *MainWindow::createScrollArea(QWidget *parent, RemoteView *remoteView)
400 QScrollArea *scrollArea = new QScrollArea(parent);
401 scrollArea->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
403 QPalette palette = scrollArea->palette();
404 palette.setColor(QPalette::Dark, Settings::backgroundColor());
405 scrollArea->setPalette(palette);
407 scrollArea->setBackgroundRole(QPalette::Dark);
408 scrollArea->setWidget(remoteView);
410 return scrollArea;
413 void MainWindow::slotLogout()
415 kDebug(5010) << "slotLogout";
417 if (m_fullscreenWindow) { // first close fullscreen view
418 slotSwitchFullscreen();
421 QWidget *tmp = m_tabWidget->currentWidget();
423 m_remoteViewList.removeAt(m_currentRemoteView);
425 m_tabWidget->removeTab(m_tabWidget->currentIndex());
427 tmp->deleteLater();
429 updateActionStatus();
432 void MainWindow::slotShowLocalCursor(bool showLocalCursor)
434 kDebug(5010) << "slotShowLocalCursor";
436 m_remoteViewList.at(m_currentRemoteView)->showDotCursor(showLocalCursor ? RemoteView::CursorOn : RemoteView::CursorOff);
439 void MainWindow::slotViewOnly(bool viewOnly)
441 kDebug(5010) << "slotViewOnly";
443 m_remoteViewList.at(m_currentRemoteView)->setViewOnly(viewOnly);
446 void MainWindow::slotSpecialKeyDialog()
448 kDebug(5010) << "slotSpecialKeyDialog";
450 SpecialKeysDialog dialog(this, m_remoteViewList.at(m_currentRemoteView));
451 dialog.exec();
454 void MainWindow::showRemoteViewToolbar()
456 kDebug(5010) << "showRemoteViewToolbar";
458 m_remoteViewList.at(m_currentRemoteView)->repaint(); // be sure there are no artifacts on the remote view
460 if (!m_toolBar) {
461 actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-restore"));
462 actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to Window Mode"));
464 m_toolBar = new FloatingToolBar(m_fullscreenWindow, m_fullscreenWindow);
465 m_toolBar->setSide(FloatingToolBar::Top);
466 m_toolBar->addAction(actionCollection()->action("switch_fullscreen"));
467 m_toolBar->addAction(actionCollection()->action("take_screenshot"));
468 m_toolBar->addAction(actionCollection()->action("view_only"));
469 m_toolBar->addAction(actionCollection()->action("show_local_cursor"));
470 m_toolBar->addAction(actionCollection()->action("special_keys_dialog"));
471 m_toolBar->addAction(actionCollection()->action("logout"));
473 QAction *stickToolBarAction = new QAction(m_toolBar);
474 stickToolBarAction->setCheckable(true);
475 stickToolBarAction->setIcon(KIcon("note2"));
476 stickToolBarAction->setText(i18n("S&tick Toolbar"));
477 connect(stickToolBarAction, SIGNAL(triggered(bool)), m_toolBar, SLOT(setSticky(bool)));
479 m_toolBar->addAction(stickToolBarAction);
482 m_toolBar->showAndAnimate();
485 void MainWindow::updateActionStatus()
487 kDebug(5010) << "updateActionStatus = " << m_tabWidget->currentIndex();
489 bool enabled;
491 if ((m_showStartPage && (m_tabWidget->currentIndex() == 0)) ||
492 (!m_showStartPage && (m_tabWidget->currentIndex() < 0)))
493 enabled = false;
494 else
495 enabled = true;
497 actionCollection()->action("switch_fullscreen")->setEnabled(enabled);
498 actionCollection()->action("take_screenshot")->setEnabled(enabled);
499 actionCollection()->action("view_only")->setEnabled(enabled);
500 actionCollection()->action("special_keys_dialog")->setEnabled(enabled);
501 actionCollection()->action("logout")->setEnabled(enabled);
503 bool viewOnlyChecked = false;
504 if (m_currentRemoteView >= 0)
505 viewOnlyChecked = enabled && m_remoteViewList.at(m_currentRemoteView)->viewOnly();
506 actionCollection()->action("view_only")->setChecked(viewOnlyChecked);
508 bool showLocalCursorChecked = false;
509 if (m_currentRemoteView >= 0)
510 showLocalCursorChecked = enabled && m_remoteViewList.at(m_currentRemoteView)->dotCursorState() == RemoteView::CursorOn;
511 actionCollection()->action("show_local_cursor")->setChecked(showLocalCursorChecked);
513 bool showLocalCursorVisible = false;
514 if (m_currentRemoteView >= 0)
515 showLocalCursorVisible = enabled && m_remoteViewList.at(m_currentRemoteView)->supportsLocalCursor();
516 actionCollection()->action("show_local_cursor")->setVisible(showLocalCursorVisible);
519 void MainWindow::slotPreferences()
521 // An instance of your dialog could be already created and could be
522 // cached, in which case you want to display the cached dialog
523 // instead of creating another one
524 if (PreferencesDialog::showDialog("preferences"))
525 return;
527 // KConfigDialog didn't find an instance of this dialog, so lets
528 // create it:
529 PreferencesDialog *dialog = new PreferencesDialog(this, Settings::self());
531 // User edited the configuration - update your local copies of the
532 // configuration data
533 connect(dialog, SIGNAL(settingsChanged(const QString&)),
534 this, SLOT(updateConfiguration()));
536 dialog->show();
539 void MainWindow::updateConfiguration()
541 m_addressNavigator->setUrlEditable(Settings::normalUrlInputLine());
543 if (Settings::showStartPage() && !m_showStartPage)
544 createStartPage();
545 else if (!Settings::showStartPage() && m_showStartPage) {
546 m_tabWidget->removeTab(0);
547 m_showStartPage = false;
549 updateActionStatus();
551 // update the scroll areas background color
552 for (int i = m_showStartPage ? 1 : 0; i < m_tabWidget->count(); i++) {
553 QPalette palette = m_tabWidget->widget(i)->palette();
554 palette.setColor(QPalette::Dark, Settings::backgroundColor());
555 m_tabWidget->widget(i)->setPalette(palette);
559 void MainWindow::slotQuit()
561 close();
564 void MainWindow::slotConfigureNotifications()
566 KNotifyConfigWidget::configure(this);
569 void MainWindow::slotConfigureKeys()
571 KShortcutsDialog::configure(actionCollection());
574 void MainWindow::slotConfigureToolbars()
576 KEditToolBar edit(actionCollection());
577 connect(&edit, SIGNAL(newToolbarConfig()), this, SLOT(slotNewToolbarConfig()));
578 edit.exec();
581 void MainWindow::slotShowMenubar()
583 if (m_menubarAction->isChecked())
584 menuBar()->show();
585 else
586 menuBar()->hide();
589 void MainWindow::closeEvent(QCloseEvent *event)
591 if (KMessageBox::warningYesNoCancel(this,
592 i18n("Are you sure you want to close the KDE Remote Desktop Client?"),
593 i18n("Confirm Quit"),
594 KStandardGuiItem::yes(), KStandardGuiItem::no(), KStandardGuiItem::cancel(),
595 "AskBeforeExit") == KMessageBox::Yes) {
597 Settings::self()->writeConfig();
598 event->accept();
599 } else
600 event->ignore();
603 void MainWindow::tabChanged(int index)
605 kDebug(5010) << "tabChanged: " << index;
607 m_currentRemoteView = index - (m_showStartPage ? 1 : 0);
609 QString tabTitle = m_tabWidget->tabText(index).remove('&');
611 setCaption(tabTitle == i18n("Start Page") ? QString() : tabTitle);
613 updateActionStatus();
616 void MainWindow::createStartPage()
618 m_showStartPage = true;
620 QWidget *startWidget = new QWidget(this);
621 startWidget->setStyleSheet("QWidget { background-color: palette(base) }");
623 QVBoxLayout *startLayout = new QVBoxLayout(startWidget);
625 QLabel *headerLabel = new QLabel(this);
626 headerLabel->setText(i18n("<h1>KDE Remote Desktop Client</h1><br />What would you like to do?"));
628 QLabel *headerIconLabel = new QLabel(this);
629 headerIconLabel->setPixmap(KIcon("krdc").pixmap(48));
631 QHBoxLayout *headerLayout = new QHBoxLayout;
632 headerLayout->setMargin(20);
633 headerLayout->addWidget(headerLabel, 1, Qt::AlignTop);
634 headerLayout->addWidget(headerIconLabel);
636 KPushButton *vncConnectButton = new KPushButton(this);
637 vncConnectButton->setStyleSheet("KPushButton { padding: 12px; margin: 10px; }");
638 vncConnectButton->setIcon(KIcon(actionCollection()->action("new_vnc_connection")->icon()));
639 vncConnectButton->setText(i18n("Connect to a VNC Remote Desktop"));
640 connect(vncConnectButton, SIGNAL(clicked()), SLOT(newVncConnection()));
641 #ifndef BUILD_VNC
642 vncConnectButton->setVisible(false);
643 #endif
645 KPushButton *rdpConnectButton = new KPushButton(this);
646 rdpConnectButton->setStyleSheet("KPushButton { padding: 12px; margin: 10px; }");
647 rdpConnectButton->setIcon(KIcon(actionCollection()->action("new_rdp_connection")->icon()));
648 rdpConnectButton->setText(i18n("Connect to a Windows Remote Desktop (RDP)"));
649 connect(rdpConnectButton, SIGNAL(clicked()), SLOT(newRdpConnection()));
650 #ifndef BUILD_RDP
651 rdpConnectButton->setVisible(false);
652 #endif
654 startLayout->addLayout(headerLayout);
655 startLayout->addWidget(vncConnectButton);
656 startLayout->addWidget(rdpConnectButton);
657 startLayout->addStretch();
659 m_tabWidget->insertTab(0, startWidget, KIcon("krdc"), i18n("Start Page"));
662 void MainWindow::newVncConnection()
664 m_addressNavigator->setUrl(KUrl("vnc://"));
665 m_addressNavigator->setFocus();
667 QToolTip::showText(m_addressNavigator->pos() + pos() + QPoint(m_addressNavigator->width(),
668 m_addressNavigator->height() + 20),
669 i18n("Enter here the address.<br />"
670 "<i>Example: vncserver:1 (host:port / screen)</i>"), this);
673 void MainWindow::newRdpConnection()
675 m_addressNavigator->setUrl(KUrl("rdp://"));
676 m_addressNavigator->setFocus();
678 QToolTip::showText(m_addressNavigator->pos() + pos() + QPoint(m_addressNavigator->width(),
679 m_addressNavigator->height() + 20),
680 i18n("Enter here the address. Port is optional.<br />"
681 "<i>Example: rdpserver:3389 (host:port)</i>"), this);
684 QList<RemoteView *> MainWindow::remoteViewList() const
686 return m_remoteViewList;
689 int MainWindow::currentRemoteView() const
691 return m_currentRemoteView;
694 #include "mainwindow.moc"