mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Launcher: add grid/list toggle button
This commit is contained in:
@@ -610,46 +610,61 @@ SmartPanel {
|
||||
Layout.preferredWidth: root.listPanelWidth
|
||||
spacing: Style.marginM
|
||||
|
||||
NTextInput {
|
||||
id: searchInput
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Style.marginS
|
||||
|
||||
fontSize: Style.fontSizeL
|
||||
fontWeight: Style.fontWeightSemiBold
|
||||
NTextInput {
|
||||
id: searchInput
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: searchText
|
||||
placeholderText: I18n.tr("placeholders.search-launcher")
|
||||
fontSize: Style.fontSizeL
|
||||
fontWeight: Style.fontWeightSemiBold
|
||||
|
||||
onTextChanged: searchText = text
|
||||
text: searchText
|
||||
placeholderText: I18n.tr("placeholders.search-launcher")
|
||||
|
||||
Component.onCompleted: {
|
||||
if (searchInput.inputItem) {
|
||||
searchInput.inputItem.forceActiveFocus();
|
||||
// Intercept keys before TextField handles them
|
||||
searchInput.inputItem.Keys.onPressed.connect(function (event) {
|
||||
if (event.key === Qt.Key_Tab) {
|
||||
root.onTabPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Backtab) {
|
||||
root.onBackTabPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Left) {
|
||||
root.onLeftPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Right) {
|
||||
root.onRightPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Up) {
|
||||
root.onUpPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Down) {
|
||||
root.onDownPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Enter) {
|
||||
root.activate();
|
||||
event.accepted = true;
|
||||
}
|
||||
});
|
||||
onTextChanged: searchText = text
|
||||
|
||||
Component.onCompleted: {
|
||||
if (searchInput.inputItem) {
|
||||
searchInput.inputItem.forceActiveFocus();
|
||||
// Intercept keys before TextField handles them
|
||||
searchInput.inputItem.Keys.onPressed.connect(function (event) {
|
||||
if (event.key === Qt.Key_Tab) {
|
||||
root.onTabPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Backtab) {
|
||||
root.onBackTabPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Left) {
|
||||
root.onLeftPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Right) {
|
||||
root.onRightPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Up) {
|
||||
root.onUpPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Down) {
|
||||
root.onDownPressed();
|
||||
event.accepted = true;
|
||||
} else if (event.key === Qt.Key_Enter) {
|
||||
root.activate();
|
||||
event.accepted = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
visible: root.activePlugin === null || root.activePlugin === appsPlugin
|
||||
icon: Settings.data.appLauncher.viewMode === "grid" ? "layout-list" : "layout-grid"
|
||||
tooltipText: Settings.data.appLauncher.viewMode === "grid" ? I18n.tr("tooltips.list-view") : I18n.tr("tooltips.grid-view")
|
||||
baseSize: Style.baseWidgetSize * 0.8
|
||||
onClicked: {
|
||||
Settings.data.appLauncher.viewMode = Settings.data.appLauncher.viewMode === "grid" ? "list" : "grid"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user