mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge branch 'main' of https://github.com/noctalia-dev/noctalia-shell
This commit is contained in:
@@ -239,21 +239,14 @@ Item {
|
||||
}
|
||||
function command() {
|
||||
root.screenDetector.withCurrentScreen(screen => {
|
||||
var launcherPanel = PanelService.getPanel("launcherPanel", screen);
|
||||
if (!launcherPanel)
|
||||
return;
|
||||
var searchText = launcherPanel.searchText || "";
|
||||
var isInClipMode = searchText.startsWith(">cmd");
|
||||
if (!launcherPanel.isPanelOpen) {
|
||||
// Closed -> open in clipboard mode
|
||||
launcherPanel.open();
|
||||
launcherPanel.setSearchText(">cmd ");
|
||||
} else if (isInClipMode) {
|
||||
// Already in clipboard mode -> close
|
||||
launcherPanel.close();
|
||||
var searchText = PanelService.getLauncherSearchText(screen);
|
||||
var isInCmdMode = searchText.startsWith(">cmd");
|
||||
if (!PanelService.isLauncherOpen(screen)) {
|
||||
PanelService.openLauncherWithSearch(screen, ">cmd ");
|
||||
} else if (isInCmdMode) {
|
||||
PanelService.closeLauncher(screen);
|
||||
} else {
|
||||
// In another mode -> switch to clipboard mode
|
||||
launcherPanel.setSearchText(">cmd ");
|
||||
PanelService.setLauncherSearchText(screen, ">cmd ");
|
||||
}
|
||||
}, Settings.data.appLauncher.overviewLayer);
|
||||
}
|
||||
@@ -275,41 +268,27 @@ Item {
|
||||
}
|
||||
function windows() {
|
||||
root.screenDetector.withCurrentScreen(screen => {
|
||||
var launcherPanel = PanelService.getPanel("launcherPanel", screen);
|
||||
if (!launcherPanel)
|
||||
return;
|
||||
var searchText = launcherPanel.searchText || "";
|
||||
var searchText = PanelService.getLauncherSearchText(screen);
|
||||
var isInWindowsMode = searchText.startsWith(">win");
|
||||
if (!launcherPanel.isPanelOpen) {
|
||||
// Closed -> open in windows mode
|
||||
launcherPanel.open();
|
||||
launcherPanel.setSearchText(">win ");
|
||||
if (!PanelService.isLauncherOpen(screen)) {
|
||||
PanelService.openLauncherWithSearch(screen, ">win ");
|
||||
} else if (isInWindowsMode) {
|
||||
// Already in windows mode -> close
|
||||
launcherPanel.close();
|
||||
PanelService.closeLauncher(screen);
|
||||
} else {
|
||||
// In another mode -> switch to windows mode
|
||||
launcherPanel.setSearchText(">win ");
|
||||
PanelService.setLauncherSearchText(screen, ">win ");
|
||||
}
|
||||
}, Settings.data.appLauncher.overviewLayer);
|
||||
}
|
||||
function settings() {
|
||||
root.screenDetector.withCurrentScreen(screen => {
|
||||
var launcherPanel = PanelService.getPanel("launcherPanel", screen);
|
||||
if (!launcherPanel)
|
||||
return;
|
||||
var searchText = launcherPanel.searchText || "";
|
||||
var searchText = PanelService.getLauncherSearchText(screen);
|
||||
var isInSettingsMode = searchText.startsWith(">settings");
|
||||
if (!launcherPanel.isPanelOpen) {
|
||||
// Closed -> open in settings mode
|
||||
launcherPanel.open();
|
||||
launcherPanel.setSearchText(">settings ");
|
||||
if (!PanelService.isLauncherOpen(screen)) {
|
||||
PanelService.openLauncherWithSearch(screen, ">settings ");
|
||||
} else if (isInSettingsMode) {
|
||||
// Already in settings mode -> close
|
||||
launcherPanel.close();
|
||||
PanelService.closeLauncher(screen);
|
||||
} else {
|
||||
// In another mode -> switch to settings mode
|
||||
launcherPanel.setSearchText(">settings ");
|
||||
PanelService.setLauncherSearchText(screen, ">settings ");
|
||||
}
|
||||
}, Settings.data.appLauncher.overviewLayer);
|
||||
}
|
||||
|
||||
@@ -932,6 +932,9 @@ Singleton {
|
||||
property var openPanel: null
|
||||
property var closePanel: null
|
||||
property var togglePanel: null
|
||||
property var openLauncher: null
|
||||
property var closeLauncher: null
|
||||
property var toggleLauncher: null
|
||||
property var withCurrentScreen: null
|
||||
property var tr: null
|
||||
property var trp: null
|
||||
@@ -1011,6 +1014,53 @@ Singleton {
|
||||
return false;
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
// Launcher provider methods
|
||||
// ----------------------------------------
|
||||
|
||||
// Get the search prefix for this plugin's launcher provider
|
||||
var getSearchPrefix = function () {
|
||||
var metadata = LauncherProviderRegistry.getProviderMetadata("plugin:" + pluginId);
|
||||
var prefix = (metadata && metadata.commandPrefix) ? metadata.commandPrefix : pluginId;
|
||||
return ">" + prefix + " ";
|
||||
};
|
||||
|
||||
api.openLauncher = function (screen) {
|
||||
// Open the launcher with this plugin's provider active
|
||||
if (!screen) {
|
||||
Logger.w("PluginAPI", "No screen available for opening launcher");
|
||||
return;
|
||||
}
|
||||
PanelService.openLauncherWithSearch(screen, getSearchPrefix());
|
||||
};
|
||||
|
||||
api.closeLauncher = function (screen) {
|
||||
// Close the launcher
|
||||
if (!screen) {
|
||||
Logger.w("PluginAPI", "No screen available for closing launcher");
|
||||
return;
|
||||
}
|
||||
PanelService.closeLauncher(screen);
|
||||
};
|
||||
|
||||
api.toggleLauncher = function (screen) {
|
||||
// Toggle the launcher with this plugin's provider active
|
||||
if (!screen) {
|
||||
Logger.w("PluginAPI", "No screen available for toggling launcher");
|
||||
return;
|
||||
}
|
||||
var searchPrefix = getSearchPrefix();
|
||||
var searchText = PanelService.getLauncherSearchText(screen);
|
||||
var isInThisMode = searchText.startsWith(searchPrefix);
|
||||
if (!PanelService.isLauncherOpen(screen)) {
|
||||
PanelService.openLauncherWithSearch(screen, searchPrefix);
|
||||
} else if (isInThisMode) {
|
||||
PanelService.closeLauncher(screen);
|
||||
} else {
|
||||
PanelService.setLauncherSearchText(screen, searchPrefix);
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
api.withCurrentScreen = function (callback) {
|
||||
// Detect which screen the cursor is on and call callback with that screen
|
||||
|
||||
Reference in New Issue
Block a user