mirror of
https://invent.kde.org/network/krdc
synced 2024-07-08 20:05:56 +00:00
Port krdc to Qt5/KF5 using Ulo Parri's review as a starting point.
This commit is contained in:
parent
c8789dd654
commit
088d7b9cd6
159
CMakeLists.txt
159
CMakeLists.txt
|
@ -1,53 +1,95 @@
|
|||
cmake_minimum_required(VERSION 2.8.9)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(krdc)
|
||||
|
||||
if(NOT INSIDE_KDENETWORK)
|
||||
message("Not building inside KDENetwork, loading KDE CMake Macros.")
|
||||
set (KDE_APPLICATIONS_VERSION_MAJOR "15")
|
||||
set (KDE_APPLICATIONS_VERSION_MINOR "12")
|
||||
set (KDE_APPLICATIONS_VERSION_MICRO "0")
|
||||
|
||||
find_package(KDE4 REQUIRED)
|
||||
set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
|
||||
|
||||
include(KDE4Defaults)
|
||||
include(MacroLibrary)
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
|
||||
include(CheckIncludeFile)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
include(CheckPrototypeExists)
|
||||
include(CheckTypeSize)
|
||||
find_package(KF5 REQUIRED COMPONENTS
|
||||
Config
|
||||
KCMUtils
|
||||
DNSSD
|
||||
NotifyConfig
|
||||
Notifications
|
||||
Bookmarks
|
||||
IconThemes
|
||||
XmlGui
|
||||
Completion
|
||||
Wallet
|
||||
WidgetsAddons
|
||||
NotifyConfig
|
||||
I18n
|
||||
)
|
||||
|
||||
set(CMAKE_REQUIRED_DEFINITIONS ${_KDE4_PLATFORM_DEFINITIONS})
|
||||
if(WIN32)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES})
|
||||
endif(WIN32)
|
||||
add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
||||
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
|
||||
endif(NOT INSIDE_KDENETWORK)
|
||||
find_package(KF5 COMPONENTS DocTools)
|
||||
|
||||
include(ECMSetupVersion)
|
||||
include(KDEInstallDirs)
|
||||
include(KDECompilerSettings)
|
||||
include(KDECMakeSettings)
|
||||
include(FeatureSummary)
|
||||
|
||||
# use sane compile flags
|
||||
add_definitions(
|
||||
-DQT_USE_QSTRINGBUILDER
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
-DQT_NO_CAST_FROM_ASCII
|
||||
-DQT_STRICT_ITERATORS
|
||||
-DQT_NO_URL_CAST_FROM_STRING
|
||||
-DQT_NO_CAST_FROM_BYTEARRAY
|
||||
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
|
||||
-DQT_USE_FAST_OPERATOR_PLUS
|
||||
)
|
||||
ecm_setup_version(${KDE_APPLICATIONS_VERSION}
|
||||
VARIABLE_PREFIX KRDC
|
||||
SOVERSION 5
|
||||
VERSION_HEADER krdc_version.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES})
|
||||
endif(WIN32)
|
||||
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
||||
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||
|
||||
macro_optional_find_package(LibVNCServer)
|
||||
macro_log_feature(LIBVNCSERVER_FOUND "libvncserver" "VNC server / client library" "http://libvncserver.sourceforge.net/" FALSE "0.9.8" "Needed to build VNC client support in KRDC")
|
||||
|
||||
FIND_PROGRAM(FREERDP_EXECUTABLE xfreerdp)
|
||||
if(FREERDP_EXECUTABLE)
|
||||
set(FREERDP_EXECUTABLE_FOUND true)
|
||||
endif(FREERDP_EXECUTABLE)
|
||||
macro_log_feature(FREERDP_EXECUTABLE_FOUND "freerdp" "A free Remote Desktop Protocol (RDP) Implementation" "http://www.freerdp.com" FALSE "1.0.2" "Needed for RDP support in KRDC (at runtime)")
|
||||
find_package(LibVNCServer)
|
||||
set_package_properties("libvncserver" PROPERTIES
|
||||
DESCRIPTION "VNC server / client library"
|
||||
URL "http://libvncserver.sourceforge.net/"
|
||||
PURPOSE "Needed to build VNC client support in KRDC"
|
||||
)
|
||||
|
||||
# Needs porting
|
||||
# FIND_PROGRAM(FREERDP_EXECUTABLE xfreerdp)
|
||||
# if(FREERDP_EXECUTABLE)
|
||||
# set(FREERDP_EXECUTABLE_FOUND true)
|
||||
# endif(FREERDP_EXECUTABLE)
|
||||
#
|
||||
# set_package_properties("freerdp" PROPERTIES
|
||||
# DESCRIPTION "A free Remote Desktop Protocol (RDP) Implementation"
|
||||
# URL "http://www.freerdp.com"
|
||||
# PURPOSE "Needed for RDP support in KRDC (at runtime)"
|
||||
# )
|
||||
# NX support is not ready for KDE 4.2; disabled (uwolfer)
|
||||
# macro_optional_find_package(LibNXCL)
|
||||
# macro_log_feature(LIBNXCL_FOUND "libnxcl" "NX X compression client library" "http://svn.berlios.de/svnroot/repos/freenx/trunk/freenx-client/nxcl/" FALSE "1.0" "Needed to build Krdc with NX support")
|
||||
|
||||
macro_optional_find_package(TelepathyQt4)
|
||||
macro_log_feature(TelepathyQt4_FOUND "telepathy-qt" "Telepathy Qt Bindings" "http://telepathy.freedesktop.org" FALSE "0.9" "Needed to build Telepathy Tubes support.")
|
||||
find_package(TelepathyQt5)
|
||||
set_package_properties("telepathy-qt" PROPERTIES
|
||||
DESCRIPTION "Telepathy Qt Bindings"
|
||||
URL "http://telepathy.freedesktop.org"
|
||||
PURPOSE "Needed to build Telepathy Tubes support.")
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
if(TelepathyQt5_FOUND)
|
||||
add_definitions(-DTELEPATHY_SUPPORT)
|
||||
include_directories(${TELEPATHY_QT4_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
|
@ -62,18 +104,19 @@ add_subdirectory(vnc)
|
|||
add_subdirectory(nx)
|
||||
add_subdirectory(rdp)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(doc)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
add_subdirectory(krdc_approver)
|
||||
if(KF5DocTools_FOUND)
|
||||
add_subdirectory(doc)
|
||||
else()
|
||||
message("KF5DocTools not found. Not building documentation.")
|
||||
endif()
|
||||
|
||||
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5010)
|
||||
add_definitions(-DBUILD_ZEROCONF)
|
||||
|
||||
set(krdc_SRCS
|
||||
config/hostpreferenceslist.cpp
|
||||
config/preferencesdialog.cpp
|
||||
core/logging.cpp
|
||||
floatingtoolbar.cpp
|
||||
bookmarkmanager.cpp
|
||||
connectiondelegate.cpp
|
||||
|
@ -84,42 +127,46 @@ set(krdc_SRCS
|
|||
main.cpp
|
||||
)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
if(TelepathyQt5_FOUND)
|
||||
add_subdirectory(krdc_approver)
|
||||
set(krdc_SRCS ${krdc_SRCS}
|
||||
tubesmanager.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
kde4_add_ui_files(krdc_SRCS
|
||||
ki18n_wrap_ui(krdc_SRCS
|
||||
config/general.ui
|
||||
)
|
||||
|
||||
kde4_add_app_icon(krdc_SRCS "${KDE4_INSTALL_DIR}/share/icons/oxygen/*/apps/krdc.png")
|
||||
|
||||
kde4_add_executable(krdc ${krdc_SRCS})
|
||||
add_executable(krdc ${krdc_SRCS})
|
||||
|
||||
target_link_libraries(krdc
|
||||
${KDE4_KFILE_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KNOTIFYCONFIG_LIBS}
|
||||
${KDE4_KCMUTILS_LIBS}
|
||||
KF5::ConfigCore
|
||||
KF5::KCMUtils
|
||||
KF5::DNSSD
|
||||
KF5::NotifyConfig
|
||||
KF5::Bookmarks
|
||||
KF5::IconThemes
|
||||
KF5::XmlGui
|
||||
KF5::Completion
|
||||
KF5::WidgetsAddons
|
||||
KF5::NotifyConfig
|
||||
KF5::Notifications
|
||||
krdccore
|
||||
)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
if(TelepathyQt5_FOUND)
|
||||
target_link_libraries(krdc
|
||||
${TELEPATHY_QT4_LIBRARIES}
|
||||
${TELEPATHY_QT5_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(krdc ${KDE4_KDNSSD_LIBS})
|
||||
|
||||
install(TARGETS krdc ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
install(FILES krdcui.rc DESTINATION ${DATA_INSTALL_DIR}/krdc)
|
||||
install(PROGRAMS krdc.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
|
||||
install(FILES krdcui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/krdc)
|
||||
install(PROGRAMS org.kde.krdc.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
|
||||
install(FILES pointcursor.png pointcursormask.png DESTINATION ${DATA_INSTALL_DIR}/krdc/pics)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
if(TelepathyQt5_FOUND)
|
||||
configure_file(org.freedesktop.Telepathy.Client.krdc_rfb_handler.service.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.krdc_rfb_handler.service)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.krdc_rfb_handler.service
|
||||
|
@ -128,6 +175,4 @@ if(TelepathyQt4_FOUND)
|
|||
install(FILES krdc_rfb_handler.client DESTINATION ${SHARE_INSTALL_PREFIX}/telepathy/clients/)
|
||||
endif()
|
||||
|
||||
if(NOT INSIDE_KDENETWORK)
|
||||
macro_display_feature_log()
|
||||
endif(NOT INSIDE_KDENETWORK)
|
||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
|
|
@ -22,36 +22,38 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "bookmarkmanager.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <KBookmarkMenu>
|
||||
#include <KStandardDirs>
|
||||
#include <KDebug>
|
||||
#include <KBookmarks/KBookmarkOwner>
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
BookmarkManager::BookmarkManager(KActionCollection *collection, KMenu *menu, MainWindow *parent)
|
||||
#include <QStandardPaths>
|
||||
|
||||
BookmarkManager::BookmarkManager(KActionCollection *collection, QMenu *menu, MainWindow *parent)
|
||||
: QObject(parent),
|
||||
KBookmarkOwner(),
|
||||
m_mainWindow(parent)
|
||||
{
|
||||
const QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
|
||||
|
||||
m_manager = KBookmarkManager::managerForFile(file, "krdc");
|
||||
const QString dir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString(),
|
||||
QStandardPaths::LocateOption::LocateDirectory);
|
||||
const QString file = dir + QLatin1String("/krdc/bookmarks.xml");
|
||||
m_manager = KBookmarkManager::managerForFile(file, QLatin1String("krdc"));
|
||||
m_manager->setUpdate(true);
|
||||
m_bookmarkMenu = new KBookmarkMenu(m_manager, this, menu, collection);
|
||||
|
||||
KBookmarkGroup root = m_manager->root();
|
||||
KBookmark bm = root.first();
|
||||
while (!bm.isNull()) {
|
||||
if (bm.metaDataItem("krdc-history") == "historyfolder") // get it also when user renamed it
|
||||
if (bm.metaDataItem(QLatin1String("krdc-history")) == QLatin1String("historyfolder")) // get it also when user renamed it
|
||||
break;
|
||||
bm = root.next(bm);
|
||||
}
|
||||
|
||||
if (bm.isNull()) {
|
||||
kDebug(5010) << "History folder not found. Create it.";
|
||||
qCDebug(KRDC) << "History folder not found. Create it.";
|
||||
bm = m_manager->root().createNewFolder(i18n("History"));
|
||||
bm.setMetaDataItem("krdc-history", "historyfolder");
|
||||
bm.setMetaDataItem(QStringLiteral("krdc-history"), QStringLiteral("historyfolder"));
|
||||
m_manager->emitChanged();
|
||||
}
|
||||
|
||||
|
@ -67,10 +69,10 @@ void BookmarkManager::addHistoryBookmark(RemoteView *view)
|
|||
{
|
||||
KBookmark bm = m_historyGroup.first();
|
||||
const QString urlString = urlForView(view);
|
||||
const KUrl url = KUrl(urlString);
|
||||
const QUrl url = QUrl(urlString);
|
||||
while (!bm.isNull()) {
|
||||
if (bm.url() == url) {
|
||||
kDebug(5010) << "Found URL. Move it at the history start.";
|
||||
qCDebug(KRDC) << "Found URL. Move it at the history start.";
|
||||
m_historyGroup.moveBookmark(bm, KBookmark());
|
||||
bm.updateAccessMetadata();
|
||||
m_manager->emitChanged(m_historyGroup);
|
||||
|
@ -80,8 +82,8 @@ void BookmarkManager::addHistoryBookmark(RemoteView *view)
|
|||
}
|
||||
|
||||
if (bm.isNull()) {
|
||||
kDebug(5010) << "Add new history bookmark.";
|
||||
bm = m_historyGroup.addBookmark(titleForUrl(urlString), urlString);
|
||||
qCDebug(KRDC) << "Add new history bookmark.";
|
||||
bm = m_historyGroup.addBookmark(titleForUrl(url), url, QString());
|
||||
bm.updateAccessMetadata();
|
||||
m_historyGroup.moveBookmark(bm, KBookmark());
|
||||
m_manager->emitChanged(m_historyGroup);
|
||||
|
@ -112,19 +114,18 @@ bool BookmarkManager::editBookmarkEntry() const
|
|||
return true;
|
||||
}
|
||||
|
||||
QString BookmarkManager::currentUrl() const
|
||||
QUrl BookmarkManager::currentUrl() const
|
||||
{
|
||||
RemoteView *view = m_mainWindow->currentRemoteView();
|
||||
if (view)
|
||||
return urlForView(view);
|
||||
return QUrl(urlForView(view));
|
||||
else
|
||||
return QString();
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
QString BookmarkManager::urlForView(RemoteView *view) const
|
||||
{
|
||||
return view->url().prettyUrl(KUrl::RemoveTrailingSlash);
|
||||
|
||||
return view->url().toDisplayString(QUrl::UrlFormattingOption::StripTrailingSlash);
|
||||
}
|
||||
|
||||
QString BookmarkManager::currentTitle() const
|
||||
|
@ -132,10 +133,9 @@ QString BookmarkManager::currentTitle() const
|
|||
return titleForUrl(currentUrl());
|
||||
}
|
||||
|
||||
QString BookmarkManager::titleForUrl(const QString &url) const
|
||||
QString BookmarkManager::titleForUrl(const QUrl &url) const
|
||||
{
|
||||
return QUrl::fromPercentEncoding(url.toUtf8());
|
||||
|
||||
return url.toDisplayString(QUrl::UrlFormattingOption::StripTrailingSlash);
|
||||
}
|
||||
|
||||
bool BookmarkManager::supportsTabs() const
|
||||
|
@ -143,24 +143,26 @@ bool BookmarkManager::supportsTabs() const
|
|||
return true;
|
||||
}
|
||||
|
||||
QList<QPair<QString, QString> > BookmarkManager::currentBookmarkList() const
|
||||
QList<KBookmarkOwner::FutureBookmark> BookmarkManager::currentBookmarkList() const
|
||||
{
|
||||
QList<QPair<QString, QString> > list;
|
||||
QList<KBookmarkOwner::FutureBookmark> list;
|
||||
|
||||
QMapIterator<QWidget *, RemoteView *> iter(m_mainWindow->remoteViewList());
|
||||
|
||||
while (iter.hasNext()) {
|
||||
RemoteView *next = iter.next().value();
|
||||
const QString url = next->url().prettyUrl(KUrl::RemoveTrailingSlash);
|
||||
list << QPair<QString, QString>(url, url);
|
||||
const QUrl url = next->url();
|
||||
const QString title = titleForUrl(url);
|
||||
KBookmarkOwner::FutureBookmark bookmark = KBookmarkOwner::FutureBookmark(title, url, QString());
|
||||
list.append(bookmark);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void BookmarkManager::addManualBookmark(const QString &url, const QString &text)
|
||||
void BookmarkManager::addManualBookmark(const QUrl &url, const QString &text)
|
||||
{
|
||||
m_manager->root().addBookmark(url, text);
|
||||
m_manager->root().addBookmark(text, url, QString());
|
||||
emit m_manager->emitChanged();
|
||||
}
|
||||
|
||||
|
@ -178,7 +180,7 @@ const QStringList BookmarkManager::findBookmarkAddresses(const KBookmarkGroup &g
|
|||
bookmarkAddresses.append(findBookmarkAddresses(bm.toGroup(), url));
|
||||
}
|
||||
|
||||
if (bm.url() == url) {
|
||||
if (bm.url() == QUrl::fromLocalFile(url)) {
|
||||
bookmarkAddresses.append(bm.address());
|
||||
}
|
||||
bm = group.next(bm);
|
||||
|
@ -190,14 +192,14 @@ void BookmarkManager::removeByUrl(KBookmarkManager *manager, const QString &url,
|
|||
{
|
||||
foreach(const QString &address, findBookmarkAddresses(manager->root(), url)) {
|
||||
KBookmark bm = manager->findByAddress(address);
|
||||
if (ignoreHistory && bm.parentGroup().metaDataItem("krdc-history") == "historyfolder") {
|
||||
if (ignoreHistory && bm.parentGroup().metaDataItem(QLatin1String("krdc-history")) == QLatin1String("historyfolder")) {
|
||||
if (!updateTitle.isEmpty()) {
|
||||
kDebug(5010) << "Update" << bm.fullText();
|
||||
qCDebug(KRDC) << "Update" << bm.fullText();
|
||||
bm.setFullText(updateTitle);
|
||||
}
|
||||
} else {
|
||||
if (!bm.isGroup()) { // please don't delete groups... happened in testing
|
||||
kDebug(5010) << "Delete" << bm.fullText();
|
||||
qCDebug(KRDC) << "Delete" << bm.fullText();
|
||||
bm.parentGroup().deleteBookmark(bm);
|
||||
}
|
||||
}
|
||||
|
@ -211,9 +213,9 @@ void BookmarkManager::updateTitle(KBookmarkManager *manager, const QString &url,
|
|||
foreach(const QString &address, findBookmarkAddresses(manager->root(), url)) {
|
||||
KBookmark bm = manager->findByAddress(address);
|
||||
bm.setFullText(title);
|
||||
kDebug(5010) << "Update" << bm.fullText();
|
||||
qCDebug(KRDC) << "Update" << bm.fullText();
|
||||
}
|
||||
manager->emitChanged();
|
||||
}
|
||||
|
||||
#include "bookmarkmanager.moc"
|
||||
|
||||
|
|
|
@ -27,9 +27,10 @@
|
|||
#include "core/remoteview.h"
|
||||
|
||||
#include <KBookmarkManager>
|
||||
#include <KXmlGui/KActionCollection>
|
||||
#include <KBookmarks/KBookmarkMenu>
|
||||
|
||||
class KActionCollection;
|
||||
class KBookmarkMenu;
|
||||
#include <QMenu>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
|
@ -38,17 +39,17 @@ class BookmarkManager : public QObject, public KBookmarkOwner
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BookmarkManager(KActionCollection *collection, KMenu *menu, MainWindow *parent);
|
||||
BookmarkManager(KActionCollection *collection, QMenu *menu, MainWindow *parent);
|
||||
~BookmarkManager();
|
||||
|
||||
virtual QString currentUrl() const;
|
||||
virtual QString currentTitle() const;
|
||||
virtual QUrl currentUrl() const Q_DECL_OVERRIDE;
|
||||
virtual QString currentTitle() const Q_DECL_OVERRIDE;
|
||||
virtual bool addBookmarkEntry() const;
|
||||
virtual bool editBookmarkEntry() const;
|
||||
virtual bool supportsTabs() const;
|
||||
virtual QList<QPair<QString, QString> > currentBookmarkList() const;
|
||||
virtual bool supportsTabs() const Q_DECL_OVERRIDE;
|
||||
virtual QList<KBookmarkOwner::FutureBookmark> currentBookmarkList() const Q_DECL_OVERRIDE;
|
||||
void addHistoryBookmark(RemoteView *view);
|
||||
void addManualBookmark(const QString &url, const QString &text);
|
||||
void addManualBookmark(const QUrl &url, const QString &text);
|
||||
KBookmarkManager* getManager();
|
||||
// removes all bookmarks with url, possibly ignore the history folder and update it's title there if it's set
|
||||
static void removeByUrl(KBookmarkManager *manager, const QString &url, bool ignoreHistory = false, const QString updateTitle = QString());
|
||||
|
@ -56,16 +57,16 @@ public:
|
|||
// returns a QStringList for all bookmarks that point to this url using KBookmark::address()
|
||||
static const QStringList findBookmarkAddresses(const KBookmarkGroup &group, const QString &url);
|
||||
|
||||
signals:
|
||||
void openUrl(const KUrl &url);
|
||||
Q_SIGNALS:
|
||||
void openUrl(const QUrl &url);
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers);
|
||||
void openFolderinTabs(const KBookmarkGroup &bookmarkGroup);
|
||||
|
||||
private:
|
||||
QString urlForView(RemoteView *view) const;
|
||||
QString titleForUrl(const QString &url) const;
|
||||
QString titleForUrl(const QUrl &url) const;
|
||||
|
||||
KBookmarkMenu *m_bookmarkMenu;
|
||||
KBookmarkManager *m_manager;
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
INCLUDE(CheckPointerMember)
|
||||
|
||||
IF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(LIBVNCSERVER_FIND_QUIETLY TRUE)
|
||||
|
@ -25,7 +23,17 @@ FIND_LIBRARY(LIBVNCCLIENT_LIBRARIES NAMES vncclient libvncclient)
|
|||
|
||||
IF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
|
||||
SET(CMAKE_REQUIRED_INCLUDES "${LIBVNCSERVER_INCLUDE_DIR}" "${CMAKE_REQUIRED_INCLUDES}")
|
||||
CHECK_POINTER_MEMBER(rfbClient* GotXCutText rfb/rfbclient.h LIBVNCSERVER_FOUND)
|
||||
SET(_TEST_SOURCE_CODE "
|
||||
#include <rfb/rfbclient.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
rfbClient* tmp;
|
||||
tmp->GotXCutText;
|
||||
return 0;
|
||||
}
|
||||
")
|
||||
CHECK_CXX_SOURCE_COMPILES("${_TEST_SOURCE_CODE}" LIBVNCSERVER_FOUND)
|
||||
ENDIF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES)
|
||||
|
||||
IF (LIBVNCSERVER_FOUND)
|
||||
|
|
|
@ -23,13 +23,11 @@
|
|||
|
||||
#include "hostpreferenceslist.h"
|
||||
#include "hostpreferences.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KIcon>
|
||||
#include <KLocale>
|
||||
#include <KMessageBox>
|
||||
#include <KPushButton>
|
||||
#include <KStandardDirs>
|
||||
#include <QIcon>
|
||||
#include <KI18n/KLocalizedString>
|
||||
#include <KWidgetsAddons/KMessageBox>
|
||||
|
||||
#include <QFile>
|
||||
#include <QLayout>
|
||||
|
@ -44,16 +42,16 @@ HostPreferencesList::HostPreferencesList(QWidget *parent, MainWindow *mainWindow
|
|||
connect(hostList, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged()));
|
||||
connect(hostList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(configureHost()));
|
||||
|
||||
configureButton = new KPushButton(this);
|
||||
configureButton = new QPushButton(this);
|
||||
configureButton->setEnabled(false);
|
||||
configureButton->setText(i18n("Configure..."));
|
||||
configureButton->setIcon(KIcon("configure"));
|
||||
configureButton->setIcon(QIcon::fromTheme(QLatin1String("configure")));
|
||||
connect(configureButton, SIGNAL(clicked()), SLOT(configureHost()));
|
||||
|
||||
removeButton = new KPushButton(this);
|
||||
removeButton = new QPushButton(this);
|
||||
removeButton->setEnabled(false);
|
||||
removeButton->setText(i18n("Remove"));
|
||||
removeButton->setIcon(KIcon("list-remove"));
|
||||
removeButton->setIcon(QIcon::fromTheme(QLatin1String("list-remove")));
|
||||
connect(removeButton, SIGNAL(clicked()), SLOT(removeHost()));
|
||||
|
||||
QVBoxLayout *buttonLayout = new QVBoxLayout;
|
||||
|
@ -77,8 +75,8 @@ HostPreferencesList::~HostPreferencesList()
|
|||
void HostPreferencesList::readConfig()
|
||||
{
|
||||
QStringList urls = m_hostPrefsConfig.groupList();
|
||||
|
||||
for (int i = 0; i < urls.size(); ++i)
|
||||
|
||||
for (int i = 0; i < urls.size(); ++i)
|
||||
hostList->addItem(new QListWidgetItem(urls.at(i)));
|
||||
}
|
||||
|
||||
|
@ -92,20 +90,21 @@ void HostPreferencesList::configureHost()
|
|||
QList<QListWidgetItem *> selectedItems = hostList->selectedItems();
|
||||
|
||||
foreach(QListWidgetItem *selectedItem, selectedItems) {
|
||||
const QString url = selectedItem->text();
|
||||
const QString urlString = selectedItem->text();
|
||||
const QUrl url = QUrl(urlString);
|
||||
|
||||
kDebug(5010) << "Configure host: " << url;
|
||||
qCDebug(KRDC) << "Configure host: " << urlString;
|
||||
|
||||
HostPreferences* prefs = 0;
|
||||
|
||||
|
||||
const QList<RemoteViewFactory *> remoteViewFactories(m_mainWindow->remoteViewFactoriesList());
|
||||
foreach(RemoteViewFactory *factory, remoteViewFactories) {
|
||||
if (factory->supportsUrl(url)) {
|
||||
prefs = factory->createHostPreferences(m_hostPrefsConfig.group(url), this);
|
||||
prefs = factory->createHostPreferences(m_hostPrefsConfig.group(urlString), this);
|
||||
if (prefs) {
|
||||
kDebug(5010) << "Found plugin to handle url (" + url + "): " + prefs->metaObject()->className();
|
||||
qCDebug(KRDC) << "Found plugin to handle url (" << urlString << "): " << prefs->metaObject()->className();
|
||||
} else {
|
||||
kDebug(5010) << "Found plugin to handle url (" + url + "), but plugin does not provide preferences";
|
||||
qCDebug(KRDC) << "Found plugin to handle url (" << urlString << "), but plugin does not provide preferences";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +125,7 @@ void HostPreferencesList::removeHost()
|
|||
const QList<QListWidgetItem *> selectedItems = hostList->selectedItems();
|
||||
|
||||
foreach(QListWidgetItem *selectedItem, selectedItems) {
|
||||
kDebug(5010) << "Remove host: " << selectedItem->text();
|
||||
qCDebug(KRDC) << "Remove host: " << selectedItem->text();
|
||||
|
||||
m_hostPrefsConfig.deleteGroup(selectedItem->text());
|
||||
delete(selectedItem);
|
||||
|
@ -144,4 +143,3 @@ void HostPreferencesList::selectionChanged()
|
|||
removeButton->setEnabled(enabled);
|
||||
}
|
||||
|
||||
#include "hostpreferenceslist.moc"
|
||||
|
|
|
@ -26,12 +26,11 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KConfigCore/KConfigGroup>
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QWidget>
|
||||
|
||||
class KPushButton;
|
||||
#include <QPushButton>
|
||||
|
||||
class QListWidget;
|
||||
|
||||
|
@ -43,7 +42,7 @@ public:
|
|||
HostPreferencesList(QWidget *parent, MainWindow *mainWindow, KConfigGroup hostPrefsConfig);
|
||||
~HostPreferencesList();
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void readConfig();
|
||||
void saveSettings();
|
||||
void configureHost();
|
||||
|
@ -53,8 +52,8 @@ private slots:
|
|||
private:
|
||||
KConfigGroup m_hostPrefsConfig;
|
||||
|
||||
KPushButton *configureButton;
|
||||
KPushButton *removeButton;
|
||||
QPushButton *configureButton;
|
||||
QPushButton *removeButton;
|
||||
QListWidget *hostList;
|
||||
MainWindow *m_mainWindow;
|
||||
};
|
||||
|
|
|
@ -22,40 +22,40 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "preferencesdialog.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "hostpreferenceslist.h"
|
||||
#include "ui_general.h"
|
||||
|
||||
#include <KConfigSkeleton>
|
||||
#include <KDebug>
|
||||
#include <KPluginSelector>
|
||||
#include <KService>
|
||||
#include <KServiceTypeTrader>
|
||||
#include <KPluginInfo>
|
||||
#include <KConfigGui/KConfigSkeleton>
|
||||
#include <KI18n/KLocalizedString>
|
||||
#include <KCMUtils/KPluginSelector>
|
||||
#include <KPluginTrader>
|
||||
#include <KService/KPluginInfo>
|
||||
|
||||
PreferencesDialog::PreferencesDialog(QWidget *parent, KConfigSkeleton *skeleton)
|
||||
: KConfigDialog(parent, "preferences", skeleton)
|
||||
: KConfigDialog(parent, QLatin1String("preferences"), skeleton)
|
||||
, m_settingsChanged(false)
|
||||
{
|
||||
QWidget *generalPage = new QWidget(this);
|
||||
Ui::General generalUi;
|
||||
generalUi.setupUi(generalPage);
|
||||
addPage(generalPage, i18nc("General Config", "General"), "krdc", i18n("General Configuration"));
|
||||
addPage(generalPage, i18nc("General Config", "General"), QLatin1String("krdc"), i18n("General Configuration"));
|
||||
|
||||
HostPreferencesList *hostPreferencesList = new HostPreferencesList(this,
|
||||
qobject_cast<MainWindow *>(parent),
|
||||
skeleton->config()->group("hostpreferences"));
|
||||
addPage(hostPreferencesList, i18n("Hosts"), "computer", i18n("Host Configuration"));
|
||||
addPage(hostPreferencesList, i18n("Hosts"), QLatin1String("computer"), i18n("Host Configuration"));
|
||||
|
||||
m_pluginSelector = new KPluginSelector();
|
||||
KService::List offers = KServiceTypeTrader::self()->query("KRDC/Plugin");
|
||||
m_pluginSelector->addPlugins(KPluginInfo::fromServices(offers), KPluginSelector::ReadConfigFile,
|
||||
i18n("Plugins"), "Service", KGlobal::config());
|
||||
const KPluginInfo::List offers = KPluginTrader::self()->query(QLatin1String("krdc/plugins"));
|
||||
m_pluginSelector->addPlugins(offers, KPluginSelector::ReadConfigFile,
|
||||
i18n("Plugins"), QLatin1String("Service"), KSharedConfig::openConfig());
|
||||
m_pluginSelector->load();
|
||||
addPage(m_pluginSelector, i18n("Plugins"), "preferences-plugin", i18n("Plugin Configuration"));
|
||||
addPage(m_pluginSelector, i18n("Plugins"), QLatin1String("preferences-plugin"), i18n("Plugin Configuration"));
|
||||
|
||||
connect(this, SIGNAL(accepted()), SLOT(saveState()));
|
||||
connect(this, SIGNAL(defaultClicked()), SLOT(loadDefaults()));
|
||||
QPushButton *defaultsButton = buttonBox()->button(QDialogButtonBox::RestoreDefaults);
|
||||
connect(defaultsButton, SIGNAL(clicked()), SLOT(loadDefaults()));
|
||||
connect(m_pluginSelector, SIGNAL(changed(bool)), SLOT(settingsChanged()));
|
||||
}
|
||||
|
||||
|
@ -68,16 +68,24 @@ void PreferencesDialog::saveState()
|
|||
void PreferencesDialog::loadDefaults()
|
||||
{
|
||||
m_pluginSelector->defaults();
|
||||
enableButton(Default, false);
|
||||
}
|
||||
|
||||
void PreferencesDialog::settingsChanged()
|
||||
{
|
||||
enableButton(Apply, true);
|
||||
enableButton(Default, true);
|
||||
enableButton(QDialogButtonBox::Apply);
|
||||
enableButton(QDialogButtonBox::RestoreDefaults);
|
||||
}
|
||||
|
||||
bool PreferencesDialog::isDefault()
|
||||
{
|
||||
return KConfigDialog::isDefault() && m_pluginSelector->isDefault();
|
||||
}
|
||||
|
||||
void PreferencesDialog::enableButton(QDialogButtonBox::StandardButton standardButton)
|
||||
{
|
||||
QPushButton *button = buttonBox()->button(standardButton);
|
||||
if (button) {
|
||||
button->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
#ifndef PREFERENCESDIALOG_H
|
||||
#define PREFERENCESDIALOG_H
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KConfigWidgets/KConfigDialog>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
class KConfigSkeleton;
|
||||
class KPluginSelector;
|
||||
|
@ -38,8 +40,8 @@ public:
|
|||
|
||||
protected:
|
||||
virtual bool isDefault();
|
||||
|
||||
private slots:
|
||||
|
||||
private Q_SLOTS:
|
||||
void saveState();
|
||||
void loadDefaults();
|
||||
void settingsChanged();
|
||||
|
@ -47,6 +49,7 @@ private slots:
|
|||
private:
|
||||
KPluginSelector *m_pluginSelector;
|
||||
bool m_settingsChanged;
|
||||
void enableButton(QDialogButtonBox::StandardButton standardButton);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "connectiondelegate.h"
|
||||
#include "remotedesktopsmodel.h"
|
||||
|
||||
#include <KDateTime>
|
||||
#include <KDebug>
|
||||
#include <KIcon>
|
||||
#include <KIconLoader>
|
||||
#include <KLocale>
|
||||
#include <KIconThemes/KIconLoader>
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QIcon>
|
||||
|
||||
ConnectionDelegate::ConnectionDelegate(QObject *parent) :
|
||||
QStyledItemDelegate(parent)
|
||||
|
@ -38,8 +38,8 @@ ConnectionDelegate::ConnectionDelegate(QObject *parent) :
|
|||
QString ConnectionDelegate::displayText(const QVariant &value, const QLocale& locale) const
|
||||
{
|
||||
if (value.type() == QVariant::DateTime) {
|
||||
KDateTime lastConnected = KDateTime(value.toDateTime());
|
||||
KDateTime currentTime = KDateTime::currentUtcDateTime();
|
||||
QDateTime lastConnected = QDateTime(value.toDateTime());
|
||||
QDateTime currentTime = QDateTime::currentDateTimeUtc();
|
||||
|
||||
int daysAgo = lastConnected.daysTo(currentTime);
|
||||
if (daysAgo <= 1 && lastConnected.secsTo(currentTime) < 86400) {
|
||||
|
@ -71,8 +71,8 @@ void ConnectionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
QVariant value = index.data(Qt::CheckStateRole);
|
||||
if (value.isValid()) {
|
||||
Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());
|
||||
KIcon favIcon = KIcon("bookmarks");
|
||||
KIcon::Mode mode = (checkState == Qt::Checked) ? KIcon::Active : KIcon::Disabled;
|
||||
QIcon favIcon = QIcon(QLatin1String("bookmarks"));
|
||||
QIcon::Mode mode = (checkState == Qt::Checked) ? QIcon::Active : QIcon::Disabled;
|
||||
favIcon.paint(painter, option.rect, option.decorationAlignment, mode);
|
||||
|
||||
}
|
||||
|
|
|
@ -34,10 +34,6 @@ public:
|
|||
QString displayText(const QVariant &value, const QLocale& locale) const;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // CONNECTIONDELEGATE_H
|
||||
|
|
|
@ -1,19 +1,33 @@
|
|||
|
||||
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5010)
|
||||
include(GenerateExportHeader)
|
||||
|
||||
set(krdccore_SRCS
|
||||
remoteviewfactory.cpp
|
||||
remoteview.cpp
|
||||
logging.cpp
|
||||
hostpreferences.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(krdccore_SRCS settings.kcfgc)
|
||||
kconfig_add_kcfg_files(krdccore_SRCS settings.kcfgc)
|
||||
|
||||
kde4_add_library(krdccore SHARED ${krdccore_SRCS})
|
||||
add_library(krdccore SHARED ${krdccore_SRCS})
|
||||
|
||||
target_link_libraries(krdccore ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS})
|
||||
kcoreaddons_desktop_to_json(krdccore krdc_plugin.desktop)
|
||||
generate_export_header(krdccore BASE_NAME krdccore)
|
||||
|
||||
set_target_properties(krdccore PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION})
|
||||
target_link_libraries(krdccore
|
||||
Qt5::Core
|
||||
KF5::Wallet
|
||||
KF5::ConfigCore
|
||||
KF5::CoreAddons
|
||||
KF5::WidgetsAddons
|
||||
KF5::I18n
|
||||
KF5::ConfigGui
|
||||
KF5::Completion
|
||||
Qt5::Gui
|
||||
Qt5::Widgets)
|
||||
|
||||
set_target_properties(krdccore PROPERTIES VERSION ${KRDC_VERSION} SOVERSION ${KRDC_SOVERSION})
|
||||
|
||||
install(TARGETS krdccore ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
|
@ -25,5 +39,5 @@ set(krdccore_HDRS
|
|||
)
|
||||
|
||||
install(FILES ${krdccore_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/krdc COMPONENT Devel)
|
||||
install(FILES krdc_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/krdccore_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel)
|
||||
install(FILES krdc.kcfg DESTINATION ${KCFG_INSTALL_DIR})
|
||||
|
|
|
@ -22,16 +22,17 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "hostpreferences.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KLocale>
|
||||
#include <KStandardDirs>
|
||||
#include <KTitleWidget>
|
||||
#include <KI18n/KLocalizedString>
|
||||
#include <KWidgetsAddons/KPageDialog>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QFile>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
HostPreferences::HostPreferences(KConfigGroup configGroup, QObject *parent)
|
||||
|
@ -113,7 +114,7 @@ bool HostPreferences::fullscreenScale()
|
|||
|
||||
void HostPreferences::setFullscreenScale(bool scale)
|
||||
{
|
||||
m_configGroup.writeEntry("fullscreenScale", scale);
|
||||
m_configGroup.writeEntry("fullscreenScale", scale);
|
||||
}
|
||||
|
||||
bool HostPreferences::windowedScale()
|
||||
|
@ -123,7 +124,7 @@ bool HostPreferences::windowedScale()
|
|||
|
||||
void HostPreferences::setWindowedScale(bool scale)
|
||||
{
|
||||
m_configGroup.writeEntry("windowedScale", scale);
|
||||
m_configGroup.writeEntry("windowedScale", scale);
|
||||
}
|
||||
|
||||
bool HostPreferences::grabAllKeys()
|
||||
|
@ -133,7 +134,7 @@ bool HostPreferences::grabAllKeys()
|
|||
|
||||
void HostPreferences::setGrabAllKeys(bool grab)
|
||||
{
|
||||
m_configGroup.writeEntry("grabAllKeys", grab);
|
||||
m_configGroup.writeEntry("grabAllKeys", grab);
|
||||
}
|
||||
|
||||
bool HostPreferences::showLocalCursor()
|
||||
|
@ -160,12 +161,12 @@ bool HostPreferences::showDialogIfNeeded(QWidget *parent)
|
|||
{
|
||||
if (hostConfigured()) {
|
||||
if (showConfigAgain()) {
|
||||
kDebug(5010) << "Show config dialog again";
|
||||
qCDebug(KRDC) << "Show config dialog again";
|
||||
return showDialog(parent);
|
||||
} else
|
||||
return true; // no changes, no need to save
|
||||
} else {
|
||||
kDebug(5010) << "No config found, create new";
|
||||
qCDebug(KRDC) << "No config found, create new";
|
||||
if (Settings::showPreferencesForNewConnections())
|
||||
return showDialog(parent);
|
||||
else
|
||||
|
@ -177,20 +178,19 @@ bool HostPreferences::showDialogIfNeeded(QWidget *parent)
|
|||
bool HostPreferences::showDialog(QWidget *parent)
|
||||
{
|
||||
// Prepare dialog
|
||||
KDialog *dialog = new KDialog(parent);
|
||||
dialog->setCaption(i18n("Host Configuration"));
|
||||
KPageDialog *dialog = new KPageDialog(parent);
|
||||
dialog->setWindowTitle(i18n("Host Configuration"));
|
||||
|
||||
QWidget *mainWidget = dialog->mainWidget();
|
||||
QWidget *mainWidget = new QWidget(parent);
|
||||
QVBoxLayout *layout = new QVBoxLayout(mainWidget);
|
||||
dialog->addPage(mainWidget, i18n("Host Configuration"));
|
||||
|
||||
KTitleWidget *titleWidget = new KTitleWidget(dialog);
|
||||
titleWidget->setText(i18n("Host Configuration"));
|
||||
if (m_connected) {
|
||||
titleWidget->setComment(QString("<i>%1</i>").arg(
|
||||
i18n("Note that settings might only apply when you connect next time to this host.")));
|
||||
const QString noteText = i18n("Note that settings might only apply when you connect next time to this host.");
|
||||
const QString format = QLatin1String("<i>%1</i>");
|
||||
QLabel *commentLabel = new QLabel(format.arg(noteText), mainWidget);
|
||||
layout->addWidget(commentLabel);
|
||||
}
|
||||
titleWidget->setPixmap(KIcon("krdc"));
|
||||
layout->addWidget(titleWidget);
|
||||
|
||||
QWidget* widget = createProtocolSpecificConfigPage();
|
||||
|
||||
|
@ -213,17 +213,9 @@ bool HostPreferences::showDialog(QWidget *parent)
|
|||
layout->addWidget(walletSupportCheckBox);
|
||||
layout->addStretch(1);
|
||||
|
||||
// WORKAROUND: it seems that KDialog does not set the minimum size properly in some cases.
|
||||
// see for example issue #244539. also it looks like KTitleWidget returns a too small size hint when a comment is shown.
|
||||
QSize minimumSize = dialog->sizeHint();
|
||||
if (m_connected) {
|
||||
minimumSize += QSize(0, 50);
|
||||
}
|
||||
dialog->setMinimumSize(minimumSize);
|
||||
|
||||
// Show dialog
|
||||
if (dialog->exec() == KDialog::Accepted) {
|
||||
kDebug(5010) << "HostPreferences config dialog accepted";
|
||||
if (dialog->exec() == QDialog::Accepted) {
|
||||
qCDebug(KRDC) << "HostPreferences config dialog accepted";
|
||||
acceptConfig();
|
||||
return true;
|
||||
} else {
|
||||
|
@ -236,4 +228,3 @@ void HostPreferences::setShownWhileConnected(bool connected)
|
|||
m_connected = connected;
|
||||
}
|
||||
|
||||
#include "hostpreferences.moc"
|
||||
|
|
|
@ -25,19 +25,12 @@
|
|||
#define HOSTPREFERENCES_H
|
||||
|
||||
#include "remoteview.h"
|
||||
#include "krdccore_export.h"
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
#include <KDE/KDialog>
|
||||
|
||||
#include <QDomDocument>
|
||||
|
||||
#include <QSize>
|
||||
#include <KConfigCore/KConfigGroup>
|
||||
|
||||
class QCheckBox;
|
||||
class QWidget;
|
||||
class KConfig;
|
||||
class KConfigGroup;
|
||||
|
||||
class KRDCCORE_EXPORT HostPreferences : public QObject
|
||||
{
|
||||
|
@ -47,23 +40,23 @@ public:
|
|||
~HostPreferences();
|
||||
|
||||
KConfigGroup configGroup();
|
||||
|
||||
|
||||
bool walletSupport();
|
||||
|
||||
|
||||
/** Whether scaling is enabled when session is full screen. Note: only windowedScale seems to be used. */
|
||||
bool fullscreenScale();
|
||||
void setFullscreenScale(bool scale);
|
||||
|
||||
|
||||
/** Whether scaling is enabled when session is not full screen */
|
||||
bool windowedScale();
|
||||
void setWindowedScale(bool scale);
|
||||
|
||||
|
||||
bool grabAllKeys();
|
||||
void setGrabAllKeys(bool grab);
|
||||
|
||||
|
||||
bool showLocalCursor();
|
||||
void setShowLocalCursor(bool show);
|
||||
|
||||
|
||||
bool viewOnly();
|
||||
void setViewOnly(bool view);
|
||||
|
||||
|
@ -74,13 +67,13 @@ public:
|
|||
int width();
|
||||
void setWidth(int width);
|
||||
|
||||
/**
|
||||
* Show the configuration dialog if needed, ie. if the user did
|
||||
/**
|
||||
* Show the configuration dialog if needed, ie. if the user did
|
||||
* check "show this dialog again for this host".
|
||||
* Returns true if user pressed ok.
|
||||
* Returns true if user pressed ok.
|
||||
*/
|
||||
bool showDialogIfNeeded(QWidget *parent);
|
||||
|
||||
|
||||
/** Show the configuration dialog */
|
||||
bool showDialog(QWidget *parent);
|
||||
|
||||
|
@ -91,10 +84,10 @@ protected:
|
|||
HostPreferences(KConfigGroup configGroup, QObject *parent);
|
||||
|
||||
virtual QWidget* createProtocolSpecificConfigPage() = 0;
|
||||
|
||||
|
||||
/** Called when the user validates the config dialog. */
|
||||
virtual void acceptConfig();
|
||||
|
||||
|
||||
bool hostConfigured();
|
||||
bool showConfigAgain();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<include>krdccore_export.h</include>
|
||||
<kcfgfile name="krdcrc"/>
|
||||
<group name="General">
|
||||
<entry name="RememberSessions" type="Bool">
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2006 David Faure <faure@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KRDCCORE_EXPORT_H
|
||||
#define KRDCCORE_EXPORT_H
|
||||
|
||||
/* needed for KDE_EXPORT and KDE_IMPORT macros */
|
||||
#include <kdemacros.h>
|
||||
|
||||
#ifndef KRDCCORE_EXPORT
|
||||
# if defined(KDELIBS_STATIC_LIBS)
|
||||
/* No export/import for static libraries */
|
||||
# define KRDCCORE_EXPORT
|
||||
# elif defined(MAKE_KRDCCORE_LIB)
|
||||
/* We are building this library */
|
||||
# define KRDCCORE_EXPORT KDE_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define KRDCCORE_EXPORT KDE_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
22
core/logging.cpp
Normal file
22
core/logging.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
Q_LOGGING_CATEGORY(KRDC, "KRDC")
|
27
core/logging.h
Normal file
27
core/logging.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef KRDC_LOGGING_H
|
||||
#define KRDC_LOGGING_H
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(KRDC)
|
||||
|
||||
#endif
|
|
@ -23,13 +23,11 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "remoteview.h"
|
||||
#include "logging.h"
|
||||
|
||||
#ifndef QTONLY
|
||||
#include <KDebug>
|
||||
#include <KStandardDirs>
|
||||
#endif
|
||||
|
||||
#include <QUrl>
|
||||
#include <QBitmap>
|
||||
#include <QStandardPaths>
|
||||
|
||||
RemoteView::RemoteView(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
@ -157,7 +155,7 @@ void RemoteView::setGrabAllKeys(bool grabAllKeys)
|
|||
}
|
||||
}
|
||||
|
||||
QPixmap RemoteView::takeScreenshot()
|
||||
QPixmap RemoteView::takeScreenshot()
|
||||
{
|
||||
return QPixmap::grabWidget(this);
|
||||
}
|
||||
|
@ -190,7 +188,7 @@ void RemoteView::scaleResize(int, int)
|
|||
{
|
||||
}
|
||||
|
||||
KUrl RemoteView::url()
|
||||
QUrl RemoteView::url()
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
@ -198,32 +196,32 @@ KUrl RemoteView::url()
|
|||
#ifndef QTONLY
|
||||
QString RemoteView::readWalletPassword(bool fromUserNameOnly)
|
||||
{
|
||||
const QString KRDCFOLDER = "KRDC";
|
||||
const QString KRDCFOLDER = QLatin1String("KRDC");
|
||||
|
||||
window()->setDisabled(true); // WORKAROUND: disable inputs so users cannot close the current tab (see #181230)
|
||||
m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), window()->winId());
|
||||
m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), window()->winId(), KWallet::Wallet::OpenType::Synchronous);
|
||||
window()->setDisabled(false);
|
||||
|
||||
if (m_wallet) {
|
||||
bool walletOK = m_wallet->hasFolder(KRDCFOLDER);
|
||||
if (!walletOK) {
|
||||
walletOK = m_wallet->createFolder(KRDCFOLDER);
|
||||
kDebug(5010) << "Wallet folder created";
|
||||
qCDebug(KRDC) << "Wallet folder created";
|
||||
}
|
||||
if (walletOK) {
|
||||
kDebug(5010) << "Wallet OK";
|
||||
qCDebug(KRDC) << "Wallet OK";
|
||||
m_wallet->setFolder(KRDCFOLDER);
|
||||
QString password;
|
||||
|
||||
|
||||
QString key;
|
||||
if (fromUserNameOnly)
|
||||
key = m_url.userName();
|
||||
else
|
||||
key = m_url.prettyUrl(KUrl::RemoveTrailingSlash);
|
||||
key = m_url.toDisplayString(QUrl::StripTrailingSlash);
|
||||
|
||||
if (m_wallet->hasEntry(key) &&
|
||||
!m_wallet->readPassword(key, password)) {
|
||||
kDebug(5010) << "Password read OK";
|
||||
qCDebug(KRDC) << "Password read OK";
|
||||
|
||||
return password;
|
||||
}
|
||||
|
@ -238,10 +236,10 @@ void RemoteView::saveWalletPassword(const QString &password, bool fromUserNameOn
|
|||
if (fromUserNameOnly)
|
||||
key = m_url.userName();
|
||||
else
|
||||
key = m_url.prettyUrl(KUrl::RemoveTrailingSlash);
|
||||
key = m_url.toDisplayString(QUrl::StripTrailingSlash);
|
||||
|
||||
if (m_wallet && m_wallet->isOpen()) {
|
||||
kDebug(5010) << "Write wallet password";
|
||||
qCDebug(KRDC) << "Write wallet password";
|
||||
m_wallet->writePassword(key, password);
|
||||
}
|
||||
}
|
||||
|
@ -249,15 +247,13 @@ void RemoteView::saveWalletPassword(const QString &password, bool fromUserNameOn
|
|||
|
||||
QCursor RemoteView::localDotCursor() const
|
||||
{
|
||||
#ifdef QTONLY
|
||||
return QCursor(); //TODO
|
||||
#else
|
||||
QBitmap cursorBitmap(KGlobal::dirs()->findResource("appdata",
|
||||
"pics/pointcursor.png"));
|
||||
QBitmap cursorMask(KGlobal::dirs()->findResource("appdata",
|
||||
"pics/pointcursormask.png"));
|
||||
QString cursorBitmapPath = QStandardPaths::locate(QStandardPaths::DataLocation, QLatin1String("pics/pointcursor.png"));
|
||||
QBitmap cursorBitmap = QBitmap();
|
||||
cursorBitmap.load(cursorBitmapPath);
|
||||
QString cursorMaskPath = QStandardPaths::locate(QStandardPaths::DataLocation, QLatin1String("pics/pointcursormask.png"));
|
||||
QBitmap cursorMask = QBitmap();
|
||||
cursorMask.load(cursorMaskPath);
|
||||
return QCursor(cursorBitmap, cursorMask);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RemoteView::focusInEvent(QFocusEvent *event)
|
||||
|
|
|
@ -25,16 +25,14 @@
|
|||
#ifndef REMOTEVIEW_H
|
||||
#define REMOTEVIEW_H
|
||||
|
||||
#ifdef QTONLY
|
||||
#include <QUrl>
|
||||
#define KUrl QUrl
|
||||
#define KRDCCORE_EXPORT
|
||||
#ifndef QTONLY
|
||||
#include <KWallet/KWallet>
|
||||
#include "krdccore_export.h"
|
||||
#else
|
||||
#include <KDE/KUrl>
|
||||
#include <KDE/KWallet/Wallet>
|
||||
#include <krdc_export.h>
|
||||
#define KRDCCORE_EXPORT
|
||||
#endif
|
||||
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
class HostPreferences;
|
||||
|
@ -238,25 +236,25 @@ public:
|
|||
* @see statusChanged()
|
||||
*/
|
||||
virtual bool start() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Called when the configuration is changed.
|
||||
* The default implementation does nothing.
|
||||
*/
|
||||
virtual void updateConfiguration();
|
||||
|
||||
|
||||
/**
|
||||
* @return screenshot of the view
|
||||
*/
|
||||
virtual QPixmap takeScreenshot();
|
||||
|
||||
|
||||
#ifndef QTONLY
|
||||
/**
|
||||
* Returns the current host preferences of this view.
|
||||
*/
|
||||
virtual HostPreferences* hostPreferences() = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current status of the connection.
|
||||
* @return the status of the connection
|
||||
|
@ -267,9 +265,9 @@ public:
|
|||
/**
|
||||
* @return the current url
|
||||
*/
|
||||
KUrl url();
|
||||
QUrl url();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Called to enable or disable scaling.
|
||||
* Ignored if @ref supportsScaling() is false.
|
||||
|
@ -346,7 +344,7 @@ Q_SIGNALS:
|
|||
* Emitted when the view has a specific error.
|
||||
*/
|
||||
void errorMessage(const QString &title, const QString &message);
|
||||
|
||||
|
||||
/**
|
||||
* Emitted when the status of the view changed.
|
||||
* @param s the new status
|
||||
|
@ -401,7 +399,7 @@ protected:
|
|||
bool m_grabAllKeys;
|
||||
bool m_scale;
|
||||
bool m_keyboardIsGrabbed;
|
||||
KUrl m_url;
|
||||
QUrl m_url;
|
||||
|
||||
#ifndef QTONLY
|
||||
QString readWalletPassword(bool fromUserNameOnly = false);
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
|
||||
#include "remoteviewfactory.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
RemoteViewFactory::RemoteViewFactory(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
@ -34,4 +32,3 @@ RemoteViewFactory::~RemoteViewFactory()
|
|||
{
|
||||
}
|
||||
|
||||
#include "moc_remoteviewfactory.cpp"
|
||||
|
|
|
@ -25,26 +25,11 @@
|
|||
#define REMOTEVIEWFACTORY_H
|
||||
|
||||
#include "remoteview.h"
|
||||
#include "krdccore_export.h"
|
||||
|
||||
#include <kdemacros.h>
|
||||
#include <KDE/KPluginFactory>
|
||||
#include <KDE/KPluginLoader>
|
||||
|
||||
class KUrl;
|
||||
|
||||
/**
|
||||
* Convenience macros to export a KRDC plugin. Suppose you created the plugin
|
||||
* FooRemoteViewFactory. In FooRemoteViewFactory you will have to put the following line:
|
||||
*
|
||||
* @code
|
||||
* KRDC_PLUGIN_EXPORT(FooRemoteViewFactory)
|
||||
* @endcode
|
||||
*
|
||||
* The rest will be done for you.
|
||||
*/
|
||||
#define KRDC_PLUGIN_EXPORT( c ) \
|
||||
K_PLUGIN_FACTORY( KrdcFactory, registerPlugin< c >(); ) \
|
||||
K_EXPORT_PLUGIN( KrdcFactory("c") )
|
||||
#include <KCoreAddons/KPluginFactory>
|
||||
#include <KConfigCore/KConfigGroup>
|
||||
#include <KCoreAddons/KPluginLoader>
|
||||
|
||||
/**
|
||||
* Factory to be implemented by any plugin.
|
||||
|
@ -62,12 +47,12 @@ public:
|
|||
/**
|
||||
* Returns true if the provided @p url is supported by the current plugin.
|
||||
*/
|
||||
virtual bool supportsUrl(const KUrl &url) const = 0;
|
||||
virtual bool supportsUrl(const QUrl &url) const = 0;
|
||||
|
||||
/**
|
||||
* Returns a new RemoteView implementing object.
|
||||
*/
|
||||
virtual RemoteView *createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup) = 0;
|
||||
virtual RemoteView *createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup) = 0;
|
||||
|
||||
/**
|
||||
* Returns a new HostPreferences implementing object or 0 if no settings are available.
|
||||
|
@ -76,7 +61,7 @@ public:
|
|||
|
||||
/**
|
||||
* Returns the supported scheme.
|
||||
* @see KUrl::scheme()
|
||||
* @see QUrl::scheme()
|
||||
*/
|
||||
virtual QString scheme() const = 0;
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ ClassName=Settings
|
|||
File=krdc.kcfg
|
||||
Mutators=true
|
||||
Singleton=true
|
||||
Visibility=KDE_EXPORT
|
||||
Visibility=KRDCCORE_EXPORT
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
########### install files ###############
|
||||
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR krdc)
|
||||
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR krdc)
|
||||
|
|
|
@ -24,16 +24,14 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "floatingtoolbar.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KGlobalSettings>
|
||||
#include "logging.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QDesktopWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include <QStyle>
|
||||
|
||||
static const int actionIconSize = 22;
|
||||
static const int toolBarRBMargin = 2;
|
||||
|
@ -161,7 +159,7 @@ void FloatingToolBar::showAndAnimate()
|
|||
d->animTimer->start(20);
|
||||
|
||||
// This permits to show the toolbar for a while when going full screen.
|
||||
if (!d->sticky)
|
||||
if (!d->sticky)
|
||||
d->autoHideTimer->start(initialAutoHideTimeout);
|
||||
}
|
||||
|
||||
|
@ -181,7 +179,7 @@ void FloatingToolBar::hideAndDestroy()
|
|||
|
||||
void FloatingToolBar::hide()
|
||||
{
|
||||
if (underMouse())
|
||||
if (underMouse())
|
||||
return;
|
||||
|
||||
if (d->visible) {
|
||||
|
@ -216,7 +214,7 @@ bool FloatingToolBar::eventFilter(QObject *obj, QEvent *e)
|
|||
showAndAnimate();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if anchorWidget changed geometry reposition toolbar
|
||||
d->animTimer->stop();
|
||||
if ((d->animState == Hiding || !d->visible) && d->toDelete)
|
||||
|
@ -283,14 +281,14 @@ void FloatingToolBar::enterEvent(QEvent *e)
|
|||
// Stop the autohide timer while the mouse is inside
|
||||
d->autoHideTimer->stop();
|
||||
|
||||
if (!d->visible)
|
||||
if (!d->visible)
|
||||
showAndAnimate();
|
||||
QToolBar::enterEvent(e);
|
||||
}
|
||||
|
||||
void FloatingToolBar::leaveEvent(QEvent *e)
|
||||
{
|
||||
if (!d->sticky)
|
||||
if (!d->sticky)
|
||||
d->autoHideTimer->start(autoHideTimeout);
|
||||
QToolBar::leaveEvent(e);
|
||||
}
|
||||
|
@ -308,7 +306,7 @@ void FloatingToolBar::wheelEvent(QWheelEvent *e)
|
|||
e->accept();
|
||||
|
||||
const qreal diff = e->delta() / 100.0 / 15.0;
|
||||
// kDebug(5010) << diff;
|
||||
// qCDebug(KRDC) << diff;
|
||||
if (((d->opacity <= 1) && (diff > 0)) || ((d->opacity >= 0) && (diff < 0)))
|
||||
d->opacity += diff;
|
||||
|
||||
|
@ -449,7 +447,7 @@ QPoint FloatingToolBarPrivate::getOuterPoint() const
|
|||
|
||||
void FloatingToolBar::animate()
|
||||
{
|
||||
if (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) {
|
||||
if (style()->styleHint(QStyle::SH_Widget_Animate, 0, this)) {
|
||||
// move currentPosition towards endPosition
|
||||
int dX = d->endPosition.x() - d->currentPosition.x();
|
||||
int dY = d->endPosition.y() - d->currentPosition.y();
|
||||
|
@ -478,9 +476,8 @@ void FloatingToolBar::animate()
|
|||
d->animState = Still;
|
||||
break;
|
||||
default:
|
||||
kDebug(5010) << "Illegal state";
|
||||
qCDebug(KRDC) << "Illegal state";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "floatingtoolbar.moc"
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
|
||||
set(BUILD_KONSOLE true)
|
||||
if(BUILD_KONSOLE)
|
||||
set(konsoleplugin_SRCS
|
||||
konsoleviewfactory.cpp
|
||||
konsoleview.cpp
|
||||
)
|
||||
if (BUILD_KONSOLE)
|
||||
set(konsoleplugin_SRCS
|
||||
konsoleviewfactory.cpp
|
||||
konsoleview.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(krdc_konsoleplugin ${konsoleplugin_SRCS})
|
||||
add_library(krdc_konsoleplugin ${konsoleplugin_SRCS})
|
||||
|
||||
target_link_libraries(krdc_konsoleplugin
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_KPARTS_LIBS}
|
||||
krdccore
|
||||
)
|
||||
install(TARGETS krdc_konsoleplugin DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
kcoreaddons_desktop_to_json(krdc_konsoleplugin krdc_test.desktop)
|
||||
|
||||
install(FILES krdc_konsole.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
find_package(KF5 REQUIRED COMPONENTS Parts)
|
||||
target_link_libraries(krdc_konsoleplugin
|
||||
Qt5::Core
|
||||
KF5::Wallet
|
||||
KF5::ConfigCore
|
||||
KF5::Parts
|
||||
Qt5::Gui
|
||||
krdccore
|
||||
)
|
||||
|
||||
install(TARGETS krdc_konsoleplugin DESTINATION ${PLUGIN_INSTALL_DIR}/krdc)
|
||||
endif(BUILD_KONSOLE)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "konsoleview.h"
|
||||
|
||||
#include <KParts/Part>
|
||||
#include <KParts/ReadOnlyPart>
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginLoader>
|
||||
#include <KService>
|
||||
|
@ -34,7 +35,7 @@
|
|||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
KonsoleView::KonsoleView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
||||
KonsoleView::KonsoleView(QWidget *parent, const QUrl &url, KConfigGroup configGroup)
|
||||
: RemoteView(parent)
|
||||
{
|
||||
m_url = url;
|
||||
|
@ -49,7 +50,7 @@ KonsoleView::KonsoleView(QWidget *parent, const KUrl &url, KConfigGroup configGr
|
|||
setFixedSize(size);
|
||||
setFixedSize(size);
|
||||
emit framebufferSizeChanged(size.width(), size.height());
|
||||
|
||||
|
||||
KPluginFactory* factory = 0;
|
||||
KService::Ptr service = KService::serviceByDesktopName("konsolepart");
|
||||
if (service) {
|
||||
|
@ -65,7 +66,7 @@ KonsoleView::KonsoleView(QWidget *parent, const KUrl &url, KConfigGroup configGr
|
|||
mainLayout->addWidget(m_terminalWidget);
|
||||
m_terminal = qobject_cast<TerminalInterface *>(part);
|
||||
m_terminal->showShellInDir(QDir::homePath());
|
||||
m_terminal->sendInput("echo " + url.user() + '@' + url.host()/* + ':' + url.port()*/ + '\n');
|
||||
m_terminal->sendInput("echo " + url.userName() + '@' + url.host()/* + ':' + url.port()*/ + '\n');
|
||||
// m_terminal->sendInput("clear\n");
|
||||
m_terminalWidget->resize(size);
|
||||
}
|
||||
|
@ -125,4 +126,3 @@ void KonsoleView::switchFullscreen(bool on)
|
|||
Q_UNUSED(on);
|
||||
}
|
||||
|
||||
#include "konsoleview.moc"
|
||||
|
|
|
@ -39,7 +39,7 @@ class KonsoleView : public RemoteView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KonsoleView(QWidget *parent = 0, const KUrl &url = KUrl(), KConfigGroup configGroup = KConfigGroup());
|
||||
explicit KonsoleView(QWidget *parent = 0, const QUrl &url = QUrl(), KConfigGroup configGroup = KConfigGroup());
|
||||
|
||||
virtual ~KonsoleView();
|
||||
|
||||
|
@ -50,12 +50,12 @@ public:
|
|||
virtual bool start();
|
||||
HostPreferences* hostPreferences();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
virtual void switchFullscreen(bool on);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
KonsoleHostPreferences *m_hostPreferences;
|
||||
TerminalInterface* m_terminal;
|
||||
|
@ -69,7 +69,7 @@ class KonsoleHostPreferences : public HostPreferences
|
|||
public:
|
||||
explicit KonsoleHostPreferences(KConfigGroup configGroup, QObject *parent = 0)
|
||||
: HostPreferences(configGroup, parent) {}
|
||||
|
||||
|
||||
protected:
|
||||
virtual QWidget* createProtocolSpecificConfigPage() { return 0; };
|
||||
};
|
||||
|
|
|
@ -23,29 +23,27 @@
|
|||
|
||||
#include "konsoleviewfactory.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KLocale>
|
||||
#include <KLocalizedString>
|
||||
|
||||
KRDC_PLUGIN_EXPORT(KonsoleViewFactory)
|
||||
K_PLUGIN_FACTORY_WITH_JSON(KrdcFactory, "krdc_konsole.json", registerPlugin<KonsoleViewFactory>();)
|
||||
|
||||
KonsoleViewFactory::KonsoleViewFactory(QObject *parent, const QVariantList &args)
|
||||
: RemoteViewFactory(parent)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
KGlobal::locale()->insertCatalog("krdc");
|
||||
KLocalizedString::setApplicationDomain("krdc");
|
||||
}
|
||||
|
||||
KonsoleViewFactory::~KonsoleViewFactory()
|
||||
{
|
||||
}
|
||||
|
||||
bool KonsoleViewFactory::supportsUrl(const KUrl &url) const
|
||||
bool KonsoleViewFactory::supportsUrl(const QUrl &url) const
|
||||
{
|
||||
return (url.scheme().compare("konsole", Qt::CaseInsensitive) == 0);
|
||||
}
|
||||
|
||||
RemoteView *KonsoleViewFactory::createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
||||
RemoteView *KonsoleViewFactory::createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup)
|
||||
{
|
||||
return new KonsoleView(parent, url, configGroup);
|
||||
}
|
||||
|
@ -54,7 +52,7 @@ HostPreferences *KonsoleViewFactory::createHostPreferences(KConfigGroup configGr
|
|||
{
|
||||
Q_UNUSED(configGroup);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -79,4 +77,4 @@ QString KonsoleViewFactory::connectToolTipText() const
|
|||
"<i>Example: konsoleserver (host)</i></html>");
|
||||
}
|
||||
|
||||
#include "moc_konsoleviewfactory.cpp"
|
||||
#include "konsoleviewfactory.moc"
|
||||
|
|
|
@ -37,16 +37,16 @@ public:
|
|||
|
||||
virtual ~KonsoleViewFactory();
|
||||
|
||||
virtual bool supportsUrl(const KUrl &url) const;
|
||||
virtual bool supportsUrl(const QUrl &url) const;
|
||||
|
||||
virtual RemoteView *createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup);
|
||||
virtual RemoteView *createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup);
|
||||
|
||||
virtual HostPreferences *createHostPreferences(KConfigGroup configGroup, QWidget *parent);
|
||||
|
||||
virtual QString scheme() const;
|
||||
|
||||
virtual QString connectActionText() const;
|
||||
|
||||
|
||||
virtual QString connectButtonText() const;
|
||||
|
||||
virtual QString connectToolTipText() const;
|
||||
|
|
|
@ -2,13 +2,18 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|||
|
||||
set (krdc_rfb_approver_SRCS
|
||||
main.cpp
|
||||
../core/logging.cpp
|
||||
approvermanager.cpp
|
||||
approver.cpp
|
||||
)
|
||||
|
||||
kde4_add_executable(krdc_rfb_approver ${krdc_rfb_approver_SRCS})
|
||||
target_link_libraries(krdc_rfb_approver ${KDE4_KDEUI_LIBS}
|
||||
${TELEPATHY_QT4_LIBRARIES}
|
||||
add_executable(krdc_rfb_approver ${krdc_rfb_approver_SRCS})
|
||||
target_link_libraries(krdc_rfb_approver
|
||||
Qt5::Gui
|
||||
KF5::Notifications
|
||||
KF5::CoreAddons
|
||||
KF5::I18n
|
||||
${TELEPATHY_QT5_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS krdc_rfb_approver ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "approver.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KNotification>
|
||||
#include <KLocalizedString>
|
||||
|
||||
|
@ -43,7 +43,7 @@ Approver::Approver(const Tp::MethodInvocationContextPtr<> &context,
|
|||
m_dispatchOp(dispatchOperation),
|
||||
m_notification(0)
|
||||
{
|
||||
kDebug() << "Initializing approver";
|
||||
qCDebug(KRDC) << "Initializing approver";
|
||||
|
||||
connect(m_dispatchOp->becomeReady(),
|
||||
SIGNAL(finished(Tp::PendingOperation*)),
|
||||
|
@ -53,14 +53,14 @@ Approver::Approver(const Tp::MethodInvocationContextPtr<> &context,
|
|||
void Approver::onDispatchOperationReady(Tp::PendingOperation *op)
|
||||
{
|
||||
if (op->isError()) {
|
||||
kError() << "Dispatch operation failed to become ready"
|
||||
qCritical(KRDC) << "Dispatch operation failed to become ready"
|
||||
<< op->errorName() << op->errorMessage();
|
||||
m_context->setFinishedWithError(op->errorName(), op->errorMessage());
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
kDebug() << "DispatchOp ready!";
|
||||
qCDebug(KRDC) << "DispatchOp ready!";
|
||||
|
||||
Tp::ChannelPtr channel = m_dispatchOp->channels()[0];
|
||||
connect(channel->becomeReady(),
|
||||
|
@ -71,18 +71,18 @@ void Approver::onDispatchOperationReady(Tp::PendingOperation *op)
|
|||
void Approver::onChannelReady(Tp::PendingOperation *op)
|
||||
{
|
||||
if (op->isError()) {
|
||||
kError() << "Channel failed to become ready"
|
||||
qCritical(KRDC) << "Channel failed to become ready"
|
||||
<< op->errorName() << op->errorMessage();
|
||||
m_context->setFinishedWithError(op->errorName(), op->errorMessage());
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
kDebug() << "Channel ready!";
|
||||
qCDebug(KRDC) << "Channel ready!";
|
||||
|
||||
Tp::ContactPtr contact = m_dispatchOp->channels()[0]->initiatorContact();
|
||||
|
||||
KNotification *notification = new KNotification("newrfb", NULL, KNotification::Persistent);
|
||||
KNotification *notification = new KNotification(QLatin1String("newrfb"), NULL, KNotification::Persistent);
|
||||
notification->setTitle(i18n("Invitation to view remote desktop"));
|
||||
notification->setText(i18n("%1 wants to share his/her desktop with you", contact->alias()));
|
||||
notification->setActions(QStringList() << i18n("Accept") << i18n("Reject"));
|
||||
|
@ -116,20 +116,20 @@ void Approver::onChannelReady(Tp::PendingOperation *op)
|
|||
|
||||
Approver::~Approver()
|
||||
{
|
||||
kDebug() << "Destroying approver";
|
||||
qCDebug(KRDC) << "Destroying approver";
|
||||
}
|
||||
|
||||
void Approver::onAccepted()
|
||||
{
|
||||
kDebug() << "Channel approved";
|
||||
m_dispatchOp->handleWith(TP_QT_IFACE_CLIENT + ".krdc_rfb_handler");
|
||||
qCDebug(KRDC) << "Channel approved";
|
||||
m_dispatchOp->handleWith(TP_QT_IFACE_CLIENT + QLatin1String(".krdc_rfb_handler"));
|
||||
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void Approver::onRejected()
|
||||
{
|
||||
kDebug() << "Channel rejected";
|
||||
qCDebug(KRDC) << "Channel rejected";
|
||||
connect(m_dispatchOp->claim(), SIGNAL(finished(Tp::PendingOperation*)),
|
||||
SLOT(onClaimFinished(Tp::PendingOperation*)));
|
||||
}
|
||||
|
@ -137,11 +137,10 @@ void Approver::onRejected()
|
|||
void Approver::onClaimFinished(Tp::PendingOperation *op)
|
||||
{
|
||||
if (op->isError()) {
|
||||
kError() << "Claim operation failed"
|
||||
qCritical(KRDC) << "Claim operation failed"
|
||||
<< op->errorName() << op->errorMessage();
|
||||
m_context->setFinishedWithError(op->errorName(), op->errorMessage());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
foreach(const Tp::ChannelPtr &channel, m_channels)
|
||||
channel->requestClose();
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
#include <QObject>
|
||||
|
||||
#include <TelepathyQt/Channel>
|
||||
|
||||
class KNotification;
|
||||
#include <KNotifications/KNotification>
|
||||
|
||||
class Approver : public QObject
|
||||
{
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
|
||||
#include "approvermanager.h"
|
||||
#include "approver.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusConnection>
|
||||
|
||||
#include <KApplication>
|
||||
#include <KDebug>
|
||||
#include <QApplication>
|
||||
#include <QUrl>
|
||||
|
||||
#include <TelepathyQt/Account>
|
||||
#include <TelepathyQt/ChannelClassSpecList>
|
||||
|
@ -45,8 +45,8 @@ static inline Tp::ChannelClassSpecList channelClassSpecList()
|
|||
spec.setChannelType(TP_QT_IFACE_CHANNEL_TYPE_STREAM_TUBE);
|
||||
spec.setTargetHandleType(Tp::HandleTypeContact);
|
||||
spec.setRequested(false);
|
||||
spec.setProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAM_TUBE + ".Service",
|
||||
QVariant("rfb"));
|
||||
spec.setProperty(TP_QT_IFACE_CHANNEL_TYPE_STREAM_TUBE + QLatin1String(".Service"),
|
||||
QVariant(QLatin1String("rfb")));
|
||||
return Tp::ChannelClassSpecList() << spec;
|
||||
}
|
||||
|
||||
|
@ -54,18 +54,18 @@ ApproverManager::ApproverManager(QObject *parent)
|
|||
: QObject(parent),
|
||||
AbstractClientApprover(channelClassSpecList())
|
||||
{
|
||||
kDebug() << "Initializing approver manager";
|
||||
qCDebug(KRDC) << "Initializing approver manager";
|
||||
}
|
||||
|
||||
ApproverManager::~ApproverManager()
|
||||
{
|
||||
kDebug() << "Destroying approver manager";
|
||||
qCDebug(KRDC) << "Destroying approver manager";
|
||||
}
|
||||
|
||||
void ApproverManager::addDispatchOperation(const Tp::MethodInvocationContextPtr<> &context,
|
||||
const Tp::ChannelDispatchOperationPtr &dispatchOperation)
|
||||
{
|
||||
kDebug() << "New channel for approving arrived";
|
||||
qCDebug(KRDC) << "New channel for approving arrived";
|
||||
|
||||
Approver *approver = new Approver(context, dispatchOperation->channels(), dispatchOperation, this);
|
||||
connect(approver, SIGNAL(finished()), SLOT(onFinished()));
|
||||
|
@ -75,14 +75,14 @@ void ApproverManager::addDispatchOperation(const Tp::MethodInvocationContextPtr<
|
|||
|
||||
void ApproverManager::onFinished()
|
||||
{
|
||||
kDebug() << "Approver finished";
|
||||
qCDebug(KRDC) << "Approver finished";
|
||||
|
||||
Approver *approver = qobject_cast<Approver*>(sender());
|
||||
m_approvers.removeOne(approver);
|
||||
approver->deleteLater();
|
||||
|
||||
if (m_approvers.empty()) {
|
||||
kDebug() << "Quitting approver manager";
|
||||
KApplication::kApplication()->quit();
|
||||
qCDebug(KRDC) << "Quitting approver manager";
|
||||
QApplication::quit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
|
||||
#include "approvermanager.h"
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KCmdLineArgs>
|
||||
#include <KLocalizedString>
|
||||
#include <KUniqueApplication>
|
||||
#include <KCoreAddons/KAboutData>
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <TelepathyQt/Types>
|
||||
#include <TelepathyQt/Debug>
|
||||
|
@ -35,20 +35,19 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
KAboutData aboutData("krdc_rfb_approver", "KRDC", ki18n("KRDC"), "0.1",
|
||||
ki18n("Approver for KRDC"), KAboutData::License_GPL,
|
||||
ki18n("(C) 2009, Abner Silva"));
|
||||
aboutData.setProgramIconName("krdc");
|
||||
aboutData.addAuthor(ki18nc("@info:credit", "Abner Silva"), KLocalizedString(),
|
||||
"abner.silva@kdemail.net");
|
||||
QApplication app(argc, argv);
|
||||
|
||||
KCmdLineArgs::init(argc, argv, &aboutData);
|
||||
KAboutData aboutData(QStringLiteral("krdc_rfb_approver"), i18n("KRDC"), i18n("Approver for KRDC"),
|
||||
i18n("0.1"), KAboutLicense::LicenseKey::GPL, i18n("(C) 2009, Abner Silva"));
|
||||
|
||||
if (!KUniqueApplication::start())
|
||||
return 0;
|
||||
aboutData.addCredit(i18n("Abner Silva"), i18n(""), QStringLiteral("abner.silva@kdemail.net"));
|
||||
KAboutData::setApplicationData(aboutData);
|
||||
|
||||
KUniqueApplication app;
|
||||
app.disableSessionManagement();
|
||||
app.setApplicationName(aboutData.componentName());
|
||||
app.setApplicationDisplayName(aboutData.displayName());
|
||||
app.setOrganizationDomain(aboutData.organizationDomain());
|
||||
app.setApplicationVersion(aboutData.version());
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
Tp::registerTypes();
|
||||
Tp::enableDebug(true);
|
||||
|
@ -57,7 +56,7 @@ int main(int argc, char **argv)
|
|||
Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create();
|
||||
Tp::SharedPtr<ApproverManager> approverManager;
|
||||
approverManager = Tp::SharedPtr<ApproverManager>(new ApproverManager(0));
|
||||
registrar->registerClient(Tp::AbstractClientPtr::dynamicCast(approverManager), "krdc_rfb_approver");
|
||||
registrar->registerClient(Tp::AbstractClientPtr::dynamicCast(approverManager), QLatin1String("krdc_rfb_approver"));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
112
main.cpp
112
main.cpp
|
@ -23,22 +23,34 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "logging.h"
|
||||
#include "krdc_version.h"
|
||||
|
||||
#include <KApplication>
|
||||
#include <KLocale>
|
||||
#include <KCmdLineArgs>
|
||||
#include <KAboutData>
|
||||
#include <KDebug>
|
||||
|
||||
#include <KCoreAddons/KAboutData>
|
||||
#include <Kdelibs4ConfigMigrator>
|
||||
#include <KI18n/KLocalizedString>
|
||||
#include <QTime>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QPluginLoader>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const QLatin1String appName("krdc");
|
||||
QApplication app(argc, argv);
|
||||
QTime startupTimer;
|
||||
startupTimer.start();
|
||||
KAboutData aboutData("krdc", 0, ki18n("KRDC"), KDE_VERSION_STRING,
|
||||
ki18n("KDE Remote Desktop Client"), KAboutData::License_GPL,
|
||||
ki18n("(c) 2007-2013, Urs Wolfer\n"
|
||||
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
|
||||
Kdelibs4ConfigMigrator migrate(appName);
|
||||
migrate.setConfigFiles(QStringList() << QLatin1String("krdcrc"));
|
||||
migrate.migrate();
|
||||
|
||||
KAboutData aboutData(appName, i18n("KRDC"), QString(KRDC_VERSION),
|
||||
i18n("KDE Remote Desktop Client"), KAboutLicense::LicenseKey::GPL);
|
||||
|
||||
aboutData.setCopyrightStatement(i18n("(c) 2007-2013, Urs Wolfer\n"
|
||||
"(c) 2001-2003, Tim Jansen\n"
|
||||
"(c) 2002-2003, Arend van Beelen jr.\n"
|
||||
"(c) 2000-2002, Const Kaplinsky\n"
|
||||
|
@ -47,59 +59,65 @@ int main(int argc, char **argv)
|
|||
"(c) 1999-2003, Matthew Chapman\n"
|
||||
"(c) 2009, Collabora Ltd"));
|
||||
|
||||
aboutData.addAuthor(ki18n("Urs Wolfer"), ki18n("Developer, Maintainer"), "uwolfer@kde.org");
|
||||
aboutData.addAuthor(ki18n("Tony Murray"), ki18n("Developer"), "murraytony@gmail.com");
|
||||
aboutData.addAuthor(ki18n("Tim Jansen"), ki18n("Former Developer"), "tim@tjansen.de");
|
||||
aboutData.addAuthor(ki18n("Arend van Beelen jr."), ki18n("Initial RDP backend"), "arend@auton.nl");
|
||||
aboutData.addCredit(ki18n("Brad Hards"), ki18n("Google Summer of Code 2007 KRDC project mentor"),
|
||||
"bradh@frogmouth.net");
|
||||
aboutData.addCredit(ki18n("LibVNCServer / LibVNCClient developers"), ki18n("VNC client library"),
|
||||
"libvncserver-common@lists.sf.net", "http://libvncserver.sourceforge.net/");
|
||||
aboutData.addAuthor(ki18n("Abner Silva"), ki18n("Telepathy Tubes Integration"), "abner.silva@kdemail.net");
|
||||
aboutData.addAuthor(i18n("Urs Wolfer"), i18n("Developer, Maintainer"), QLatin1String("uwolfer@kde.org"));
|
||||
aboutData.addAuthor(i18n("Tony Murray"), i18n("Developer"), QLatin1String("murraytony@gmail.com"));
|
||||
aboutData.addAuthor(i18n("Tim Jansen"), i18n("Former Developer"), QLatin1String("tim@tjansen.de"));
|
||||
aboutData.addAuthor(i18n("Arend van Beelen jr."), i18n("Initial RDP backend"), QLatin1String("arend@auton.nl"));
|
||||
aboutData.addCredit(i18n("Brad Hards"), i18n("Google Summer of Code 2007 KRDC project mentor"),
|
||||
QLatin1String("bradh@frogmouth.net"));
|
||||
aboutData.addCredit(i18n("LibVNCServer / LibVNCClient developers"), i18n("VNC client library"),
|
||||
QLatin1String("libvncserver-common@lists.sf.net"), QLatin1String("http://libvncserver.sourceforge.net/"));
|
||||
aboutData.addAuthor(i18n("Abner Silva"), i18n("Telepathy Tubes Integration"), QLatin1String("abner.silva@kdemail.net"));
|
||||
aboutData.setOrganizationDomain("kde.org");
|
||||
KAboutData::setApplicationData(aboutData);
|
||||
|
||||
KCmdLineArgs::init(argc, argv, &aboutData);
|
||||
app.setApplicationName(aboutData.componentName());
|
||||
app.setApplicationDisplayName(aboutData.displayName());
|
||||
app.setOrganizationDomain(aboutData.organizationDomain());
|
||||
app.setApplicationVersion(aboutData.version());
|
||||
app.setWindowIcon(QIcon::fromTheme(appName));
|
||||
|
||||
KCmdLineOptions options;
|
||||
options.add("fullscreen", ki18n("Start KRDC with the provided URL in fullscreen mode (works only with one URL)"));
|
||||
options.add("!+[URL]", ki18n("URLs to connect after startup"));
|
||||
QCommandLineParser parser;
|
||||
parser.addVersionOption();
|
||||
parser.addHelpOption();
|
||||
aboutData.setupCommandLine(&parser);
|
||||
|
||||
KCmdLineArgs::addCmdLineOptions(options);
|
||||
|
||||
KApplication app;
|
||||
// command line options
|
||||
parser.addOption(QCommandLineOption(QStringList() << QLatin1String("fullscreen"),
|
||||
i18n("Start KRDC with the provided URL in fullscreen mode (works only with one URL)")));
|
||||
parser.addPositionalArgument(QLatin1String("url"), i18n("URLs to connect after startup"));
|
||||
|
||||
parser.process(app);
|
||||
aboutData.processCommandLine(&parser);
|
||||
MainWindow *mainwindow = new MainWindow;
|
||||
mainwindow->show();
|
||||
const QStringList args = parser.positionalArguments();
|
||||
if (args.length() > 0) {
|
||||
for (int i = 0; i < args.length(); ++i) {
|
||||
QUrl url = QUrl::fromLocalFile(args.at(i));
|
||||
if (url.scheme().isEmpty() || url.host().isEmpty()) { // unusable url; try to recover it...
|
||||
QString arg = args.at(i);
|
||||
|
||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||
qCDebug(KRDC) << "unusable url; try to recover it:" << arg;
|
||||
|
||||
if (args->count() > 0) {
|
||||
for (int i = 0; i < args->count(); ++i) {
|
||||
KUrl u(args->url(i));
|
||||
if (arg.lastIndexOf(QLatin1Char('/')) != 0)
|
||||
arg = arg.right(arg.length() - arg.lastIndexOf(QLatin1Char('/')) - 1);
|
||||
|
||||
if (u.scheme().isEmpty() || u.host().isEmpty()) { // unusable url; try to recover it...
|
||||
QString arg(args->url(i).url());
|
||||
if (!arg.contains(QLatin1String("://")))
|
||||
arg.prepend(QLatin1String("vnc://")); // vnc was default in kde3 times...
|
||||
|
||||
kDebug(5010) << "unusable url; try to recover it:" << arg;
|
||||
qCDebug(KRDC) << "recovered url:" << arg;
|
||||
|
||||
if (arg.lastIndexOf('/') != 0)
|
||||
arg = arg.right(arg.length() - arg.lastIndexOf('/') - 1);
|
||||
|
||||
if (!arg.contains("://"))
|
||||
arg.prepend("vnc://"); // vnc was default in kde3 times...
|
||||
|
||||
kDebug(5010) << "recovered url:" << arg;
|
||||
|
||||
u = arg;
|
||||
url = QUrl(arg);
|
||||
}
|
||||
if (!url.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!u.isValid())
|
||||
continue;
|
||||
|
||||
mainwindow->newConnection(u, ((args->isSet("fullscreen")) && (args->count() == 1)));
|
||||
mainwindow->newConnection(url, parser.isSet(QLatin1String("fullscreen")));
|
||||
}
|
||||
}
|
||||
|
||||
kDebug(5010) << "########## KRDC ready:" << startupTimer.elapsed() << "ms ##########";
|
||||
qCDebug(KRDC) << "########## KRDC ready:" << startupTimer.elapsed() << "ms ##########";
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
386
mainwindow.cpp
386
mainwindow.cpp
|
@ -23,7 +23,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "logging.h"
|
||||
#include "remoteview.h"
|
||||
#include "settings.h"
|
||||
#include "config/preferencesdialog.h"
|
||||
|
@ -39,24 +39,17 @@
|
|||
#include "tubesmanager.h"
|
||||
#endif
|
||||
|
||||
#include <KAction>
|
||||
#include <KActionCollection>
|
||||
#include <KActionMenu>
|
||||
#include <KComboBox>
|
||||
#include <KIcon>
|
||||
#include <KInputDialog>
|
||||
#include <KLineEdit>
|
||||
#include <KLocale>
|
||||
#include <KMenu>
|
||||
#include <KMenuBar>
|
||||
#include <KLocalizedString>
|
||||
#include <KMessageBox>
|
||||
#include <KNotifyConfigWidget>
|
||||
#include <KPluginInfo>
|
||||
#include <KPushButton>
|
||||
#include <KStatusBar>
|
||||
#include <KToggleAction>
|
||||
#include <KToggleFullScreenAction>
|
||||
#include <KServiceTypeTrader>
|
||||
#include <KPluginTrader>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDockWidget>
|
||||
|
@ -64,10 +57,18 @@
|
|||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QIcon>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStatusBar>
|
||||
#include <QScrollBar>
|
||||
#include <QTabWidget>
|
||||
#include <QTableView>
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
|
@ -95,23 +96,21 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
setStandardToolBarMenuEnabled(true);
|
||||
|
||||
m_tabWidget = new TabbedViewWidget(this);
|
||||
m_tabWidget->setAutoFillBackground(true);
|
||||
m_tabWidget->setMovable(true);
|
||||
m_tabWidget->setTabPosition((KTabWidget::TabPosition) Settings::tabPosition());
|
||||
m_tabWidget->setTabPosition((QTabWidget::TabPosition) Settings::tabPosition());
|
||||
|
||||
#if QT_VERSION >= 0x040500
|
||||
m_tabWidget->setTabsClosable(Settings::tabCloseButton());
|
||||
#else
|
||||
m_tabWidget->setCloseButtonEnabled(Settings::tabCloseButton());
|
||||
#endif
|
||||
|
||||
connect(m_tabWidget, SIGNAL(closeRequest(QWidget*)), SLOT(closeTab(QWidget*)));
|
||||
connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)));
|
||||
|
||||
if (Settings::tabMiddleClick())
|
||||
connect(m_tabWidget, SIGNAL(mouseMiddleClick(QWidget*)), SLOT(closeTab(QWidget*)));
|
||||
connect(m_tabWidget, SIGNAL(mouseMiddleClick(int)), SLOT(closeTab(int)));
|
||||
|
||||
connect(m_tabWidget, SIGNAL(mouseDoubleClick(QWidget*)), SLOT(openTabSettings(QWidget*)));
|
||||
connect(m_tabWidget, SIGNAL(mouseDoubleClick()), SLOT(newConnectionPage()));
|
||||
connect(m_tabWidget, SIGNAL(contextMenu(QWidget*,QPoint)), SLOT(tabContextMenu(QWidget*,QPoint)));
|
||||
connect(m_tabWidget, SIGNAL(tabBarDoubleClicked(int)), SLOT(openTabSettings(int)));
|
||||
|
||||
m_tabWidget->tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_tabWidget->tabBar(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(tabContextMenu(QPoint)));
|
||||
|
||||
m_tabWidget->setMinimumSize(600, 400);
|
||||
setCentralWidget(m_tabWidget);
|
||||
|
@ -145,53 +144,53 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::setupActions()
|
||||
{
|
||||
QAction *connectionAction = actionCollection()->addAction("new_connection");
|
||||
QAction *connectionAction = actionCollection()->addAction(QStringLiteral("new_connection"));
|
||||
connectionAction->setText(i18n("New Connection"));
|
||||
connectionAction->setIcon(KIcon("network-connect"));
|
||||
connectionAction->setIcon(QIcon::fromTheme(QLatin1String("network-connect")));
|
||||
connect(connectionAction, SIGNAL(triggered()), SLOT(newConnectionPage()));
|
||||
|
||||
QAction *screenshotAction = actionCollection()->addAction("take_screenshot");
|
||||
QAction *screenshotAction = actionCollection()->addAction(QStringLiteral("take_screenshot"));
|
||||
screenshotAction->setText(i18n("Copy Screenshot to Clipboard"));
|
||||
screenshotAction->setIconText(i18n("Screenshot"));
|
||||
screenshotAction->setIcon(KIcon("ksnapshot"));
|
||||
screenshotAction->setIcon(QIcon::fromTheme(QLatin1String("ksnapshot")));
|
||||
connect(screenshotAction, SIGNAL(triggered()), SLOT(takeScreenshot()));
|
||||
|
||||
KAction *fullscreenAction = actionCollection()->addAction("switch_fullscreen"); // note: please do not switch to KStandardShortcut unless you know what you are doing (see history of this file)
|
||||
QAction *fullscreenAction = actionCollection()->addAction(QStringLiteral("switch_fullscreen")); // note: please do not switch to KStandardShortcut unless you know what you are doing (see history of this file)
|
||||
fullscreenAction->setText(i18n("Switch to Full Screen Mode"));
|
||||
fullscreenAction->setIconText(i18n("Full Screen"));
|
||||
fullscreenAction->setIcon(KIcon("view-fullscreen"));
|
||||
fullscreenAction->setShortcut(KStandardShortcut::fullScreen());
|
||||
fullscreenAction->setIcon(QIcon::fromTheme(QLatin1String("view-fullscreen")));
|
||||
actionCollection()->setDefaultShortcuts(fullscreenAction, KStandardShortcut::fullScreen());
|
||||
connect(fullscreenAction, SIGNAL(triggered()), SLOT(switchFullscreen()));
|
||||
|
||||
QAction *viewOnlyAction = actionCollection()->addAction("view_only");
|
||||
QAction *viewOnlyAction = actionCollection()->addAction(QStringLiteral("view_only"));
|
||||
viewOnlyAction->setCheckable(true);
|
||||
viewOnlyAction->setText(i18n("View Only"));
|
||||
viewOnlyAction->setIcon(KIcon("document-preview"));
|
||||
viewOnlyAction->setIcon(QIcon::fromTheme(QLatin1String("document-preview")));
|
||||
connect(viewOnlyAction, SIGNAL(triggered(bool)), SLOT(viewOnly(bool)));
|
||||
|
||||
KAction *disconnectAction = actionCollection()->addAction("disconnect");
|
||||
QAction *disconnectAction = actionCollection()->addAction(QStringLiteral("disconnect"));
|
||||
disconnectAction->setText(i18n("Disconnect"));
|
||||
disconnectAction->setIcon(KIcon("network-disconnect"));
|
||||
disconnectAction->setShortcut(QKeySequence::Close);
|
||||
disconnectAction->setIcon(QIcon::fromTheme(QLatin1String("network-disconnect")));
|
||||
actionCollection()->setDefaultShortcuts(disconnectAction, KStandardShortcut::close());
|
||||
connect(disconnectAction, SIGNAL(triggered()), SLOT(disconnectHost()));
|
||||
|
||||
QAction *showLocalCursorAction = actionCollection()->addAction("show_local_cursor");
|
||||
QAction *showLocalCursorAction = actionCollection()->addAction(QStringLiteral("show_local_cursor"));
|
||||
showLocalCursorAction->setCheckable(true);
|
||||
showLocalCursorAction->setIcon(KIcon("input-mouse"));
|
||||
showLocalCursorAction->setIcon(QIcon::fromTheme(QLatin1String("input-mouse")));
|
||||
showLocalCursorAction->setText(i18n("Show Local Cursor"));
|
||||
showLocalCursorAction->setIconText(i18n("Local Cursor"));
|
||||
connect(showLocalCursorAction, SIGNAL(triggered(bool)), SLOT(showLocalCursor(bool)));
|
||||
|
||||
QAction *grabAllKeysAction = actionCollection()->addAction("grab_all_keys");
|
||||
QAction *grabAllKeysAction = actionCollection()->addAction(QStringLiteral("grab_all_keys"));
|
||||
grabAllKeysAction->setCheckable(true);
|
||||
grabAllKeysAction->setIcon(KIcon("configure-shortcuts"));
|
||||
grabAllKeysAction->setIcon(QIcon::fromTheme(QLatin1String("configure-shortcuts")));
|
||||
grabAllKeysAction->setText(i18n("Grab All Possible Keys"));
|
||||
grabAllKeysAction->setIconText(i18n("Grab Keys"));
|
||||
connect(grabAllKeysAction, SIGNAL(triggered(bool)), SLOT(grabAllKeys(bool)));
|
||||
|
||||
QAction *scaleAction = actionCollection()->addAction("scale");
|
||||
QAction *scaleAction = actionCollection()->addAction(QStringLiteral("scale"));
|
||||
scaleAction->setCheckable(true);
|
||||
scaleAction->setIcon(KIcon("zoom-fit-best"));
|
||||
scaleAction->setIcon(QIcon::fromTheme(QLatin1String("zoom-fit-best")));
|
||||
scaleAction->setText(i18n("Scale Remote Screen to Fit Window Size"));
|
||||
scaleAction->setIconText(i18n("Scale"));
|
||||
connect(scaleAction, SIGNAL(triggered(bool)), SLOT(scale(bool)));
|
||||
|
@ -205,41 +204,29 @@ void MainWindow::setupActions()
|
|||
|
||||
KActionMenu *bookmarkMenu = new KActionMenu(i18n("Bookmarks"), actionCollection());
|
||||
m_bookmarkManager = new BookmarkManager(actionCollection(), bookmarkMenu->menu(), this);
|
||||
actionCollection()->addAction("bookmark" , bookmarkMenu);
|
||||
connect(m_bookmarkManager, SIGNAL(openUrl(KUrl)), SLOT(newConnection(KUrl)));
|
||||
actionCollection()->addAction(QLatin1String("bookmark") , bookmarkMenu);
|
||||
connect(m_bookmarkManager, SIGNAL(openUrl(QUrl)), SLOT(newConnection(QUrl)));
|
||||
}
|
||||
|
||||
void MainWindow::loadAllPlugins()
|
||||
{
|
||||
const KService::List offers = KServiceTypeTrader::self()->query("KRDC/Plugin");
|
||||
|
||||
KConfigGroup conf(KGlobal::config(), "Plugins");
|
||||
|
||||
const KPluginInfo::List offers = KPluginTrader::self()->query(QLatin1String("krdc"));
|
||||
const KConfigGroup conf = KSharedConfig::openConfig()->group(QLatin1String("Plugins"));
|
||||
qCDebug(KRDC) << "Loading Plugins ";
|
||||
for (int i = 0; i < offers.size(); i++) {
|
||||
KService::Ptr offer = offers[i];
|
||||
|
||||
RemoteViewFactory *remoteView;
|
||||
|
||||
KPluginInfo description(offer);
|
||||
description.load(conf);
|
||||
|
||||
const bool selected = description.isPluginEnabled();
|
||||
|
||||
if (selected) {
|
||||
if ((remoteView = createPluginFromService(offer)) != 0) {
|
||||
kDebug(5010) << "### Plugin " + description.name() + " found ###";
|
||||
kDebug(5010) << "# Version:" << description.version();
|
||||
kDebug(5010) << "# Description:" << description.comment();
|
||||
kDebug(5010) << "# Author:" << description.author();
|
||||
const int sorting = offer->property("X-KDE-KRDC-Sorting").toInt();
|
||||
kDebug(5010) << "# Sorting:" << sorting;
|
||||
|
||||
m_remoteViewFactories.insert(sorting, remoteView);
|
||||
KPluginInfo info = offers[i];
|
||||
info.load(conf);
|
||||
const bool enabled = info.isPluginEnabled();
|
||||
if (enabled) {
|
||||
RemoteViewFactory *component = createPluginFromInfo(info);
|
||||
if (component != 0) {
|
||||
const int sorting = info.property(QLatin1String("X-KDE-KRDC-Sorting")).toInt();
|
||||
m_remoteViewFactories.insert(sorting, component);
|
||||
} else {
|
||||
kDebug(5010) << "Error loading KRDC plugin (" << (offers[i])->library() << ')';
|
||||
qCDebug(KRDC) << "Error loading KRDC plugin (" << info.pluginName() << ')';
|
||||
}
|
||||
} else {
|
||||
kDebug(5010) << "# Plugin " + description.name() + " found, however it's not activated, skipping...";
|
||||
qCDebug(KRDC) << "# Plugin " << info.name() << " found, however it's not activated, skipping...";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -247,54 +234,49 @@ void MainWindow::loadAllPlugins()
|
|||
#ifdef TELEPATHY_SUPPORT
|
||||
/* Start tube handler */
|
||||
m_tubesManager = new TubesManager(this);
|
||||
connect(m_tubesManager, SIGNAL(newConnection(KUrl)), SLOT(newConnection(KUrl)));
|
||||
connect(m_tubesManager, SIGNAL(newConnection(QUrl)), SLOT(newConnection(QUrl)));
|
||||
#endif
|
||||
}
|
||||
|
||||
RemoteViewFactory *MainWindow::createPluginFromService(const KService::Ptr &service)
|
||||
RemoteViewFactory *MainWindow::createPluginFromInfo(const KPluginInfo &info)
|
||||
{
|
||||
//try to load the specified library
|
||||
KPluginFactory *factory = KPluginLoader(service->library()).factory();
|
||||
|
||||
if (!factory) {
|
||||
kError(5010) << "KPluginFactory could not load the plugin:" << service->library();
|
||||
return 0;
|
||||
RemoteViewFactory *plugin;
|
||||
KPluginLoader loader(info.libraryPath());
|
||||
KPluginFactory *factory = loader.factory();
|
||||
if (factory) {
|
||||
plugin = factory->create<RemoteViewFactory>();
|
||||
}
|
||||
|
||||
RemoteViewFactory *plugin = factory->create<RemoteViewFactory>();
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
void MainWindow::restoreOpenSessions()
|
||||
{
|
||||
const QStringList list = Settings::openSessions();
|
||||
QStringList::ConstIterator it = list.begin();
|
||||
QStringList::ConstIterator end = list.end();
|
||||
while (it != end) {
|
||||
newConnection(*it);
|
||||
++it;
|
||||
QListIterator<QString> it(list);
|
||||
while (it.hasNext()) {
|
||||
newConnection(QUrl(it.next()));
|
||||
}
|
||||
}
|
||||
|
||||
KUrl MainWindow::getInputUrl()
|
||||
QUrl MainWindow::getInputUrl()
|
||||
{
|
||||
QString userInput = m_addressInput->text();
|
||||
|
||||
// percent encode usernames so KUrl can parse it
|
||||
int lastAtIndex = userInput.indexOf(QRegExp("@[^@]+$"));
|
||||
qCDebug(KRDC) << "input url " << userInput;
|
||||
// percent encode usernames so QUrl can parse it
|
||||
int lastAtIndex = userInput.indexOf(QRegExp(QLatin1String("@[^@]+$")));
|
||||
if (lastAtIndex >0) {
|
||||
userInput = KUrl::toPercentEncoding(userInput.left(lastAtIndex)) + userInput.mid(lastAtIndex);
|
||||
userInput = QUrl::fromLocalFile(userInput.left(lastAtIndex)).toString(QUrl::FullyEncoded) + userInput.mid(lastAtIndex);
|
||||
qCDebug(KRDC) << "input url " << userInput;
|
||||
}
|
||||
|
||||
return KUrl(m_protocolInput->currentText() + "://" + userInput);
|
||||
return QUrl(m_protocolInput->currentText() + QLatin1String("://") + userInput);
|
||||
}
|
||||
|
||||
void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConnected, const QString &tabName)
|
||||
void MainWindow::newConnection(const QUrl &newUrl, bool switchFullscreenWhenConnected, const QString &tabName)
|
||||
{
|
||||
m_switchFullscreenWhenConnected = switchFullscreenWhenConnected;
|
||||
|
||||
const KUrl url = newUrl.isEmpty() ? getInputUrl() : newUrl;
|
||||
const QUrl url = newUrl.isEmpty() ? getInputUrl() : newUrl;
|
||||
|
||||
if (!url.isValid() || (url.host().isEmpty() && url.port() < 0)
|
||||
|| (!url.path().isEmpty() && url.path() != QLatin1String("/"))) {
|
||||
|
@ -305,18 +287,18 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
|
|||
}
|
||||
|
||||
if (m_protocolInput && m_addressInput) {
|
||||
int index = m_protocolInput->findText(url.protocol());
|
||||
int index = m_protocolInput->findText(url.scheme());
|
||||
if (index>=0) m_protocolInput->setCurrentIndex(index);
|
||||
m_addressInput->setText(url.authority());
|
||||
}
|
||||
|
||||
RemoteView *view = 0;
|
||||
KConfigGroup configGroup = Settings::self()->config()->group("hostpreferences").group(url.prettyUrl(KUrl::RemoveTrailingSlash));
|
||||
KConfigGroup configGroup = Settings::self()->config()->group(QLatin1String("hostpreferences")).group(url.toDisplayString(QUrl::StripTrailingSlash));
|
||||
|
||||
foreach(RemoteViewFactory *factory, m_remoteViewFactories) {
|
||||
if (factory->supportsUrl(url)) {
|
||||
view = factory->createView(this, url, configGroup);
|
||||
kDebug(5010) << "Found plugin to handle url (" + url.url() + "): " + view->metaObject()->className();
|
||||
qCDebug(KRDC) << "Found plugin to handle url (" << url.url() << "): " << view->metaObject()->className();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +332,7 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
|
|||
if (indexOfNewConnectionWidget >= 0)
|
||||
m_tabWidget->removeTab(indexOfNewConnectionWidget);
|
||||
|
||||
const int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), tabName.isEmpty() ? url.prettyUrl(KUrl::RemoveTrailingSlash) : tabName);
|
||||
const int newIndex = m_tabWidget->addTab(scrollArea, QIcon::fromTheme(QLatin1String("krdc")), tabName.isEmpty() ? url.toDisplayString(QUrl::StripTrailingSlash) : tabName);
|
||||
m_tabWidget->setCurrentIndex(newIndex);
|
||||
m_remoteViewMap.insert(m_tabWidget->widget(newIndex), view);
|
||||
tabChanged(newIndex); // force to update m_currentRemoteView (tabChanged is not emitted when start page has been disabled)
|
||||
|
@ -363,7 +345,7 @@ void MainWindow::openFromRemoteDesktopsModel(const QModelIndex &index)
|
|||
const QString urlString = index.data(10001).toString();
|
||||
const QString nameString = index.data(10003).toString();
|
||||
if (!urlString.isEmpty()) {
|
||||
const KUrl url(urlString);
|
||||
const QUrl url(urlString);
|
||||
// first check if url has already been opened; in case show the tab
|
||||
foreach (QWidget *widget, m_remoteViewMap.keys()) {
|
||||
if (m_remoteViewMap.value(widget)->url() == url) {
|
||||
|
@ -378,9 +360,9 @@ void MainWindow::openFromRemoteDesktopsModel(const QModelIndex &index)
|
|||
|
||||
void MainWindow::resizeTabWidget(int w, int h)
|
||||
{
|
||||
kDebug(5010) << "tabwidget resize, view size: w: " << w << ", h: " << h;
|
||||
qCDebug(KRDC) << "tabwidget resize, view size: w: " << w << ", h: " << h;
|
||||
if (m_fullscreenWindow) {
|
||||
kDebug(5010) << "in fullscreen mode, refusing to resize";
|
||||
qCDebug(KRDC) << "in fullscreen mode, refusing to resize";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -392,7 +374,7 @@ void MainWindow::resizeTabWidget(int w, int h)
|
|||
const QSize screenSize = desktop->screenGeometry(currentScreen).size();
|
||||
|
||||
if (screenSize == viewSize) {
|
||||
kDebug(5010) << "screen size equal to target view size -> switch to fullscreen mode";
|
||||
qCDebug(KRDC) << "screen size equal to target view size -> switch to fullscreen mode";
|
||||
switchFullscreen();
|
||||
return;
|
||||
}
|
||||
|
@ -403,21 +385,21 @@ void MainWindow::resizeTabWidget(int w, int h)
|
|||
const QSize newWindowSize = size() - currentWidget->frameSize() + viewSize;
|
||||
|
||||
const QSize desktopSize = desktop->availableGeometry().size();
|
||||
kDebug(5010) << "new window size: " << newWindowSize << " available space:" << desktopSize;
|
||||
qCDebug(KRDC) << "new window size: " << newWindowSize << " available space:" << desktopSize;
|
||||
|
||||
if ((newWindowSize.width() >= desktopSize.width()) || (newWindowSize.height() >= desktopSize.height())) {
|
||||
kDebug(5010) << "remote desktop needs more space than available -> show window maximized";
|
||||
qCDebug(KRDC) << "remote desktop needs more space than available -> show window maximized";
|
||||
setWindowState(windowState() | Qt::WindowMaximized);
|
||||
return;
|
||||
}
|
||||
|
||||
setWindowState(windowState() & ~ Qt::WindowMaximized);
|
||||
resize(newWindowSize);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::statusChanged(RemoteView::RemoteStatus status)
|
||||
{
|
||||
kDebug(5010) << status;
|
||||
qCDebug(KRDC) << status;
|
||||
|
||||
// the remoteview is already deleted, so don't show it; otherwise it would crash
|
||||
if (status == RemoteView::Disconnecting || status == RemoteView::Disconnected)
|
||||
|
@ -426,24 +408,24 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
|
|||
RemoteView *view = qobject_cast<RemoteView*>(QObject::sender());
|
||||
const QString host = view->host();
|
||||
|
||||
QString iconName = "krdc";
|
||||
QString iconName = QLatin1String("krdc");
|
||||
QString message;
|
||||
|
||||
switch (status) {
|
||||
case RemoteView::Connecting:
|
||||
iconName = "network-connect";
|
||||
iconName = QLatin1String("network-connect");
|
||||
message = i18n("Connecting to %1", host);
|
||||
break;
|
||||
case RemoteView::Authenticating:
|
||||
iconName = "dialog-password";
|
||||
iconName = QLatin1String("dialog-password");
|
||||
message = i18n("Authenticating at %1", host);
|
||||
break;
|
||||
case RemoteView::Preparing:
|
||||
iconName = "view-history";
|
||||
iconName = QLatin1String("view-history");
|
||||
message = i18n("Preparing connection to %1", host);
|
||||
break;
|
||||
case RemoteView::Connected:
|
||||
iconName = "krdc";
|
||||
iconName = QLatin1String("krdc");
|
||||
message = i18n("Connected to %1", host);
|
||||
|
||||
if (view->grabAllKeys() != view->hostPreferences()->grabAllKeys()) {
|
||||
|
@ -466,7 +448,7 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
|
|||
break;
|
||||
}
|
||||
|
||||
m_tabWidget->setTabIcon(m_tabWidget->indexOf(view), KIcon(iconName));
|
||||
m_tabWidget->setTabIcon(m_tabWidget->indexOf(view), QIcon::fromTheme(iconName));
|
||||
if (Settings::showStatusBar())
|
||||
statusBar()->showMessage(message);
|
||||
}
|
||||
|
@ -480,14 +462,14 @@ void MainWindow::takeScreenshot()
|
|||
|
||||
void MainWindow::switchFullscreen()
|
||||
{
|
||||
kDebug(5010);
|
||||
qCDebug(KRDC);
|
||||
|
||||
if (m_fullscreenWindow) {
|
||||
// Leaving full screen mode
|
||||
m_fullscreenWindow->setWindowState(0);
|
||||
m_fullscreenWindow->hide();
|
||||
|
||||
m_tabWidget->setTabBarHidden(m_tabWidget->count() <= 1 && !Settings::showTabBar());
|
||||
m_tabWidget->tabBar()->setHidden(m_tabWidget->count() <= 1 && !Settings::showTabBar());
|
||||
m_tabWidget->setDocumentMode(false);
|
||||
setCentralWidget(m_tabWidget);
|
||||
|
||||
|
@ -505,9 +487,9 @@ void MainWindow::switchFullscreen()
|
|||
m_toolBar = 0;
|
||||
}
|
||||
|
||||
actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-fullscreen"));
|
||||
actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to Full Screen Mode"));
|
||||
actionCollection()->action("switch_fullscreen")->setIconText(i18n("Full Screen"));
|
||||
actionCollection()->action(QLatin1String("switch_fullscreen"))->setIcon(QIcon::fromTheme(QLatin1String("view-fullscreen")));
|
||||
actionCollection()->action(QLatin1String("switch_fullscreen"))->setText(i18n("Switch to Full Screen Mode"));
|
||||
actionCollection()->action(QLatin1String("switch_fullscreen"))->setIconText(i18n("Full Screen"));
|
||||
|
||||
m_fullscreenWindow->deleteLater();
|
||||
m_fullscreenWindow = 0;
|
||||
|
@ -519,7 +501,7 @@ void MainWindow::switchFullscreen()
|
|||
|
||||
m_mainWindowGeometry = saveGeometry();
|
||||
|
||||
m_tabWidget->setTabBarHidden(true);
|
||||
m_tabWidget->tabBar()->hide();
|
||||
m_tabWidget->setDocumentMode(true);
|
||||
|
||||
foreach(RemoteView *currentView, m_remoteViewMap) {
|
||||
|
@ -542,9 +524,9 @@ void MainWindow::switchFullscreen()
|
|||
|
||||
if (m_systemTrayIcon) m_systemTrayIcon->setAssociatedWidget(m_fullscreenWindow);
|
||||
|
||||
actionCollection()->action("switch_fullscreen")->setIcon(KIcon("view-restore"));
|
||||
actionCollection()->action("switch_fullscreen")->setText(i18n("Switch to Window Mode"));
|
||||
actionCollection()->action("switch_fullscreen")->setIconText(i18n("Window Mode"));
|
||||
actionCollection()->action(QLatin1String("switch_fullscreen"))->setIcon(QIcon::fromTheme(QLatin1String("view-restore")));
|
||||
actionCollection()->action(QLatin1String("switch_fullscreen"))->setText(i18n("Switch to Window Mode"));
|
||||
actionCollection()->action(QLatin1String("switch_fullscreen"))->setIconText(i18n("Window Mode"));
|
||||
showRemoteViewToolbar();
|
||||
}
|
||||
if (m_tabWidget->currentWidget() == m_newConnectionWidget) {
|
||||
|
@ -560,12 +542,11 @@ QScrollArea *MainWindow::createScrollArea(QWidget *parent, RemoteView *remoteVie
|
|||
connect(scrollArea, SIGNAL(resized(int,int)), remoteView, SLOT(scaleResize(int,int)));
|
||||
|
||||
QPalette palette = scrollArea->palette();
|
||||
palette.setColor(QPalette::Dark, Settings::backgroundColor());
|
||||
palette.setColor(QPalette::Active, QPalette::Background, Settings::backgroundColor());
|
||||
scrollArea->setPalette(palette);
|
||||
|
||||
scrollArea->setBackgroundRole(QPalette::Dark);
|
||||
scrollArea->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
scrollArea->viewport()->setAutoFillBackground(true);
|
||||
scrollArea->setWidget(remoteView);
|
||||
|
||||
return scrollArea;
|
||||
|
@ -573,7 +554,7 @@ QScrollArea *MainWindow::createScrollArea(QWidget *parent, RemoteView *remoteVie
|
|||
|
||||
void MainWindow::disconnectHost()
|
||||
{
|
||||
kDebug(5010);
|
||||
qCDebug(KRDC);
|
||||
|
||||
RemoteView *view = qobject_cast<RemoteView*>(QObject::sender());
|
||||
|
||||
|
@ -606,8 +587,12 @@ void MainWindow::disconnectHost()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::closeTab(QWidget *widget)
|
||||
void MainWindow::closeTab(int index)
|
||||
{
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
QWidget *widget = m_tabWidget->widget(index);
|
||||
bool isNewConnectionPage = widget == m_newConnectionWidget;
|
||||
|
||||
if (!isNewConnectionPage) {
|
||||
|
@ -633,15 +618,20 @@ void MainWindow::closeTab(QWidget *widget)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::openTabSettings(QWidget *widget)
|
||||
void MainWindow::openTabSettings(int index)
|
||||
{
|
||||
if (index == -1) {
|
||||
newConnectionPage();
|
||||
return;
|
||||
}
|
||||
QWidget *widget = m_tabWidget->widget(index);
|
||||
RemoteViewScrollArea *scrollArea = qobject_cast<RemoteViewScrollArea*>(widget);
|
||||
if (!scrollArea) return;
|
||||
RemoteView *view = qobject_cast<RemoteView*>(scrollArea->widget());
|
||||
if (!view) return;
|
||||
|
||||
const QString url = view->url().url();
|
||||
kDebug(5010) << url;
|
||||
qCDebug(KRDC) << url;
|
||||
|
||||
showSettingsDialog(url);
|
||||
}
|
||||
|
@ -651,12 +641,12 @@ void MainWindow::showSettingsDialog(const QString &url)
|
|||
HostPreferences *prefs = 0;
|
||||
|
||||
foreach(RemoteViewFactory *factory, remoteViewFactoriesList()) {
|
||||
if (factory->supportsUrl(url)) {
|
||||
prefs = factory->createHostPreferences(Settings::self()->config()->group("hostpreferences").group(url), this);
|
||||
if (factory->supportsUrl(QUrl(url))) {
|
||||
prefs = factory->createHostPreferences(Settings::self()->config()->group(QLatin1String("hostpreferences")).group(url), this);
|
||||
if (prefs) {
|
||||
kDebug(5010) << "Found plugin to handle url (" + url + "): " + prefs->metaObject()->className();
|
||||
qCDebug(KRDC) << "Found plugin to handle url (" << url << "): " << prefs->metaObject()->className();
|
||||
} else {
|
||||
kDebug(5010) << "Found plugin to handle url (" + url + "), but plugin does not provide preferences";
|
||||
qCDebug(KRDC) << "Found plugin to handle url (" << url << "), but plugin does not provide preferences";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -685,13 +675,12 @@ void MainWindow::showConnectionContextMenu(const QPoint &pos)
|
|||
const QString title = index.model()->index(index.row(), RemoteDesktopsModel::Title).data(Qt::DisplayRole).toString();
|
||||
const QString source = index.model()->index(index.row(), RemoteDesktopsModel::Source).data(Qt::DisplayRole).toString();
|
||||
|
||||
KMenu *menu = new KMenu(m_newConnectionTableView);
|
||||
menu->addTitle(url);
|
||||
QMenu *menu = new QMenu(url, m_newConnectionTableView);
|
||||
|
||||
QAction *connectAction = menu->addAction(KIcon("network-connect"), i18n("Connect"));
|
||||
QAction *renameAction = menu->addAction(KIcon("edit-rename"), i18n("Rename"));
|
||||
QAction *settingsAction = menu->addAction(KIcon("configure"), i18n("Settings"));
|
||||
QAction *deleteAction = menu->addAction(KIcon("edit-delete"), i18n("Delete"));
|
||||
QAction *connectAction = menu->addAction(QIcon::fromTheme(QLatin1String("network-connect")), i18n("Connect"));
|
||||
QAction *renameAction = menu->addAction(QIcon::fromTheme(QLatin1String("edit-rename")), i18n("Rename"));
|
||||
QAction *settingsAction = menu->addAction(QIcon::fromTheme(QLatin1String("configure")), i18n("Settings"));
|
||||
QAction *deleteAction = menu->addAction(QIcon::fromTheme(QLatin1String("edit-delete")), i18n("Delete"));
|
||||
|
||||
// not very clean, but it works,
|
||||
if (!(source == i18nc("Where each displayed link comes from", "Bookmarks") ||
|
||||
|
@ -707,7 +696,7 @@ void MainWindow::showConnectionContextMenu(const QPoint &pos)
|
|||
} else if (selectedAction == renameAction) {
|
||||
//TODO: use inline editor if possible
|
||||
bool ok = false;
|
||||
const QString newTitle = KInputDialog::getText(i18n("Rename %1", title), i18n("Rename %1 to", title), title, &ok, this);
|
||||
const QString newTitle = QInputDialog::getText(this, i18n("Rename %1", title), i18n("Rename %1 to", title), QLineEdit::EchoMode::Normal, title, &ok);
|
||||
if (ok && !newTitle.isEmpty()) {
|
||||
BookmarkManager::updateTitle(m_bookmarkManager->getManager(), url, newTitle);
|
||||
}
|
||||
|
@ -724,26 +713,27 @@ void MainWindow::showConnectionContextMenu(const QPoint &pos)
|
|||
menu->deleteLater();
|
||||
}
|
||||
|
||||
void MainWindow::tabContextMenu(QWidget *widget, const QPoint &point)
|
||||
void MainWindow::tabContextMenu(const QPoint &point)
|
||||
{
|
||||
int index = m_tabWidget->tabBar()->tabAt(point);
|
||||
QWidget *widget = m_tabWidget->widget(index);
|
||||
RemoteViewScrollArea *scrollArea = qobject_cast<RemoteViewScrollArea*>(widget);
|
||||
if (!scrollArea) return;
|
||||
RemoteView *view = qobject_cast<RemoteView*>(scrollArea->widget());
|
||||
if (!view) return;
|
||||
|
||||
const QString url = view->url().prettyUrl(KUrl::RemoveTrailingSlash);
|
||||
kDebug(5010) << url;
|
||||
const QString url = view->url().toDisplayString(QUrl::StripTrailingSlash);
|
||||
qCDebug(KRDC) << url;
|
||||
|
||||
KMenu *menu = new KMenu(this);
|
||||
menu->addTitle(url);
|
||||
QAction *bookmarkAction = menu->addAction(KIcon("bookmark-new"), i18n("Add Bookmark"));
|
||||
QAction *closeAction = menu->addAction(KIcon("tab-close"), i18n("Close Tab"));
|
||||
QAction *selectedAction = menu->exec(point);
|
||||
QMenu *menu = new QMenu(url, this);
|
||||
QAction *bookmarkAction = menu->addAction(QIcon::fromTheme(QLatin1String("bookmark-new")), i18n("Add Bookmark"));
|
||||
QAction *closeAction = menu->addAction(QIcon::fromTheme(QLatin1String("tab-close")), i18n("Close Tab"));
|
||||
QAction *selectedAction = menu->exec(QCursor::pos());
|
||||
if (selectedAction) {
|
||||
if (selectedAction == closeAction) {
|
||||
closeTab(widget);
|
||||
closeTab(m_tabWidget->indexOf(widget));
|
||||
} else if (selectedAction == bookmarkAction) {
|
||||
m_bookmarkManager->addManualBookmark(url, url);
|
||||
m_bookmarkManager->addManualBookmark(view->url(), url);
|
||||
}
|
||||
}
|
||||
menu->deleteLater();
|
||||
|
@ -751,7 +741,7 @@ void MainWindow::tabContextMenu(QWidget *widget, const QPoint &point)
|
|||
|
||||
void MainWindow::showLocalCursor(bool showLocalCursor)
|
||||
{
|
||||
kDebug(5010) << showLocalCursor;
|
||||
qCDebug(KRDC) << showLocalCursor;
|
||||
|
||||
RemoteView* view = currentRemoteView();
|
||||
view->showDotCursor(showLocalCursor ? RemoteView::CursorOn : RemoteView::CursorOff);
|
||||
|
@ -761,7 +751,7 @@ void MainWindow::showLocalCursor(bool showLocalCursor)
|
|||
|
||||
void MainWindow::viewOnly(bool viewOnly)
|
||||
{
|
||||
kDebug(5010) << viewOnly;
|
||||
qCDebug(KRDC) << viewOnly;
|
||||
|
||||
RemoteView* view = currentRemoteView();
|
||||
view->setViewOnly(viewOnly);
|
||||
|
@ -771,7 +761,7 @@ void MainWindow::viewOnly(bool viewOnly)
|
|||
|
||||
void MainWindow::grabAllKeys(bool grabAllKeys)
|
||||
{
|
||||
kDebug(5010);
|
||||
qCDebug(KRDC);
|
||||
|
||||
RemoteView* view = currentRemoteView();
|
||||
view->setGrabAllKeys(grabAllKeys);
|
||||
|
@ -781,7 +771,7 @@ void MainWindow::grabAllKeys(bool grabAllKeys)
|
|||
|
||||
void MainWindow::scale(bool scale)
|
||||
{
|
||||
kDebug(5010);
|
||||
qCDebug(KRDC);
|
||||
|
||||
RemoteView* view = currentRemoteView();
|
||||
view->enableScaling(scale);
|
||||
|
@ -795,7 +785,7 @@ void MainWindow::scale(bool scale)
|
|||
|
||||
void MainWindow::showRemoteViewToolbar()
|
||||
{
|
||||
kDebug(5010);
|
||||
qCDebug(KRDC);
|
||||
|
||||
if (!m_toolBar) {
|
||||
m_toolBar = new FloatingToolBar(m_fullscreenWindow, m_fullscreenWindow);
|
||||
|
@ -803,7 +793,7 @@ void MainWindow::showRemoteViewToolbar()
|
|||
m_toolBar->setSide(FloatingToolBar::Top);
|
||||
|
||||
KComboBox *sessionComboBox = new KComboBox(m_toolBar);
|
||||
sessionComboBox->setStyleSheet("QComboBox:!editable{background:transparent;}");
|
||||
sessionComboBox->setStyleSheet(QLatin1String("QComboBox:!editable{background:transparent;}"));
|
||||
sessionComboBox->setModel(m_tabWidget->getModel());
|
||||
sessionComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
sessionComboBox->setCurrentIndex(m_tabWidget->currentIndex());
|
||||
|
@ -813,26 +803,26 @@ void MainWindow::showRemoteViewToolbar()
|
|||
|
||||
QToolBar *buttonBox = new QToolBar(m_toolBar);
|
||||
|
||||
buttonBox->addAction(actionCollection()->action("new_connection"));
|
||||
buttonBox->addAction(actionCollection()->action("switch_fullscreen"));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("new_connection")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("switch_fullscreen")));
|
||||
|
||||
QAction *minimizeAction = new QAction(m_toolBar);
|
||||
minimizeAction->setIcon(KIcon("go-down"));
|
||||
minimizeAction->setIcon(QIcon::fromTheme(QLatin1String("go-down")));
|
||||
minimizeAction->setText(i18n("Minimize Full Screen Window"));
|
||||
connect(minimizeAction, SIGNAL(triggered()), m_fullscreenWindow, SLOT(showMinimized()));
|
||||
buttonBox->addAction(minimizeAction);
|
||||
|
||||
buttonBox->addAction(actionCollection()->action("take_screenshot"));
|
||||
buttonBox->addAction(actionCollection()->action("view_only"));
|
||||
buttonBox->addAction(actionCollection()->action("show_local_cursor"));
|
||||
buttonBox->addAction(actionCollection()->action("grab_all_keys"));
|
||||
buttonBox->addAction(actionCollection()->action("scale"));
|
||||
buttonBox->addAction(actionCollection()->action("disconnect"));
|
||||
buttonBox->addAction(actionCollection()->action("file_quit"));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("take_screenshot")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("view_only")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("show_local_cursor")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("grab_all_keys")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("scale")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("disconnect")));
|
||||
buttonBox->addAction(actionCollection()->action(QLatin1String("file_quit")));
|
||||
|
||||
QAction *stickToolBarAction = new QAction(m_toolBar);
|
||||
stickToolBarAction->setCheckable(true);
|
||||
stickToolBarAction->setIcon(KIcon("object-locked"));
|
||||
stickToolBarAction->setIcon(QIcon::fromTheme(QLatin1String("object-locked")));
|
||||
stickToolBarAction->setText(i18n("Stick Toolbar"));
|
||||
connect(stickToolBarAction, SIGNAL(triggered(bool)), m_toolBar, SLOT(setSticky(bool)));
|
||||
buttonBox->addAction(stickToolBarAction);
|
||||
|
@ -850,7 +840,7 @@ void setActionStatus(QAction* action, bool enabled, bool visible, bool checked)
|
|||
|
||||
void MainWindow::updateActionStatus()
|
||||
{
|
||||
kDebug(5010) << m_tabWidget->currentIndex();
|
||||
qCDebug(KRDC) << m_tabWidget->currentIndex();
|
||||
|
||||
bool enabled = true;
|
||||
|
||||
|
@ -859,25 +849,25 @@ void MainWindow::updateActionStatus()
|
|||
|
||||
RemoteView* view = (m_currentRemoteView >= 0 && enabled) ? currentRemoteView() : 0;
|
||||
|
||||
actionCollection()->action("take_screenshot")->setEnabled(enabled);
|
||||
actionCollection()->action("disconnect")->setEnabled(enabled);
|
||||
actionCollection()->action(QLatin1String("take_screenshot"))->setEnabled(enabled);
|
||||
actionCollection()->action(QLatin1String("disconnect"))->setEnabled(enabled);
|
||||
|
||||
setActionStatus(actionCollection()->action("view_only"),
|
||||
setActionStatus(actionCollection()->action(QLatin1String("view_only")),
|
||||
enabled,
|
||||
true,
|
||||
view ? view->viewOnly() : false);
|
||||
|
||||
setActionStatus(actionCollection()->action("show_local_cursor"),
|
||||
setActionStatus(actionCollection()->action(QLatin1String("show_local_cursor")),
|
||||
enabled,
|
||||
view ? view->supportsLocalCursor() : false,
|
||||
view ? view->dotCursorState() == RemoteView::CursorOn : false);
|
||||
|
||||
setActionStatus(actionCollection()->action("scale"),
|
||||
setActionStatus(actionCollection()->action(QLatin1String("scale")),
|
||||
enabled,
|
||||
view ? view->supportsScaling() : false,
|
||||
view ? view->scaling() : false);
|
||||
|
||||
setActionStatus(actionCollection()->action("grab_all_keys"),
|
||||
setActionStatus(actionCollection()->action(QLatin1String("grab_all_keys")),
|
||||
enabled,
|
||||
enabled,
|
||||
view ? view->grabAllKeys() : false);
|
||||
|
@ -888,7 +878,7 @@ void MainWindow::preferences()
|
|||
// An instance of your dialog could be already created and could be
|
||||
// cached, in which case you want to display the cached dialog
|
||||
// instead of creating another one
|
||||
if (PreferencesDialog::showDialog("preferences"))
|
||||
if (PreferencesDialog::showDialog(QLatin1String("preferences")))
|
||||
return;
|
||||
|
||||
// KConfigDialog didn't find an instance of this dialog, so lets
|
||||
|
@ -908,18 +898,15 @@ void MainWindow::updateConfiguration()
|
|||
if (!Settings::showStatusBar())
|
||||
statusBar()->deleteLater();
|
||||
else
|
||||
statusBar()->showMessage(""); // force creation of statusbar
|
||||
statusBar()->showMessage(QLatin1String("")); // force creation of statusbar
|
||||
|
||||
m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && !Settings::showTabBar()) || m_fullscreenWindow);
|
||||
m_tabWidget->setTabPosition((KTabWidget::TabPosition) Settings::tabPosition());
|
||||
#if QT_VERSION >= 0x040500
|
||||
m_tabWidget->tabBar()->setHidden((m_tabWidget->count() <= 1 && !Settings::showTabBar()) || m_fullscreenWindow);
|
||||
m_tabWidget->setTabPosition((QTabWidget::TabPosition) Settings::tabPosition());
|
||||
m_tabWidget->setTabsClosable(Settings::tabCloseButton());
|
||||
#else
|
||||
m_tabWidget->setCloseButtonEnabled(Settings::tabCloseButton());
|
||||
#endif
|
||||
disconnect(m_tabWidget, SIGNAL(mouseMiddleClick(QWidget*)), this, SLOT(closeTab(QWidget*))); // just be sure it is not connected twice
|
||||
|
||||
disconnect(m_tabWidget, SIGNAL(mouseMiddleClick(int)), this, SLOT(closeTab(int))); // just be sure it is not connected twice
|
||||
if (Settings::tabMiddleClick())
|
||||
connect(m_tabWidget, SIGNAL(mouseMiddleClick(QWidget*)), SLOT(closeTab(QWidget*)));
|
||||
connect(m_tabWidget, SIGNAL(mouseMiddleClick(int)), SLOT(closeTab(int)));
|
||||
|
||||
if (Settings::systemTrayIcon() && !m_systemTrayIcon) {
|
||||
m_systemTrayIcon = new SystemTrayIcon(this);
|
||||
|
@ -940,7 +927,6 @@ void MainWindow::updateConfiguration()
|
|||
foreach (RemoteView *view, m_remoteViewMap.values()) {
|
||||
view->updateConfiguration();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::quit(bool systemEvent)
|
||||
|
@ -950,13 +936,13 @@ void MainWindow::quit(bool systemEvent)
|
|||
i18n("Are you sure you want to quit the KDE Remote Desktop Client?"),
|
||||
i18n("Confirm Quit"),
|
||||
KStandardGuiItem::quit(), KStandardGuiItem::cancel(),
|
||||
"DoNotAskBeforeExit") == KMessageBox::Continue) {
|
||||
QLatin1String("DoNotAskBeforeExit")) == KMessageBox::Continue) {
|
||||
|
||||
if (Settings::rememberSessions()) { // remember open remote views for next startup
|
||||
QStringList list;
|
||||
foreach (RemoteView *view, m_remoteViewMap.values()) {
|
||||
kDebug(5010) << view->url();
|
||||
list.append(view->url().prettyUrl(KUrl::RemoveTrailingSlash));
|
||||
qCDebug(KRDC) << view->url();
|
||||
list.append(view->url().toDisplayString(QUrl::StripTrailingSlash));
|
||||
}
|
||||
Settings::setOpenSessions(list);
|
||||
}
|
||||
|
@ -967,7 +953,7 @@ void MainWindow::quit(bool systemEvent)
|
|||
view->startQuitting();
|
||||
}
|
||||
|
||||
Settings::self()->writeConfig();
|
||||
Settings::self()->save();
|
||||
|
||||
qApp->quit();
|
||||
}
|
||||
|
@ -1012,7 +998,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
|
||||
void MainWindow::saveProperties(KConfigGroup &group)
|
||||
{
|
||||
kDebug(5010);
|
||||
qCDebug(KRDC);
|
||||
KMainWindow::saveProperties(group);
|
||||
saveHostPrefs();
|
||||
}
|
||||
|
@ -1031,7 +1017,7 @@ void MainWindow::saveHostPrefs(RemoteView* view)
|
|||
// should saving this be a user option?
|
||||
if (view && view->scaling()) {
|
||||
QSize viewSize = m_tabWidget->currentWidget()->size();
|
||||
kDebug(5010) << "saving window size:" << viewSize;
|
||||
qCDebug(KRDC) << "saving window size:" << viewSize;
|
||||
view->hostPreferences()->setWidth(viewSize.width());
|
||||
view->hostPreferences()->setHeight(viewSize.height());
|
||||
}
|
||||
|
@ -1041,9 +1027,9 @@ void MainWindow::saveHostPrefs(RemoteView* view)
|
|||
|
||||
void MainWindow::tabChanged(int index)
|
||||
{
|
||||
kDebug(5010) << index;
|
||||
qCDebug(KRDC) << index;
|
||||
|
||||
m_tabWidget->setTabBarHidden((m_tabWidget->count() <= 1 && !Settings::showTabBar()) || m_fullscreenWindow);
|
||||
m_tabWidget->tabBar()->setHidden((m_tabWidget->count() <= 1 && !Settings::showTabBar()) || m_fullscreenWindow);
|
||||
|
||||
m_currentRemoteView = index;
|
||||
|
||||
|
@ -1052,7 +1038,7 @@ void MainWindow::tabChanged(int index)
|
|||
if(m_addressInput) m_addressInput->setFocus();
|
||||
}
|
||||
|
||||
const QString tabTitle = m_tabWidget->tabText(index).remove('&');
|
||||
const QString tabTitle = m_tabWidget->tabText(index).remove(QLatin1Char('&'));
|
||||
setCaption(tabTitle == i18n("New Connection") ? QString() : tabTitle);
|
||||
|
||||
updateActionStatus();
|
||||
|
@ -1072,7 +1058,7 @@ QWidget* MainWindow::newConnectionWidget()
|
|||
headerLabel->setText(i18n("<h1>KDE Remote Desktop Client</h1><br />Enter or select the address of the desktop you would like to connect to."));
|
||||
|
||||
QLabel *headerIconLabel = new QLabel(m_newConnectionWidget);
|
||||
headerIconLabel->setPixmap(KIcon("krdc").pixmap(80));
|
||||
headerIconLabel->setPixmap(QIcon::fromTheme(QLatin1String("krdc")).pixmap(80));
|
||||
|
||||
QHBoxLayout *headerLayout = new QHBoxLayout;
|
||||
headerLayout->addWidget(headerLabel, 1, Qt::AlignTop);
|
||||
|
@ -1091,7 +1077,7 @@ QWidget* MainWindow::newConnectionWidget()
|
|||
m_protocolInput = new KComboBox(m_newConnectionWidget);
|
||||
m_addressInput = new KLineEdit(m_newConnectionWidget);
|
||||
m_addressInput->setClearButtonShown(true);
|
||||
m_addressInput->setClickMessage(i18n("Type here to connect to an address and filter the list."));
|
||||
m_addressInput->setPlaceholderText(i18n("Type here to connect to an address and filter the list."));
|
||||
connect(m_addressInput, SIGNAL(textChanged(QString)), remoteDesktopsModelProxy, SLOT(setFilterFixedString(QString)));
|
||||
|
||||
foreach(RemoteViewFactory *factory, m_remoteViewFactories) {
|
||||
|
@ -1101,9 +1087,9 @@ QWidget* MainWindow::newConnectionWidget()
|
|||
connect(m_addressInput, SIGNAL(returnPressed()), SLOT(newConnection()));
|
||||
m_addressInput->setToolTip(i18n("Type an IP or DNS Name here. Clear the line to get a list of connection methods."));
|
||||
|
||||
KPushButton *connectButton = new KPushButton(m_newConnectionWidget);
|
||||
QPushButton *connectButton = new QPushButton(m_newConnectionWidget);
|
||||
connectButton->setToolTip(i18n("Goto Address"));
|
||||
connectButton->setIcon(KIcon("go-jump-locationbar"));
|
||||
connectButton->setIcon(QIcon::fromTheme(QLatin1String("go-jump-locationbar")));
|
||||
connect(connectButton, SIGNAL(clicked()), SLOT(newConnection()));
|
||||
|
||||
connectLayout->addWidget(addressLabel);
|
||||
|
@ -1148,7 +1134,7 @@ void MainWindow::saveConnectionListSort(const int logicalindex, const Qt::SortOr
|
|||
{
|
||||
Settings::setConnectionListSortColumn(logicalindex);
|
||||
Settings::setConnectionListSortOrder(order);
|
||||
Settings::self()->writeConfig();
|
||||
Settings::self()->save();
|
||||
}
|
||||
|
||||
void MainWindow::newConnectionPage(bool clearInput)
|
||||
|
@ -1192,15 +1178,15 @@ void MainWindow::createDockWidget()
|
|||
QDockWidget *remoteDesktopsDockWidget = new QDockWidget(this);
|
||||
QWidget *remoteDesktopsDockLayoutWidget = new QWidget(remoteDesktopsDockWidget);
|
||||
QVBoxLayout *remoteDesktopsDockLayout = new QVBoxLayout(remoteDesktopsDockLayoutWidget);
|
||||
remoteDesktopsDockWidget->setObjectName("remoteDesktopsDockWidget"); // required for saving position / state
|
||||
remoteDesktopsDockWidget->setObjectName(QLatin1String("remoteDesktopsDockWidget")); // required for saving position / state
|
||||
remoteDesktopsDockWidget->setWindowTitle(i18n("Remote Desktops"));
|
||||
QFontMetrics fontMetrics(remoteDesktopsDockWidget->font());
|
||||
remoteDesktopsDockWidget->setMinimumWidth(fontMetrics.width("vnc://192.168.100.100:6000"));
|
||||
actionCollection()->addAction("remote_desktop_dockwidget",
|
||||
remoteDesktopsDockWidget->setMinimumWidth(fontMetrics.width(QLatin1String("vnc://192.168.100.100:6000")));
|
||||
actionCollection()->addAction(QLatin1String("remote_desktop_dockwidget"),
|
||||
remoteDesktopsDockWidget->toggleViewAction());
|
||||
|
||||
m_dockWidgetTableView = new QTableView(remoteDesktopsDockLayoutWidget);
|
||||
m_remoteDesktopsModel = new RemoteDesktopsModel(this);
|
||||
m_remoteDesktopsModel = new RemoteDesktopsModel(this, m_bookmarkManager->getManager());
|
||||
QSortFilterProxyModel *remoteDesktopsModelProxy = new QSortFilterProxyModel(this);
|
||||
remoteDesktopsModelProxy->setSourceModel(m_remoteDesktopsModel);
|
||||
remoteDesktopsModelProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
@ -1224,7 +1210,7 @@ void MainWindow::createDockWidget()
|
|||
SLOT(openFromRemoteDesktopsModel(QModelIndex)));
|
||||
|
||||
KLineEdit *filterLineEdit = new KLineEdit(remoteDesktopsDockLayoutWidget);
|
||||
filterLineEdit->setClickMessage(i18n("Filter"));
|
||||
filterLineEdit->setPlaceholderText(i18n("Filter"));
|
||||
filterLineEdit->setClearButtonShown(true);
|
||||
connect(filterLineEdit, SIGNAL(textChanged(QString)), remoteDesktopsModelProxy, SLOT(setFilterFixedString(QString)));
|
||||
remoteDesktopsDockLayout->addWidget(filterLineEdit);
|
||||
|
@ -1233,4 +1219,4 @@ void MainWindow::createDockWidget()
|
|||
addDockWidget(Qt::LeftDockWidgetArea, remoteDesktopsDockWidget);
|
||||
}
|
||||
|
||||
#include "mainwindow.moc"
|
||||
|
||||
|
|
24
mainwindow.h
24
mainwindow.h
|
@ -28,8 +28,8 @@
|
|||
#include "remoteview.h"
|
||||
#include "remoteviewfactory.h"
|
||||
|
||||
#include <KService>
|
||||
#include <KXmlGuiWindow>
|
||||
#include <KXmlGui/KXmlGuiWindow>
|
||||
#include <KService/KPluginInfo>
|
||||
|
||||
class KComboBox;
|
||||
class KLineEdit;
|
||||
|
@ -63,8 +63,8 @@ public:
|
|||
QList<RemoteViewFactory *> remoteViewFactoriesList() const;
|
||||
RemoteView* currentRemoteView() const;
|
||||
|
||||
public slots:
|
||||
void newConnection(const KUrl &newUrl = KUrl(), bool switchFullscreenWhenConnected = false, const QString &tabName = QString());
|
||||
public Q_SLOTS:
|
||||
void newConnection(const QUrl &newUrl = QUrl(), bool switchFullscreenWhenConnected = false, const QString &tabName = QString());
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
|
@ -73,7 +73,7 @@ protected:
|
|||
void saveHostPrefs();
|
||||
void saveHostPrefs(RemoteView *view);
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void restoreOpenSessions();
|
||||
void quit(bool systemEvent = false);
|
||||
void preferences();
|
||||
|
@ -85,9 +85,9 @@ private slots:
|
|||
void takeScreenshot();
|
||||
void switchFullscreen();
|
||||
void disconnectHost();
|
||||
void closeTab(QWidget *widget);
|
||||
void openTabSettings(QWidget *widget);
|
||||
void tabContextMenu(QWidget *widget, const QPoint &point);
|
||||
void closeTab(int index);
|
||||
void openTabSettings(int index);
|
||||
void tabContextMenu(const QPoint &point);
|
||||
void viewOnly(bool viewOnly);
|
||||
void showLocalCursor(bool showLocalCursor);
|
||||
void grabAllKeys(bool grabAllKeys);
|
||||
|
@ -105,10 +105,10 @@ private slots:
|
|||
private:
|
||||
void setupActions();
|
||||
void loadAllPlugins();
|
||||
RemoteViewFactory *createPluginFromService(const KService::Ptr &service);
|
||||
RemoteViewFactory *createPluginFromInfo(const KPluginInfo &info);
|
||||
void showSettingsDialog(const QString &url);
|
||||
QScrollArea *createScrollArea(QWidget *parent, RemoteView *remoteView);
|
||||
KUrl getInputUrl();
|
||||
QUrl getInputUrl();
|
||||
|
||||
QWidget *m_fullscreenWindow;
|
||||
QByteArray m_mainWindowGeometry;
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
move(QApplication::desktop()->screenGeometry().width() - 1, 0);
|
||||
}
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void rightClicked();
|
||||
|
||||
protected:
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
: QScrollArea(parent) {
|
||||
}
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void resized(int w, int h);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# KDE Config File
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Exec=krdc -caption %c %u
|
||||
Exec=krdc -qwindowtitle %c %u
|
||||
Icon=krdc
|
||||
Terminal=false
|
||||
Name=KRDC
|
|
@ -23,29 +23,32 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "remotedesktopsmodel.h"
|
||||
#include "bookmarkmanager.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <KStandardDirs>
|
||||
#include <KDebug>
|
||||
#include <KLocale>
|
||||
#include <KI18n/KLocalizedString>
|
||||
#include<KCoreAddons/KFormat>
|
||||
#include <DNSSD/ServiceBrowser>
|
||||
#include <QDateTime>
|
||||
#include <QLoggingCategory>
|
||||
#include <QStandardPaths>
|
||||
#include <QObject>
|
||||
|
||||
RemoteDesktopsModel::RemoteDesktopsModel(QObject *parent)
|
||||
RemoteDesktopsModel::RemoteDesktopsModel(QObject *parent, KBookmarkManager *manager)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
const QString file = KStandardDirs::locateLocal("data", "krdc/bookmarks.xml");
|
||||
m_manager = KBookmarkManager::managerForFile(file, "krdc");
|
||||
m_manager = manager;
|
||||
m_manager->setUpdate(true);
|
||||
connect(m_manager, SIGNAL(changed(QString,QString)), SLOT(bookmarksChanged()));
|
||||
buildModelFromBookmarkGroup(m_manager->root());
|
||||
|
||||
#ifdef BUILD_ZEROCONF
|
||||
// Add RDP and NX if they start announcing via Zeroconf:
|
||||
m_protocols["_rfb._tcp"] = "vnc";
|
||||
m_protocols[QLatin1String("_rfb._tcp")] = QLatin1String("vnc");
|
||||
|
||||
zeroconfBrowser = new DNSSD::ServiceBrowser("_rfb._tcp", true);
|
||||
zeroconfBrowser = new KDNSSD::ServiceBrowser(QLatin1String("_rfb._tcp"), true);
|
||||
connect(zeroconfBrowser, SIGNAL(finished()), this, SLOT(servicesChanged()));
|
||||
zeroconfBrowser->startBrowse();
|
||||
kDebug(5010) << "Browsing for zeroconf hosts.";
|
||||
qCDebug(KRDC) << "Browsing for zeroconf hosts.";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -82,7 +85,7 @@ bool RemoteDesktopsModel::setData(const QModelIndex &index, const QVariant &valu
|
|||
RemoteDesktop rd = remoteDesktops.at(index.row());
|
||||
if (checked) {
|
||||
KBookmarkGroup root = m_manager->root();
|
||||
root.addBookmark(rd.title, rd.url);
|
||||
root.addBookmark(rd.title, QUrl(rd.url), QString());
|
||||
m_manager->emitChanged(root);
|
||||
} else {
|
||||
BookmarkManager::removeByUrl(m_manager, rd.url, true, rd.title);
|
||||
|
@ -107,12 +110,12 @@ QVariant RemoteDesktopsModel::data(const QModelIndex &index, int role) const
|
|||
case RemoteDesktopsModel::Title:
|
||||
return item.title;
|
||||
case RemoteDesktopsModel::LastConnected:
|
||||
return QVariant(item.lastConnected.dateTime());
|
||||
return QVariant(item.lastConnected);
|
||||
case RemoteDesktopsModel::VisitCount:
|
||||
return item.visits;
|
||||
case RemoteDesktopsModel::Created:
|
||||
if (item.created.isNull()) return QVariant();
|
||||
return KGlobal::locale()->formatDateTime(item.created.toLocalZone(), KLocale::ShortDate);
|
||||
return QLocale().toString(item.created.toLocalTime(), QLocale::FormatType::ShortFormat);
|
||||
case RemoteDesktopsModel::Source:
|
||||
switch (item.source) {
|
||||
case RemoteDesktop::Bookmarks:
|
||||
|
@ -143,19 +146,19 @@ QVariant RemoteDesktopsModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
case RemoteDesktopsModel::LastConnected:
|
||||
if (!item.lastConnected.isNull()) {
|
||||
return KGlobal::locale()->formatDateTime(item.lastConnected.toLocalZone(), KLocale::FancyLongDate);
|
||||
return QLocale().toString(item.lastConnected.toLocalTime(), QLocale::FormatType::LongFormat);
|
||||
}
|
||||
break; // else show default tooltip
|
||||
case RemoteDesktopsModel::Created:
|
||||
if (!item.created.isNull()) {
|
||||
return KGlobal::locale()->formatDateTime(item.created.toLocalZone(), KLocale::FancyLongDate);
|
||||
return QLocale().toString(item.lastConnected.toLocalTime(), QLocale::FormatType::LongFormat);
|
||||
}
|
||||
break; // else show default tooltip
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return item.url; //use the url for the tooltip
|
||||
|
||||
|
||||
case 10001: //url for dockwidget
|
||||
return item.url;
|
||||
|
||||
|
@ -206,10 +209,10 @@ void RemoteDesktopsModel::removeAllItemsFromSources(RemoteDesktop::Sources sourc
|
|||
|
||||
void RemoteDesktopsModel::bookmarksChanged()
|
||||
{
|
||||
kDebug(5010);
|
||||
removeAllItemsFromSources(RemoteDesktop::Bookmarks | RemoteDesktop::History);
|
||||
buildModelFromBookmarkGroup(m_manager->root());
|
||||
reset();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
// Danger Will Roobinson, confusing code ahead!
|
||||
|
@ -229,31 +232,31 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
|
|||
bool newItem = index < 0; // do we need to create a new item?
|
||||
|
||||
// we want to merge all copies of a url into one link, so if the item exists, update it
|
||||
if (group.metaDataItem("krdc-history") == "historyfolder") {
|
||||
if (group.metaDataItem(QLatin1String("krdc-history")) == QLatin1String("historyfolder")) {
|
||||
// set source and favorite (will override later if needed)
|
||||
item.source = RemoteDesktop::History;
|
||||
item.favorite = false;
|
||||
|
||||
// since we are in the history folder collect statitics and add them
|
||||
KDateTime connected = KDateTime();
|
||||
KDateTime created = KDateTime();
|
||||
QDateTime connected = QDateTime();
|
||||
QDateTime created = QDateTime();
|
||||
bool ok = false;
|
||||
// first the created datetime
|
||||
created.setTime_t(bm.metaDataItem("time_added").toLongLong(&ok));
|
||||
created.setTime_t(bm.metaDataItem(QLatin1String("time_added")).toLongLong(&ok));
|
||||
if (ok) (newItem ? item : remoteDesktops[index]).created = created;
|
||||
// then the last visited datetime
|
||||
ok = false;
|
||||
connected.setTime_t(bm.metaDataItem("time_visited").toLongLong(&ok));
|
||||
connected.setTime_t(bm.metaDataItem(QLatin1String("time_visited")).toLongLong(&ok));
|
||||
if (ok) (newItem ? item : remoteDesktops[index]).lastConnected = connected;
|
||||
// finally the visited count
|
||||
ok = false;
|
||||
int visits = bm.metaDataItem("visit_count").toInt(&ok);
|
||||
int visits = bm.metaDataItem(QLatin1String("visit_count")).toInt(&ok);
|
||||
if (ok) (newItem ? item : remoteDesktops[index]).visits = visits;
|
||||
} else {
|
||||
if (newItem) {
|
||||
// if this is a new item, just add the rest of the required data
|
||||
item.lastConnected = KDateTime();
|
||||
item.created = KDateTime();
|
||||
item.lastConnected = QDateTime();
|
||||
item.created = QDateTime();
|
||||
item.visits = 0;
|
||||
item.favorite = true;
|
||||
item.source = RemoteDesktop::Bookmarks;
|
||||
|
@ -276,11 +279,11 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
|
|||
void RemoteDesktopsModel::servicesChanged()
|
||||
{
|
||||
//redo list because it is easier than finding and removing one that disappeared
|
||||
QList<DNSSD::RemoteService::Ptr> services = zeroconfBrowser->services();
|
||||
KUrl url;
|
||||
QList<KDNSSD::RemoteService::Ptr> services = zeroconfBrowser->services();
|
||||
QUrl url;
|
||||
removeAllItemsFromSources(RemoteDesktop::Zeroconf);
|
||||
foreach(DNSSD::RemoteService::Ptr service, services) {
|
||||
url.setProtocol(m_protocols[service->type()].toLower());
|
||||
foreach(KDNSSD::RemoteService::Ptr service, services) {
|
||||
url.setScheme(m_protocols[service->type()].toLower());
|
||||
url.setHost(service->hostName());
|
||||
url.setPort(service->port());
|
||||
|
||||
|
@ -290,14 +293,14 @@ void RemoteDesktopsModel::servicesChanged()
|
|||
if (!remoteDesktops.contains(item)) {
|
||||
item.title = service->serviceName();
|
||||
item.source = RemoteDesktop::Zeroconf;
|
||||
item.created = KDateTime::currentLocalDateTime();
|
||||
item.created = QDateTime::currentDateTime();
|
||||
item.favorite = false;
|
||||
item.visits = 0;
|
||||
remoteDesktops.append(item);
|
||||
}
|
||||
}
|
||||
reset();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "remotedesktopsmodel.moc"
|
||||
|
|
|
@ -25,24 +25,24 @@
|
|||
#ifndef REMOTEDESKTOPSMODEL_H
|
||||
#define REMOTEDESKTOPSMODEL_H
|
||||
|
||||
#include "bookmarkmanager.h"
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <KDateTime>
|
||||
#include <QDateTime>
|
||||
|
||||
#ifdef BUILD_ZEROCONF
|
||||
#include <dnssd/servicebrowser.h>
|
||||
#include <DNSSD/RemoteService>
|
||||
#include <DNSSD/ServiceBrowser>
|
||||
#endif
|
||||
|
||||
class KBookmarkGroup;
|
||||
class KBookmarkManager;
|
||||
|
||||
struct RemoteDesktop {
|
||||
public:
|
||||
enum Source { None = 0x0, Bookmarks = 0x1, History = 0x2, Zeroconf = 0x4 };
|
||||
Q_DECLARE_FLAGS(Sources, Source)
|
||||
QString title;
|
||||
QString url;
|
||||
KDateTime lastConnected;
|
||||
KDateTime created;
|
||||
QDateTime lastConnected;
|
||||
QDateTime created;
|
||||
int visits;
|
||||
RemoteDesktop::Source source;
|
||||
bool favorite;
|
||||
|
@ -61,7 +61,7 @@ class RemoteDesktopsModel : public QAbstractTableModel
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RemoteDesktopsModel(QObject *parent);
|
||||
explicit RemoteDesktopsModel(QObject *parent, KBookmarkManager *manager);
|
||||
~RemoteDesktopsModel();
|
||||
|
||||
enum DisplayItems { Favorite, Title, LastConnected, VisitCount, Created, Source };
|
||||
|
@ -75,17 +75,17 @@ public:
|
|||
|
||||
private:
|
||||
QList<RemoteDesktop> remoteDesktops;
|
||||
QString getLastConnectedString(KDateTime lastConnected, bool fuzzy = false) const;
|
||||
QString getLastConnectedString(QDateTime lastConnected, bool fuzzy = false) const;
|
||||
void removeAllItemsFromSources(RemoteDesktop::Sources sources);
|
||||
void buildModelFromBookmarkGroup(const KBookmarkGroup &group);
|
||||
KBookmarkManager *m_manager;
|
||||
|
||||
#ifdef BUILD_ZEROCONF
|
||||
DNSSD::ServiceBrowser *zeroconfBrowser;
|
||||
KDNSSD::ServiceBrowser *zeroconfBrowser;
|
||||
QHash<QString, QString> m_protocols;
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void bookmarksChanged();
|
||||
#ifdef BUILD_ZEROCONF
|
||||
void servicesChanged();
|
||||
|
|
|
@ -22,26 +22,26 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "systemtrayicon.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <KActionCollection>
|
||||
#include <KLocale>
|
||||
#include <KMenu>
|
||||
#include <KXmlGui/KActionCollection>
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
SystemTrayIcon::SystemTrayIcon(MainWindow *parent)
|
||||
: KStatusNotifierItem(parent),
|
||||
m_mainWindow(parent)
|
||||
{
|
||||
setIconByName("krdc");
|
||||
setIconByName(QLatin1String("krdc"));
|
||||
setStatus(KStatusNotifierItem::Active);
|
||||
setCategory(KStatusNotifierItem::ApplicationStatus);
|
||||
|
||||
setToolTipIconByName("krdc");
|
||||
setToolTipIconByName(QLatin1String("krdc"));
|
||||
setToolTipTitle(i18n("KDE Remote Desktop Client"));
|
||||
|
||||
contextMenu()->addSeparator();
|
||||
contextMenu()->addAction(parent->actionCollection()->action("bookmark"));
|
||||
contextMenu()->addAction(parent->actionCollection()->action(QLatin1String("bookmark")));
|
||||
contextMenu()->addSeparator();
|
||||
|
||||
connect(this, SIGNAL(activateRequested(bool,QPoint)), this, SLOT(checkActivatedWindow(bool)));
|
||||
|
@ -59,4 +59,3 @@ SystemTrayIcon::~SystemTrayIcon()
|
|||
{
|
||||
}
|
||||
|
||||
#include "systemtrayicon.moc"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef SYSTEMTRAYICON_H
|
||||
#define SYSTEMTRAYICON_H
|
||||
|
||||
#include <kstatusnotifieritem.h>
|
||||
#include <KNotifications/KStatusNotifierItem>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
explicit SystemTrayIcon(MainWindow *parent);
|
||||
~SystemTrayIcon();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void checkActivatedWindow(bool active);
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,8 +22,11 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "tabbedviewwidget.h"
|
||||
#include "logging.h"
|
||||
|
||||
TabbedViewWidgetModel::TabbedViewWidgetModel(KTabWidget *modelTarget)
|
||||
#include <QTabBar>
|
||||
|
||||
TabbedViewWidgetModel::TabbedViewWidgetModel(QTabWidget *modelTarget)
|
||||
: QAbstractItemModel(modelTarget), m_tabWidget(modelTarget)
|
||||
{
|
||||
}
|
||||
|
@ -46,7 +49,6 @@ int TabbedViewWidgetModel::columnCount(const QModelIndex &) const
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int TabbedViewWidgetModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return m_tabWidget->count();
|
||||
|
@ -79,7 +81,7 @@ QVariant TabbedViewWidgetModel::data(const QModelIndex &index, int role) const
|
|||
switch (role) {
|
||||
case Qt::EditRole:
|
||||
case Qt::DisplayRole:
|
||||
return m_tabWidget->tabText(index.row()).remove(QRegExp("&(?!&)")); //remove accelerator string
|
||||
return m_tabWidget->tabText(index.row()).remove(QRegExp(QLatin1String("&(?!&)"))); //remove accelerator string
|
||||
case Qt::ToolTipRole:
|
||||
return m_tabWidget->tabToolTip(index.row());
|
||||
case Qt::DecorationRole:
|
||||
|
@ -105,8 +107,8 @@ void TabbedViewWidgetModel::emitDataChanged(int index)
|
|||
emit dataChanged(modelIndex, modelIndex);
|
||||
}
|
||||
|
||||
TabbedViewWidget::TabbedViewWidget(QWidget *parent, Qt::WFlags flags)
|
||||
: KTabWidget(parent, flags), m_model(new TabbedViewWidgetModel(this))
|
||||
TabbedViewWidget::TabbedViewWidget(QWidget *parent)
|
||||
: QTabWidget(parent), m_model(new TabbedViewWidgetModel(this))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -121,18 +123,18 @@ TabbedViewWidgetModel* TabbedViewWidget::getModel()
|
|||
|
||||
int TabbedViewWidget::addTab(QWidget *page, const QString &label)
|
||||
{
|
||||
int count = KTabWidget::count();
|
||||
int count = QTabWidget::count();
|
||||
m_model->beginInsertRows(QModelIndex(), count, count);
|
||||
int ret = KTabWidget::addTab(page, label);
|
||||
int ret = QTabWidget::addTab(page, label);
|
||||
m_model->endInsertRows();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TabbedViewWidget::addTab(QWidget *page, const QIcon &icon, const QString &label)
|
||||
{
|
||||
int count = KTabWidget::count();
|
||||
int count = QTabWidget::count();
|
||||
m_model->beginInsertRows(QModelIndex(), count, count);
|
||||
int ret = KTabWidget::addTab(page, icon, label);
|
||||
int ret = QTabWidget::addTab(page, icon, label);
|
||||
m_model->endInsertRows();
|
||||
return ret;
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ int TabbedViewWidget::addTab(QWidget *page, const QIcon &icon, const QString &la
|
|||
int TabbedViewWidget::insertTab(int index, QWidget *page, const QString &label)
|
||||
{
|
||||
m_model->beginInsertRows(QModelIndex(), index, index);
|
||||
int ret = KTabWidget::insertTab(index, page, label);
|
||||
int ret = QTabWidget::insertTab(index, page, label);
|
||||
m_model->endInsertRows();
|
||||
return ret;
|
||||
}
|
||||
|
@ -148,37 +150,107 @@ int TabbedViewWidget::insertTab(int index, QWidget *page, const QString &label)
|
|||
int TabbedViewWidget::insertTab(int index, QWidget *page, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_model->beginInsertRows(QModelIndex(), index, index);
|
||||
int ret = KTabWidget::insertTab(index, page, icon, label);
|
||||
int ret = QTabWidget::insertTab(index, page, icon, label);
|
||||
m_model->endInsertRows();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TabbedViewWidget::removePage(QWidget *page)
|
||||
{
|
||||
int index = KTabWidget::indexOf(page);
|
||||
int index = QTabWidget::indexOf(page);
|
||||
m_model->beginRemoveRows(QModelIndex(), index, index);
|
||||
KTabWidget::removePage(page);
|
||||
QTabWidget::removeTab(index);
|
||||
m_model->endRemoveRows();
|
||||
}
|
||||
|
||||
void TabbedViewWidget::removeTab(int index)
|
||||
{
|
||||
m_model->beginRemoveRows(QModelIndex(), index, index);
|
||||
KTabWidget::removeTab(index);
|
||||
QTabWidget::removeTab(index);
|
||||
m_model->endRemoveRows();
|
||||
}
|
||||
|
||||
void TabbedViewWidget::moveTab(int from, int to)
|
||||
{
|
||||
m_model->emitLayoutAboutToBeChanged();
|
||||
KTabWidget::moveTab(from, to);
|
||||
tabBar()->moveTab(from, to);
|
||||
m_model->emitLayoutChanged();
|
||||
}
|
||||
|
||||
void TabbedViewWidget::setTabText(int index, const QString &label)
|
||||
{
|
||||
KTabWidget::setTabText(index, label);
|
||||
QTabWidget::setTabText(index, label);
|
||||
m_model->emitDataChanged(index);
|
||||
}
|
||||
|
||||
#include "tabbedviewwidget.moc"
|
||||
//This functinality is taken from KTabWidget for comatibility.
|
||||
//KTabWidget has been moved to KdeLibs4Support and QTabWidget::tabBarDoubleClicked does not
|
||||
//work on empty space after tabs,
|
||||
bool TabbedViewWidget::isEmptyTabbarSpace(const QPoint &point) const
|
||||
{
|
||||
if (count() == 0) {
|
||||
return true;
|
||||
}
|
||||
if (tabBar()->isHidden()) {
|
||||
return false;
|
||||
}
|
||||
QSize size(tabBar()->sizeHint());
|
||||
if ((tabPosition() == QTabWidget::North && point.y() < size.height()) ||
|
||||
(tabPosition() == QTabWidget::South && point.y() > (height() - size.height()))) {
|
||||
|
||||
QWidget *rightcorner = cornerWidget(Qt::TopRightCorner);
|
||||
if (rightcorner && rightcorner->isVisible()) {
|
||||
if (point.x() >= width() - rightcorner->width()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *leftcorner = cornerWidget(Qt::TopLeftCorner);
|
||||
if (leftcorner && leftcorner->isVisible()) {
|
||||
if (point.x() <= leftcorner->width()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (tabBar()->tabRect(i).contains(tabBar()->mapFromParent(point))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TabbedViewWidget::mouseDoubleClickEvent(QMouseEvent * event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEmptyTabbarSpace(event->pos())) {
|
||||
emit(tabBarDoubleClicked(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
QTabWidget::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void TabbedViewWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MidButton) {
|
||||
if (isEmptyTabbarSpace(event->pos())) {
|
||||
emit(mouseMiddleClick(-1));
|
||||
return;
|
||||
}
|
||||
int pos = tabBar()->tabAt(event->pos());
|
||||
if(pos != -1){
|
||||
emit(mouseMiddleClick(pos));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QTabWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,15 @@
|
|||
#define TABBEDVIEWWIDGET_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <KTabWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class TabbedViewWidgetModel : public QAbstractItemModel
|
||||
{
|
||||
friend class TabbedViewWidget;
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TabbedViewWidgetModel(KTabWidget *modelTarget);
|
||||
explicit TabbedViewWidgetModel(QTabWidget *modelTarget);
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
@ -44,15 +45,16 @@ protected:
|
|||
void emitLayoutAboutToBeChanged();
|
||||
void emitLayoutChanged();
|
||||
void emitDataChanged(int index);
|
||||
|
||||
private:
|
||||
KTabWidget *m_tabWidget;
|
||||
QTabWidget *m_tabWidget;
|
||||
};
|
||||
|
||||
class TabbedViewWidget : public KTabWidget
|
||||
class TabbedViewWidget : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TabbedViewWidget(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
explicit TabbedViewWidget(QWidget *parent = 0);
|
||||
virtual ~TabbedViewWidget();
|
||||
TabbedViewWidgetModel* getModel();
|
||||
int addTab(QWidget *page, const QString &label);
|
||||
|
@ -63,8 +65,17 @@ public:
|
|||
void removePage(QWidget *page);
|
||||
void moveTab(int from, int to);
|
||||
void setTabText(int index, const QString &label);
|
||||
|
||||
Q_SIGNALS:
|
||||
void mouseMiddleClick(int index);
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent * event) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
TabbedViewWidgetModel *m_model;
|
||||
bool isEmptyTabbarSpace(const QPoint &point) const;
|
||||
};
|
||||
|
||||
#endif // FULLSCREENWINDOW_H
|
||||
|
|
|
@ -13,14 +13,18 @@ if(BUILD_TEST)
|
|||
testview.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(krdc_testplugin ${testplugin_SRCS})
|
||||
add_library(krdc_testplugin ${testplugin_SRCS})
|
||||
|
||||
target_link_libraries(krdc_testplugin
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
kcoreaddons_desktop_to_json(krdc_testplugin krdc_test.desktop)
|
||||
|
||||
target_link_libraries(krdc_testplugin
|
||||
Qt5::Core
|
||||
KF5::Wallet
|
||||
KF5::ConfigCore
|
||||
KF5::I18n
|
||||
KF5::CoreAddons
|
||||
Qt5::Gui
|
||||
krdccore
|
||||
)
|
||||
install(TARGETS krdc_testplugin DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
||||
install(FILES krdc_test.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install(TARGETS krdc_testplugin DESTINATION ${PLUGIN_INSTALL_DIR}/krdc)
|
||||
endif(BUILD_TEST)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <QEvent>
|
||||
|
||||
TestView::TestView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
||||
TestView::TestView(QWidget *parent, const QUrl &url, KConfigGroup configGroup)
|
||||
: RemoteView(parent)
|
||||
{
|
||||
m_hostPreferences = new TestHostPreferences(configGroup, this);
|
||||
|
@ -96,4 +96,3 @@ void TestView::switchFullscreen(bool on)
|
|||
Q_UNUSED(on);
|
||||
}
|
||||
|
||||
#include "testview.moc"
|
||||
|
|
|
@ -24,12 +24,10 @@
|
|||
#ifndef TESTVIEW_H
|
||||
#define TESTVIEW_H
|
||||
|
||||
#include "testview.h"
|
||||
|
||||
#include "remoteview.h"
|
||||
#include "hostpreferences.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KConfigCore/KConfigGroup>
|
||||
|
||||
class TestHostPreferences;
|
||||
|
||||
|
@ -38,7 +36,7 @@ class TestView : public RemoteView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TestView(QWidget *parent = 0, const KUrl &url = KUrl(), KConfigGroup configGroup = KConfigGroup());
|
||||
explicit TestView(QWidget *parent = 0, const QUrl &url = QUrl(), KConfigGroup configGroup = KConfigGroup());
|
||||
|
||||
virtual ~TestView();
|
||||
|
||||
|
@ -49,12 +47,12 @@ public:
|
|||
virtual bool start();
|
||||
HostPreferences* hostPreferences();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
virtual void switchFullscreen(bool on);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
TestHostPreferences *m_hostPreferences;
|
||||
};
|
||||
|
@ -66,7 +64,7 @@ class TestHostPreferences : public HostPreferences
|
|||
public:
|
||||
explicit TestHostPreferences(KConfigGroup configGroup, QObject *parent = 0)
|
||||
: HostPreferences(configGroup, parent) {}
|
||||
|
||||
|
||||
protected:
|
||||
virtual QWidget* createProtocolSpecificConfigPage() { return 0; };
|
||||
};
|
||||
|
|
|
@ -23,29 +23,28 @@
|
|||
|
||||
#include "testviewfactory.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KLocale>
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
KRDC_PLUGIN_EXPORT(TestViewFactory)
|
||||
K_PLUGIN_FACTORY_WITH_JSON(KrdcFactory, "krdc_test.json", registerPlugin<TestViewFactory>();)
|
||||
|
||||
TestViewFactory::TestViewFactory(QObject *parent, const QVariantList &args)
|
||||
: RemoteViewFactory(parent)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
KGlobal::locale()->insertCatalog("krdc");
|
||||
KLocalizedString::setApplicationDomain("krdc");
|
||||
}
|
||||
|
||||
TestViewFactory::~TestViewFactory()
|
||||
{
|
||||
}
|
||||
|
||||
bool TestViewFactory::supportsUrl(const KUrl &url) const
|
||||
bool TestViewFactory::supportsUrl(const QUrl &url) const
|
||||
{
|
||||
return (url.scheme().compare("test", Qt::CaseInsensitive) == 0);
|
||||
return (url.scheme().compare(QLatin1String("test"), Qt::CaseInsensitive) == 0);
|
||||
}
|
||||
|
||||
RemoteView *TestViewFactory::createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
||||
RemoteView *TestViewFactory::createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup)
|
||||
{
|
||||
return new TestView(parent, url, configGroup);
|
||||
}
|
||||
|
@ -54,29 +53,29 @@ HostPreferences *TestViewFactory::createHostPreferences(KConfigGroup configGroup
|
|||
{
|
||||
Q_UNUSED(configGroup);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString TestViewFactory::scheme() const
|
||||
{
|
||||
return "test";
|
||||
return QLatin1String("test");
|
||||
}
|
||||
|
||||
QString TestViewFactory::connectActionText() const
|
||||
{
|
||||
return ("New Test Connection..."); // no i18n required, just internal test plugin!
|
||||
return QLatin1String("New Test Connection..."); // no i18n required, just internal test plugin!
|
||||
}
|
||||
|
||||
QString TestViewFactory::connectButtonText() const
|
||||
{
|
||||
return ("KRDC Test Connection"); // no i18n required, just internal test plugin!
|
||||
return QLatin1String("KRDC Test Connection"); // no i18n required, just internal test plugin!
|
||||
}
|
||||
|
||||
QString TestViewFactory::connectToolTipText() const
|
||||
{
|
||||
return ("<html>Enter the address here. Port is optional.<br />"
|
||||
return QLatin1String("<html>Enter the address here. Port is optional.<br />"
|
||||
"<i>Example: testserver (host)</i></html>"); // no i18n required, just internal test plugin!
|
||||
}
|
||||
|
||||
#include "moc_testviewfactory.cpp"
|
||||
#include "testviewfactory.moc"
|
||||
|
|
|
@ -37,16 +37,16 @@ public:
|
|||
|
||||
virtual ~TestViewFactory();
|
||||
|
||||
virtual bool supportsUrl(const KUrl &url) const;
|
||||
virtual bool supportsUrl(const QUrl &url) const;
|
||||
|
||||
virtual RemoteView *createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup);
|
||||
virtual RemoteView *createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup);
|
||||
|
||||
virtual HostPreferences *createHostPreferences(KConfigGroup configGroup, QWidget *parent);
|
||||
|
||||
virtual QString scheme() const;
|
||||
|
||||
virtual QString connectActionText() const;
|
||||
|
||||
|
||||
virtual QString connectButtonText() const;
|
||||
|
||||
virtual QString connectToolTipText() const;
|
||||
|
|
|
@ -23,17 +23,16 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "tubesmanager.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <TelepathyQt/IncomingStreamTubeChannel>
|
||||
#include <TelepathyQt/Debug>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
#include <TelepathyQt/Types>
|
||||
|
||||
TubesManager::TubesManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
kDebug() << "Initializing tubes manager";
|
||||
qCDebug(KRDC) << "Initializing tubes manager";
|
||||
|
||||
Tp::enableDebug(true);
|
||||
Tp::enableWarnings(true);
|
||||
|
@ -57,10 +56,10 @@ TubesManager::TubesManager(QObject *parent)
|
|||
|
||||
TubesManager::~TubesManager()
|
||||
{
|
||||
kDebug() << "Destroying tubes manager";
|
||||
qCDebug(KRDC) << "Destroying tubes manager";
|
||||
}
|
||||
|
||||
void TubesManager::closeTube(const KUrl& url)
|
||||
void TubesManager::closeTube(const QUrl& url)
|
||||
{
|
||||
if (m_tubes.contains(url)) {
|
||||
m_tubes.take(url)->requestClose();
|
||||
|
@ -77,12 +76,12 @@ void TubesManager::onTubeAccepted(
|
|||
Q_UNUSED(sourcePort);
|
||||
Q_UNUSED(account);
|
||||
|
||||
KUrl url;
|
||||
url.setScheme("vnc");
|
||||
QUrl url;
|
||||
url.setScheme(QLatin1String("vnc"));
|
||||
url.setHost(listenAddress.toString());
|
||||
url.setPort(listenPort);
|
||||
|
||||
kDebug() << "newConnection:" << url;
|
||||
qCDebug(KRDC) << "newConnection:" << url;
|
||||
m_tubes.insert(url, tube);
|
||||
emit newConnection(url);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
|
||||
#include <TelepathyQt/StreamTubeClient>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <KUrl>
|
||||
#include <QUrl>
|
||||
#include <QObject>
|
||||
|
||||
class TubesManager : public QObject
|
||||
{
|
||||
|
@ -37,10 +38,10 @@ public:
|
|||
explicit TubesManager(QObject *parent);
|
||||
virtual ~TubesManager();
|
||||
|
||||
void closeTube(const KUrl & url);
|
||||
void closeTube(const QUrl & url);
|
||||
|
||||
Q_SIGNALS:
|
||||
void newConnection(KUrl);
|
||||
void newConnection(QUrl);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onTubeAccepted(
|
||||
|
@ -53,7 +54,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
Tp::StreamTubeClientPtr m_stubeClient;
|
||||
QHash<KUrl, Tp::IncomingStreamTubeChannelPtr> m_tubes;
|
||||
QHash<QUrl, Tp::IncomingStreamTubeChannelPtr> m_tubes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
if(LIBVNCSERVER_FOUND)
|
||||
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5011)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
@ -11,18 +10,21 @@ if(LIBVNCSERVER_FOUND)
|
|||
vnchostpreferences.cpp
|
||||
vncclientthread.cpp
|
||||
vncviewfactory.cpp
|
||||
../core/logging.cpp
|
||||
vncview.cpp
|
||||
)
|
||||
|
||||
kde4_add_ui_files(vncplugin_SRCS
|
||||
ki18n_wrap_ui(vncplugin_SRCS
|
||||
vncpreferences.ui
|
||||
)
|
||||
|
||||
kde4_add_plugin(krdc_vncplugin ${vncplugin_SRCS})
|
||||
|
||||
target_link_libraries(krdc_vncplugin
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
add_library(krdc_vncplugin ${vncplugin_SRCS})
|
||||
target_link_libraries(krdc_vncplugin
|
||||
Qt5::Core
|
||||
KF5::ConfigCore
|
||||
KF5::CoreAddons
|
||||
KF5::XmlGui
|
||||
Qt5::Gui
|
||||
${LIBVNCCLIENT_LIBRARIES}
|
||||
krdccore
|
||||
)
|
||||
|
@ -35,19 +37,27 @@ if(LIBVNCSERVER_FOUND)
|
|||
vncpreferences.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(kcm_krdc_vncplugin ${kcm_krdc_vncplugin_SRCS})
|
||||
add_library(kcm_krdc_vncplugin ${kcm_krdc_vncplugin_SRCS})
|
||||
|
||||
target_link_libraries(kcm_krdc_vncplugin
|
||||
${KDE4_KDEUI_LIBS}
|
||||
Qt5::Core
|
||||
KF5::Wallet
|
||||
KF5::ConfigCore
|
||||
KF5::CoreAddons
|
||||
KF5::XmlGui
|
||||
Qt5::Gui
|
||||
${LIBVNCCLIENT_LIBRARIES}
|
||||
krdccore
|
||||
)
|
||||
|
||||
kcoreaddons_desktop_to_json(krdc_vncplugin krdc_vnc.desktop)
|
||||
kcoreaddons_desktop_to_json(kcm_krdc_vncplugin krdc_vnc_config.desktop)
|
||||
|
||||
add_dependencies(kcm_krdc_vncplugin krdc_vncplugin)
|
||||
|
||||
install(TARGETS kcm_krdc_vncplugin DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install(TARGETS krdc_vncplugin DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install(TARGETS kcm_krdc_vncplugin DESTINATION ${PLUGIN_INSTALL_DIR}/krdc/kcms)
|
||||
install(TARGETS krdc_vncplugin DESTINATION ${PLUGIN_INSTALL_DIR}/krdc)
|
||||
|
||||
install(FILES krdc_vnc.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install(FILES krdc_vnc_config.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
|
||||
install(FILES vnc.protocol DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
|
|
|
@ -57,5 +57,5 @@ Name[x-test]=xxVNCxx
|
|||
Name[zh_CN]=VNC
|
||||
Name[zh_TW]=VNC
|
||||
|
||||
X-KDE-Library=kcm_krdc_vncplugin
|
||||
X-KDE-Library=krdc/kcms/kcm_krdc_vncplugin
|
||||
X-KDE-ParentComponents=krdc_vncplugin
|
||||
|
|
|
@ -7,6 +7,7 @@ library (version 0.9.1 or newer required):
|
|||
|
||||
The following files from KRDC are required:
|
||||
krdc/core/remoteview.{cpp,h}
|
||||
krdc/core/logging.{cpp,h}
|
||||
krdc/vnc/vncview.{cpp,h}
|
||||
krdc/vnc/vncclientthread.{cpp,h}
|
||||
krdc/vnc/qtonly/main.cpp
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
TEMPLATE = app
|
||||
TARGET =
|
||||
TARGET = krdc-vnc-qtonly
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += .
|
||||
LIBS += -lvncclient -lgnutls
|
||||
DEFINES += QTONLY
|
||||
|
||||
HEADERS += remoteview.h vncclientthread.h vncview.h
|
||||
SOURCES += main.cpp remoteview.cpp vncclientthread.cpp vncview.cpp
|
||||
QT += core gui widgets
|
||||
|
||||
HEADERS += remoteview.h vncclientthread.h vncview.h logging.h
|
||||
SOURCES += main.cpp remoteview.cpp vncclientthread.cpp vncview.cpp logging.cpp
|
||||
|
|
|
@ -24,12 +24,13 @@
|
|||
#include <QApplication>
|
||||
|
||||
#include "vncview.h"
|
||||
#include "logging.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
if (QCoreApplication::arguments().count() < 2) {
|
||||
qFatal("Please define an URL as argument. Example: vnc://:password@server:1\n"
|
||||
qCritical(KRDC) << ("Please define an URL as argument. Example: vnc://:password@server:1\n"
|
||||
"Optionally, you can define the quality as second argument (1-3, where 1 is the best). Default is 2.");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "vncclientthread.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <netinet/in.h>
|
||||
|
@ -33,7 +34,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
//for detecting intel AMT KVM vnc server
|
||||
static const QString INTEL_AMT_KVM_STRING= "Intel(r) AMT KVM";
|
||||
static const QString INTEL_AMT_KVM_STRING= QLatin1String("Intel(r) AMT KVM");
|
||||
static QThreadStorage<VncClientThread **> instances;
|
||||
|
||||
// Dispatch from this static callback context to the member context.
|
||||
|
@ -143,8 +144,8 @@ void VncClientThread::setClientColorDepth(rfbClient* cl, VncClientThread::ColorD
|
|||
rfbBool VncClientThread::newclient()
|
||||
{
|
||||
//8bit color hack for Intel(r) AMT KVM "classic vnc" = vnc server built in in Intel Vpro chipsets.
|
||||
if (INTEL_AMT_KVM_STRING == cl->desktopName) {
|
||||
kDebug(5011) << "Intel(R) AMT KVM: switching to 8 bit color depth (workaround, recent libvncserver needed)";
|
||||
if (INTEL_AMT_KVM_STRING == QLatin1String(cl->desktopName)) {
|
||||
qCDebug(KRDC) << "Intel(R) AMT KVM: switching to 8 bit color depth (workaround, recent libvncserver needed)";
|
||||
setColorDepth(bpp8);
|
||||
}
|
||||
setClientColorDepth(cl, colorDepth());
|
||||
|
@ -177,13 +178,13 @@ rfbBool VncClientThread::newclient()
|
|||
}
|
||||
|
||||
SetFormatAndEncodings(cl);
|
||||
kDebug(5011) << "Client created";
|
||||
qCDebug(KRDC) << "Client created";
|
||||
return true;
|
||||
}
|
||||
|
||||
void VncClientThread::updatefb(int x, int y, int w, int h)
|
||||
{
|
||||
// kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h;
|
||||
// qCDebug(KRDC) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h;
|
||||
|
||||
const int width = cl->width, height = cl->height;
|
||||
QImage img;
|
||||
|
@ -201,9 +202,9 @@ void VncClientThread::updatefb(int x, int y, int w, int h)
|
|||
}
|
||||
|
||||
if (img.isNull()) {
|
||||
kDebug(5011) << "image not loaded";
|
||||
qCDebug(KRDC) << "image not loaded";
|
||||
}
|
||||
|
||||
|
||||
if (m_stopped) {
|
||||
return; // sending data to a stopped thread is not a good idea
|
||||
}
|
||||
|
@ -216,7 +217,7 @@ void VncClientThread::updatefb(int x, int y, int w, int h)
|
|||
void VncClientThread::cuttext(const char *text, int textlen)
|
||||
{
|
||||
const QString cutText = QString::fromUtf8(text, textlen);
|
||||
kDebug(5011) << cutText;
|
||||
qCDebug(KRDC) << cutText;
|
||||
|
||||
if (!cutText.isEmpty()) {
|
||||
emitGotCut(cutText);
|
||||
|
@ -225,19 +226,19 @@ void VncClientThread::cuttext(const char *text, int textlen)
|
|||
|
||||
char *VncClientThread::passwdHandler()
|
||||
{
|
||||
kDebug(5011) << "password request";
|
||||
qCDebug(KRDC) << "password request";
|
||||
|
||||
// Never request a password during a reconnect attempt.
|
||||
if (!m_keepalive.failed) {
|
||||
passwordRequest();
|
||||
m_passwordError = true;
|
||||
}
|
||||
return strdup(m_password.toUtf8());
|
||||
return strdup(m_password.toUtf8().constData());
|
||||
}
|
||||
|
||||
rfbCredential *VncClientThread::credentialHandler(int credentialType)
|
||||
{
|
||||
kDebug(5011) << "credential request" << credentialType;
|
||||
qCDebug(KRDC) << "credential request" << credentialType;
|
||||
|
||||
rfbCredential *cred = 0;
|
||||
|
||||
|
@ -247,11 +248,11 @@ rfbCredential *VncClientThread::credentialHandler(int credentialType)
|
|||
m_passwordError = true;
|
||||
|
||||
cred = new rfbCredential;
|
||||
cred->userCredential.username = strdup(username().toUtf8());
|
||||
cred->userCredential.password = strdup(password().toUtf8());
|
||||
cred->userCredential.username = strdup(username().toUtf8().constData());
|
||||
cred->userCredential.password = strdup(password().toUtf8().constData());
|
||||
break;
|
||||
default:
|
||||
kError(5011) << "credential request failed, unspported credentialType:" << credentialType;
|
||||
qCritical(KRDC) << "credential request failed, unspported credentialType:" << credentialType;
|
||||
outputErrorMessage(i18n("VNC authentication type is not supported."));
|
||||
break;
|
||||
}
|
||||
|
@ -270,10 +271,10 @@ void VncClientThread::outputHandler(const char *format, ...)
|
|||
|
||||
message = message.trimmed();
|
||||
|
||||
kDebug(5011) << message;
|
||||
qCDebug(KRDC) << message;
|
||||
|
||||
if ((message.contains("Couldn't convert ")) ||
|
||||
(message.contains("Unable to connect to VNC server"))) {
|
||||
if ((message.contains(QLatin1String("Couldn't convert "))) ||
|
||||
(message.contains(QLatin1String("Unable to connect to VNC server")))) {
|
||||
// Don't show a dialog if a reconnection is needed. Never contemplate
|
||||
// reconnection if we don't have a password.
|
||||
QString tmp = i18n("Server not found.");
|
||||
|
@ -291,22 +292,22 @@ void VncClientThread::outputHandler(const char *format, ...)
|
|||
// Process general authentication failures before more specific authentication
|
||||
// failures. All authentication failures cancel any auto-reconnection that
|
||||
// may be in progress.
|
||||
if (message.contains("VNC connection failed: Authentication failed")) {
|
||||
if (message.contains(QLatin1String("VNC connection failed: Authentication failed"))) {
|
||||
m_keepalive.failed = false;
|
||||
outputErrorMessageString = i18n("VNC authentication failed.");
|
||||
}
|
||||
if ((message.contains("VNC connection failed: Authentication failed, too many tries")) ||
|
||||
(message.contains("VNC connection failed: Too many authentication failures"))) {
|
||||
if ((message.contains(QLatin1String("VNC connection failed: Authentication failed, too many tries"))) ||
|
||||
(message.contains(QLatin1String("VNC connection failed: Too many authentication failures")))) {
|
||||
m_keepalive.failed = false;
|
||||
outputErrorMessageString = i18n("VNC authentication failed because of too many authentication tries.");
|
||||
}
|
||||
|
||||
if (message.contains("VNC server closed connection"))
|
||||
if (message.contains(QLatin1String("VNC server closed connection")))
|
||||
outputErrorMessageString = i18n("VNC server closed connection.");
|
||||
|
||||
// If we are not going to attempt a reconnection, at least tell the user
|
||||
// the connection went away.
|
||||
if (message.contains("read (")) {
|
||||
if (message.contains(QLatin1String("read ("))) {
|
||||
// Don't show a dialog if a reconnection is needed. Never contemplate
|
||||
// reconnection if we don't have a password.
|
||||
QString tmp = i18n("Disconnected: %1.", message);
|
||||
|
@ -319,8 +320,8 @@ void VncClientThread::outputHandler(const char *format, ...)
|
|||
}
|
||||
|
||||
// internal messages, not displayed to user
|
||||
if (message.contains("VNC server supports protocol version 3.889")) // see http://bugs.kde.org/162640
|
||||
outputErrorMessageString = "INTERNAL:APPLE_VNC_COMPATIBILTY";
|
||||
if (message.contains(QLatin1String("VNC server supports protocol version 3.889"))) // see http://bugs.kde.org/162640
|
||||
outputErrorMessageString = QLatin1String("INTERNAL:APPLE_VNC_COMPATIBILTY");
|
||||
}
|
||||
|
||||
VncClientThread::VncClientThread(QObject *parent)
|
||||
|
@ -352,7 +353,7 @@ VncClientThread::~VncClientThread()
|
|||
stop();
|
||||
terminate();
|
||||
const bool quitSuccess = wait(1000);
|
||||
kDebug(5011) << "Attempting to stop in deconstructor, will crash if this fails:" << quitSuccess;
|
||||
qCDebug(KRDC) << "Attempting to stop in deconstructor, will crash if this fails:" << quitSuccess;
|
||||
}
|
||||
|
||||
clientDestroy();
|
||||
|
@ -363,7 +364,7 @@ VncClientThread::~VncClientThread()
|
|||
void VncClientThread::checkOutputErrorMessage()
|
||||
{
|
||||
if (!outputErrorMessageString.isEmpty()) {
|
||||
kDebug(5011) << outputErrorMessageString;
|
||||
qCDebug(KRDC) << outputErrorMessageString;
|
||||
QString errorMessage = outputErrorMessageString;
|
||||
outputErrorMessageString.clear();
|
||||
// show authentication failure error only after the 3rd unsuccessful try
|
||||
|
@ -479,7 +480,7 @@ void VncClientThread::run()
|
|||
}
|
||||
|
||||
locker.relock();
|
||||
kDebug(5011) << "--------------------- Starting main VNC event loop ---------------------";
|
||||
qCDebug(KRDC) << "--------------------- Starting main VNC event loop ---------------------";
|
||||
while (!m_stopped) {
|
||||
locker.unlock();
|
||||
const int i = WaitForMessage(cl, 500);
|
||||
|
@ -499,7 +500,7 @@ void VncClientThread::run()
|
|||
} while (!clientCreate(true));
|
||||
continue;
|
||||
}
|
||||
kError(5011) << "HandleRFBServerMessage failed";
|
||||
qCritical(KRDC) << "HandleRFBServerMessage failed";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -550,13 +551,13 @@ bool VncClientThread::clientCreate(bool reinitialising)
|
|||
m_port += 5900;
|
||||
cl->serverPort = m_port;
|
||||
|
||||
kDebug(5011) << "--------------------- trying init ---------------------";
|
||||
qCDebug(KRDC) << "--------------------- trying init ---------------------";
|
||||
|
||||
if (!rfbInitClient(cl, 0, 0)) {
|
||||
if (!reinitialising) {
|
||||
// Don't whine on reconnection failure: presumably the network
|
||||
// is simply still down.
|
||||
kError(5011) << "rfbInitClient failed";
|
||||
qCritical(KRDC) << "rfbInitClient failed";
|
||||
}
|
||||
cl = 0;
|
||||
return false;
|
||||
|
@ -602,29 +603,29 @@ void VncClientThread::clientSetKeepalive()
|
|||
// Try to set the option active
|
||||
optval = 1;
|
||||
if (setsockopt(cl->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) {
|
||||
kError(5011) << "setsockopt(SO_KEEPALIVE)" << strerror(errno);
|
||||
qCritical(KRDC) << "setsockopt(SO_KEEPALIVE)" << strerror(errno);
|
||||
return;
|
||||
}
|
||||
|
||||
optval = m_keepalive.intervalSeconds;
|
||||
if (setsockopt(cl->sock, IPPROTO_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
|
||||
kError(5011) << "setsockopt(TCP_KEEPIDLE)" << strerror(errno);
|
||||
qCritical(KRDC) << "setsockopt(TCP_KEEPIDLE)" << strerror(errno);
|
||||
return;
|
||||
}
|
||||
|
||||
optval = m_keepalive.intervalSeconds;
|
||||
if (setsockopt(cl->sock, IPPROTO_TCP, TCP_KEEPINTVL, &optval, optlen) < 0) {
|
||||
kError(5011) << "setsockopt(TCP_KEEPINTVL)" << strerror(errno);
|
||||
qCritical(KRDC) << "setsockopt(TCP_KEEPINTVL)" << strerror(errno);
|
||||
return;
|
||||
}
|
||||
|
||||
optval = m_keepalive.failedProbes;
|
||||
if(setsockopt(cl->sock, IPPROTO_TCP, TCP_KEEPCNT, &optval, optlen) < 0) {
|
||||
kError(5011) << "setsockopt(TCP_KEEPCNT)" << strerror(errno);
|
||||
qCritical(KRDC) << "setsockopt(TCP_KEEPCNT)" << strerror(errno);
|
||||
return;
|
||||
}
|
||||
m_keepalive.set = true;
|
||||
kDebug(5011) << "TCP keepalive set";
|
||||
qCDebug(KRDC) << "TCP keepalive set";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -632,7 +633,7 @@ void VncClientThread::clientSetKeepalive()
|
|||
*/
|
||||
void VncClientThread::clientStateChange(RemoteView::RemoteStatus status, const QString &details)
|
||||
{
|
||||
kDebug(5011) << status << details << m_host << ":" << m_port;
|
||||
qCDebug(KRDC) << status << details << m_host << ":" << m_port;
|
||||
emit clientStateChanged(status, details);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,9 @@
|
|||
#define VNCCLIENTTHREAD_H
|
||||
|
||||
#ifdef QTONLY
|
||||
#include <QDebug>
|
||||
#define kDebug(n) qDebug()
|
||||
#define kError(n) qDebug()
|
||||
#define kBacktrace() ""
|
||||
#define i18n tr
|
||||
#else
|
||||
#include <KDebug>
|
||||
#include <KLocale>
|
||||
#include <KI18n/KLocalizedString>
|
||||
#endif
|
||||
|
||||
#include "remoteview.h"
|
||||
|
@ -133,7 +128,7 @@ public:
|
|||
ColorDepth colorDepth() const;
|
||||
uint8_t *frameBuffer;
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void imageUpdated(int x, int y, int w, int h);
|
||||
void gotCut(const QString &text);
|
||||
void passwordRequest(bool includingUsername = false);
|
||||
|
@ -147,7 +142,7 @@ signals:
|
|||
*/
|
||||
void clientStateChanged(RemoteView::RemoteStatus status, const QString &details);
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void mouseEvent(int x, int y, int buttonMask);
|
||||
void keyEvent(int key, bool pressed);
|
||||
void clientCut(const QString &text);
|
||||
|
@ -230,7 +225,7 @@ private:
|
|||
void clientStateChange(RemoteView::RemoteStatus status, const QString &details);
|
||||
QString m_previousDetails;
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void checkOutputErrorMessage();
|
||||
};
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include "settings.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
#include <QDesktopWidget>
|
||||
|
||||
VncHostPreferences::VncHostPreferences(KConfigGroup configGroup, QObject *parent)
|
||||
|
@ -51,7 +49,7 @@ QWidget* VncHostPreferences::createProtocolSpecificConfigPage()
|
|||
connect(vncUi.resolutionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateScalingWidthHeight(int)));
|
||||
connect(vncUi.kcfg_Scaling, SIGNAL(toggled(bool)), SLOT(updateScaling(bool)));
|
||||
|
||||
const QString resolutionString = QString::number(width()) + 'x' + QString::number(height());
|
||||
const QString resolutionString = QString::number(width()) + QLatin1Char('x') + QString::number(height());
|
||||
const int resolutionIndex = vncUi.resolutionComboBox->findText(resolutionString, Qt::MatchContains);
|
||||
vncUi.resolutionComboBox->setCurrentIndex((resolutionIndex == -1) ? vncUi.resolutionComboBox->count() - 1 : resolutionIndex);
|
||||
|
||||
|
@ -140,4 +138,3 @@ RemoteView::Quality VncHostPreferences::quality()
|
|||
return (RemoteView::Quality) m_configGroup.readEntry("quality", (int) Settings::quality() + 1);
|
||||
}
|
||||
|
||||
#include "vnchostpreferences.moc"
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
Ui::VncPreferences vncUi;
|
||||
void checkEnableCustomSize(int index);
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void updateScalingWidthHeight(int index);
|
||||
void updateScaling(bool enabled);
|
||||
};
|
||||
|
|
|
@ -27,16 +27,14 @@
|
|||
|
||||
#include "ui_vncpreferences.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
KRDC_PLUGIN_EXPORT(VncPreferences)
|
||||
K_PLUGIN_FACTORY_WITH_JSON(KrdcKcmFactory, "krdc_vnc_config.json", registerPlugin<VncPreferences>();)
|
||||
|
||||
VncPreferences::VncPreferences(QWidget *parent, const QVariantList &args)
|
||||
: KCModule(KrdcFactory::componentData(), parent, args)
|
||||
: KCModule(parent, args)
|
||||
{
|
||||
Ui::VncPreferences vncUi;
|
||||
vncUi.setupUi(this);
|
||||
|
||||
|
||||
// copying the RDP preferences... need to create generic code for the plugins.
|
||||
vncUi.resolutionDummyLabel->hide();
|
||||
vncUi.resolutionComboBox->hide();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "vncview.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QImage>
|
||||
|
@ -37,10 +38,10 @@
|
|||
#else
|
||||
#include "settings.h"
|
||||
#include <KActionCollection>
|
||||
#include <KMainWindow>
|
||||
#include <KMessageBox>
|
||||
#include <KPasswordDialog>
|
||||
#include <KXMLGUIClient>
|
||||
#include <KXmlGui/KMainWindow>
|
||||
#include <KWidgetsAddons/KMessageBox>
|
||||
#include <KWidgetsAddons/KPasswordDialog>
|
||||
#include <KXmlGui/KXMLGUIClient>
|
||||
#endif
|
||||
|
||||
// Definition of key modifier mask constants
|
||||
|
@ -50,7 +51,7 @@
|
|||
#define KMOD_Control_L 0x08
|
||||
#define KMOD_Shift_L 0x10
|
||||
|
||||
VncView::VncView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
||||
VncView::VncView(QWidget *parent, const QUrl &url, KConfigGroup configGroup)
|
||||
: RemoteView(parent),
|
||||
m_initDone(false),
|
||||
m_buttonMask(0),
|
||||
|
@ -74,7 +75,7 @@ VncView::VncView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
|||
|
||||
m_clipboard = QApplication::clipboard();
|
||||
connect(m_clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
|
||||
|
||||
|
||||
#ifndef QTONLY
|
||||
m_hostPreferences = new VncHostPreferences(configGroup, this);
|
||||
#else
|
||||
|
@ -121,8 +122,8 @@ QSize VncView::minimumSizeHint() const
|
|||
void VncView::scaleResize(int w, int h)
|
||||
{
|
||||
RemoteView::scaleResize(w, h);
|
||||
|
||||
kDebug(5011) << w << h;
|
||||
|
||||
qCritical(KRDC) << w << h;
|
||||
if (m_scale) {
|
||||
m_verticalFactor = (qreal) h / m_frame.height();
|
||||
m_horizontalFactor = (qreal) w / m_frame.width();
|
||||
|
@ -139,7 +140,7 @@ void VncView::scaleResize(int w, int h)
|
|||
const qreal newH = m_frame.height() * m_verticalFactor;
|
||||
setMaximumSize(newW, newH); //This is a hack to force Qt to center the view in the scroll area
|
||||
resize(newW, newH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VncView::updateConfiguration()
|
||||
|
@ -152,7 +153,7 @@ void VncView::updateConfiguration()
|
|||
|
||||
void VncView::startQuitting()
|
||||
{
|
||||
kDebug(5011) << "about to quit";
|
||||
qCritical(KRDC) << "about to quit";
|
||||
|
||||
setStatus(Disconnecting);
|
||||
|
||||
|
@ -173,12 +174,12 @@ void VncView::startQuitting()
|
|||
// needs an event loop in this thread so execution continues after 'emit'
|
||||
QEventLoop loop;
|
||||
if (!loop.processEvents()) {
|
||||
kDebug(5011) << "BUG: deadlocked, but no events to deliver?";
|
||||
qCritical(KRDC) << "BUG: deadlocked, but no events to deliver?";
|
||||
}
|
||||
vncThread.wait(500);
|
||||
}
|
||||
|
||||
kDebug(5011) << "Quit VNC thread success:" << quitSuccess;
|
||||
qCritical(KRDC) << "Quit VNC thread success:" << quitSuccess;
|
||||
|
||||
setStatus(Disconnected);
|
||||
}
|
||||
|
@ -209,7 +210,7 @@ bool VncView::start()
|
|||
// KRDC does always just have one main window, so at(0) is safe
|
||||
KXMLGUIClient *mainWindow = dynamic_cast<KXMLGUIClient*>(KMainWindow::memberList().at(0));
|
||||
if (mainWindow)
|
||||
mainWindow->actionCollection()->action("show_local_cursor")->setChecked(true);
|
||||
mainWindow->actionCollection()->action(QLatin1String("show_local_cursor"))->setChecked(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -231,7 +232,7 @@ bool VncView::supportsLocalCursor() const
|
|||
|
||||
void VncView::requestPassword(bool includingUsername)
|
||||
{
|
||||
kDebug(5011) << "request password";
|
||||
qCritical(KRDC) << "request password";
|
||||
|
||||
setStatus(Authenticating);
|
||||
|
||||
|
@ -290,7 +291,7 @@ void VncView::requestPassword(bool includingUsername)
|
|||
vncThread.setPassword(dialog.password());
|
||||
if (includingUsername) vncThread.setUsername(dialog.username());
|
||||
} else {
|
||||
kDebug(5011) << "password dialog not accepted";
|
||||
qCritical(KRDC) << "password dialog not accepted";
|
||||
startQuitting();
|
||||
}
|
||||
#endif
|
||||
|
@ -298,9 +299,9 @@ void VncView::requestPassword(bool includingUsername)
|
|||
|
||||
void VncView::outputErrorMessage(const QString &message)
|
||||
{
|
||||
kDebug(5011) << message;
|
||||
qCritical(KRDC) << message;
|
||||
|
||||
if (message == "INTERNAL:APPLE_VNC_COMPATIBILTY") {
|
||||
if (message == QLatin1String("INTERNAL:APPLE_VNC_COMPATIBILTY")) {
|
||||
setCursor(localDotCursor());
|
||||
m_forceLocalCursor = true;
|
||||
return;
|
||||
|
@ -322,7 +323,7 @@ HostPreferences* VncView::hostPreferences()
|
|||
|
||||
void VncView::updateImage(int x, int y, int w, int h)
|
||||
{
|
||||
// kDebug(5011) << "got update" << width() << height();
|
||||
// qCritical(KRDC) << "got update" << width() << height();
|
||||
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
|
@ -353,13 +354,13 @@ void VncView::updateImage(int x, int y, int w, int h)
|
|||
setFocusPolicy(Qt::WheelFocus);
|
||||
setStatus(Connected);
|
||||
emit connected();
|
||||
|
||||
|
||||
if (m_scale) {
|
||||
#ifndef QTONLY
|
||||
kDebug(5011) << "Setting initial size w:" <<m_hostPreferences->width() << " h:" << m_hostPreferences->height();
|
||||
qCritical(KRDC) << "Setting initial size w:" <<m_hostPreferences->width() << " h:" << m_hostPreferences->height();
|
||||
emit framebufferSizeChanged(m_hostPreferences->width(), m_hostPreferences->height());
|
||||
scaleResize(m_hostPreferences->width(), m_hostPreferences->height());
|
||||
kDebug() << "m_frame.size():" << m_frame.size() << "size()" << size();
|
||||
qCDebug(KRDC) << "m_frame.size():" << m_frame.size() << "size()" << size();
|
||||
#else
|
||||
//TODO: qtonly alternative
|
||||
#endif
|
||||
|
@ -375,13 +376,13 @@ void VncView::updateImage(int x, int y, int w, int h)
|
|||
}
|
||||
|
||||
if ((y == 0 && x == 0) && (m_frame.size() != size())) {
|
||||
kDebug(5011) << "Updating framebuffer size";
|
||||
qCritical(KRDC) << "Updating framebuffer size";
|
||||
if (m_scale) {
|
||||
setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
if (parentWidget())
|
||||
scaleResize(parentWidget()->width(), parentWidget()->height());
|
||||
} else {
|
||||
kDebug(5011) << "Resizing: " << m_frame.width() << m_frame.height();
|
||||
qCritical(KRDC) << "Resizing: " << m_frame.width() << m_frame.height();
|
||||
resize(m_frame.width(), m_frame.height());
|
||||
setMaximumSize(m_frame.width(), m_frame.height()); //This is a hack to force Qt to center the view in the scroll area
|
||||
setMinimumSize(m_frame.width(), m_frame.height());
|
||||
|
@ -441,9 +442,9 @@ void VncView::setCut(const QString &text)
|
|||
|
||||
void VncView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
// kDebug(5011) << "paint event: x: " << m_x << ", y: " << m_y << ", w: " << m_w << ", h: " << m_h;
|
||||
// qCDebug(KRDC) << "paint event: x: " << m_x << ", y: " << m_y << ", w: " << m_w << ", h: " << m_h;
|
||||
if (m_frame.isNull() || m_frame.format() == QImage::Format_Invalid) {
|
||||
kDebug(5011) << "no valid image to paint";
|
||||
qCDebug(KRDC) << "no valid image to paint";
|
||||
RemoteView::paintEvent(event);
|
||||
return;
|
||||
}
|
||||
|
@ -453,27 +454,27 @@ void VncView::paintEvent(QPaintEvent *event)
|
|||
QPainter painter(this);
|
||||
|
||||
if (m_repaint) {
|
||||
// kDebug(5011) << "normal repaint";
|
||||
// qCDebug(KRDC) << "normal repaint";
|
||||
painter.drawImage(QRect(qRound(m_x*m_horizontalFactor), qRound(m_y*m_verticalFactor),
|
||||
qRound(m_w*m_horizontalFactor), qRound(m_h*m_verticalFactor)),
|
||||
m_frame.copy(m_x, m_y, m_w, m_h).scaled(qRound(m_w*m_horizontalFactor),
|
||||
qRound(m_w*m_horizontalFactor), qRound(m_h*m_verticalFactor)),
|
||||
m_frame.copy(m_x, m_y, m_w, m_h).scaled(qRound(m_w*m_horizontalFactor),
|
||||
qRound(m_h*m_verticalFactor),
|
||||
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
} else {
|
||||
// kDebug(5011) << "resize repaint";
|
||||
// qCDebug(KRDC) << "resize repaint";
|
||||
QRect rect = event->rect();
|
||||
if (rect.width() != width() || rect.height() != height()) {
|
||||
// kDebug(5011) << "Partial repaint";
|
||||
// qCDebug(KRDC) << "Partial repaint";
|
||||
const int sx = rect.x()/m_horizontalFactor;
|
||||
const int sy = rect.y()/m_verticalFactor;
|
||||
const int sw = rect.width()/m_horizontalFactor;
|
||||
const int sh = rect.height()/m_verticalFactor;
|
||||
painter.drawImage(rect,
|
||||
painter.drawImage(rect,
|
||||
m_frame.copy(sx, sy, sw, sh).scaled(rect.width(), rect.height(),
|
||||
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
} else {
|
||||
// kDebug(5011) << "Full repaint" << width() << height() << m_frame.width() << m_frame.height();
|
||||
painter.drawImage(QRect(0, 0, width(), height()),
|
||||
// qCDebug(KRDC) << "Full repaint" << width() << height() << m_frame.width() << m_frame.height();
|
||||
painter.drawImage(QRect(0, 0, width(), height()),
|
||||
m_frame.scaled(m_frame.width() * m_horizontalFactor, m_frame.height() * m_verticalFactor,
|
||||
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
}
|
||||
|
@ -493,7 +494,7 @@ bool VncView::event(QEvent *event)
|
|||
switch (event->type()) {
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
// kDebug(5011) << "keyEvent";
|
||||
// qCDebug(KRDC) << "keyEvent";
|
||||
keyEventHandler(static_cast<QKeyEvent*>(event));
|
||||
return true;
|
||||
break;
|
||||
|
@ -501,12 +502,12 @@ bool VncView::event(QEvent *event)
|
|||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove:
|
||||
// kDebug(5011) << "mouseEvent";
|
||||
// qCDebug(KRDC) << "mouseEvent";
|
||||
mouseEventHandler(static_cast<QMouseEvent*>(event));
|
||||
return true;
|
||||
break;
|
||||
case QEvent::Wheel:
|
||||
// kDebug(5011) << "wheelEvent";
|
||||
// qCDebug(KRDC) << "wheelEvent";
|
||||
wheelEventHandler(static_cast<QWheelEvent*>(event));
|
||||
return true;
|
||||
break;
|
||||
|
@ -600,8 +601,6 @@ void VncView::unpressModifiers()
|
|||
|
||||
void VncView::clipboardDataChanged()
|
||||
{
|
||||
kDebug(5011);
|
||||
|
||||
if (m_status != Connected)
|
||||
return;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#endif
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QMap>
|
||||
|
||||
extern "C" {
|
||||
#include <rfb/rfbclient.h>
|
||||
|
@ -44,7 +45,7 @@ class VncView: public RemoteView
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VncView(QWidget *parent = 0, const KUrl &url = KUrl(), KConfigGroup configGroup = KConfigGroup());
|
||||
explicit VncView(QWidget *parent = 0, const QUrl &url = QUrl(), KConfigGroup configGroup = KConfigGroup());
|
||||
~VncView();
|
||||
|
||||
QSize framebufferSize();
|
||||
|
@ -55,7 +56,7 @@ public:
|
|||
bool start();
|
||||
bool supportsScaling() const;
|
||||
bool supportsLocalCursor() const;
|
||||
|
||||
|
||||
#ifndef QTONLY
|
||||
HostPreferences* hostPreferences();
|
||||
#endif
|
||||
|
@ -63,10 +64,10 @@ public:
|
|||
void setViewOnly(bool viewOnly);
|
||||
void showDotCursor(DotCursorState state);
|
||||
void enableScaling(bool scale);
|
||||
|
||||
|
||||
virtual void updateConfiguration();
|
||||
|
||||
public slots:
|
||||
public Q_SLOTS:
|
||||
void scaleResize(int w, int h);
|
||||
|
||||
protected:
|
||||
|
@ -98,8 +99,8 @@ private:
|
|||
void unpressModifiers();
|
||||
void wheelEventHandler(QWheelEvent *event);
|
||||
void mouseEventHandler(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateImage(int x, int y, int w, int h);
|
||||
void setCut(const QString &text);
|
||||
void requestPassword(bool includingUsername);
|
||||
|
|
|
@ -22,29 +22,30 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "vncviewfactory.h"
|
||||
#include "remoteviewfactory.h"
|
||||
|
||||
#include <KDebug>
|
||||
#include <KCoreAddons/KExportPlugin>
|
||||
|
||||
KRDC_PLUGIN_EXPORT(VncViewFactory)
|
||||
K_PLUGIN_FACTORY_WITH_JSON(KrdcFactory, "krdc_vnc.json", registerPlugin<VncViewFactory>();)
|
||||
|
||||
VncViewFactory::VncViewFactory(QObject *parent, const QVariantList &args)
|
||||
: RemoteViewFactory(parent)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
KGlobal::locale()->insertCatalog("krdc");
|
||||
KLocalizedString::setApplicationDomain("krdc");
|
||||
}
|
||||
|
||||
VncViewFactory::~VncViewFactory()
|
||||
{
|
||||
}
|
||||
|
||||
bool VncViewFactory::supportsUrl(const KUrl &url) const
|
||||
bool VncViewFactory::supportsUrl(const QUrl &url) const
|
||||
{
|
||||
return (url.scheme().compare("vnc", Qt::CaseInsensitive) == 0);
|
||||
return (url.scheme().compare(QLatin1String("vnc"), Qt::CaseInsensitive) == 0);
|
||||
}
|
||||
|
||||
RemoteView *VncViewFactory::createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup)
|
||||
RemoteView *VncViewFactory::createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup)
|
||||
{
|
||||
return new VncView(parent, url, configGroup);
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ HostPreferences *VncViewFactory::createHostPreferences(KConfigGroup configGroup,
|
|||
|
||||
QString VncViewFactory::scheme() const
|
||||
{
|
||||
return "vnc";
|
||||
return QLatin1String("vnc");
|
||||
}
|
||||
|
||||
QString VncViewFactory::connectActionText() const
|
||||
|
@ -75,4 +76,4 @@ QString VncViewFactory::connectToolTipText() const
|
|||
"<i>Example: vncserver:1 (host:port / screen)</i></html>");
|
||||
}
|
||||
|
||||
#include "moc_vncviewfactory.cpp"
|
||||
#include "vncviewfactory.moc"
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#define VNCVIEWFACTORY_H
|
||||
|
||||
#include "remoteviewfactory.h"
|
||||
|
||||
#include "vncview.h"
|
||||
#include "vncpreferences.h"
|
||||
|
||||
|
@ -38,16 +37,16 @@ public:
|
|||
|
||||
virtual ~VncViewFactory();
|
||||
|
||||
virtual bool supportsUrl(const KUrl &url) const;
|
||||
virtual bool supportsUrl(const QUrl &url) const;
|
||||
|
||||
virtual RemoteView *createView(QWidget *parent, const KUrl &url, KConfigGroup configGroup);
|
||||
virtual RemoteView *createView(QWidget *parent, const QUrl &url, KConfigGroup configGroup);
|
||||
|
||||
virtual HostPreferences *createHostPreferences(KConfigGroup configGroup, QWidget *parent);
|
||||
|
||||
virtual QString scheme() const;
|
||||
|
||||
virtual QString connectActionText() const;
|
||||
|
||||
|
||||
virtual QString connectButtonText() const;
|
||||
|
||||
virtual QString connectToolTipText() const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user