diff --git a/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml b/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml index c545464ba..b1247ab68 100644 --- a/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml +++ b/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml @@ -1,129 +1,129 @@ /* * Copyright 2015 Marco Martin * * This program 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, 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.4 import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import QtQuick.Controls 1.4 as QtQuickControls import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate pragma Singleton QtObject { id: unitsRoot /** * The fundamental unit of space that should be used for sizes, expressed in pixels. * Given the screen has an accurate DPI settings, it corresponds to a width of * the capital letter M */ property int gridUnit: fontMetrics.height /** * units.iconSizes provides access to platform-dependent icon sizing * * The icon sizes provided are normalized for different DPI, so icons * will scale depending on the DPI. * * Icon sizes from KIconLoader, adjusted to devicePixelRatio: * * small * * smallMedium * * medium * * large * * huge * * enormous * * Not devicePixelRation-adjusted:: * * desktop */ property QtObject iconSizes: QtObject { property int small: fontMetrics.roundedIconSize(16 * devicePixelRatio) property int smallMedium: fontMetrics.roundedIconSize(22 * devicePixelRatio) property int medium: fontMetrics.roundedIconSize(32 * devicePixelRatio) property int large: fontMetrics.roundedIconSize(48 * devicePixelRatio) property int huge: fontMetrics.roundedIconSize(64 * devicePixelRatio) property int enormous: 128 * devicePixelRatio } /** * units.smallSpacing is the amount of spacing that should be used around smaller UI elements, * for example as spacing in Columns. Internally, this size depends on the size of * the default font as rendered on the screen, so it takes user-configured font size and DPI * into account. */ property int smallSpacing: Math.floor(gridUnit/4) /** * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, * for example between an icon and the corresponding text. Internally, this size depends on * the size of the default font as rendered on the screen, so it takes user-configured font * size and DPI into account. */ - property int largeSpacing: Math.floor(gridUnit/2) + property int largeSpacing: smallSpacing * 2 /** * The ratio between physical and device-independent pixels. This value does not depend on the \ * size of the configured font. If you want to take font sizes into account when scaling elements, * use theme.mSize(theme.defaultFont), units.smallSpacing and units.largeSpacing. * The devicePixelRatio follows the definition of "device independent pixel" by Microsoft. */ property real devicePixelRatio: Math.max(1, (fontMetrics.font.pixelSize / fontMetrics.font.pointSize)) /** * units.longDuration should be used for longer, screen-covering animations, for opening and * closing of dialogs and other "not too small" animations */ property int longDuration: units.longDuration /** * units.shortDuration should be used for short animations, such as accentuating a UI event, * hover events, etc.. */ property int shortDuration: units.shortDuration readonly property QtObject __styleItem: QtQuickControlsPrivate.StyleItem {elementType: "frame" } /** * How much the mouse scroll wheel scrolls, expressed in lines of text. * Note: this is strictly for classical mouse wheels, touchpads 2 figer scrolling won't be affected */ readonly property int wheelScrollLines: __styleItem.styleHint("wheelScrollLines") property int toolTipDelay: 700 property variant fontMetrics: TextMetrics { text: "M" function roundedIconSize(size) { if (size < 16) { return size; } else if (size < 22) { return 16; } else if (size < 32) { return 22; } else if (size < 48) { return 32; } else if (size < 64) { return 48; } else { return size; } } } } diff --git a/src/declarativeimports/kirigamiplasmastyle/Units.qml b/src/declarativeimports/kirigamiplasmastyle/Units.qml index c240144c5..a5c9984c8 100644 --- a/src/declarativeimports/kirigamiplasmastyle/Units.qml +++ b/src/declarativeimports/kirigamiplasmastyle/Units.qml @@ -1,110 +1,110 @@ /* * Copyright 2015 Marco Martin * * This program 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, 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 Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ pragma Singleton import QtQuick 2.4 import org.kde.plasma.core 2.0 as PlasmaCore QtObject { /** * The fundamental unit of space that should be used for sizes, expressed in pixels. * Given the screen has an accurate DPI settings, it corresponds to a width of * the capital letter M */ property int gridUnit: units.gridUnit /** * units.iconSizes provides access to platform-dependent icon sizing * * The icon sizes provided are normalized for different DPI, so icons * will scale depending on the DPI. * * Icon sizes from KIconLoader, adjusted to devicePixelRatio: * * small * * smallMedium * * medium * * large * * huge * * enormous * * Not devicePixelRation-adjusted:: * * desktop */ property QtObject iconSizes: QtObject { property int small: units.iconSizes.small property int smallMedium: units.iconSizes.smallMedium property int medium: units.iconSizes.medium property int large: units.iconSizes.large property int huge: units.iconSizes.huge property int enormous: units.iconSizes.enormous } /** * units.smallSpacing is the amount of spacing that should be used around smaller UI elements, * for example as spacing in Columns. Internally, this size depends on the size of * the default font as rendered on the screen, so it takes user-configured font size and DPI * into account. */ property int smallSpacing: units.smallSpacing /** * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, * for example between an icon and the corresponding text. Internally, this size depends on * the size of the default font as rendered on the screen, so it takes user-configured font * size and DPI into account. */ - property int largeSpacing: units.largeSpacing + property int largeSpacing: smallSpacing * 2 /** * The ratio between physical and device-independent pixels. This value does not depend on the \ * size of the configured font. If you want to take font sizes into account when scaling elements, * use theme.mSize(theme.defaultFont), units.smallSpacing and units.largeSpacing. * The devicePixelRatio follows the definition of "device independent pixel" by Microsoft. */ property real devicePixelRatio: units.devicePixelRatio /** * units.longDuration should be used for longer, screen-covering animations, for opening and * closing of dialogs and other "not too small" animations */ property int longDuration: units.longDuration /** * units.shortDuration should be used for short animations, such as accentuating a UI event, * hover events, etc.. */ property int shortDuration: units.shortDuration /** * How much the mouse scroll wheel scrolls, expressed in lines of text. * Note: this is strictly for classical mouse wheels, touchpads 2 figer scrolling won't be affected */ property int wheelScrollLines: 3 property int toolTipDelay: 700 /** * metrics used by the default font */ property variant fontMetrics: TextMetrics { text: "M" } }