feat: add setting variant
This commit is contained in:
+26
-2
@@ -2,7 +2,8 @@ import { Button, CheckBox, ListView } from "std-widgets.slint";
|
||||
import { BrowserItem } from "./browser_item.slint";
|
||||
import { Header } from "./header.slint";
|
||||
import { Footer } from "./footer.slint";
|
||||
import { BrowserConfig } from "./types.slint";
|
||||
import { SettingsView } from "./settings.slint";
|
||||
import { BrowserConfig, RememberedEntry } from "./types.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
|
||||
export { Theme }
|
||||
@@ -62,11 +63,17 @@ export component MainWindow inherits Window {
|
||||
in-out property <bool> remember-choice: false;
|
||||
in-out property <bool> always-ask: true;
|
||||
in property <int> selected-index: 0;
|
||||
in property <[RememberedEntry]> remembered-list: [];
|
||||
in-out property <bool> settings-open: false;
|
||||
|
||||
callback launch-browser(BrowserConfig);
|
||||
callback toggle-remember(bool);
|
||||
callback toggle-always-ask(bool);
|
||||
callback settings-clicked();
|
||||
callback settings-closed();
|
||||
callback remove-browser(string);
|
||||
callback remove-remembered(string);
|
||||
callback redetect-browsers();
|
||||
callback open-clicked();
|
||||
callback request-drag();
|
||||
callback esc-pressed();
|
||||
@@ -106,7 +113,24 @@ export component MainWindow inherits Window {
|
||||
border-width: 1px;
|
||||
border-color: Theme.border-main;
|
||||
|
||||
VerticalLayout {
|
||||
if root.settings-open: SettingsView {
|
||||
browsers: root.browser-model;
|
||||
remembered: root.remembered-list;
|
||||
back => {
|
||||
root.settings-closed();
|
||||
}
|
||||
remove-browser(name) => {
|
||||
root.remove-browser(name);
|
||||
}
|
||||
remove-remembered(domain) => {
|
||||
root.remove-remembered(domain);
|
||||
}
|
||||
redetect => {
|
||||
root.redetect-browsers();
|
||||
}
|
||||
}
|
||||
|
||||
if !root.settings-open: VerticalLayout {
|
||||
|
||||
Header {
|
||||
url: current-url;
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
import { ListView } from "std-widgets.slint";
|
||||
import { Theme } from "./theme.slint";
|
||||
import { BrowserConfig, RememberedEntry } from "./types.slint";
|
||||
|
||||
export component SettingsView inherits Rectangle {
|
||||
in property <[BrowserConfig]> browsers;
|
||||
in property <[RememberedEntry]> remembered;
|
||||
callback back();
|
||||
callback remove-browser(string);
|
||||
callback remove-remembered(string);
|
||||
callback redetect();
|
||||
|
||||
background: transparent;
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 12px;
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
|
||||
Rectangle {
|
||||
width: 32px;
|
||||
border-radius: 8px;
|
||||
background: back-touch.has-hover ? Theme.surface-hover : transparent;
|
||||
|
||||
back-touch := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.back();
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
source: @image-url("../icons/arrow_left.svg");
|
||||
colorize: back-touch.has-hover ? Theme.text-main : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
|
||||
Text {
|
||||
text: "Настройки";
|
||||
color: Theme.text-main;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
|
||||
Text {
|
||||
text: "Браузеры";
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
|
||||
Rectangle {}
|
||||
|
||||
Rectangle {
|
||||
width: 120px;
|
||||
height: 26px;
|
||||
border-radius: 8px;
|
||||
background: redetect-touch.has-hover ? Theme.surface-hover : Theme.surface-elevated;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border-main;
|
||||
|
||||
redetect-touch := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.redetect();
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text: "Автодетект";
|
||||
color: redetect-touch.has-hover ? Theme.text-main : Theme.text-control;
|
||||
font-size: 12px;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
vertical-stretch: 3;
|
||||
border-radius: 8px;
|
||||
background: Theme.surface-elevated;
|
||||
clip: true;
|
||||
|
||||
ListView {
|
||||
for b in root.browsers: Rectangle {
|
||||
height: 52px;
|
||||
background: transparent;
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 8px;
|
||||
spacing: 10px;
|
||||
|
||||
Image {
|
||||
width: 22px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
source: b.icon;
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
horizontal-stretch: 1;
|
||||
alignment: center;
|
||||
|
||||
Text {
|
||||
text: b.name;
|
||||
color: Theme.text-main;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
Text {
|
||||
text: b.path;
|
||||
color: Theme.text-hint;
|
||||
font-size: 11px;
|
||||
font-family: "Consolas";
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 28px;
|
||||
border-radius: 6px;
|
||||
background: del-touch.has-hover ? #ef444420 : transparent;
|
||||
|
||||
del-touch := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.remove-browser(b.name);
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
source: @image-url("../icons/trash.svg");
|
||||
colorize: del-touch.has-hover ? #ef4444 : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Запомненные домены";
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
vertical-stretch: 2;
|
||||
border-radius: 8px;
|
||||
background: Theme.surface-elevated;
|
||||
clip: true;
|
||||
|
||||
ListView {
|
||||
for r in root.remembered: Rectangle {
|
||||
height: 40px;
|
||||
background: transparent;
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 8px;
|
||||
spacing: 10px;
|
||||
|
||||
VerticalLayout {
|
||||
horizontal-stretch: 1;
|
||||
alignment: center;
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 6px;
|
||||
|
||||
Text {
|
||||
text: r.domain;
|
||||
color: Theme.text-main;
|
||||
font-size: 13px;
|
||||
font-family: "Consolas";
|
||||
vertical-alignment: center;
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "→ " + r.browser;
|
||||
color: Theme.text-hint;
|
||||
font-size: 12px;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 28px;
|
||||
border-radius: 6px;
|
||||
background: del2-touch.has-hover ? #ef444420 : transparent;
|
||||
|
||||
del2-touch := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.remove-remembered(r.domain);
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
source: @image-url("../icons/trash.svg");
|
||||
colorize: del2-touch.has-hover ? #ef4444 : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,3 +5,8 @@ export struct BrowserConfig {
|
||||
flags: string,
|
||||
is-default: bool,
|
||||
}
|
||||
|
||||
export struct RememberedEntry {
|
||||
domain: string,
|
||||
browser: string,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user