From 596817298e470c29ee0dd7e84e5208f80de59414 Mon Sep 17 00:00:00 2001 From: Reion Wong Date: Wed, 1 Sep 2021 21:18:34 +0800 Subject: [PATCH 1/7] Update build.yml --- .github/workflows/build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a71b4bd..9899f30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,16 @@ on: branches: [ main ] jobs: + archlinux: + name: ArchLinux + runs-on: ubuntu-latest + container: docker.io/library/archlinux:latest + steps: + - name: dependencies + run: pacman -Sy; pacman -S fishui qt5-svg extra-cmake-modules qt5-tools + - name: Build + run: mkdir build; cd build; cmake .. ; make -j$(nproc); + debian: name: Debian runs-on: ubuntu-latest From bc21b510b29ad91966fd1a8265d69920d625dd23 Mon Sep 17 00:00:00 2001 From: Reion Wong Date: Wed, 1 Sep 2021 21:21:33 +0800 Subject: [PATCH 2/7] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9899f30..0bbd75d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: container: docker.io/library/archlinux:latest steps: - name: dependencies - run: pacman -Sy; pacman -S fishui qt5-svg extra-cmake-modules qt5-tools + run: pacman -Sy; pacman -S --noconfirm fishui qt5-svg extra-cmake-modules qt5-tools - name: Build run: mkdir build; cd build; cmake .. ; make -j$(nproc); From e9cfc181e4f5ca0d021615041a756e1b587045fe Mon Sep 17 00:00:00 2001 From: Reion Wong Date: Wed, 1 Sep 2021 21:23:47 +0800 Subject: [PATCH 3/7] Update build.yml --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0bbd75d..6acbb54 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,8 @@ jobs: runs-on: ubuntu-latest container: docker.io/library/archlinux:latest steps: + - name: Checkout Source + uses: actions/checkout@v2 - name: dependencies run: pacman -Sy; pacman -S --noconfirm fishui qt5-svg extra-cmake-modules qt5-tools - name: Build From 2b9f807d56bc6d4b4a9edd69ae05dfd1497da052 Mon Sep 17 00:00:00 2001 From: Reion Wong Date: Wed, 1 Sep 2021 21:26:23 +0800 Subject: [PATCH 4/7] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6acbb54..9888cbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: - name: Checkout Source uses: actions/checkout@v2 - name: dependencies - run: pacman -Sy; pacman -S --noconfirm fishui qt5-svg extra-cmake-modules qt5-tools + run: pacman -Sy; pacman -S --noconfirm fishui base-devel qt5-base qt5-svg cmake extra-cmake-modules qt5-tools - name: Build run: mkdir build; cd build; cmake .. ; make -j$(nproc); From 8ef31807ded337b5543979c67d4b1c3bf0ff4fa5 Mon Sep 17 00:00:00 2001 From: reionwong Date: Thu, 2 Sep 2021 00:29:32 +0800 Subject: [PATCH 5/7] Support blur --- qmltermwidget/lib/TerminalDisplay.cpp | 37 ++++++++++++++++++++++++--- qmltermwidget/lib/TerminalDisplay.h | 8 ++++++ src/qml/GlobalSettings.qml | 3 +++ src/qml/Terminal.qml | 8 +++++- src/qml/main.qml | 16 +++++++++--- 5 files changed, 63 insertions(+), 9 deletions(-) diff --git a/qmltermwidget/lib/TerminalDisplay.cpp b/qmltermwidget/lib/TerminalDisplay.cpp index af91ab1..09b289e 100644 --- a/qmltermwidget/lib/TerminalDisplay.cpp +++ b/qmltermwidget/lib/TerminalDisplay.cpp @@ -336,6 +336,7 @@ TerminalDisplay::TerminalDisplay(QQuickItem *parent) , m_font("Monospace", 12) , m_colorRole(QPalette::Background) , m_full_cursor_height(false) + , m_backgroundOpacity(1.0) { // terminal applications are not designed with Right-To-Left in mind, // so the layout is forced to Left-To-Right @@ -2843,11 +2844,37 @@ bool TerminalDisplay::handleShortcutOverrideEvent(QKeyEvent* keyEvent) return false; } +qreal TerminalDisplay::backgroundOpacity() const +{ + return m_backgroundOpacity; +} + +void TerminalDisplay::setBackgroundOpacity(const qreal &backgroundOpacity) +{ + if (m_backgroundOpacity != backgroundOpacity) { + m_backgroundOpacity = backgroundOpacity; + + const ColorScheme *cs; + if (!availableColorSchemes().contains(_colorScheme)) + cs = ColorSchemeManager::instance()->defaultColorScheme(); + else + cs = ColorSchemeManager::instance()->findColorScheme(_colorScheme); + + if (cs) { + QColor color = cs->backgroundColor(); + color.setAlphaF(m_backgroundOpacity); + setFillColor(color); + } + + emit backgroundOpacityChanged(); + } +} + bool TerminalDisplay::event(QEvent* event) { - bool eventHandled = false; - switch (event->type()) - { + bool eventHandled = false; + switch (event->type()) + { case QEvent::ShortcutOverride: eventHandled = handleShortcutOverrideEvent((QKeyEvent*)event); break; @@ -3259,7 +3286,9 @@ void TerminalDisplay::setColorScheme(const QString &name) cs->getColorTable(table); setColorTable(table); - setFillColor(cs->backgroundColor()); + QColor bgColor = cs->backgroundColor(); + bgColor.setAlphaF(m_backgroundOpacity); + setFillColor(bgColor); _colorScheme = name; emit colorSchemeChanged(); } diff --git a/qmltermwidget/lib/TerminalDisplay.h b/qmltermwidget/lib/TerminalDisplay.h index 013e874..f084468 100644 --- a/qmltermwidget/lib/TerminalDisplay.h +++ b/qmltermwidget/lib/TerminalDisplay.h @@ -97,6 +97,8 @@ class TerminalDisplay : public QQuickPaintedItem Q_PROPERTY(bool selectedText READ selectedText CONSTANT) + Q_PROPERTY(qreal backgroundOpacity READ backgroundOpacity WRITE setBackgroundOpacity NOTIFY backgroundOpacityChanged) + public: /** Constructs a new terminal display widget with the specified parent. */ explicit TerminalDisplay(QQuickItem *parent = nullptr); @@ -120,6 +122,9 @@ public: /** Sets the opacity of the terminal display. */ void setOpacity(qreal opacity); + qreal backgroundOpacity() const; + void setBackgroundOpacity(const qreal &backgroundOpacity); + /** * This enum describes the location where the scroll bar is positioned in the display widget. */ @@ -553,6 +558,7 @@ public slots: void simulateMouseDoubleClick(int x, int y, int button, int buttons, int modifiers); signals: + void backgroundOpacityChanged(); /** * Emitted when the user presses a key whilst the terminal widget has focus. @@ -888,6 +894,8 @@ private: KSession *m_session; bool m_full_cursor_height; + qreal m_backgroundOpacity; + QFont font() const { return m_font; } const QPalette palette() { return m_palette; } diff --git a/src/qml/GlobalSettings.qml b/src/qml/GlobalSettings.qml index 63f5759..83bb9f9 100644 --- a/src/qml/GlobalSettings.qml +++ b/src/qml/GlobalSettings.qml @@ -25,4 +25,7 @@ Settings { property int height: 500 property int fontPointSize: 10 property bool blinkingCursor: true + + property real opacity: 0.8 + property bool blur: true } diff --git a/src/qml/Terminal.qml b/src/qml/Terminal.qml index f3264e6..6ad20e6 100644 --- a/src/qml/Terminal.qml +++ b/src/qml/Terminal.qml @@ -33,7 +33,12 @@ Page { focus: true // Drop effect - opacity: _dropArea.containsDrag ? 0.8 : 1 + // opacity: _dropArea.containsDrag ? 0.8 : 1 +// opacity: 0.5 + + background: Rectangle { + color: "transparent" + } signal urlsDropped(var urls) signal keyPressed(var event) @@ -106,6 +111,7 @@ Page { font.pointSize: settings.fontPointSize blinkingCursor: settings.blinkingCursor fullCursorHeight: true + backgroundOpacity: 0 Keys.enabled: true Keys.onPressed: control.keyPressed(event) diff --git a/src/qml/main.qml b/src/qml/main.qml index abfe30e..13e938c 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -34,7 +34,8 @@ FishUI.Window { height: settings.height title: currentItem && currentItem.terminal ? currentItem.terminal.session.title : "" - background.color: FishUI.Theme.secondBackgroundColor + background.color: FishUI.Theme.backgroundColor + background.opacity: settings.opacity header.height: 45 property int currentIndex: -1 @@ -49,6 +50,13 @@ FishUI.Window { onOkBtnClicked: Qt.quit() } + FishUI.WindowBlur { + view: root + geometry: Qt.rect(root.x, root.y, root.width, root.height) + windowRadius: root.background.radius + enabled: settings.blur + } + onClosing: { if (!root.isMaximized) { settings.width = root.width @@ -92,7 +100,7 @@ FishUI.Window { highlight: Rectangle { color: FishUI.Theme.highlightColor - opacity: FishUI.Theme.darkMode ? 0.2 : 0.1 + opacity: 1 border.width: 0 radius: FishUI.Theme.smallRadius } @@ -136,7 +144,7 @@ FishUI.Window { elide: Label.ElideRight font.pointSize: 9 font.family: "Noto Sans Mono" - color: isCurrent ? FishUI.Theme.highlightColor : FishUI.Theme.textColor + color: isCurrent ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor } Item { @@ -147,7 +155,7 @@ FishUI.Window { Layout.preferredHeight: 24 Layout.preferredWidth: 24 size: 24 - source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "close.svg" + source: "qrc:/images/" + (FishUI.Theme.darkMode || isCurrent ? "dark/" : "light/") + "close.svg" onClicked: closeTab(index) } } From 9566bb1e98beff485e7224c3adefc58a29c6b905 Mon Sep 17 00:00:00 2001 From: reionwong Date: Thu, 2 Sep 2021 01:05:58 +0800 Subject: [PATCH 6/7] Add settings dialog --- src/qml/GlobalSettings.qml | 4 +- src/qml/SettingsDialog.qml | 102 +++++++++++++++++++++++++++++++++++++ src/qml/Terminal.qml | 8 +++ src/qml/main.qml | 4 ++ src/resources.qrc | 1 + 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 src/qml/SettingsDialog.qml diff --git a/src/qml/GlobalSettings.qml b/src/qml/GlobalSettings.qml index 83bb9f9..3c47950 100644 --- a/src/qml/GlobalSettings.qml +++ b/src/qml/GlobalSettings.qml @@ -26,6 +26,6 @@ Settings { property int fontPointSize: 10 property bool blinkingCursor: true - property real opacity: 0.8 - property bool blur: true + property real opacity: 1.0 + property bool blur: false } diff --git a/src/qml/SettingsDialog.qml b/src/qml/SettingsDialog.qml new file mode 100644 index 0000000..7447088 --- /dev/null +++ b/src/qml/SettingsDialog.qml @@ -0,0 +1,102 @@ +import QtQuick 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Window 2.12 +import QtQuick.Controls 2.12 +import FishUI 1.0 as FishUI + +FishUI.Window { + id: control + + width: 400 + height: 400 + + maximumHeight: 400 + maximumWidth: 400 + minimumWidth: 400 + minimumHeight: 400 + + visible: false + + ColumnLayout { + id: _mainLayout + anchors.fill: parent + anchors.leftMargin: FishUI.Units.largeSpacing + anchors.rightMargin: FishUI.Units.largeSpacing + spacing: FishUI.Units.largeSpacing + + Item { + Layout.fillWidth: true + Layout.preferredHeight: 45 + + Rectangle { + anchors.fill: parent + color: FishUI.Theme.secondBackgroundColor + radius: FishUI.Theme.smallRadius + } + + RowLayout { + anchors.fill: parent + anchors.leftMargin: FishUI.Units.largeSpacing + anchors.rightMargin: FishUI.Units.largeSpacing + + Label { + text: qsTr("Transparency") + } + + Item { + width: FishUI.Units.largeSpacing + } + + Slider { + id: transparencySlider + Layout.fillHeight: true + Layout.fillWidth: true + from: 0.1 + to: 1.0 + stepSize: 0.05 + + Component.onCompleted: { + transparencySlider.value = settings.opacity + } + + onValueChanged: settings.opacity = transparencySlider.value + } + } + } + + Item { + Layout.fillWidth: true + Layout.preferredHeight: 45 + + Rectangle { + anchors.fill: parent + color: FishUI.Theme.secondBackgroundColor + radius: FishUI.Theme.smallRadius + } + + RowLayout { + anchors.fill: parent + anchors.leftMargin: FishUI.Units.largeSpacing + anchors.rightMargin: FishUI.Units.smallSpacing + + Label { + text: qsTr("Window Blur") + } + + Item { + Layout.fillWidth: true + } + + Switch { + Layout.fillHeight: true + checked: settings.blur + onCheckedChanged: settings.blur = checked + } + } + } + + Item { + Layout.fillHeight: true + } + } +} diff --git a/src/qml/Terminal.qml b/src/qml/Terminal.qml index 6ad20e6..b677234 100644 --- a/src/qml/Terminal.qml +++ b/src/qml/Terminal.qml @@ -208,6 +208,14 @@ Page { text: qsTr("Open File Manager") onTriggered: Process.openFileManager(_session.currentDir) } + + MenuItem { + text: qsTr("Open Settings") + onTriggered: { + settingsDialog.show() + settingsDialog.raise() + } + } } ScrollBar { diff --git a/src/qml/main.qml b/src/qml/main.qml index 13e938c..982aa88 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -50,6 +50,10 @@ FishUI.Window { onOkBtnClicked: Qt.quit() } + SettingsDialog { + id: settingsDialog + } + FishUI.WindowBlur { view: root geometry: Qt.rect(root.x, root.y, root.width, root.height) diff --git a/src/resources.qrc b/src/resources.qrc index f67c951..6e280ed 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -9,5 +9,6 @@ images/dark/close.svg qml/ImageButton.qml qml/ExitPromptDialog.qml + qml/SettingsDialog.qml From 61bb5ef23e208912874501bc354aece30f912480 Mon Sep 17 00:00:00 2001 From: reionwong Date: Thu, 2 Sep 2021 01:10:33 +0800 Subject: [PATCH 7/7] Update translations --- src/qml/Terminal.qml | 2 +- translations/en_US.ts | 28 ++++++++++++++---- translations/zh_CN.ts | 28 ++++++++++++++---- translations/zh_CN.ts.ts | 64 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 translations/zh_CN.ts.ts diff --git a/src/qml/Terminal.qml b/src/qml/Terminal.qml index b677234..7a7960c 100644 --- a/src/qml/Terminal.qml +++ b/src/qml/Terminal.qml @@ -210,7 +210,7 @@ Page { } MenuItem { - text: qsTr("Open Settings") + text: qsTr("Settings") onTriggered: { settingsDialog.show() settingsDialog.raise() diff --git a/translations/en_US.ts b/translations/en_US.ts index ea66cb2..ef8023b 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -19,28 +19,46 @@ Cancel + + SettingsDialog + + + Transparency + + + + + Window Blur + + + Terminal - + Copy - - + + Paste - + Select All - + Open File Manager + + + Settings + + diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index feb29c6..778b848 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -19,28 +19,46 @@ 取消 + + SettingsDialog + + + Transparency + 透明度 + + + + Window Blur + 窗口模糊 + + Terminal - + Copy 复制 - - + + Paste 粘贴 - + Select All 全选 - + Open File Manager 打开文件管理器 + + + Settings + 设置 + diff --git a/translations/zh_CN.ts.ts b/translations/zh_CN.ts.ts new file mode 100644 index 0000000..e0c83de --- /dev/null +++ b/translations/zh_CN.ts.ts @@ -0,0 +1,64 @@ + + + + + ExitPromptDialog + + + Process is running, are you sure you want to quit? + + + + + Cancel + + + + + OK + + + + + SettingsDialog + + + Transparency + + + + + Window Blur + + + + + Terminal + + + Copy + + + + + + Paste + + + + + Select All + + + + + Open File Manager + + + + + Settings + + + +