fix(powerButton):电源右键菜单添加tooltips(issues:I7H1AF;I8J75H)
修复电源右键菜单位置不对齐问题(issues:I8J74R)
This commit is contained in:
parent
7985110082
commit
6039e6c66c
|
@ -202,7 +202,7 @@ Item {
|
||||||
ToolTip.visible: containsMouse
|
ToolTip.visible: containsMouse
|
||||||
ToolTip.text: powerButtonBase.toolTip
|
ToolTip.text: powerButtonBase.toolTip
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
property int spacingFromMenu: 16
|
property int spacingFromMenu: 4
|
||||||
|
|
||||||
activeFocusOnTab: true
|
activeFocusOnTab: true
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
|
@ -213,7 +213,8 @@ Item {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var buttonPosition = powerButtonArea.mapToGlobal(width, height);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,50 +68,75 @@ void PowerButton::openMenu(int menuX, int menuY, bool isFullScreen)
|
||||||
"org.gnome.SessionManager", QDBusConnection::sessionBus());
|
"org.gnome.SessionManager", QDBusConnection::sessionBus());
|
||||||
|
|
||||||
if (canSwitch() && hasMultipleUsers()) {
|
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");
|
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--switchuser");
|
||||||
});
|
});
|
||||||
|
powerMenu.addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = qDBusInterface.call("canHibernate");
|
reply = qDBusInterface.call("canHibernate");
|
||||||
if (reply.isValid() && reply.value()) {
|
if (reply.isValid() && reply.value()) {
|
||||||
connect(powerMenu.addAction(tr("Hibernate")), &QAction::triggered, &powerMenu, [] {
|
QAction *action = new QAction(tr("Hibernate"), &powerMenu);
|
||||||
|
action->setToolTip(tr("<p>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</p>"));
|
||||||
|
connect(action, &QAction::triggered, &powerMenu, [] {
|
||||||
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--hibernate");
|
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--hibernate");
|
||||||
});
|
});
|
||||||
|
powerMenu.addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = qDBusInterface.call("canSuspend");
|
reply = qDBusInterface.call("canSuspend");
|
||||||
if (reply.isValid() && reply.value()) {
|
if (reply.isValid() && reply.value()) {
|
||||||
connect(powerMenu.addAction(tr("Suspend")), &QAction::triggered, &powerMenu, [] {
|
QAction *action = new QAction(tr("Suspend"), &powerMenu);
|
||||||
|
action->setToolTip(tr("<p>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</p>"));
|
||||||
|
connect(action, &QAction::triggered, &powerMenu, [] {
|
||||||
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--suspend");
|
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");
|
AppManager::instance()->launchBinaryApp("ukui-screensaver-command", "-l");
|
||||||
});
|
});
|
||||||
|
powerMenu.addAction(lockAction);
|
||||||
|
|
||||||
reply = qDBusInterface.call("canLogout");
|
reply = qDBusInterface.call("canLogout");
|
||||||
if (reply.isValid() && reply.value()) {
|
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("<p>The current user logs out of the system, ending "
|
||||||
|
"their session and returning to the login screen</p>"));
|
||||||
|
connect(action, &QAction::triggered, &powerMenu, [] {
|
||||||
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--logout");
|
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--logout");
|
||||||
});
|
});
|
||||||
|
powerMenu.addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = qDBusInterface.call("canReboot");
|
reply = qDBusInterface.call("canReboot");
|
||||||
if (reply.isValid() && reply.value()) {
|
if (reply.isValid() && reply.value()) {
|
||||||
connect(powerMenu.addAction(tr("Reboot")), &QAction::triggered, &powerMenu, [] {
|
QAction *action = new QAction(tr("Reboot"), &powerMenu);
|
||||||
|
action->setToolTip(tr("<p>Close all applications, turn off the computer, and then turn it back on</p>"));
|
||||||
|
connect(action, &QAction::triggered, &powerMenu, [] {
|
||||||
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--reboot");
|
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--reboot");
|
||||||
});
|
});
|
||||||
|
powerMenu.addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = qDBusInterface.call("canPowerOff");
|
reply = qDBusInterface.call("canPowerOff");
|
||||||
if (reply.isValid() && reply.value()) {
|
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("<p>Close all applications, and then turn off the computer</p>"));
|
||||||
|
connect(action, &QAction::triggered, &powerMenu, [] {
|
||||||
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--shutdown");
|
AppManager::instance()->launchBinaryApp("ukui-session-tools", "--shutdown");
|
||||||
});
|
});
|
||||||
|
powerMenu.addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
powerMenu.setToolTipsVisible(true);
|
||||||
powerMenu.setAttribute(Qt::WA_DeleteOnClose);
|
powerMenu.setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
|
|
Loading…
Reference in New Issue