diff --git a/rdp/rdphostpreferences.cpp b/rdp/rdphostpreferences.cpp index 37f4cb6..e43038e 100644 --- a/rdp/rdphostpreferences.cpp +++ b/rdp/rdphostpreferences.cpp @@ -1,316 +1,323 @@ /**************************************************************************** ** ** Copyright (C) 2007 - 2012 Urs Wolfer ** Copyright (C) 2012 AceLan Kao ** ** This file is part of KDE. ** ** 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) any later version. ** ** 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; see the file COPYING. If not, write to ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ** Boston, MA 02110-1301, USA. ** ****************************************************************************/ #include "rdphostpreferences.h" #include "settings.h" -#include - static const QStringList keymaps = (QStringList() << QStringLiteral("ar") << QStringLiteral("cs") << QStringLiteral("da") << QStringLiteral("de") << QStringLiteral("de-ch") << QStringLiteral("en-dv") << QStringLiteral("en-gb") << QStringLiteral("en-us") << QStringLiteral("es") << QStringLiteral("et") << QStringLiteral("fi") << QStringLiteral("fo") << QStringLiteral("fr") << QStringLiteral("fr-be") << QStringLiteral("fr-ca") << QStringLiteral("fr-ch") << QStringLiteral("he") << QStringLiteral("hr") << QStringLiteral("hu") << QStringLiteral("is") << QStringLiteral("it") << QStringLiteral("ja") << QStringLiteral("ko") << QStringLiteral("lt") << QStringLiteral("lv") << QStringLiteral("mk") << QStringLiteral("nl") << QStringLiteral("nl-be") << QStringLiteral("no") << QStringLiteral("pl") << QStringLiteral("pt") << QStringLiteral("pt-br") << QStringLiteral("ru") << QStringLiteral("sl") << QStringLiteral("sv") << QStringLiteral("th") << QStringLiteral("tr") ); static const int defaultKeymap = 7; // en-us inline int keymap2int(const QString &keymap) { const int index = keymaps.lastIndexOf(keymap); return (index == -1) ? defaultKeymap : index; } inline QString int2keymap(int layout) { if (layout >= 0 && layout < keymaps.count()) return keymaps.at(layout); else return keymaps.at(defaultKeymap); } RdpHostPreferences::RdpHostPreferences(KConfigGroup configGroup, QObject *parent) : HostPreferences(configGroup, parent) { } RdpHostPreferences::~RdpHostPreferences() { } QWidget* RdpHostPreferences::createProtocolSpecificConfigPage() { QWidget *rdpPage = new QWidget(); rdpUi.setupUi(rdpPage); connect(rdpUi.kcfg_Sound, SIGNAL(currentIndexChanged(int)), SLOT(updateSoundSystem(int))); + connect(rdpUi.browseMediaButton, SIGNAL(released()), SLOT(browseMedia())); rdpUi.loginGroupBox->setVisible(false); rdpUi.kcfg_Height->setValue(height()); rdpUi.kcfg_Width->setValue(width()); rdpUi.kcfg_Resolution->setCurrentIndex(resolution()); rdpUi.kcfg_ColorDepth->setCurrentIndex(colorDepth()); rdpUi.kcfg_KeyboardLayout->setCurrentIndex(keymap2int(keyboardLayout())); rdpUi.kcfg_Sound->setCurrentIndex(sound()); rdpUi.kcfg_SoundSystem->setCurrentIndex(soundSystem()); rdpUi.kcfg_Console->setChecked(console()); rdpUi.kcfg_ExtraOptions->setText(extraOptions()); rdpUi.kcfg_RemoteFX->setChecked(remoteFX()); rdpUi.kcfg_Performance->setCurrentIndex(performance()); rdpUi.kcfg_ShareMedia->setText(shareMedia()); // Have to call updateWidthHeight() here // We leverage the final part of this function to enable/disable kcfg_Height and kcfg_Width updateWidthHeight(resolution()); connect(rdpUi.kcfg_Resolution, SIGNAL(currentIndexChanged(int)), SLOT(updateWidthHeight(int))); return rdpPage; } void RdpHostPreferences::updateWidthHeight(int index) { switch (index) { case 0: rdpUi.kcfg_Height->setValue(480); rdpUi.kcfg_Width->setValue(640); break; case 1: rdpUi.kcfg_Height->setValue(600); rdpUi.kcfg_Width->setValue(800); break; case 2: rdpUi.kcfg_Height->setValue(768); rdpUi.kcfg_Width->setValue(1024); break; case 3: rdpUi.kcfg_Height->setValue(1024); rdpUi.kcfg_Width->setValue(1280); break; case 4: rdpUi.kcfg_Height->setValue(1200); rdpUi.kcfg_Width->setValue(1600); break; case 5: { QDesktopWidget *desktop = QApplication::desktop(); int currentScreen = desktop->screenNumber(rdpUi.kcfg_Height); rdpUi.kcfg_Height->setValue(desktop->screenGeometry(currentScreen).height()); rdpUi.kcfg_Width->setValue(desktop->screenGeometry(currentScreen).width()); break; } case 7: rdpUi.kcfg_Height->setValue(0); rdpUi.kcfg_Width->setValue(0); break; case 6: default: break; } const bool enabled = (index == 6) ? true : false; rdpUi.kcfg_Height->setEnabled(enabled); rdpUi.kcfg_Width->setEnabled(enabled); rdpUi.heightLabel->setEnabled(enabled); rdpUi.widthLabel->setEnabled(enabled); } void RdpHostPreferences::updateSoundSystem(int index) { switch (index) { case 0: /* On This Computer */ rdpUi.kcfg_SoundSystem->setCurrentIndex(soundSystem()); rdpUi.kcfg_SoundSystem->setEnabled(true); break; case 1: /* On Remote Computer */ case 2: /* Disable Sound */ rdpUi.kcfg_SoundSystem->setCurrentIndex(2); rdpUi.kcfg_SoundSystem->setEnabled(false); break; default: break; } } +void RdpHostPreferences::browseMedia() +{ + QString shareDir = QFileDialog::getExistingDirectory(rdpUi.browseMediaButton, i18n("Browse to media share path"), rdpUi.kcfg_ShareMedia->text()); + if (!shareDir.isNull()) { + rdpUi.kcfg_ShareMedia->setText(shareDir); + } +} + void RdpHostPreferences::acceptConfig() { HostPreferences::acceptConfig(); setHeight(rdpUi.kcfg_Height->value()); setWidth(rdpUi.kcfg_Width->value()); setResolution(rdpUi.kcfg_Resolution->currentIndex()); setColorDepth(rdpUi.kcfg_ColorDepth->currentIndex()); setKeyboardLayout(int2keymap(rdpUi.kcfg_KeyboardLayout->currentIndex())); setSound(rdpUi.kcfg_Sound->currentIndex()); setSoundSystem(rdpUi.kcfg_SoundSystem->currentIndex()); setConsole(rdpUi.kcfg_Console->isChecked()); setExtraOptions(rdpUi.kcfg_ExtraOptions->text()); setRemoteFX(rdpUi.kcfg_RemoteFX->isChecked()); setPerformance(rdpUi.kcfg_Performance->currentIndex()); setShareMedia(rdpUi.kcfg_ShareMedia->text()); } void RdpHostPreferences::setResolution(int resolution) { if (resolution >= 0) m_configGroup.writeEntry("resolution", resolution); } int RdpHostPreferences::resolution() const { return m_configGroup.readEntry("resolution", Settings::resolution()); } void RdpHostPreferences::setColorDepth(int colorDepth) { if (colorDepth >= 0) m_configGroup.writeEntry("colorDepth", colorDepth); } int RdpHostPreferences::colorDepth() const { return m_configGroup.readEntry("colorDepth", Settings::colorDepth()); } void RdpHostPreferences::setKeyboardLayout(const QString &keyboardLayout) { if (!keyboardLayout.isNull()) m_configGroup.writeEntry("keyboardLayout", keymap2int(keyboardLayout)); } QString RdpHostPreferences::keyboardLayout() const { return int2keymap(m_configGroup.readEntry("keyboardLayout", Settings::keyboardLayout())); } void RdpHostPreferences::setSound(int sound) { if (sound >= 0) m_configGroup.writeEntry("sound", sound); } int RdpHostPreferences::sound() const { return m_configGroup.readEntry("sound", Settings::sound()); } void RdpHostPreferences::setSoundSystem(int sound) { if (sound >= 0) m_configGroup.writeEntry("soundSystem", sound); } int RdpHostPreferences::soundSystem() const { return m_configGroup.readEntry("soundSystem", Settings::soundSystem()); } void RdpHostPreferences::setConsole(bool console) { m_configGroup.writeEntry("console", console); } bool RdpHostPreferences::console() const { return m_configGroup.readEntry("console", Settings::console()); } void RdpHostPreferences::setExtraOptions(const QString &extraOptions) { if (!extraOptions.isNull()) m_configGroup.writeEntry("extraOptions", extraOptions); } QString RdpHostPreferences::extraOptions() const { return m_configGroup.readEntry("extraOptions", Settings::extraOptions()); } void RdpHostPreferences::setRemoteFX(bool remoteFX) { m_configGroup.writeEntry("remoteFX", remoteFX); } bool RdpHostPreferences::remoteFX() const { return m_configGroup.readEntry("remoteFX", Settings::remoteFX()); } void RdpHostPreferences::setPerformance(int performance) { if (performance >= 0) m_configGroup.writeEntry("performance", performance); } int RdpHostPreferences::performance() const { return m_configGroup.readEntry("performance", Settings::performance()); } void RdpHostPreferences::setShareMedia(const QString &shareMedia) { if (!shareMedia.isNull()) m_configGroup.writeEntry("shareMedia", shareMedia); } QString RdpHostPreferences::shareMedia() const { return m_configGroup.readEntry("shareMedia", Settings::shareMedia()); } diff --git a/rdp/rdphostpreferences.h b/rdp/rdphostpreferences.h index dff3d89..d56ae77 100644 --- a/rdp/rdphostpreferences.h +++ b/rdp/rdphostpreferences.h @@ -1,72 +1,76 @@ /**************************************************************************** ** ** Copyright (C) 2007 - 2012 Urs Wolfer ** Copyright (C) 2012 AceLan Kao ** ** This file is part of KDE. ** ** 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) any later version. ** ** 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; see the file COPYING. If not, write to ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ** Boston, MA 02110-1301, USA. ** ****************************************************************************/ #ifndef RDPHOSTPREFERENCES_H #define RDPHOSTPREFERENCES_H #include "hostpreferences.h" #include "ui_rdppreferences.h" +#include +#include + class RdpHostPreferences : public HostPreferences { Q_OBJECT public: explicit RdpHostPreferences(KConfigGroup configGroup, QObject *parent = nullptr); ~RdpHostPreferences() override; void setResolution(int resolution); int resolution() const; void setColorDepth(int colorDepth); int colorDepth() const; void setKeyboardLayout(const QString &keyboardLayout); QString keyboardLayout() const; void setSound(int sound); int sound() const; void setSoundSystem(int sound); int soundSystem() const; void setConsole(bool console); bool console() const; void setExtraOptions(const QString &extraOptions); QString extraOptions() const; void setRemoteFX(bool remoteFX); bool remoteFX() const; void setPerformance(int performance); int performance() const; void setShareMedia(const QString &shareMedia); QString shareMedia() const; protected: QWidget* createProtocolSpecificConfigPage() override; void acceptConfig() override; private: Ui::RdpPreferences rdpUi; private Q_SLOTS: void updateWidthHeight(int index); void updateSoundSystem(int index); + void browseMedia(); }; #endif diff --git a/rdp/rdppreferences.cpp b/rdp/rdppreferences.cpp index c1c61a7..5586d75 100644 --- a/rdp/rdppreferences.cpp +++ b/rdp/rdppreferences.cpp @@ -1,64 +1,66 @@ /**************************************************************************** ** ** Copyright (C) 2008 Urs Wolfer ** ** This file is part of KDE. ** ** 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) any later version. ** ** 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; see the file COPYING. If not, write to ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ** Boston, MA 02110-1301, USA. ** ****************************************************************************/ #include "rdppreferences.h" #include "remoteviewfactory.h" #include "settings.h" #include "ui_rdppreferences.h" K_PLUGIN_FACTORY_WITH_JSON(KrdcKcmFactory, "krdc_rdp_config.json", registerPlugin();) RdpPreferences::RdpPreferences(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { Ui::RdpPreferences rdpUi; rdpUi.setupUi(this); // would need a lot of code duplication. find a solution, bit it's not // that important because you will not change this configuration each day... // see rdp/rdphostpreferences.cpp rdpUi.kcfg_Resolution->hide(); rdpUi.resolutionDummyLabel->hide(); rdpUi.kcfg_Height->setEnabled(true); rdpUi.kcfg_Width->setEnabled(true); rdpUi.heightLabel->setEnabled(true); rdpUi.widthLabel->setEnabled(true); + rdpUi.browseMediaButton->hide(); + addConfig(Settings::self(), this); } RdpPreferences::~RdpPreferences() { } void RdpPreferences::load() { KCModule::load(); } void RdpPreferences::save() { KCModule::save(); } #include "rdppreferences.moc" diff --git a/rdp/rdppreferences.ui b/rdp/rdppreferences.ui index 33f522a..ac7a077 100644 --- a/rdp/rdppreferences.ui +++ b/rdp/rdppreferences.ui @@ -1,702 +1,716 @@ RdpPreferences 0 0 484 452 Connection Desktop &resolution: kcfg_Resolution 280 0 Here you can specify the resolution of the remote desktop. This resolution determines the size of the desktop that will be presented to you. 1 Minimal (640x480) Small (800x600) Normal (1024x768) Large (1280x1024) Very Large (1600x1200) Current Screen Resolution Custom Resolution (...) Current KRDC Size false &Width: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_Width false This is the width of the remote desktop. You can only change this value manually if you select Custom as desktop resolution above. 9999 800 false H&eight: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_Height false This is the height of the remote desktop. You can only change this value manually if you select Custom as desktop resolution above. 9999 600 Color &depth: kcfg_ColorDepth 280 0 Low Color (8 Bit) High Color (16 Bit) True Color (24 Bit) True Color with Alpha (32 Bit) &Keyboard layout: kcfg_KeyboardLayout 280 0 Use this to specify your keyboard layout. This layout setting is used to send the correct keyboard codes to the server. 7 Arabic (ar) Czech (cs) Danish (da) German (de) Swiss German (de-ch) American Dvorak (en-dv) British English (en-gb) US English (en-us) Spanish (es) Estonian (et) Finnish (fi) Faroese (fo) French (fr) Belgian (fr-be) French Canadian (fr-ca) Swiss French (fr-ch) Hebrew (he) Croatian (hr) Hungarian (hu) Icelandic (is) Italian (it) Japanese (ja) Korean (ko) Lithuanian (lt) Latvian (lv) Macedonian (mk) Dutch (nl) Belgian Dutch (nl-be) Norwegian (no) Polish (pl) Portuguese (pt) Brazilian (pt-br) Russian (ru) Slovenian (sl) Swedish (sv) Thai (th) Turkish (tr) Sound: kcfg_Sound 280 0 On This Computer On Remote Computer Disable Sound 100 0 ALSA PulseAudio None Performance: kcfg_Performance 280 0 Modem Broadband LAN RemoteFX: kcfg_RemoteFX Enhanced visual experience RemoteFX covers a set of technologies that enhance visual experience of the Remote Desktop Protocol. Share Media: kcfg_ShareMedia - - - - 280 - 0 - - - - Share a local media directory with the remote host. - - - true - - + + + + + + 280 + 0 + + + + Share a local media directory with the remote host. + + + true + + + + + + + + + + + + + + Expert Options Console login: kcfg_Console Attach to Windows Server console Extra options: kcfg_ExtraOptions 280 0 Here you can enter additional xfreerdp (FreeRDP) options. true Login Default user name: No default user name true Automatically recognize "LDAP"-Logins and share passwords Qt::Vertical 428 16 KComboBox QComboBox
kcombobox.h
KLineEdit QLineEdit
klineedit.h
kcfg_Resolution kcfg_Width kcfg_Height kcfg_ColorDepth kcfg_KeyboardLayout kcfg_Sound kcfg_SoundSystem kcfg_Performance kcfg_RemoteFX kcfg_ShareMedia kcfg_Console kcfg_ExtraOptions kcfg_DefaultRdpUserName kcfg_RecognizeLdapLogins