mirror of
https://github.com/KDE/latte-dock.git
synced 2025-02-05 05:47:26 +03:00
Option to set Settings size at per screen level
--the Latte Settings window tries its best in order to provide a nice experience concerning its width/height ratio and a width size that is best for its contents. There are cases that this fails so the user in the best to set it right. Latte now provides two shortcuts Meta+Scroll, that changes the width scale ratio and Ctrl+Scroll, that changes the height scale ratio when settings are in Basic mode. The previous shortcuts must be applied when the mouse is over the empty areas in the Settings View window.
This commit is contained in:
parent
6290ec33cf
commit
4048edc7f9
@ -58,6 +58,8 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
|
||||
connect(this, &UniversalSettings::screenTrackerIntervalChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::showInfoWindowChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::versionChanged, this, &UniversalSettings::saveConfig);
|
||||
|
||||
connect(this, &UniversalSettings::screenScalesChanged, this, &UniversalSettings::saveScalesConfig);
|
||||
}
|
||||
|
||||
UniversalSettings::~UniversalSettings()
|
||||
@ -75,6 +77,9 @@ void UniversalSettings::load()
|
||||
setAutostart(true);
|
||||
}
|
||||
|
||||
//! init screen scales
|
||||
m_screenScalesGroup = m_universalGroup.group("ScreenScales");
|
||||
|
||||
//! load configuration
|
||||
loadConfig();
|
||||
|
||||
@ -374,6 +379,42 @@ void UniversalSettings::setMouseSensitivity(Types::MouseSensitivity sensitivity)
|
||||
emit mouseSensitivityChanged();
|
||||
}
|
||||
|
||||
float UniversalSettings::screenWidthScale(QString screenName) const
|
||||
{
|
||||
if (!m_screenScales.contains(screenName)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return m_screenScales[screenName].first;
|
||||
}
|
||||
|
||||
float UniversalSettings::screenHeightScale(QString screenName) const
|
||||
{
|
||||
if (!m_screenScales.contains(screenName)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return m_screenScales[screenName].second;
|
||||
}
|
||||
|
||||
void UniversalSettings::setScreenScales(QString screenName, float widthScale, float heightScale)
|
||||
{
|
||||
if (!m_screenScales.contains(screenName)) {
|
||||
m_screenScales[screenName].first = widthScale;
|
||||
m_screenScales[screenName].second = heightScale;
|
||||
} else {
|
||||
if (m_screenScales[screenName].first == widthScale
|
||||
&& m_screenScales[screenName].second == heightScale) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_screenScales[screenName].first = widthScale;
|
||||
m_screenScales[screenName].second = heightScale;
|
||||
}
|
||||
|
||||
emit screenScalesChanged();
|
||||
}
|
||||
|
||||
void UniversalSettings::loadConfig()
|
||||
{
|
||||
m_version = m_universalGroup.readEntry("version", 1);
|
||||
@ -389,6 +430,8 @@ void UniversalSettings::loadConfig()
|
||||
m_showInfoWindow = m_universalGroup.readEntry("showInfoWindow", true);
|
||||
m_memoryUsage = static_cast<Types::LayoutsMemoryUsage>(m_universalGroup.readEntry("memoryUsage", (int)Types::SingleLayout));
|
||||
m_mouseSensitivity = static_cast<Types::MouseSensitivity>(m_universalGroup.readEntry("mouseSensitivity", (int)Types::HighSensitivity));
|
||||
|
||||
loadScalesConfig();
|
||||
}
|
||||
|
||||
void UniversalSettings::saveConfig()
|
||||
@ -445,4 +488,26 @@ QScreen *UniversalSettings::atScreens(QQmlListProperty<QScreen> *property, int i
|
||||
return qGuiApp->screens().at(index);
|
||||
}
|
||||
|
||||
void UniversalSettings::loadScalesConfig()
|
||||
{
|
||||
for (const auto &screenName : m_screenScalesGroup.keyList()) {
|
||||
QString scalesStr = m_screenScalesGroup.readEntry(screenName, QString());
|
||||
QStringList scales = scalesStr.split(";");
|
||||
if (scales.count() == 2) {
|
||||
m_screenScales[screenName] = qMakePair(scales[0].toFloat(), scales[1].toFloat());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UniversalSettings::saveScalesConfig()
|
||||
{
|
||||
for (const auto &screenName : m_screenScales.keys()) {
|
||||
QStringList scales;
|
||||
scales << QString::number(m_screenScales[screenName].first) << QString::number(m_screenScales[screenName].second);
|
||||
m_screenScalesGroup.writeEntry(screenName, scales.join(";"));
|
||||
}
|
||||
|
||||
m_screenScalesGroup.sync();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QObject>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QHash>
|
||||
#include <QPair>
|
||||
#include <QPointer>
|
||||
#include <QQmlListProperty>
|
||||
#include <QScreen>
|
||||
@ -38,8 +39,12 @@
|
||||
#include <KSharedConfig>
|
||||
|
||||
namespace Latte {
|
||||
|
||||
class LayoutManager;
|
||||
}
|
||||
|
||||
namespace Latte {
|
||||
//width_scale, height_scale
|
||||
typedef QPair<float, float> ScreenScales;
|
||||
|
||||
//! This class holds all the settings that are universally available
|
||||
//! independent of layouts
|
||||
@ -113,6 +118,10 @@ public slots:
|
||||
Q_INVOKABLE QString splitterIconPath();
|
||||
Q_INVOKABLE QString trademarkIconPath();
|
||||
|
||||
Q_INVOKABLE float screenWidthScale(QString screenName) const;
|
||||
Q_INVOKABLE float screenHeightScale(QString screenName) const;
|
||||
Q_INVOKABLE void setScreenScales(QString screenName, float widthScale, float heightScale);
|
||||
|
||||
signals:
|
||||
void autostartChanged();
|
||||
void canDisableBordersChanged();
|
||||
@ -125,13 +134,16 @@ signals:
|
||||
void layoutsMemoryUsageChanged();
|
||||
void metaPressAndHoldEnabledChanged();
|
||||
void mouseSensitivityChanged();
|
||||
void screenScalesChanged();
|
||||
void screenTrackerIntervalChanged();
|
||||
void showInfoWindowChanged();
|
||||
void versionChanged();
|
||||
|
||||
private slots:
|
||||
void loadConfig();
|
||||
void loadScalesConfig();
|
||||
void saveConfig();
|
||||
void saveScalesConfig();
|
||||
|
||||
private:
|
||||
void cleanupSettings();
|
||||
@ -163,8 +175,12 @@ private:
|
||||
Types::LayoutsMemoryUsage m_memoryUsage;
|
||||
Types::MouseSensitivity m_mouseSensitivity{Types::HighSensitivity};
|
||||
|
||||
//! ScreenName, <width_scale, height_scale>
|
||||
QHash<QString, ScreenScales> m_screenScales;
|
||||
|
||||
QPointer<Latte::Corona> m_corona;
|
||||
|
||||
KConfigGroup m_screenScalesGroup;
|
||||
KConfigGroup m_universalGroup;
|
||||
KSharedConfig::Ptr m_config;
|
||||
|
||||
|
@ -245,14 +245,6 @@
|
||||
<entry name="configurationSticker" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="windowWidthScale" type="Int">
|
||||
<default>100</default>
|
||||
<label>user set dock settings window width scale</label>
|
||||
</entry>
|
||||
<entry name="windowHeightScale" type="Int">
|
||||
<default>100</default>
|
||||
<label>user set dock settings window height scale</label>
|
||||
</entry>
|
||||
<!-- Animations -->
|
||||
<entry name="animationsEnabled" type="Bool">
|
||||
<default>true</default>
|
||||
|
@ -62,13 +62,13 @@ FocusScope {
|
||||
property int proposedWidth: 0.84 * proposedHeight + units.smallSpacing * 2
|
||||
property int proposedHeight: 36 * theme.mSize(theme.defaultFont).height
|
||||
|
||||
//! user set scales based on its preference, e.g. 96% of the proposed size
|
||||
property int userScaleWidth: plasmoid.configuration.windowWidthScale
|
||||
property int userScaleHeight: plasmoid.configuration.windowHeightScale
|
||||
|
||||
//! chosen size to be applied, if the user has set or not a different scale for the settings window
|
||||
property int chosenWidth: userScaleWidth !== 100 ? (userScaleWidth/100) * proposedWidth : proposedWidth
|
||||
property int chosenHeight: userScaleHeight !== 100 ? (userScaleHeight/100) * heightLevel * proposedHeight : heightLevel * proposedHeight
|
||||
property int chosenWidth: userScaleWidth !== 1 ? userScaleWidth * proposedWidth : proposedWidth
|
||||
property int chosenHeight: userScaleHeight !== 1 ? userScaleHeight * heightLevel * proposedHeight : heightLevel * proposedHeight
|
||||
|
||||
//! user set scales based on its preference, e.g. 96% of the proposed size
|
||||
property real userScaleWidth: 1
|
||||
property real userScaleHeight: 1
|
||||
|
||||
readonly property real heightLevel: (dialog.expertLevel ? 100 : 1)
|
||||
|
||||
@ -105,6 +105,20 @@ FocusScope {
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
updateScales();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: latteView.positioner
|
||||
onCurrentScreenNameChanged: dialog.updateScales();
|
||||
}
|
||||
|
||||
function updateScales() {
|
||||
userScaleWidth = universalSettings.screenWidthScale(latteView.positioner.currentScreenName);
|
||||
userScaleHeight = universalSettings.screenHeightScale(latteView.positioner.currentScreenName);
|
||||
}
|
||||
|
||||
PlasmaCore.FrameSvgItem{
|
||||
anchors.fill: parent
|
||||
imagePath: "dialogs/background"
|
||||
@ -117,8 +131,10 @@ FocusScope {
|
||||
hoverEnabled: true
|
||||
|
||||
property bool blockWheel: false
|
||||
property bool updatingWidthScale: false
|
||||
property bool updatingHeightScale: false
|
||||
property bool wheelTriggeredOnce: false
|
||||
property int scaleStep: 4
|
||||
property real scaleStep: 0.04
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (!containsMouse) {
|
||||
@ -127,10 +143,16 @@ FocusScope {
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
if (blockWheel || !(wheel.modifiers & Qt.MetaModifier)){
|
||||
var metaModifier = (wheel.modifiers & Qt.MetaModifier);
|
||||
var ctrlModifier = (wheel.modifiers & Qt.ControlModifier);
|
||||
|
||||
if (blockWheel || !(metaModifier || ctrlModifier)){
|
||||
return;
|
||||
}
|
||||
|
||||
updatingWidthScale = metaModifier || (dialog.expertLevel && ctrlModifier);
|
||||
updatingHeightScale = !dialog.expertLevel && ctrlModifier;
|
||||
|
||||
blockWheel = true;
|
||||
wheelTriggeredOnce = true;
|
||||
scrollDelayer.start();
|
||||
@ -139,13 +161,27 @@ FocusScope {
|
||||
|
||||
//positive direction
|
||||
if (angle > 12) {
|
||||
plasmoid.configuration.windowWidthScale = plasmoid.configuration.windowWidthScale + scaleStep;
|
||||
plasmoid.configuration.windowHeightScale = plasmoid.configuration.windowHeightScale + scaleStep;
|
||||
var scales;
|
||||
if (updatingWidthScale) {
|
||||
userScaleWidth = userScaleWidth + scaleStep;
|
||||
}
|
||||
|
||||
if (updatingHeightScale) {
|
||||
userScaleHeight = userScaleHeight + scaleStep;
|
||||
}
|
||||
|
||||
universalSettings.setScreenScales(latteView.positioner.currentScreenName, userScaleWidth, userScaleHeight);
|
||||
viewConfig.syncGeometry();
|
||||
//negative direction
|
||||
} else if (angle < -12) {
|
||||
plasmoid.configuration.windowWidthScale = plasmoid.configuration.windowWidthScale - scaleStep;
|
||||
plasmoid.configuration.windowHeightScale = plasmoid.configuration.windowHeightScale - scaleStep;
|
||||
if (updatingWidthScale) {
|
||||
userScaleWidth = userScaleWidth - scaleStep;
|
||||
}
|
||||
|
||||
if (updatingHeightScale) {
|
||||
userScaleHeight = userScaleHeight - scaleStep;
|
||||
}
|
||||
universalSettings.setScreenScales(latteView.positioner.currentScreenName, userScaleWidth, userScaleHeight);
|
||||
viewConfig.syncGeometry();
|
||||
}
|
||||
}
|
||||
@ -154,7 +190,9 @@ FocusScope {
|
||||
PlasmaComponents.Label{
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: i18nc("view settings window scale","Window scale at %0%").arg(userScaleWidth)
|
||||
text: backgroundMouseArea.updatingWidthScale ?
|
||||
i18nc("view settings width scale","Width scale at %0%").arg(userScaleWidth * 100) :
|
||||
i18nc("view settings height scale","Height scale at %0%").arg(userScaleHeight * 100)
|
||||
visible: backgroundMouseArea.containsMouse && backgroundMouseArea.wheelTriggeredOnce
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user