38 #ifdef TELEPATHY_SUPPORT
43 #include <KActionCollection>
44 #include <KActionMenu>
47 #include <KInputDialog>
52 #include <KMessageBox>
53 #include <KNotifyConfigWidget>
54 #include <KPluginInfo>
55 #include <KPushButton>
57 #include <KToggleAction>
58 #include <KToggleFullScreenAction>
59 #include <KServiceTypeTrader>
62 #include <QDockWidget>
63 #include <QFontMetrics>
65 #include <QHBoxLayout>
66 #include <QHeaderView>
69 #include <QScrollArea>
70 #include <QSortFilterProxyModel>
74 #include <QVBoxLayout>
78 m_fullscreenWindow(0),
82 m_currentRemoteView(-1),
84 m_dockWidgetTableView(0),
85 m_newConnectionTableView(0),
86 #ifdef TELEPATHY_SUPPORT
89 m_newConnectionWidget(0)
95 setStandardToolBarMenuEnabled(
true);
98 m_tabWidget->setMovable(
true);
101 #if QT_VERSION >= 0x040500
107 connect(m_tabWidget, SIGNAL(closeRequest(
QWidget*)), SLOT(closeTab(
QWidget*)));
110 connect(m_tabWidget, SIGNAL(mouseMiddleClick(
QWidget*)), SLOT(closeTab(
QWidget*)));
112 connect(m_tabWidget, SIGNAL(mouseDoubleClick(
QWidget*)), SLOT(openTabSettings(
QWidget*)));
113 connect(m_tabWidget, SIGNAL(mouseDoubleClick()), SLOT(newConnectionPage()));
116 m_tabWidget->setMinimumSize(600, 400);
117 setCentralWidget(m_tabWidget);
121 setupGUI(ToolBar | Keys | Save | Create);
125 if(m_fullscreenWindow) m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);
128 connect(m_tabWidget, SIGNAL(currentChanged(
int)), SLOT(tabChanged(
int)));
131 statusBar()->showMessage(i18n(
"KDE Remote Desktop Client started"));
133 updateActionStatus();
136 m_tabWidget->
addTab(newConnectionWidget(), i18n(
"New Connection"));
146 void MainWindow::setupActions()
148 QAction *connectionAction = actionCollection()->addAction(
"new_connection");
149 connectionAction->
setText(i18n(
"New Connection"));
150 connectionAction->
setIcon(KIcon(
"network-connect"));
151 connect(connectionAction, SIGNAL(triggered()), SLOT(newConnectionPage()));
153 QAction *screenshotAction = actionCollection()->addAction(
"take_screenshot");
154 screenshotAction->
setText(i18n(
"Copy Screenshot to Clipboard"));
156 screenshotAction->
setIcon(KIcon(
"ksnapshot"));
157 connect(screenshotAction, SIGNAL(triggered()), SLOT(takeScreenshot()));
159 KAction *fullscreenAction = actionCollection()->addAction(
"switch_fullscreen");
160 fullscreenAction->setText(i18n(
"Switch to Full Screen Mode"));
161 fullscreenAction->setIconText(i18n(
"Full Screen"));
162 fullscreenAction->setIcon(KIcon(
"view-fullscreen"));
163 fullscreenAction->setShortcut(KStandardShortcut::fullScreen());
164 connect(fullscreenAction, SIGNAL(triggered()), SLOT(switchFullscreen()));
166 QAction *viewOnlyAction = actionCollection()->addAction(
"view_only");
168 viewOnlyAction->
setText(i18n(
"View Only"));
169 viewOnlyAction->
setIcon(KIcon(
"document-preview"));
170 connect(viewOnlyAction, SIGNAL(triggered(
bool)), SLOT(viewOnly(
bool)));
172 KAction *disconnectAction = actionCollection()->addAction(
"disconnect");
173 disconnectAction->setText(i18n(
"Disconnect"));
174 disconnectAction->setIcon(KIcon(
"network-disconnect"));
175 disconnectAction->setShortcut(QKeySequence::Close);
176 connect(disconnectAction, SIGNAL(triggered()), SLOT(disconnectHost()));
178 QAction *showLocalCursorAction = actionCollection()->addAction(
"show_local_cursor");
180 showLocalCursorAction->
setIcon(KIcon(
"input-mouse"));
181 showLocalCursorAction->
setText(i18n(
"Show Local Cursor"));
182 showLocalCursorAction->
setIconText(i18n(
"Local Cursor"));
183 connect(showLocalCursorAction, SIGNAL(triggered(
bool)), SLOT(showLocalCursor(
bool)));
185 QAction *grabAllKeysAction = actionCollection()->addAction(
"grab_all_keys");
187 grabAllKeysAction->
setIcon(KIcon(
"configure-shortcuts"));
188 grabAllKeysAction->
setText(i18n(
"Grab All Possible Keys"));
190 connect(grabAllKeysAction, SIGNAL(triggered(
bool)), SLOT(grabAllKeys(
bool)));
192 QAction *scaleAction = actionCollection()->addAction(
"scale");
194 scaleAction->
setIcon(KIcon(
"zoom-fit-best"));
195 scaleAction->
setText(i18n(
"Scale Remote Screen to Fit Window Size"));
197 connect(scaleAction, SIGNAL(triggered(
bool)), SLOT(scale(
bool)));
199 KStandardAction::quit(
this, SLOT(quit()), actionCollection());
200 KStandardAction::preferences(
this, SLOT(preferences()), actionCollection());
201 QAction *configNotifyAction = KStandardAction::configureNotifications(
this, SLOT(configureNotifications()), actionCollection());
203 m_menubarAction = KStandardAction::showMenubar(
this, SLOT(showMenubar()), actionCollection());
204 m_menubarAction->setChecked(!menuBar()->isHidden());
206 KActionMenu *bookmarkMenu =
new KActionMenu(i18n(
"Bookmarks"), actionCollection());
207 m_bookmarkManager =
new BookmarkManager(actionCollection(), bookmarkMenu->menu(),
this);
208 actionCollection()->addAction(
"bookmark" , bookmarkMenu);
209 connect(m_bookmarkManager, SIGNAL(openUrl(KUrl)), SLOT(
newConnection(KUrl)));
212 void MainWindow::loadAllPlugins()
214 const KService::List offers = KServiceTypeTrader::self()->query(
"KRDC/Plugin");
216 KConfigGroup conf(KGlobal::config(),
"Plugins");
218 for (
int i = 0; i < offers.size(); i++) {
219 KService::Ptr offer = offers[i];
223 KPluginInfo description(offer);
224 description.load(conf);
226 const bool selected = description.isPluginEnabled();
229 if ((remoteView = createPluginFromService(offer)) != 0) {
230 kDebug(5010) <<
"### Plugin " + description.name() +
" found ###";
231 kDebug(5010) <<
"# Version:" << description.version();
232 kDebug(5010) <<
"# Description:" << description.comment();
233 kDebug(5010) <<
"# Author:" << description.author();
234 const int sorting = offer->property(
"X-KDE-KRDC-Sorting").toInt();
235 kDebug(5010) <<
"# Sorting:" << sorting;
237 m_remoteViewFactories.
insert(sorting, remoteView);
239 kDebug(5010) <<
"Error loading KRDC plugin (" << (offers[i])->library() <<
')';
242 kDebug(5010) <<
"# Plugin " + description.name() +
" found, however it's not activated, skipping...";
247 #ifdef TELEPATHY_SUPPORT
254 RemoteViewFactory *MainWindow::createPluginFromService(
const KService::Ptr &service)
257 KPluginFactory *factory = KPluginLoader(service->library()).factory();
260 kError(5010) <<
"KPluginFactory could not load the plugin:" << service->library();
269 void MainWindow::restoreOpenSessions()
280 KUrl MainWindow::getInputUrl()
282 return KUrl(m_protocolInput->currentText() +
"://" + m_addressInput->text());
287 m_switchFullscreenWhenConnected = switchFullscreenWhenConnected;
289 const KUrl url = newUrl.isEmpty() ? getInputUrl() : newUrl;
291 if (!url.isValid() || (url.host().isEmpty() && url.port() < 0)
292 || (!url.path().isEmpty() && url.path() !=
QLatin1String(
"/"))) {
293 KMessageBox::error(
this,
294 i18n(
"The entered address does not have the required form.\n Syntax: [username@]host[:port]"),
295 i18n(
"Malformed URL"));
299 if (m_protocolInput && m_addressInput) {
300 int index = m_protocolInput->findText(url.protocol());
301 if (index>=0) m_protocolInput->setCurrentIndex(index);
302 m_addressInput->setText(url.authority());
306 KConfigGroup configGroup =
Settings::self()->config()->group(
"hostpreferences").group(url.prettyUrl(KUrl::RemoveTrailingSlash));
310 view = factory->
createView(
this, url, configGroup);
317 KMessageBox::error(
this,
318 i18n(
"The entered address cannot be handled."),
319 i18n(
"Unusable URL"));
334 connect(view, SIGNAL(framebufferSizeChanged(
int,
int)),
this, SLOT(resizeTabWidget(
int,
int)));
336 connect(view, SIGNAL(disconnected()),
this, SLOT(disconnectHost()));
339 QScrollArea *scrollArea = createScrollArea(m_tabWidget, view);
341 const int indexOfNewConnectionWidget = m_tabWidget->indexOf(m_newConnectionWidget);
342 if (indexOfNewConnectionWidget >= 0)
343 m_tabWidget->
removeTab(indexOfNewConnectionWidget);
345 const int newIndex = m_tabWidget->
addTab(scrollArea, KIcon(
"krdc"), tabName.
isEmpty() ? url.prettyUrl(KUrl::RemoveTrailingSlash) : tabName);
346 m_tabWidget->setCurrentIndex(newIndex);
347 m_remoteViewMap.
insert(m_tabWidget->widget(newIndex), view);
348 tabChanged(newIndex);
353 void MainWindow::openFromRemoteDesktopsModel(
const QModelIndex &index)
358 const KUrl url(urlString);
360 foreach (
QWidget *widget, m_remoteViewMap.
keys()) {
361 if (m_remoteViewMap.
value(widget)->url() == url) {
362 m_tabWidget->setCurrentWidget(widget);
371 void MainWindow::resizeTabWidget(
int w,
int h)
373 kDebug(5010) <<
"tabwidget resize, view size: w: " << w <<
", h: " << h;
374 if (m_fullscreenWindow) {
375 kDebug(5010) <<
"in fullscreen mode, refusing to resize";
386 if (screenSize == viewSize) {
387 kDebug(5010) <<
"screen size equal to target view size -> switch to fullscreen mode";
394 QWidget* currentWidget = m_tabWidget->currentWidget();
395 const QSize newWindowSize = size() - currentWidget->
frameSize() + viewSize;
398 kDebug(5010) <<
"new window size: " << newWindowSize <<
" available space:" << desktopSize;
400 if ((newWindowSize.
width() >= desktopSize.width()) || (newWindowSize.
height() >= desktopSize.height())) {
401 kDebug(5010) <<
"remote desktop needs more space than available -> show window maximized";
402 setWindowState(windowState() | Qt::WindowMaximized);
406 resize(newWindowSize);
412 kDebug(5010) << status;
426 iconName =
"network-connect";
427 message = i18n(
"Connecting to %1", host);
430 iconName =
"dialog-password";
431 message = i18n(
"Authenticating at %1", host);
434 iconName =
"view-history";
435 message = i18n(
"Preparing connection to %1", host);
439 message = i18n(
"Connected to %1", host);
443 updateActionStatus();
447 if (m_switchFullscreenWhenConnected) {
448 m_switchFullscreenWhenConnected =
false;
461 m_tabWidget->setTabIcon(m_tabWidget->indexOf(view), KIcon(iconName));
463 statusBar()->showMessage(message);
466 void MainWindow::takeScreenshot()
473 void MainWindow::switchFullscreen()
477 if (m_fullscreenWindow) {
480 m_fullscreenWindow->
hide();
483 m_tabWidget->setDocumentMode(
false);
484 setCentralWidget(m_tabWidget);
487 restoreGeometry(m_mainWindowGeometry);
488 if (m_systemTrayIcon) m_systemTrayIcon->setAssociatedWidget(
this);
500 actionCollection()->action(
"switch_fullscreen")->
setIcon(KIcon(
"view-fullscreen"));
501 actionCollection()->action(
"switch_fullscreen")->setText(i18n(
"Switch to Full Screen Mode"));
502 actionCollection()->action(
"switch_fullscreen")->setIconText(i18n(
"Full Screen"));
505 m_fullscreenWindow = 0;
508 m_fullscreenWindow =
new QWidget(
this, Qt::Window);
509 m_fullscreenWindow->
setWindowTitle(i18nc(
"window title when in full screen mode (for example displayed in tasklist)",
510 "KDE Remote Desktop Client (Full Screen)"));
512 m_mainWindowGeometry = saveGeometry();
514 m_tabWidget->setTabBarHidden(
true);
515 m_tabWidget->setDocumentMode(
true);
517 foreach(
RemoteView *currentView, m_remoteViewMap) {
523 fullscreenLayout->
addWidget(m_tabWidget);
525 KToggleFullScreenAction::setFullScreen(m_fullscreenWindow,
true);
528 minimizePixel->
winId();
529 connect(minimizePixel, SIGNAL(rightClicked()), m_fullscreenWindow, SLOT(showMinimized()));
532 m_fullscreenWindow->
show();
535 if (m_systemTrayIcon) m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);
537 actionCollection()->action(
"switch_fullscreen")->setIcon(KIcon(
"view-restore"));
538 actionCollection()->action(
"switch_fullscreen")->setText(i18n(
"Switch to Window Mode"));
539 actionCollection()->action(
"switch_fullscreen")->setIconText(i18n(
"Window Mode"));
540 showRemoteViewToolbar();
542 if (m_tabWidget->currentWidget() == m_newConnectionWidget) {
543 m_addressInput->setFocus();
550 scrollArea->
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
552 connect(scrollArea, SIGNAL(resized(
int,
int)), remoteView, SLOT(scaleResize(
int,
int)));
566 void MainWindow::disconnectHost()
575 m_remoteViewMap.
remove(m_remoteViewMap.
key(view));
577 widgetToDelete = m_tabWidget->currentWidget();
579 m_remoteViewMap.
remove(m_remoteViewMap.
key(view));
585 widgetToDelete->deleteLater();
586 #ifdef TELEPATHY_SUPPORT
587 m_tubesManager->closeTube(view->
url());
591 if (m_tabWidget->count() == 0) {
592 newConnectionPage(
false);
596 if (m_fullscreenWindow && m_tabWidget->count() == 1 && m_tabWidget->currentWidget() == m_newConnectionWidget) {
601 void MainWindow::closeTab(
QWidget *widget)
603 bool isNewConnectionPage = widget == m_newConnectionWidget;
605 if (!isNewConnectionPage) {
607 m_remoteViewMap.
remove(m_remoteViewMap.
key(view));
609 #ifdef TELEPATHY_SUPPORT
610 m_tubesManager->closeTube(view->
url());
618 if (m_tabWidget->count() == 0) {
619 newConnectionPage(
false);
623 if (m_fullscreenWindow && m_tabWidget->count() == 1 && m_tabWidget->currentWidget() == m_newConnectionWidget) {
628 void MainWindow::openTabSettings(
QWidget *widget)
631 if (!scrollArea)
return;
638 showSettingsDialog(url);
641 void MainWindow::showSettingsDialog(
const QString &url)
649 kDebug(5010) <<
"Found plugin to handle url (" + url +
"): " + prefs->
metaObject()->
className();
651 kDebug(5010) <<
"Found plugin to handle url (" + url +
"), but plugin does not provide preferences";
660 KMessageBox::error(
this,
661 i18n(
"The selected host cannot be handled."),
662 i18n(
"Unusable URL"));
666 void MainWindow::showConnectionContextMenu(
const QPoint &pos)
673 if (!index.isValid())
680 KMenu *menu =
new KMenu(m_newConnectionTableView);
683 QAction *connectAction = menu->addAction(KIcon(
"network-connect"), i18n(
"Connect"));
684 QAction *renameAction = menu->addAction(KIcon(
"edit-rename"), i18n(
"Rename"));
685 QAction *settingsAction = menu->addAction(KIcon(
"configure"), i18n(
"Settings"));
686 QAction *deleteAction = menu->addAction(KIcon(
"edit-delete"), i18n(
"Delete"));
689 if (!(source == i18nc(
"Where each displayed link comes from",
"Bookmarks") ||
690 source == i18nc(
"Where each displayed link comes from",
"History"))) {
695 QAction *selectedAction = menu->exec(m_newConnectionTableView->
mapToGlobal(pos + offset));
697 if (selectedAction == connectAction) {
698 openFromRemoteDesktopsModel(index);
699 }
else if (selectedAction == renameAction) {
702 const QString newTitle = KInputDialog::getText(i18n(
"Rename %1", title), i18n(
"Rename %1 to", title), title, &ok,
this);
703 if (ok && !newTitle.
isEmpty()) {
706 }
else if (selectedAction == settingsAction) {
707 showSettingsDialog(url);
708 }
else if (selectedAction == deleteAction) {
710 if (KMessageBox::warningContinueCancel(
this, i18n(
"Are you sure you want to delete %1?", url), i18n(
"Delete %1", title),
711 KStandardGuiItem::del()) == KMessageBox::Continue) {
719 void MainWindow::tabContextMenu(
QWidget *widget,
const QPoint &point)
722 if (!scrollArea)
return;
726 const QString url = view->
url().prettyUrl(KUrl::RemoveTrailingSlash);
729 KMenu *menu =
new KMenu(
this);
731 QAction *bookmarkAction = menu->addAction(KIcon(
"bookmark-new"), i18n(
"Add Bookmark"));
732 QAction *closeAction = menu->addAction(KIcon(
"tab-close"), i18n(
"Close Tab"));
733 QAction *selectedAction = menu->exec(point);
734 if (selectedAction) {
735 if (selectedAction == closeAction) {
737 }
else if (selectedAction == bookmarkAction) {
744 void MainWindow::showLocalCursor(
bool showLocalCursor)
746 kDebug(5010) << showLocalCursor;
754 void MainWindow::viewOnly(
bool viewOnly)
756 kDebug(5010) << viewOnly;
764 void MainWindow::grabAllKeys(
bool grabAllKeys)
774 void MainWindow::scale(
bool scale)
780 if (m_fullscreenWindow)
788 void MainWindow::showRemoteViewToolbar()
793 m_toolBar =
new FloatingToolBar(m_fullscreenWindow, m_fullscreenWindow);
797 KComboBox *sessionComboBox =
new KComboBox(m_toolBar);
798 sessionComboBox->setStyleSheet(
"QComboBox:!editable{background:transparent;}");
799 sessionComboBox->setModel(m_tabWidget->
getModel());
800 sessionComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
801 sessionComboBox->setCurrentIndex(m_tabWidget->currentIndex());
802 connect(sessionComboBox, SIGNAL(activated(
int)), m_tabWidget, SLOT(setCurrentIndex(
int)));
803 connect(m_tabWidget, SIGNAL(currentChanged(
int)), sessionComboBox, SLOT(setCurrentIndex(
int)));
808 buttonBox->
addAction(actionCollection()->action(
"new_connection"));
809 buttonBox->
addAction(actionCollection()->action(
"switch_fullscreen"));
812 minimizeAction->
setIcon(KIcon(
"go-down"));
813 minimizeAction->
setText(i18n(
"Minimize Full Screen Window"));
814 connect(minimizeAction, SIGNAL(triggered()), m_fullscreenWindow, SLOT(showMinimized()));
817 buttonBox->
addAction(actionCollection()->action(
"take_screenshot"));
818 buttonBox->
addAction(actionCollection()->action(
"view_only"));
819 buttonBox->
addAction(actionCollection()->action(
"show_local_cursor"));
820 buttonBox->
addAction(actionCollection()->action(
"grab_all_keys"));
821 buttonBox->
addAction(actionCollection()->action(
"scale"));
822 buttonBox->
addAction(actionCollection()->action(
"disconnect"));
823 buttonBox->
addAction(actionCollection()->action(
"file_quit"));
827 stickToolBarAction->
setIcon(KIcon(
"object-locked"));
828 stickToolBarAction->
setText(i18n(
"Stick Toolbar"));
829 connect(stickToolBarAction, SIGNAL(triggered(
bool)), m_toolBar, SLOT(setSticky(
bool)));
830 buttonBox->
addAction(stickToolBarAction);
843 void MainWindow::updateActionStatus()
845 kDebug(5010) << m_tabWidget->currentIndex();
849 if (m_tabWidget->currentWidget() == m_newConnectionWidget)
854 actionCollection()->action(
"take_screenshot")->
setEnabled(enabled);
855 actionCollection()->action(
"disconnect")->setEnabled(enabled);
870 view ? view->
scaling() :
false);
878 void MainWindow::preferences()
883 if (PreferencesDialog::showDialog(
"preferences"))
892 connect(dialog, SIGNAL(settingsChanged(
QString)),
893 this, SLOT(updateConfiguration()));
898 void MainWindow::updateConfiguration()
901 statusBar()->deleteLater();
903 statusBar()->showMessage(
"");
905 m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && !
Settings::showTabBar()) || m_fullscreenWindow);
907 #if QT_VERSION >= 0x040500
912 disconnect(m_tabWidget, SIGNAL(mouseMiddleClick(
QWidget*)),
this, SLOT(closeTab(
QWidget*)));
914 connect(m_tabWidget, SIGNAL(mouseMiddleClick(
QWidget*)), SLOT(closeTab(
QWidget*)));
918 if(m_fullscreenWindow) m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);
919 }
else if (m_systemTrayIcon) {
920 delete m_systemTrayIcon;
921 m_systemTrayIcon = 0;
925 for (
int i = 0; i < m_tabWidget->count(); ++i) {
926 QPalette palette = m_tabWidget->widget(i)->palette();
928 m_tabWidget->widget(i)->setPalette(palette);
938 void MainWindow::quit(
bool systemEvent)
940 const bool haveRemoteConnections = !m_remoteViewMap.
isEmpty();
941 if (systemEvent || !haveRemoteConnections || KMessageBox::warningContinueCancel(
this,
942 i18n(
"Are you sure you want to quit the KDE Remote Desktop Client?"),
943 i18n(
"Confirm Quit"),
944 KStandardGuiItem::quit(), KStandardGuiItem::cancel(),
945 "DoNotAskBeforeExit") == KMessageBox::Continue) {
950 kDebug(5010) << view->
url();
951 list.
append(view->
url().prettyUrl(KUrl::RemoveTrailingSlash));
968 void MainWindow::configureNotifications()
970 KNotifyConfigWidget::configure(
this);
973 void MainWindow::showMenubar()
975 if (m_menubarAction->isChecked())
984 if (obj == m_fullscreenWindow && event->
type() == QEvent::Close) {
1008 KMainWindow::saveProperties(group);
1024 if (view && view->
scaling()) {
1025 QSize viewSize = m_tabWidget->currentWidget()->size();
1026 kDebug(5010) <<
"saving window size:" << viewSize;
1034 void MainWindow::tabChanged(
int index)
1036 kDebug(5010) << index;
1038 m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && !
Settings::showTabBar()) || m_fullscreenWindow);
1040 m_currentRemoteView = index;
1042 if (m_tabWidget->currentWidget() == m_newConnectionWidget) {
1043 m_currentRemoteView = -1;
1044 if(m_addressInput) m_addressInput->setFocus();
1047 const QString tabTitle = m_tabWidget->tabText(index).remove(
'&');
1048 setCaption(tabTitle == i18n(
"New Connection") ?
QString() : tabTitle);
1050 updateActionStatus();
1053 QWidget* MainWindow::newConnectionWidget()
1055 if (m_newConnectionWidget)
1056 return m_newConnectionWidget;
1058 m_newConnectionWidget =
new QWidget(
this);
1063 QLabel *headerLabel =
new QLabel(m_newConnectionWidget);
1064 headerLabel->
setText(i18n(
"<h1>KDE Remote Desktop Client</h1><br />Enter or select the address of the desktop you would like to connect to."));
1066 QLabel *headerIconLabel =
new QLabel(m_newConnectionWidget);
1067 headerIconLabel->
setPixmap(KIcon(
"krdc").pixmap(80));
1070 headerLayout->
addWidget(headerLabel, 1, Qt::AlignTop);
1071 headerLayout->
addWidget(headerIconLabel);
1082 QLabel *addressLabel =
new QLabel(i18n(
"Connect to:"), m_newConnectionWidget);
1083 m_protocolInput =
new KComboBox(m_newConnectionWidget);
1084 m_addressInput =
new KLineEdit(m_newConnectionWidget);
1085 m_addressInput->setClearButtonShown(
true);
1086 m_addressInput->setClickMessage(i18n(
"Type here to connect to an address and filter the list."));
1087 connect(m_addressInput, SIGNAL(textChanged(
QString)), remoteDesktopsModelProxy, SLOT(setFilterFixedString(
QString)));
1090 m_protocolInput->addItem(factory->
scheme());
1093 connect(m_addressInput, SIGNAL(returnPressed()), SLOT(
newConnection()));
1094 m_addressInput->setToolTip(i18n(
"Type an IP or DNS Name here. Clear the line to get a list of connection methods."));
1096 KPushButton *connectButton =
new KPushButton(m_newConnectionWidget);
1097 connectButton->setToolTip(i18n(
"Goto Address"));
1098 connectButton->setIcon(KIcon(
"go-jump-locationbar"));
1099 connect(connectButton, SIGNAL(clicked()), SLOT(
newConnection()));
1102 connectLayout->
addWidget(m_protocolInput);
1103 connectLayout->
addWidget(m_addressInput, 1);
1104 connectLayout->
addWidget(connectButton);
1110 m_newConnectionTableView =
new QTableView(m_newConnectionWidget);
1111 m_newConnectionTableView->
setModel(remoteDesktopsModelProxy);
1116 m_newConnectionTableView->
setSelectionMode(QAbstractItemView::NoSelection);
1126 connect(m_newConnectionTableView->
horizontalHeader(), SIGNAL(sortIndicatorChanged(
int,Qt::SortOrder)),
1127 SLOT(saveConnectionListSort(
int,Qt::SortOrder)));
1128 connect(m_newConnectionTableView, SIGNAL(doubleClicked(
QModelIndex)),
1131 connect(m_newConnectionTableView, SIGNAL(customContextMenuRequested(
QPoint)), SLOT(showConnectionContextMenu(
QPoint)));
1133 startLayout->
addWidget(m_newConnectionTableView);
1136 return m_newConnectionWidget;
1139 void MainWindow::saveConnectionListSort(
const int logicalindex,
const Qt::SortOrder order)
1146 void MainWindow::newConnectionPage(
bool clearInput)
1148 const int indexOfNewConnectionWidget = m_tabWidget->indexOf(m_newConnectionWidget);
1149 if (indexOfNewConnectionWidget >= 0)
1150 m_tabWidget->setCurrentIndex(indexOfNewConnectionWidget);
1152 const int index = m_tabWidget->
addTab(newConnectionWidget(), i18n(
"New Connection"));
1153 m_tabWidget->setCurrentIndex(index);
1156 m_addressInput->clear();
1158 m_addressInput->selectAll();
1160 m_addressInput->setFocus();
1165 return m_remoteViewMap;
1170 return m_remoteViewFactories.
values();
1175 if (m_currentRemoteView >= 0) {
1176 return m_remoteViewMap.
value(m_tabWidget->widget(m_currentRemoteView));
1182 void MainWindow::createDockWidget()
1185 QWidget *remoteDesktopsDockLayoutWidget =
new QWidget(remoteDesktopsDockWidget);
1187 remoteDesktopsDockWidget->
setObjectName(
"remoteDesktopsDockWidget");
1188 remoteDesktopsDockWidget->
setWindowTitle(i18n(
"Remote Desktops"));
1190 remoteDesktopsDockWidget->
setMinimumWidth(fontMetrics.width(
"vnc://192.168.100.100:6000"));
1191 actionCollection()->addAction(
"remote_desktop_dockwidget",
1194 m_dockWidgetTableView =
new QTableView(remoteDesktopsDockLayoutWidget);
1200 m_dockWidgetTableView->
setModel(remoteDesktopsModelProxy);
1209 for (
int i=0; i < remoteDesktopsModelProxy->
columnCount(); i++) {
1215 connect(m_dockWidgetTableView, SIGNAL(doubleClicked(
QModelIndex)),
1218 KLineEdit *filterLineEdit =
new KLineEdit(remoteDesktopsDockLayoutWidget);
1219 filterLineEdit->setClickMessage(i18n(
"Filter"));
1220 filterLineEdit->setClearButtonShown(
true);
1221 connect(filterLineEdit, SIGNAL(textChanged(
QString)), remoteDesktopsModelProxy, SLOT(setFilterFixedString(
QString)));
1222 remoteDesktopsDockLayout->
addWidget(filterLineEdit);
1223 remoteDesktopsDockLayout->
addWidget(m_dockWidgetTableView);
1224 remoteDesktopsDockWidget->
setWidget(remoteDesktopsDockLayoutWidget);
1225 addDockWidget(Qt::LeftDockWidgetArea, remoteDesktopsDockWidget);
1228 #include "mainwindow.moc"
void setShownWhileConnected(bool connected)
If connected is true, a message is shown that settings might only apply after a reconnect.
void setText(const QString &text)
virtual void saveProperties(KConfigGroup &group)
static int connectionListSortColumn()
Get ConnectionListSortColumn.
virtual QPixmap takeScreenshot()
void setActionStatus(QAction *action, bool enabled, bool visible, bool checked)
Never show local cursor, only the remote one.
bool windowedScale()
Whether scaling is enabled when session is not full screen.
void setContentsMargins(int left, int top, int right, int bottom)
void setFilterCaseSensitivity(Qt::CaseSensitivity cs)
void setAlternatingRowColors(bool enable)
RemoteStatus
State of the connection.
virtual void showDotCursor(DotCursorState state)
Sets the state of the dot cursor, if supported by the backend.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
QList< T > values() const
void setColor(ColorGroup group, ColorRole role, const QColor &color)
void setWindowedScale(bool scale)
virtual void setSourceModel(QAbstractItemModel *sourceModel)
static void setConnectionListSortColumn(int v)
Set ConnectionListSortColumn.
virtual bool supportsScaling() const
Checks whether the backend supports scaling.
bool showDialog(QWidget *parent)
Show the configuration dialog.
void setIconText(const QString &text)
static bool resizeOnConnect()
Get ResizeOnConnect.
static void setOpenSessions(const QStringList &v)
Set Sessions.
void setPixmap(const QPixmap &)
void sortByColumn(int column, Qt::SortOrder order)
void setIcon(const QIcon &icon)
virtual void closeEvent(QCloseEvent *event)
KBookmarkManager * getManager()
void setSortingEnabled(bool enable)
static QStringList openSessions()
Get Sessions.
void newConnection(const KUrl &newUrl=KUrl(), bool switchFullscreenWhenConnected=false, const QString &tabName=QString())
void setFrameStyle(int style)
bool fullscreenScale()
Whether scaling is enabled when session is full screen.
static bool systemTrayIcon()
Get SystemTrayIcon.
Always show local cursor (and the remote one).
RemoteView * currentRemoteView() const
static bool tabMiddleClick()
Get TabMiddleClick.
virtual bool grabAllKeys()
Checks whether grabbing all possible keys is enabled.
Generic widget that displays a remote framebuffer.
virtual bool scaling() const
Checks whether the widget is in scale mode.
void setShowLocalCursor(bool show)
QList< Key > keys() const
virtual QModelIndex indexAt(const QPoint &pos) const
void setFilterRole(int role)
void append(const T &value)
virtual void setModel(QAbstractItemModel *model)
virtual HostPreferences * createHostPreferences(KConfigGroup configGroup, QWidget *parent)=0
Returns a new HostPreferences implementing object or 0 if no settings are available.
void setPixmap(const QPixmap &pixmap, Mode mode)
void installEventFilter(QObject *filterObj)
void setObjectName(const QString &name)
void setGrabAllKeys(bool grab)
virtual DotCursorState dotCursorState() const
Returns the state of the local cursor.
void setItemDelegate(QAbstractItemDelegate *delegate)
MainWindow(QWidget *parent=0)
virtual int columnCount(const QModelIndex &parent) const
virtual HostPreferences * hostPreferences()=0
Returns the current host preferences of this view.
virtual QString scheme() const =0
Returns the supported scheme.
virtual bool eventFilter(QObject *watched, QEvent *event)
void setText(const QString &)
static void updateTitle(KBookmarkManager *manager, const QString &url, const QString &title)
void setShowGrid(bool show)
static QColor backgroundColor()
Get BackgroundColor.
virtual void setViewOnly(bool viewOnly)
Enables/disables the view-only mode.
virtual void setGrabAllKeys(bool grabAllKeys)
Enables/disables grabbing all possible keys.
void showColumn(int column)
void addManualBookmark(const QString &url, const QString &text)
static bool showTabBar()
Get ShowTabBar.
static int connectionListSortOrder()
Get ConnectionListSortOrder.
const Key key(const T &value) const
virtual bool viewOnly()
Checks whether the view is in view-only mode.
static bool rememberHistory()
Get RememberHistory.
void setFullscreenScale(bool scale)
QVariant data(int role) const
virtual void enableScaling(bool scale)
Called to enable or disable scaling.
virtual void startQuitting()
Initiate the disconnection.
virtual void updateConfiguration()
Called when the configuration is changed.
QDesktopWidget * desktop()
static bool fullscreenOnConnect()
Get FullscreenOnConnect.
virtual bool supportsLocalCursor() const
Checks whether the backend supports the concept of local cursors.
void setViewOnly(bool view)
static int tabPosition()
Get TabPosition.
virtual bool supportsUrl(const KUrl &url) const =0
Returns true if the provided url is supported by the current plugin.
virtual bool start()=0
Initialize the view (for example by showing configuration dialogs to the user) and start connecting...
static void removeByUrl(KBookmarkManager *manager, const QString &url, bool ignoreHistory=false, const QString updateTitle=QString())
static bool rememberSessions()
Get RememberSessions.
iterator insert(const Key &key, const T &value)
void addHistoryBookmark(RemoteView *view)
static bool showStatusBar()
Get ShowStatusBar.
virtual RemoteView * createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)=0
Returns a new RemoteView implementing object.
Factory to be implemented by any plugin.
void setHeight(int height)
bool showDialogIfNeeded(QWidget *parent)
Show the configuration dialog if needed, ie.
QList< RemoteViewFactory * > remoteViewFactoriesList() const
bool eventFilter(QObject *obj, QEvent *event)
static void setConnectionListSortOrder(int v)
Set ConnectionListSortOrder.
static bool tabCloseButton()
Get TabCloseButton.
void addLayout(QLayout *layout, int stretch)
const T value(const Key &key) const
QMap< QWidget *, RemoteView * > remoteViewList() const
int remove(const Key &key)
void hideColumn(int column)