Skip to content

Commit

Permalink
fix: [mainwidow] The software page is not fully displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakueeen authored and deepin-mozart committed Jan 7, 2025
1 parent 55fabff commit 5f7068a
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/plugins/core/uicontroller/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ struct WidgetInfo
bool defaultVisible { true };
bool created { false }; // has already create dock
bool hiddenByManual { false };

std::function<AbstractWidget*()> createDWidgetFunc;

DWidget* getDWidget()
std::function<AbstractWidget *()> createDWidgetFunc;

DWidget *getDWidget()
{
if (!widget) {
if (createDWidgetFunc) {
auto abstractWidget = createDWidgetFunc();
auto abstractWidget = createDWidgetFunc();
icon = abstractWidget->getDisplayIcon();
widget = static_cast<DWidget *>(abstractWidget->qWidget());
Q_ASSERT(widget);
Expand All @@ -85,7 +85,7 @@ struct WidgetInfo
}
return widget;
}

void setWidget(DWidget *widget)
{
this->widget = widget;
Expand All @@ -98,7 +98,7 @@ struct WidgetInfo
return false;
};

private:
private:
DWidget *widget { nullptr };
};

Expand All @@ -123,8 +123,8 @@ class ControllerPrivate
{
MainWindow *mainWindow { nullptr };
loadingWidget *loadingwidget { nullptr };
WorkspaceWidget *workspace { nullptr }; // left default dock widget
WorkspaceWidget *rightspace { nullptr }; // right default dock widget
WorkspaceWidget *workspace { nullptr }; // left default dock widget
WorkspaceWidget *rightspace { nullptr }; // right default dock widget

DWidget *navigationToolBar { nullptr };
NavigationBar *navigationBar { nullptr };
Expand Down Expand Up @@ -504,9 +504,9 @@ void Controller::registerWidget(const QString &name, AbstractWidget *abstractWid
d->allWidgets.insert(name, widgetInfo);
}

void Controller::registerWidgetCreator(const QString &name, std::function<AbstractWidget*()> &widgetCreateFunc)
void Controller::registerWidgetCreator(const QString &name, std::function<AbstractWidget *()> &widgetCreateFunc)
{
if (d->allWidgets.contains(name))
if (d->allWidgets.contains(name))
return;

WidgetInfo widgetInfo;
Expand Down Expand Up @@ -752,7 +752,7 @@ void Controller::showRightspace()
connect(d->rightspace, &WorkspaceWidget::workSpaceWidgeSwitched, this, [=](const QString &title) {
d->mainWindow->setDockHeaderName(WN_RIGHTSPACE, title);
});
connect(rightSpaceInfo.dockWidget, &QDockWidget::visibilityChanged, d->showRightspaceBtn, [=](bool visible){ d->showRightspaceBtn->setChecked(visible); });
connect(rightSpaceInfo.dockWidget, &QDockWidget::visibilityChanged, d->showRightspaceBtn, [=](bool visible) { d->showRightspaceBtn->setChecked(visible); });
} else if (!rightSpaceInfo.hiddenByManual) {
d->mainWindow->showWidget(WN_RIGHTSPACE);
}
Expand Down Expand Up @@ -914,15 +914,17 @@ void Controller::initMainWindow()

loading();

auto desktop = QApplication::desktop();
int currentScreenIndex = desktop->screenNumber(d->mainWindow);
QList<QScreen *> screenList = QGuiApplication::screens();
if (!d->mainWindow->isMaximized()) {
auto desktop = QApplication::desktop();
int currentScreenIndex = desktop->screenNumber(d->mainWindow);
QList<QScreen *> screenList = QGuiApplication::screens();

if (currentScreenIndex < screenList.count()) {
QRect screenRect = screenList[currentScreenIndex]->geometry();
int screenWidth = screenRect.width();
int screenHeight = screenRect.height();
d->mainWindow->move((screenWidth - d->mainWindow->width()) / 2, (screenHeight - d->mainWindow->height()) / 2);
if (currentScreenIndex < screenList.count()) {
QRect screenRect = screenList[currentScreenIndex]->geometry();
int screenWidth = screenRect.width();
int screenHeight = screenRect.height();
d->mainWindow->move((screenWidth - d->mainWindow->width()) / 2, (screenHeight - d->mainWindow->height()) / 2);
}
}

connect(d->mainWindow, &MainWindow::dockHidden, this, [=](const QString &dockName) {
Expand Down

0 comments on commit 5f7068a

Please sign in to comment.