forked from openkylin/ukui-menu
修改bug133399,单用户电源右键存在切换用户选项
This commit is contained in:
parent
d2c9b3bab8
commit
ebdfe9b63e
|
@ -101,6 +101,36 @@ void RightClickMenu::removeFromCollectionActionTriggerSlot()
|
|||
m_actionNumber = 18;
|
||||
}
|
||||
|
||||
bool RightClickMenu::hasMultipleUsers()
|
||||
{
|
||||
QDBusInterface interface("org.freedesktop.Accounts",
|
||||
"/org/freedesktop/Accounts",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
QDBusConnection::systemBus());
|
||||
if (!interface.isValid()) {
|
||||
qCritical() << QDBusConnection::systemBus().lastError().message();
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusReply<QVariant> reply = interface.call("Get","org.freedesktop.Accounts","HasMultipleUsers");
|
||||
return reply.value().toBool();
|
||||
}
|
||||
|
||||
bool RightClickMenu::canSwitch()
|
||||
{
|
||||
QDBusInterface interface("org.freedesktop.DisplayManager",
|
||||
"/org/freedesktop/DisplayManager/Seat0",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
QDBusConnection::systemBus());
|
||||
if (!interface.isValid()) {
|
||||
qCritical() << QDBusConnection::systemBus().lastError().message();
|
||||
return false;
|
||||
} else {
|
||||
QDBusReply<QVariant> reply = interface.call("Get","org.freedesktop.DisplayManager.Seat","CanSwitch");
|
||||
return reply.value().toBool();
|
||||
}
|
||||
}
|
||||
|
||||
void RightClickMenu::fixToTaskbarActionTriggerSlot()
|
||||
{
|
||||
QDBusInterface iface("com.ukui.panel.desktop",
|
||||
|
@ -265,12 +295,12 @@ int RightClickMenu::showShutdownMenu(const QPoint &pos, const bool &isFullWind)
|
|||
{
|
||||
m_actionNumber = 0;
|
||||
MenuBox m_showShutMenu;
|
||||
QDBusReply<bool> reply;
|
||||
connect(&m_showShutMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal);
|
||||
QDBusInterface iface(DBUS_SESSION_NAME, DBUS_SESSION_PATH,
|
||||
DBUS_SESSION_INTERFACE, QDBusConnection::sessionBus());
|
||||
QDBusReply<bool> reply = iface.call("canSwitch");
|
||||
|
||||
if (reply.isValid() && reply.value() == true) {
|
||||
if (canSwitch() && hasMultipleUsers()) {
|
||||
m_showShutMenu.addAction(QIcon(getIconPixmap("stock-people-symbolic", 1)), tr("Switch user"),
|
||||
this, SLOT(switchUserActionTriggerSlot()));
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ private:
|
|||
int m_actionNumber;
|
||||
QProcess *m_cmdProc = nullptr;
|
||||
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
|
||||
|
||||
QStringList m_whiteList;
|
||||
|
||||
protected:
|
||||
|
@ -92,6 +91,10 @@ protected:
|
|||
*/
|
||||
QPixmap getIconPixmap(QString iconstr, int type);
|
||||
|
||||
bool hasMultipleUsers();
|
||||
|
||||
bool canSwitch();
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* @brief Fixed to all software
|
||||
|
|
Loading…
Reference in New Issue