diff --git a/qml/ControlCenterItem.qml b/qml/ControlCenterItem.qml index 3a03e82..d1d67e3 100644 --- a/qml/ControlCenterItem.qml +++ b/qml/ControlCenterItem.qml @@ -11,8 +11,8 @@ StandardItem { Layout.preferredWidth: isHorizontal ? controlLayout.implicitWidth + root.largeSpacing * 2 : mainLayout.width * 0.7 Layout.preferredHeight: isHorizontal ? mainLayout.height * 0.7 : controlLayout.implicitHeight + root.largeSpacing * 2 - Layout.rightMargin: isHorizontal ? root.windowRadius / 2 : 0 - Layout.bottomMargin: isHorizontal ? 0 : root.windowRadius / 2 + Layout.rightMargin: isHorizontal ? root.windowRadius ? root.windowRadius / 2 : root.largeSpacing : 0 + Layout.bottomMargin: isHorizontal ? 0 : root.windowRadius ? root.windowRadius / 2 : root.largeSpacing Layout.alignment: Qt.AlignCenter onClicked: { diff --git a/qml/main.qml b/qml/main.qml index 49ed8dc..897c566 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -12,7 +12,8 @@ Item { visible: true property color borderColor: Meui.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.1) : Qt.rgba(0, 0, 0, 0.05) - property real windowRadius: (Settings.direction === DockSettings.Left) ? root.width * 0.25 : root.height * 0.25 + property real windowRadius: Settings.roundedWindowEnabled ? (Settings.direction === DockSettings.Left) ? root.width * 0.25 : root.height * 0.25 + : 0 property bool isHorizontal: Settings.direction !== DockSettings.Left property var appViewLength: isHorizontal ? appItemView.width : appItemView.height property var appViewHeight: isHorizontal ? appItemView.height : appItemView.width @@ -91,6 +92,7 @@ Item { anchors.fill: parent color: "transparent" radius: windowRadius + visible: windowRadius border.width: 1 border.color: Qt.rgba(0, 0, 0, 0.5) antialiasing: true @@ -101,6 +103,7 @@ Item { anchors.fill: parent anchors.margins: 1 radius: windowRadius - 1 + visible: windowRadius color: "transparent" border.width: 1 border.color: Qt.rgba(255, 255, 255, 0.3) diff --git a/src/docksettings.cpp b/src/docksettings.cpp index c6e5506..5eb0fa6 100644 --- a/src/docksettings.cpp +++ b/src/docksettings.cpp @@ -40,7 +40,7 @@ DockSettings::DockSettings(QObject *parent) : QObject(parent) , m_iconSize(0) , m_edgeMargins(10) - , m_statusBarHeight(30) + , m_roundedWindowEnabled(true) , m_direction(Left) , m_visibility(AlwaysVisible) , m_settings(new QSettings(QSettings::UserScope, "cutefishos", "dock")) @@ -52,11 +52,14 @@ DockSettings::DockSettings(QObject *parent) m_settings->setValue("Direction", Bottom); if (!m_settings->contains("Visibility")) m_settings->setValue("Visibility", AlwaysVisible); + if (!m_settings->contains("RoundedWindow")) + m_settings->setValue("RoundedWindow", true); m_settings->sync(); m_iconSize = m_settings->value("IconSize").toInt(); m_direction = static_cast(m_settings->value("Direction").toInt()); + m_roundedWindowEnabled = m_settings->value("RoundedWindow").toBool(); m_fileWatcher->addPath(m_settings->fileName()); connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &DockSettings::onConfigFileChanged); @@ -107,14 +110,17 @@ void DockSettings::setEdgeMargins(int edgeMargins) m_edgeMargins = edgeMargins; } -int DockSettings::statusBarHeight() const +bool DockSettings::roundedWindowEnabled() const { - return m_statusBarHeight; + return m_roundedWindowEnabled; } -void DockSettings::setStatusBarHeight(int statusBarHeight) +void DockSettings::setRoundedWindowEnabled(bool enabled) { - m_statusBarHeight = statusBarHeight; + if (m_roundedWindowEnabled != enabled) { + m_roundedWindowEnabled = enabled; + emit roundedWindowEnabledChanged(); + } } void DockSettings::onConfigFileChanged() @@ -127,6 +133,7 @@ void DockSettings::onConfigFileChanged() int iconSize = m_settings->value("IconSize").toInt(); Direction direction = static_cast(m_settings->value("Direction").toInt()); Visibility visibility = static_cast(m_settings->value("Visibility").toInt()); + bool roundedWindow = m_settings->value("RoundedWindow").toBool(); if (m_iconSize != iconSize) setIconSize(iconSize); @@ -137,5 +144,8 @@ void DockSettings::onConfigFileChanged() if (m_visibility != visibility) setVisibility(visibility); + if (m_roundedWindowEnabled != roundedWindow) + setRoundedWindowEnabled(roundedWindow); + m_fileWatcher->addPath(m_settings->fileName()); } diff --git a/src/docksettings.h b/src/docksettings.h index 700a444..3ac2729 100644 --- a/src/docksettings.h +++ b/src/docksettings.h @@ -30,6 +30,7 @@ class DockSettings : public QObject Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged) Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) Q_PROPERTY(int edgeMargins READ edgeMargins WRITE setEdgeMargins) + Q_PROPERTY(bool roundedWindowEnabled READ roundedWindowEnabled WRITE setRoundedWindowEnabled NOTIFY roundedWindowEnabledChanged) public: enum Direction { @@ -60,8 +61,8 @@ public: int edgeMargins() const; void setEdgeMargins(int edgeMargins); - int statusBarHeight() const; - void setStatusBarHeight(int statusBarHeight); + bool roundedWindowEnabled() const; + void setRoundedWindowEnabled(bool enabled); private slots: void onConfigFileChanged(); @@ -70,11 +71,12 @@ signals: void iconSizeChanged(); void directionChanged(); void visibilityChanged(); + void roundedWindowEnabledChanged(); private: int m_iconSize; int m_edgeMargins; - int m_statusBarHeight; + bool m_roundedWindowEnabled; Direction m_direction; Visibility m_visibility; QSettings *m_settings; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a864da0..a55c6a9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -67,6 +67,8 @@ MainWindow::MainWindow(QQuickView *parent) }); + connect(m_settings, &DockSettings::roundedWindowEnabledChanged, this, &MainWindow::resizeWindow); + connect(m_settings, &DockSettings::directionChanged, this, &MainWindow::onPositionChanged); connect(m_settings, &DockSettings::iconSizeChanged, this, &MainWindow::onIconSizeChanged); connect(m_settings, &DockSettings::visibilityChanged, this, &MainWindow::onVisibilityChanged); @@ -85,17 +87,30 @@ QRect MainWindow::windowRect() const switch (m_settings->direction()) { case DockSettings::Left: - newSize = QSize(m_settings->iconSize(), screenGeometry.height() - m_settings->edgeMargins()); - position = { screenGeometry.x() + DockSettings::self()->edgeMargins() / 2, - (screenGeometry.height() - newSize.height()) / 2 - }; + if (m_settings->roundedWindowEnabled()) { + newSize = QSize(m_settings->iconSize(), screenGeometry.height() - m_settings->edgeMargins()); + position = { screenGeometry.x() + DockSettings::self()->edgeMargins() / 2, + (screenGeometry.height() - newSize.height()) / 2 + }; + } else { + newSize = QSize(m_settings->iconSize(), screenGeometry.height()); + position = { screenGeometry.x(), (screenGeometry.height() - newSize.height()) / 2 }; + } break; case DockSettings::Bottom: - newSize = QSize(screenGeometry.width() - DockSettings::self()->edgeMargins(), m_settings->iconSize()); - position = { (screenGeometry.width() - newSize.width()) / 2, - screenGeometry.y() + screenGeometry.height() - newSize.height() - - DockSettings::self()->edgeMargins() / 2 - }; + if (m_settings->roundedWindowEnabled()) { + newSize = QSize(screenGeometry.width() - DockSettings::self()->edgeMargins(), m_settings->iconSize()); + position = { (screenGeometry.width() - newSize.width()) / 2, + screenGeometry.y() + screenGeometry.height() - newSize.height() + - DockSettings::self()->edgeMargins() / 2 + }; + } else { + newSize = QSize(screenGeometry.width(), m_settings->iconSize()); + position = { screenGeometry.x(), + screenGeometry.y() + screenGeometry.height() - newSize.height() + }; + + } break; default: break; diff --git a/src/xwindowinterface.cpp b/src/xwindowinterface.cpp index 30de604..b44c508 100644 --- a/src/xwindowinterface.cpp +++ b/src/xwindowinterface.cpp @@ -152,17 +152,19 @@ void XWindowInterface::setViewStruts(QWindow *view, DockSettings::Direction dire const QRect currentScreen { screen->geometry() }; const QRect wholeScreen { {0, 0}, screen->virtualSize() }; + bool roundedWindow = DockSettings::self()->roundedWindowEnabled(); + switch (direction) { case DockSettings::Left: { const int leftOffset = { screen->geometry().left() }; - strut.left_width = rect.width() + leftOffset + DockSettings::self()->edgeMargins(); + strut.left_width = rect.width() + leftOffset + (roundedWindow ? DockSettings::self()->edgeMargins() : 0); strut.left_start = rect.y(); strut.left_end = rect.y() + rect.height() - 1; break; } case DockSettings::Bottom: { const int bottomOffset { wholeScreen.bottom() - currentScreen.bottom() }; - strut.bottom_width = rect.height() + bottomOffset + (isMax ? 0 : DockSettings::self()->edgeMargins()); + strut.bottom_width = rect.height() + bottomOffset + (roundedWindow ? DockSettings::self()->edgeMargins() : 0); strut.bottom_start = rect.x(); strut.bottom_end = rect.x() + rect.width(); break; diff --git a/translations/en_US.ts b/translations/en_US.ts index 91ec4e5..425ffd0 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -27,7 +27,7 @@ ApplicationModel - + Launcher @@ -35,30 +35,30 @@ ControlDialog - + Wi-Fi - - + + On - - - + + + Off - + Bluetooth - + Dark Mode diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 68d01ad..1658f67 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -27,7 +27,7 @@ ApplicationModel - + Launcher 应用启动器 @@ -35,30 +35,30 @@ ControlDialog - + Wi-Fi 无线网络 - - + + On 打开 - - - + + + Off 关闭 - + Bluetooth 蓝牙 - + Dark Mode 深色模式