diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 36351cc47..8b74d6b04 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -520,10 +520,6 @@ endif() if (LINUX) target_sources(Kepka PRIVATE SourceFiles/platform/linux/file_utilities_linux.cpp - SourceFiles/platform/linux/linux_desktop_environment.cpp - SourceFiles/platform/linux/linux_gdk_helper.cpp - SourceFiles/platform/linux/linux_libnotify.cpp - SourceFiles/platform/linux/linux_libs.cpp SourceFiles/platform/linux/main_window_linux.cpp SourceFiles/platform/linux/notifications_manager_linux.cpp SourceFiles/platform/linux/specific_linux.cpp @@ -706,7 +702,7 @@ if(WIN32) endif() if (LINUX) - target_link_libraries(Kepka Qt5::DBus dl ${ALSA_LIBRARIES} ${PULSEAUDIO_LIBRARIES}) + target_link_libraries(Kepka Qt5::DBus dl) endif() # Enable LTO optimizations... diff --git a/Telegram/SourceFiles/main.cpp b/Telegram/SourceFiles/main.cpp index 536271073..e66ca28a6 100644 --- a/Telegram/SourceFiles/main.cpp +++ b/Telegram/SourceFiles/main.cpp @@ -43,9 +43,6 @@ int main(int argc, char *argv[]) { Logs::start(); // must be started before Platform is started Platform::start(); // must be started before QApplication is created - qputenv("QT_STYLE_OVERRIDE", "qwerty"); - qunsetenv("QT_QPA_PLATFORMTHEME"); - int result = 0; { Application app(argc, argv); diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index 54a2d46e1..59cf11a3f 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -22,18 +22,13 @@ // #include "platform/linux/file_utilities_linux.h" -// #include #include "facades.h" #include "mainwindow.h" #include "messenger.h" -#include "platform/linux/linux_gdk_helper.h" -#include "platform/linux/linux_libs.h" #include "storage/localstorage.h" #include -QStringList qt_make_filter_list(const QString &filter); - namespace Platform { namespace File { namespace internal { @@ -113,20 +108,5 @@ bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, return ::FileDialog::internal::GetDefault(files, remoteContent, caption, filter, type, startFile); } -namespace { - -const char *filterRegExp = "^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; - -// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" -QStringList cleanFilterList(const QString &filter) { - QRegExp regexp(QString::fromLatin1(filterRegExp)); - Q_ASSERT(regexp.isValid()); - QString f = filter; - int i = regexp.indexIn(f); - if (i >= 0) f = regexp.cap(2); - return f.split(QLatin1Char(' '), QString::SkipEmptyParts); -} - -} // namespace } // namespace FileDialog } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp deleted file mode 100644 index fec423973..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#include "platform/linux/linux_desktop_environment.h" -#include "logs.h" - -#include - -#define qstr QString // to avoid #include bloat utils.h - -namespace Platform { -namespace DesktopEnvironment { -namespace { - -QString GetEnv(const char *name) { - auto result = getenv(name); - auto value = result ? QString::fromLatin1(result) : QString(); - LOG(("Getting DE, %1: '%2'").arg(name).arg(value)); - return value; -} - -Type Compute() { - auto xdgCurrentDesktop = GetEnv("XDG_CURRENT_DESKTOP").toLower(); - auto list = xdgCurrentDesktop.split(':', QString::SkipEmptyParts); - auto desktopSession = GetEnv("DESKTOP_SESSION").toLower(); - auto kdeSession = GetEnv("KDE_SESSION_VERSION"); - if (!list.isEmpty()) { - if (list.contains("unity")) { - // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity - // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz - if (desktopSession.indexOf(QString("gnome-fallback")) >= 0) { - return Type::Gnome; - } - return Type::Unity; - } else if (list.contains("xfce")) { - return Type::XFCE; - } else if (list.contains("pantheon")) { - return Type::Pantheon; - } else if (list.contains("gnome")) { - return Type::Gnome; - } else if (list.contains("kde")) { - if (kdeSession == QString("5")) { - return Type::KDE5; - } - return Type::KDE4; - } - } - - if (!desktopSession.isEmpty()) { - if (desktopSession == qstr("gnome") || desktopSession == qstr("mate")) { - return Type::Gnome; - } else if (desktopSession == qstr("kde4") || desktopSession == qstr("kde-plasma")) { - return Type::KDE4; - } else if (desktopSession == qstr("kde")) { - // This may mean KDE4 on newer systems, so we have to check. - if (!kdeSession.isEmpty()) { - return Type::KDE4; - } - return Type::KDE3; - } else if (desktopSession.indexOf(qstr("xfce")) >= 0 || desktopSession == qstr("xubuntu")) { - return Type::XFCE; - } - } - - // Fall back on some older environment variables. - // Useful particularly in the DESKTOP_SESSION=default case. - if (!GetEnv("GNOME_DESKTOP_SESSION_ID").isEmpty()) { - return Type::Gnome; - } else if (!GetEnv("KDE_FULL_SESSION").isEmpty()) { - if (!kdeSession.isEmpty()) { - return Type::KDE4; - } - return Type::KDE3; - } - - return Type::Other; -} - -Type ComputeAndLog() { - auto result = Compute(); - auto name = [result]() -> QString { - switch (result) { - case Type::Other: return "Other"; - case Type::Gnome: return "Gnome"; - case Type::KDE3: return "KDE3"; - case Type::KDE4: return "KDE4"; - case Type::KDE5: return "KDE5"; - case Type::Unity: return "Unity"; - case Type::XFCE: return "XFCE"; - case Type::Pantheon: return "Pantheon"; - } - return QString::number(static_cast(result)); - }; - LOG(("DE: %1").arg(name())); - return result; -} - -} // namespace - -// Thanks Chromium. -Type Get() { - static const auto result = ComputeAndLog(); - return result; -} - -bool TryQtTrayIcon() { - return !IsPantheon(); -} - -bool PreferAppIndicatorTrayIcon() { - return IsXFCE() || IsUnity() || (IsGnome() && QDBusInterface("org.kde.StatusNotifierWatcher", "/").isValid()); -} - -bool TryUnityCounter() { - return IsUnity() || IsPantheon(); -} - -} // namespace DesktopEnvironment -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h deleted file mode 100644 index 8649dddda..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h +++ /dev/null @@ -1,78 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#pragma once - -namespace Platform { -namespace DesktopEnvironment { - -enum class Type { - Other, - Gnome, - KDE3, - KDE4, - KDE5, - Unity, - XFCE, - Pantheon, -}; - -Type Get(); - -inline bool IsGnome() { - return Get() == Type::Gnome; -} - -inline bool IsKDE3() { - return Get() == Type::KDE3; -} - -inline bool IsKDE4() { - return Get() == Type::KDE4; -} - -inline bool IsKDE5() { - return Get() == Type::KDE5; -} - -inline bool IsKDE() { - return IsKDE3() || IsKDE4() || IsKDE5(); -} - -inline bool IsUnity() { - return Get() == Type::Unity; -} - -inline bool IsXFCE() { - return Get() == Type::XFCE; -} - -inline bool IsPantheon() { - return Get() == Type::Pantheon; -} - -bool TryQtTrayIcon(); -bool PreferAppIndicatorTrayIcon(); -bool TryUnityCounter(); - -} // namespace DesktopEnvironment -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp deleted file mode 100644 index d40139780..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// diff --git a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h deleted file mode 100644 index 4049a30b7..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#pragma once - -#include diff --git a/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp b/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp deleted file mode 100644 index 7b4f0d523..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#include "platform/linux/linux_libnotify.h" - -#include "logs.h" - -#include "platform/linux/linux_libs.h" - -namespace Platform { -namespace Libs { -namespace { - -bool loadLibrary(QLibrary &lib, const char *name, int version) { - DEBUG_LOG(("Loading '%1' with version %2...").arg(QLatin1String(name)).arg(version)); - lib.setFileNameAndVersion(QLatin1String(name), version); - if (lib.load()) { - DEBUG_LOG(("Loaded '%1' with version %2!").arg(QLatin1String(name)).arg(version)); - return true; - } - lib.setFileNameAndVersion(QLatin1String(name), QString()); - if (lib.load()) { - DEBUG_LOG(("Loaded '%1' without version!").arg(QLatin1String(name))); - return true; - } - LOG(("Could not load '%1' with version %2 :(").arg(QLatin1String(name)).arg(version)); - return false; -} - -} // namespace -} // namespace Libs -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_libnotify.h b/Telegram/SourceFiles/platform/linux/linux_libnotify.h deleted file mode 100644 index 8494f88c6..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_libnotify.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#pragma once diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.cpp b/Telegram/SourceFiles/platform/linux/linux_libs.cpp deleted file mode 100644 index c6b62af89..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_libs.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#include "platform/linux/linux_libs.h" - -#include "logs.h" -#include "platform/linux/linux_desktop_environment.h" -#include "platform/linux/linux_gdk_helper.h" -#include "platform/linux/linux_libnotify.h" -#include "settings.h" - -namespace Platform { -namespace Libs { -namespace { - -bool loadLibrary(QLibrary &lib, const char *name, int version) { - DEBUG_LOG(("Loading '%1' with version %2...").arg(QLatin1String(name)).arg(version)); - lib.setFileNameAndVersion(QLatin1String(name), version); - if (lib.load()) { - DEBUG_LOG(("Loaded '%1' with version %2!").arg(QLatin1String(name)).arg(version)); - return true; - } - lib.setFileNameAndVersion(QLatin1String(name), QString()); - if (lib.load()) { - DEBUG_LOG(("Loaded '%1' without version!").arg(QLatin1String(name))); - return true; - } - LOG(("Could not load '%1' with version %2 :(").arg(QLatin1String(name)).arg(version)); - return false; -} - - -} // namespace - - -void start() { - DEBUG_LOG(("Loading libraries")); -} - -} // namespace Libs -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.h b/Telegram/SourceFiles/platform/linux/linux_libs.h deleted file mode 100644 index b535243d3..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_libs.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// This file is part of Kepka, -// an unofficial desktop version of Telegram messaging app, -// see https://github.com/procxx/kepka -// -// Kepka is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// It is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// In addition, as a special exception, the copyright holders give permission -// to link the code of portions of this program with the OpenSSL library. -// -// Full license: https://github.com/procxx/kepka/blob/master/LICENSE -// Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -// Copyright (c) 2017- Kepka Contributors, https://github.com/procxx -// -#pragma once - -#include - -#include "logs.h" - -namespace Platform { -namespace Libs { - -void start(); - -template bool load(QLibrary &lib, const char *name, Function &func) { - func = nullptr; - if (!lib.isLoaded()) { - return false; - } - - func = reinterpret_cast(lib.resolve(name)); - if (func) { - return true; - } - LOG(("Error: failed to load '%1' function!").arg(name)); - return false; -} - - -} // namespace Libs -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 5f829044b..322db9583 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -28,8 +28,6 @@ #include "lang/lang_keys.h" #include "mainwindow.h" #include "messenger.h" -#include "platform/linux/linux_desktop_environment.h" -#include "platform/linux/linux_libs.h" #include "platform/platform_notifications_manager.h" #include "storage/localstorage.h" #include "styles/style_window.h" @@ -37,21 +35,16 @@ namespace Platform { namespace { -bool noQtTrayIcon = false, tryAppIndicator = false; - - qint32 _trayIconSize = 22; bool _trayIconMuted = true; qint32 _trayIconCount = 0; QImage _trayIconImageBack, _trayIconImage; - #define QT_RED 0 #define QT_GREEN 1 #define QT_BLUE 2 #define QT_ALPHA 3 - QImage _trayIconImageGen() { qint32 counter = App::histories().unreadBadge(), counterSlice = (counter >= 1000) ? (1000 + (counter % 100)) : counter; @@ -117,91 +110,57 @@ QString _trayIconImageFile() { return QString(); } - } // namespace -MainWindow::MainWindow() { - connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck())); - _psCheckStatusIconTimer.setSingleShot(false); - - connect(&_psUpdateIndicatorTimer, SIGNAL(timeout()), this, SLOT(psUpdateIndicator())); - _psUpdateIndicatorTimer.setSingleShot(true); -} - bool MainWindow::hasTrayIcon() const { return trayIcon; } -void MainWindow::psStatusIconCheck() { - if (cSupportTray() || !--_psCheckStatusIconLeft) { - _psCheckStatusIconTimer.stop(); - return; - } -} - -void MainWindow::psShowTrayMenu() {} - -void MainWindow::psTrayMenuUpdated() {} - void MainWindow::psSetupTrayIcon() { - if (noQtTrayIcon) { - if (!cSupportTray()) return; - updateIconCounters(); - } else { - LOG(("Using Qt tray icon.")); - if (!trayIcon) { - trayIcon = new QSystemTrayIcon(this); - QIcon icon; - QFileInfo iconFile(_trayIconImageFile()); - if (iconFile.exists()) { - QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); - icon = QIcon(path.constData()); - } else { - icon = Window::CreateIcon(); - } - trayIcon->setIcon(icon); - - trayIcon->setToolTip(str_const_toString(AppName)); - connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, - SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection); - - // This is very important for native notifications via libnotify! - // Some notification servers compose several notifications with a "Reply" - // action into one and after that a click on "Reply" button does not call - // the specified callback from any of the sent notification - libnotify - // just ignores ibus messages, but Qt tray icon at least emits this signal. - connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray())); - - App::wnd()->updateTrayMenu(); + if (!trayIcon) { + trayIcon = new QSystemTrayIcon(this); + QIcon icon; + QFileInfo iconFile(_trayIconImageFile()); + if (iconFile.exists()) { + QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); + icon = QIcon(path.constData()); + } else { + icon = Window::CreateIcon(); } - updateIconCounters(); + trayIcon->setIcon(icon); - trayIcon->show(); + trayIcon->setToolTip(str_const_toString(AppName)); + connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, + SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection); + + // This is very important for native notifications via libnotify! + // Some notification servers compose several notifications with a "Reply" + // action into one and after that a click on "Reply" button does not call + // the specified callback from any of the sent notification - libnotify + // just ignores ibus messages, but Qt tray icon at least emits this signal. + connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray())); + + App::wnd()->updateTrayMenu(); } + updateIconCounters(); + + trayIcon->show(); } void MainWindow::workmodeUpdated(DBIWorkMode mode) { if (!cSupportTray()) return; if (mode == dbiwmWindowOnly) { - if (noQtTrayIcon) { - } else { - if (trayIcon) { - trayIcon->setContextMenu(0); - trayIcon->deleteLater(); - } - trayIcon = 0; + if (trayIcon) { + trayIcon->setContextMenu(0); + trayIcon->deleteLater(); } + trayIcon = 0; } else { - if (noQtTrayIcon) { - } else { - psSetupTrayIcon(); - } + psSetupTrayIcon(); } } -void MainWindow::psUpdateIndicator() {} - void MainWindow::unreadCounterChangedHook() { setWindowTitle(titleText()); updateIconCounters(); @@ -210,8 +169,7 @@ void MainWindow::unreadCounterChangedHook() { void MainWindow::updateIconCounters() { updateWindowIcon(); - if (noQtTrayIcon) { - } else if (trayIcon) { + if (trayIcon) { QIcon icon; QFileInfo iconFile(_trayIconImageFile()); if (iconFile.exists()) { @@ -230,27 +188,14 @@ void MainWindow::updateIconCounters() { } } -void MainWindow::LibsLoaded() { - noQtTrayIcon = !DesktopEnvironment::TryQtTrayIcon(); - - LOG(("Tray Icon: Try Qt = %1, Prefer appindicator = %2").arg(Logs::b(!noQtTrayIcon)).arg(Logs::b(tryAppIndicator))); - - if (noQtTrayIcon) cSetSupportTray(false); -} - void MainWindow::psCreateTrayIcon() { - if (!noQtTrayIcon) { - LOG(("Tray Icon: Using Qt tray icon, available: %1").arg(Logs::b(QSystemTrayIcon::isSystemTrayAvailable()))); - cSetSupportTray(QSystemTrayIcon::isSystemTrayAvailable()); - return; - } + LOG(("Tray Icon: Using Qt tray icon, available: %1").arg(Logs::b(QSystemTrayIcon::isSystemTrayAvailable()))); + cSetSupportTray(QSystemTrayIcon::isSystemTrayAvailable()); + return; } void MainWindow::psFirstShow() { psCreateTrayIcon(); - - psUpdateMargins(); - show(); if (cWindowPos().maximized) { @@ -272,10 +217,4 @@ void MainWindow::psFirstShow() { setPositionInited(); } -void MainWindow::psInitSysMenu() {} - -void MainWindow::psUpdateMargins() {} - -MainWindow::~MainWindow() {} - } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index e52766978..ee13bdf36 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -24,8 +24,6 @@ #include "platform/platform_main_window.h" -#include - class QSystemTrayIcon; class QMenu; @@ -35,25 +33,16 @@ class MainWindow : public Window::MainWindow { Q_OBJECT public: - MainWindow(); + MainWindow() {} void psFirstShow(); - void psInitSysMenu(); - void psUpdateMargins(); - - void psRefreshTaskbarIcon() {} virtual QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) = 0; - static void LibsLoaded(); - - ~MainWindow(); + ~MainWindow() {} public slots: - void psShowTrayMenu(); - - void psStatusIconCheck(); - void psUpdateIndicator(); + void psShowTrayMenu() {} protected: void unreadCounterChangedHook() override; @@ -65,7 +54,7 @@ protected: QSystemTrayIcon *trayIcon = nullptr; QMenu *trayIconMenu = nullptr; - void psTrayMenuUpdated(); + void psTrayMenuUpdated() {} void psSetupTrayIcon(); virtual void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, @@ -74,12 +63,6 @@ protected: private: void updateIconCounters(); void psCreateTrayIcon(); - - QTimer _psCheckStatusIconTimer; - int _psCheckStatusIconLeft = 100; - - QTimer _psUpdateIndicatorTimer; - TimeMs _psLastIndicatorUpdate = 0; }; } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index d6c28a8bf..1d0a839e3 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -22,13 +22,6 @@ // #include "platform/linux/notifications_manager_linux.h" -#include "base/task_queue.h" -#include "config.h" -#include "lang/lang_keys.h" -#include "platform/linux/linux_libnotify.h" -#include "platform/linux/linux_libs.h" -#include "window/notifications_utilities.h" - namespace Platform { namespace Notifications { @@ -40,7 +33,5 @@ std::unique_ptr Create(Window::Notifications::Sy return nullptr; } -void Finish() {} - } // namespace Notifications } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h index fc57999e9..c276bf546 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.h @@ -37,28 +37,5 @@ inline bool SkipToast() { inline void FlashBounce() {} -void Finish(); - -class Manager : public Window::Notifications::NativeManager { -public: - Manager(Window::Notifications::System *system); - - void clearNotification(PeerId peerId, MsgId msgId); - bool hasPoorSupport() const; - bool hasActionsSupport() const; - - ~Manager(); - -protected: - void doShowNativeNotification(PeerData *peer, MsgId msgId, const QString &title, const QString &subtitle, - const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) override; - void doClearAllFast() override; - void doClearFromHistory(History *history) override; - -private: - class Private; - const std::unique_ptr _private; -}; - } // namespace Notifications } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index efc4db6fa..31e1361ac 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -27,7 +27,6 @@ #include "mainwidget.h" #include "mainwindow.h" #include "platform/linux/file_utilities_linux.h" -#include "platform/linux/linux_libs.h" #include "platform/platform_notifications_manager.h" #include "storage/localstorage.h" @@ -111,8 +110,6 @@ QAbstractNativeEventFilter *psNativeEventFilter() { return _psEventFilter; } -void psWriteDump() {} - QString demanglestr(const QString &mangled) { if (mangled.isEmpty()) return mangled; @@ -359,20 +356,13 @@ int psCleanup() { return 0; } -void psDoFixPrevious() {} - int psFixPrevious() { - psDoFixPrevious(); return 0; } namespace Platform { -void start() {} - void finish() { - Notifications::Finish(); - delete _psEventFilter; _psEventFilter = nullptr; } @@ -417,17 +407,6 @@ QString SystemLanguage() { return QString(); } -namespace ThirdParty { - -void start() { - Libs::start(); - MainWindow::LibsLoaded(); -} - -void finish() {} - -} // namespace ThirdParty - } // namespace Platform namespace { @@ -485,7 +464,6 @@ void psRegisterCustomScheme() { s << "Exec=" << EscapeShell(QFile::encodeName(cExeDir() + cExeName())) << " -- %u\n"; s << "Icon=telegram\n"; s << "Terminal=false\n"; - s << "StartupWMClass=Kepka\n"; s << "StartupWMClass=" << str_const_toString(AppName) << '\n'; s << "Type=Application\n"; s << "Categories=Network;InstantMessaging;Qt;\n"; @@ -516,12 +494,8 @@ void psRegisterCustomScheme() { } DEBUG_LOG(("App Info: placing .protocol file")); - QString services; - if (QDir(home + qsl(".kde4/")).exists()) { - services = home + qsl(".kde4/share/kde4/services/"); - } else if (QDir(home + qsl(".kde/")).exists()) { - services = home + qsl(".kde/share/kde4/services/"); - } + QString services = home + qsl(".local/share/kservices5/"); + if (!services.isEmpty()) { if (!QDir(services).exists()) QDir().mkpath(services); @@ -649,12 +623,6 @@ bool psShowOpenWithMenu(int x, int y, const QString &file) { return false; } -void psAutoStart(bool start, bool silent) {} - -void psSendToMenu(bool send, bool silent) {} - -void psUpdateOverlayed(QWidget *widget) {} - bool linuxMoveFile(const char *from, const char *to) { FILE *ffrom = fopen(from, "rb"), *fto = fopen(to, "wb"); if (!ffrom) { diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index 86f494734..e0d26e849 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -38,6 +38,8 @@ class LocationCoords; namespace Platform { +inline void start() {} + inline void SetWatchingMediaKeys(bool watching) {} inline void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {} @@ -50,6 +52,13 @@ inline void ReInitOnTopPanel(QWidget *panel) {} QString CurrentExecutablePath(int argc, char *argv[]); +namespace ThirdParty { + +inline void start() {} + +inline void finish() {} + +} // namespace ThirdParty } // namespace Platform inline QString psServerPrefix() { @@ -62,7 +71,7 @@ inline void psCheckLocalSocket(const QString &serverName) { } } -void psWriteDump(); +inline void psWriteDump() {} QString psPrepareCrashDump(const QByteArray &crashdump, QString dumpfile); void psDeleteDir(const QString &dir); @@ -78,8 +87,8 @@ void psActivateProcess(quint64 pid = 0); QString psLocalServerPrefix(); QString psAppDataPath(); QString psDownloadPath(); -void psAutoStart(bool start, bool silent = false); -void psSendToMenu(bool send, bool silent = false); +inline void psAutoStart(bool start, bool silent = false) {} +inline void psSendToMenu(bool send, bool silent = false) {} QRect psDesktopRect(); void psShowOverAll(QWidget *w, bool canFocus = true); @@ -95,7 +104,7 @@ QAbstractNativeEventFilter *psNativeEventFilter(); void psNewVersion(); -void psUpdateOverlayed(QWidget *widget); +inline void psUpdateOverlayed(QWidget *widget) {} inline QByteArray psDownloadPathBookmark(const QString &path) { return QByteArray(); } diff --git a/Telegram/SourceFiles/qt_functions.cpp b/Telegram/SourceFiles/qt_functions.cpp index 481ecfc84..6e6e7f474 100644 --- a/Telegram/SourceFiles/qt_functions.cpp +++ b/Telegram/SourceFiles/qt_functions.cpp @@ -35,28 +35,6 @@ /* TODO: find a dynamic library with these symbols. */ -/* Debian maintainer: this function is taken from qfiledialog.cpp */ -/* - Makes a list of filters from ;;-separated text. - Used by the mac and windows implementations -*/ -QStringList qt_make_filter_list(const QString &filter) { - QString f(filter); - - if (f.isEmpty()) return QStringList(); - - QString sep(QLatin1String(";;")); - int i = f.indexOf(sep, 0); - if (i == -1) { - if (f.indexOf(QLatin1Char('\n'), 0) != -1) { - sep = QLatin1Char('\n'); - i = f.indexOf(sep, 0); - } - } - - return f.split(sep); -} - /* Debian maintainer: this constructor is taken from qtextengine.cpp for TextPainter::drawLine */ QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) diff --git a/Telegram/SourceFiles/qt_static_plugins.cpp b/Telegram/SourceFiles/qt_static_plugins.cpp index 59b2a62cd..62f894054 100644 --- a/Telegram/SourceFiles/qt_static_plugins.cpp +++ b/Telegram/SourceFiles/qt_static_plugins.cpp @@ -25,9 +25,4 @@ #ifdef Q_OS_WIN Q_IMPORT_PLUGIN(QWebpPlugin) Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) -#elif defined Q_OS_MAC // Q_OS_WIN -// Q_IMPORT_PLUGIN(QWebpPlugin) -// Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) -// Q_IMPORT_PLUGIN(QGenericEnginePlugin) -#elif defined Q_OS_LINUX // Q_OS_WIN | Q_OS_MAC -#endif // Q_OS_WIN | Q_OS_MAC | Q_OS_LINUX +#endif // Q_OS_WIN