代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/ukui-menu 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 58482ffe6e2752173739827989bbf1135bc8104a Mon Sep 17 00:00:00 2001
From: liuhao-startmenu <liuhao@kylinos.cn>
Date: Thu, 26 Mar 2020 22:29:09 +0800
Subject: [PATCH] Fixed size problem with multiple screens
---
src/FunctionWidget/fullfunctionwidget.cpp | 57 +++++++++----------
src/MainWindow/mainwindow.cpp | 7 ++-
src/MainWindow/mainwindow.h | 2 +-
.../qtsingleapplication.cpp | 12 ++--
src/Style/style.cpp | 14 ++---
src/Style/style.h | 1 +
ukui-menu.desktop | 2 +-
7 files changed, 45 insertions(+), 50 deletions(-)
diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp
index 0223db7..8c0e29d 100644
--- a/src/FunctionWidget/fullfunctionwidget.cpp
+++ b/src/FunctionWidget/fullfunctionwidget.cpp
@@ -300,27 +300,25 @@ void FullFunctionWidget::updateAppListView()
pBtnGroup->removeButton(button);
}
buttonList.clear();
-// iconlistscrollareawidLayout->removeItem(pIconListTopSpacer);
-// iconlistscrollareawidLayout->removeItem(pIconListBottomSpacer);
-// while ((child = iconlistscrollareawidLayout->takeAt(0)) != 0) {
-// QWidget* wid=child->widget();
-// iconlistscrollareawidLayout->removeWidget(wid);
-// wid->setParent(nullptr);
-// delete wid;
-// delete child;
-// }
+ while ((child = iconlistscrollareawidLayout->takeAt(0)) != 0) {
+ QWidget* wid=child->widget();
+ iconlistscrollareawidLayout->removeWidget(wid);
+ wid->setParent(nullptr);
+ delete wid;
+ delete child;
+ }
- for(int i=iconlistscrollareawidLayout->count()-2;i>0;i--)
- {
- if((child = iconlistscrollareawidLayout->takeAt(i)) != 0)
- {
- QWidget* wid=child->widget();
- iconlistscrollareawidLayout->removeWidget(wid);
- wid->setParent(nullptr);
- delete wid;
- delete child;
- }
- }
+// for(int i=iconlistscrollareawidLayout->count()-2;i>0;i--)
+// {
+// if((child = iconlistscrollareawidLayout->takeAt(i)) != 0)
+// {
+// QWidget* wid=child->widget();
+// iconlistscrollareawidLayout->removeWidget(wid);
+// wid->setParent(nullptr);
+// delete wid;
+// delete child;
+// }
+// }
initIconListScrollArea();
}
@@ -373,21 +371,20 @@ void FullFunctionWidget::initIconListWidget()
iconlistWid->setLayout(iconlistLayout);
iconlistscrollarea=new ClassifyScrollArea();
- iconlistscrollarea->setFixedSize(Style::LeftBtnWidth,iconlistWid->height());
+// iconlistscrollarea->setFixedSize(Style::LeftBtnWidth,iconlistWid->height());
iconlistscrollareaWid=new QWidget;
iconlistscrollareawidLayout=new QVBoxLayout;
iconlistscrollareawidLayout->setContentsMargins(0,0,0,0);
iconlistscrollareawidLayout->setSpacing(Style::LeftSpaceBetweenItem);
iconlistscrollareaWid->setLayout(iconlistscrollareawidLayout);
iconlistscrollarea->setWidget(iconlistscrollareaWid);
- iconlistLayout->addWidget(iconlistscrollarea);
- pBtnGroup=new QButtonGroup(iconlistscrollareaWid);
-// iconlistscrollarea->setStyleSheet("border:1px solid #ff0000;");
-// iconlistscrollareaWid->setStyleSheet("border:1px solid #00ff00;");
+
pIconListTopSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
pIconListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding);
- iconlistscrollareawidLayout->addItem(pIconListTopSpacer);
- iconlistscrollareawidLayout->addItem(pIconListBottomSpacer);
+ iconlistLayout->addItem(pIconListTopSpacer);
+ iconlistLayout->addWidget(iconlistscrollarea);
+ iconlistLayout->addItem(pIconListBottomSpacer);
+ pBtnGroup=new QButtonGroup(iconlistscrollareaWid);
initIconListScrollArea();
}
@@ -396,6 +393,8 @@ void FullFunctionWidget::initIconListWidget()
*/
void FullFunctionWidget::initIconListScrollArea()
{
+ iconlistscrollarea->setFixedSize(Style::LeftBtnWidth,
+ classificationbtnlist.size()*Style::LeftBtnHeight+(classificationbtnlist.size()-1)*Style::LeftSpaceBetweenItem);
for(int i=0;i<classificationbtnlist.size();i++)
{
FunctionClassifyButton* iconbtn=new FunctionClassifyButton(this,
@@ -412,8 +411,8 @@ void FullFunctionWidget::initIconListScrollArea()
true,
true);
buttonList.append(iconbtn);
-// iconlistscrollareawidLayout->addWidget(iconbtn);
- iconlistscrollareawidLayout->insertWidget(i+1,iconbtn);
+ iconlistscrollareawidLayout->addWidget(iconbtn);
+// iconlistscrollareawidLayout->insertWidget(i+1,iconbtn);
connect(iconbtn,SIGNAL(buttonClicked(QAbstractButton*)),pBtnGroup, SIGNAL(buttonClicked(QAbstractButton*)));
}
diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp
index 97c8daf..27dc2e9 100644
--- a/src/MainWindow/mainwindow.cpp
+++ b/src/MainWindow/mainwindow.cpp
@@ -171,7 +171,8 @@ void MainWindow::initMainWindow()
connect(mainviewwid,SIGNAL(sendHideMainWindowSignal()),this,SLOT(recvHideMainWindowSlot()));
connect(sidebarwid,SIGNAL(sendHideMainWindowSignal()),this,SLOT(recvHideMainWindowSlot()));
- connect(QApplication::desktop(),SIGNAL(resized(int)),this,SLOT(monitorResolutionChange(int)));
+ connect(QApplication::primaryScreen(),SIGNAL(geometryChanged(QRect)),
+ this,SLOT(monitorResolutionChange(QRect)));
}
/**
@@ -392,9 +393,9 @@ void MainWindow::mainWindowMakeZero()
// pLeaveAnimation->start();
//}
-void MainWindow::monitorResolutionChange(int screen)
+void MainWindow::monitorResolutionChange(QRect rect)
{
- Q_UNUSED(screen);
+ Q_UNUSED(rect);
qApp->quit();
QProcess::startDetached(QString("/usr/bin/ukui-menu"));
}
diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h
index 8ae3292..28f9997 100644
--- a/src/MainWindow/mainwindow.h
+++ b/src/MainWindow/mainwindow.h
@@ -80,7 +80,7 @@ private Q_SLOTS:
void showDefaultWidget();//显示默认窗口
void recvHideMainWindowSlot();//接收隐藏主窗口信号
// void recv_hover_signal_slot(bool is_hover);
- void monitorResolutionChange(int screen);//监控屏幕分辨率
+ void monitorResolutionChange(QRect rect);//监控屏幕分辨率
};
#endif // MAINWINDOW_H
diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp
index 7b14df0..4a9294d 100644
--- a/src/QtSingleApplication/qtsingleapplication.cpp
+++ b/src/QtSingleApplication/qtsingleapplication.cpp
@@ -344,26 +344,26 @@ void QtSingleApplication::activateWindow()
if(ret)
{
if(position==0)
- actWin->setGeometry(QRect(0,0,this->desktop()->width(),this->desktop()->height()-panelSize));
+ actWin->setGeometry(QRect(0,0,this->primaryScreen()->geometry().width(),this->primaryScreen()->geometry().height()-panelSize));
else if(position==1)
- actWin->setGeometry(QRect(0,panelSize,this->desktop()->width(),this->desktop()->height()-panelSize));
+ actWin->setGeometry(QRect(0,panelSize,this->primaryScreen()->geometry().width(),this->primaryScreen()->geometry().height()-panelSize));
else if(position==2)
- actWin->setGeometry(QRect(panelSize,0,this->desktop()->width()-panelSize,this->desktop()->height()));
+ actWin->setGeometry(QRect(panelSize,0,this->primaryScreen()->geometry().width()-panelSize,this->primaryScreen()->geometry().height()));
else
- actWin->setGeometry(QRect(0,0,this->desktop()->width()-panelSize,this->desktop()->height()));
+ actWin->setGeometry(QRect(0,0,this->primaryScreen()->geometry().width()-panelSize,this->primaryScreen()->geometry().height()));
}
else {
w->setFrameStyle();
if(position==0)
- actWin->setGeometry(QRect(0,this->desktop()->height()-panelSize-actWin->height(),
+ actWin->setGeometry(QRect(0,this->primaryScreen()->geometry().height()-panelSize-actWin->height(),
actWin->width(),actWin->height()));
else if(position==1)
actWin->setGeometry(QRect(0,panelSize,actWin->width(),actWin->height()));
else if(position==2)
actWin->setGeometry(QRect(panelSize,0,actWin->width(),actWin->height()));
else
- actWin->setGeometry(QRect(this->desktop()->width()-panelSize-actWin->width(),0,
+ actWin->setGeometry(QRect(this->primaryScreen()->geometry().width()-panelSize-actWin->width(),0,
actWin->width(),actWin->height()));
}
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
diff --git a/src/Style/style.cpp b/src/Style/style.cpp
index b3bc629..4a8ae47 100644
--- a/src/Style/style.cpp
+++ b/src/Style/style.cpp
@@ -82,7 +82,6 @@ void Style::initWidStyle()
QString value=setting->get("font-name").toString();
QStringList valstr=value.split(" ");
int fontSize=valstr.at(valstr.count()-1).toInt();
-// int fontSize=14;
QDBusInterface iface("com.ukui.panel.desktop",
"/",
@@ -91,22 +90,17 @@ void Style::initWidStyle()
QDBusReply<int> position=iface.call("GetPanelPosition","");
QDBusReply<int> panelSize=iface.call("GetPanelSize","");
-// int widthavailable=0;
-// int heightavailable=0;
if(position==0 || position==1)
{
- widthavailable=QApplication::desktop()->width();
- heightavailable=QApplication::desktop()->height()-panelSize;
+ widthavailable=QApplication::primaryScreen()->geometry().width();
+ heightavailable=QApplication::primaryScreen()->geometry().height()-panelSize;
}
if(position==2 || position==3)
{
- widthavailable=QApplication::desktop()->width()-panelSize;
- heightavailable=QApplication::desktop()->height();
+ widthavailable=QApplication::primaryScreen()->geometry().width()-panelSize;
+ heightavailable=QApplication::primaryScreen()->geometry().height();
}
- QApplication::desktop()->width();
-// int height=QApplication::desktop()->height();
-// int heightavailable=QApplication::desktop()->availableGeometry().height();
if(widthavailable>=2000 && widthavailable<=4000)
{
MainViewWidWidth=widthavailable-round((widthavailable-1440)/2);
diff --git a/src/Style/style.h b/src/Style/style.h
index e6cac50..f20a79d 100644
--- a/src/Style/style.h
+++ b/src/Style/style.h
@@ -25,6 +25,7 @@
#include <QDBusReply>
#include <QDBusInterface>
#include <qgsettings.h>
+#include <QScreen>
//颜色
#define BORDERCOLOR "rgba(37,41,43)" //边框
diff --git a/ukui-menu.desktop b/ukui-menu.desktop
index 39f263b..0fc2e77 100644
--- a/ukui-menu.desktop
+++ b/ukui-menu.desktop
@@ -8,4 +8,4 @@ Type=Application
Icon=ukui-menu
X-UKUI-AutoRestart=true
OnlyShowIn=UKUI
-X-UKUI-Autostart-Phase=Applications
+X-UKUI-Autostart-Phase=Application
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。