Handle the top statusbar

This commit is contained in:
cutefishd 2021-03-24 20:43:50 +08:00
parent 06d779de92
commit bdc3b08027
3 changed files with 11 additions and 12 deletions

View file

@ -1,6 +1,5 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
// import Qt.labs.platform 1.0
import Cutefish.Dock 1.0 import Cutefish.Dock 1.0
DockItem { DockItem {

View file

@ -3,7 +3,6 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import Cyber.NetworkManagement 1.0 as NM
import Cutefish.Dock 1.0 import Cutefish.Dock 1.0
import MeuiKit 1.0 as Meui import MeuiKit 1.0 as Meui

View file

@ -81,13 +81,14 @@ MainWindow::~MainWindow()
QRect MainWindow::windowRect() const QRect MainWindow::windowRect() const
{ {
const QRect screenGeometry = qApp->primaryScreen()->geometry(); const QRect screenGeometry = qApp->primaryScreen()->geometry();
const QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
bool isHorizontal = m_settings->direction() == DockSettings::Bottom;
QSize newSize(0, 0); QSize newSize(0, 0);
QPoint position(0, 0); QPoint position(0, 0);
int maxLength = isHorizontal ? screenGeometry.width() - m_settings->edgeMargins()
const int maxLength = (m_settings->direction() == DockSettings::Left) ? : availableGeometry.height() - m_settings->edgeMargins();;
screenGeometry.height() - m_settings->edgeMargins() / 2:
screenGeometry.width() - m_settings->edgeMargins() / 2;
int appCount = m_appModel->rowCount(); int appCount = m_appModel->rowCount();
int iconSize = m_settings->iconSize(); int iconSize = m_settings->iconSize();
@ -101,15 +102,15 @@ QRect MainWindow::windowRect() const
switch (m_settings->direction()) { switch (m_settings->direction()) {
case DockSettings::Left: case DockSettings::Left:
newSize = QSize(iconSize, length); newSize = QSize(iconSize, length);
position = { screenGeometry.x() + DockSettings::self()->edgeMargins() / 2, position.setX(screenGeometry.x() + DockSettings::self()->edgeMargins() / 2);
screenGeometry.y() };
position.setY((screenGeometry.height() - newSize.height()) / 2); // Handle the top statusbar.
position.setY(availableGeometry.y() + (availableGeometry.height() - newSize.height()) / 2);
break; break;
case DockSettings::Bottom: case DockSettings::Bottom:
newSize = QSize(length, iconSize); newSize = QSize(length, iconSize);
position = { screenGeometry.x(), position.setX(screenGeometry.x() + (screenGeometry.width() - newSize.width()) / 2);
screenGeometry.y() + screenGeometry.height() - newSize.height() - DockSettings::self()->edgeMargins() / 2}; position.setY(screenGeometry.y() + screenGeometry.height() - newSize.height() - DockSettings::self()->edgeMargins() / 2);
position.setX((screenGeometry.width() - newSize.width()) / 2);
break; break;
default: default:
break; break;