mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-15 02:02:08 -04:00
fix loading of spotlight
This commit is contained in:
@@ -8,6 +8,7 @@ PanelWindow {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property alias content: contentLoader.sourceComponent
|
property alias content: contentLoader.sourceComponent
|
||||||
|
property alias contentLoader: contentLoader
|
||||||
property real width: 400
|
property real width: 400
|
||||||
property real height: 300
|
property real height: 300
|
||||||
readonly property real screenWidth: screen ? screen.width : 1920
|
readonly property real screenWidth: screen ? screen.width : 1920
|
||||||
|
|||||||
@@ -13,47 +13,41 @@ DankModal {
|
|||||||
id: spotlightModal
|
id: spotlightModal
|
||||||
|
|
||||||
property bool spotlightOpen: false
|
property bool spotlightOpen: false
|
||||||
|
property Component spotlightContent
|
||||||
|
|
||||||
function show() {
|
spotlightContent: Component {
|
||||||
|
Item {
|
||||||
|
id: spotlightKeyHandler
|
||||||
|
|
||||||
spotlightOpen = true
|
property alias appLauncher: appLauncher
|
||||||
|
property alias searchField: searchField
|
||||||
|
|
||||||
appLauncher.searchQuery = ""
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
|
Keys.onPressed: function(event) {
|
||||||
|
if (event.key === Qt.Key_Escape) {
|
||||||
|
hide();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Down) {
|
||||||
|
appLauncher.selectNext();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Up) {
|
||||||
|
appLauncher.selectPrevious();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Right && appLauncher.viewMode === "grid") {
|
||||||
|
appLauncher.selectNextInRow();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Left && appLauncher.viewMode === "grid") {
|
||||||
|
appLauncher.selectPreviousInRow();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
||||||
|
appLauncher.launchSelected();
|
||||||
|
event.accepted = true;
|
||||||
|
} else if (!searchField.activeFocus && event.text && event.text.length > 0 && event.text.match(/[a-zA-Z0-9\\s]/)) {
|
||||||
|
searchField.forceActiveFocus();
|
||||||
|
searchField.insertText(event.text);
|
||||||
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
|
||||||
spotlightOpen = false
|
|
||||||
appLauncher.searchQuery = ""
|
|
||||||
appLauncher.selectedIndex = 0
|
|
||||||
appLauncher.setCategory("All")
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggle() {
|
|
||||||
if (spotlightOpen)
|
|
||||||
hide()
|
|
||||||
else
|
|
||||||
show()
|
|
||||||
}
|
|
||||||
|
|
||||||
visible: spotlightOpen
|
|
||||||
width: 550
|
|
||||||
height: 600
|
|
||||||
keyboardFocus: "ondemand"
|
|
||||||
backgroundColor: Theme.popupBackground()
|
|
||||||
cornerRadius: Theme.cornerRadius
|
|
||||||
borderColor: Theme.outlineMedium
|
|
||||||
borderWidth: 1
|
|
||||||
enableShadow: true
|
|
||||||
onVisibleChanged: {
|
|
||||||
|
|
||||||
if (visible && !spotlightOpen)
|
|
||||||
show()
|
|
||||||
}
|
|
||||||
onBackgroundClicked: {
|
|
||||||
spotlightOpen = false
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLauncher {
|
AppLauncher {
|
||||||
@@ -62,66 +56,8 @@ DankModal {
|
|||||||
viewMode: SettingsData.spotlightModalViewMode
|
viewMode: SettingsData.spotlightModalViewMode
|
||||||
gridColumns: 4
|
gridColumns: 4
|
||||||
onAppLaunched: hide()
|
onAppLaunched: hide()
|
||||||
onViewModeSelected: function (mode) {
|
onViewModeSelected: function(mode) {
|
||||||
SettingsData.setSpotlightModalViewMode(mode)
|
SettingsData.setSpotlightModalViewMode(mode);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IpcHandler {
|
|
||||||
function open() {
|
|
||||||
|
|
||||||
spotlightModal.show()
|
|
||||||
return "SPOTLIGHT_OPEN_SUCCESS"
|
|
||||||
}
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
|
|
||||||
spotlightModal.hide()
|
|
||||||
return "SPOTLIGHT_CLOSE_SUCCESS"
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggle() {
|
|
||||||
|
|
||||||
spotlightModal.toggle()
|
|
||||||
return "SPOTLIGHT_TOGGLE_SUCCESS"
|
|
||||||
}
|
|
||||||
|
|
||||||
target: "spotlight"
|
|
||||||
}
|
|
||||||
|
|
||||||
property Component spotlightContent: Component {
|
|
||||||
Item {
|
|
||||||
id: spotlightKeyHandler
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
focus: true
|
|
||||||
Keys.onPressed: function (event) {
|
|
||||||
if (event.key === Qt.Key_Escape) {
|
|
||||||
hide()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Down) {
|
|
||||||
appLauncher.selectNext()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Up) {
|
|
||||||
appLauncher.selectPrevious()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Right
|
|
||||||
&& appLauncher.viewMode === "grid") {
|
|
||||||
appLauncher.selectNextInRow()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Left
|
|
||||||
&& appLauncher.viewMode === "grid") {
|
|
||||||
appLauncher.selectPreviousInRow()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
|
||||||
appLauncher.launchSelected()
|
|
||||||
event.accepted = true
|
|
||||||
} else if (!searchField.activeFocus && event.text
|
|
||||||
&& event.text.length > 0 && event.text.match(
|
|
||||||
/[a-zA-Z0-9\\s]/)) {
|
|
||||||
searchField.forceActiveFocus()
|
|
||||||
searchField.insertText(event.text)
|
|
||||||
event.accepted = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,8 +73,7 @@ DankModal {
|
|||||||
color: Theme.surfaceVariantAlpha
|
color: Theme.surfaceVariantAlpha
|
||||||
border.color: Theme.outlineMedium
|
border.color: Theme.outlineMedium
|
||||||
border.width: 1
|
border.width: 1
|
||||||
visible: appLauncher.categories.length > 1
|
visible: appLauncher.categories.length > 1 || appLauncher.model.count > 0
|
||||||
|| appLauncher.model.count > 0
|
|
||||||
|
|
||||||
CategorySelector {
|
CategorySelector {
|
||||||
id: categorySelector
|
id: categorySelector
|
||||||
@@ -148,10 +83,11 @@ DankModal {
|
|||||||
categories: appLauncher.categories
|
categories: appLauncher.categories
|
||||||
selectedCategory: appLauncher.selectedCategory
|
selectedCategory: appLauncher.selectedCategory
|
||||||
compact: false
|
compact: false
|
||||||
onCategorySelected: category => {
|
onCategorySelected: (category) => {
|
||||||
return appLauncher.setCategory(category)
|
return appLauncher.setCategory(category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
@@ -164,10 +100,7 @@ DankModal {
|
|||||||
width: parent.width - 80 - Theme.spacingM // Leave space for view toggle buttons
|
width: parent.width - 80 - Theme.spacingM // Leave space for view toggle buttons
|
||||||
height: 56
|
height: 56
|
||||||
cornerRadius: Theme.cornerRadius
|
cornerRadius: Theme.cornerRadius
|
||||||
backgroundColor: Qt.rgba(Theme.surfaceVariant.r,
|
backgroundColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, Theme.getContentBackgroundAlpha() * 0.7)
|
||||||
Theme.surfaceVariant.g,
|
|
||||||
Theme.surfaceVariant.b,
|
|
||||||
Theme.getContentBackgroundAlpha() * 0.7)
|
|
||||||
normalBorderColor: Theme.outlineMedium
|
normalBorderColor: Theme.outlineMedium
|
||||||
focusedBorderColor: Theme.primary
|
focusedBorderColor: Theme.primary
|
||||||
leftIconName: "search"
|
leftIconName: "search"
|
||||||
@@ -183,39 +116,24 @@ DankModal {
|
|||||||
keyForwardTargets: [spotlightKeyHandler]
|
keyForwardTargets: [spotlightKeyHandler]
|
||||||
text: appLauncher.searchQuery
|
text: appLauncher.searchQuery
|
||||||
onTextEdited: {
|
onTextEdited: {
|
||||||
appLauncher.searchQuery = text
|
appLauncher.searchQuery = text;
|
||||||
}
|
}
|
||||||
Keys.onPressed: event => {
|
Keys.onPressed: (event) => {
|
||||||
if (event.key === Qt.Key_Escape) {
|
if (event.key === Qt.Key_Escape) {
|
||||||
hide()
|
hide();
|
||||||
event.accepted = true
|
event.accepted = true;
|
||||||
} else if ((event.key === Qt.Key_Return
|
} else if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && text.length > 0) {
|
||||||
|| event.key === Qt.Key_Enter)
|
if (appLauncher.keyboardNavigationActive && appLauncher.model.count > 0)
|
||||||
&& text.length > 0) {
|
appLauncher.launchSelected();
|
||||||
if (appLauncher.keyboardNavigationActive
|
|
||||||
&& appLauncher.model.count > 0)
|
|
||||||
appLauncher.launchSelected()
|
|
||||||
else if (appLauncher.model.count > 0)
|
else if (appLauncher.model.count > 0)
|
||||||
appLauncher.launchApp(appLauncher.model.get(0))
|
appLauncher.launchApp(appLauncher.model.get(0));
|
||||||
event.accepted = true
|
event.accepted = true;
|
||||||
} else if (event.key === Qt.Key_Down || event.key
|
} else if (event.key === Qt.Key_Down || event.key === Qt.Key_Up || event.key === Qt.Key_Left || event.key === Qt.Key_Right || ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && text.length === 0)) {
|
||||||
=== Qt.Key_Up || event.key === Qt.Key_Left || event.key
|
event.accepted = false;
|
||||||
=== Qt.Key_Right || ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && text.length === 0)) {
|
|
||||||
event.accepted = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
function onSpotlightOpenChanged() {
|
|
||||||
if (spotlightModal.spotlightOpen) {
|
|
||||||
Qt.callLater(function () {
|
|
||||||
searchField.forceActiveFocus()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target: spotlightModal
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
@@ -245,9 +163,10 @@ DankModal {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
appLauncher.setViewMode("list")
|
appLauncher.setViewMode("list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -272,11 +191,14 @@ DankModal {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
appLauncher.setViewMode("grid")
|
appLauncher.setViewMode("grid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -299,21 +221,21 @@ DankModal {
|
|||||||
property bool hoverUpdatesSelection: false
|
property bool hoverUpdatesSelection: false
|
||||||
property bool keyboardNavigationActive: appLauncher.keyboardNavigationActive
|
property bool keyboardNavigationActive: appLauncher.keyboardNavigationActive
|
||||||
|
|
||||||
signal keyboardNavigationReset
|
signal keyboardNavigationReset()
|
||||||
signal itemClicked(int index, var modelData)
|
signal itemClicked(int index, var modelData)
|
||||||
signal itemHovered(int index)
|
signal itemHovered(int index)
|
||||||
signal itemRightClicked(int index, var modelData, real mouseX, real mouseY)
|
signal itemRightClicked(int index, var modelData, real mouseX, real mouseY)
|
||||||
|
|
||||||
function ensureVisible(index) {
|
function ensureVisible(index) {
|
||||||
if (index < 0 || index >= count)
|
if (index < 0 || index >= count)
|
||||||
return
|
return ;
|
||||||
|
|
||||||
var itemY = index * (itemHeight + itemSpacing)
|
var itemY = index * (itemHeight + itemSpacing);
|
||||||
var itemBottom = itemY + itemHeight
|
var itemBottom = itemY + itemHeight;
|
||||||
if (itemY < contentY)
|
if (itemY < contentY)
|
||||||
contentY = itemY
|
contentY = itemY;
|
||||||
else if (itemBottom > contentY + height)
|
else if (itemBottom > contentY + height)
|
||||||
contentY = itemBottom - height
|
contentY = itemBottom - height;
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -327,23 +249,22 @@ DankModal {
|
|||||||
interactive: true
|
interactive: true
|
||||||
cacheBuffer: Math.max(0, Math.min(height * 2, 1000))
|
cacheBuffer: Math.max(0, Math.min(height * 2, 1000))
|
||||||
reuseItems: true
|
reuseItems: true
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (keyboardNavigationActive)
|
if (keyboardNavigationActive)
|
||||||
ensureVisible(currentIndex)
|
ensureVisible(currentIndex);
|
||||||
}
|
|
||||||
|
|
||||||
onItemClicked: function (index, modelData) {
|
|
||||||
appLauncher.launchApp(modelData)
|
|
||||||
}
|
}
|
||||||
onItemHovered: function (index) {
|
onItemClicked: function(index, modelData) {
|
||||||
appLauncher.selectedIndex = index
|
appLauncher.launchApp(modelData);
|
||||||
}
|
}
|
||||||
onItemRightClicked: function (index, modelData, mouseX, mouseY) {
|
onItemHovered: function(index) {
|
||||||
contextMenu.show(mouseX, mouseY, modelData)
|
appLauncher.selectedIndex = index;
|
||||||
|
}
|
||||||
|
onItemRightClicked: function(index, modelData, mouseX, mouseY) {
|
||||||
|
contextMenu.show(mouseX, mouseY, modelData);
|
||||||
}
|
}
|
||||||
onKeyboardNavigationReset: {
|
onKeyboardNavigationReset: {
|
||||||
appLauncher.keyboardNavigationActive = false
|
appLauncher.keyboardNavigationActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
@@ -376,9 +297,7 @@ DankModal {
|
|||||||
id: listIconImg
|
id: listIconImg
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: (model.icon) ? Quickshell.iconPath(
|
source: (model.icon) ? Quickshell.iconPath(model.icon, SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) : ""
|
||||||
model.icon,
|
|
||||||
SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) : ""
|
|
||||||
smooth: true
|
smooth: true
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
visible: status === Image.Ready
|
visible: status === Image.Ready
|
||||||
@@ -394,15 +313,14 @@ DankModal {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: (model.name
|
text: (model.name && model.name.length > 0) ? model.name.charAt(0).toUpperCase() : "A"
|
||||||
&& model.name.length > 0) ? model.name.charAt(
|
|
||||||
0).toUpperCase(
|
|
||||||
) : "A"
|
|
||||||
font.pixelSize: resultsList.iconSize * 0.4
|
font.pixelSize: resultsList.iconSize * 0.4
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -425,10 +343,11 @@ DankModal {
|
|||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
visible: resultsList.showDescription && model.comment
|
visible: resultsList.showDescription && model.comment && model.comment.length > 0
|
||||||
&& model.comment.length > 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -440,27 +359,26 @@ DankModal {
|
|||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
z: 10
|
z: 10
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (resultsList.hoverUpdatesSelection
|
if (resultsList.hoverUpdatesSelection && !resultsList.keyboardNavigationActive)
|
||||||
&& !resultsList.keyboardNavigationActive)
|
resultsList.currentIndex = index;
|
||||||
resultsList.currentIndex = index
|
|
||||||
|
|
||||||
resultsList.itemHovered(index)
|
resultsList.itemHovered(index);
|
||||||
}
|
}
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
resultsList.keyboardNavigationReset()
|
resultsList.keyboardNavigationReset();
|
||||||
}
|
}
|
||||||
onClicked: mouse => {
|
onClicked: (mouse) => {
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
resultsList.itemClicked(index, model)
|
resultsList.itemClicked(index, model);
|
||||||
} else if (mouse.button === Qt.RightButton) {
|
} else if (mouse.button === Qt.RightButton) {
|
||||||
var globalPos = mapToGlobal(mouse.x, mouse.y)
|
var globalPos = mapToGlobal(mouse.x, mouse.y);
|
||||||
resultsList.itemRightClicked(index, model,
|
resultsList.itemRightClicked(index, model, globalPos.x, globalPos.y);
|
||||||
globalPos.x,
|
|
||||||
globalPos.y)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DankGridView {
|
DankGridView {
|
||||||
@@ -477,31 +395,26 @@ DankModal {
|
|||||||
property int minIconSize: 32
|
property int minIconSize: 32
|
||||||
property bool hoverUpdatesSelection: false
|
property bool hoverUpdatesSelection: false
|
||||||
property bool keyboardNavigationActive: appLauncher.keyboardNavigationActive
|
property bool keyboardNavigationActive: appLauncher.keyboardNavigationActive
|
||||||
property int baseCellWidth: adaptiveColumns ? Math.max(
|
property int baseCellWidth: adaptiveColumns ? Math.max(minCellWidth, Math.min(maxCellWidth, width / columns)) : (width - Theme.spacingS * 2) / columns
|
||||||
minCellWidth,
|
|
||||||
Math.min(
|
|
||||||
maxCellWidth,
|
|
||||||
width / columns)) : (width - Theme.spacingS * 2) / columns
|
|
||||||
property int baseCellHeight: baseCellWidth + 20
|
property int baseCellHeight: baseCellWidth + 20
|
||||||
property int actualColumns: adaptiveColumns ? Math.floor(
|
property int actualColumns: adaptiveColumns ? Math.floor(width / cellWidth) : columns
|
||||||
width / cellWidth) : columns
|
|
||||||
property int remainingSpace: width - (actualColumns * cellWidth)
|
property int remainingSpace: width - (actualColumns * cellWidth)
|
||||||
|
|
||||||
signal keyboardNavigationReset
|
signal keyboardNavigationReset()
|
||||||
signal itemClicked(int index, var modelData)
|
signal itemClicked(int index, var modelData)
|
||||||
signal itemHovered(int index)
|
signal itemHovered(int index)
|
||||||
signal itemRightClicked(int index, var modelData, real mouseX, real mouseY)
|
signal itemRightClicked(int index, var modelData, real mouseX, real mouseY)
|
||||||
|
|
||||||
function ensureVisible(index) {
|
function ensureVisible(index) {
|
||||||
if (index < 0 || index >= count)
|
if (index < 0 || index >= count)
|
||||||
return
|
return ;
|
||||||
|
|
||||||
var itemY = Math.floor(index / actualColumns) * cellHeight
|
var itemY = Math.floor(index / actualColumns) * cellHeight;
|
||||||
var itemBottom = itemY + cellHeight
|
var itemBottom = itemY + cellHeight;
|
||||||
if (itemY < contentY)
|
if (itemY < contentY)
|
||||||
contentY = itemY
|
contentY = itemY;
|
||||||
else if (itemBottom > contentY + height)
|
else if (itemBottom > contentY + height)
|
||||||
contentY = itemBottom - height
|
contentY = itemBottom - height;
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -517,23 +430,22 @@ DankModal {
|
|||||||
interactive: true
|
interactive: true
|
||||||
cacheBuffer: Math.max(0, Math.min(height * 2, 1000))
|
cacheBuffer: Math.max(0, Math.min(height * 2, 1000))
|
||||||
reuseItems: true
|
reuseItems: true
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (keyboardNavigationActive)
|
if (keyboardNavigationActive)
|
||||||
ensureVisible(currentIndex)
|
ensureVisible(currentIndex);
|
||||||
}
|
|
||||||
|
|
||||||
onItemClicked: function (index, modelData) {
|
|
||||||
appLauncher.launchApp(modelData)
|
|
||||||
}
|
}
|
||||||
onItemHovered: function (index) {
|
onItemClicked: function(index, modelData) {
|
||||||
appLauncher.selectedIndex = index
|
appLauncher.launchApp(modelData);
|
||||||
}
|
}
|
||||||
onItemRightClicked: function (index, modelData, mouseX, mouseY) {
|
onItemHovered: function(index) {
|
||||||
contextMenu.show(mouseX, mouseY, modelData)
|
appLauncher.selectedIndex = index;
|
||||||
|
}
|
||||||
|
onItemRightClicked: function(index, modelData, mouseX, mouseY) {
|
||||||
|
contextMenu.show(mouseX, mouseY, modelData);
|
||||||
}
|
}
|
||||||
onKeyboardNavigationReset: {
|
onKeyboardNavigationReset: {
|
||||||
appLauncher.keyboardNavigationActive = false
|
appLauncher.keyboardNavigationActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
@@ -549,8 +461,7 @@ DankModal {
|
|||||||
height: resultsGrid.cellHeight - resultsGrid.cellPadding
|
height: resultsGrid.cellHeight - resultsGrid.cellPadding
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: resultsGrid.currentIndex === index ? Theme.primaryPressed : gridMouseArea.containsMouse ? Theme.primaryHoverLight : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.03)
|
color: resultsGrid.currentIndex === index ? Theme.primaryPressed : gridMouseArea.containsMouse ? Theme.primaryHoverLight : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.03)
|
||||||
border.color: resultsGrid.currentIndex
|
border.color: resultsGrid.currentIndex === index ? Theme.primarySelected : Theme.outlineMedium
|
||||||
=== index ? Theme.primarySelected : Theme.outlineMedium
|
|
||||||
border.width: resultsGrid.currentIndex === index ? 2 : 1
|
border.width: resultsGrid.currentIndex === index ? 2 : 1
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -558,10 +469,7 @@ DankModal {
|
|||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
property int iconSize: Math.min(
|
property int iconSize: Math.min(resultsGrid.maxIconSize, Math.max(resultsGrid.minIconSize, resultsGrid.cellWidth * resultsGrid.iconSizeRatio))
|
||||||
resultsGrid.maxIconSize, Math.max(
|
|
||||||
resultsGrid.minIconSize,
|
|
||||||
resultsGrid.cellWidth * resultsGrid.iconSizeRatio))
|
|
||||||
|
|
||||||
width: iconSize
|
width: iconSize
|
||||||
height: iconSize
|
height: iconSize
|
||||||
@@ -571,9 +479,7 @@ DankModal {
|
|||||||
id: gridIconImg
|
id: gridIconImg
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: (model.icon) ? Quickshell.iconPath(
|
source: (model.icon) ? Quickshell.iconPath(model.icon, SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) : ""
|
||||||
model.icon,
|
|
||||||
SettingsData.iconTheme === "System Default" ? "" : SettingsData.iconTheme) : ""
|
|
||||||
smooth: true
|
smooth: true
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
visible: status === Image.Ready
|
visible: status === Image.Ready
|
||||||
@@ -589,15 +495,14 @@ DankModal {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: (model.name
|
text: (model.name && model.name.length > 0) ? model.name.charAt(0).toUpperCase() : "A"
|
||||||
&& model.name.length > 0) ? model.name.charAt(
|
|
||||||
0).toUpperCase(
|
|
||||||
) : "A"
|
|
||||||
font.pixelSize: Math.min(28, parent.width * 0.5)
|
font.pixelSize: Math.min(28, parent.width * 0.5)
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
@@ -612,6 +517,7 @@ DankModal {
|
|||||||
maximumLineCount: 2
|
maximumLineCount: 2
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -623,31 +529,104 @@ DankModal {
|
|||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
z: 10
|
z: 10
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (resultsGrid.hoverUpdatesSelection
|
if (resultsGrid.hoverUpdatesSelection && !resultsGrid.keyboardNavigationActive)
|
||||||
&& !resultsGrid.keyboardNavigationActive)
|
resultsGrid.currentIndex = index;
|
||||||
resultsGrid.currentIndex = index
|
|
||||||
|
|
||||||
resultsGrid.itemHovered(index)
|
resultsGrid.itemHovered(index);
|
||||||
}
|
}
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
resultsGrid.keyboardNavigationReset()
|
resultsGrid.keyboardNavigationReset();
|
||||||
}
|
}
|
||||||
onClicked: mouse => {
|
onClicked: (mouse) => {
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
resultsGrid.itemClicked(index, model)
|
resultsGrid.itemClicked(index, model);
|
||||||
} else if (mouse.button === Qt.RightButton) {
|
} else if (mouse.button === Qt.RightButton) {
|
||||||
var globalPos = mapToGlobal(mouse.x, mouse.y)
|
var globalPos = mapToGlobal(mouse.x, mouse.y);
|
||||||
resultsGrid.itemRightClicked(index, model,
|
resultsGrid.itemRightClicked(index, model, globalPos.x, globalPos.y);
|
||||||
globalPos.x,
|
|
||||||
globalPos.y)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
spotlightOpen = true;
|
||||||
|
if (contentLoader.item && contentLoader.item.appLauncher)
|
||||||
|
contentLoader.item.appLauncher.searchQuery = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
spotlightOpen = false;
|
||||||
|
if (contentLoader.item && contentLoader.item.appLauncher) {
|
||||||
|
contentLoader.item.appLauncher.searchQuery = "";
|
||||||
|
contentLoader.item.appLauncher.selectedIndex = 0;
|
||||||
|
contentLoader.item.appLauncher.setCategory("All");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
if (spotlightOpen)
|
||||||
|
hide();
|
||||||
|
else
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
visible: spotlightOpen
|
||||||
|
width: 550
|
||||||
|
height: 600
|
||||||
|
keyboardFocus: "ondemand"
|
||||||
|
backgroundColor: Theme.popupBackground()
|
||||||
|
cornerRadius: Theme.cornerRadius
|
||||||
|
borderColor: Theme.outlineMedium
|
||||||
|
borderWidth: 1
|
||||||
|
enableShadow: true
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (visible && !spotlightOpen)
|
||||||
|
show();
|
||||||
|
|
||||||
|
if (visible && contentLoader.item) {
|
||||||
|
Qt.callLater(function() {
|
||||||
|
if (contentLoader.item.searchField) {
|
||||||
|
contentLoader.item.searchField.forceActiveFocus();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onBackgroundClicked: {
|
||||||
|
spotlightOpen = false;
|
||||||
}
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
}
|
||||||
|
content: spotlightContent
|
||||||
|
IpcHandler {
|
||||||
|
function open() {
|
||||||
|
spotlightModal.show();
|
||||||
|
return "SPOTLIGHT_OPEN_SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
spotlightModal.hide();
|
||||||
|
return "SPOTLIGHT_CLOSE_SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
spotlightModal.toggle();
|
||||||
|
return "SPOTLIGHT_TOGGLE_SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
|
target: "spotlight"
|
||||||
}
|
}
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
@@ -656,26 +635,25 @@ DankModal {
|
|||||||
property var currentApp: null
|
property var currentApp: null
|
||||||
|
|
||||||
function show(x, y, app) {
|
function show(x, y, app) {
|
||||||
currentApp = app
|
currentApp = app;
|
||||||
if (!contextMenu.parent && typeof Overlay !== "undefined"
|
if (!contextMenu.parent && typeof Overlay !== "undefined" && Overlay.overlay)
|
||||||
&& Overlay.overlay)
|
contextMenu.parent = Overlay.overlay;
|
||||||
contextMenu.parent = Overlay.overlay
|
|
||||||
|
|
||||||
const menuWidth = 180
|
const menuWidth = 180;
|
||||||
const menuHeight = menuColumn.implicitHeight + Theme.spacingS * 2
|
const menuHeight = menuColumn.implicitHeight + Theme.spacingS * 2;
|
||||||
const screenWidth = Screen.width
|
const screenWidth = Screen.width;
|
||||||
const screenHeight = Screen.height
|
const screenHeight = Screen.height;
|
||||||
let finalX = x
|
let finalX = x;
|
||||||
let finalY = y
|
let finalY = y;
|
||||||
if (x + menuWidth > screenWidth - 20)
|
if (x + menuWidth > screenWidth - 20)
|
||||||
finalX = x - menuWidth
|
finalX = x - menuWidth;
|
||||||
|
|
||||||
if (y + menuHeight > screenHeight - 20)
|
if (y + menuHeight > screenHeight - 20)
|
||||||
finalY = y - menuHeight
|
finalY = y - menuHeight;
|
||||||
|
|
||||||
contextMenu.x = Math.max(20, finalX)
|
contextMenu.x = Math.max(20, finalX);
|
||||||
contextMenu.y = Math.max(20, finalY)
|
contextMenu.y = Math.max(20, finalY);
|
||||||
open()
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 180
|
width: 180
|
||||||
@@ -684,17 +662,18 @@ DankModal {
|
|||||||
modal: false
|
modal: false
|
||||||
closePolicy: Popup.CloseOnEscape
|
closePolicy: Popup.CloseOnEscape
|
||||||
onClosed: {
|
onClosed: {
|
||||||
closePolicy = Popup.CloseOnEscape
|
closePolicy = Popup.CloseOnEscape;
|
||||||
}
|
}
|
||||||
onOpened: {
|
onOpened: {
|
||||||
outsideClickTimer.start()
|
outsideClickTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: outsideClickTimer
|
id: outsideClickTimer
|
||||||
|
|
||||||
interval: 100
|
interval: 100
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
contextMenu.closePolicy = Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
contextMenu.closePolicy = Popup.CloseOnEscape | Popup.CloseOnPressOutside;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,12 +684,12 @@ DankModal {
|
|||||||
contentItem: Rectangle {
|
contentItem: Rectangle {
|
||||||
color: Theme.popupBackground()
|
color: Theme.popupBackground()
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||||
Theme.outline.b, 0.08)
|
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: menuColumn
|
id: menuColumn
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingS
|
anchors.margins: Theme.spacingS
|
||||||
spacing: 1
|
spacing: 1
|
||||||
@@ -719,10 +698,7 @@ DankModal {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: 32
|
height: 32
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: pinMouseArea.containsMouse ? Qt.rgba(Theme.primary.r,
|
color: pinMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
|
||||||
Theme.primary.g,
|
|
||||||
Theme.primary.b,
|
|
||||||
0.12) : "transparent"
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
@@ -732,12 +708,11 @@ DankModal {
|
|||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
name: {
|
name: {
|
||||||
if (!contextMenu.currentApp
|
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry)
|
||||||
|| !contextMenu.currentApp.desktopEntry)
|
return "push_pin";
|
||||||
return "push_pin"
|
|
||||||
var appId = contextMenu.currentApp.desktopEntry.id
|
var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "";
|
||||||
|| contextMenu.currentApp.desktopEntry.execString || ""
|
return SessionData.isPinnedApp(appId) ? "keep_off" : "push_pin";
|
||||||
return SessionData.isPinnedApp(appId) ? "keep_off" : "push_pin"
|
|
||||||
}
|
}
|
||||||
size: Theme.iconSize - 2
|
size: Theme.iconSize - 2
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
@@ -747,40 +722,39 @@ DankModal {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: {
|
text: {
|
||||||
if (!contextMenu.currentApp
|
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry)
|
||||||
|| !contextMenu.currentApp.desktopEntry)
|
return "Pin to Dock";
|
||||||
return "Pin to Dock"
|
|
||||||
var appId = contextMenu.currentApp.desktopEntry.id
|
var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "";
|
||||||
|| contextMenu.currentApp.desktopEntry.execString || ""
|
return SessionData.isPinnedApp(appId) ? "Unpin from Dock" : "Pin to Dock";
|
||||||
return SessionData.isPinnedApp(
|
|
||||||
appId) ? "Unpin from Dock" : "Pin to Dock"
|
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
font.weight: Font.Normal
|
font.weight: Font.Normal
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: pinMouseArea
|
id: pinMouseArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!contextMenu.currentApp
|
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry)
|
||||||
|| !contextMenu.currentApp.desktopEntry)
|
return ;
|
||||||
return
|
|
||||||
var appId = contextMenu.currentApp.desktopEntry.id
|
var appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "";
|
||||||
|| contextMenu.currentApp.desktopEntry.execString || ""
|
if (SessionData.isPinnedApp(appId))
|
||||||
if (SessionData.isPinnedApp(appId)) {
|
SessionData.removePinnedApp(appId);
|
||||||
SessionData.removePinnedApp(appId)
|
else
|
||||||
} else {
|
SessionData.addPinnedApp(appId);
|
||||||
SessionData.addPinnedApp(appId)
|
contextMenu.close();
|
||||||
}
|
|
||||||
contextMenu.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -793,19 +767,16 @@ DankModal {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 1
|
height: 1
|
||||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||||
Theme.outline.b, 0.2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 32
|
height: 32
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: launchMouseArea.containsMouse ? Qt.rgba(Theme.primary.r,
|
color: launchMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
|
||||||
Theme.primary.g,
|
|
||||||
Theme.primary.b,
|
|
||||||
0.12) : "transparent"
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
@@ -828,24 +799,29 @@ DankModal {
|
|||||||
font.weight: Font.Normal
|
font.weight: Font.Normal
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: launchMouseArea
|
id: launchMouseArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (contextMenu.currentApp) {
|
if (contextMenu.currentApp && contentLoader.item && contentLoader.item.appLauncher)
|
||||||
appLauncher.launchApp(contextMenu.currentApp)
|
contentLoader.item.appLauncher.launchApp(contextMenu.currentApp);
|
||||||
}
|
|
||||||
contextMenu.close()
|
contextMenu.close();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content: spotlightContent
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user