WIP: Improve positioning of tray widget under Wayland
* Add support for the layer shell protocol
This commit is contained in:
parent
71675c7b18
commit
864d2777b5
|
@ -132,6 +132,18 @@ endif ()
|
||||||
# apply basic configuration
|
# apply basic configuration
|
||||||
include(BasicConfig)
|
include(BasicConfig)
|
||||||
|
|
||||||
|
# configure support for layer-shell protocol
|
||||||
|
if (LINUX)
|
||||||
|
option(LAYER_SHELL_PROTOCOL_SUPPORT "whether to compile with support for the layer-shell protocol" OFF)
|
||||||
|
if (LAYER_SHELL_PROTOCOL_SUPPORT)
|
||||||
|
use_package(TARGET_NAME LayerShellQt::Interface PACKAGE_NAME LayerShellQt PACKAGE_ARGS "REQUIRED")
|
||||||
|
set_property(
|
||||||
|
SOURCE application/main.cpp
|
||||||
|
APPEND
|
||||||
|
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_LAYER_SHELL_PROTOCOL_SUPPORT)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
# add an option to unify left- and right-click context menus useful on Mac OS
|
# add an option to unify left- and right-click context menus useful on Mac OS
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(UNIFY_TRAY_MENUS_BY_DEFAULT ON)
|
set(UNIFY_TRAY_MENUS_BY_DEFAULT ON)
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#include <qtutilities/resources/resources.h>
|
#include <qtutilities/resources/resources.h>
|
||||||
#include <qtutilities/settingsdialog/qtsettings.h>
|
#include <qtutilities/settingsdialog/qtsettings.h>
|
||||||
|
|
||||||
|
#ifdef SYNCTHINGTRAY_LAYER_SHELL_PROTOCOL_SUPPORT
|
||||||
|
#include <LayerShellQt/Shell>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
@ -106,6 +110,14 @@ int initSyncthingTray(bool windowed, bool waitForTray, const Argument &connectio
|
||||||
auto *const trayIcon = new TrayIcon(QString::fromLocal8Bit(connectionConfig), QApplication::instance());
|
auto *const trayIcon = new TrayIcon(QString::fromLocal8Bit(connectionConfig), QApplication::instance());
|
||||||
trayIcon->show();
|
trayIcon->show();
|
||||||
widget = &trayIcon->trayMenu().widget();
|
widget = &trayIcon->trayMenu().widget();
|
||||||
|
#ifdef SYNCTHINGTRAY_LAYER_SHELL_PROTOCOL_SUPPORT
|
||||||
|
if (auto *const qtWindow = trayIcon->trayMenu().windowHandle()) {
|
||||||
|
if (auto *const layerShellWindow = LayerShellQt::Window::get(qtWindow)) {
|
||||||
|
layerShellWindow->setAnchors(
|
||||||
|
static_cast<LayerShellQt::Window::Anchors>(LayerShellQt::Window::AnchorTop | LayerShellQt::Window::AnchorRight));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// show wizard on first launch
|
// show wizard on first launch
|
||||||
|
@ -211,6 +223,9 @@ int runApplication(int argc, const char *const *argv)
|
||||||
|
|
||||||
// do first-time initializations
|
// do first-time initializations
|
||||||
SET_QT_APPLICATION_INFO;
|
SET_QT_APPLICATION_INFO;
|
||||||
|
#ifdef SYNCTHINGTRAY_LAYER_SHELL_PROTOCOL_SUPPORT
|
||||||
|
LayerShellQt::Shell::useLayerShell();
|
||||||
|
#endif
|
||||||
QApplication application(argc, const_cast<char **>(argv));
|
QApplication application(argc, const_cast<char **>(argv));
|
||||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||||
SingleInstance singleInstance(argc, argv, newInstanceArg.isPresent());
|
SingleInstance singleInstance(argc, argv, newInstanceArg.isPresent());
|
||||||
|
|
Loading…
Reference in New Issue