Commit 36e32279 authored by Ivan Čukić's avatar Ivan Čukić 👁

Add the option to show the current activity name and icon

Summary:
The current activity switching applet shows a generic icon that
opens the activity switcher which does not offer any information
on the current activity. This does not go well with other applets
like desktop pager.

This patch adds options (on by default) to show the current activity
icon and name in the applet.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28136
parent 5ef386a4
/*
* Copyright 2020 Ivan Čukić <ivan.cukic at kde.org>
*
* 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 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.0
import org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: i18n("Appearance")
icon: "activities"
source: "ConfigAppearance.qml"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="showActivityName" type="Bool">
<label>Show the current activity name</label>
<default>true</default>
</entry>
<entry name="showActivityIcon" type="Bool">
<label>Show the current activity icon instead of the applet icon</label>
<default>true</default>
</entry>
</group>
</kcfg>
/*
* Copyright 2020 Ivan Čukić <ivan.cukic at kde.org>
*
* 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 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.0
import QtQuick.Controls 2.5
import org.kde.kirigami 2.5 as Kirigami
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Kirigami.FormLayout {
anchors.left: parent.left
anchors.right: parent.right
property alias cfg_showActivityIcon: radioCurrentActivityIcon.checked
property alias cfg_showActivityName: checkShowActivityName.checked
property bool disableSetting: plasmoid.formFactor === PlasmaCore.Types.Vertical
Item { Kirigami.FormData.isSection: true }
RadioButton {
id: radioCurrentActivityIcon
Kirigami.FormData.label: i18n("Icon:")
enabled: !disableSetting
text: i18n("Show the current activity icon")
}
RadioButton {
id: radioGenericActivityIcon
enabled: !disableSetting
checked: !radioCurrentActivityIcon.checked
text: i18n("Show the generic activity icon")
}
Item { Kirigami.FormData.isSection: true }
CheckBox {
id: checkShowActivityName
Kirigami.FormData.label: i18n("Title:")
text: i18n("Show the current activity name")
}
}
/*
* Copyright 2012 Gregor Taetzner <gregor@freenet.de>
* Copyright 2020 Ivan Čukić <ivan.cukic at kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
......@@ -21,20 +22,32 @@ import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.activities 0.1 as Activities
MouseArea {
id: iconContainer
id: root
property string activeSource: "Status"
height: units.iconSizes.large
width: units.iconSizes.large
property bool showActivityName: plasmoid.configuration.showActivityName
property bool showActivityIcon: plasmoid.configuration.showActivityIcon
readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge
|| plasmoid.location === PlasmaCore.Types.RightEdge
|| plasmoid.location === PlasmaCore.Types.BottomEdge
|| plasmoid.location === PlasmaCore.Types.LeftEdge)
Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1
Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1
Layout.maximumWidth: Infinity
Layout.maximumHeight: Infinity
Layout.preferredWidth : icon.width + units.smallSpacing + (root.showActivityName ? name.implicitWidth : 0)
Layout.preferredHeight: inPanel ? units.iconSizeHints.panel : -1
Layout.minimumWidth: 0
Layout.minimumHeight: 0
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
......@@ -58,11 +71,35 @@ MouseArea {
icon: "activities"
}
Activities.ActivityInfo {
id: currentActivity
activityId: ":current"
}
PlasmaCore.IconItem {
id: icon
source: "activities"
width: parent.width
source: !root.showActivityIcon ? "activities" :
currentActivity.icon == "" ? "activities" :
currentActivity.icon
height: parent.height
width: height
}
PlasmaComponents.Label {
id: name
text: currentActivity.name
height: parent.height
width: implicitWidth
visible: root.showActivityName
anchors {
left: icon.right
leftMargin: units.smallSpacing
}
}
}
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