Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b85cbd49 authored by David Edmundson's avatar David Edmundson

Show UI for per screen scaling options on supported platforms

Summary:
X still has a global set scale UI
Wayland gets a more normal looking per-screen UI

Test Plan: #plasma

Reviewers: sebas

Reviewed By: sebas

Subscribers: sebas, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7331
parent 98a0345d
......@@ -65,8 +65,10 @@ void ControlPanel::setConfig(const KScreen::ConfigPtr &config)
void ControlPanel::addOutput(const KScreen::OutputPtr &output)
{
OutputConfig *outputCfg = new OutputConfig(output, this);
OutputConfig *outputCfg = new OutputConfig(this);
outputCfg->setVisible(false);
outputCfg->setShowScaleOption(mConfig->supportedFeatures().testFlag(KScreen::Config::Feature::PerOutputScaling));
outputCfg->setOutput(output);
connect(outputCfg, &OutputConfig::changed,
this, &ControlPanel::changed);
......
......@@ -82,6 +82,12 @@ void OutputConfig::initUi()
mRotation->setCurrentIndex(index);
});
connect(mOutput.data(), &KScreen::Output::scaleChanged,
this, [=]() {
const int index = mScale->findData(mOutput->scale());
mScale->setCurrentIndex(index);
});
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *vbox = new QVBoxLayout(this);
......@@ -120,7 +126,18 @@ void OutputConfig::initUi()
formLayout->addRow(i18n("Orientation:"), mRotation);
formLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
if (mShowScaleOption) {
mScale = new QComboBox(this);
mScale->addItem(i18nc("Scale multiplier, show everything at 1 times normal scale", "1x"), 1);
mScale->addItem(i18nc("Scale multiplier, show everything at 2 times normal scale", "2x"), 2);
connect(mScale, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
this, &OutputConfig::slotScaleChanged);
mScale->setCurrentIndex(mScale->findData(mOutput->scale()));
formLayout->addRow(i18n("Scale:"), mScale);
formLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
}
CollapsableButton *advancedButton = new CollapsableButton(i18n("Advanced Settings"), this);
advancedButton->setCollapsed(true);
......@@ -224,3 +241,23 @@ void OutputConfig::slotRefreshRateChanged(int index)
Q_EMIT changed();
}
void OutputConfig::slotScaleChanged(int index)
{
auto scale = mScale->itemData(index).toInt();
mOutput->setScale(scale);
Q_EMIT changed();
}
void OutputConfig::setShowScaleOption(bool showScaleOption)
{
mShowScaleOption = showScaleOption;
if (mOutput) {
initUi();
}
}
bool OutputConfig::showScaleOption() const
{
return mShowScaleOption;
}
......@@ -47,10 +47,14 @@ class OutputConfig : public QWidget
KScreen::OutputPtr output() const;
void setTitle(const QString &title);
void setShowScaleOption(bool showScaleOption);
bool showScaleOption() const;
protected Q_SLOTS:
void slotResolutionChanged(const QSize &size);
void slotRotationChanged(int index);
void slotRefreshRateChanged(int index);
void slotScaleChanged(int index);
Q_SIGNALS:
void changed();
......@@ -64,7 +68,9 @@ class OutputConfig : public QWidget
QCheckBox *mEnabled;
ResolutionSlider *mResolution;
QComboBox *mRotation;
QComboBox *mScale;
QComboBox *mRefreshRate;
bool mShowScaleOption = false;
};
#endif // OUTPUTCONFIG_H
......@@ -119,15 +119,16 @@ Widget::Widget(QWidget *parent):
vbox->addWidget(mUnifyButton);
auto setScaleButton = new QPushButton(i18n("Scale Display"), this);
connect(setScaleButton, &QPushButton::released,
mScaleAllOutputsButton = new QPushButton(i18n("Scale Display"), this);
connect(mScaleAllOutputsButton, &QPushButton::released,
[this] {
QPointer<ScalingConfig> dialog = new ScalingConfig(mConfig->outputs(), this);
dialog->exec();
delete dialog;
});
vbox->addWidget(setScaleButton);
vbox->addWidget(mScaleAllOutputsButton);
mOutputTimer = new QTimer(this);
connect(mOutputTimer, &QTimer::timeout,
......@@ -174,6 +175,8 @@ void Widget::setConfig(const KScreen::ConfigPtr &config)
mControlPanel->setConfig(mConfig);
mPrimaryCombo->setConfig(mConfig);
mUnifyButton->setEnabled(mConfig->outputs().count() > 1);
mScaleAllOutputsButton->setVisible(!mConfig->supportedFeatures().testFlag(KScreen::Config::Feature::PerOutputScaling));
for (const KScreen::OutputPtr &output : mConfig->outputs()) {
connect(output.data(), &KScreen::Output::isEnabledChanged,
......
......@@ -91,6 +91,7 @@ class Widget : public QWidget
PrimaryOutputCombo *mPrimaryCombo;
QComboBox *mProfilesCombo;
QPushButton *mScaleAllOutputsButton;
QPushButton *mUnifyButton;
QPushButton *mSaveProfileButton;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment