mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-04 01:32:31 +01:00
Merge #14123: gui: Add GUIUtil::bringToFront
0a656f85a9qt: All tray menu actions call showNormalIfMinimized (João Barbosa)6fc21aca6dqt: Use GUIUtil::bringToFront where possible (João Barbosa)5796671e1dqt: Add GUIUtil::bringToFront (João Barbosa)6b1d2972bfRemove obj_c for macOS Dock icon menu (Hennadii Stepanov)2464925e7bUse Qt signal for macOS Dock icon click event (Hennadii Stepanov)53bb6be3f8Remove obj_c for macOS Dock icon setting (Hennadii Stepanov) Pull request description: The sequence `show -> raise -> activateWindow` is factored out to the new function `GUIUtil::bringToFront` where a macOS fix is added in order to fix #13829. Also included: - simplification of `BitcoinGUI::showNormalIfMinimized` - simplified some connections to `BitcoinGUI::showNormalIfMinimized` - added missing connections to `BitcoinGUI::showNormalIfMinimized`. Tree-SHA512: a8e301aebc359aa353821e2af352ae356f44555724921b01da907e128653ef9dc55d8764a1bff72a579e5ff96df8a681f6804bfe83acba441da92fedff974a55
This commit is contained in:
@@ -60,6 +60,14 @@
|
||||
#include <QFontDatabase>
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#include <objc/objc-runtime.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
namespace GUIUtil {
|
||||
|
||||
QString dateTimeStr(const QDateTime &date)
|
||||
@@ -353,6 +361,27 @@ bool isObscured(QWidget *w)
|
||||
&& checkPoint(QPoint(w->width() / 2, w->height() / 2), w));
|
||||
}
|
||||
|
||||
void bringToFront(QWidget* w)
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
// Force application activation on macOS. With Qt 5.4 this is required when
|
||||
// an action in the dock menu is triggered.
|
||||
id app = objc_msgSend((id) objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
|
||||
objc_msgSend(app, sel_registerName("activateIgnoringOtherApps:"), YES);
|
||||
#endif
|
||||
|
||||
if (w) {
|
||||
// activateWindow() (sometimes) helps with keyboard focus on Windows
|
||||
if (w->isMinimized()) {
|
||||
w->showNormal();
|
||||
} else {
|
||||
w->show();
|
||||
}
|
||||
w->activateWindow();
|
||||
w->raise();
|
||||
}
|
||||
}
|
||||
|
||||
void openDebugLogfile()
|
||||
{
|
||||
fs::path pathDebug = GetDataDir() / "debug.log";
|
||||
@@ -663,13 +692,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
|
||||
|
||||
#elif defined(Q_OS_MAC)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
|
||||
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user