diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a71b4bd..9888cbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,18 @@ on: branches: [ main ] jobs: + archlinux: + name: ArchLinux + 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 base-devel qt5-base qt5-svg cmake extra-cmake-modules qt5-tools + - name: Build + run: mkdir build; cd build; cmake .. ; make -j$(nproc); + debian: name: Debian runs-on: ubuntu-latest 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..3c47950 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: 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 f3264e6..7a7960c 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) @@ -202,6 +208,14 @@ Page { text: qsTr("Open File Manager") onTriggered: Process.openFileManager(_session.currentDir) } + + MenuItem { + text: qsTr("Settings") + onTriggered: { + settingsDialog.show() + settingsDialog.raise() + } + } } ScrollBar { diff --git a/src/qml/main.qml b/src/qml/main.qml index abfe30e..982aa88 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,17 @@ FishUI.Window { onOkBtnClicked: Qt.quit() } + SettingsDialog { + id: settingsDialog + } + + 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 +104,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 +148,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 +159,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) } } 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 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 + + + +