diff --git a/kcm/src/kcm_kscreen.cpp b/kcm/src/kcm_kscreen.cpp index 82282cc..2fdcd33 100644 --- a/kcm/src/kcm_kscreen.cpp +++ b/kcm/src/kcm_kscreen.cpp @@ -1,186 +1,188 @@ /* Copyright (C) 2012 Dan Vratil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "kcm_kscreen.h" #include "kcm_screen_debug.h" #include "widget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY(KCMDisplayConfigurationFactory, registerPlugin();) using namespace KScreen; Q_DECLARE_METATYPE(KScreen::OutputPtr) Q_DECLARE_METATYPE(KScreen::ScreenPtr) KCMKScreen::KCMKScreen(QWidget* parent, const QVariantList& args) : KCModule(parent, args) { Log::instance(); setButtons(Apply | Default); KAboutData* about = new KAboutData(QStringLiteral("kcm_kscreen"), i18n("Display Configuration"), QStringLiteral(KSCREEN_VERSION), i18n("Configuration for displays"), KAboutLicense::GPL_V2, i18n("(c), 2012-2013 Daniel Vrátil")); about->addAuthor(i18n("Daniel Vrátil"), i18n("Maintainer") , QStringLiteral("dvratil@redhat.com")); setAboutData(about); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); } void KCMKScreen::configReady(ConfigOperation* op) { delete mMainLayout; mMainLayout = new QHBoxLayout(this); mMainLayout->setMargin(0); if (op->hasError()) { mKScreenWidget = nullptr; delete mKScreenWidget; QLabel *errorLabel = new QLabel(this); mMainLayout->addWidget(errorLabel); errorLabel->setText(i18n("No kscreen backend found. Please check your kscreen installation.")); return; } if (!mKScreenWidget) { mKScreenWidget = new Widget(this); mMainLayout->addWidget(mKScreenWidget); QObject::connect(mKScreenWidget, &Widget::changed, this, &KCMKScreen::changed); + } else { + mMainLayout->addWidget(mKScreenWidget); } mKScreenWidget->setConfig(qobject_cast(op)->config()); } KCMKScreen::~KCMKScreen() { } QSize KCMKScreen::sizeHint() const { return QSize(0, 700); } void KCMKScreen::changed() { if (!m_blockChanges) { KCModule::changed(); } } void KCMKScreen::save() { qCDebug(KSCREEN_KCM) << "Saving."; if (!mKScreenWidget) { return; } const KScreen::ConfigPtr &config = mKScreenWidget->currentConfig(); bool atLeastOneEnabledOutput = false; Q_FOREACH(const KScreen::OutputPtr &output, config->outputs()) { KScreen::ModePtr mode = output->currentMode(); if (output->isEnabled()) { atLeastOneEnabledOutput = true; } qCDebug(KSCREEN_KCM) << output->name() << output->id() << output.data() << "\n" << " Connected:" << output->isConnected() << "\n" << " Enabled:" << output->isEnabled() << "\n" << " Primary:" << output->isPrimary() << "\n" << " Rotation:" << output->rotation() << "\n" << " Mode:" << (mode ? mode->name() : QStringLiteral("unknown")) << "@" << (mode ? mode->refreshRate() : 0.0) << "Hz" << "\n" << " Position:" << output->pos().x() << "x" << output->pos().y(); } if (!atLeastOneEnabledOutput) { if (KMessageBox::warningYesNo(this, i18n("Are you sure you want to disable all outputs?"), i18nc("@title:window", "Disable All Outputs"), KGuiItem(i18n("&Disable All Outputs"), QIcon::fromTheme(QStringLiteral("dialog-ok-apply"))), KGuiItem(i18n("&Reconfigure"), QIcon::fromTheme(QStringLiteral("dialog-cancel"))), QString(), KMessageBox::Dangerous) == KMessageBox::No) { return; } } if (!Config::canBeApplied(config)) { KMessageBox::information(this, i18n("Sorry, your configuration could not be applied.\n\n" "Common reasons are that the overall screen size is too big, or you enabled more displays than supported by your GPU."), i18nc("@title:window", "Unsupported Configuration")); return; } m_blockChanges = true; /* Store the current config, apply settings */ auto *op = new SetConfigOperation(config); /* Block until the operation is completed, otherwise KCMShell will terminate * before we get to execute the Operation */ op->exec(); // The 1000ms is a bit "random" here, it's what works on the systems I've tested, but ultimately, this is a hack // due to the fact that we just can't be sure when xrandr is done changing things, 1000 doesn't seem to get in the way QTimer::singleShot(1000, this, [this] () { m_blockChanges = false; } ); } void KCMKScreen::defaults() { qCDebug(KSCREEN_KCM) << "APPLY DEFAULT"; load(); } void KCMKScreen::load() { qCDebug(KSCREEN_KCM) << "LOAD"; connect(new GetConfigOperation(), &GetConfigOperation::finished, this, &KCMKScreen::configReady); } #include "kcm_kscreen.moc" diff --git a/plasma/plasma-applet-kscreen.desktop.cmake b/plasma/plasma-applet-kscreen.desktop.cmake index fc27a01..7057d7a 100644 --- a/plasma/plasma-applet-kscreen.desktop.cmake +++ b/plasma/plasma-applet-kscreen.desktop.cmake @@ -1,96 +1,96 @@ [Desktop Entry] Name=Quick Display Configuration Name[ar]=ضبط سريع للعرض Name[bs]=Brza konfiguracija ekrana Name[ca]=Configuració ràpida de la pantalla Name[ca@valencia]=Configuració ràpida de la pantalla Name[da]=Hurtig konfiguration af skærme Name[de]=Schnelle Anzeige-Einrichtung Name[el]=Γρήγορη διαμόρφωση οθόνης Name[en_GB]=Quick Display Configuration Name[es]=Configuración rápida de la pantalla Name[et]=Ekraani kiirseadistamine Name[eu]=Bistaratzaileen konfigurazio azkarra Name[fi]=Näyttöasetusten pikasäätö Name[fr]=Configuration rapide de l'affichage Name[gl]=Configuración rápida da pantalla Name[hu]=Gyors megjelenítő-beállítás Name[id]=Quick Display Configuration Name[it]=Configurazione rapida dello schermo Name[ko]=빠른 화면 설정 Name[lt]=Greita ekrano konfigūracija Name[nb]=Hurtig skjermoppsett Name[nl]=Snel instellen van scherm Name[nn]=Kjapt skjermoppsett Name[pa]=ਤੁਰੰਤ ਡਿਸਪਲੇਅ ਸੰਰਚਨਾ Name[pl]=Szybkie ustawienia ekranu Name[pt]=Configuração Rápida do Ecrã Name[pt_BR]=Configuração rápida da tela Name[ro]=Configurare rapidă afișaj Name[ru]=Быстрая настройка экрана Name[sk]=Rýchle nastavenie obrazovky Name[sl]=Hitre nastavitve zaslona Name[sv]=Snabbinställning av skärm Name[tr]=Hızlı Ekran Yapılandırması Name[uk]=Швидке налаштовування дисплея Name[x-test]=xxQuick Display Configurationxx Name[zh_CN]=快捷显示配置 Name[zh_TW]=快速設定顯示器 Comment=Quick configuration of a new display Comment[ar]=ضبط سريع لعرض جديد Comment[bs]=Brza konfiguracija novog ekrana Comment[ca]=Configuració ràpida d'una pantalla nova Comment[ca@valencia]=Configuració ràpida d'una pantalla nova Comment[da]=Hurtig konfiguration af en ny skærm Comment[de]=Schnelle Einrichtung einer neuen Anzeige Comment[el]=Γρήγορη διαμόρφωση μιας νέας οθόνης Comment[en_GB]=Quick configuration of a new display Comment[es]=Configuración rápida de una nueva pantalla Comment[et]=Uue ekraani kiirseadistamine Comment[eu]=Bistaratzaile berri baten konfigurazio azkarra Comment[fi]=Näyttöasetusten pikasäätö Comment[fr]=Configuration rapide d'un nouvel affichage Comment[gl]=Configura rapidamente unha nova pantalla Comment[he]=הגדרה מהירה של תצוגה חדשה Comment[hu]=Új megjelenítők gyors beállítása Comment[ia]=Configuration rapide de un nove monstrator -Comment[id]=Konfigurasi cepat dari sebuah displai baru +Comment[id]=Konfigurasi cepat sebuah display baru Comment[it]=Configurazione rapida di un nuovo schermo Comment[ko]=새 디스플레이 빠른 설정 Comment[lt]=Grupės naujo ekrano konfigūracija Comment[nb]=Hurtig oppsett av en ny skjerm Comment[nl]=Snel instellen van een nieuwe scherm Comment[nn]=Kjapt oppsett av ny skjerm Comment[pa]=ਨਵੇਂ ਡਿਸਪਲੇਅ ਲਈ ਤੁਰੰਤ ਸੰਰਚਨਾ Comment[pl]=Szybkie ustawienia nowego ekranu Comment[pt]=Configuração rápida de um novo ecrã Comment[pt_BR]=Configuração rápida de uma nova tela Comment[ro]=Configurare rapidă a unui nou afișaj Comment[ru]=Быстрая настройка нового экрана Comment[sk]=Rýchle nastavenie novej obrazovky Comment[sl]=Hitre nastavitve novega zaslona Comment[sv]=Snabbinställning av en ny skärm Comment[tr]=Yeni bir ekranın hızlı yapılandırması Comment[uk]=Швидке налаштовування нового дисплея Comment[x-test]=xxQuick configuration of a new displayxx Comment[zh_CN]=快捷配置新显示器 Comment[zh_TW]=快速設定新的顯示器 Icon=preferences-desktop-display-randr Type=Service X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet X-Plasma-DefaultSize=290,150 X-Plasma-NotificationArea=true X-Plasma-ConfigPlugins=kscreen X-KDE-Library=plasma_applet_kscreen X-KDE-PluginInfo-Author=Dan Vrátil X-KDE-PluginInfo-Email=dvratil@redhat.com X-KDE-PluginInfo-Name=org.kde.plasma.kscreen X-KDE-PluginInfo-Version=@KSCREEN_VERSION@ X-KDE-PluginInfo-Website=http://www.kde.org X-KDE-PluginInfo-Category=System Information X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true