diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml index 2d1ed21..bdffa73 100644 --- a/qml/AppUI/Sidebar.qml +++ b/qml/AppUI/Sidebar.qml @@ -202,7 +202,7 @@ Item { ToolTip.visible: containsMouse ToolTip.text: powerButtonBase.toolTip acceptedButtons: Qt.LeftButton | Qt.RightButton - property int spacingFromMenu: 16 + property int spacingFromMenu: 4 activeFocusOnTab: true Keys.onPressed: { @@ -213,7 +213,8 @@ Item { onClicked: { var buttonPosition = powerButtonArea.mapToGlobal(width, height); - powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen); + powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + sidebarBottomBar.Layout.rightMargin + 4, + buttonPosition.y + sidebarBottomBar.Layout.bottomMargin, mainWindow.isFullScreen); } } } diff --git a/src/utils/power-button.cpp b/src/utils/power-button.cpp index dbde67a..dd4e35d 100644 --- a/src/utils/power-button.cpp +++ b/src/utils/power-button.cpp @@ -68,50 +68,75 @@ void PowerButton::openMenu(int menuX, int menuY, bool isFullScreen) "org.gnome.SessionManager", QDBusConnection::sessionBus()); if (canSwitch() && hasMultipleUsers()) { - connect(powerMenu.addAction(tr("Switch user")), &QAction::triggered, &powerMenu, [] { + QAction *action = new QAction(tr("Switch user"), &powerMenu); + connect(action, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-session-tools", "--switchuser"); }); + powerMenu.addAction(action); } reply = qDBusInterface.call("canHibernate"); if (reply.isValid() && reply.value()) { - connect(powerMenu.addAction(tr("Hibernate")), &QAction::triggered, &powerMenu, [] { + QAction *action = new QAction(tr("Hibernate"), &powerMenu); + action->setToolTip(tr("
Turn off the computer, but the applications " + "will remain open. When you turn on the computer again, " + "you can return to the state you were in before
")); + connect(action, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-session-tools", "--hibernate"); }); + powerMenu.addAction(action); } reply = qDBusInterface.call("canSuspend"); if (reply.isValid() && reply.value()) { - connect(powerMenu.addAction(tr("Suspend")), &QAction::triggered, &powerMenu, [] { + QAction *action = new QAction(tr("Suspend"), &powerMenu); + action->setToolTip(tr("The computer remains on but consumes less power, " + "and the applications will remain open. You can quickly wake " + "up the computer and return to the state you left
")); + connect(action, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-session-tools", "--suspend"); }); + powerMenu.addAction(action); } - connect(powerMenu.addAction(tr("Lock Screen")), &QAction::triggered, &powerMenu, [] { + QAction *lockAction = new QAction(tr("Lock Screen"), &powerMenu); + connect(lockAction, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-screensaver-command", "-l"); }); + powerMenu.addAction(lockAction); reply = qDBusInterface.call("canLogout"); if (reply.isValid() && reply.value()) { - connect(powerMenu.addAction(tr("Log Out")), &QAction::triggered, &powerMenu, [] { + QAction *action = new QAction(tr("Log Out"), &powerMenu); + action->setToolTip(tr("The current user logs out of the system, ending " + "their session and returning to the login screen
")); + connect(action, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-session-tools", "--logout"); }); + powerMenu.addAction(action); } reply = qDBusInterface.call("canReboot"); if (reply.isValid() && reply.value()) { - connect(powerMenu.addAction(tr("Reboot")), &QAction::triggered, &powerMenu, [] { + QAction *action = new QAction(tr("Reboot"), &powerMenu); + action->setToolTip(tr("Close all applications, turn off the computer, and then turn it back on
")); + connect(action, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-session-tools", "--reboot"); }); + powerMenu.addAction(action); } reply = qDBusInterface.call("canPowerOff"); if (reply.isValid() && reply.value()) { - connect(powerMenu.addAction(tr("Power Off")), &QAction::triggered, &powerMenu, [] { + QAction *action = new QAction(tr("Power Off"), &powerMenu); + action->setToolTip(tr("Close all applications, and then turn off the computer
")); + connect(action, &QAction::triggered, &powerMenu, [] { AppManager::instance()->launchBinaryApp("ukui-session-tools", "--shutdown"); }); + powerMenu.addAction(action); } + powerMenu.setToolTipsVisible(true); powerMenu.setAttribute(Qt::WA_DeleteOnClose); if (isFullScreen) {