0
0
mirror of https://github.com/keepassxreboot/keepassxc.git synced 2024-09-19 20:02:18 +02:00

Re-register global D-Bus menu when restoring window from tray, resolves #271

This commit is contained in:
Janek Bevendorff 2017-02-09 15:28:52 +01:00 committed by Jonathan White
parent 38d64a34a1
commit 8a26cfad79
3 changed files with 40 additions and 2 deletions

View File

@ -166,6 +166,9 @@ find_package(Qt5Widgets 5.2 REQUIRED)
find_package(Qt5Test 5.2 REQUIRED)
find_package(Qt5LinguistTools 5.2 REQUIRED)
find_package(Qt5Network 5.2 REQUIRED)
if (UNIX AND NOT APPLE)
find_package(Qt5DBus 5.2 REQUIRED)
endif()
set(CMAKE_AUTOMOC ON)
# Debian sets the the build type to None for package builds.

View File

@ -197,7 +197,11 @@ target_link_libraries(zxcvbn)
if(WITH_XC_HTTP)
add_library(keepasshttp STATIC ${keepasshttp_SOURCES})
target_link_libraries(keepasshttp ${MHD_LIBRARIES} Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network)
target_link_libraries(keepasshttp ${MHD_LIBRARIES}
Qt5::Core
Qt5::Concurrent
Qt5::Widgets
Qt5::Network)
endif()
add_library(autotype STATIC ${autotype_SOURCES})
@ -207,7 +211,14 @@ set(autotype_LIB autotype)
add_library(keepassx_core STATIC ${keepassx_SOURCES})
set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core zxcvbn ${keepasshttp_LIB} ${autotype_LIB} Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network)
target_link_libraries(keepassx_core zxcvbn ${keepasshttp_LIB} ${autotype_LIB}
Qt5::Core
Qt5::Concurrent
Qt5::Widgets
Qt5::Network)
if (UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus)
endif()
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE})
target_link_libraries(${PROGNAME}
@ -221,6 +232,7 @@ target_link_libraries(${PROGNAME}
${GPGERROR_LIBRARIES}
${ZLIB_LIBRARIES})
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
if(APPLE)

View File

@ -22,6 +22,11 @@
#include <QShortcut>
#include <QTimer>
#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS)
#include <QList>
#include <QtDBus/QtDBus>
#endif
#include "config-keepassx.h"
#include "autotype/AutoType.h"
@ -735,6 +740,24 @@ void MainWindow::toggleWindow()
setWindowState(windowState() & ~Qt::WindowMinimized);
raise();
activateWindow();
#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
// re-register global D-Bus menu (needed on Ubuntu with Unity)
// see https://github.com/keepassxreboot/keepassxc/issues/271
// and https://bugreports.qt.io/browse/QTBUG-58723
if (m_ui->menubar->isNativeMenuBar()) {
QDBusMessage msg = QDBusMessage::createMethodCall(
"com.canonical.AppMenu.Registrar",
"/com/canonical/AppMenu/Registrar",
"com.canonical.AppMenu.Registrar",
"RegisterWindow");
QList<QVariant> args;
args << QVariant::fromValue(static_cast<uint32_t>(winId()))
<< QVariant::fromValue(QDBusObjectPath("/MenuBar/1"));
msg.setArguments(args);
QDBusConnection::sessionBus().send(msg);
}
#endif
}
}