mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-11-04 13:37:43 +03:00
feat: introduce tray item, that lets you toggle floating mode
This commit is contained in:
parent
8ebffbe639
commit
ba689c5ff0
27
res/ui/TrayItem.qml
Normal file
27
res/ui/TrayItem.qml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
import Qt.labs.platform 1.1 as Labs
|
||||||
|
|
||||||
|
Labs.SystemTrayIcon {
|
||||||
|
id: root
|
||||||
|
visible: true
|
||||||
|
icon.name: "bismuth"
|
||||||
|
tooltip: "Windows' Tiling"
|
||||||
|
|
||||||
|
menu: Labs.Menu {
|
||||||
|
id: menu
|
||||||
|
visible: false // Prevent from showing on Script Loading
|
||||||
|
|
||||||
|
property var onToggleTiling: () => {}
|
||||||
|
|
||||||
|
Labs.MenuItem {
|
||||||
|
text: i18n("Toggle Tiling")
|
||||||
|
icon.name: "window"
|
||||||
|
onTriggered: () => menu.onToggleTiling()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,11 +6,16 @@
|
|||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import org.kde.kwin 2.0;
|
import org.kde.kwin 2.0;
|
||||||
import org.kde.taskmanager 0.1 as TaskManager
|
import org.kde.taskmanager 0.1 as TaskManager
|
||||||
|
|
||||||
import "../code/index.mjs" as Bismuth
|
import "../code/index.mjs" as Bismuth
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: scriptRoot
|
id: scriptRoot
|
||||||
|
|
||||||
|
TrayItem {
|
||||||
|
id: trayItem
|
||||||
|
}
|
||||||
|
|
||||||
TaskManager.ActivityInfo {
|
TaskManager.ActivityInfo {
|
||||||
id: activityInfo
|
id: activityInfo
|
||||||
}
|
}
|
||||||
@ -29,6 +34,7 @@ Item {
|
|||||||
|
|
||||||
const qmlObjects = {
|
const qmlObjects = {
|
||||||
scriptRoot: scriptRoot,
|
scriptRoot: scriptRoot,
|
||||||
|
trayItem: trayItem,
|
||||||
activityInfo: activityInfo,
|
activityInfo: activityInfo,
|
||||||
popupDialog: popupDialog
|
popupDialog: popupDialog
|
||||||
};
|
};
|
||||||
|
@ -150,7 +150,7 @@ export class ControllerImpl implements Controller {
|
|||||||
private engine: Engine;
|
private engine: Engine;
|
||||||
private driver: Driver;
|
private driver: Driver;
|
||||||
public constructor(
|
public constructor(
|
||||||
qmlObjects: Bismuth.Qml.Main,
|
private qmlObjects: Bismuth.Qml.Main,
|
||||||
kwinApi: KWin.Api,
|
kwinApi: KWin.Api,
|
||||||
private config: Config,
|
private config: Config,
|
||||||
private log: Log
|
private log: Log
|
||||||
@ -166,6 +166,7 @@ export class ControllerImpl implements Controller {
|
|||||||
this.log.log("Let's get down to bismuth!");
|
this.log.log("Let's get down to bismuth!");
|
||||||
|
|
||||||
this.driver.bindEvents();
|
this.driver.bindEvents();
|
||||||
|
this.bindTrayActions();
|
||||||
this.bindShortcuts();
|
this.bindShortcuts();
|
||||||
|
|
||||||
this.driver.manageWindows();
|
this.driver.manageWindows();
|
||||||
@ -372,6 +373,16 @@ export class ControllerImpl implements Controller {
|
|||||||
this.engine.manage(win);
|
this.engine.manage(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bindTrayActions(): void {
|
||||||
|
// NOTE: Since the qml interface is very agile, it's seems
|
||||||
|
// to be unreasonable to make the bindings universal.
|
||||||
|
// However, this may be changed it the future.
|
||||||
|
this.qmlObjects.trayItem.menu.onToggleTiling = (): void => {
|
||||||
|
const action = new Action.ToggleFloatingLayout(this.engine, this.log);
|
||||||
|
action.execute();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private bindShortcuts(): void {
|
private bindShortcuts(): void {
|
||||||
const allPossibleActions = [
|
const allPossibleActions = [
|
||||||
new Action.FocusNextWindow(this.engine, this.log),
|
new Action.FocusNextWindow(this.engine, this.log),
|
||||||
|
9
src/extern/global.d.ts
vendored
9
src/extern/global.d.ts
vendored
@ -9,10 +9,19 @@ declare namespace Bismuth {
|
|||||||
export namespace Qml {
|
export namespace Qml {
|
||||||
export interface Main {
|
export interface Main {
|
||||||
scriptRoot: object;
|
scriptRoot: object;
|
||||||
|
trayItem: TrayItem;
|
||||||
activityInfo: Plasma.TaskManager.ActivityInfo;
|
activityInfo: Plasma.TaskManager.ActivityInfo;
|
||||||
popupDialog: PopupDialog;
|
popupDialog: PopupDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TrayItem {
|
||||||
|
menu: TrayMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TrayMenu {
|
||||||
|
onToggleTiling: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
export interface PopupDialog {
|
export interface PopupDialog {
|
||||||
show(text: string): void;
|
show(text: string): void;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user