Support setting to enable rounded corners
This commit is contained in:
parent
11e247d075
commit
3d53224ebb
8 changed files with 72 additions and 40 deletions
|
@ -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: {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<Direction>(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<Direction>(m_settings->value("Direction").toInt());
|
||||
Visibility visibility = static_cast<Visibility>(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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
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:
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<context>
|
||||
<name>ApplicationModel</name>
|
||||
<message>
|
||||
<location filename="../src/applicationmodel.cpp" line="279"/>
|
||||
<location filename="../src/applicationmodel.cpp" line="282"/>
|
||||
<source>Launcher</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -35,30 +35,30 @@
|
|||
<context>
|
||||
<name>ControlDialog</name>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="177"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="178"/>
|
||||
<source>Wi-Fi</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="180"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="201"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="181"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="204"/>
|
||||
<source>On</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="180"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="191"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="201"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="181"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="193"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="204"/>
|
||||
<source>Off</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="190"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="192"/>
|
||||
<source>Bluetooth</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="200"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="203"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<context>
|
||||
<name>ApplicationModel</name>
|
||||
<message>
|
||||
<location filename="../src/applicationmodel.cpp" line="279"/>
|
||||
<location filename="../src/applicationmodel.cpp" line="282"/>
|
||||
<source>Launcher</source>
|
||||
<translation>应用启动器</translation>
|
||||
</message>
|
||||
|
@ -35,30 +35,30 @@
|
|||
<context>
|
||||
<name>ControlDialog</name>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="177"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="178"/>
|
||||
<source>Wi-Fi</source>
|
||||
<translation>无线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="180"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="201"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="181"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="204"/>
|
||||
<source>On</source>
|
||||
<translation>打开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="180"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="191"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="201"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="181"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="193"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="204"/>
|
||||
<source>Off</source>
|
||||
<translation>关闭</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="190"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="192"/>
|
||||
<source>Bluetooth</source>
|
||||
<translation>蓝牙</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/ControlDialog.qml" line="200"/>
|
||||
<location filename="../qml/ControlDialog.qml" line="203"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation>深色模式</translation>
|
||||
</message>
|
||||
|
|
Loading…
Add table
Reference in a new issue