Merge branch 'tanjing_develop_new' into 'Develop'
根据systemd判断睡眠、休眠、注销、关机、重启功能是否可用来决定是否需要隐藏相关按钮 See merge request kylin-desktop/ukui-session-manager!84
@@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 902 B |
@@ -1 +1 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><defs><style>.cls-1{fill:#fff;}.cls-2{fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}</style></defs><title>画板 6</title><path class="cls-1" d="M25.73,5.22a22.84,22.84,0,0,0-9.68,20.25A23.08,23.08,0,0,0,37,46.92c.65,0,1.32.08,2,.08a23,23,0,0,0,7-1.11A24,24,0,1,1,25.73,5.22M29,3a25.62,25.62,0,0,0-2.61.13A26,26,0,1,0,50.3,43.91,1,1,0,0,0,49,42.47,20.89,20.89,0,0,1,39,45c-.6,0-1.2,0-1.81-.08a21,21,0,0,1-6.95-40A1,1,0,0,0,29.87,3Z"/><polyline class="cls-2" points="39 32 48 32 39 40 48 40"/><polyline class="cls-2" points="48 24 54 24 48 29 54 29"/><polyline class="cls-2" points="30 30 36 30 30 35 36 35"/></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M41.06,31.53A18.5,18.5,0,0,1,16,6.44a1.51,1.51,0,0,0-2-2A21.5,21.5,0,1,0,43.1,33.57a1.51,1.51,0,0,0-2-2ZM24.22,41.78A18.5,18.5,0,0,1,11.39,10a21.27,21.27,0,0,0-.67,5.33,21.52,21.52,0,0,0,21.5,21.5,21.27,21.27,0,0,0,5.33-.67A18.49,18.49,0,0,1,24.22,41.78Z" fill="#fff"/><path d="M26,31h6.8a1,1,0,0,0,0-2H28.41l4.3-4.29a1,1,0,0,0,.21-1.09A1,1,0,0,0,32,23H26.4a1,1,0,0,0,0,2h3.19l-4.3,4.29a1,1,0,0,0-.21,1.09A1,1,0,0,0,26,31Z" fill="#fff"/><path d="M29,20h6.8a1,1,0,0,0,0-2H31.41l4.3-4.29a1,1,0,0,0,.21-1.09A1,1,0,0,0,35,12H29.4a1,1,0,0,0,0,2h3.19l-4.3,4.29a1,1,0,0,0-.21,1.09A1,1,0,0,0,29,20Z" fill="#fff"/><path d="M43.8,27H39.41l4.3-4.29a1,1,0,0,0,.21-1.09A1,1,0,0,0,43,21H37.4a1,1,0,0,0,0,2h3.19l-4.3,4.29a1,1,0,0,0-.21,1.09A1,1,0,0,0,37,29h6.8a1,1,0,0,0,0-2Z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 746 B After Width: | Height: | Size: 885 B |
|
Before Width: | Height: | Size: 502 B |
@@ -1 +1 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><defs><style>.cls-1{fill:none;stroke:#fff;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;}.cls-2{fill:#fff;}</style></defs><title>画板 5</title><g id="锁定"><rect class="cls-1" x="7" y="20" width="44" height="34" rx="6"/><path class="cls-1" d="M16,20V17A13,13,0,0,1,29,4h0A13,13,0,0,1,42,17v3"/><rect class="cls-2" x="26" y="31" width="6" height="12" rx="2"/></g></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M36.34,16H34V10.9C34,6,29.51,2,24,2S14,6,14,10.9V16H11.66A6.67,6.67,0,0,0,5,22.66V39.34A6.67,6.67,0,0,0,11.66,46H36.34A6.67,6.67,0,0,0,43,39.34V22.66A6.67,6.67,0,0,0,36.34,16ZM17,10.9C17,7.65,20.14,5,24,5s7,2.65,7,5.9V16H17ZM40,39.34A3.66,3.66,0,0,1,36.34,43H11.66A3.66,3.66,0,0,1,8,39.34V22.66A3.66,3.66,0,0,1,11.66,19H36.34A3.66,3.66,0,0,1,40,22.66Z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 476 B |
|
Before Width: | Height: | Size: 562 B |
@@ -1 +1 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><defs><style>.cls-1{fill:none;stroke:#fff;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;}</style></defs><title>画板 1</title><g id="注销"><path class="cls-1" d="M46,47.33a25,25,0,1,1,0-36.66"/><line class="cls-1" x1="53.68" y1="29" x2="28.68" y2="29"/><path class="cls-1" d="M46.46,21.5l7.22,6.77a1,1,0,0,1,0,1.46L46.46,36.5"/></g></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M34.34,35.14A16.58,16.58,0,0,1,21.71,41a17,17,0,0,1,0-34,16.59,16.59,0,0,1,12.65,5.88,1.5,1.5,0,1,0,2.28-2A19.61,19.61,0,0,0,21.71,4,19.88,19.88,0,0,0,2,24,19.88,19.88,0,0,0,21.71,44a19.6,19.6,0,0,0,14.91-6.91,1.5,1.5,0,0,0-2.28-2Z" fill="#fff"/><path d="M40.14,22H21.5a1.5,1.5,0,0,0,0,3H40.14v4.36L46,23.5l-5.86-5.86Z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 443 B |
|
Before Width: | Height: | Size: 639 B |
@@ -1 +1 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><defs><style>.cls-1{fill:none;stroke:#fff;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;}</style></defs><title>画板 3</title><g id="重启"><path class="cls-1" d="M54,29a25,25,0,1,1-4-13.53"/><polyline class="cls-1" points="50 5 50 16 40 16"/></g></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M42.44,21.88A1.5,1.5,0,0,0,41,23.43,17,17,0,0,1,12,36,17,17,0,0,1,34.91,11L32,13.91h8.29V5.62L37,8.84a20,20,0,1,0,7,14.49A1.46,1.46,0,0,0,42.44,21.88Z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 363 B After Width: | Height: | Size: 275 B |
|
Before Width: | Height: | Size: 684 B |
@@ -1 +1 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><defs><style>.cls-1{fill:none;stroke:#fff;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;}.cls-2{fill:#fff;}</style></defs><title>画板 2</title><g id="关机"><path class="cls-1" d="M44,9A25,25,0,1,1,14,9"/><rect class="cls-2" x="27" y="3" width="4" height="22" rx="2"/></g></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M37.09,11.38a1.5,1.5,0,0,0-2,2.28A16.58,16.58,0,0,1,41,26.29a17,17,0,0,1-34,0,16.59,16.59,0,0,1,5.88-12.65,1.5,1.5,0,1,0-2-2.28A19.61,19.61,0,0,0,4,26.29,19.88,19.88,0,0,0,24,46,19.88,19.88,0,0,0,44,26.29,19.6,19.6,0,0,0,37.09,11.38Z" fill="#fff"/><rect x="22" y="2" width="4" height="24" rx="1.92" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 817 B |
@@ -1,10 +1 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 58 58" enable-background="new 0 0 58 58" xml:space="preserve">
|
||||
<path fill="#FFFFFF" d="M25.7,5.2C19.2,9.8,15.5,17.5,16,25.5c0.8,11.3,9.6,20.4,21,21.4c0.7,0,1.3,0.1,2,0.1c2.4,0,4.7-0.4,7-1.1
|
||||
c-9.3,9.4-24.5,9.5-33.9,0.2s-9.5-24.5-0.2-33.9C15.6,8.4,20.5,5.9,25.7,5.2 M29,3c-0.9,0-1.7,0-2.6,0.1C12.1,4.6,1.7,17.3,3.1,31.6
|
||||
s14.2,24.7,28.5,23.3c7.5-0.8,14.3-4.8,18.7-11c0.3-0.5,0.2-1.1-0.3-1.4c-0.3-0.2-0.7-0.2-1-0.1c-3.1,1.7-6.5,2.5-10,2.5
|
||||
c-0.6,0-1.2,0-1.8-0.1c-11.6-1-20.1-11.2-19.1-22.7c0.7-7.5,5.3-14.1,12.1-17.3c0.5-0.2,0.7-0.8,0.5-1.3C30.6,3.2,30.3,3,29.9,3H29z
|
||||
"/>
|
||||
</svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M42.06,30.53A18.5,18.5,0,0,1,17,5.44a1.51,1.51,0,0,0-2-2A21.5,21.5,0,1,0,44.1,32.57a1.51,1.51,0,0,0-2-2ZM25.22,40.78A18.5,18.5,0,0,1,12.39,9a21.27,21.27,0,0,0-.67,5.33,21.52,21.52,0,0,0,21.5,21.5,21.27,21.27,0,0,0,5.33-.67A18.49,18.49,0,0,1,25.22,40.78Z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 864 B After Width: | Height: | Size: 378 B |
|
Before Width: | Height: | Size: 630 B |
@@ -1 +1 @@
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><defs><style>.cls-1,.cls-2{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:2px;}.cls-1{stroke-linecap:round;}</style></defs><title>画板 4</title><g id="用户切换"><path class="cls-1" d="M14.09,34H10.55A9.56,9.56,0,0,0,1,43.55v3.81A5.66,5.66,0,0,0,6.73,53H12"/><path class="cls-1" d="M24,5.19A10.33,10.33,0,0,0,22,5a11,11,0,1,0,2,21.82"/><path class="cls-2" d="M47.45,34H24.55A9.53,9.53,0,0,0,15,43.5v3.8A5.72,5.72,0,0,0,20.73,53H51.27A5.72,5.72,0,0,0,57,47.3V43.5A9.53,9.53,0,0,0,47.45,34Z"/><circle class="cls-2" cx="36" cy="16" r="11"/></g></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M27.73,8h.19A6.25,6.25,0,0,1,29.2,20.37a9.44,9.44,0,0,1-1.38,2,8.61,8.61,0,0,1-1.08,1A9.24,9.24,0,1,0,27.92,5a9.08,9.08,0,0,0-3.5.71c.17.07.34.13.5.21A9.21,9.21,0,0,1,27.73,8Z" fill="#fff"/><path d="M18.92,24.5a9.25,9.25,0,1,0-9.25-9.25A9.22,9.22,0,0,0,18.92,24.5Zm0-15.5a6.62,6.62,0,0,1,1.1.1,6.25,6.25,0,0,1,0,12.3,6.52,6.52,0,0,1-1.1.1,6.25,6.25,0,0,1,0-12.5Z" fill="#fff"/><path d="M37.75,25.81H33.08A8.28,8.28,0,0,1,36,28.34c.12.15.22.31.33.47h1.4A5.08,5.08,0,0,1,38.24,39,8,8,0,0,1,37,41a8.41,8.41,0,0,1-1,1h1.71a8.1,8.1,0,0,0,0-16.19Z" fill="#fff"/><path d="M35,29.81a8.09,8.09,0,0,0-6.27-3H9.09A8.1,8.1,0,0,0,9.09,43H28.75A8.08,8.08,0,0,0,35,29.81ZM28.75,40H9.09a5.1,5.1,0,0,1,0-10.19H28.75a5.1,5.1,0,0,1,0,10.19Z" fill="#fff"/></svg>
|
||||
|
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 846 B |
@@ -185,16 +185,15 @@ MainWindow::MainWindow(bool a, bool b, QWidget *parent) : QMainWindow(parent)
|
||||
inhibitShutdown = true;
|
||||
}
|
||||
|
||||
|
||||
user = getenv("USER");
|
||||
lockfile = a;
|
||||
lockuser = b;
|
||||
|
||||
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 +203,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--;
|
||||
}
|
||||
@@ -227,23 +241,40 @@ 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();
|
||||
//根据屏幕分辨率与鼠标位置重设界面
|
||||
//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);//设置初始位置的值
|
||||
|
||||
//设置窗体无边框,不可拖动拖拽拉伸;为顶层窗口,无法被切屏;不使用窗口管理器
|
||||
@@ -373,13 +404,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 +431,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,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() - 2 * margins,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"));
|
||||
@@ -438,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);
|
||||
|
||||
@@ -458,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");
|
||||
@@ -468,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");
|
||||
@@ -564,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()
|
||||
@@ -606,15 +636,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)
|
||||
@@ -656,7 +689,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());
|
||||
@@ -669,11 +702,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();
|
||||
}
|
||||
@@ -701,7 +735,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)
|
||||
{
|
||||
@@ -714,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_screen.height()/1080);
|
||||
|
||||
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,160);
|
||||
//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);
|
||||
@@ -751,7 +785,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);
|
||||
@@ -782,11 +816,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;
|
||||
@@ -813,6 +847,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)
|
||||
{
|
||||
@@ -830,16 +865,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)
|
||||
{
|
||||
@@ -851,11 +885,18 @@ 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);
|
||||
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();
|
||||
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);
|
||||
|
||||
//m_scrollArea->adjustSize();
|
||||
//m_scrollArea->setWidgetResizable(true);
|
||||
m_toolWidget->setGeometry(m_screen);
|
||||
@@ -942,7 +983,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());
|
||||
@@ -1310,6 +1351,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);
|
||||
|
||||
//移动整个区域到指定的相对位置
|
||||
@@ -1362,8 +1404,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);
|
||||
|
||||
@@ -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,30 +120,106 @@ public:
|
||||
void changeBtnState(QString btnName, bool isEnterKey = false);
|
||||
|
||||
private:
|
||||
QString getAppLocalName(QString desktopfp);//获取应用名
|
||||
void ResizeEvent();
|
||||
void showInhibitWarning();//当有inhibitor存在时显示提醒界面
|
||||
void drawWarningWindow(QRect &rect);//画出提醒界面
|
||||
QMap<QString, QString> 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<QString, QString> 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);
|
||||
|
||||
void doLockscreen();//锁屏操作
|
||||
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:
|
||||
@@ -150,9 +249,15 @@ private:
|
||||
XEventMonitor *xEventMonitor;
|
||||
int tableNum;
|
||||
bool flag = false;
|
||||
|
||||
/// 各按钮是否隐藏 默认隐藏
|
||||
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;
|
||||
@@ -160,10 +265,8 @@ private:
|
||||
bool inhibitSleep = false;
|
||||
bool inhibitShutdown = false;
|
||||
|
||||
|
||||
QHash<MyPushButton*, bool> m_btnHideMap;
|
||||
|
||||
bool m_IsRoundBtn = true;//是否是圆形按钮
|
||||
QString m_btnImagesPath = "/usr/share/ukui/ukui-session-manager/images";
|
||||
MyPushButton *m_switchUserBtn = nullptr;
|
||||
MyPushButton *m_hibernateBtn = nullptr;
|
||||
@@ -201,6 +304,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;
|
||||
@@ -212,8 +316,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
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
|
||||
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();
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -22,20 +22,16 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
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);
|
||||
|
||||