summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palaga <[email protected]>2017-02-28 23:27:23 +0900
committerEike Hein <[email protected]>2017-02-28 23:30:07 +0900
commit26b92df48a6a61acbe1a649167e9f03b159ab2a6 (patch)
treea22882bb575fef7f1cc592485124024fc10e1eb8
parentea7f36b46273084686ff4116bec15cb9d9b4c885 (diff)
Task Manager: Make the icon size configurable for task buttons in a vertical task manager
Summary: This improves the rendering when the task manager is oriented vertically. Before this change the taskbar had to be made too wide so that the task buttons show both icon and text. With the present change, the preferred icon size can be chosen via task bar configuration dialog so that text is shown also in narrower vertical task bars. Test Plan: 1. Place the task bar vertically 2. Adjust the task bar width e.g. so that the tray icons appear in rows of three 3. Open some windows a Dolphin window so that there is at least one task open in the task bar Before: The task buttons show only icons that stretch through the most of the button width. There is no text in the task button After: 1. Task Manager contect menu > Task Manager Settings... > Lower the icon size to Small Medium Hit OK 2. The task buttons are showing a bit smaller icons and there is some text shown there too. Reviewers: davidedmundson, hein, broulik Reviewed By: hein Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4550
-rw-r--r--applets/taskmanager/package/contents/code/layout.js30
-rw-r--r--applets/taskmanager/package/contents/config/main.xml12
-rw-r--r--applets/taskmanager/package/contents/ui/ConfigGeneral.qml33
-rw-r--r--applets/taskmanager/package/contents/ui/Task.qml2
4 files changed, 74 insertions, 3 deletions
diff --git a/applets/taskmanager/package/contents/code/layout.js b/applets/taskmanager/package/contents/code/layout.js
index dd702a5..7e67081 100644
--- a/applets/taskmanager/package/contents/code/layout.js
+++ b/applets/taskmanager/package/contents/code/layout.js
@@ -17,6 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
+var iconSizes = ["small", "smallMedium", "medium", "large", "huge", "enormous"];
+
function horizontalMargins() {
return taskFrame.margins.left + taskFrame.margins.right;
}
@@ -132,7 +134,33 @@ function preferredMinHeight() {
}
function preferredMaxHeight() {
- return verticalMargins() + Math.min(units.iconSizes.small * 3, theme.mSize(theme.defaultFont).height * 3);
+ if (tasks.vertical) {
+ return verticalMargins()
+ + Math.min(
+ // Do not allow the preferred icon size to exceed the width of the vertical task manager.
+ tasks.width,
+ Math.max(
+ // This assumes that we show some text and that we need some minimal vertical space for it.
+ // In reality, we do not always show the text. We show the text only if there
+ // is enough horizontal space for some hard coded amount of 'm' characters
+ // - see minimumMColumns() below.
+ // Hence in case the user prefers icons smaller than the height of his font,
+ // the font height will win even if the text will stay invisible.
+ // We leave it for the future developers to improve this expresssion if the
+ // named corner case turns out to be important.
+ units.iconSizes[iconSizes[plasmoid.configuration.iconSize]],
+ theme.mSize(theme.defaultFont).height
+ )
+ );
+ } else {
+ return verticalMargins() + Math.min(units.iconSizes.small * 3, theme.mSize(theme.defaultFont).height * 3);
+ }
+}
+
+// Returns the number of 'm' characters whose joint width must be available in the task button label
+// so that the button text is rendered at all.
+function minimumMColumns() {
+ return tasks.vertical ? 4 : 5;
}
function taskWidth() {
diff --git a/applets/taskmanager/package/contents/config/main.xml b/applets/taskmanager/package/contents/config/main.xml
index 4c0c7d1..8b35bfc 100644
--- a/applets/taskmanager/package/contents/config/main.xml
+++ b/applets/taskmanager/package/contents/config/main.xml
@@ -101,6 +101,18 @@
<label>The maximum number of text lines to show in a task button. 0 means no limit.</label>
<default>0</default>
</entry>
+ <entry name="iconSize" type="Enum">
+ <label>The preferred size of task button icons in a vertical task manager.</label>
+ <choices>
+ <choice name="small"/>
+ <choice name="smallMedium"/>
+ <choice name="medium"/>
+ <choice name="large"/>
+ <choice name="huge"/>
+ <choice name="enormous"/>
+ </choices>
+ <default>3</default>
+ </entry>
</group>
</kcfg>
diff --git a/applets/taskmanager/package/contents/ui/ConfigGeneral.qml b/applets/taskmanager/package/contents/ui/ConfigGeneral.qml
index 1a590f8..dce2225 100644
--- a/applets/taskmanager/package/contents/ui/ConfigGeneral.qml
+++ b/applets/taskmanager/package/contents/ui/ConfigGeneral.qml
@@ -32,6 +32,7 @@ Item {
readonly property bool plasmaPaAvailable: Qt.createComponent("PulseAudio.qml").status === Component.Ready
property alias cfg_forceStripes: forceStripes.checked
+ property alias cfg_iconSize: iconSize.value
property alias cfg_showToolTips: showToolTips.checked
property alias cfg_wheelEnabled: wheelEnabled.checked
property alias cfg_highlightWindows: highlightWindows.checked
@@ -58,7 +59,7 @@ Item {
flat: true
GridLayout {
- columns: 2
+ columns: 4
Layout.fillWidth: true
Label {
@@ -68,6 +69,7 @@ Item {
SpinBox {
id: maxStripes
minimumValue: 1
+ Layout.columnSpan: 3
}
CheckBox {
@@ -76,7 +78,36 @@ Item {
Layout.row: 1
text: vertical ? i18n("Always arrange tasks in rows of as many columns") : i18n("Always arrange tasks in columns of as many rows")
enabled: maxStripes.value > 1
+ Layout.columnSpan: 3
}
+
+ Label {
+ visible: vertical
+ text: i18n("Icon size:")
+ }
+
+ Label {
+ visible: vertical
+ text: i18n("Small")
+ }
+
+ Slider {
+ Layout.fillWidth: true
+ visible: vertical
+ id: iconSize
+
+ minimumValue: 0
+ maximumValue: 5
+ stepSize: 1
+
+ tickmarksEnabled: true
+ }
+
+ Label {
+ visible: vertical
+ text: i18n("Large")
+ }
+
}
}
diff --git a/applets/taskmanager/package/contents/ui/Task.qml b/applets/taskmanager/package/contents/ui/Task.qml
index fdc7392..4484ced 100644
--- a/applets/taskmanager/package/contents/ui/Task.qml
+++ b/applets/taskmanager/package/contents/ui/Task.qml
@@ -474,7 +474,7 @@ MouseArea {
id: label
visible: (inPopup || !iconsOnly && model.IsLauncher !== true
- && (parent.width - iconBox.height - units.smallSpacing) >= (theme.mSize(theme.defaultFont).width * 5))
+ && (parent.width - iconBox.height - units.smallSpacing) >= (theme.mSize(theme.defaultFont).width * LayoutManager.minimumMColumns()))
anchors {
fill: parent