Add new style
This commit is contained in:
parent
1194e01512
commit
a1761b3ddb
7 changed files with 107 additions and 21 deletions
15
qml/main.qml
15
qml/main.qml
|
@ -37,6 +37,10 @@ Item {
|
|||
mainWindow.updateSize()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log(Settings.style)
|
||||
}
|
||||
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
enabled: true
|
||||
|
@ -46,9 +50,9 @@ Item {
|
|||
Rectangle {
|
||||
id: _background
|
||||
anchors.fill: parent
|
||||
radius: root.compositing ? windowRadius : 0
|
||||
radius: root.compositing && Settings.style === 0 ? windowRadius : 0
|
||||
color: FishUI.Theme.darkMode ? "#666666" : "#E6E6E6"
|
||||
opacity: root.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.4 : 0.9
|
||||
opacity: root.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.5 : 0.9
|
||||
border.width: 0
|
||||
|
||||
Behavior on color {
|
||||
|
@ -67,13 +71,13 @@ Item {
|
|||
view: mainWindow
|
||||
geometry: Qt.rect(root.x, root.y, root.width, root.height)
|
||||
strength: 1
|
||||
radius: root.windowRadius
|
||||
radius: _background.radius
|
||||
}
|
||||
|
||||
FishUI.WindowBlur {
|
||||
view: mainWindow
|
||||
geometry: Qt.rect(root.x, root.y, root.width, root.height)
|
||||
windowRadius: root.windowRadius
|
||||
windowRadius: _background.radius
|
||||
enabled: true
|
||||
}
|
||||
|
||||
|
@ -86,6 +90,9 @@ Item {
|
|||
GridLayout {
|
||||
id: mainLayout
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Settings.style === 1
|
||||
&& (Settings.direction === 0 || Settings.direction === 2)
|
||||
? 28 : 0
|
||||
flow: isHorizontal ? Grid.LeftToRight : Grid.TopToBottom
|
||||
columnSpacing: 0
|
||||
rowSpacing: 0
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<method name="setDirection"><arg name="direction" type="i" direction="in"/></method>
|
||||
<method name="setIconSize"><arg name="iconSize" type="i" direction="in"/></method>
|
||||
<method name="setVisibility"><arg name="visibility" type="i" direction="in"/></method>
|
||||
<method name="setStyle"><arg name="style" type="i" direction="in"/></method>
|
||||
|
||||
<property name="primaryGeometry" type="(iiii)" access="read">
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QRect"/>
|
||||
|
@ -18,9 +19,12 @@
|
|||
|
||||
<property name="direction" type="i" access="read"></property>
|
||||
<property name="visibility" type="i" access="read"></property>
|
||||
<property name="style" type="i" access="read"></property>
|
||||
|
||||
<signal name="primaryGeometryChanged"></signal>
|
||||
<signal name="directionChanged"></signal>
|
||||
<signal name="visibilityChanged"></signal>
|
||||
<signal name="styleChanged"></signal>
|
||||
|
||||
</interface>
|
||||
</node>
|
||||
|
|
|
@ -53,6 +53,8 @@ DockSettings::DockSettings(QObject *parent)
|
|||
m_settings->setValue("Visibility", AlwaysShow);
|
||||
if (!m_settings->contains("RoundedWindow"))
|
||||
m_settings->setValue("RoundedWindow", true);
|
||||
if (!m_settings->contains("Style"))
|
||||
m_settings->setValue("Style", Straight);
|
||||
|
||||
m_settings->sync();
|
||||
|
||||
|
@ -60,6 +62,7 @@ DockSettings::DockSettings(QObject *parent)
|
|||
m_direction = static_cast<Direction>(m_settings->value("Direction").toInt());
|
||||
m_visibility = static_cast<Visibility>(m_settings->value("Visibility").toInt());
|
||||
m_roundedWindowEnabled = m_settings->value("RoundedWindow").toBool();
|
||||
m_style = static_cast<Style>(m_settings->value("Style").toInt());
|
||||
}
|
||||
|
||||
int DockSettings::iconSize() const
|
||||
|
@ -126,3 +129,17 @@ void DockSettings::setRoundedWindowEnabled(bool enabled)
|
|||
emit roundedWindowEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
DockSettings::Style DockSettings::style() const
|
||||
{
|
||||
return m_style;
|
||||
}
|
||||
|
||||
void DockSettings::setStyle(const DockSettings::Style &style)
|
||||
{
|
||||
if (m_style != style) {
|
||||
m_style = style;
|
||||
m_settings->setValue("Style", style);
|
||||
emit styleChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class DockSettings : public QObject
|
|||
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)
|
||||
Q_PROPERTY(Style style READ style WRITE setStyle NOTIFY styleChanged)
|
||||
|
||||
public:
|
||||
enum Direction {
|
||||
|
@ -47,6 +48,12 @@ public:
|
|||
};
|
||||
Q_ENUMS(Visibility)
|
||||
|
||||
enum Style {
|
||||
Round = 0,
|
||||
Straight
|
||||
};
|
||||
Q_ENUMS(Style)
|
||||
|
||||
static DockSettings *self();
|
||||
explicit DockSettings(QObject *parent = nullptr);
|
||||
|
||||
|
@ -65,11 +72,15 @@ public:
|
|||
bool roundedWindowEnabled() const;
|
||||
void setRoundedWindowEnabled(bool enabled);
|
||||
|
||||
Style style() const;
|
||||
void setStyle(const Style &style);
|
||||
|
||||
signals:
|
||||
void iconSizeChanged();
|
||||
void directionChanged();
|
||||
void visibilityChanged();
|
||||
void roundedWindowEnabledChanged();
|
||||
void styleChanged();
|
||||
|
||||
private:
|
||||
int m_iconSize;
|
||||
|
@ -77,6 +88,7 @@ private:
|
|||
bool m_roundedWindowEnabled;
|
||||
Direction m_direction;
|
||||
Visibility m_visibility;
|
||||
Style m_style;
|
||||
QSettings *m_settings;
|
||||
};
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ MainWindow::MainWindow(QQuickView *parent)
|
|||
connect(m_settings, &DockSettings::directionChanged, this, &MainWindow::onPositionChanged);
|
||||
connect(m_settings, &DockSettings::iconSizeChanged, this, &MainWindow::onIconSizeChanged);
|
||||
connect(m_settings, &DockSettings::visibilityChanged, this, &MainWindow::onVisibilityChanged);
|
||||
connect(m_settings, &DockSettings::styleChanged, this, &MainWindow::resizeWindow);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -143,6 +144,16 @@ void MainWindow::setVisibility(int visibility)
|
|||
DockSettings::self()->setVisibility(static_cast<DockSettings::Visibility>(visibility));
|
||||
}
|
||||
|
||||
int MainWindow::style() const
|
||||
{
|
||||
return DockSettings::self()->style();
|
||||
}
|
||||
|
||||
void MainWindow::setStyle(int style)
|
||||
{
|
||||
DockSettings::self()->setStyle(static_cast<DockSettings::Style>(style));
|
||||
}
|
||||
|
||||
void MainWindow::updateSize()
|
||||
{
|
||||
resizeWindow();
|
||||
|
@ -171,14 +182,15 @@ QRect MainWindow::windowRect() const
|
|||
int iconSize = m_settings->iconSize();
|
||||
iconSize += iconSize * 0.1;
|
||||
int length = appCount * iconSize;
|
||||
int margins = compositing ? DockSettings::self()->edgeMargins() / 2 : 0;
|
||||
|
||||
if (length >= maxLength) {
|
||||
iconSize = (maxLength - (maxLength % appCount)) / appCount;
|
||||
length = appCount * iconSize;
|
||||
}
|
||||
|
||||
int margins = compositing ? DockSettings::self()->edgeMargins() / 2 : 0;
|
||||
|
||||
switch (m_settings->style()) {
|
||||
case DockSettings::Round: {
|
||||
switch (m_settings->direction()) {
|
||||
case DockSettings::Left:
|
||||
newSize = QSize(iconSize, length);
|
||||
|
@ -200,6 +212,34 @@ QRect MainWindow::windowRect() const
|
|||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case DockSettings::Straight: {
|
||||
switch (m_settings->direction()) {
|
||||
case DockSettings::Left:
|
||||
newSize = QSize(iconSize, screenGeometry.height());
|
||||
position.setX(screenGeometry.x());
|
||||
position.setY(screenGeometry.y());
|
||||
break;
|
||||
case DockSettings::Bottom:
|
||||
newSize = QSize(screenGeometry.width(), iconSize);
|
||||
position.setX(screenGeometry.x());
|
||||
position.setY(screenGeometry.y() + screenGeometry.height() - newSize.height());
|
||||
break;
|
||||
case DockSettings::Right:
|
||||
newSize = QSize(iconSize, screenGeometry.height());
|
||||
position.setX(screenGeometry.x() + screenGeometry.width() - newSize.width());
|
||||
position.setY(screenGeometry.y() + screenGeometry.height() - newSize.height());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QRect(position, newSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class MainWindow : public QQuickView
|
|||
Q_PROPERTY(QRect primaryGeometry READ primaryGeometry NOTIFY primaryGeometryChanged)
|
||||
Q_PROPERTY(int direction READ direction NOTIFY directionChanged)
|
||||
Q_PROPERTY(int visibility READ visibility NOTIFY visibilityChanged)
|
||||
Q_PROPERTY(int style READ style NOTIFY styleChanged)
|
||||
|
||||
public:
|
||||
explicit MainWindow(QQuickView *parent = nullptr);
|
||||
|
@ -54,6 +55,9 @@ public:
|
|||
void setIconSize(int iconSize);
|
||||
void setVisibility(int visibility);
|
||||
|
||||
int style() const;
|
||||
void setStyle(int style);
|
||||
|
||||
Q_INVOKABLE void updateSize();
|
||||
|
||||
signals:
|
||||
|
@ -62,6 +66,7 @@ signals:
|
|||
void directionChanged();
|
||||
void primaryGeometryChanged();
|
||||
void visibilityChanged();
|
||||
void styleChanged();
|
||||
|
||||
private:
|
||||
QRect windowRect() const;
|
||||
|
|
|
@ -151,7 +151,8 @@ void XWindowInterface::setViewStruts(QWindow *view, DockSettings::Direction dire
|
|||
|
||||
// const QRect currentScreen {screen->geometry()};
|
||||
const QRect wholeScreen { {0, 0}, screen->virtualSize() };
|
||||
const int edgeMargins = compositing ? DockSettings::self()->edgeMargins() : 0;
|
||||
bool isRound = DockSettings::self()->style() == DockSettings::Round;
|
||||
const int edgeMargins = compositing && isRound? DockSettings::self()->edgeMargins() : 0;
|
||||
|
||||
switch (direction) {
|
||||
case DockSettings::Left: {
|
||||
|
|
Loading…
Reference in a new issue