Beta version 1.9.20: Fix build without dbus.

This commit is contained in:
John Preston 2020-03-14 16:13:33 +04:00
parent 46445e0542
commit fec6a8dd96
2 changed files with 20 additions and 15 deletions

View File

@ -411,6 +411,12 @@ void MainWindow::initHook() {
&QDBusServiceWatcher::serviceOwnerChanged, &QDBusServiceWatcher::serviceOwnerChanged,
this, this,
&MainWindow::onSNIOwnerChanged); &MainWindow::onSNIOwnerChanged);
connect(
windowHandle(),
&QWindow::visibleChanged,
this,
&MainWindow::onVisibleChanged);
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION #endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
if (UseUnityCounter()) { if (UseUnityCounter()) {
@ -418,12 +424,6 @@ void MainWindow::initHook() {
} else { } else {
LOG(("Not using Unity launcher counter.")); LOG(("Not using Unity launcher counter."));
} }
connect(
windowHandle(),
&QWindow::visibleChanged,
this,
&MainWindow::onVisibleChanged);
} }
bool MainWindow::hasTrayIcon() const { bool MainWindow::hasTrayIcon() const {
@ -632,9 +632,7 @@ void MainWindow::updateIconCounters() {
signal << dbusUnityProperties; signal << dbusUnityProperties;
QDBusConnection::sessionBus().send(signal); QDBusConnection::sessionBus().send(signal);
} }
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
if (_sniTrayIcon) { if (_sniTrayIcon) {
setSNITrayIcon(counter, muted); setSNITrayIcon(counter, muted);
} }
@ -658,8 +656,17 @@ void MainWindow::initTrayMenuHook() {
_trayIconMenuXEmbed->deleteOnHide(false); _trayIconMenuXEmbed->deleteOnHide(false);
} }
#ifdef TDESKTOP_DISABLE_DBUS_INTEGRATION
void MainWindow::createGlobalMenu() {
}
void MainWindow::updateGlobalMenuHook() {
}
#else // TDESKTOP_DISABLE_DBUS_INTEGRATION
void MainWindow::createGlobalMenu() { void MainWindow::createGlobalMenu() {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
if (!AppMenuSupported()) return; if (!AppMenuSupported()) return;
psMainMenu = new QMenu(this); psMainMenu = new QMenu(this);
@ -843,7 +850,6 @@ void MainWindow::createGlobalMenu() {
RegisterAppMenu(winId(), _mainMenuPath); RegisterAppMenu(winId(), _mainMenuPath);
updateGlobalMenu(); updateGlobalMenu();
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
} }
void MainWindow::psLinuxUndo() { void MainWindow::psLinuxUndo() {
@ -899,7 +905,6 @@ void MainWindow::psLinuxClearFormat() {
} }
void MainWindow::updateGlobalMenuHook() { void MainWindow::updateGlobalMenuHook() {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
if (!AppMenuSupported() || !App::wnd() || !positionInited()) return; if (!AppMenuSupported() || !App::wnd() || !positionInited()) return;
const auto focused = QApplication::focusWidget(); const auto focused = QApplication::focusWidget();
@ -959,11 +964,9 @@ void MainWindow::updateGlobalMenuHook() {
ForceDisabled(psStrikeOut, !markdownEnabled); ForceDisabled(psStrikeOut, !markdownEnabled);
ForceDisabled(psMonospace, !markdownEnabled); ForceDisabled(psMonospace, !markdownEnabled);
ForceDisabled(psClearFormat, !markdownEnabled); ForceDisabled(psClearFormat, !markdownEnabled);
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
} }
void MainWindow::onVisibleChanged(bool visible) { void MainWindow::onVisibleChanged(bool visible) {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
if (AppMenuSupported() && !_mainMenuPath.path().isEmpty()) { if (AppMenuSupported() && !_mainMenuPath.path().isEmpty()) {
if (visible) { if (visible) {
RegisterAppMenu(winId(), _mainMenuPath); RegisterAppMenu(winId(), _mainMenuPath);
@ -971,9 +974,10 @@ void MainWindow::onVisibleChanged(bool visible) {
UnregisterAppMenu(winId()); UnregisterAppMenu(winId());
} }
} }
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
} }
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
MainWindow::~MainWindow() { MainWindow::~MainWindow() {
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
delete _sniTrayIcon; delete _sniTrayIcon;

View File

@ -45,7 +45,6 @@ public slots:
const QString &service, const QString &service,
const QString &oldOwner, const QString &oldOwner,
const QString &newOwner); const QString &newOwner);
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
void psLinuxUndo(); void psLinuxUndo();
void psLinuxRedo(); void psLinuxRedo();
@ -64,6 +63,8 @@ public slots:
void onVisibleChanged(bool visible); void onVisibleChanged(bool visible);
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
protected: protected:
void initHook() override; void initHook() override;
void unreadCounterChangedHook() override; void unreadCounterChangedHook() override;