From 315b686aeced7e4a3ce8fe3fd2dd72efbc299fea Mon Sep 17 00:00:00 2001 From: tanjing Date: Wed, 2 Mar 2022 17:47:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E6=98=BE=E7=A4=BA=E4=B8=8E=E5=90=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/mainwindow.cpp | 68 +++++++++++++++----------- tools/mainwindow.h | 5 +- tools/myiconlabel.cpp | 106 ++--------------------------------------- tools/myiconlabel.h | 11 +---- tools/mypushbutton.cpp | 18 ++----- tools/mypushbutton.h | 6 +-- 6 files changed, 58 insertions(+), 156 deletions(-) diff --git a/tools/mainwindow.cpp b/tools/mainwindow.cpp index 4dadfc4..f4e53e6 100644 --- a/tools/mainwindow.cpp +++ b/tools/mainwindow.cpp @@ -192,9 +192,9 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent) initialMessageWidget(); - int hideNum = 3; + int hideNum = 7; //Make a hash-map to store tableNum-to-lastWidget - if (m_power->canAction(UkuiPower::PowerHibernate)) {//m_power->canAction(UkuiPower::PowerHibernate) + if (m_power->canAction(UkuiPower::PowerHibernate)) { isHibernateHide = false; hideNum--; } @@ -204,7 +204,22 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent) hideNum--; } - if (LockChecker::getCachedUsers() > 1) { + if (m_power->canAction(UkuiPower::PowerLogout)) { + isLogoutHide = false; + hideNum--; + } + + if (m_power->canAction(UkuiPower::PowerReboot)) { + isRebootHide = false; + hideNum--; + } + + if (m_power->canAction(UkuiPower::PowerShutdown)) { + isPowerOffHide = false; + hideNum--; + } + + if (LockChecker::getCachedUsers() > 1 && m_power->canAction(UkuiPower::PowerSwitchUser)) { isSwitchuserHide = false; hideNum--; } @@ -373,13 +388,13 @@ void MainWindow::initialSystemMonitor() void MainWindow::initialBtn() { - m_switchUserBtn = new MyPushButton(m_btnImagesPath+"/switchuser.svg", QApplication::tr("Switch User"), "switchuser", m_scrollArea, !m_IsRoundBtn); - m_hibernateBtn = new MyPushButton(m_btnImagesPath+"/hibernate.svg", QApplication::tr("Hibernate"), "hibernate", m_scrollArea, !m_IsRoundBtn); - m_suspendBtn = new MyPushButton(m_btnImagesPath+"/suspend.svg", QApplication::tr("Suspend"), "suspend", m_scrollArea, !m_IsRoundBtn); - m_logoutBtn = new MyPushButton(m_btnImagesPath+"/logout.svg", QApplication::tr("Logout"), "logout", m_scrollArea, !m_IsRoundBtn); - m_rebootBtn = new MyPushButton(m_btnImagesPath+"/reboot.svg", QApplication::tr("Reboot"), "reboot", m_scrollArea, !m_IsRoundBtn); - m_shutDownBtn = new MyPushButton(m_btnImagesPath+"/shutdown.svg", QApplication::tr("Shut Down"), "shutdown", m_scrollArea, !m_IsRoundBtn); - m_lockScreenBtn = new MyPushButton(m_btnImagesPath+"/lockscreen.svg", QApplication::tr("Lock Screen"), "lockscreen", m_scrollArea, !m_IsRoundBtn); + m_switchUserBtn = new MyPushButton(m_btnImagesPath+"/switchuser.svg", QApplication::tr("Switch User"), "switchuser", m_scrollArea); + m_hibernateBtn = new MyPushButton(m_btnImagesPath+"/hibernate.svg", QApplication::tr("Hibernate"), "hibernate", m_scrollArea); + m_suspendBtn = new MyPushButton(m_btnImagesPath+"/suspend.svg", QApplication::tr("Suspend"), "suspend", m_scrollArea); + m_logoutBtn = new MyPushButton(m_btnImagesPath+"/logout.svg", QApplication::tr("Logout"), "logout", m_scrollArea); + m_rebootBtn = new MyPushButton(m_btnImagesPath+"/reboot.svg", QApplication::tr("Reboot"), "reboot", m_scrollArea); + m_shutDownBtn = new MyPushButton(m_btnImagesPath+"/shutdown.svg", QApplication::tr("Shut Down"), "shutdown", m_scrollArea); + m_lockScreenBtn = new MyPushButton(m_btnImagesPath+"/lockscreen.svg", QApplication::tr("Lock Screen"), "lockscreen", m_scrollArea); //ui->setupUi(this); m_switchUserBtn->installEventFilter(this); @@ -400,12 +415,6 @@ void MainWindow::initialBtn() void MainWindow::initialJudgeWidget() { - int margins = 0; - if (m_screen.width() > 1088) { - margins = (m_screen.width() - 60 * 6 - 140 * 7) / 2; - } else { - margins = (m_screen.width() - 60 * 2 - 140 * 3) / 2; - } // QStringList userlist = getLoginedUsers(); QStringList userlist = LockChecker::getLoginedUsers(); if (userlist.count() > 1) { @@ -416,7 +425,7 @@ void MainWindow::initialJudgeWidget() m_judgeLabel->setText(tips); m_judgeLabel->setStyleSheet("color:white;font:12pt;"); m_judgeLabel->setObjectName("label"); - m_judgeLabel->setGeometry(0,0,m_screen.width() - 2 * margins,50); + m_judgeLabel->setGeometry(0,0,m_screen.width() - 160,50); //m_judgeLabel->setFixedHeight(60); qDebug() << "m_judgeLabel width:" << m_judgeLabel->width() << m_judgeLabel->height(); @@ -606,15 +615,18 @@ void MainWindow::initialBtnCfg() m_btnCfgSetting->setValue("btn/SwitchUserBtnHide", isSwitchuserHide); m_btnCfgSetting->setValue("btn/HibernateBtnHide", isHibernateHide); m_btnCfgSetting->setValue("btn/SuspendBtnHide", isSuspendHide); + m_btnCfgSetting->setValue("btn/LogoutBtnHide", isLogoutHide); + m_btnCfgSetting->setValue("btn/RebootBtnHide", isRebootHide); + m_btnCfgSetting->setValue("btn/ShutDownBtnHide", isPowerOffHide); qDebug() << "isHibernateHide..." << isHibernateHide; m_btnHideMap.insert(m_switchUserBtn, isSwitchuserHide); m_btnHideMap.insert(m_hibernateBtn, isHibernateHide); m_btnHideMap.insert(m_suspendBtn, isSuspendHide); m_btnHideMap.insert(m_lockScreenBtn, m_btnCfgSetting->value("btn/LockScreenBtnHide").toBool()); - m_btnHideMap.insert(m_logoutBtn, m_btnCfgSetting->value("btn/LogoutBtnHide").toBool()); - m_btnHideMap.insert(m_rebootBtn, m_btnCfgSetting->value("btn/RebootBtnHide").toBool()); - m_btnHideMap.insert(m_shutDownBtn, m_btnCfgSetting->value("btn/ShutDownBtnHide").toBool()); + m_btnHideMap.insert(m_logoutBtn, isLogoutHide); + m_btnHideMap.insert(m_rebootBtn, isRebootHide); + m_btnHideMap.insert(m_shutDownBtn, isPowerOffHide); } void MainWindow::setLayoutWidgetVisible(QLayout* layout, bool show) @@ -723,7 +735,7 @@ void MainWindow::showNormalBtnWidget(int hideNum) m_scrollArea->verticalScrollBar()->setVisible(false); m_scrollArea->verticalScrollBar()->setDisabled(true); - m_buttonHLayout->setContentsMargins(0,0,0,160); + m_buttonHLayout->setContentsMargins(0,0,0,260); for (int i = 0;i < m_buttonHLayout->count(); i++) { QLayoutItem*item = m_buttonHLayout->layout()->itemAt(i); @@ -830,16 +842,15 @@ void MainWindow::ResizeEvent() } // Move the widget to the direction where they should be - int recWidth; - if (m_IsRoundBtn) { - recWidth = 128; - } else { - recWidth = 140; - } for (int i = 0; i <= 6; i++) { - if (m_btnHideMap.value(map.value(i))) { + if (m_btnHideMap.value(map.value(i))) + { map[i]->hide(); } + else + { + map[i]->show(); + } } if((m_screen.width() -160 - 128 * (7 - hideNum))/(6-hideNum) >= 16) { @@ -1302,6 +1313,7 @@ void MainWindow::drawWarningWindow(QRect &rect) vBoxLayout->addWidget(tips); vBoxLayout->addWidget(applist, 0, Qt::AlignHCenter); + vBoxLayout->addSpacing(isEnoughBig ? 32 : 0); vBoxLayout->addLayout(hBoxLayout, Qt::AlignHCenter); //移动整个区域到指定的相对位置 diff --git a/tools/mainwindow.h b/tools/mainwindow.h index fc82c61..a2e418a 100644 --- a/tools/mainwindow.h +++ b/tools/mainwindow.h @@ -151,6 +151,10 @@ private: bool isSwitchuserHide = true; bool isHibernateHide = true; bool isSuspendHide = true; + bool isLogoutHide = true; + bool isRebootHide = true; + bool isPowerOffHide = true; + bool lockfile = false; bool lockuser = false; bool click_blank_space_need_to_exit = true; @@ -161,7 +165,6 @@ private: QHash m_btnHideMap; - bool m_IsRoundBtn = true;//是否是圆形按钮 QString m_btnImagesPath = "/usr/share/ukui/ukui-session-manager/images"; MyPushButton *m_switchUserBtn = nullptr; MyPushButton *m_hibernateBtn = nullptr; diff --git a/tools/myiconlabel.cpp b/tools/myiconlabel.cpp index d1024ec..5e9e00f 100644 --- a/tools/myiconlabel.cpp +++ b/tools/myiconlabel.cpp @@ -27,8 +27,7 @@ #include #include -MyIconLabel::MyIconLabel(int labelWidth, int iconWidth, QString path, bool showBackColor, QWidget *parent) - :m_showBackColor(showBackColor) +MyIconLabel::MyIconLabel(int labelWidth, int iconWidth, QString path, QWidget *parent) { this->setFixedSize(labelWidth, labelWidth); this->setObjectName("iconlabel"); @@ -44,13 +43,10 @@ MyIconLabel::MyIconLabel(int labelWidth, int iconWidth, QString path, bool showB m_btnIcon->setChecked(false); m_btnIcon->setGeometry(QRect((width() - iconWidth)/2, (width() - iconWidth)/2, iconWidth, iconWidth)); m_btnIcon->setAttribute(Qt::WA_TransparentForMouseEvents,true); - if (m_showBackColor) { - //mask不要与控件一样大 锯齿明显 稍微大一点 - this->setMask(QRegion(this->x() - 1, this->y() - 1, this->width() + 2, this->height() + 2,QRegion::Ellipse)); - this->setStyleSheet("QLabel#"+ this->objectName() + "{background-color: rgb(255,255,255,40);border-radius:" + QString::number(this->width()/2) + "px;}"); - } else { - this->setStyleSheet("QLabel#"+ this->objectName() + "{background-color: transparent;}"); - } + + //mask不要与控件一样大 锯齿明显 稍微大一点 + this->setMask(QRegion(this->x() - 1, this->y() - 1, this->width() + 2, this->height() + 2,QRegion::Ellipse)); + this->setStyleSheet("QLabel#"+ this->objectName() + "{background-color: rgb(255,255,255,40);border-radius:" + QString::number(this->width()/2) + "px;}"); //this->setPixmap(m_pixMap); this->setAlignment(Qt::AlignCenter); @@ -62,44 +58,6 @@ MyIconLabel::~MyIconLabel() { } -/* -void MyIconLabel::paintEvent(QPaintEvent *event) -{ - return; - QPainter painter(this); - QColor color; - if(m_isNormal) - color = QColor(255,255,255,40); - else if(m_isHover) - color = QColor(255,255,255,80); - else if(m_isClicked) - color = QColor(255,255,255,100); - painter.setPen(QPen(color,0)); - painter.setBrush(color); - painter.drawEllipse(QRect(0,0,width(),height())); - painter.drawPixmap(QRect((width() - m_btnIcon.width())/2, (height() - m_btnIcon.height())/2, m_btnIcon.width(), m_btnIcon.height()), m_btnIcon); -} -*/ -void MyIconLabel::enterEvent(QEvent *event) -{ - if (!m_showBackColor) return; - emit mouseEventSignals(event); - - QString str = "QLabel{background-color: rgb(255,255,255,80);border-radius: " + QString::number(this->width()/2) + "px;}"; - - this->setStyleSheet(str); - this->setAttribute(Qt::WA_StyledBackground); -} - -void MyIconLabel::leaveEvent(QEvent *event) -{ - return; - if (!m_showBackColor) return; - QString str = "QLabel{background-color: rgb(255,255,255,40);border-radius: " + QString::number(this->width()/2) + "px;}"; - this->setStyleSheet(str); - this->setAttribute(Qt::WA_StyledBackground); -} - bool MyIconLabel::event(QEvent *event) { // qDebug() << m_showBackColor << "event..." << event->type(); @@ -121,31 +79,6 @@ bool MyIconLabel::event(QEvent *event) return QWidget::event(event); } -/* -void MyIconLabel::mouseMoveEvent(QMouseEvent *event) -{ - return; -// m_point = event->pos(); -// qDebug() << "MyIconLabel mouseMoveEvent..." << m_point; - -// if(!m_showBackColor) -// return; -// QRegion region(this->x(), this->y(), this->width(), this->height(),QRegion::Ellipse); -// qDebug() << "MyIconLabel mouseMoveEvent..." << m_point << region; - -// QString str; - -// if(!region.contains(m_point)) -// str = "QLabel{background-color: rgb(255,255,255,40);border-radius: " + QString::number(this->width()/2) + "px;}"; -// else -// str = "QLabel{background-color: rgb(255,255,255,80);border-radius: " + QString::number(this->width()/2) + "px;}"; - -// this->setStyleSheet(str); -// this->setAttribute(Qt::WA_StyledBackground); - -} -*/ - bool MyIconLabel::containsPoint(QPoint p) { QPainterPath path; @@ -153,32 +86,3 @@ bool MyIconLabel::containsPoint(QPoint p) //qDebug() << "containsPoint..." << width() << height() << p << QRect(0,0,width(),height()); return path.contains(p); } - -/* -void MyIconLabel::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setPen(QPen(QColor(0,0,0),2)); - painter.setBrush(QColor(10,10,10)); - QPainterPath path; - QRect rect(10,50,100,48); - const qreal radius = 24; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter.drawPath(path); - qDebug() << "1111" << path.contains(QPoint(11,51)); -} - - -void MyIconLabel::mousePressEvent(QMouseEvent* event) -{ - qDebug() << "mousePressEvent..." << event->pos(); -} -*/ diff --git a/tools/myiconlabel.h b/tools/myiconlabel.h index 9546291..ad8b45d 100644 --- a/tools/myiconlabel.h +++ b/tools/myiconlabel.h @@ -36,24 +36,17 @@ class MyIconLabel : public QLabel Q_OBJECT public: - MyIconLabel(int labelWidth, int iconWidth, QString path, bool showBackClor, QWidget *parent = nullptr); + MyIconLabel(int labelWidth, int iconWidth, QString path, QWidget *parent = nullptr); ~MyIconLabel(); bool containsPoint(QPoint p); protected: - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); bool event(QEvent *); - //void paintEvent(QPaintEvent *event); - //void mouseMoveEvent(QMouseEvent *event); - //void mousePressEvent(QMouseEvent* event); + private: PushButton *m_btnIcon = nullptr; bool m_showBackColor = false; QPoint m_point; -// bool m_isNormal = true; -// bool m_isHover = false; -// bool m_isClicked = false; protected: public: diff --git a/tools/mypushbutton.cpp b/tools/mypushbutton.cpp index e54163f..72c9994 100644 --- a/tools/mypushbutton.cpp +++ b/tools/mypushbutton.cpp @@ -22,20 +22,16 @@ #include #include #include -MyPushButton::MyPushButton(QString iconPath, QString buttonLable, QString objName, QWidget *parent, bool isRecBtn, int x, int y, +MyPushButton::MyPushButton(QString iconPath, QString buttonLable, QString objName, QWidget *parent, int x, int y, int width, int height, int iconWidth, int labelWidth) - : m_isRecBtn(isRecBtn) - , QWidget(parent) + : QWidget(parent) { - if (m_isRecBtn) { - this->setFixedSize(width, width); - } else { - this->setFixedSize(labelWidth, height); - } + this->setFixedSize(labelWidth, height); + this->setObjectName(objName); QVBoxLayout *vBoxLayout = new QVBoxLayout(); vBoxLayout->setContentsMargins(0, 0, 0, 10); - m_iconLabel = new MyIconLabel(labelWidth, iconWidth, iconPath, !isRecBtn); + m_iconLabel = new MyIconLabel(labelWidth, iconWidth, iconPath); m_iconLabel->setObjectName(objName + "_button"); m_iconLabel->installEventFilter(this); @@ -46,10 +42,6 @@ MyPushButton::MyPushButton(QString iconPath, QString buttonLable, QString objNam m_buttonLabel->setStyleSheet("color: white; font: 12pt"); m_buttonLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop); - if (m_isRecBtn) { - this->setStyleSheet("QWidget#" + this->objectName() + "{background-color: transparent;border-radius: 6px;}"); - this->setAttribute(Qt::WA_StyledBackground); - } vBoxLayout->addWidget(m_iconLabel, 0, Qt::AlignHCenter); vBoxLayout->addWidget(m_buttonLabel, 0, Qt::AlignHCenter); this->setLayout(vBoxLayout); diff --git a/tools/mypushbutton.h b/tools/mypushbutton.h index 640c28b..988208d 100644 --- a/tools/mypushbutton.h +++ b/tools/mypushbutton.h @@ -35,9 +35,8 @@ class MyPushButton : public QWidget Q_OBJECT public: - MyPushButton(QString iconPath, QString buttonLable, QString objName, QWidget *parent = nullptr, bool isRecBtn=true, int x = 0, int y = 0, - int width = 140, int height = 180, int iconWidth = 48, - int labelWidth = 128); + MyPushButton(QString iconPath, QString buttonLable, QString objName, QWidget *parent = nullptr, int x = 0, int y = 0, + int width = 140, int height = 180, int iconWidth = 48, int labelWidth = 128); ~MyPushButton(); void changeIconBackColor(bool isChoose = true, bool isKeySelect = false); @@ -60,7 +59,6 @@ private: QFont m_buttonLabelFont; QPixmap m_pixMap; MyIconLabel *m_iconLabel = nullptr; - bool m_isRecBtn=true;//true 背景为整体 false表示背景只在ICON区域 bool m_isKeySelect = false;//是否通过键盘选中 bool m_isMouseSelect = false;//是否鼠标选中 protected: From 38b3f3aa33baac4501371fc28162593aa85e3a80 Mon Sep 17 00:00:00 2001 From: tanjing Date: Tue, 8 Mar 2022 11:23:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- tools/mainwindow.cpp | 14 +++-- tools/mainwindow.h | 123 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 119 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 601f64d..e5f8a94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if (NOT DEFINED UPDATE_TRANSLATIONS) set(UPDATE_TRANSLATIONS "No") endif() -# To create a new ts file: lupdate -recursive . -target-language en_US -ts translations/en_US.ts +# To create a new ts file: lupdate -recursive . -target-language en_US -ts translations/en_US.ts -no-ui-lines file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") # cmake -DUPDATE_TRANSLATIONS=yes diff --git a/tools/mainwindow.cpp b/tools/mainwindow.cpp index f4e53e6..134d76a 100644 --- a/tools/mainwindow.cpp +++ b/tools/mainwindow.cpp @@ -185,7 +185,6 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent) inhibitShutdown = true; } - user = getenv("USER"); lockfile = a; lockuser = b; @@ -246,7 +245,7 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent) m_vBoxLayout->addLayout(m_dateTimeLayout, 60); m_vBoxLayout->addStretch(); m_vBoxLayout->addLayout(m_judgeWidgetVLayout, 140); - m_vBoxLayout->addWidget(m_scrollArea,632); + m_vBoxLayout->addWidget(m_scrollArea, 632); m_vBoxLayout->addStretch(174); m_vBoxLayout->addLayout(m_messageVLayout, 80); //m_vBoxLayout->addWidget(m_systemMonitorBtn,48,Qt::AlignHCenter); @@ -257,8 +256,8 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent) qDebug() << "width..........." << m_judgeLabel->width() << m_scrollArea->width() << m_messageLabel1->width() << m_messageLabel2->width(); //根据屏幕分辨率与鼠标位置重设界面 //m_screen = QApplication::desktop()->screenGeometry(QCursor::pos()); - setFixedSize(QApplication::primaryScreen()->virtualSize()); - + //setFixedSize(QApplication::primaryScreen()->virtualSize()); + setGeometry(0, 0, QApplication::primaryScreen()->virtualSize().width(), QApplication::primaryScreen()->virtualSize().height()); move(0, 0);//设置初始位置的值 //设置窗体无边框,不可拖动拖拽拉伸;为顶层窗口,无法被切屏;不使用窗口管理器 @@ -668,7 +667,7 @@ void MainWindow::mouseReleaseSlots(QEvent *event, QString objName) { for (auto iter = map.begin(); iter != map.end(); iter++) { if (iter.value()->getIconLabel()->objectName() == objName) { - changePoint(iter.value(), event, iter.key()); + changePoint(iter.value(), event); if (event->type() == QEvent::MouseButtonRelease) { qDebug() << "mouseReleaseSlots..." << objName; doEvent(objName, iter.key()); @@ -825,6 +824,7 @@ void MainWindow::showHasScrollBarBtnWidget(int hideNum) void MainWindow::ResizeEvent() { m_screen = QApplication::desktop()->screenGeometry(QCursor::pos()); + setGeometry(0, 0, QApplication::primaryScreen()->virtualSize().width(), QApplication::primaryScreen()->virtualSize().height()); if(m_showWarningMesg) { @@ -946,7 +946,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) return QWidget::eventFilter(obj, event); } -void MainWindow::changePoint(QWidget *widget, QEvent *event, int i) +void MainWindow::changePoint(QWidget *widget, QEvent *event) { if (event->type() == QEvent::Enter) { changeBtnState(widget->objectName()); @@ -1366,8 +1366,6 @@ void MainWindow::judgeboxShow() } m_scrollArea->verticalScrollBar()->setVisible(false); - int xx = m_screen.x(); - int yy = m_screen.y(); //取得当前鼠标所在屏幕的最左,上坐标 setLayoutWidgetVisible(m_dateTimeLayout, false); setLayoutWidgetVisible(m_judgeWidgetVLayout, true); setLayoutWidgetVisible(m_judgeBtnHLayout, true); diff --git a/tools/mainwindow.h b/tools/mainwindow.h index a2e418a..b981919 100644 --- a/tools/mainwindow.h +++ b/tools/mainwindow.h @@ -47,10 +47,33 @@ public: MainWindow(bool a , bool b ,QWidget *parent = nullptr); ~MainWindow(); + /** + * @brief 响应按钮事件 + * @param test2 按钮名字 + * @param i 按钮序号 + */ void doEvent(QString test2,int i); - void changePoint(QWidget *widget ,QEvent *event ,int i); + + /** + * @brief 响应鼠标事件后改变按钮状态 + * @param widget 指定按钮对象 + * @param widget 鼠标事件 + */ + void changePoint(QWidget *widget ,QEvent *event); + + /** + * @brief 调整界面显示的控件 + */ void judgeboxShow(); + + /** + * @brief 模拟按键 + */ void keyPressEmulate(); + + /** + * @brief 消息过滤 + */ virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; //void closeEvent(QCloseEvent *event); @@ -97,28 +120,104 @@ public: void changeBtnState(QString btnName, bool isEnterKey = false); private: - QString getAppLocalName(QString desktopfp);//获取应用名 - void ResizeEvent(); - void showInhibitWarning();//当有inhibitor存在时显示提醒界面 - void drawWarningWindow(QRect &rect);//画出提醒界面 - QMap findNameAndIcon(QString &basename);//根据inhibitor的名称获取对应desktop文件中的应用名和icon路径 + /** + * @brief 获取应用名 + */ + QString getAppLocalName(QString desktopfp); - void calculateBtnSpan(int allNum, int lineMaxNum, MyPushButton*, int& row, int& colum); + /** + * @brief 重新计算界面大小及控件位置布局 + */ + void ResizeEvent(); + + /** + * @brief 当有inhibitor存在时显示提醒界面 + */ + void showInhibitWarning(); + + /** + * @brief 画出提醒界面 + */ + void drawWarningWindow(QRect &rect); + + /** + * @brief 根据inhibitor的名称获取对应desktop文件中的应用名和icon路径 + */ + QMap findNameAndIcon(QString &basename); + + /** + * @brief 根据inhibitor的名称获取对应desktop文件中的应用名和icon路径 + * @param allNum 共显示的按钮数 + * @param lineMaxNum 一行最多显示的按钮数 + * @param btn 指定按钮 + */ + void calculateBtnSpan(int allNum, int lineMaxNum, MyPushButton* btn, int& row, int& colum); + + /** + * @brief 计算键盘左右键对应的按钮 + * @param key 按键名字 + */ void calculateKeyBtn(const QString &key); + + /** + * @brief 按钮是否可用 + * @param index 按钮序号 + */ bool judgeBtnIsEnable(int index); + + /** + * @brief 打开监视器 + */ //void doSystemMonitor(); + /** + * @brief 显示常规的按钮界面 + * @param hideBtnNum 隐藏的按钮数 + */ void showNormalBtnWidget(int hideBtnNum); + + /** + * @brief 显示需要换行的按钮界面 + * @param hideBtnNum 隐藏的按钮数 + */ void showHasScrollBarBtnWidget(int hideBtnNum); Q_SIGNALS: + /** + * @brief 按钮点击后的事件信号 + */ void signalTostart(); + + /** + * @brief 点击提示界面的确认按钮信号 + */ void confirmButtonclicked(); private Q_SLOTS: + /** + * @brief 退出 + */ bool exitt(); + + /** + * @brief 按键按下事件 + * @param key 键名 + */ void onGlobalKeyPress(const QString &key); + + /** + * @brief 按键弹起事件 + * @param key 键名 + */ void onGlobalkeyRelease(const QString &key); + + /** + * @brief 屏幕变化 + */ void screenCountChanged(); + + /** + * @brief 点击按钮事件 + */ void mouseReleaseSlots(QEvent *event, QString objName); protected: @@ -148,6 +247,8 @@ private: XEventMonitor *xEventMonitor; int tableNum; bool flag = false; + + /// 各按钮是否隐藏 默认隐藏 bool isSwitchuserHide = true; bool isHibernateHide = true; bool isSuspendHide = true; @@ -162,7 +263,6 @@ private: bool inhibitSleep = false; bool inhibitShutdown = false; - QHash m_btnHideMap; QString m_btnImagesPath = "/usr/share/ukui/ukui-session-manager/images"; @@ -202,6 +302,7 @@ private: //QLabel *m_systemMonitorLabel = nullptr; //QPixmap m_systemMonitorIcon; + /// 计算各按钮的行列位置 int m_switchRow = 0, m_switchColumn = 0; int m_hibernateRow = 0, m_hibernateColumn = 0; int m_suspendRow = 0, m_suspendColumn = 0; @@ -213,8 +314,8 @@ private: QSettings *m_btnCfgSetting = nullptr; QRect m_screen; - QWidget *m_showWarningArea = nullptr; - bool m_btnWidgetNeedScrollbar = false; - bool m_showWarningMesg = false; + QWidget *m_showWarningArea = nullptr; /// 阻止列表 + bool m_btnWidgetNeedScrollbar = false; /// 是否需要滑动条显示 + bool m_showWarningMesg = false; /// 是否显示阻止列表 }; #endif // MAINWINDOW_H From 88cfb8a01510cd221079e6847c98448734a0993a Mon Sep 17 00:00:00 2001 From: tanjing Date: Tue, 15 Mar 2022 09:59:46 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8C=E5=B1=8F?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=8C=89=E9=92=AE=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=85=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/mainwindow.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/mainwindow.cpp b/tools/mainwindow.cpp index 5291062..0e20b7a 100644 --- a/tools/mainwindow.cpp +++ b/tools/mainwindow.cpp @@ -680,11 +680,12 @@ void MainWindow::mouseReleaseSlots(QEvent *event, QString objName) void MainWindow::screenCountChanged() { QDesktopWidget *desktop = QApplication::desktop(); - qDebug() << "inside screenCountChanged,screenCount = " << desktop->screenCount(); + qDebug() << "inside screenCountChanged,screenCount = " << desktop->screenCount() << QApplication::desktop()->screenGeometry(QCursor::pos()).width() << QApplication::desktop()->screenGeometry(QCursor::pos()).height(); //setGeometry(desktop->geometry()); //updateGeometry(); //move(0,0); - setFixedSize(QApplication::primaryScreen()->virtualSize()); + //setFixedSize(QApplication::primaryScreen()->virtualSize()); + setGeometry(0, 0, QApplication::primaryScreen()->virtualSize().width(), QApplication::primaryScreen()->virtualSize().height()); ResizeEvent(); update(); } @@ -712,7 +713,7 @@ void MainWindow::showNormalBtnWidget(int hideNum) int margins = 0; margins = (m_screen.width() -160 - 128 * (7 - hideNum))/(6-hideNum); - qDebug() << "margins:" << margins; + qDebug() << "showNormalBtnWidget hideNum:" << hideNum << "margins:" << margins; int btnWidgetWidth = 0; if(margins > 60) { @@ -734,7 +735,7 @@ void MainWindow::showNormalBtnWidget(int hideNum) m_scrollArea->verticalScrollBar()->setVisible(false); m_scrollArea->verticalScrollBar()->setDisabled(true); - m_buttonHLayout->setContentsMargins(0,0,0,260); + m_buttonHLayout->setContentsMargins(0,0,0,340); for (int i = 0;i < m_buttonHLayout->count(); i++) { QLayoutItem*item = m_buttonHLayout->layout()->itemAt(i); @@ -762,7 +763,7 @@ void MainWindow::showHasScrollBarBtnWidget(int hideNum) int needHeight = (m_lineNum * 171 + (m_lineNum - 1) * 32); int btnWidgetHeight = 632; - qDebug() << "lineWidth:" << lineWidth << "lineMaxBtnNum:" << lineMaxBtnNum << "needHeight:" << needHeight << "lineNum:" << m_lineNum<< allBtnNum/lineMaxBtnNum << allBtnNum%lineMaxBtnNum; + qDebug() << "showHasScrollBarBtnWidget lineWidth:" << lineWidth << "lineMaxBtnNum:" << lineMaxBtnNum << "needHeight:" << needHeight << "lineNum:" << m_lineNum<< allBtnNum/lineMaxBtnNum << allBtnNum%lineMaxBtnNum; calculateBtnSpan(allBtnNum, lineMaxBtnNum, m_switchUserBtn, m_switchRow, m_switchColumn); calculateBtnSpan(allBtnNum, lineMaxBtnNum, m_hibernateBtn, m_hibernateRow, m_hibernateColumn); @@ -793,11 +794,11 @@ void MainWindow::showHasScrollBarBtnWidget(int hideNum) qDebug() << "set bar pos..."; //m_scrollArea->verticalScrollBar()->setGeometry(QRect(lineWidth + 20, 0, 6, 100)); m_scrollArea->setContentsMargins(0,0,0,0); - m_scrollArea->setGeometry(QRect(0,0,128 * lineMaxBtnNum + 60 * (lineMaxBtnNum-1) +6,btnWidgetHeight)); + m_scrollArea->setGeometry(QRect(0,0,128 * lineMaxBtnNum + 60 * (lineMaxBtnNum-1) + 6, btnWidgetHeight * m_screen.height()/1080)); m_buttonHLayout->setContentsMargins(0,0,0,0);// (needHeight > 632 ? 0 : (632 - needHeight)) * m_screen.height()/1080); - m_btnWidget->setGeometry(QRect(0,0,128 * lineMaxBtnNum + 60 * (lineMaxBtnNum-1),needHeight)); + m_btnWidget->setGeometry(QRect(0,0,128 * lineMaxBtnNum + 60 * (lineMaxBtnNum-1), needHeight)); m_btnWidget->setContentsMargins(6,0,12,0); qDebug() << "m_btnWidget FixedHeight:" << needHeight << btnWidgetHeight << m_btnWidget->width() << m_scrollArea->width(); qDebug() << "isSwitchuserHide:" << isSwitchuserHide << "isHibernateHide:" << isHibernateHide << "isSuspendHide:" << isSuspendHide; @@ -867,6 +868,11 @@ void MainWindow::ResizeEvent() m_scrollArea->setWidget(m_btnWidget); m_scrollArea->setStyleSheet("QScrollArea#scrollArea{background-color: transparent;}"); m_scrollArea->setAlignment(Qt::AlignHCenter); + qDebug() << "m_scrollArea geometry:" << m_scrollArea->geometry(); + qDebug() << "m_btnWidget geometry:" << m_btnWidget->geometry(); + + m_vBoxLayout->setContentsMargins((m_screen.width() - m_scrollArea->width() - 20)/2,0,(m_screen.width() - m_scrollArea->width() - 20)/2,0); + //m_scrollArea->adjustSize(); //m_scrollArea->setWidgetResizable(true); m_toolWidget->setGeometry(m_screen); From 090499a1e166e45d2f39c314273c5dd5d6fd7609 Mon Sep 17 00:00:00 2001 From: tanjing Date: Tue, 15 Mar 2022 17:09:47 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/images/hibernate.png | Bin 902 -> 0 bytes data/images/hibernate.svg | 2 +- data/images/lockscreen.png | Bin 502 -> 0 bytes data/images/lockscreen.svg | 2 +- data/images/logout.png | Bin 562 -> 0 bytes data/images/logout.svg | 2 +- data/images/reboot.png | Bin 639 -> 0 bytes data/images/reboot.svg | 2 +- data/images/shutdown.png | Bin 684 -> 0 bytes data/images/shutdown.svg | 2 +- data/images/suspend.png | Bin 817 -> 0 bytes data/images/suspend.svg | 11 +---------- data/images/switchuser.png | Bin 630 -> 0 bytes data/images/switchuser.svg | 2 +- 14 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 data/images/hibernate.png delete mode 100644 data/images/lockscreen.png delete mode 100644 data/images/logout.png delete mode 100644 data/images/reboot.png delete mode 100644 data/images/shutdown.png delete mode 100644 data/images/suspend.png delete mode 100644 data/images/switchuser.png diff --git a/data/images/hibernate.png b/data/images/hibernate.png deleted file mode 100644 index a6338b182d17cbe633cdafa67297d95851d29f23..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 902 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_ovePZ!6KjK;H(-G#Recvy>N4=86eS2XXEULkztuESh~cPx^QHxJx%c*jzvw!wUY zxkI03#X&~_R~Bl10$GV~6t*HbMOxQ~&C)YktaoGhQk>B5`J7DxPC6!G7sD~++{X{;k-tYT7QNA$;>>5OmwH+85gZDaZ|&Gz|& zzq`IRE7o%=?c*w#S`o)JU9zkFDT`n><2r!{+-1hO=N@G9%5Xnhb9dRh$isj4UAkuD z(&GQUG2ZZcW)ai*+Fj-ftzS16&7JT(T5>~DtVTrnVvdteqGcDB?>%~RmytTFliN<7 zHMd)%qxkMNaJUOjVBR)f7u#JT>c`633IyH;#CBYgJx6uah>!$v!Qe@T{-? zN6*vJmeFCulbe>){U0ZatUpj5Rdr5qLGil>9t;oI8ScEe`15oA>i>tEV>;%ZUHxC& z+k?|fP`^7copIkZ{>ht8U5fO`4Bc77RyZO0Pw3oI?}(ksVX8%i~)h|o-+@HUOtKo%w(#8o=N3IyO_N|vKc`ITh ze)GFkJ5v%(A&-6GiKGd>PS9S|vSyp^(wCl7ntOKlr|#Zx z!6eE=CZh9phGxLokB$*q6IHA>Yb?+C($2E%=d(G#ZG$?SRFW`Rd#Nt6CVi3V zEcObnqJV$*Eo%z)%v;2JGHKIc58zHE1S;*_&H?)yt8YRUh6_wDDDm|pgJo7XCPEPl-_ZTp_@+M^O) za$3>#eEYk*CuUs~zvIce!MsD6JzvAtYhK;bFF)jFep;*9VD2^ROZ9)N=Y1<@xN(La zuWESD@2OF+INj%@`2tSH5B7EEUg_R`&a^P&r&8IRoLq(<3}@$rcL(0{1!XJ-Pgg&e IbxsLQ09QPl%K!iX diff --git a/data/images/hibernate.svg b/data/images/hibernate.svg index 1693a24..6cfad35 100644 --- a/data/images/hibernate.svg +++ b/data/images/hibernate.svg @@ -1 +1 @@ -画板 6 \ No newline at end of file + \ No newline at end of file diff --git a/data/images/lockscreen.png b/data/images/lockscreen.png deleted file mode 100644 index 7985bba3cdae1deef8614f156d02743caa23f93c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 502 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_s6zo-U3d8I5meKAhNOAkaE_^#LJ`#-KM3bXr$82@}}YSgS!QrcUCsD zaH#27{QPI3eDYm&n((BIB&G!{0n8a6Je1F$TH%?@@PK21tl-b?>!wG}yGoy#q99tnjn zwSPIW?f*+rS09T@{y9;(t2zwt&dEqV`bAZ1WyzweYtF39JG-Ke<=L+(=T~q2roLgl zcxS2XlL(g;jNf0^92fH6G2`XED<(I)SkF2qi|bXqxiLp2v&ri857UKBbIca~ zm6z(QS~YR@hF{0`GH&7imjC09gl6WPRG;{|iJ6mmGbSH7@Zi=F!M7ZzZa6;LFPXP? zYq9L|4{K94J}R0M<8&*98H$z|ec1Y8_l_r@8<=i3nB}KG$a})(;NB;Hsbqdu$os!> z8TZYL)83aazEZe<`{k5J5C1c={<^cb?c*lHV}F?Xd5=B{*SA{Az`(%Z>FVdQ&MBb@ E0L@tJf&c&j diff --git a/data/images/lockscreen.svg b/data/images/lockscreen.svg index 7c0ab9a..1f910ee 100644 --- a/data/images/lockscreen.svg +++ b/data/images/lockscreen.svg @@ -1 +1 @@ -画板 5 \ No newline at end of file + \ No newline at end of file diff --git a/data/images/logout.png b/data/images/logout.png deleted file mode 100644 index cec5de0a1a3764dd6bfba15b1c42f40df9df2ccb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 562 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_s6_o-U3d8I5xaO#G;gjdW2gDm{IUZ&l+|Lo1p>#_i z(EsU+nQdWZB?q@lPP7(Vrnt!JbL`n<>3{2wm4&!=WE?%S^+K+U_LA#qQ*KVVu>1I$ zuysN+&Dy?5FZGx|`)JUkwF)&#i^7EuRmSxig;-BnP%?Aw&nwR=*Ubobnt5=_hv;I@ z_n+(apRK)n@tB{qW=M_x`~;5y2n$taF~)M>I~6D=`*$ zULSDH{C1*x^M~5{YsdSUG(XwsJbQk?`qRTShroBnt4}ENRPUN~r!%&^?A_sGws(RS zF?~3)-+r0+N3$JIY91PyRJnh5=bYGn-t1RFn?m}ciOna^=WumQTrgz^%bYJ}=?_&y zZ11(H)NmYJa&(fwTGoU&k+$K=#uD=PVlxE0ZlQ0_O^oxfS0m zEn64N`TwNMp5>P#JRBeIUefY?k(_tN>I2ou+};_whpLOs50+NP*1Y-N;4JX5`iKh0 zFWV==Eq~=UbE(zw?-EU(AI`f@BdPG_bP0l+XkK*qi;I diff --git a/data/images/logout.svg b/data/images/logout.svg index 156f396..9659657 100644 --- a/data/images/logout.svg +++ b/data/images/logout.svg @@ -1 +1 @@ -画板 1 \ No newline at end of file + \ No newline at end of file diff --git a/data/images/reboot.png b/data/images/reboot.png deleted file mode 100644 index a78262e2deaec2880dd14a4a11fbf401b69db01c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 639 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_mZWPZ!6KjK-@`-Gzq?c%~N1E>KQs-oz-`$U95W%E{~nhm5cRQwdW-(+0-74z|Ia zTvydP3m^Ts`}9GF?tb+r^K+O58#+`OLKrr%Gz8fQrC0Sa6fiaHHGC$s_^(35rH&g4 zN!<@KPPU1?W>J!RBi#JsmSd%Rik3@^#Vg$xb9FbDUWqT~eAu+`Nc_q|-(B0@Grhf< z;=JhNO>QxVd)cBNvoY5V_C0pkucQ%22rEi69Oc; zxO8v2&r)FQ`cswjsPCKo){c8jAvdnf6?JQRcF~)m^hV0O@(&aLA4z5uslU^?ZL(1< zgKd6=ch`>nJ{J>1Z?nJ6l&@j)3as0*u*ipTkIfBV-+!4J@7-r7E*H6w^1Aki=mBN_ zO@{UoS~Y62l}QU0%oVx7_tM&(G5^b7ZNupb5sZ7@-Ah0Aw~OhY+5MZX=SAnf?wxdv})lYOShTntIL=jyj4RzoA2ZJo}67{wj)@|hSEmPgLmd5`l%rs%1d{?-|d z(>XbLS&MB`x6fEyYrXi1{N_l%?k`^4NfLK2Jg>IO+IvvOd^^|998JygDtWs{Pv4k- zRciig|8Sbs+DojbPrj~oJ9Xrm@`V${ig~@;GuT!h-FA7SvCq3xpLf)~-nw(y_4Y8o z+5?KV@B4rADQ~t);xe^(s(9b4$L!;wa=qhg&YMm8v%s25Dc1DDl8xs>n+;oz?0EC> uBhSYh*K>2`U9FnG{*K3y{dvp`_7-MtNvqdRT*tt`z~JfX=d#Wzp$Pyp=Nwr8 diff --git a/data/images/reboot.svg b/data/images/reboot.svg index d5dcb5d..4f55d46 100644 --- a/data/images/reboot.svg +++ b/data/images/reboot.svg @@ -1 +1 @@ -画板 3 \ No newline at end of file + \ No newline at end of file diff --git a/data/images/shutdown.png b/data/images/shutdown.png deleted file mode 100644 index 4b07a8b452ac3bd464633cb27be89dfbcf9ccd5e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 684 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_q`$PZ!6KjK;T--G$8tJfbrdlvA2hnvI;yHIz$O%uaB`sGZ!b3=Vn-~yDVTReyp!CcQH%A?Zp}M+P9@EPx@oGsCElO*8YC6 zhpoO>4EjU`&K~YQ_+XxRnHzV*H;*sp9bICSlSG9-%Wex{Iq-K*!JTWh`p=r!y(8$nUM%zKZEYnx`7~|HiEM&2t;x1qy6jf9ZFE z3d1{h#p&jiO)K7(uX)9|(JZ9Kx$XRlGsdhM%BG1=$`;FfUasP~Z<=0%#k?0rrA*sO zJ{l^o4=}jCR`|f_&z{G>sU)nkR&Tg`@zG)ThMjpre#O&Tx3kXpULR<0Uf0^79iV7z zKQ~bzW_>RML&P5~odYrNSysGpQfDgOyXMHMZ=YP4X1soWIse&@WxvX9as4Zsb@@f( zzx&hl913hq%5}WFxW9;fyXCrfV#B*da<>+Lu;M-}XW_?RJzufwca^7Pr;-0%t!MIk zRupYn(Rt9l`-0t_+~c>tJmEf=exuI!aYZci;))7+3pIJp_0L21U6NTo画板 2 \ No newline at end of file + \ No newline at end of file diff --git a/data/images/suspend.png b/data/images/suspend.png deleted file mode 100644 index 63f2a32b7da50b62050547fa0f9045c9da874e85..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 817 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_q|bo-U3d8I5NndkbF~@Jy?gRZ!l*m=oaUp{|kNT+(!W_JZr2mv~>WeNfYw%V6eV ze!+Ts(R?kD|1B!t%8wsZ6`GdvH?qyJu_N2%j?yDJLH~-*yDPYv4!qr3pU}$Iz|OFO zaRJwa`RilzO(typ-Zj;~>+5}wi%Kl(*Jx`vnRo1PIMQ3OUDx4_zCu!O$6SG$!}p3G z>fY7beBys&hriPfw>|4yPq#cuv{OjZZi(*r&b`ez_T-`MvkG)(beGNE*53BJcJalO z#t$#;9%?_c`aP-Tx!qmq35R~U?(94Lc`i?c<8!WSFLVzj1hn%0+OpMR@oMj&1F2Jj z8}eS4W!k-D61aB%$BLPYvKrDEPydX2J((%6>m1j#$~`~lTw3mI7^_x3|K1tp%;%E> zj`LQ((y25#Hl_FjM}u~O`~BmOmV9Z@exUWTI#7u1fM~&6r%QZK^5*6%W#}dJSZ+v< ztX|;H+9GPNR4E%<$EtKpQRRZuNvd)33d5`8XkfMf`z?-?tnC>$^cRSs(b>7SBiF;Qj|NR@SbpQKL#cW@X%x5+={+GQZ#ne{K4g2xq zhw6Oor7{^T@vfJ-+ii~OKJ{4n;nc^Zc~_*WSG<21+xhbApUJy!Z0u@}*V^dq$+cLa zY{S#QMMB%nWtYBOeMv{MT>MPg#>GcFSfw{g%c^$0_@NLfHBn_>df>6c8RCV?hsBf6 ztZ($XA^V4yAu7mX!?F)P^5tgnL95qQ9@uO6EVQz2V@1K9d5bu9PAvO7t4aRd<=xCV z52r=GXJwG>%?O!eM( za-ILls}&#mFDJLIi**0-zqe!JM{O(C#bp=w%0?LfYO-F%z}9?Y^M_fN7R$Vwr)j&d zI?YF$>%rDZYP#>`4R_7t3z3a}7`3v1Rj=}rZ3Vl@1cqo7e()Mw aL%mVH#<%?RT7L!x1_n=8KbLh*2~7Z*ntY=G diff --git a/data/images/suspend.svg b/data/images/suspend.svg index 0f2bbac..a83bdfa 100644 --- a/data/images/suspend.svg +++ b/data/images/suspend.svg @@ -1,10 +1 @@ - - - - - + \ No newline at end of file diff --git a/data/images/switchuser.png b/data/images/switchuser.png deleted file mode 100644 index 7c402569892d20d0a2975472e7ee638071b96d74..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4mJh`hH$2z?F2BR0 z1_mY#PZ!6KjK;SS7Yh#=@NAu_plslDLqYn2phTnKjfU4OCCxnnW(%ZScn`6?YV}%R z<)=HN>s|Mw!vh=QA8&u8Id6fX-l3xh zALcXHyz@E#^Ts3oGYQR)yuQ`0d@}vVy2L%r+2*Z3=1!82i7Zj+6_zk-=?(IkV4tAw zXOYMh#N!<{@AFlq8J}~f97$V!X~_fr8#zn<-*Ym!FExL@)9m*CtpL92A|{)-vrrvvf6Qp(>xu$4Jh%*+1fXcW z#S0P_afy6;D>&)<#G+$8;+Kiog96Z3QXvnBO@ z{_Hs!FIZcfR@7eolzcezx;b|pZ_-*`xrcHO+*xn!iQm1UpyJlnlOY@Cq&`v6dSRQb zskg4MX_e}Vr|x3$h9BRqtvqr_;MLPgY2Am*UA$Yr%sO)ImVEM=QxczD4ei+4|DP#) m)MOUEBJo&{r@^s5Oocz{jC=F4cQG(9FnGH9xvX画板 4 \ No newline at end of file + \ No newline at end of file From 4b21e8ce9f025ac4d0603f372f70c9a569deef53 Mon Sep 17 00:00:00 2001 From: tanjing Date: Fri, 18 Mar 2022 13:45:38 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=9C=A8=E4=B8=8D=E5=90=8C=E5=88=86=E8=BE=A8=E7=8E=87=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BD=8D=E7=BD=AE=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/mainwindow.cpp | 70 +++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/tools/mainwindow.cpp b/tools/mainwindow.cpp index 0e20b7a..9b6f5d2 100644 --- a/tools/mainwindow.cpp +++ b/tools/mainwindow.cpp @@ -241,16 +241,33 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent) ResizeEvent(); + //使按钮控件上下比例均衡 + QVBoxLayout *spaceLayout = new QVBoxLayout(); + QLabel spaceLabel1; + QLabel spaceLabel2; + spaceLabel1.setFont(QFont("Noto Sans CJK SC", 28, 50)); + spaceLabel2.setFont(QFont("Noto Sans CJK SC", 12, 50)); + spaceLabel1.setStyleSheet("color: white; font: 28pt"); + spaceLabel2.setStyleSheet("color: white; font: 12pt"); + spaceLabel1.setAlignment(Qt::AlignHCenter | Qt::AlignTop); + spaceLabel2.setAlignment(Qt::AlignHCenter | Qt::AlignBottom); + spaceLabel1.setObjectName("date_label"); + spaceLabel2.setObjectName("time_lable"); + spaceLayout->addStretch(); + spaceLayout->addWidget(&spaceLabel1); + spaceLayout->addSpacing(10); + spaceLayout->addWidget(&spaceLabel2); + setLayoutWidgetVisible(spaceLayout, false); + m_vBoxLayout->addStretch(20); - m_vBoxLayout->addLayout(m_dateTimeLayout, 60); - m_vBoxLayout->addStretch(); - m_vBoxLayout->addLayout(m_judgeWidgetVLayout, 140); - m_vBoxLayout->addWidget(m_scrollArea, 632); - m_vBoxLayout->addStretch(174); - m_vBoxLayout->addLayout(m_messageVLayout, 80); - //m_vBoxLayout->addWidget(m_systemMonitorBtn,48,Qt::AlignHCenter); - m_vBoxLayout->addStretch(58); - //m_vBoxLayout->setContentsMargins(0,0,0,0); + m_vBoxLayout->addLayout(m_dateTimeLayout, 80); + m_vBoxLayout->addLayout(m_judgeWidgetVLayout, 120); + m_vBoxLayout->addWidget(m_scrollArea, 640); + m_vBoxLayout->addLayout(m_messageVLayout, 120); + m_vBoxLayout->addLayout(spaceLayout, 80); + m_vBoxLayout->addStretch(20); + m_vBoxLayout->setSpacing(0); + m_vBoxLayout->setContentsMargins((m_screen.width() - m_scrollArea->width() - 20)/2,0,(m_screen.width() - m_scrollArea->width() - 20)/2,0); qDebug() << "width..........." << m_judgeLabel->width() << m_scrollArea->width() << m_messageLabel1->width() << m_messageLabel2->width(); @@ -424,11 +441,11 @@ void MainWindow::initialJudgeWidget() m_judgeLabel->setText(tips); m_judgeLabel->setStyleSheet("color:white;font:12pt;"); m_judgeLabel->setObjectName("label"); - m_judgeLabel->setGeometry(0,0,m_screen.width() - 160,50); + //m_judgeLabel->setGeometry(0,0,m_screen.width(),50); //m_judgeLabel->setFixedHeight(60); qDebug() << "m_judgeLabel width:" << m_judgeLabel->width() << m_judgeLabel->height(); - m_judgeLabel->setAlignment(Qt::AlignHCenter| Qt::AlignBottom); + m_judgeLabel->setAlignment(Qt::AlignCenter); m_judgeLabel->setWordWrap(true); m_cancelBtn = new QPushButton(QApplication::tr("cancel")); @@ -446,7 +463,7 @@ void MainWindow::initialJudgeWidget() m_judgeWidgetVLayout->addStretch(); m_judgeWidgetVLayout->addWidget(m_judgeLabel); - m_judgeWidgetVLayout->addSpacing(0); + m_judgeWidgetVLayout->addSpacing(10); m_judgeWidgetVLayout->addLayout(m_judgeBtnHLayout); m_judgeWidgetVLayout->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); @@ -466,8 +483,8 @@ void MainWindow::initialMessageWidget() margins = (m_screen.width() - 60 * 2 - 140 * 3) / 2; } - m_messageLabel1->setGeometry(QRect(0, 0, 700, 40)); - m_messageLabel2->setGeometry(QRect(0, 0, 700, 40)); + m_messageLabel1->setGeometry(0, 0, m_screen.width() - 160, 40); + m_messageLabel2->setGeometry(0, 0, m_screen.width() - 160, 40); m_messageLabel1->setStyleSheet("color:white;font:12pt;"); m_messageLabel2->setStyleSheet("color:white;font:12pt;"); m_messageLabel1->setObjectName("messagelabel1"); @@ -476,16 +493,19 @@ void MainWindow::initialMessageWidget() // m_messageLabel2->setFixedWidth(m_screen.width() - 20); m_messageLabel1->setWordWrap(true); m_messageLabel2->setWordWrap(true); - m_messageLabel2->setAlignment(Qt::AlignCenter); - m_messageLabel1->setAlignment(Qt::AlignCenter); + m_messageLabel2->setAlignment(Qt::AlignHCenter); + m_messageLabel1->setAlignment(Qt::AlignHCenter); m_messageLabel1->setMargin(0); m_messageLabel2->setMargin(0); + m_messageLabel1->setWordWrap(true); + m_messageLabel2->setWordWrap(true); + m_messageVLayout->addStretch(); m_messageVLayout->addWidget(m_messageLabel1); m_messageVLayout->addSpacing(10); m_messageVLayout->addWidget(m_messageLabel2); //m_messageVLayout->setAlignment(Qt::AlignHCenter); - m_messageVLayout->setContentsMargins(0,0,0,0); + //m_messageVLayout->setContentsMargins(0,0,0,0); if (lockfile) { QFile file_update("/tmp/lock/kylin-update.lock"); @@ -572,10 +592,12 @@ void MainWindow::initialDateTimeWidget() m_dateLabel->setObjectName("date_label"); m_timeLabel->setObjectName("time_lable"); + m_dateTimeLayout->addStretch(); m_dateTimeLayout->addWidget(m_timeLabel); - m_dateTimeLayout->setStretch(0,1); + m_messageVLayout->addSpacing(10); + //m_dateTimeLayout->setStretch(0,1); m_dateTimeLayout->addWidget(m_dateLabel); - m_dateTimeLayout->setStretch(1,2); + //m_dateTimeLayout->setStretch(1,2); } void MainWindow::initialBtnCfg() @@ -726,16 +748,16 @@ void MainWindow::showNormalBtnWidget(int hideNum) btnWidgetWidth = 128 * (7 - hideNum) + margins * (6 - hideNum); m_buttonHLayout->setHorizontalSpacing(margins); } - m_btnWidget->setGeometry(QRect(0,0,btnWidgetWidth+ 24, 632)); - m_btnWidget->setContentsMargins(0,0,0,0); + m_btnWidget->setGeometry(QRect(0,0,btnWidgetWidth+ 24, 632 * m_screen.height()/1080)); + m_btnWidget->setContentsMargins(0,0,0,100); - m_scrollArea->setGeometry(QRect(0,0,btnWidgetWidth + 24, 632)); + m_scrollArea->setGeometry(QRect(0,0,btnWidgetWidth + 24, 632 * m_screen.height()/1080)); m_scrollArea->setContentsMargins(0,0,0,0); m_scrollArea->verticalScrollBar()->setVisible(false); m_scrollArea->verticalScrollBar()->setDisabled(true); - m_buttonHLayout->setContentsMargins(0,0,0,340); + //m_buttonHLayout->setContentsMargins(0,0,0,(m_scrollArea->height() - m_switchUserBtn->height()) * 3/5); for (int i = 0;i < m_buttonHLayout->count(); i++) { QLayoutItem*item = m_buttonHLayout->layout()->itemAt(i); @@ -863,6 +885,7 @@ void MainWindow::ResizeEvent() } m_btnWidget->setStyleSheet("QWidget#btnWidget{background-color: transparent;}"); m_btnWidget->setLayout(m_buttonHLayout); + m_scrollArea->horizontalScrollBar()->setVisible(false); m_scrollArea->horizontalScrollBar()->setDisabled(true); m_scrollArea->setWidget(m_btnWidget); @@ -870,6 +893,7 @@ void MainWindow::ResizeEvent() m_scrollArea->setAlignment(Qt::AlignHCenter); qDebug() << "m_scrollArea geometry:" << m_scrollArea->geometry(); qDebug() << "m_btnWidget geometry:" << m_btnWidget->geometry(); + qDebug() << "m_buttonHLayout geometry:" << m_buttonHLayout->geometry(); m_vBoxLayout->setContentsMargins((m_screen.width() - m_scrollArea->width() - 20)/2,0,(m_screen.width() - m_scrollArea->width() - 20)/2,0); From 59cf2246dfc49dfda3992686ffeda8cb5468feac Mon Sep 17 00:00:00 2001 From: tanjing Date: Mon, 21 Mar 2022 10:25:06 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=97=B4=E8=B7=9D?= =?UTF-8?q?=E4=B9=98=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mainwindow.cpp b/tools/mainwindow.cpp index 9b6f5d2..9bdf665 100644 --- a/tools/mainwindow.cpp +++ b/tools/mainwindow.cpp @@ -749,7 +749,7 @@ void MainWindow::showNormalBtnWidget(int hideNum) m_buttonHLayout->setHorizontalSpacing(margins); } m_btnWidget->setGeometry(QRect(0,0,btnWidgetWidth+ 24, 632 * m_screen.height()/1080)); - m_btnWidget->setContentsMargins(0,0,0,100); + m_btnWidget->setContentsMargins(0,0,0,100 * m_screen.height()/1080); m_scrollArea->setGeometry(QRect(0,0,btnWidgetWidth + 24, 632 * m_screen.height()/1080));