added all files

This commit is contained in:
RustyRaptor committed 2018-08-04 13:49:17 -06:00
1 parent 6a876678bd
commit 2db72ce25b
144 files changed
+10244

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
/***************************************************************************
* Copyright (C) 2013 by Eike Hein <hein@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, 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 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("General")
icon: "preferences-system-windows"
source: "config/ConfigGeneral.qml"
}
ConfigCategory {
name: i18n("Advanced")
icon: "applications-development"
source: "lib/ConfigAdvanced.qml"
visible: false
}
}
Binary file not shown.
+113
View File
@@ -0,0 +1,113 @@
<?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="favoriteApps" type="StringList">
<label>List of general favorites. Supported values are menu id's (usually .desktop file names), special URLs that expand into default applications (e.g. preferred://browser), document URLs and KPeople contact URIs.</label>
<default>preferred://browser,kontact.desktop,systemsettings.desktop,org.kde.dolphin.desktop,ktp-contactlist.desktop,org.kde.kate.desktop,org.kde.discover</default>
</entry>
<entry name="width" type="int">
<default>0</default> <!-- serialized in pixels in older versions unfortunately -->
</entry>
<entry name="height" type="int">
<default>0</default> <!-- serialized in pixels in older versions unfortunately -->
</entry>
<entry name="fullscreen" type="bool">
<default>false</default>
</entry>
<entry name="icon" type="String">
<label>The name of the icon used in the compact representation (e.g. on a small panel).</label>
<default>start-here-kde</default>
</entry>
<entry name="fixedPanelIcon" type="bool">
<default>true</default>
</entry>
<entry name="searchResultsMerged" type="bool">
<default>true</default>
</entry>
<entry name="searchResultsCustomSort" type="bool">
<default>false</default>
</entry>
<entry name="searchResultsReversed" type="bool">
<default>false</default>
</entry>
<entry name="showRecentApps" type="bool">
<label>Whether to show the "Recent Applications" category.</label>
<default>true</default>
</entry>
<entry name="sidebarShortcuts" type="StringList">
<label>Same as favoriteApps except "xdg:DOCUMENTS", etc are constants to ~/Documents.</label>
<default>xdg:DOCUMENTS,xdg:PICTURES,org.kde.dolphin.desktop,systemsettings.desktop</default>
</entry>
<entry name="defaultAppListOrder" type="string">
<!-- enum: alphabetical, categories -->
<default>alphabetical</default>
</entry>
<!-- Base64 encoded JSON -->
<entry name="tileData" type="string" stringType="base64json">
<!-- Schema: { "konsole.desktop": { size: "1x1", x: 3, y: 0, label: "Terminal" }, ...} -->
<default></default>
</entry>
<entry name="tileModel" type="string" stringType="base64json">
<!-- Schema: [{ url: "konsole.desktop", x: 3, y: 0, w: 2, h: 2, label: "Terminal" }, ...] -->
<!-- For Testing: W3siaCI6MiwidXJsIjoib3JnLmtkZS5hcmsuZGVza3RvcCIsInciOjIsIngiOjQsInkiOjB9LHsiaCI6NCwidXJsIjoib3JnLmtkZS5kaXNjb3Zlci5kZXNrdG9wIiwidyI6NCwieCI6MCwieSI6MH0seyJoIjoyLCJ1cmwiOiJvcmcua2RlLmRvbHBoaW4uZGVza3RvcCIsInciOjIsIngiOjQsInkiOjJ9LHsiaCI6MiwidXJsIjoib3JnLmtkZS5rc3lzZ3VhcmQuZGVza3RvcCIsInciOjQsIngiOjAsInkiOjR9LHsiaCI6MSwidXJsIjoib3JnLmtkZS5rb25zb2xlLmRlc2t0b3AiLCJ3IjoyLCJ4IjowLCJ5Ijo2fSx7ImgiOjEsInVybCI6Im9yZy5rZGUua2F0ZS5kZXNrdG9wIiwidyI6MSwieCI6MywieSI6Nn0seyJoIjozLCJ1cmwiOiJmaXJlZm94LmRlc2t0b3AiLCJ3IjoxLCJ4Ijo0LCJ5Ijo0fV0= -->
<default></default>
</entry>
<entry name="tileScale" type="double">
<default>0.8</default>
</entry>
<entry name="tileMargin" type="double">
<default>5</default>
</entry>
<entry name="tilesLocked" type="bool">
<default>false</default>
</entry>
<!-- Colors -->
<!-- Use empty string instead of color type so that we can use default colors from the color scheme. -->
<entry name="defaultTileColor" type="string">
<default></default>
</entry>
<entry name="sidebarBackgroundColor" type="string">
<default></default>
</entry>
<!-- Style -->
<entry name="searchFieldFollowsTheme" type="bool">
<default>false</default>
</entry>
<entry name="sidebarFollowsTheme" type="bool">
<default>false</default>
</entry>
<entry name="tileLabelAlignment" type="string">
<!-- enum: left, center, right -->
<default>left</default>
</entry>
<entry name="appDescription" type="string">
<!-- enum: hidden, after, below -->
<default>after</default>
</entry>
<entry name="menuItemHeight" type="int">
<default>36</default>
</entry>
<entry name="searchFieldHeight" type="int">
<default>50</default>
</entry>
<entry name="appListWidth" type="int">
<default>350</default>
</entry>
<entry name="favGridCols" type="int">
<default>6</default>
</entry>
<entry name="popupHeight" type="int">
<default>620</default>
</entry>
</group>
</kcfg>
+148
View File
@@ -0,0 +1,148 @@
// Based off kicker's ActionMenu
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
id: root
property QtObject menu
property Item visualParent
property bool opened: menu ? (menu.status != PlasmaComponents.DialogStatus.Closed) : false
property int tileIndex: -1
signal closed
signal populateMenu(var menu)
onOpenedChanged: {
if (!opened) {
closed()
}
}
onClosed: destroyMenu()
function open(x, y) {
refreshMenu()
if (menu.content.length === 0) {
return;
}
if (x && y) {
menu.open(x, y);
} else {
menu.open();
}
}
function destroyMenu() {
if (menu) {
menu.destroy()
// menu = null // Don't null here. Binding loop: onOpended=false => closed() => destroyMenu() => menu=null => opened=false
logger.debug('AppContextMenu.destroyMenu', menu)
}
}
function refreshMenu() {
destroyMenu()
menu = contextMenuComponent.createObject(root);
populateMenu(menu)
}
Component {
id: contextMenuComponent
PlasmaComponents.ContextMenu {
id: contextMenu
visualParent: root.visualParent
function newSeperator() {
return Qt.createQmlObject("import org.kde.plasma.components 2.0 as PlasmaComponents; PlasmaComponents.MenuItem { separator: true }", contextMenu);
}
function newMenuItem() {
return Qt.createQmlObject("import org.kde.plasma.components 2.0 as PlasmaComponents; PlasmaComponents.MenuItem {}", contextMenu);
}
function addPinToMenuAction(favoriteId) {
var menuItem = menu.newMenuItem();
if (tileGrid.hasAppTile(favoriteId)) {
menuItem.text = i18n("Unpin from Menu")
menuItem.icon = "list-remove"
menuItem.clicked.connect(function() {
if (root.tileIndex >= 0) {
tileGrid.removeIndex(root.tileIndex)
} else {
tileGrid.removeApp(favoriteId)
}
})
} else {
menuItem.text = i18n("Pin to Menu")
menuItem.icon = "bookmark-new"
menuItem.clicked.connect(function() {
tileGrid.addApp(favoriteId)
})
}
menu.addMenuItem(menuItem)
}
// // https://github.com/KDE/plasma-desktop/blob/master/applets/taskmanager/package/contents/ui/ContextMenu.qml#L75
function addActionList(actionList, listModel, index) {
// .desktop file Exec actions
// ------
// Pin to Taskbar / Desktop / Panel
// ------
// Recent Documents
// ------
// ...
// ------
// Edit Application
actionList.forEach(function(actionItem) {
// console.log(index, actionItem.actionId, actionItem.actionArgument, actionItem.text)
var menuItem = menu.newMenuItem()
menuItem.text = actionItem.text ? actionItem.text : ""
menuItem.enabled = actionItem.type != "title" && ("enabled" in actionItem ? actionItem.enabled : true)
menuItem.separator = actionItem.type == "separator"
menuItem.section = actionItem.type == "title"
menuItem.icon = actionItem.icon ? actionItem.icon : null
menuItem.clicked.connect(function() {
listModel.triggerIndexAction(index, actionItem.actionId, actionItem.actionArgument)
});
//--- Overrides
if (actionItem.actionId == 'addToDesktop') {
// Remove (user should just drag it)
menu.removeMenuItem(menuItem)
} else if (actionItem.actionId == 'addToPanel') {
// Remove (user should just drag it)
// User usually means to add it to taskmanager anyways.
menu.removeMenuItem(menuItem)
} else if (actionItem.actionId == 'addToTaskManager') {
menuItem.text = i18n("Pin to Taskbar")
menuItem.icon = "bookmark-new"
} else if (actionItem.actionId == 'editApplication') {
// menuItem.text = i18n("Properties")
}
});
}
}
}
Component {
id: contextMenuItemComponent
PlasmaComponents.MenuItem {
property variant actionItem
text: actionItem.text ? actionItem.text : ""
enabled: actionItem.type != "title" && ("enabled" in actionItem ? actionItem.enabled : true)
separator: actionItem.type == "separator"
section: actionItem.type == "title"
icon: actionItem.icon ? actionItem.icon : null
onClicked: {
actionClicked(actionItem.actionId, actionItem.actionArgument);
}
}
}
}
Binary file not shown.
+50
View File
@@ -0,0 +1,50 @@
import QtQuick 2.0
QtObject {
property var tile: null
readonly property bool isGroup: tile && tile.tileType == "group"
readonly property bool isLauncher: !isGroup
readonly property color defaultBackgroundColor: isGroup ? "transparent" : config.defaultTileColor
readonly property bool defaultShowIcon: isGroup ? false : true
readonly property int defaultTileW: isGroup ? 6 : 2
readonly property int defaultTileH: isGroup ? 1 : 2
readonly property string favoriteId: tile && tile.url || ''
readonly property var app: favoriteId ? appsModel.tileGridModel.getApp(favoriteId) : null
readonly property string appLabel: app ? app.display : ""
readonly property string appUrl: app ? app.url : ""
readonly property var appIcon: app ? app.decoration : null
readonly property string labelText: tile && tile.label || appLabel || appUrl || ""
readonly property var iconSource: tile && tile.icon || appIcon
readonly property bool iconFill: tile && typeof tile.iconFill !== "undefined" ? tile.iconFill : false
readonly property bool showIcon: tile && typeof tile.showIcon !== "undefined" ? tile.showIcon : defaultShowIcon
readonly property bool showLabel: tile && typeof tile.showLabel !== "undefined" ? tile.showLabel : true
readonly property color backgroundColor: tile && typeof tile.backgroundColor !== "undefined" ? tile.backgroundColor : defaultBackgroundColor
readonly property string backgroundImage: tile && typeof tile.backgroundImage !== "undefined" ? tile.backgroundImage : ""
readonly property int tileX: tile && typeof tile.x !== "undefined" ? tile.x : 0
readonly property int tileY: tile && typeof tile.y !== "undefined" ? tile.y : 0
readonly property int tileW: tile && typeof tile.w !== "undefined" ? tile.w : defaultTileW
readonly property int tileH: tile && typeof tile.h !== "undefined" ? tile.h : defaultTileH
// onTileChanged: console.log('onTileChanged', JSON.stringify(tile))
// onAppLabelChanged: console.log('onAppLabelChanged', appLabel)
function hasActionList() {
return app ? appsModel.tileGridModel.indexHasActionList(app.indexInModel) : false
}
function getActionList() {
return app ? appsModel.tileGridModel.getActionListAtIndex(app.indexInModel) : []
}
function addActionList(menu) {
if (hasActionList()) {
var actionList = getActionList()
menu.addActionList(actionList, appsModel.tileGridModel, appObj.app.indexInModel)
}
}
}
Binary file not shown.
+84
View File
@@ -0,0 +1,84 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate
MouseArea {
id: control
hoverEnabled: true
property alias hovered: control.containsMouse
property string iconName: ""
property string text: ""
property string tooltip: ""
property font font: theme.defaultFont
property alias iconSource: control.iconName
property real minimumWidth: 0
property real minimumHeight: 0
property bool flat: true
Loader {
id: styleLoader
anchors.fill: parent
asynchronous: true
// source: "AppToolButtonStyle.qml"
source: "HoverOutlineButtonStyle.qml"
property var control: control
readonly property int paddingTop: item ? item.paddingTop : 0
readonly property int paddingLeft: item ? item.paddingLeft : 0
readonly property int paddingRight: item ? item.paddingRight : 0
readonly property int paddingBottom: item ? item.paddingBottom : 0
}
Item {
// id: buttonArea
anchors.fill: parent
anchors.topMargin: styleLoader.paddingTop
anchors.leftMargin: styleLoader.paddingLeft
anchors.rightMargin: styleLoader.paddingRight
anchors.bottomMargin: styleLoader.paddingBottom
RowLayout {
id: buttonContent
anchors.fill: parent
spacing: units.smallSpacing
Layout.preferredHeight: Math.max(units.iconSizes.small, label.implicitHeight)
PlasmaCore.IconItem {
id: icon
source: control.iconName || control.iconSource
implicitHeight: label.implicitHeight
implicitWidth: implicitHeight
Layout.minimumWidth: valid ? parent.height: 0
Layout.maximumWidth: Layout.minimumWidth
visible: valid
Layout.minimumHeight: Layout.minimumWidth
Layout.maximumHeight: Layout.minimumWidth
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
active: control.containsMouse
colorGroup: control.containsMouse ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup
}
PlasmaComponents.Label {
id: label
Layout.minimumWidth: implicitWidth
text: QtQuickControlsPrivate.StyleHelpers.stylizeMnemonics(control.text)
font: control.font || theme.defaultFont
visible: control.text != ""
Layout.fillWidth: true
height: parent.height
color: control.containsMouse ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
}
Binary file not shown.
+90
View File
@@ -0,0 +1,90 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
id: style
property int paddingTop: surfaceNormal.margins.top
property int paddingLeft: surfaceNormal.margins.left
property int paddingRight: surfaceNormal.margins.right
property int paddingBottom: surfaceNormal.margins.bottom
ButtonShadow {
id: shadow
visible: control.activeFocus
anchors.fill: parent
enabledBorders: surfaceNormal.enabledBorders
state: {
if (control.pressed) {
return "hidden"
} else if (control.containsMouse) {
return "hover"
} else if (control.activeFocus) {
return "focus"
} else {
return "shadow"
}
}
}
PlasmaCore.FrameSvgItem {
id: surfaceNormal
anchors.fill: parent
imagePath: "widgets/button"
prefix: "normal"
enabledBorders: "AllBorders"
}
PlasmaCore.FrameSvgItem {
id: surfacePressed
anchors.fill: parent
imagePath: "widgets/button"
prefix: "pressed"
enabledBorders: surfaceNormal.enabledBorders
opacity: 0
}
state: (control.pressed || control.checked ? "pressed" : (control.containsMouse ? "hover" : "normal"))
states: [
State { name: "normal"
PropertyChanges {
target: surfaceNormal
opacity: 0
}
PropertyChanges {
target: surfacePressed
opacity: 0
}
},
State { name: "hover"
PropertyChanges {
target: surfaceNormal
opacity: 1
}
PropertyChanges {
target: surfacePressed
opacity: 0
}
},
State { name: "pressed"
PropertyChanges {
target: surfaceNormal
opacity: 0
}
PropertyChanges {
target: surfacePressed
opacity: 1
}
}
]
transitions: [
Transition {
//Cross fade from pressed to normal
ParallelAnimation {
NumberAnimation { target: surfaceNormal; property: "opacity"; duration: 100 }
NumberAnimation { target: surfacePressed; property: "opacity"; duration: 100 }
}
}
]
}
+137
View File
@@ -0,0 +1,137 @@
import QtQuick 2.0
import QtQuick.Window 2.2
Item {
function setAlpha(c, a) {
var c2 = Qt.darker(c, 1)
c2.a = a
return c2
}
//--- Sizes
readonly property int panelIconSize: 24 * units.devicePixelRatio
readonly property int flatButtonSize: 60 * units.devicePixelRatio
readonly property int flatButtonIconSize: 30 * units.devicePixelRatio
readonly property int sidebarWidth: flatButtonSize
readonly property int sidebarOpenWidth: 200 * units.devicePixelRatio
readonly property int appListWidth: plasmoid.configuration.appListWidth * units.devicePixelRatio
readonly property int leftSectionWidth: sidebarWidth + appListWidth
readonly property real tileScale: plasmoid.configuration.tileScale
readonly property int cellBoxUnits: 80
readonly property int cellMarginUnits: plasmoid.configuration.tileMargin
readonly property int cellSizeUnits: cellBoxUnits - cellMarginUnits*2
readonly property int cellSize: cellSizeUnits * tileScale * units.devicePixelRatio
readonly property real cellMargin: cellMarginUnits * tileScale * units.devicePixelRatio
readonly property real cellPushedMargin: cellMargin * 2
readonly property int cellBoxSize: cellMargin + cellSize + cellMargin
readonly property int tileGridWidth: plasmoid.configuration.favGridCols * cellBoxSize
readonly property int favCellWidth: 60 * units.devicePixelRatio
readonly property int favCellPushedMargin: 5 * units.devicePixelRatio
readonly property int favCellPadding: 3 * units.devicePixelRatio
readonly property int favColWidth: ((favCellWidth + favCellPadding * 2) * 2) // = 132 (Medium Size)
readonly property int favViewDefaultWidth: (favColWidth * 3) * units.devicePixelRatio
readonly property int favSmallIconSize: 32 * units.devicePixelRatio
readonly property int favMediumIconSize: 72 * units.devicePixelRatio
readonly property int favGridWidth: (plasmoid.configuration.favGridCols/2) * favColWidth
readonly property int searchFieldHeight: plasmoid.configuration.searchFieldHeight * units.devicePixelRatio
readonly property int popupWidth: {
if (plasmoid.configuration.fullscreen) {
return Screen.desktopAvailableWidth
} else {
return leftSectionWidth + tileGridWidth
}
}
readonly property int popupHeight: {
if (plasmoid.configuration.fullscreen) {
return Screen.desktopAvailableHeight
} else {
return plasmoid.configuration.popupHeight * units.devicePixelRatio
}
}
readonly property int menuItemHeight: plasmoid.configuration.menuItemHeight * units.devicePixelRatio
readonly property int searchFilterRowHeight: {
if (plasmoid.configuration.appListWidth >= 310) {
return flatButtonSize // 60px
} else if (plasmoid.configuration.appListWidth >= 250) {
return flatButtonSize*3/4 // 45px
} else {
return flatButtonSize/2 // 30px
}
}
//--- Colors
readonly property color defaultTileColor: plasmoid.configuration.defaultTileColor || theme.buttonBackgroundColor
readonly property color sidebarBackgroundColor: plasmoid.configuration.sidebarBackgroundColor || theme.backgroundColor
readonly property color menuItemTextColor2: setAlpha(theme.textColor, 0.6)
readonly property color favHoverOutlineColor: setAlpha(theme.textColor, 0.8)
//--- Style
// Tiles
readonly property int tileLabelAlignment: {
var val = plasmoid.configuration.tileLabelAlignment
if (val === 'center') {
return Text.AlignHCenter
} else if (val === 'right') {
return Text.AlignRight
} else { // left
return Text.AlignLeft
}
}
// App Description Enum (hidden, after, below)
readonly property bool appDescriptionVisible: plasmoid.configuration.appDescription !== 'hidden'
readonly property bool appDescriptionBelow: plasmoid.configuration.appDescription == 'below'
//--- Settings
// Search
readonly property bool searchResultsMerged: plasmoid.configuration.searchResultsMerged
readonly property bool searchResultsCustomSort: plasmoid.configuration.searchResultsCustomSort
readonly property int searchResultsDirection: plasmoid.configuration.searchResultsReversed ? ListView.BottomToTop : ListView.TopToBottom
//--- Tile Data
property var tileData: Base64JsonString {
configKey: 'tileData'
}
property var tileModel: Base64JsonString {
configKey: 'tileModel'
defaultValue: []
onLoaded: {
// Only load on change at start.
// Otherwise .save() will create a new [] breaking the tile editor.
loadOnConfigChange = false
}
// defaultValue: [
// {
// "x": 0,
// "y": 0,
// "w": 2,
// "h": 2,
// "url": "org.kde.dolphin.desktop",
// "label": "Files",
// },
// {
// "x": 2,
// "y": 1,
// "w": 1,
// "h": 1,
// "url": "virtualbox.desktop",
// "iconFill": true,
// },
// {
// "x": 2,
// "y": 0,
// "w": 1,
// "h": 1,
// "url": "org.kde.ark.desktop",
// },
// ]
}
}
Binary file not shown.
+499
View File
@@ -0,0 +1,499 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.private.kicker 0.1 as Kicker
Item {
id: appsModel
property alias rootModel: rootModel
property alias allAppsModel: allAppsModel
property alias powerActionsModel: powerActionsModel
property alias favoritesModel: favoritesModel
property alias tileGridModel: tileGridModel
property alias sidebarModel: sidebarModel
property string order: plasmoid.configuration.defaultAppListOrder
onOrderChanged: allAppsModel.refresh()
signal refreshing()
signal refreshed()
Timer {
id: rootModelRefresh
interval: 400
onTriggered: {
logger.debug('rootModel.refresh.star', Date.now())
rootModel.refresh()
logger.debug('rootModel.refresh.done', Date.now())
}
}
Kicker.RootModel {
id: rootModel
appNameFormat: 0 // plasmoid.configuration.appNameFormat
flat: true // isDash ? true : plasmoid.configuration.limitDepth
showSeparators: false // !isDash
appletInterface: plasmoid
// showAllSubtree: true //isDash (KDE 5.8 and below)
showAllApps: true //isDash (KDE 5.9+)
showRecentApps: true //plasmoid.configuration.showRecentApps
showRecentDocs: false //plasmoid.configuration.showRecentDocs
showRecentContacts: false //plasmoid.configuration.showRecentContacts
autoPopulate: false // (KDE 5.9+) defaulted to true
// paginate: false // (KDE 5.9+)
Component.onCompleted: {
if (!autoPopulate) {
rootModelRefresh.restart()
// console.log('rootModel.refresh.star', Date.now())
// rootModel.refresh()
// console.log('rootModel.refresh.done', Date.now())
}
}
function log() {
// logListModel('rootModel', rootModel);
var listModel = rootModel;
for (var i = 0; i < listModel.count; i++) {
var item = listModel.modelForRow(i);
// console.log(listModel, i, item);
logObj('rootModel[' + i + ']', item)
// logListModel('rootModel[' + i + ']', item);
}
}
onCountChanged: {
// for (var i = 0; i < rootModel.count; i++) {
// var listModel = rootModel.modelForRow(i);
// if (listModel.description == 'KICKER_ALL_MODEL') {
// logObj('rootModel[' + i + ']', listModel)
// appsModel.allAppsList = listModel;
// appsModel.refreshed()
// }
// }
debouncedRefresh.restart()
}
onRefreshed: {
//--- Power
var systemModel = rootModel.modelForRow(rootModel.count - 1)
var systemList = []
if (systemModel) {
powerActionsModel.parseModel(systemList, systemModel)
} else {
console.log('systemModel is null')
}
powerActionsModel.list = systemList
sessionActionsModel.parseSourceModel(powerActionsModel)
debouncedRefresh.restart()
}
// KickerAppModel is a wrapper of Kicker.FavoritesModel
// Kicker.FavoritesModel must be a child object of RootModel.
// appEntry.actions() looks at the parent object for parent.appletInterface and will crash plasma if it can't find it.
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/appentry.cpp#L151
favoritesModel: KickerAppModel {
id: favoritesModel
Component.onCompleted: {
// favorites = 'systemsettings.desktop,sublime-text.desktop,clementine.desktop,hexchat.desktop,virtualbox.desktop'.split(',')
favorites = plasmoid.configuration.favoriteApps
}
onFavoritesChanged: {
plasmoid.configuration.favoriteApps = favorites
}
}
property var tileGridModel: KickerAppModel {
id: tileGridModel
}
property var sidebarModel: KickerAppModel {
id: sidebarModel
Component.onCompleted: {
favorites = plasmoid.configuration.sidebarShortcuts
}
onFavoritesChanged: {
plasmoid.configuration.sidebarShortcuts = favorites
}
property Connections configConnection: Connections {
target: plasmoid.configuration
onSidebarShortcutsChanged: sidebarModel.favorites = plasmoid.configuration.sidebarShortcuts
}
}
property var openModel: Kicker.FavoritesModel {
id: openModel
onFavoritesChanged: {
if (count > 0) {
openModel.trigger(0, "", null)
}
}
}
}
Connections {
target: plasmoid.configuration
onFavoriteAppsChanged: {
if (favoritesModel.favorites != plasmoid.configuration.favoriteApps) {
favoritesModel.favorites = plasmoid.configuration.favoriteApps
}
}
}
Item {
//--- Detect Changes
// Changes aren't bubbled up to the RootModel, so we need to detect changes somehow.
// Recent Apps
Repeater {
model: rootModel.count >= 0 ? rootModel.modelForRow(0) : []
Item {
Component.onCompleted: {
// console.log('debouncedRefreshRecentApps', index)
if (plasmoid.configuration.showRecentApps) {
debouncedRefreshRecentApps.restart()
}
}
}
}
// All Apps
Repeater { // A-Z
model: rootModel.count >= 2 ? rootModel.modelForRow(1) : []
Item {
property var parentModel: rootModel.modelForRow(1).modelForRow(index)
Repeater { // Aaa ... Azz (Apps)
model: parentModel.hasChildren ? parentModel : []
Item {
Component.onCompleted: {
// console.log('depth2', index, display, model)
debouncedRefresh.restart()
}
}
}
// Component.onCompleted: {
// console.log('depth1', index, display, model)
// }
}
}
Timer {
id: debouncedRefresh
interval: 100
onTriggered: allAppsModel.refresh()
}
Timer {
id: debouncedRefreshRecentApps
interval: debouncedRefresh.interval
onTriggered: allAppsModel.refreshRecentApps()
}
Connections {
target: plasmoid.configuration
onShowRecentAppsChanged: debouncedRefresh.restart()
}
}
KickerListModel {
id: powerActionsModel
onItemTriggered: {
// console.log('powerActionsModel.onItemTriggered')
plasmoid.expanded = false
}
function nameByIconName(iconName) {
var item = getByValue('iconName', iconName)
if (item) {
return item.name
} else {
return iconName
}
}
function triggerByIconName(iconName) {
var item = getByValue('iconName', iconName)
item.parentModel.trigger(item.indexInParent, "", null)
}
}
// powerActionsModel filtered to logout/lock/switch user
property alias sessionActionsModel: sessionActionsModel
KickerListModel {
id: sessionActionsModel
onItemTriggered: {
// console.log('sessionActionsModel.onItemTriggered')
plasmoid.expanded = false
}
function parseSourceModel(powerActionsModel) {
// Filter by iconName
var sessionActionsList = []
var sessionIconNames = ['system-lock-screen', 'system-log-out', 'system-save-session', 'system-switch-user']
for (var i = 0; i < powerActionsModel.list.length; i++) {
var item = powerActionsModel.list[i];
// console.log(item, item.iconName, sessionIconNames.indexOf(item.iconName) >= 0)
if (sessionIconNames.indexOf(item.iconName) >= 0) {
sessionActionsList.push(item)
}
}
sessionActionsModel.list = sessionActionsList
}
}
KickerListModel {
id: allAppsModel
onItemTriggered: {
// console.log('allAppsModel.onItemTriggered')
plasmoid.expanded = false
}
function getRecentApps() {
var recentAppList = [];
//--- populate
var model = rootModel.modelForRow(0)
if (model) {
parseModel(recentAppList, model)
} else {
console.log('getRecentApps() recent apps model is null')
}
//--- filter
recentAppList = recentAppList.filter(function(item){
//--- filter kcmshell5 applications since they show up blank (undefined)
if (typeof item.name === 'undefined') {
return false;
} else {
return true;
}
});
//--- first 5 items
recentAppList = recentAppList.slice(0, 5);
//--- section
for (var i = 0; i < recentAppList.length; i++) {
var item = recentAppList[i];
item.sectionKey = i18n('Recent Apps');
}
return recentAppList;
}
function refreshRecentApps() {
// console.log('refreshRecentApps')
if (debouncedRefresh.running) {
// We're about to do a full refresh so don't bother doing a partial update.
return
}
var recentAppList = getRecentApps();
var recentAppCount = 5
if (recentAppCount == recentAppList.length) {
// Do a partial update since we're only updating properties.
refreshing()
// Overwrite the exisiting items.
for (var i = 0; i < recentAppList.length; i++) {
var item = recentAppList[i]
list[i] = item
set(i, item)
}
refreshed()
} else {
// We'll be removing items, so just replace the entire list.
refresh()
}
}
property int categoryStartIndex: 2 // Skip Recent Apps, All Apps
property int categoryEndIndex: rootModel.count - 1 // Skip Power
function getCategory(rootIndex) {
var modelIndex = rootModel.index(rootIndex, 0)
var categoryLabel = rootModel.data(modelIndex, Qt.DisplayRole)
var categoryModel = rootModel.modelForRow(rootIndex)
var appList = []
if (categoryModel) {
parseModel(appList, categoryModel)
} else {
console.log('allAppsModel.getCategory', rootIndex, categoryModel, 'is null')
}
for (var i = 0; i < appList.length; i++) {
var item = appList[i];
item.sectionKey = categoryLabel
}
return appList
}
function getAllCategories() {
var appList = [];
for (var i = categoryStartIndex; i < categoryEndIndex; i++) { // Skip Recent Apps, All Apps, ... and Power
// for (var i = 0; i < rootModel.count; i++) {
appList = appList.concat(getCategory(i))
}
return appList
}
function getAllApps() {
//--- populate list
var appList = [];
var model = rootModel.modelForRow(1)
if (model) {
parseModel(appList, model)
} else {
console.log('getAllApps() all apps model is null')
}
//--- filter
// var powerActionsList = [];
// var sceneUrls = [];
// appList = appList.filter(function(item){
// //--- filter multiples
// if (item.url) {
// if (sceneUrls.indexOf(item.url) >= 0) {
// return false;
// } else {
// sceneUrls.push(item.url);
// return true;
// }
// } else {
// return true;
// //--- filter
// // if (item.parentModel.toString().indexOf('SystemModel') >= 0) {
// // // console.log(item.description, 'removed');
// // powerActionsList.push(item);
// // return false;
// // } else {
// // return true;
// // }
// }
// });
// powerActionsModel.list = powerActionsList;
//---
for (var i = 0; i < appList.length; i++) {
var item = appList[i];
if (item.name) {
var firstCharCode = item.name.charCodeAt(0);
if (48 <= firstCharCode && firstCharCode <= 57) { // isDigit
item.sectionKey = '0-9';
} else {
item.sectionKey = item.name.charAt(0).toUpperCase();
}
} else {
item.sectionKey = '?';
}
// console.log(item.sectionKey, item.name)
}
//--- sort
appList = appList.sort(function(a,b) {
if (a.name && b.name) {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
} else {
// console.log(a, b);
return 0;
}
})
return appList
}
function refresh() {
refreshing()
logger.debug("allAppsModel.refresh().star", Date.now())
//--- Apps
var appList = []
if (appsModel.order == "categories") {
appList = getAllCategories()
} else {
appList = getAllApps()
}
//--- Recent Apps
if (plasmoid.configuration.showRecentApps) {
var recentAppList = getRecentApps();
appList = recentAppList.concat(appList); // prepend
}
//--- Power
// var systemModel = rootModel.modelForRow(rootModel.count - 1)
// var systemList = []
// parseModel(systemList, systemModel)
// powerActionsModel.list = systemList;
//--- apply model
allAppsModel.list = appList;
// allAppsModel.log();
//--- listen for changes
// for (var i = 0; i < runnerModel.count; i++){
// var runner = runnerModel.modelForRow(i);
// if (!runner.listenersBound) {
// runner.countChanged.connect(debouncedRefresh.logAndRestart)
// runner.dataChanged.connect(debouncedRefresh.logAndRestart)
// runner.listenersBound = true;
// }
// }
logger.debug("allAppsModel.refresh().done", Date.now())
refreshed()
}
}
function endsWith(s, substr) {
return s.indexOf(substr) == s.length - substr.length
}
function launch(launcherName) {
for (var i = 0; i < allAppsModel.count; i++) {
var item = allAppsModel.get(i);
if (item.url && endsWith(item.url, '/' + launcherName + '.desktop')) {
item.parentModel.trigger(item.indexInParent, "", null);
break;
}
}
}
function open(filepath) {
if (filepath.indexOf('~/') == 0) {
if (kuser.loginName) {
filepath = '/home/' + kuser.loginName + filepath.substr(1)
} else {
console.log('kuser.loginName', kuser.loginName, 'is empty and can\'t be used to expand the ~ tilde to open a home path.')
// Can't open the right filepath
return
}
}
if (filepath.indexOf('file://') != 0) {
filepath = 'file://' + filepath
}
// console.log('open', filepath)
openModel.favorites = [filepath]
}
}
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
ScrollView {
id: appsView
property alias listView: appsListView
KickerListView {
id: appsListView
section.property: 'sectionKey'
// section.criteria: ViewSection.FirstCharacter
model: appsModel.allAppsModel // Should be populated by the time this is created
delegate: MenuListItem {
secondRowVisible: config.appDescriptionBelow
description: config.appDescriptionVisible ? modelDescription : ''
}
iconSize: config.menuItemHeight
showItemUrl: false
}
function scrollToTop() {
appsListView.positionViewAtBeginning()
}
}
Binary file not shown.
+75
View File
@@ -0,0 +1,75 @@
import QtQuick 2.0
QtObject {
property string configKey
property string configValue: plasmoid.configuration[configKey]
property variant value: { return {} }
property variant defaultValue: { return {} }
property bool writing: false
property bool loadOnConfigChange: true
signal loaded()
Component.onCompleted: {
load()
}
onConfigValueChanged: {
if (loadOnConfigChange) {
load()
}
}
function getBase64Json(key, defaultValue) {
var val = plasmoid.configuration[key]
if (val === '') {
return defaultValue
}
val = Qt.atob(val) // decode base64
val = JSON.parse(val)
return val
}
function setBase64Json(key, data) {
var val = JSON.stringify(data)
val = Qt.btoa(val)
plasmoid.configuration[key] = val
}
function set(obj) {
writing = true
setBase64Json(configKey, obj)
writing = false
}
function setItemProperty(key1, key2, val) {
var item = value[key1] || {}
item[key2] = val
value[key1] = item
set(value)
valueChanged()
}
function getItemProperty(key1, key2, def) {
var item = value[key1] || {}
return typeof item[key2] !== "undefined" ? item[key2] : def
}
function load() {
// console.log('load')
// console.log('configKey', configKey)
// console.log('plasmoid.configuration[key]', plasmoid.configuration[configKey])
value = getBase64Json(configKey, defaultValue)
loaded()
}
function save() {
// console.log('save')
// console.log('configKey', configKey)
// console.log('plasmoid.configuration[key]', plasmoid.configuration[configKey])
setBase64Json(configKey, value || defaultValue)
}
onValueChanged: {
// console.log('onValueChanged', configKey, value)
}
}
Binary file not shown.
+135
View File
@@ -0,0 +1,135 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 by Marco Martin <mart@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 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 2.010-1301, USA.
*/
/**Documented API
Inherits:
Item
Imports:
QtQuick 2.1
org.kde.plasma.core
Description:
TODO i need more info here
Properties:
**/
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
id: main
state: parent.state
//used to tell apart this implementation with the touch components one
property bool hasOverState: true
property alias enabledBorders: shadow.enabledBorders
PlasmaCore.FrameSvgItem {
id: hover
anchors {
fill: parent
leftMargin: -margins.left
topMargin: -margins.top
rightMargin: -margins.right
bottomMargin: -margins.bottom
}
opacity: 0
imagePath: "widgets/button"
prefix: "hover"
}
PlasmaCore.FrameSvgItem {
id: shadow
anchors {
fill: parent
leftMargin: -margins.left
topMargin: -margins.top
rightMargin: -margins.right
bottomMargin: -margins.bottom
}
imagePath: "widgets/button"
prefix: "shadow"
}
states: [
State {
name: "shadow"
PropertyChanges {
target: shadow
opacity: 1
}
PropertyChanges {
target: hover
opacity: 0
prefix: "hover"
}
},
State {
name: "hover"
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: hover
opacity: 1
prefix: "hover"
}
},
State {
name: "focus"
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: hover
opacity: 1
prefix: "focus"
}
},
State {
name: "hidden"
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: hover
opacity: 0
prefix: "hover"
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "opacity"
duration: units.longDuration
easing.type: Easing.OutQuad
}
}
]
}
+153
View File
@@ -0,0 +1,153 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate
import QtQuick.Controls.Styles.Plasma 2.0 as PlasmaStyles
PlasmaComponents.ToolButton {
id: flatButton
width: parent.width
height: config.flatButtonSize
property var icon: null
iconName: ""
property bool expanded: true
text: ""
property string label: expanded ? text : ""
property bool labelVisible: text != ""
property color backgroundColor: Qt.rgba(theme.buttonBackgroundColor.r, theme.buttonBackgroundColor.g, theme.buttonBackgroundColor.b, 0)
property bool zoomOnPush: true
// http://doc.qt.io/qt-5/qt.html#Edge-enum
property int checkedEdge: 0 // 0 = all edges
property int checkedEdgeWidth: 2 * units.devicePixelRatio
style: PlasmaStyles.ToolButtonStyle {
label: RowLayout {
spacing: units.smallSpacing
scale: control.zoomOnPush && control.pressed ? (height-5) / height : 1
Behavior on scale { NumberAnimation { duration: 200 } }
Item {
Layout.fillHeight: true
Layout.preferredWidth: height
visible: !!icon.source
PlasmaCore.IconItem {
id: icon
source: control.iconName || control.iconSource || control.icon
width: config.flatButtonIconSize
height: config.flatButtonIconSize
anchors.centerIn: parent
// colorGroup: PlasmaCore.Theme.ButtonColorGroup
}
}
PlasmaComponents.Label {
id: label
text: QtQuickControlsPrivate.StyleHelpers.stylizeMnemonics(control.text)
font: control.font || theme.defaultFont
visible: control.labelVisible
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
}
}
background: Item {
Rectangle {
id: background
anchors.fill: parent
color: flatButton.backgroundColor
}
Rectangle {
id: checkedOutline
color: theme.highlightColor
visible: control.checked
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
states: [
State {
when: control.checkedEdge === 0
PropertyChanges {
target: checkedOutline
anchors.fill: checkedOutline.parent
color: "transparent"
border.color: theme.highlightColor
}
},
State {
when: control.checkedEdge == Qt.TopEdge
PropertyChanges {
target: checkedOutline
anchors.bottom: undefined
height: control.checkedEdgeWidth
}
},
State {
when: control.checkedEdge == Qt.LeftEdge
PropertyChanges {
target: checkedOutline
anchors.right: undefined
width: control.checkedEdgeWidth
}
},
State {
when: control.checkedEdge == Qt.RightEdge
PropertyChanges {
target: checkedOutline
anchors.left: undefined
width: control.checkedEdgeWidth
}
},
State {
when: control.checkedEdge == Qt.BottomEdge
PropertyChanges {
target: checkedOutline
anchors.top: undefined
height: control.checkedEdgeWidth
}
}
]
}
states: [
State {
name: "hovering"
when: !control.pressed && control.hovered
PropertyChanges {
target: background
color: theme.buttonBackgroundColor
}
},
State {
name: "pressed"
when: control.pressed
PropertyChanges {
target: background
color: theme.highlightColor
}
}
]
transitions: [
Transition {
to: "hovering"
ColorAnimation { duration: 200 }
},
Transition {
to: "pressed"
ColorAnimation { duration: 100 }
}
]
}
}
}
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
Main
SearchModel
SearchResultsModel
LauncherIcon
Popup
SearchView
SidebarView
SearchResultsView
SearchResultsList
SearchField
TileGrid
krunner_id (filename)
org.kde.activities (activityrunner)
Audio Player Control Runner (audioplayercontrol)
baloosearch (baloosearch)
bookmarks (bookmarks)
calculator (calculator)
unitconverter (converter)
org.kde.datetime (datetime)
Dictionary (dictionary)
Kill Runner (kill)
kwin (kwin)
locations (locations)
places (places)
Name=plasma-desktop (plasma)
PowerDevil (powerdevil)
services (services)
desktopsessions (sessions)
shell (shell)
Spell Checker (spellchecker)
webshortcuts (webshortcuts)
org.kde.windowedwidgets (windowedwidgets)
windows (windows)
+8
View File
@@ -0,0 +1,8 @@
import QtQuick 2.0
HoverOutlineEffect {
id: hoverOutlineButtonEffect
anchors.fill: parent
hoverRadius: width/2
pressedRadius: width
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
import QtQuick 2.0
Item {
id: style
property int paddingTop: 0
property int paddingRight: 0
property int paddingBottom: 0
property int paddingLeft: 0
Loader {
id: hoverOutlineEffectLoader
anchors.fill: parent
active: control.containsMouse
visible: active
source: "HoverOutlineButtonEffect.qml"
}
}
Binary file not shown.
+64
View File
@@ -0,0 +1,64 @@
import QtQuick 2.0
import QtGraphicalEffects 1.0
Item {
id: hoverOutlineEffect
property int hoverOutlineSize: 1 * units.devicePixelRatio
property int hoverRadius: 40
property int pressedRadius: hoverRadius
property bool useOutlineMask: true
property int effectRadius: control.pressed ? pressedRadius : hoverRadius
Behavior on effectRadius {
NumberAnimation {
duration: units.longDuration
}
}
visible: control.containsMouse
function alpha(c, a) {
return Qt.rgba(c.r, c.g, c.b, a)
}
property color effectColor: theme.textColor
property color fillColor: alpha(effectColor, 1/16)
property color pressedFillColor: alpha(effectColor, 4/16)
property color borderColor: alpha(effectColor, 8/16)
Rectangle {
id: hoverOutline
visible: !hoverOutlineEffect.useOutlineMask
anchors.fill: parent
// color: "transparent"
color: control.pressed ? pressedFillColor : fillColor
border.color: borderColor
border.width: hoverOutlineSize
Behavior on color {
ColorAnimation {
duration: units.longDuration
}
}
}
RadialGradient {
id: hoverOutlineMask
visible: false
anchors.fill: parent
horizontalOffset: hoverOutlineEffect.visible ? control.mouseX - width/2 : 0
verticalOffset: hoverOutlineEffect.visible ? control.mouseY - height/2 : 0
horizontalRadius: effectRadius
verticalRadius: effectRadius
gradient: Gradient {
GradientStop { position: 0.0; color: "#FFFFFFFF" }
GradientStop { position: 1; color: "#00FFFFFF" }
}
}
OpacityMask {
anchors.fill: parent
visible: hoverOutlineEffect.useOutlineMask
source: hoverOutline
maskSource: hoverOutlineMask
}
}
Binary file not shown.
+81
View File
@@ -0,0 +1,81 @@
import QtQuick 2.0
import org.kde.plasma.private.kicker 0.1 as Kicker
Kicker.FavoritesModel {
// Kicker.FavoritesModel must be a child object of RootModel.
// appEntry.actions() looks at the parent object for parent.appletInterface and will crash plasma if it can't find it.
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/appentry.cpp#L151
id: kickerAppModel
signal triggerIndex(int index)
onTriggerIndex: {
var closeRequested = kickerAppModel.trigger(index, "", null)
if (closeRequested) {
plasmoid.expanded = false
}
}
signal triggerIndexAction(int index, string actionId, string actionArgument)
onTriggerIndexAction: {
var closeRequested = kickerAppModel.trigger(index, actionId, actionArgument)
if (closeRequested) {
plasmoid.expanded = false
}
}
// DescriptionRole Qt.UserRole + 1
// GroupRole Qt.UserRole + 2
// FavoriteIdRole Qt.UserRole + 3
// IsSeparatorRole Qt.UserRole + 4
// IsDropPlaceholderRole Qt.UserRole + 5
// IsParentRole Qt.UserRole + 6
// HasChildrenRole Qt.UserRole + 7
// HasActionListRole Qt.UserRole + 8
// ActionListRole Qt.UserRole + 9
// UrlRole Qt.UserRole + 10
function getApp(url) {
for (var i = 0; i < count; i++) {
var modelIndex = kickerAppModel.index(i, 0)
var favoriteId = kickerAppModel.data(modelIndex, Qt.UserRole + 3)
if (favoriteId == url) {
var app = {}
app.indexInModel = i
app.favoriteId = favoriteId
app.display = kickerAppModel.data(modelIndex, Qt.DisplayRole)
app.decoration = kickerAppModel.data(modelIndex, Qt.DecorationRole)
app.description = kickerAppModel.data(modelIndex, Qt.UserRole + 1)
app.group = kickerAppModel.data(modelIndex, Qt.UserRole + 2)
app.url = kickerAppModel.data(modelIndex, Qt.UserRole + 10)
// console.log(app, app.display, app.decoration, app.description, app.group, app.favoriteId)
return app
}
}
console.log('getApp', url, 'no index')
return null
}
function runApp(url) {
for (var i = 0; i < count; i++) {
var modelIndex = kickerAppModel.index(i, 0)
var favoriteId = kickerAppModel.data(modelIndex, Qt.UserRole + 3)
if (favoriteId == url) {
kickerAppModel.triggerIndex(i)
return
}
}
console.log('runApp', url, 'no index')
}
function indexHasActionList(i) {
var modelIndex = kickerAppModel.index(i, 0)
var hasActionList = kickerAppModel.data(modelIndex, Qt.UserRole + 8)
return hasActionList
}
function getActionListAtIndex(i) {
var modelIndex = kickerAppModel.index(i, 0)
var actionList = kickerAppModel.data(modelIndex, Qt.UserRole + 9)
return actionList
}
}
Binary file not shown.
+136
View File
@@ -0,0 +1,136 @@
import QtQuick 2.0
ListModel {
id: listModel
property var list: []
signal refreshing()
signal refreshed()
onListChanged: {
clear()
for (var i = 0; i < list.length; i++) {
append(list[i]);
}
}
function parseAppsModelItem(model, i) {
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/actionlist.h#L30
var DescriptionRole = Qt.UserRole + 1;
var GroupRole = DescriptionRole + 1;
var FavoriteIdRole = DescriptionRole + 2;
var IsSeparatorRole = DescriptionRole + 3;
var IsDropPlaceholderRole = DescriptionRole + 4;
var IsParentRole = DescriptionRole + 5;
var HasChildrenRole = DescriptionRole + 6;
var HasActionListRole = DescriptionRole + 7;
var ActionListRole = DescriptionRole + 8;
var UrlRole = DescriptionRole + 9;
var modelIndex = model.index(i, 0);
var item = {
parentModel: model,
indexInParent: i,
parentName: model.name,
name: model.data(modelIndex, Qt.DisplayRole),
description: model.data(modelIndex, DescriptionRole),
favoriteId: model.data(modelIndex, FavoriteIdRole),
largeIcon: false, // for KickerListView
};
// ListView.append() doesn't like it when we have { key: [object] }.
var url = model.data(modelIndex, UrlRole);
if (typeof url === 'object') {
url = url.toString();
}
item.url = url;
var icon = model.data(modelIndex, Qt.DecorationRole);
item.icon = typeof icon === 'object' ? icon : undefined;
item.iconName = typeof icon === 'string' ? icon : undefined;
return item;
}
function parseModel(appList, model, path) {
// console.log(path, model, model.description, model.count);
for (var i = 0; i < model.count; i++) {
var item = model.modelForRow(i);
if (!item) {
item = parseAppsModelItem(model, i);
}
var itemPath = (path || []).concat(i);
if (item && item.hasChildren) {
// console.log(item)
parseModel(appList, item, itemPath);
} else {
// console.log(itemPath, item, item.description);
appList.push(item);
}
}
}
function refresh() {
refreshing()
refreshed()
}
function log() {
for (var i = 0; i < list.length; i++) {
var item = list[i];
console.log(JSON.stringify({
name: item.name,
description: item.description,
}, null, '\t'))
}
}
function triggerIndex(index) {
var item = list[index]
item.parentModel.trigger(item.indexInParent, "", null);
itemTriggered()
}
signal itemTriggered()
function hasActionList(index) {
var DescriptionRole = Qt.UserRole + 1;
var HasActionListRole = DescriptionRole + 7;
var item = list[index]
var modelIndex = item.parentModel.index(item.indexInParent, 0)
return item.parentModel.data(modelIndex, HasActionListRole)
}
function getActionList(index) {
var DescriptionRole = Qt.UserRole + 1;
var ActionListRole = DescriptionRole + 8;
var item = list[index]
var modelIndex = item.parentModel.index(item.indexInParent, 0)
return item.parentModel.data(modelIndex, ActionListRole)
}
function triggerIndexAction(index, actionId, actionArgument) {
// kicker/code/tools.js triggerAction()
var item = list[index]
item.parentModel.trigger(item.indexInParent, actionId, actionArgument)
itemTriggered()
}
function getByValue(key, value) {
for (var i = 0; i < count; i++) {
var item = get(i)
if (item[key] == value) {
return item
}
}
return null
}
}
Binary file not shown.
+117
View File
@@ -0,0 +1,117 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
ListView {
id: listView
width: parent.width
Layout.fillHeight: true
clip: true
cacheBuffer: 200 // Don't unload when scrolling (prevent stutter)
// snapMode: ListView.SnapToItem
keyNavigationWraps: true
highlightMoveDuration: 0
highlightResizeDuration: 0
property bool showItemUrl: true
property bool showDesktopFileUrl: false
property int iconSize: 36 * units.devicePixelRatio
section.delegate: Item {
id: sectionDelegate
width: parent.width
height: childrenRect.height
PlasmaComponents.Label {
id: sectionHeading
anchors {
left: parent.left
leftMargin: units.smallSpacing
}
text: section
font.bold: true
font.pointSize: 14
property bool centerOverIcon: sectionHeading.contentWidth <= listView.iconSize
width: centerOverIcon ? listView.iconSize : parent.width
horizontalAlignment: centerOverIcon ? Text.AlignHCenter : Text.AlignLeft
}
}
delegate: MenuListItem {}
property var modelList: model ? model.list : []
// currentIndex: 0
// Connections {
// target: appsModel.allAppsModel
// onRefreshing: {
// console.log('appsList.onRefreshing')
// appsList.model = []
// // console.log('search.results.onRefreshed')
// appsList.currentIndex = 0
// }
// onRefreshed: {
// console.log('appsList.onRefreshed')
// // appsList.model = appsModel.allAppsList
// appsList.model = appsModel.allAppsList
// appsList.modelList = appsModel.allAppsList.list
// appsList.currentIndex = 0
// }
// }
highlight: PlasmaComponents.Highlight {
visible: listView.currentItem && !listView.currentItem.isSeparator
}
// function triggerIndex(index) {
// model.triggerIndex(index)
// }
function goUp() {
if (verticalLayoutDirection == ListView.TopToBottom) {
decrementCurrentIndex()
} else { // ListView.BottomToTop
incrementCurrentIndex()
}
}
function goDown() {
if (verticalLayoutDirection == ListView.TopToBottom) {
incrementCurrentIndex()
} else { // ListView.BottomToTop
decrementCurrentIndex()
}
}
function skipToMin() {
currentIndex = Math.max(0, currentIndex - 10)
}
function skipToMax() {
currentIndex = Math.min(currentIndex + 10, count-1)
}
function pageUp() {
if (verticalLayoutDirection == ListView.TopToBottom) {
skipToMin()
} else { // ListView.BottomToTop
skipToMax()
}
}
function pageDown() {
if (verticalLayoutDirection == ListView.TopToBottom) {
skipToMax()
} else { // ListView.BottomToTop
skipToMin()
}
}
}
Binary file not shown.
+98
View File
@@ -0,0 +1,98 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.draganddrop 2.0 as DragAndDrop
MouseArea {
id: launcherIcon
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.minimumWidth: {
switch (plasmoid.formFactor) {
case PlasmaCore.Types.Vertical:
return 0;
case PlasmaCore.Types.Horizontal:
return height;
default:
return units.gridUnit * 3;
}
}
Layout.minimumHeight: {
switch (plasmoid.formFactor) {
case PlasmaCore.Types.Vertical:
return width;
case PlasmaCore.Types.Horizontal:
return 0;
default:
return units.gridUnit * 3;
}
}
readonly property int maxSize: Math.max(width, height)
property int size: {
if (inPanel) {
if (plasmoid.configuration.fixedPanelIcon) {
return units.iconSizeHints.panel
} else {
return maxSize
}
} else {
return -1
}
}
Layout.maximumWidth: size
Layout.maximumHeight: size
property int iconSize: Math.min(width, height)
property alias iconSource: icon.source
PlasmaCore.IconItem {
id: icon
anchors.centerIn: parent
source: "start-here-kde"
width: launcherIcon.iconSize
height: launcherIcon.iconSize
active: launcherIcon.containsMouse
smooth: true
}
// Debugging
// Rectangle { anchors.fill: parent; border.color: "#ff0"; color: "transparent"; border.width: 1; }
// Rectangle { anchors.fill: icon; border.color: "#f00"; color: "transparent"; border.width: 1; }
hoverEnabled: true
// cursorShape: Qt.PointingHandCursor
onClicked: {
plasmoid.expanded = !plasmoid.expanded
}
property alias activateOnDrag: dropArea.enabled
DragAndDrop.DropArea {
id: dropArea
anchors.fill: parent
onDragEnter: {
dragHoverTimer.restart()
}
}
onContainsMouseChanged: {
if (!containsMouse) {
dragHoverTimer.stop()
}
}
Timer {
id: dragHoverTimer
interval: 250 // Same as taskmanager's activationTimer in MouseHandler.qml
onTriggered: plasmoid.expanded = true
}
}
Binary file not shown.
+245
View File
@@ -0,0 +1,245 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.private.kicker 0.1 as Kicker
import org.kde.kcoreaddons 1.0 as KCoreAddons
import "lib"
Item {
id: widget
Logger {
id: logger
name: 'tiledmenu'
// showDebug: true
}
SearchModel {
id: search
Component.onCompleted: {
search.applyDefaultFilters()
}
}
property alias rootModel: appsModel.rootModel
AppsModel {
id: appsModel
}
Item {
XdgPathsLoader { id: xdgPathsLoader }
KCoreAddons.KUser {
id: kuser
}
Kicker.SystemSettings {
id: systemSettings
}
Kicker.DragHelper {
id: dragHelper
dragIconSize: units.iconSizes.medium
onDropped: widget.draggedFavoriteId = ""
}
Kicker.ProcessRunner {
id: processRunner
// .runMenuEditor() to run kmenuedit
}
Kicker.WindowSystem {
id: windowSystem
}
PlasmaCore.DataSource {
id: executable
engine: "executable"
connectedSources: []
onNewData: disconnectSource(sourceName) // cmd finished
function exec(cmd) {
connectSource(cmd)
}
}
}
// Workaround for passing the favoriteId to the drop handler.
// Use until event.mimeData.mimeData is exposed.
// https://github.com/KDE/kdeclarative/blob/0e47f91b3a2c93655f25f85150faadad0d65d2c1/src/qmlcontrols/draganddrop/DeclarativeDragDropEvent.cpp#L66
property string draggedFavoriteId: ""
// onDraggedFavoriteIdChanged: console.log('onDraggedFavoriteIdChanged', draggedFavoriteId)
AppletConfig {
id: config
}
function logListModel(label, listModel) {
console.log(label + '.count', listModel.count);
// logObj(label, listModel);
for (var i = 0; i < listModel.count; i++) {
var item = listModel.modelForRow(i);
var itemLabel = label + '[' + i + ']';
console.log(itemLabel, item);
logObj(itemLabel, item);
if (('' + item).indexOf('Model') >= 0) {
logListModel(itemLabel, item);
}
}
}
function logObj(label, obj) {
// if (obj && typeof obj === 'object') {
// console.log(label, Object.keys(obj))
// }
for (var key in obj) {
var val = obj[key];
if (typeof val !== 'function') {
var itemLabel = label + '.' + key;
console.log(itemLabel, typeof val, val);
if (('' + val).indexOf('Model') >= 0) {
logListModel(itemLabel, val);
}
}
}
}
Plasmoid.compactRepresentation: LauncherIcon {
id: panelItem
iconSource: plasmoid.configuration.icon || "start-here-kde"
}
Plasmoid.hideOnWindowDeactivate: !plasmoid.userConfiguring
property bool expanded: plasmoid.expanded
onExpandedChanged: {
if (expanded) {
search.query = ""
search.applyDefaultFilters()
popup.searchView.searchField.forceActiveFocus()
popup.searchView.appsView.show()
// popup.searchView.tileEditorView.open('preferred://browser')
}
}
// property alias searchResultsView: popup.searchView.searchResultsView
// width: popup.width
// height: popup.height
Popup {
id: popup
anchors.fill: parent
}
Layout.minimumWidth: config.leftSectionWidth
Layout.preferredWidth: config.popupWidth
Layout.preferredHeight: config.popupHeight
// Layout.minimumHeight: 600 // For quickly testing as a desktop widget
// Layout.minimumWidth: 800
Connections {
target: config
property int lastAppListWidth: -1
onAppListWidthChanged: {
// We we increase the appListWidth, we need to increase the window width too.
// console.log('onAppListWidthChanged')
if (config.appListWidth != lastAppListWidth) {
// console.log('onAppListWidthChanged', config.appListWidth != lastAppListWidth)
if (lastAppListWidth != -1 && lastAppListWidth < config.appListWidth) {
var deltaPixels = config.appListWidth - lastAppListWidth
// console.log('onAppListWidthChanged', deltaPixels)
plasmoid.configuration.width += deltaPixels
}
lastAppListWidth = config.appListWidth
}
}
}
onWidthChanged: {
// console.log('popup.size', width, height, 'width')
// plasmoid.configuration.width = width
resizeToFit.run()
}
onHeightChanged: {
// console.log('popup.size', width, height, 'height')
resizeHeight.restart()
}
Timer {
id: resizeHeight
interval: 200
onTriggered: {
if (!plasmoid.configuration.fullscreen) {
plasmoid.configuration.popupHeight = height / units.devicePixelRatio
}
}
}
Timer {
id: resizeToFit
interval: attemptsLeft == attempts ? 200 : 100
repeat: attemptsLeft > 0
property int attempts: 10
property int attemptsLeft: 10
function run() {
restart()
attemptsLeft = attempts
}
onTriggered: {
if (plasmoid.configuration.fullscreen) {
attemptsLeft = 0
} else {
var favWidth = Math.max(0, widget.width - config.leftSectionWidth) // 398 // 888-60-430
// console.log(favWidth, widget.width, config.leftSectionWidth)
// console.log(favWidth / config.cellBoxSize)
// var cols = Math.floor(favWidth / config.favColWidth) * 2
var cols = Math.floor(favWidth / config.cellBoxSize)
if (plasmoid.configuration.favGridCols != cols) {
// console.log(plasmoid.configuration.favGridCols, cols)
plasmoid.configuration.favGridCols = cols
}
// Force a reflow since Alt+RightClick+Drag resizing doesn't really play nice with PlasmaCore.Dialog.
config.popupWidthChanged()
widget.Layout.preferredWidthChanged()
attemptsLeft -= 1
}
}
}
// Layout.onPreferredWidthChanged: console.log('popup.size', width, height)
// Layout.onPreferredHeightChanged: console.log('popup.size', width, height)
onFocusChanged: {
if (focus) {
popup.searchView.searchField.forceActiveFocus()
}
}
function action_kinfocenter() { appsModel.launch('org.kde.kinfocenter') }
function action_konsole() { appsModel.launch('org.kde.konsole') }
function action_ksysguard() { appsModel.launch('org.kde.ksysguard') }
function action_systemsettings() { appsModel.launch('systemsettings') }
function action_filemanager() { appsModel.launch('org.kde.dolphin') }
function action_menuedit() { processRunner.runMenuEditor(); }
Component.onCompleted: {
if (plasmoid.hasOwnProperty("activationTogglesExpanded")) {
plasmoid.activationTogglesExpanded = true
}
plasmoid.setAction("kinfocenter", i18n("System Info"), "hwinfo");
plasmoid.setAction("konsole", i18n("Terminal"), "utilities-terminal");
plasmoid.setActionSeparator("systemAppsSection")
plasmoid.setAction("ksysguard", i18n("Task Manager"), "ksysguardd");
plasmoid.setAction("systemsettings", i18n("System Settings"), "systemsettings");
plasmoid.setAction("filemanager", i18n("File Manager"), "folder");
plasmoid.setActionSeparator("configSection")
plasmoid.setAction("menuedit", i18n("Edit Applications..."), "kmenuedit");
// plasmoid.action('configure').trigger() // Uncomment to open the config window on load.
}
}
Binary file not shown.
+182
View File
@@ -0,0 +1,182 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
AppToolButton {
id: itemDelegate
width: parent.width
implicitHeight: row.implicitHeight
property var parentModel: typeof modelList !== "undefined" && modelList[index] ? modelList[index].parentModel : undefined
property string modelDescription: model.name == model.description ? '' : model.description // Ignore the Comment if it's the same as the Name.
property string description: model.url ? modelDescription : '' //
property bool isDesktopFile: !!(model.url && endsWith(model.url, '.desktop'))
property bool showItemUrl: listView.showItemUrl && (!isDesktopFile || listView.showDesktopFileUrl)
property string secondRowText: showItemUrl && model.url ? model.url : modelDescription
property bool secondRowVisible: secondRowText
property string launcherUrl: model.favoriteId || model.url
property alias iconSource: itemIcon.source
property int iconSize: model.largeIcon ? listView.iconSize * 2 : listView.iconSize
function endsWith(s, substr) {
return s.indexOf(substr) == s.length - substr.length
}
// We need to look at the js list since ListModel doesn't support item's with non primitive propeties (like an Image).
property bool modelListPopulated: !!listView.model.list && listView.model.list.length - 1 >= index
property var iconInstance: modelListPopulated && listView.model.list[index] ? listView.model.list[index].icon : ""
Connections {
target: listView.model
onRefreshed: {
// We need to manually trigger an update when we update the model without replacing the list.
// Otherwise the icon won't be in sync.
itemDelegate.iconInstance = listView.model.list[index] ? listView.model.list[index].icon : ""
}
}
// Drag (based on kicker)
// https://github.com/KDE/plasma-desktop/blob/4aad3fdf16bc5fd25035d3d59bb6968e06f86ec6/applets/kicker/package/contents/ui/ItemListDelegate.qml#L96
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/draghelper.cpp
property int pressX: -1
property int pressY: -1
property bool dragEnabled: launcherUrl
function initDrag(mouse) {
pressX = mouse.x
pressY = mouse.y
}
function shouldStartDrag(mouse) {
return dragEnabled
&& pressX != -1 // Drag initialized?
&& dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y) // Mouse moved far enough?
}
function startDrag() {
widget.draggedFavoriteId = model.favoriteId
// Requires Plasma 5.9 (probably) https://github.com/KDE/plasma-desktop/commit/85d946b206f6e8a12cf0a03b2386279ff2b0ff1a
// dragHelper.startDrag(widget, model.url, iconInstance, "favoriteId", model.favoriteId)
dragHelper.startDrag(widget, model.url || model.favoriteId, iconInstance)
resetDragState()
}
function resetDragState() {
pressX = -1
pressY = -1
}
onPressed: {
if (mouse.buttons & Qt.LeftButton) {
initDrag(mouse)
}
}
onContainsMouseChanged: {
if (!containsMouse) {
resetDragState()
}
}
onPositionChanged: {
if (shouldStartDrag(mouse)) {
startDrag()
}
}
RowLayout { // ItemListDelegate
id: row
anchors.left: parent.left
anchors.leftMargin: units.smallSpacing
anchors.right: parent.right
anchors.rightMargin: units.smallSpacing
Item {
Layout.fillHeight: true
implicitHeight: itemIcon.implicitHeight
implicitWidth: itemIcon.implicitWidth
PlasmaCore.IconItem {
id: itemIcon
anchors.centerIn: parent
implicitHeight: itemDelegate.iconSize
implicitWidth: implicitHeight
// visible: iconsEnabled
animated: false
// usesPlasmaTheme: false
source: itemDelegate.iconInstance
}
}
ColumnLayout {
Layout.fillWidth: true
// Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter
spacing: 0
RowLayout {
Layout.fillWidth: true
// height: itemLabel.height
PlasmaComponents.Label {
id: itemLabel
text: model.name
maximumLineCount: 1
// elide: Text.ElideMiddle
height: implicitHeight
}
PlasmaComponents.Label {
Layout.fillWidth: true
text: !itemDelegate.secondRowVisible ? itemDelegate.description : ''
color: config.menuItemTextColor2
maximumLineCount: 1
elide: Text.ElideRight
height: implicitHeight // ElideRight causes some top padding for some reason
}
}
PlasmaComponents.Label {
visible: itemDelegate.secondRowVisible
Layout.fillWidth: true
// Layout.fillHeight: true
text: itemDelegate.secondRowText
color: config.menuItemTextColor2
maximumLineCount: 1
elide: Text.ElideMiddle
height: implicitHeight
}
}
}
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
mouse.accepted = true
logger.debug('MenuListItem.onClicked', mouse.button, Qt.LeftButton, Qt.RightButton)
if (mouse.button == Qt.LeftButton) {
trigger()
} else if (mouse.button == Qt.RightButton) {
contextMenu.open(mouse.x, mouse.y)
}
}
function trigger() {
listView.model.triggerIndex(index)
}
// property bool hasActionList: listView.model.hasActionList(index)
// property var actionList: hasActionList ? listView.model.getActionList(index) : []
AppContextMenu {
id: contextMenu
onPopulateMenu: {
if (launcherUrl && !plasmoid.configuration.tilesLocked) {
menu.addPinToMenuAction(launcherUrl)
}
if (listView.model.hasActionList(index)) {
var actionList = listView.model.getActionList(index)
menu.addActionList(actionList, listView.model, index)
}
}
}
} // delegate: AppToolButton
Binary file not shown.
+82
View File
@@ -0,0 +1,82 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
MouseArea {
property alias searchView: searchView
property alias tileEditorView: searchView.tileEditorView
property alias tileEditorViewLoader: searchView.tileEditorViewLoader
property alias tileGrid: tileGrid
RowLayout {
anchors.fill: parent
spacing: 0
SearchView {
id: searchView
Layout.minimumWidth: config.leftSectionWidth
Layout.maximumWidth: config.leftSectionWidth
Layout.fillHeight: true
}
TileGrid {
id: tileGrid
Layout.fillWidth: true
Layout.fillHeight: true
cellSize: config.cellSize
cellMargin: config.cellMargin
cellPushedMargin: config.cellPushedMargin
tileModel: config.tileModel.value
onEditTile: tileEditorViewLoader.open(tile)
onTileModelChanged: saveTileModel.restart()
Timer {
id: saveTileModel
interval: 2000
onTriggered: config.tileModel.save()
}
}
}
MouseArea {
visible: !plasmoid.configuration.tilesLocked && !(plasmoid.location == PlasmaCore.Types.TopEdge || plasmoid.location == PlasmaCore.Types.RightEdge)
anchors.top: parent.top
anchors.right: parent.right
width: units.largeSpacing
height: units.largeSpacing
cursorShape: Qt.WhatsThisCursor
PlasmaCore.ToolTipArea {
anchors.fill: parent
icon: "help-hint"
mainText: i18n("Resize?")
subText: i18n("Alt + Right Click to resize the menu.")
}
}
MouseArea {
visible: !plasmoid.configuration.tilesLocked && !(plasmoid.location == PlasmaCore.Types.BottomEdge || plasmoid.location == PlasmaCore.Types.RightEdge)
anchors.bottom: parent.bottom
anchors.right: parent.right
width: units.largeSpacing
height: units.largeSpacing
cursorShape: Qt.WhatsThisCursor
PlasmaCore.ToolTipArea {
anchors.fill: parent
icon: "help-hint"
mainText: i18n("Resize?")
subText: i18n("Alt + Right Click to resize the menu.")
}
}
onClicked: searchView.searchField.forceActiveFocus()
}
Binary file not shown.
+134
View File
@@ -0,0 +1,134 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 by Marco Martin <mart@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 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 2.010-1301, USA.
*/
/**Documented API
Inherits:
Item
Imports:
QtQuick 2.1
org.kde.plasma.core
Description:
It is a simple Radio button which is using the plasma theme.
TODO Do we need more info?
Properties:
TODO needs more info??
**/
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
id: main
state: parent.state
property alias imagePath: shadowSvg.imagePath
property string hoverElement: "hover"
property string focusElement: "focus"
property alias shadowElement: shadow.elementId
//used to tell apart this implementation with the touch components one
property bool hasOverState: true
PlasmaCore.Svg {
id: shadowSvg
imagePath: "widgets/actionbutton"
}
PlasmaCore.SvgItem {
id: hover
svg: shadowSvg
elementId: "hover"
anchors.fill: parent
opacity: 0
}
PlasmaCore.SvgItem {
id: shadow
svg: shadowSvg
elementId: "shadow"
anchors.fill: parent
}
states: [
State {
name: "shadow"
PropertyChanges {
target: shadow
opacity: 1
}
PropertyChanges {
target: hover
opacity: 0
elementId: hoverElement
}
},
State {
name: "hover"
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: hover
opacity: 1
elementId: hoverElement
}
},
State {
name: "focus"
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: hover
opacity: 1
elementId: focusElement
}
},
State {
name: "hidden"
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: hover
opacity: 0
elementId: hoverElement
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "opacity"
duration: units.longDuration
easing.type: Easing.OutQuad
}
}
]
}
+108
View File
@@ -0,0 +1,108 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls.Styles.Plasma 2.0 as PlasmaStyles
TextField {
id: searchField
placeholderText: {
if (search.isDefaultFilter) {
return i18n("Search")
} else if (search.isAppsFilter) {
return i18n("Search Apps")
} else if (search.isFileFilter) {
return i18n("Search Files")
} else if (search.isBookmarksFilter) {
return i18n("Search Bookmarks")
} else {
return i18nc("Search [krunnerName, krunnerName, ...], ", "Search %1", search.filters)
}
}
property int topMargin: 0
property int bottomMargin: 0
property int defaultFontSize: 16 * units.devicePixelRatio // Not the same as pointSize=16
property int styleMaxFontSize: height - topMargin - bottomMargin
font.pixelSize: Math.min(defaultFontSize, styleMaxFontSize)
style: plasmoid.configuration.searchFieldFollowsTheme ? plasmaStyle : redmondStyle
Component {
id: plasmaStyle
// Creates the following warning when not in use:
// file:///usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Controls/Styles/Plasma/TextFieldStyle.qml:74: ReferenceError: textField is not defined
// Caused by:
// var actionIconSize = Math.max(textField.height * 0.8, units.iconSizes.small);
PlasmaStyles.TextFieldStyle {
id: style
Component.onCompleted: {
searchField.topMargin = Qt.binding(function() {
return style.padding.top
})
searchField.bottomMargin = Qt.binding(function() {
return style.padding.bottom
})
}
}
}
Component {
id: redmondStyle
// https://github.com/qt/qtquickcontrols/blob/dev/src/controls/Styles/Base/TextFieldStyle.qml
// https://github.com/qt/qtquickcontrols/blob/dev/src/controls/Styles/Desktop/TextFieldStyle.qml
TextFieldStyle {
id: style
background: Rectangle {
color: "#eee"
}
textColor: "#111"
placeholderTextColor: "#777"
Component.onCompleted: {
searchField.topMargin = Qt.binding(function() {
return style.padding.top
})
searchField.bottomMargin = Qt.binding(function() {
return style.padding.bottom
})
}
}
}
onTextChanged: {
search.query = text
}
Connections {
target: search
onQueryChanged: searchField.text = search.query
}
property var listView: searchResultsView.listView
Keys.onPressed: {
if (event.key == Qt.Key_Up) {
event.accepted = true; listView.goUp()
} else if (event.key == Qt.Key_Down) {
event.accepted = true; listView.goDown()
} else if (event.key == Qt.Key_PageUp) {
event.accepted = true; listView.pageUp()
} else if (event.key == Qt.Key_PageDown) {
event.accepted = true; listView.pageDown()
} else if (event.key == Qt.Key_Return) {
event.accepted = true; listView.currentItem.trigger()
} else if (event.modifiers & Qt.MetaModifier && event.key == Qt.Key_R) {
event.accepted = true; search.filters = ['shell']
} else if (event.modifiers & Qt.MetaModifier && event.key == Qt.Key_R) {
event.accepted = true; search.filters = ['shell']
} else if (event.key == Qt.Key_Escape) {
plasmoid.expanded = false
}
}
Component.onCompleted: {
forceActiveFocus()
}
}
Binary file not shown.
+129
View File
@@ -0,0 +1,129 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
ColumnLayout {
id: searchFiltersView
// width: parent.width
// Layout.fillHeight: true
SearchFiltersViewItem {
runnerId: ""
indentLevel: 0
iconSource: "applications-other"
text: i18n("All") + ' (Not working)'
subText: i18n("Search with all KRunner plugins")
checkBox.visible: false
onApplyButtonClicked: search.filters = []
enabled: false
}
SearchFiltersViewItem {
runnerId: ""
indentLevel: 0
iconSource: "applications-other"
text: i18n("Default")
subText: i18n("Search with user selected defaults")
checkBox.visible: false
onApplyButtonClicked: search.applyDefaultFilters()
}
// Installed runners are listed at: /usr/share/kservices5/plasma-runner-*.desktop
SearchFiltersViewItem {
runnerId: "services"
indentLevel: 1
iconSource: "window"
text: i18n("Applications")
}
SearchFiltersViewItem {
runnerId: "baloosearch"
indentLevel: 1
iconSource: "document-new"
text: i18n("Files")
}
//--- baloosearch filters
// https://github.com/KDE/baloo/blob/master/docs/user/searching.md#advanced-searches
// Use `type:Audio` or `type:Document` to filter specific filetypes.
SearchFiltersViewItem {
runnerId: "baloosearch"
indentLevel: 2
iconSource: "folder-music-symbolic"
text: i18n("Music")
checkBox.visible: false
onApplyButtonClicked: search.setQueryPrefix('type:Audio ')
}
SearchFiltersViewItem {
runnerId: "baloosearch"
indentLevel: 2
iconSource: "folder-videos-symbolic"
text: i18n("Videos")
checkBox.visible: false
onApplyButtonClicked: search.setQueryPrefix('type:Video ')
}
//--- end baloosearch filters
SearchFiltersViewItem {
runnerId: "bookmarks"
indentLevel: 1
iconSource: "globe"
text: i18n("Bookmarks")
}
SearchFiltersViewItem {
runnerId: "locations"
indentLevel: 1
iconSource: "system-file-manager"
text: i18n("locations")
}
SearchFiltersViewItem {
runnerId: "Dictionary"
indentLevel: 1
iconSource: "accessories-dictionary"
text: i18n("Dictionary")
onApplyButtonClicked: search.setQueryPrefix('define ')
}
SearchFiltersViewItem {
runnerId: "shell"
indentLevel: 1
iconSource: "system-run"
text: i18n("Shell")
}
SearchFiltersViewItem {
runnerId: "calculator"
indentLevel: 1
iconSource: "accessories-calculator"
text: i18n("Calculator")
}
SearchFiltersViewItem {
runnerId: "org.kde.windowedwidgets"
indentLevel: 1
iconSource: ""
text: i18n("Windowed Widgets")
}
SearchFiltersViewItem {
runnerId: "org.kde.datetime"
indentLevel: 1
iconSource: ""
text: i18n("Date/Time")
}
SearchFiltersViewItem {
runnerId: "unitconverter"
indentLevel: 1
iconSource: ""
text: i18n("Unit Converter")
}
}
Binary file not shown.
+124
View File
@@ -0,0 +1,124 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle
import QtQuick.Controls.Styles.Plasma 2.0 as PlasmaStyles
RowLayout {
id: searchFiltersViewItem
Layout.fillWidth: true
spacing: 0
property string runnerId: ''
property int indentLevel: 0
property alias iconSource: applyFilterButton.iconSource
property alias text: applyFilterButton.text
property alias subText: applyFilterButton.subText
property alias checkBox: isDefaultFilter
property alias applyButton: applyFilterButton
signal applyButtonClicked()
property var surfaceNormal: PlasmaCore.FrameSvgItem {
anchors.fill: parent
imagePath: "widgets/button"
prefix: "normal"
// prefix: style.flat ? ["toolbutton-hover", "normal"] : "normal"
}
Item { // Align CheckBoxes buttons to "All"
Layout.minimumWidth: surfaceNormal.margins.left
Layout.maximumWidth: Layout.minimumWidth
Layout.fillHeight: true
// visible: isDefaultFilter.visible && searchFiltersViewItem.indentLevel > 0
}
Item { // Align CheckBoxes buttons to "All"
// Layout.minimumWidth: (isDefaultFilter.Layout.preferredWidth + surfaceNormal.margins.left) * (searchFiltersViewItem.indentLevel - (isDefaultFilter.visible ? 1 : 0))
Layout.minimumWidth: (isDefaultFilter.Layout.minimumWidth + surfaceNormal.margins.left) * searchFiltersViewItem.indentLevel
Layout.maximumWidth: Layout.minimumWidth
Layout.fillHeight: true
}
PlasmaComponents.ToolButton {
id: applyFilterButton
Layout.fillWidth: true
property string subText: ""
style: PlasmaStyles.ToolButtonStyle {
id: style
readonly property bool smallIcon: !control.subText
label: RowLayout {
PlasmaCore.IconItem {
source: control.iconSource
Layout.preferredHeight: style.smallIcon ? config.flatButtonIconSize : -1
Layout.preferredWidth: style.smallIcon ? config.flatButtonIconSize : -1
}
ColumnLayout {
id: textColumn
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 0
PlasmaComponents.Label {
Layout.fillWidth: true
text: control.text
horizontalAlignment: Text.AlignLeft
maximumLineCount: 1
elide: Text.ElideRight
}
PlasmaComponents.Label {
Layout.fillWidth: true
text: control.subText
horizontalAlignment: Text.AlignLeft
visible: control.subText
color: config.menuItemTextColor2
maximumLineCount: 1
elide: Text.ElideRight
}
}
}
}
onClicked: {
if (searchFiltersViewItem.runnerId) {
search.filters = [searchFiltersViewItem.runnerId]
}
searchFiltersViewItem.applyButtonClicked()
searchResultsView.filterViewOpen = false
}
}
PlasmaComponents.CheckBox {
id: isDefaultFilter
checked: search.defaultFilters.indexOf(searchFiltersViewItem.runnerId) != -1
enabled: false
onCheckedChanged: {
if (checked) {
} else {
}
}
// Layout.fillHeight: true
Layout.preferredHeight: config.flatButtonIconSize
Layout.minimumWidth: config.flatButtonIconSize
Layout.preferredWidth: implicitWidth
implicitHeight: -1
text: i18n("Default")
}
Item { // Align CheckBoxes buttons to "All"
Layout.minimumWidth: surfaceNormal.margins.right
Layout.maximumWidth: Layout.minimumWidth
Layout.fillHeight: true
// visible: isDefaultFilter.visible && searchFiltersViewItem.indentLevel > 0
}
}
Binary file not shown.
+119
View File
@@ -0,0 +1,119 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.private.kicker 0.1 as Kicker
Item {
id: search
property alias results: resultModel
property alias runnerModel: runnerModel
property string query: ""
property bool isSearching: query.length > 0
onQueryChanged: {
runnerModel.query = search.query
}
// KRunner runners are defined in /usr/share/kservices5/plasma-runner-*.desktop
// To list the runner ids, use:
// find /usr/share/kservices5/ -iname "plasma-runner-*.desktop" -print0 | xargs -0 grep "PluginInfo-Name" | sort
property var filters: []
onFiltersChanged: {
runnerModel.deleteWhenEmpty = !runnerModel.deleteWhenEmpty // runnerModel.clear()
runnerModel.runners = filters
clearQueryPrefix()
runnerModel.query = search.query
}
Kicker.RunnerModel {
id: runnerModel
appletInterface: plasmoid
favoritesModel: rootModel.favoritesModel
mergeResults: config.searchResultsMerged
runners: [] // Empty = All runners.
// deleteWhenEmpty: isDash
// deleteWhenEmpty: false
onRunnersChanged: debouncedRefresh.restart()
onDataChanged: debouncedRefresh.restart()
onCountChanged: debouncedRefresh.restart()
}
Timer {
id: debouncedRefresh
interval: 100
onTriggered: resultModel.refresh()
function logAndRestart() {
// console.log('debouncedRefresh')
restart()
}
}
SearchResultsModel {
id: resultModel
}
property var defaultFilters: [
'Dictionary',
'services',
// 'calculator',
'shell',
'org.kde.windowedwidgets',
'org.kde.datetime',
'baloosearch',
// 'bookmarks',
'locations',
'unitconverter',
]
function isFilter(runnerId) {
return filters.length == 1 && filters[0] == runnerId
}
property bool isDefaultFilter: filters == defaultFilters
property bool isAppsFilter: isFilter('services')
property bool isFileFilter: isFilter('baloosearch')
property bool isBookmarksFilter: isFilter('bookmarks')
function hasFilter(runnerId) {
return filters.indexOf(runnerId) >= 0
}
function applyDefaultFilters() {
filters = defaultFilters
}
function setQueryPrefix(prefix) {
// First check to see if there's already a prefix we need to replace.
var firstSpaceIndex = query.indexOf(' ')
if (firstSpaceIndex > 0) {
var firstToken = query.substring(0, firstSpaceIndex)
if (/^type:\w+$/.exec(firstToken) // baloosearch
|| /^define$/.exec(firstToken) // Dictionary
) {
// replace existing prefix
query = prefix + query.substring(firstSpaceIndex + 1, query.length)
return
}
}
// If not, just prepend the prefix
var newQuery = prefix + query
if (newQuery != query) {
query = prefix + query
}
}
function clearQueryPrefix() {
setQueryPrefix('')
}
}
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
KickerListView { // RunnerResultsList
id: searchResultsList
model: []
delegate: MenuListItem {
property var runner: search.runnerModel.modelForRow(model.runnerIndex)
iconSource: runner && runner.data(runner.index(model.runnerItemIndex, 0), Qt.DecorationRole)
}
section.property: 'runnerName'
section.criteria: ViewSection.FullString
// verticalLayoutDirection: config.searchResultsDirection
Connections {
target: search.results
onRefreshing: {
searchResultsList.model = []
// console.log('search.results.onRefreshed')
searchResultsList.currentIndex = 0
}
onRefreshed: {
// console.log('search.results.onRefreshed')
searchResultsList.model = search.results
// if (searchResultsList.verticalLayoutDirection == Qt.BottomToTop) {
if (plasmoid.configuration.searchResultsReversed) {
searchResultsList.currentIndex = searchResultsList.model.count - 1
} else { // TopToBottom (normal)
searchResultsList.currentIndex = 0
}
}
}
}
Binary file not shown.
+245
View File
@@ -0,0 +1,245 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
ListModel {
id: resultModel
signal refreshing()
signal refreshed()
function refresh() {
refreshing()
// console.log('resultModel.refresh')
//--- populate list
var resultList = [];
for (var i = 0; i < runnerModel.count; i++){
var runner = runnerModel.modelForRow(i);
// console.log(i, runner, runner.runnerId, runner.name)
for (var j = 0; j < runner.count; j++) {
// RunnerMatchesModel.modelForRow is NOT implemented.
// We need to use model.data(model.index(row, 0), role)
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/abstractmodel.cpp#L35
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/runnermatchesmodel.cpp#L54
// https://github.com/KDE/plasma-desktop/blob/master/applets/kicker/plugin/actionlist.h#L30
var DescriptionRole = Qt.UserRole + 1;
var GroupRole = DescriptionRole + 1;
var FavoriteIdRole = DescriptionRole + 2;
var IsSeparatorRole = DescriptionRole + 3;
var IsDropPlaceholderRole = DescriptionRole + 4;
var IsParentRole = DescriptionRole + 5;
var HasChildrenRole = DescriptionRole + 6;
var HasActionListRole = DescriptionRole + 7;
var ActionListRole = DescriptionRole + 8;
var UrlRole = DescriptionRole + 9;
var modelIndex = runner.index(j, 0);
// ListView.append() doesn't like it when we have { key: [object] }.
var url = runner.data(modelIndex, UrlRole);
if (typeof url === 'object') {
url = url.toString();
}
var icon = runner.data(modelIndex, Qt.DecorationRole);
if (typeof icon === 'object') {
icon = icon.toString();
}
var resultItem = {
runnerIndex: i,
runnerName: runner.name,
runnerItemIndex: j,
name: runner.data(modelIndex, Qt.DisplayRole),
description: runner.data(modelIndex, DescriptionRole),
icon: icon,
url: url,
favoriteId: runner.data(modelIndex, FavoriteIdRole),
largeIcon: false, // for KickerListView
};
// console.log(resultItem.name, resultItem.url);
// for (var x = 0; x < 10; x++) {
// console.log('\t', typeof runner.data(runner.index(j, 0), DescriptionRole + x));
// }
// console.log(resultItem.name, Qt.DisplayRole, DescriptionRole, UrlRole)
resultList.push(resultItem);
}
}
if (config.searchResultsCustomSort) {
//--- sort: runner relevance (English only)
// We have to sort by .name instead of .runnerId because the later isn't exposed... anywhere. :/
var runnerOrder = [
//--- Single line action
"Desktop Sessions", // sessions
"Command Line", // shell
"Locations", // locations (Open website)
//--- Single line
"Calculator", // calculator
"Date and Time", // datetime
//--- Small Lists
"Control Audio Player", // audioplayercontrol
"Unit Converter", // converter
"Dictionary", // dictionary
"Terminate Applications", // kill
//--- Large Lists
"Applications", // services
"System Settings",
"Places", // places
"Windows", // windows
"Bookmarks", // bookmarks
"Recent Documents", // ? baloosearch ?
"Windowed widgets", // windowedwidgets
//--- ?
"Desktop Search", // baloosearch
"KWin", // kwin
"Plasma Desktop Shell", // plasma-desktop
"Power", // powerdevil
"Spell Checker", // spellchecker
"Web Shortcuts", // webshortcuts
];
resultList = resultList.sort(function(a, b) {
var aOrder = runnerOrder.indexOf(a.runnerName);
var bOrder = runnerOrder.indexOf(b.runnerName);
if (aOrder == -1 && bOrder == -1) { // Neither really matters
return 0;
} else if (aOrder == -1) { // a doesn't matter
return 1; // a should be placed after b
} else if (bOrder == -1) { // b doesn't matter
return -1; // a should be placed before b
} else {
return aOrder - bOrder;
}
});
//--- sort: matches start
function moveToTopOfRunner(queryLower) {
// Scan in reverse so we preserve runnerOrder with multiple matches
for (var i = resultList.length-1; i >= 0; i--) {
var resultItem = resultList[i];
if (resultItem.name.toLowerCase().indexOf(queryLower) == 0) {
for (var j = i-1; j >= 0; j--) {
// Scan (in reverse) for insertion point.
if (resultList[j].runnerName != resultItem.runnerName) {
resultList.splice(i, 1); // remove from old index
resultList.splice(j, 0, resultItem); // insert at new index
break;
}
}
}
}
}
var queryLower = search.query.toLowerCase();
moveToTopOfRunner(queryLower)
//--- sort: exact match
function moveToTop(queryLower) {
// Scan in reverse so we preserve runnerOrder with multiple matches
for (var i = resultList.length-1; i >= 0; i--) {
var resultItem = resultList[i];
if (queryLower == resultItem.name.toLowerCase()) {
resultList.splice(i, 1); // remove at index
resultList.splice(0, 0, resultItem); // add to beginning
}
}
}
// sort: clementine (English only)
// /usr/share/applications/clementine.desktop
if (queryLower == 'play') {
moveToTop('Play - Clementine'.toLowerCase())
} else if (queryLower == 'play') {
moveToTop('Pause - Clementine'.toLowerCase())
} else if (queryLower == 'play') {
moveToTop('Stop - Clementine'.toLowerCase())
} else if (queryLower.indexOf('prev') == 0) { // Matches previous as well
moveToTop('Previous - Clementine'.toLowerCase())
} else if (queryLower == 'next') {
moveToTop('Next - Clementine'.toLowerCase())
}
}
//--- Make the (selected) first item bigger.
if (resultList.length > 0) {
resultList[0].largeIcon = true
}
//--- Reverse the model?
if (plasmoid.configuration.searchResultsReversed) {
resultList.reverse()
}
//--- apply model
resultModel.clear();
for (var i = 0; i < resultList.length; i++) {
resultModel.append(resultList[i]);
}
// console.log(JSON.stringify(resultList, null, '\t'))
//--- listen for changes
for (var i = 0; i < runnerModel.count; i++){
var runner = runnerModel.modelForRow(i);
if (!runner.listenersBound) {
runner.countChanged.connect(debouncedRefresh.logAndRestart)
runner.dataChanged.connect(debouncedRefresh.logAndRestart)
runner.listenersBound = true;
}
}
refreshed()
}
function triggerIndex(index) {
var model = resultModel.get(index)
var runner = runnerModel.modelForRow(model.runnerIndex)
runner.trigger(model.runnerItemIndex, "", null)
itemTriggered()
}
signal itemTriggered()
function hasActionList(index) {
var DescriptionRole = Qt.UserRole + 1;
var HasActionListRole = DescriptionRole + 7;
var model = resultModel.get(index)
var runner = runnerModel.modelForRow(model.runnerIndex)
var modelIndex = runner.index(model.runnerItemIndex, 0)
return runner.data(modelIndex, HasActionListRole)
}
function getActionList(index) {
var DescriptionRole = Qt.UserRole + 1;
var ActionListRole = DescriptionRole + 8;
var model = resultModel.get(index)
var runner = runnerModel.modelForRow(model.runnerIndex)
var modelIndex = runner.index(model.runnerItemIndex, 0)
return runner.data(modelIndex, ActionListRole)
}
function triggerIndexAction(index, actionId, actionArgument) {
// kicker/code/tools.js triggerAction()
var model = resultModel.get(index)
var runner = runnerModel.modelForRow(model.runnerIndex)
runner.trigger(model.runnerItemIndex, actionId, actionArgument)
itemTriggered()
// Note that Recent Documents actions do not work (in the search results) as of Plasma 5.8.4
// https://bugs.kde.org/show_bug.cgi?id=373173
}
}
Binary file not shown.
+136
View File
@@ -0,0 +1,136 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
GridLayout {
id: searchResultsView
rowSpacing: 0
property alias listView: searchResultsList
property bool filterViewOpen: false
RowLayout {
id: searchFiltersRow
Layout.row: searchView.searchOnTop ? 2 : 0
Layout.preferredHeight: config.searchFilterRowHeight - 1 // -1px is for the underline seperator
Layout.fillWidth: true
FlatButton {
iconName: "system-search-symbolic"
Layout.preferredHeight: parent.Layout.preferredHeight
Layout.preferredWidth: parent.Layout.preferredHeight
onClicked: search.applyDefaultFilters()
checked: search.isDefaultFilter
checkedEdge: searchView.searchOnTop ? Qt.TopEdge : Qt.BottomEdge
}
FlatButton {
iconName: "window"
Layout.preferredHeight: parent.Layout.preferredHeight
Layout.preferredWidth: parent.Layout.preferredHeight
onClicked: search.filters = ['services']
checked: search.isAppsFilter
checkedEdge: searchView.searchOnTop ? Qt.TopEdge : Qt.BottomEdge
}
FlatButton {
iconName: "document-new"
Layout.preferredHeight: parent.Layout.preferredHeight
Layout.preferredWidth: parent.Layout.preferredHeight
onClicked: search.filters = ['baloosearch']
checked: search.isFileFilter
checkedEdge: searchView.searchOnTop ? Qt.TopEdge : Qt.BottomEdge
}
// FlatButton {
// iconName: "globe"
// Layout.preferredHeight: parent.Layout.preferredHeight
// Layout.preferredWidth: parent.Layout.preferredHeight
// onClicked: search.filters = ['bookmarks']
// checked: search.isBookmarksFilter
// checkedEdge: searchView.searchOnTop ? Qt.TopEdge : Qt.BottomEdge
// }
Item { Layout.fillWidth: true }
FlatButton {
id: moreFiltersButton
Layout.preferredHeight: parent.Layout.preferredHeight
Layout.preferredWidth: moreFiltersButtonRow.implicitWidth + padding*2
property int padding: (config.searchFilterRowHeight - config.flatButtonIconSize) / 2
// enabled: false
RowLayout {
id: moreFiltersButtonRow
anchors.centerIn: parent
anchors.margins: parent.padding
PlasmaComponents.Label {
id: moreFiltersButtonLabel
text: i18n("Filters")
}
PlasmaCore.IconItem {
source: "usermenu-down"
rotation: searchResultsView.filterViewOpen ? 180 : 0
Layout.preferredHeight: config.flatButtonIconSize
Layout.preferredWidth: config.flatButtonIconSize
Behavior on rotation {
NumberAnimation { duration: units.longDuration }
}
}
}
onClicked: searchResultsView.filterViewOpen = !searchResultsView.filterViewOpen
}
}
Rectangle {
color: "#111"
height: 1
width: parent.width
// anchors.bottom: searchFiltersRow.bottom - 1
}
StackView {
id: searchResultsViewStackView
Layout.row: searchView.searchOnTop ? 0 : 2
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
initialItem: searchResultsListScrollView
Connections {
target: searchResultsView
onFilterViewOpenChanged: {
if (searchResultsView.filterViewOpen) {
searchResultsViewStackView.push(searchFiltersViewScrollView)
} else {
searchResultsViewStackView.pop()
}
}
}
ScrollView {
id: searchResultsListScrollView
visible: false
SearchResultsList {
id: searchResultsList
}
}
ScrollView {
id: searchFiltersViewScrollView
visible: false
SearchFiltersView {
id: searchFiltersView
width: searchFiltersViewScrollView.viewport.width
}
}
}
}
Binary file not shown.
+121
View File
@@ -0,0 +1,121 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
StackView {
id: stackView
clip: true
delegate: panUp
property int zoomDuration: 250
property int zoomDelta: 100
property real zoomedInRatio: Math.max(1, stackView.width + zoomDelta * units.devicePixelRatio) / stackView.width
property real zoomedOutRatio: Math.max(1, stackView.width - zoomDelta * units.devicePixelRatio) / stackView.width
readonly property var noTransition: StackViewDelegate {}
readonly property var panUp: StackViewDelegate {
pushTransition: StackViewTransition {
PropertyAnimation {
target: enterItem
property: "y"
from: stackView.height * (searchView.searchOnTop ? -1 : 1)
to: 0
}
PropertyAnimation {
target: exitItem
property: "opacity"
from: 1
to: 0
}
}
function transitionFinished(properties) {
properties.exitItem.opacity = 1
}
}
readonly property var zoomOut: StackViewDelegate {
function transitionFinished(properties) {
properties.exitItem.opacity = 1
properties.exitItem.scale = 1
}
pushTransition: StackViewTransition {
PropertyAnimation {
target: enterItem
property: "opacity"
easing.type: Easing.InQuad
from: 0
to: 1
duration: stackView.zoomDuration
}
PropertyAnimation {
target: exitItem
property: "opacity"
easing.type: Easing.InQuad
from: 1
to: 0
duration: stackView.zoomDuration
}
PropertyAnimation {
target: enterItem
property: "scale"
easing.type: Easing.Linear
from: stackView.zoomedInRatio
to: 1
duration: stackView.zoomDuration
}
PropertyAnimation {
target: exitItem
property: "scale"
easing.type: Easing.Linear
from: 1
to: stackView.zoomedOutRatio
duration: stackView.zoomDuration
}
}
}
readonly property var zoomIn: StackViewDelegate {
function transitionFinished(properties) {
properties.exitItem.opacity = 1
properties.exitItem.scale = 1
}
pushTransition: StackViewTransition {
PropertyAnimation {
target: enterItem
property: "opacity"
easing.type: Easing.InQuad
from: 0
to: 1
duration: stackView.zoomDuration
}
PropertyAnimation {
target: exitItem
property: "opacity"
easing.type: Easing.InQuad
from: 1
to: 0
duration: stackView.zoomDuration
}
PropertyAnimation {
target: enterItem
property: "scale"
easing.type: Easing.Linear
from: stackView.zoomedOutRatio
to: 1
duration: stackView.zoomDuration
}
PropertyAnimation {
target: exitItem
property: "scale"
easing.type: Easing.Linear
from: 1
to: stackView.zoomedInRatio
duration: stackView.zoomDuration
}
}
popTransition: pushTransition
}
}
Binary file not shown.
+166
View File
@@ -0,0 +1,166 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
import org.kde.kquickcontrolsaddons 2.0 // KCMShell
import "Utils.js" as Utils
Item {
id: searchView
width: config.leftSectionWidth
height: config.popupHeight
property alias searchResultsView: searchResultsView
property alias appsView: appsView
property alias tileEditorView: tileEditorViewLoader.item
property alias tileEditorViewLoader: tileEditorViewLoader
property alias searchField: searchField
property bool searchOnTop: false
states: [
State {
name: "searchOnTop"
when: searchOnTop
PropertyChanges {
target: stackViewContainer
anchors.topMargin: searchField.height
}
PropertyChanges {
target: searchField
anchors.top: searchField.parent.top
}
},
State {
name: "searchOnBottom"
when: !searchOnTop
PropertyChanges {
target: stackViewContainer
anchors.bottomMargin: searchField.height
}
PropertyChanges {
target: searchField
anchors.bottom: searchField.parent.bottom
}
}
]
SidebarView {
id: sidebarView
}
Item {
id: stackViewContainer
anchors.fill: parent
SearchResultsView {
id: searchResultsView
visible: false
Connections {
target: search
onQueryChanged: {
if (search.query.length > 0 && stackView.currentItem != searchResultsView) {
stackView.push(searchResultsView, true)
}
searchResultsView.filterViewOpen = false
}
}
onVisibleChanged: {
if (!visible) { // !stackView.currentItem
search.query = ""
}
}
function showDefaultSearch() {
if (stackView.currentItem != searchResultsView) {
stackView.push(searchResultsView, true)
}
search.applyDefaultFilters()
}
}
AppsView {
id: appsView
visible: false
function showAppsAlphabetically() {
appsModel.order = "alphabetical"
show()
}
function showAppsCategorically() {
appsModel.order = "categories"
show()
}
function show() {
if (stackView.currentItem != appsView) {
stackView.delegate = stackView.panUp
stackView.push({
item: appsView,
replace: true,
})
}
appsView.scrollToTop()
}
}
// TM3.Main {
// id: appsView
// // width: parent.width
// // height: parent.height
// function show() {
// if (stackView.currentItem != appsView) {
// stackView.push(appsView, true)
// }
// appsView.scrollToTop()
// }
// }
// Item {
// id: appsView
// }
Loader {
id: tileEditorViewLoader
source: "TileEditorView.qml"
visible: false
active: false
// asynchronous: true
function open(tile) {
active = true
item.open(tile)
}
}
SearchStackView {
id: stackView
width: config.appListWidth
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
initialItem: appsView
}
}
SearchField {
id: searchField
// width: 430
height: config.searchFieldHeight
anchors.leftMargin: config.sidebarWidth
anchors.left: parent.left
anchors.right: parent.right
listView: stackView.currentItem && stackView.currentItem.listView ? stackView.currentItem.listView : []
}
}
Binary file not shown.
+58
View File
@@ -0,0 +1,58 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
SidebarMenu {
id: sidebarContextMenu
visible: open
open: false
anchors.left: parent.right
anchors.bottom: parent.bottom
width: config.sidebarOpenWidth
height: childrenRect.height
z: 2
default property alias _contentChildren: content.data
Column {
id: content
width: parent.width
height: childrenRect.height
// We're using Column instead of ColumnLayout, so this isn't needed.
// Keeping it here in case Layout is used in the future.
// Workaround for crash when using default on a Layout.
// https://bugreports.qt.io/browse/QTBUG-52490
// Still affecting Qt 5.7.0
// Component.onDestruction: {
// while (children.length > 0) {
// children[children.length - 1].parent = page;
// }
// }
}
// onVisibleChanged: {
// if (sidebarContextMenu.visible) {
// sidebarContextMenu.focus = true
// }
// }
onFocusChanged: {
// console.log('sidebarContextMenu.onFocusChanged', focus)
if (!sidebarContextMenu.focus) {
sidebarContextMenu.open = false
}
}
onActiveFocusChanged: {
// console.log('sidebarContextMenu.onActiveFocusChanged', activeFocus)
if (!sidebarContextMenu.activeFocus) {
sidebarContextMenu.open = false
}
}
}
Binary file not shown.
+107
View File
@@ -0,0 +1,107 @@
import QtQuick 2.0
Repeater {
id: repeater
property int maxHeight: 1000000
property int numAvailable: maxHeight / config.flatButtonSize
property int minVisibleIndex: count - numAvailable // Hide items with an index smaller than this
delegate: SidebarItem {
icon: symbolicIconName || model.iconName || model.decoration
text: xdgDisplayName || model.name || model.display
sidebarMenu: repeater.parent.parent // SidebarContextMenu { Column { Repeater{} } }
onClicked: {
repeater.parent.parent.open = false // SidebarContextMenu { Column { Repeater{} } }
var xdgFolder = isLocalizedFolder()
if (xdgFolder === 'DOCUMENTS') {
executable.exec('xdg-open $(xdg-user-dir DOCUMENTS)')
} else if (xdgFolder === 'DOWNLOAD') {
executable.exec('xdg-open $(xdg-user-dir DOWNLOAD)')
} else if (xdgFolder === 'MUSIC') {
executable.exec('xdg-open $(xdg-user-dir MUSIC)')
} else if (xdgFolder === 'PICTURES') {
executable.exec('xdg-open $(xdg-user-dir PICTURES)')
} else if (xdgFolder === 'VIDEOS') {
executable.exec('xdg-open $(xdg-user-dir VIDEOS)')
} else {
repeater.model.triggerIndex(index)
}
}
visible: index >= minVisibleIndex
// These files are localize, so open them via commandline
// since Qt 5.7 doesn't expose the localized paths anywhere.
function isLocalizedFolder() {
var s = model.url.toString()
if (startsWith(s, 'xdg:')) {
s = s.substring('xdg:'.length, s.length)
if (s == 'DOCUMENTS'
|| s == 'DOWNLOAD'
|| s == 'MUSIC'
|| s == 'PICTURES'
|| s == 'VIDEOS'
) {
return s
}
}
return ''
}
function startsWith(s, sub) {
return s.indexOf(sub) === 0
}
function endsWith(s, sub) {
return s.indexOf(sub) === s.length - sub.length
}
property string xdgDisplayName: {
var xdgFolder = isLocalizedFolder()
if (xdgFolder) {
return xdgPathsLoader.displayName(xdgFolder)
} else {
return ''
}
}
property string symbolicIconName: {
if (model.url) {
var s = model.url.toString()
if (endsWith(s, '.desktop')) {
if (endsWith(s, '/org.kde.dolphin.desktop')) {
return 'folder-open-symbolic'
} else if (endsWith(s, '/systemsettings.desktop')) {
return 'configure'
}
} else if (startsWith(s, 'file:///home/')) {
s = s.substring('file:///home/'.length, s.length)
// console.log(model.url, s)
var trimIndex = s.indexOf('/')
if (trimIndex == -1) { // file:///home/username
s = ''
} else {
s = s.substring(trimIndex, s.length)
}
// console.log(model.url, s)
if (s === '') { // Home Directory
return 'user-home-symbolic'
}
} else if (startsWith(s, 'xdg:')) {
s = s.substring('xdg:'.length, s.length)
if (s === 'DOCUMENTS') {
return 'folder-documents-symbolic'
} else if (s === 'DOWNLOAD') {
return 'folder-download-symbolic'
} else if (s === 'MUSIC') {
return 'folder-music-symbolic'
} else if (s === 'PICTURES') {
return 'folder-pictures-symbolic'
} else if (s === 'VIDEOS') {
return 'folder-videos-symbolic'
}
}
}
return ""
}
}
}
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate
import QtQuick.Controls.Styles.Plasma 2.0 as PlasmaStyles
FlatButton {
width: parent.width
height: config.flatButtonSize
property var sidebarMenu: parent.parent // Column.SidebarMenu
property bool expanded: sidebarMenu ? sidebarMenu.open : false
labelVisible: expanded
property bool closeOnClick: true
onClicked: {
if (sidebarMenu.open && closeOnClick) {
sidebarMenu.open = false
}
}
}
Binary file not shown.
+14
View File
@@ -0,0 +1,14 @@
import QtQuick 2.0
Repeater {
id: repeater
delegate: SidebarItem {
icon: model.iconName || model.decoration
text: model.name || model.display
sidebarMenu: repeater.parent.parent // SidebarContextMenu { Column { Repeater{} } }
onClicked: {
repeater.parent.parent.open = false // SidebarContextMenu { Column { Repeater{} } }
repeater.model.triggerIndex(index)
}
}
}
Binary file not shown.
+51
View File
@@ -0,0 +1,51 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
MouseArea {
id: sidebarMenu
hoverEnabled: true
z: 1
// clip: true
width: open ? config.sidebarOpenWidth : config.sidebarWidth
property bool open: false
onOpenChanged: {
if (open) {
forceActiveFocus()
} else {
searchField.forceActiveFocus()
}
}
Rectangle {
anchors.fill: parent
visible: !plasmoid.configuration.sidebarFollowsTheme
color: config.sidebarBackgroundColor
opacity: parent.open ? 1 : 0.5
}
Rectangle {
anchors.fill: parent
visible: plasmoid.configuration.sidebarFollowsTheme
color: theme.backgroundColor
opacity: parent.open ? 1 : 0
}
PlasmaCore.FrameSvgItem {
anchors.fill: parent
visible: plasmoid.configuration.sidebarFollowsTheme
imagePath: "widgets/frame"
prefix: "raised"
}
property alias showDropShadow: sidebarMenuShadows.visible
SidebarMenuShadows {
id: sidebarMenuShadows
anchors.fill: parent
visible: !plasmoid.configuration.sidebarFollowsTheme && sidebarMenu.open
}
}
Binary file not shown.
+58
View File
@@ -0,0 +1,58 @@
import QtQuick 2.0
Item {
property int dropShadowSize: 4 * units.devicePixelRatio
property int roundShadowHack: dropShadowSize/2 // "dropShadowSize/2" draws enough to fool the eye.
Rectangle {
id: topShadow
anchors.left: parent.left
anchors.bottom: parent.top
width: parent.width + roundShadowHack
height: dropShadowSize
gradient: Gradient {
GradientStop { position: 0.0; color: "#00000000" }
GradientStop { position: 1.0; color: "#60000000" }
}
}
Rectangle {
id: rightShadow
anchors.bottom: parent.top
anchors.left: parent.right
height: dropShadowSize
width: parent.height
transformOrigin: Item.BottomLeft
rotation: 90
gradient: Gradient {
GradientStop { position: 0.0; color: "#00000000" }
GradientStop { position: 1.0; color: "#60000000" }
}
}
Rectangle {
id: bottomShadow
anchors.left: parent.left
anchors.top: parent.bottom
width: parent.width + roundShadowHack
height: dropShadowSize
gradient: Gradient {
GradientStop { position: 0.0; color: "#90000000" }
GradientStop { position: 1.0; color: "#00000000" }
}
}
Rectangle {
id: leftShadow
anchors.bottom: parent.top
anchors.left: parent.left
height: dropShadowSize
width: parent.height
transformOrigin: Item.BottomLeft
rotation: 90
gradient: Gradient {
GradientStop { position: 0.0; color: "#00000000" }
GradientStop { position: 1.0; color: "#20000000" }
}
}
}
Binary file not shown.
+155
View File
@@ -0,0 +1,155 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
import org.kde.kquickcontrolsaddons 2.0 // KCMShell
import "Utils.js" as Utils
Item {
id: sidebarView
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
z: 1
width: sidebarMenu.width
Behavior on width { NumberAnimation { duration: 100 } }
DragAndDrop.DropArea {
anchors.fill: sidebarMenu
onDrop: {
if (event && event.mimeData && event.mimeData.url) {
var url = event.mimeData.url.toString()
url = Utils.parseDropUrl(url)
appsModel.sidebarModel.addFavorite(url, 0)
}
}
}
SidebarMenu {
id: sidebarMenu
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
Column {
id: sidebarMenuTop
width: parent.width
height: childrenRect.height
SidebarItem {
iconName: 'open-menu-symbolic'
text: i18n("Menu")
closeOnClick: false
onClicked: sidebarMenu.open = !sidebarMenu.open
zoomOnPush: expanded
}
SidebarItem {
iconName: 'view-sort-ascending-symbolic'
text: i18n("Apps")
onClicked: appsView.showAppsAlphabetically()
// checked: stackView.currentItem == appsView
// checkedEdge: Qt.RightEdge
// checkedEdgeWidth: 4 * units.devicePixelRatio // Twice as thick as normal
}
SidebarItem {
iconName: 'view-list-tree'
text: i18n("Categories")
onClicked: appsView.showAppsCategorically()
// checked: stackView.currentItem == appsView
// checkedEdge: Qt.RightEdge
// checkedEdgeWidth: 4 * units.devicePixelRatio // Twice as thick as normal
}
// SidebarItem {
// iconName: 'system-search-symbolic'
// text: i18n("Search")
// onClicked: searchResultsView.showDefaultSearch()
// // checked: stackView.currentItem == searchResultsView
// // checkedEdge: Qt.RightEdge
// // checkedEdgeWidth: 4 * units.devicePixelRatio // Twice as thick as normal
// }
}
Column {
width: parent.width
height: childrenRect.height
anchors.bottom: parent.bottom
SidebarItem {
iconName: kuser.faceIconUrl ? kuser.faceIconUrl : 'user-identity'
text: kuser.fullName
onClicked: userMenu.open = !userMenu.open
SidebarContextMenu {
id: userMenu
SidebarItem {
iconName: 'system-users'
text: i18n("User Manager")
onClicked: KCMShell.open('user_manager')
visible: KCMShell.authorize('user_manager.desktop').length > 0
}
SidebarItemRepeater {
model: appsModel.sessionActionsModel
}
}
}
// Repeater {
// model: appsModel.sidebarModel
// onCountChanged: console.log(count, 'appsModel.sidebarModel', appsModel.sidebarModel)
// delegate: SidebarItem {
// }
// }
SidebarFavouritesView {
model: appsModel.sidebarModel
maxHeight: sidebarMenu.height - sidebarMenuTop.height - 2 * config.flatButtonSize
}
// SidebarItem {
// iconName: 'folder-open-symbolic'
// text: i18n("File Manager")
// onClicked: appsModel.launch('org.kde.dolphin')
// }
// SidebarItem {
// iconName: 'configure'
// text: i18n("Settings")
// onClicked: appsModel.launch('systemsettings')
// }
SidebarItem {
iconName: 'system-shutdown-symbolic'
text: i18n("Power")
onClicked: powerMenu.open = !powerMenu.open
SidebarContextMenu {
id: powerMenu
SidebarItemRepeater {
model: appsModel.powerActionsModel
}
}
}
}
onFocusChanged: {
logger.debug('searchView.onFocusChanged', focus)
if (!focus) {
open = false
}
}
}
}
Binary file not shown.
+56
View File
@@ -0,0 +1,56 @@
import QtQuick 2.0
Item {
id: tileData
property string configKey: 'tileData'
property variant value: { return {} }
property variant defaultValue: { return {} }
property bool writing: false
function set(obj) {
writing = true
setBase64Json(configKey, obj)
writing = false
}
function load() {
// console.log('plasmoid.configuration[key]', plasmoid.configuration[configKey])
value = getBase64Json(configKey, defaultValue)
// console.log(configKey, 'load()', value, defaultValue)
// console.log('discover', getTileData("org.kde.dolphin.desktop").label)
// console.log('discover', value["org.kde.dolphin.desktop"].label)
}
Connections {
target: plasmoid.configuration
onTileDataChanged: {
tileData.load()
}
}
Component.onCompleted: {
// console.log('tileData.value', value)
// console.log('tileData.defaultValue', defaultValue)
// console.log('plasmoid.configuration[key]', plasmoid.configuration[configKey])
tileData.load()
}
// function getTileData(url) {
// // console.log('getTileData', url.toString())
// // console.log('getTileData', url, value[url.toString()])
// var tile = value[url] || {}
// tile.x = tile.x || -1
// tile.y = tile.y || -1
// tile.size = tile.size || "2x2"
// tile.label = tile.label || ""
// return tile
// }
function setItemProperty(itemKey, key, value) {
var item = value[itemKey] || {}
item[key] = value
value[itemKey] = item
set(value)
valueChanged()
}
}
+95
View File
@@ -0,0 +1,95 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import "lib"
GroupBox {
id: tileEditorColorField
title: "Label"
implicitWidth: parent.implicitWidth
Layout.fillWidth: true
property alias placeholderText: textField.placeholderText
property alias enabled: textField.enabled
property string key: ''
style: GroupBoxStyle {}
RowLayout {
anchors.fill: parent
MouseArea {
id: mouseArea
width: textField.height
height: textField.height
hoverEnabled: true
onClicked: dialog.open()
Rectangle {
anchors.fill: parent
color: textField.text
border.width: 3
border.color: mouseArea.containsMouse ? theme.highlightColor : theme.backgroundColor
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: "transparent"
border.width: 1
border.color: mouseArea.containsMouse ? theme.highlightColor : theme.textColor
}
}
ColorDialog {
id: dialog
visible: false
// modality: Qt.WindowModal // Don't dim the menu
title: tileEditorColorField.title
showAlphaChannel: true
color: textField.text
onCurrentColorChanged: {
if (visible && color != currentColor) {
textField.text = currentColor
}
}
}
}
PlasmaComponents.TextField {
id: textField
Layout.fillWidth: true
text: key && appObj.tile && appObj.tile[key] ? appObj.tile[key] : ''
property bool updateOnChange: false
onTextChanged: {
if (key && updateOnChange) {
if (text) {
appObj.tile[key] = text
} else {
delete appObj.tile[key]
}
appObj.tileChanged()
tileGrid.tileModelChanged()
}
}
Connections {
target: appObj
onTileChanged: {
if (key && tile) {
textField.updateOnChange = false
textField.text = appObj.tile[key] || ''
textField.updateOnChange = true
}
}
}
}
}
}
Binary file not shown.
+88
View File
@@ -0,0 +1,88 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import QtQuick.Controls.Styles.Plasma 2.0 as PlasmaStyles
import "lib"
GroupBox {
id: tileEditorField
title: "Label"
Layout.fillWidth: true
property alias text: textField.text
property alias placeholderText: textField.placeholderText
property alias enabled: textField.enabled
property string key: ''
property string checkedKey: ''
checkable: checkedKey
property bool checkedDefault: true
property bool updateOnChange: false
onCheckedChanged: {
if (checkedKey && tileEditorField.updateOnChange) {
appObj.tile[checkedKey] = checked
appObj.tileChanged()
tileGrid.tileModelChanged()
}
}
default property alias _contentChildren: content.data
Connections {
target: appObj
onTileChanged: {
if (checkedKey && tile) {
tileEditorField.updateOnChange = false
tileEditorField.checked = typeof appObj.tile[checkedKey] !== "undefined" ? appObj.tile[checkedKey] : checkedDefault
tileEditorField.updateOnChange = true
}
}
}
style: PlasmaStyles.GroupBoxStyle {}
RowLayout {
id: content
anchors.left: parent.left
anchors.right: parent.right
PlasmaComponents.TextField {
id: textField
Layout.fillWidth: true
text: key && appObj.tile && appObj.tile[key] ? appObj.tile[key] : ''
property bool updateOnChange: false
onTextChanged: {
if (key && textField.updateOnChange) {
appObj.tile[key] = text
appObj.tileChanged()
tileGrid.tileModelChanged()
}
}
Connections {
target: appObj
onTileChanged: {
if (key && tile) {
textField.updateOnChange = false
textField.text = appObj.tile[key] || ''
textField.updateOnChange = true
}
}
}
}
Component.onDestruction: {
while (children.length > 0) {
children[children.length - 1].parent = tileEditorField
}
}
}
}
Binary file not shown.
+90
View File
@@ -0,0 +1,90 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import "lib"
GroupBox {
id: tileEditorRectField
title: "Label"
implicitWidth: parent.implicitWidth
Layout.fillWidth: true
// readonly property int xLeft: tileGrid.columns - (appObj.tileX + appObj.tileW)
style: GroupBoxStyle {}
RowLayout {
anchors.fill: parent
ColumnLayout {
Layout.fillWidth: true
RowLayout {
PlasmaComponents.Label { text: "x:" }
TileEditorSpinBox {
key: 'x'
minimumValue: 0
// maximumValue: tileGrid.columns - (appObj.tile && appObj.tile.w-1 || 0)
// maximumValue: appObj.tileX + tileEditorRectField.xLeft
}
}
RowLayout {
PlasmaComponents.Label { text: "y:" }
TileEditorSpinBox {
key: 'y'
minimumValue: 0
}
}
RowLayout {
PlasmaComponents.Label { text: "w:" }
TileEditorSpinBox {
key: 'w'
minimumValue: 1
// maximumValue: tileGrid.columns - (appObj.tile && appObj.tile.x || 0)
// maximumValue: appObj.tileW + tileEditorRectField.xLeft
}
}
RowLayout {
PlasmaComponents.Label { text: "h:" }
TileEditorSpinBox {
key: 'h'
minimumValue: 1
}
}
}
GridLayout {
id: resizeGrid
Layout.fillWidth: true
rows: 4
columns: 4
Repeater {
model: resizeGrid.rows * resizeGrid.columns
PlasmaComponents.Button {
Layout.fillWidth: true
implicitWidth: 20
property int w: (modelData % resizeGrid.columns) + 1
property int h: Math.floor(modelData / resizeGrid.columns) + 1
text: '' + w + 'x' + h
checked: w <= appObj.tileW && h <= appObj.tileH
// enabled: w - appObj.tileW <= tileEditorRectField.xLeft
onClicked: {
appObj.tile.w = w
appObj.tile.h = h
appObj.tileChanged()
tileGrid.tileModelChanged()
}
}
}
}
}
}
Binary file not shown.
+38
View File
@@ -0,0 +1,38 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
SpinBox {
id: spinBox
property string key: ''
Layout.fillWidth: true
implicitWidth: 20
Layout.minimumWidth: 20
value: appObj.tile && appObj.tile[key] || 0
property bool updateOnChange: false
onValueChanged: {
if (key && updateOnChange) {
appObj.tile[key] = value
appObj.tileChanged()
tileGrid.tileModelChanged()
}
}
Connections {
target: appObj
onTileChanged: {
if (key && tile) {
spinBox.updateOnChange = false
spinBox.value = appObj.tile[key] || 0
spinBox.updateOnChange = true
}
}
}
}
Binary file not shown.
+177
View File
@@ -0,0 +1,177 @@
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons
import "./config"
ColumnLayout {
id: tileEditorView
Layout.alignment: Qt.AlignTop
AppObject {
id: appObj
}
property alias tile: appObj.tile
function resetView() {
tile = null
}
function resetTile() {
delete appObj.tile.showIcon
delete appObj.tile.showLabel
delete appObj.tile.label
delete appObj.tile.icon
delete appObj.tile.backgroundColor
delete appObj.tile.backgroundImage
appObj.tileChanged()
tileGrid.tileModelChanged()
}
RowLayout {
PlasmaExtras.Heading {
Layout.fillWidth: true
level: 2
text: i18n("Edit Tile")
}
PlasmaComponents.Button {
text: i18n("Reset Tile")
onClicked: resetTile()
}
PlasmaComponents.Button {
text: i18n("Close")
onClicked: {
tileEditorView.close()
}
}
}
ScrollView {
id: scrollView
Layout.fillHeight: true
Layout.fillWidth: true
readonly property int viewportWidth: viewport ? viewport.width : 0
ColumnLayout {
id: scrollContent
width: scrollView.viewportWidth
TileEditorField {
visible: appObj.isLauncher
title: i18n("Url")
key: 'url'
}
TileEditorField {
id: labelField
title: i18n("Label")
placeholderText: appObj.appLabel
key: 'label'
checkedKey: 'showLabel'
}
TileEditorField {
id: iconField
title: i18n("Icon")
// placeholderText: appObj.appIcon ? appObj.appIcon.toString() : ''
key: 'icon'
checkedKey: 'showIcon'
checkedDefault: appObj.defaultShowIcon
PlasmaComponents.Button {
iconName: "document-open"
onClicked: iconDialog.open()
KQuickAddons.IconDialog {
id: iconDialog
onIconNameChanged: iconField.text = iconName
}
}
}
TileEditorField {
id: backgroundImageField
title: i18n("Background Image")
key: 'backgroundImage'
PlasmaComponents.Button {
iconName: 'document-open'
onClicked: imagePicker.open()
FileDialog {
id: imagePicker
title: i18n("Choose an image")
selectFolder: false
selectMultiple: false
nameFilters: [ i18n("Image Files (*.png *.jpg *.jpeg *.bmp *.svg *.svgz)") ]
onFileUrlChanged: {
backgroundImageField.text = fileUrl
if (fileUrl) {
labelField.checked = false
iconField.checked = false
}
}
}
}
}
TileEditorColorField {
title: i18n("Background Color")
placeholderText: config.defaultTileColor
key: 'backgroundColor'
}
TileEditorRectField {
title: i18n("Position / Size")
}
Item { // Consume the extra space below
Layout.fillHeight: true
}
}
}
function show() {
if (stackView.currentItem != tileEditorView) {
stackView.push(tileEditorView, true)
}
}
function open(tile) {
resetView()
tileEditorView.tile = tile
show()
}
function close() {
appsView.show()
}
Connections {
target: stackView
onCurrentItemChanged: {
if (stackView.currentItem != tileEditorView) {
tileEditorView.resetView()
}
}
}
}
Binary file not shown.
+527
View File
@@ -0,0 +1,527 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
import org.kde.plasma.private.kicker 0.1 as Kicker
import org.kde.kquickcontrolsaddons 2.0
// MouseArea {
DragAndDrop.DropArea {
id: tileGrid
// hoverEnabled: true
property bool isDragging: cellRepeater.dropping
property int cellSize: 60 * units.devicePixelRatio
property real cellMargin: 3 * units.devicePixelRatio
property real cellPushedMargin: 6 * units.devicePixelRatio
property int cellBoxSize: cellMargin + cellSize + cellMargin
property int hoverOutlineSize: 2 * units.devicePixelRatio
property int minColumns: Math.floor(width / cellBoxSize)
property int minRows: Math.floor(height / cellBoxSize)
property int maxColumn: 0
property int maxRow: 0
property int maxWidth: 0
property int maxHeight: 0
property int columns: Math.max(minColumns, maxColumn)
property int rows: Math.max(minRows, maxRow)
property var addedItem: null
readonly property bool adding: addedItem
property int draggedIndex: -1
readonly property var draggedItem: draggedIndex >= 0 ? tileModel[draggedIndex] : null
property bool editing: isDragging && draggedItem || adding
property int dropHoverX: -1
property int dropHoverY: -1
property int dropOffsetX: 0
property int dropOffsetY: 0
readonly property int dropWidth: draggedItem ? draggedItem.w : addedItem ? addedItem.w : 0
readonly property int dropHeight: draggedItem ? draggedItem.h : addedItem ? addedItem.h : 0
property bool canDrop: false
function resetDragHover() {
dropHoverX = -1
dropHoverY = -1
dropOffsetX = 0
dropOffsetY = 0
scrollUpArea.containsDrag = false
scrollDownArea.containsDrag = false
addedItem = null
}
function resetDrag() {
resetDragHover()
cellRepeater.dropping = false
draggedIndex = -1
}
function startDrag(index) {
draggedIndex = index
dropHoverX = draggedItem.x
dropHoverY = draggedItem.y
cellRepeater.dropping = true
}
onDrop: {
// console.log('onDrop', JSON.stringify(draggedItem))
if (draggedItem) {
draggedItem.x = dropHoverX
draggedItem.y = dropHoverY
tileGrid.tileModelChanged()
tileGrid.resetDrag()
// event.accept(Qt.MoveAction)
} else if (addedItem) {
addedItem.x = dropHoverX
addedItem.y = dropHoverY
tileGrid.tileModel.push(addedItem)
tileGrid.tileModelChanged()
tileGrid.resetDrag()
}
}
function parseDropUrl(url) {
var workingDir = Qt.resolvedUrl('.')
var endsWithDesktop = url.indexOf('.desktop') === url.length - '.desktop'.length
var isRelativeDesktopUrl = endsWithDesktop && (
url.indexOf(workingDir) === 0
// || url.indexOf('file:///usr/share/applications/') === 0
// || url.indexOf('/.local/share/applications/') >= 0
|| url.indexOf('/share/applications/') >= 0 // 99% certain this desktop file should be accessed relatively.
)
logger.debug('parseDropUrl', workingDir, endsWithDesktop, isRelativeDesktopUrl)
logger.debug('onUrlDropped', 'url', url)
if (isRelativeDesktopUrl) {
// Remove the path because .favoriteId is just the file name.
// However passing the favoriteId in mimeData.url will prefix the current QML path because it's a QUrl.
var tokens = url.toString().split('/')
var favoriteId = tokens[tokens.length-1]
logger.debug('isRelativeDesktopUrl', tokens, favoriteId)
return favoriteId
} else {
return url
}
}
function dragTick(event) {
var dragX = event.x + scrollView.flickableItem.contentX - dropOffsetX
var dragY = event.y + scrollView.flickableItem.contentY - dropOffsetY
var modelX = Math.floor(dragX / cellBoxSize)
var modelY = Math.floor(dragY / cellBoxSize)
// console.log('onDragMove', event.x, event.y, modelX, modelY)
scrollUpArea.checkContains(event)
scrollDownArea.checkContains(event)
if (draggedItem) {
} else if (addedItem) {
} else if (event && event.mimeData && event.mimeData.url) {
var url = event.mimeData.url.toString()
// console.log('new addedItem', event.mimeData.url, url)
url = parseDropUrl(url)
addedItem = newTile(url)
dropHoverX = modelX
dropHoverY = modelY
} else {
return
}
dropHoverX = Math.max(0, Math.min(modelX, columns - dropWidth))
dropHoverY = Math.max(0, modelY)
canDrop = !hits(dropHoverX, dropHoverY, dropWidth, dropHeight)
}
onDragEnter: dragTick(event)
onDragMove: dragTick(event)
onDragLeave: {
// console.log('onExited')
resetDragHover()
}
property var hitBox: [] // hitBox[y][x]
function updateSize() {
var c = 0;
var r = 0;
var w = 1;
var h = 1;
for (var i = 0; i < tileModel.length; i++) {
var tile = tileModel[i]
c = Math.max(c, tile.x + tile.w)
r = Math.max(r, tile.y + tile.h)
w = Math.max(w, tile.w)
h = Math.max(h, tile.h)
}
// Add extra rows when dragging so we can drop scrolled down
if (draggedItem) {
// c += draggedItem.w
r += draggedItem.h
}
// Rebuild hitBox
var hbColumns = Math.max(minColumns, c)
var hbRows = Math.max(minRows, r)
var hb = new Array(hbRows)
for (var i = 0; i < hbRows; i++) {
hb[i] = new Array(hbColumns)
}
for (var i = 0; i < tileModel.length; i++) {
var tile = tileModel[i]
if (i == draggedIndex) {
continue;
}
for (var j = tile.y; j < tile.y + tile.h; j++) {
for (var k = tile.x; k < tile.x + tile.w; k++) {
hb[j][k] = true
}
}
}
// Update Properties
hitBox = hb
maxColumn = c
maxRow = r
maxWidth = w
maxHeight = h
}
function update() {
var urlList = []
for (var i = 0; i < tileModel.length; i++) {
var tile = tileModel[i]
if (tile.url) {
urlList.push(tile.url)
}
}
appsModel.tileGridModel.favorites = urlList
updateSize()
}
onDraggedItemChanged: update()
onTileModelChanged: update()
property var tileModel: []
function hits(x, y, w, h) {
// console.log('hits', [columns,rows], [x,y,w,h], hitBox)
for (var j = y; j < y + h; j++) {
if (j < 0 || j >= hitBox.length) {
continue; // Should we return true when out of bounds?
}
for (var k = x; k < x + w; k++) {
if (k < 0 || k >= hitBox[j].length) {
continue; // Should we return true when out of bounds?
}
if (hitBox[j][k]) {
return true
}
}
}
return false
}
ScrollView {
id: scrollView
anchors.fill: parent
readonly property int scrollTop: flickableItem ? flickableItem.contentY : 0
readonly property int scrollHeight: flickableItem ? flickableItem.contentHeight : 0
readonly property int scrollTopAtBottom: viewport ? scrollHeight - viewport.height : 0
readonly property bool scrollAtTop: scrollTop == 0
readonly property bool scrollAtBottom: scrollTop >= scrollTopAtBottom
function scrollBy(deltaY) {
if (flickableItem) {
// console.log('scrollHeight', scrollTopAtBottom, scrollHeight, viewport.height)
flickableItem.contentY = Math.max(0, Math.min(scrollTop + deltaY, scrollTopAtBottom))
}
}
__wheelAreaScrollSpeed: cellBoxSize
style: ScrollViewStyle {
transientScrollBars: true
}
Item {
id: scrollItem
width: columns * cellBoxSize
height: rows * cellBoxSize
// Rectangle {
// anchors.fill: parent
// color: "#88336699"
// }
Repeater {
id: cellRepeater
property int cellCount: columns * rows
property bool dropping: false
onCellCountChanged: {
if (!dropping) {
model = cellCount
}
}
model: 0
Item {
id: cellItem
property int modelX: modelData % columns
property int modelY: Math.floor(modelData / columns)
x: modelX * cellBoxSize
y: modelY * cellBoxSize
width: cellBoxSize
height: cellBoxSize
property bool hovered: {
if (tileGrid.editing && dropHoverX >= 0 && dropHoverY >= 0) {
return dropHoverX <= modelX && modelX < dropHoverX + dropWidth && dropHoverY <= modelY && modelY < dropHoverY + dropHeight
} else {
return false
}
}
Rectangle {
anchors.fill: parent
anchors.margins: cellMargin
color: {
if (cellItem.hovered) {
if (canDrop) {
return "#88336699"
} else {
return "#88880000"
}
} else {
return "transparent"
}
}
border.width: 1
border.color: tileGrid.editing ? "#44000000" : "transparent"
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
if (mouse.button == Qt.RightButton) {
cellContextMenu.cellX = cellItem.modelX
cellContextMenu.cellY = cellItem.modelY
var pos = mapToItem(scrollItem, mouse.x, mouse.y) // cellContextMenu is a child of scrollItem
cellContextMenu.open(pos.x, pos.y)
}
}
}
}
}
PlasmaComponents.ContextMenu {
id: cellContextMenu
property int cellX: -1
property int cellY: -1
PlasmaComponents.MenuItem {
icon: "group-new"
text: i18n("New Group")
visible: !plasmoid.configuration.tilesLocked
onClicked: {
var tile = tileGrid.addGroup(cellContextMenu.cellX, cellContextMenu.cellY)
tileGrid.editTile(tile)
}
}
PlasmaComponents.MenuItem {
icon: plasmoid.configuration.tilesLocked ? "object-unlocked" : "object-locked"
text: plasmoid.configuration.tilesLocked ? i18n("Unlock Tiles") : i18n("Lock Tiles")
onClicked: {
plasmoid.configuration.tilesLocked = !plasmoid.configuration.tilesLocked
}
}
}
Repeater {
id: tileModelRepeater
model: tileModel
// onCountChanged: console.log('onCountChanged', count)
TileItem {
id: tileItem
}
}
}
}
/* Scroll on hover with drag */
property int scrollAreaTickDelta: cellBoxSize
property int scrollAreaTickInterval: 200
property int scrollAreaSize: Math.min(cellBoxSize * 1.5, scrollView.height / 5) // 20vh or 90pt
Item {
id: scrollUpArea
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: scrollAreaSize
property bool active: !scrollView.scrollAtTop
property bool containsDrag: false
property bool ticking: active && containsDrag
function checkContains(event) {
containsDrag = scrollUpArea.contains(Qt.point(event.x, event.y))
}
Timer {
id: scrollUpTicker
interval: scrollAreaTickInterval
repeat: true
running: parent.ticking
onTriggered: {
scrollView.scrollBy(-scrollAreaTickDelta)
}
}
Rectangle {
anchors.fill: parent
opacity: parent.ticking ? 1 : 0
gradient: Gradient {
GradientStop { position: 0.0; color: theme.highlightColor }
GradientStop { position: 0.3; color: "transparent" }
}
}
}
Item {
id: scrollDownArea
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: scrollAreaSize
property bool active: !scrollView.scrollAtBottom
property bool containsDrag: false
property bool ticking: active && containsDrag
function checkContains(event) {
var mouseY = event.y - (parent.height - height)
containsDrag = scrollDownArea.contains(Qt.point(event.x, mouseY))
}
Timer {
id: scrollDownTicker
interval: scrollAreaTickInterval
repeat: true
running: parent.ticking
onTriggered: {
scrollView.scrollBy(scrollAreaTickDelta)
}
}
Rectangle {
anchors.fill: parent
opacity: parent.ticking ? 1 : 0
gradient: Gradient {
GradientStop { position: 0.7; color: "transparent" }
GradientStop { position: 1.0; color: theme.highlightColor }
}
}
}
function newTile(url) {
return {
"x": 0,
"y": 0,
"w": 2,
"h": 2,
"url": url,
}
}
function removeIndex(i) {
tileModel.splice(i, 1) // remove 1 item at index
tileModelChanged()
}
function removeApp(url) {
var removedCount = 0
for (var i = tileModel.length - 1; i >= 0; i--) {
var tile = tileModel[i]
if (tile.url == url) {
removedCount += 1
tileModel.splice(i, 1) // remove 1 item at index
}
}
if (removedCount > 0) {
tileModelChanged()
}
}
function addTile(tile) {
tileModel.push(tile)
tileModelChanged()
}
function findOpenPos(w, h) {
for (var y = 0; y < rows; y++) {
for (var x = 0; x < columns - (w-1); x++) {
if (hits(x, y, w, h))
continue
// Room open for
return {
x: x,
y: y,
}
}
}
// Current grid has no room.
// Add to new row.
return {
x: 0,
y: rows
}
}
function parseTileXY(tile, x, y) {
if (typeof x !== "undefined" && typeof y !== "undefined") {
tile.x = x
tile.y = y
} else {
var openPos = findOpenPos(tile.w, tile.h)
tile.x = openPos.x
tile.y = openPos.y
}
}
function addApp(url, x, y) {
var tile = newTile(url)
parseTileXY(tile, x, y)
tileModel.push(tile)
tileModelChanged()
return tile
}
function hasAppTile(url) {
for (var i = 0; i < tileModel.length; i++) {
var tile = tileModel[i]
if (tile.url == url) {
return true
}
}
return false
}
function limit(minValue, value, maxValue) {
return Math.max(minValue, Math.min(value, maxValue))
}
function addGroup(x, y) {
var tile = newTile("")
parseTileXY(tile, x, y)
tile.tileType = "group"
tile.label = i18nc("default group label", "Group")
tile.w = limit(2, columns-x, 6) // 6 unless we have less columns.
tile.h = 1
tileModel.push(tile)
tileModelChanged()
return tile
}
signal editTile(var tile)
}
Binary file not shown.
+121
View File
@@ -0,0 +1,121 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
import QtGraphicalEffects 1.0
Item {
id: tileItem
x: modelData.x * cellBoxSize
y: modelData.y * cellBoxSize
width: modelData.w * cellBoxSize
height: modelData.h * cellBoxSize
AppObject {
id: appObj
tile: modelData
}
readonly property alias app: appObj.app
readonly property bool faded: tileGrid.editing || tileMouseArea.isLeftPressed
readonly property int fadedWidth: width - cellPushedMargin
opacity: faded ? 0.75 : 1
scale: faded ? fadedWidth / width : 1
Behavior on opacity { NumberAnimation { duration: 200 } }
Behavior on scale { NumberAnimation { duration: 200 } }
//--- View Start
TileItemView {
id: tileItemView
anchors.fill: parent
anchors.margins: cellMargin
width: modelData.w * cellBoxSize
height: modelData.h * cellBoxSize
readonly property int minSize: Math.min(width, height)
hovered: tileMouseArea.containsMouse
}
HoverOutlineEffect {
id: hoverOutlineEffect
anchors.fill: parent
anchors.margins: cellMargin
hoverRadius: tileItemView.minSize
hoverOutlineSize: tileGrid.hoverOutlineSize
property alias control: tileMouseArea
}
//--- View End
DragAndDrop.DragArea {
anchors.fill: parent
enabled: !plasmoid.configuration.tilesLocked
delegate: tileItemView
onDragStarted: {
console.log('onDragStarted', JSON.stringify(modelData), index, tileModel.length)
// tileGrid.draggedItem = tileModel.splice(index, 1)[0]
tileGrid.startDrag(index)
tileGrid.dropOffsetX = Math.floor(tileMouseArea.mouseX / cellBoxSize) * cellBoxSize
tileGrid.dropOffsetY = Math.floor(tileMouseArea.mouseY / cellBoxSize) * cellBoxSize
}
onDrop: {
console.log('DragArea.onDrop', draggedItem)
tileGrid.resetDrag()
}
MouseArea {
id: tileMouseArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
cursorShape: editing ? Qt.ClosedHandCursor : Qt.ArrowCursor
readonly property bool isLeftPressed: pressedButtons & Qt.LeftButton
// This MouseArea will spam "QQuickItem::ungrabMouse(): Item is not the mouse grabber."
// but there's no other way of having a clickable drag area.
onClicked: {
mouse.accepted = true
if (mouse.button == Qt.LeftButton) {
if (tileEditorView && tileEditorView.tile) {
openTileEditor()
} else {
appsModel.tileGridModel.runApp(modelData.url)
}
} else if (mouse.button == Qt.RightButton) {
contextMenu.open(mouse.x, mouse.y)
}
}
}
}
AppContextMenu {
id: contextMenu
tileIndex: index
onPopulateMenu: {
if (!plasmoid.configuration.tilesLocked) {
menu.addPinToMenuAction(modelData.url)
}
appObj.addActionList(menu)
if (!plasmoid.configuration.tilesLocked) {
var menuItem = menu.newMenuItem()
menuItem.text = i18n("Edit Tile")
menuItem.icon = 'rectangle-shape'
menuItem.onClicked.connect(function(){
tileItem.openTileEditor()
})
}
}
}
function openTileEditor() {
tileGrid.editTile(tileGrid.tileModel[index])
}
function closeTileEditor() {
}
}
Binary file not shown.
+96
View File
@@ -0,0 +1,96 @@
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.draganddrop 2.0 as DragAndDrop
Rectangle {
id: tileItemView
color: appObj.backgroundColor
readonly property int smallIconSize: 32 * units.devicePixelRatio
readonly property int mediumIconSize: 72 * units.devicePixelRatio
readonly property int largeIconSize: 96 * units.devicePixelRatio
readonly property int tileLabelAlignment: config.tileLabelAlignment
property bool hovered: false
states: [
State {
when: modelData.w == 1 && modelData.h >= 1
PropertyChanges { target: icon; size: smallIconSize }
PropertyChanges { target: label; visible: false }
},
State {
when: modelData.w >= 2 && modelData.h == 1
AnchorChanges { target: icon
anchors.horizontalCenter: undefined
anchors.left: tileItemView.left
}
PropertyChanges { target: icon; anchors.leftMargin: 4 }
AnchorChanges { target: label
anchors.verticalCenter: tileItemView.verticalCenter
anchors.left: icon.right
anchors.bottom: undefined
anchors.right: tileItemView.right
}
},
State {
when: modelData.w == 2 && modelData.h == 2
PropertyChanges { target: icon; size: mediumIconSize }
},
State {
when: modelData.w == 4 && modelData.h == 2
PropertyChanges { target: icon; size: mediumIconSize }
},
State {
when: modelData.w == 4 && modelData.h == 4
PropertyChanges { target: icon; size: largeIconSize }
}
]
Image {
id: backgroundImage
anchors.fill: parent
visible: appObj.backgroundImage
source: appObj.backgroundImage
fillMode: Image.PreserveAspectCrop
asynchronous: true
}
PlasmaCore.IconItem {
id: icon
visible: appObj.showIcon
source: appObj.iconSource
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
// property int size: 72 // Just a default, overriden in State change
property int size: Math.min(parent.width, parent.height) / 2
width: appObj.showIcon ? size : 0
height: appObj.showIcon ? size : 0
anchors.fill: appObj.iconFill ? parent : null
smooth: appObj.iconFill
}
PlasmaComponents.Label {
id: label
visible: appObj.showLabel
text: appObj.labelText
anchors.leftMargin: 4
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 4
wrapMode: Text.Wrap
horizontalAlignment: tileLabelAlignment
width: parent.width
font.pointSize: 10
renderType: Text.QtRendering // Fix pixelation when scaling. Plasma.Label uses NativeRendering.
style: Text.Outline
styleColor: tileItemView.color
}
}
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
.pragma library
function parseDropUrl(url) {
var workingDir = Qt.resolvedUrl('.')
var endsWithDesktop = url.indexOf('.desktop') === url.length - '.desktop'.length
var isRelativeDesktopUrl = endsWithDesktop && (
url.indexOf(workingDir) === 0
// || url.indexOf('file:///usr/share/applications/') === 0
// || url.indexOf('/.local/share/applications/') >= 0
|| url.indexOf('/share/applications/') >= 0 // 99% certain this desktop file should be accessed relatively.
)
// logger.debug('parseDropUrl', workingDir, endsWithDesktop, isRelativeDesktopUrl)
// logger.debug('onUrlDropped', 'url', url)
if (isRelativeDesktopUrl) {
// Remove the path because .favoriteId is just the file name.
// However passing the favoriteId in mimeData.url will prefix the current QML path because it's a QUrl.
var tokens = url.toString().split('/')
var favoriteId = tokens[tokens.length-1]
// logger.debug('isRelativeDesktopUrl', tokens, favoriteId)
return favoriteId
} else {
return url
}
}
Binary file not shown.
Loaded 100 of 144 files, more files were not shown because too many files have changed in this diff. Show more