From: Michael Schuster Date: Sun, 1 Dec 2019 01:45:19 +0000 (+0100) Subject: Remove submodule qtmacgoodies and the MacSettingsDialog class X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~499 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b4f926ded72798d4861747bf2b2a1634c3810f75;p=nextcloud-desktop.git Remove submodule qtmacgoodies and the MacSettingsDialog class Reverts back to the SettingsDialog class because of bugs and glitches with more recent Qt versions (Qt 5.12) and with the macOS Dark Mode. See upstream: https://github.com/owncloud/client/pull/7492 Signed-off-by: Michael Schuster --- diff --git a/.gitmodules b/.gitmodules index ea2e77390..3f303cf1c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "src/3rdparty/qtmacgoodies"] - path = src/3rdparty/qtmacgoodies - url = https://github.com/camilasan/qtmacgoodies.git [submodule "binary"] path = binary url = git://github.com/owncloud/owncloud-client-binary.git diff --git a/src/3rdparty/qtmacgoodies b/src/3rdparty/qtmacgoodies deleted file mode 160000 index b59d091b3..000000000 --- a/src/3rdparty/qtmacgoodies +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b59d091b3e6b98e7219cf636f7d21fb267242c27 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 9f0f4d12b..462173554 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -145,8 +145,6 @@ set(updater_SRCS IF( APPLE ) list(APPEND client_SRCS cocoainitializer_mac.mm) - list(APPEND client_SRCS settingsdialogmac.cpp) - list(REMOVE_ITEM client_SRCS settingsdialog.cpp) list(APPEND client_SRCS socketapisocket_mac.mm) list(APPEND client_SRCS systray.mm) @@ -176,17 +174,6 @@ set(3rdparty_SRC ../3rdparty/kmessagewidget/kmessagewidget.cpp ) -if (APPLE) - list(APPEND 3rdparty_SRC - ../3rdparty/qtmacgoodies/src/macpreferenceswindow.mm - ../3rdparty/qtmacgoodies/src/macstandardicon.mm - ../3rdparty/qtmacgoodies/src/macwindow.mm - ) - # We want to access Cocoa specific structures in the code above - # and need the platform plugin interface for that - which is private. - include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) -endif() - if(NOT WIN32) list(APPEND 3rdparty_SRC ../3rdparty/qtlockedfile/qtlockedfile_unix.cpp) else() @@ -342,7 +329,6 @@ ENDIF() target_include_directories(${APPLICATION_EXECUTABLE} PRIVATE ${CMAKE_SOURCE_DIR}/src/3rdparty/QProgressIndicator ${CMAKE_SOURCE_DIR}/src/3rdparty/qtlockedfile - ${CMAKE_SOURCE_DIR}/src/3rdparty/qtmacgoodies/src ${CMAKE_SOURCE_DIR}/src/3rdparty/qtsingleapplication ${CMAKE_SOURCE_DIR}/src/3rdparty/kmessagewidget ${CMAKE_CURRENT_BINARY_DIR} diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index c62f29f86..50ee4e8a6 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -57,10 +57,6 @@ #include "account.h" -#ifdef Q_OS_MAC -#include "settingsdialogmac.h" -#endif - namespace OCC { Q_LOGGING_CATEGORY(lcAccountSettings, "nextcloud.gui.account.settings", QtInfoMsg) @@ -280,16 +276,7 @@ void AccountSettings::slotOpenAccountWizard() if (qgetenv("QT_QPA_PLATFORMTHEME") == "appmenu-qt5" || QSystemTrayIcon::isSystemTrayAvailable()) { topLevelWidget()->close(); } -#ifdef Q_OS_MAC - qCDebug(lcAccountSettings) << parent() << topLevelWidget(); - SettingsDialogMac *sd = qobject_cast(topLevelWidget()); - if (sd) { - sd->showActivityPage(); - } else { - qFatal("nope"); - } -#endif OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)), nullptr); } diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 6ece39b92..ee30acf50 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -20,12 +20,7 @@ #include "progressdispatcher.h" #include "owncloudsetupwizard.h" #include "sharedialog.h" -#if defined(Q_OS_MAC) -#include "settingsdialogmac.h" -#include "macwindow.h" // qtmacgoodies -#else #include "settingsdialog.h" -#endif #include "logger.h" #include "logbrowser.h" #include "account.h" @@ -62,11 +57,7 @@ const char propertyAccountC[] = "oc_account"; ownCloudGui::ownCloudGui(Application *parent) : QObject(parent) , _tray(nullptr) -#if defined(Q_OS_MAC) - , _settingsDialog(new SettingsDialogMac(this)) -#else , _settingsDialog(new SettingsDialog(this)) -#endif , _logBrowser(nullptr) #ifdef WITH_LIBCLOUDPROVIDERS , _bus(QDBusConnection::sessionBus()) @@ -1077,12 +1068,7 @@ void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &messag void ownCloudGui::slotShowSettings() { if (_settingsDialog.isNull()) { - _settingsDialog = -#if defined(Q_OS_MAC) - new SettingsDialogMac(this); -#else - new SettingsDialog(this); -#endif + _settingsDialog = new SettingsDialog(this); _settingsDialog->setAttribute(Qt::WA_DeleteOnClose, true); _settingsDialog->show(); } @@ -1143,10 +1129,6 @@ void ownCloudGui::raiseDialog(QWidget *raiseWidget) raiseWidget->raise(); raiseWidget->activateWindow(); -#if defined(Q_OS_MAC) - // viel hilft viel ;-) - MacWindow::bringToFront(raiseWidget); -#endif #if defined(Q_OS_X11) WId wid = widget->winId(); NETWM::init(); diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index 95d078bc6..3df9582d8 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -34,7 +34,6 @@ namespace OCC { class Folder; class SettingsDialog; -class SettingsDialogMac; class ShareDialog; class Application; class LogBrowser; @@ -131,11 +130,7 @@ private: void buildNavigationAppsMenu(AccountStatePtr account, QMenu *accountMenu); QPointer _tray; -#if defined(Q_OS_MAC) - QPointer _settingsDialog; -#else QPointer _settingsDialog; -#endif QPointer _logBrowser; // tray's menu QScopedPointer _contextMenu; diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index e91b96853..c96168ca7 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -56,10 +56,6 @@ namespace OCC { #include "settingsdialogcommon.cpp" -// -// Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp ! -// - SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) : QDialog(parent) , _ui(new Ui::SettingsDialog) diff --git a/src/gui/settingsdialogmac.cpp b/src/gui/settingsdialogmac.cpp deleted file mode 100644 index 938dd6b45..000000000 --- a/src/gui/settingsdialogmac.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) by Denis Dzyubenko - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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. - */ - -#include "settingsdialogmac.h" - -#include "macstandardicon.h" - -#include "folderman.h" -#include "theme.h" -#include "generalsettings.h" -#include "networksettings.h" -#include "accountsettings.h" -#include "accountstate.h" -#include "creds/abstractcredentials.h" -#include "configfile.h" -#include "progressdispatcher.h" -#include "owncloudgui.h" -#include "activitywidget.h" -#include "accountmanager.h" - -#include -#include -#include -#include -#include -#include - -namespace OCC { - -#include "settingsdialogcommon.cpp" - - -// Duplicate in settingsdialog.cpp -static QIcon circleMask(const QImage &avatar) -{ - int dim = avatar.width(); - - QPixmap fixedImage(dim, dim); - fixedImage.fill(Qt::transparent); - - QPainter imgPainter(&fixedImage); - QPainterPath clip; - clip.addEllipse(0, 0, dim, dim); - imgPainter.setClipPath(clip); - imgPainter.drawImage(0, 0, avatar); - imgPainter.end(); - - return QIcon(fixedImage); -} - - -// -// Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp ! -// -SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent) - : MacPreferencesWindow(parent) - , _gui(gui) -{ - // do not show minimize button. There is no use, and restoring the - // dialog from minimize is broken in MacPreferencesWindow - setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint); - - // Emulate dialog behavior: Escape means close - QAction *closeDialogAction = new QAction(this); - closeDialogAction->setShortcut(QKeySequence(Qt::Key_Escape)); - connect(closeDialogAction, &QAction::triggered, this, &SettingsDialogMac::close); - addAction(closeDialogAction); - // People perceive this as a Window, so also make Ctrl+W work - QAction *closeWindowAction = new QAction(this); - closeWindowAction->setShortcut(QKeySequence("Ctrl+W")); - connect(closeWindowAction, &QAction::triggered, this, &SettingsDialogMac::close); - addAction(closeWindowAction); - // People perceive this as a Window, so also make Ctrl+H work - QAction *hideWindowAction = new QAction(this); - hideWindowAction->setShortcut(QKeySequence("Ctrl+H")); - connect(hideWindowAction, &QAction::triggered, this, &SettingsDialogMac::hide); - addAction(hideWindowAction); - - setObjectName("SettingsMac"); // required as group for saveGeometry call - - setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI())); - - connect(AccountManager::instance(), &AccountManager::accountAdded, - this, &SettingsDialogMac::accountAdded); - connect(AccountManager::instance(), &AccountManager::accountRemoved, - this, &SettingsDialogMac::accountRemoved); - - _actionsIdx = -1; - foreach (auto ai, AccountManager::instance()->accounts()) { - accountAdded(ai.data()); - } - - QIcon generalIcon = MacStandardIcon::icon(MacStandardIcon::PreferencesGeneral); - GeneralSettings *generalSettings = new GeneralSettings; - addPreferencesPanel(generalIcon, tr("General"), generalSettings); - - QIcon networkIcon = MacStandardIcon::icon(MacStandardIcon::Network); - NetworkSettings *networkSettings = new NetworkSettings; - addPreferencesPanel(networkIcon, tr("Network"), networkSettings); - - QAction *showLogWindow = new QAction(this); - showLogWindow->setShortcut(QKeySequence("F12")); - connect(showLogWindow, &QAction::triggered, gui, &ownCloudGui::slotToggleLogBrowser); - addAction(showLogWindow); - - ConfigFile cfg; - cfg.restoreGeometry(this); -} - -void SettingsDialogMac::closeEvent(QCloseEvent *event) -{ - ConfigFile cfg; - cfg.saveGeometry(this); - MacPreferencesWindow::closeEvent(event); -} - -void SettingsDialogMac::showActivityPage() -{ - // Count backwards (0-based) from the last panel (multiple accounts can be on the left) - setCurrentPanelIndex(preferencePanelCount() - 1 - 2); -} - -void SettingsDialogMac::accountAdded(AccountState *s) -{ - QIcon accountIcon = MacStandardIcon::icon(MacStandardIcon::UserAccounts); - auto accountSettings = new AccountSettings(s, this); - QString displayName = Theme::instance()->multiAccount() ? SettingsDialogCommon::shortDisplayNameForSettings(s->account().data(), 0) : tr("Account"); - - // this adds the panel - nothing to add here just to fix the order - insertPreferencesPanel(++_actionsIdx, accountIcon, displayName, accountSettings); - - connect(accountSettings, &AccountSettings::folderChanged, _gui, &ownCloudGui::slotFoldersChanged); - connect(accountSettings, &AccountSettings::openFolderAlias, _gui, &ownCloudGui::slotFolderOpenAction); - - connect(s->account().data(), &Account::accountChangedAvatar, this, &SettingsDialogMac::slotAccountAvatarChanged); - connect(s->account().data(), &Account::accountChangedDisplayName, this, &SettingsDialogMac::slotAccountDisplayNameChanged); - - // Refresh immediatly when getting online - connect(s, &AccountState::isConnectedChanged, this, &SettingsDialogMac::slotRefreshActivityAccountStateSender); - - // Add activity panel - QIcon activityIcon(QLatin1String(":/client/resources/activity.png")); - _activitySettings[s] = new ActivitySettings(s, this); - insertPreferencesPanel(++_actionsIdx, activityIcon, tr("Activity"), _activitySettings[s]); - connect(_activitySettings[s], SIGNAL(guiLog(QString, QString)), _gui, - SLOT(slotShowOptionalTrayMessage(QString, QString))); - - // if this is not the first account, add separator 2 positions before int the toolbar - if(AccountManager::instance()->accounts().first().data() != s && - AccountManager::instance()->accounts().size() >= 1){ - _separators[s] = insertSeparator(_actionsIdx - 1); - ++_actionsIdx; //we have one more item in the toolbar - } - - ConfigFile cfg; - _activitySettings[s]->setNotificationRefreshInterval(cfg.notificationRefreshInterval()); - - slotRefreshActivity(s); - setCurrentPanelIndex(0); -} - -void SettingsDialogMac::accountRemoved(AccountState *s) -{ - auto list = findChildren(QString()); - foreach (auto p, list) { - if (p->accountsState() == s) { - removePreferencesPanel(p); - - // remove settings panel - if(_activitySettings.contains(s)) - removePreferencesPanel(_activitySettings[s]); - - // remove separator if there is any - if(_separators.contains(s)){ - removeSeparator(_separators[s]); - _separators.remove(s); - } - } - } -} - -void SettingsDialogMac::slotRefreshActivityAccountStateSender() -{ - slotRefreshActivity(qobject_cast(sender())); -} - -void SettingsDialogMac::slotRefreshActivity(AccountState *accountState) -{ - if (accountState) { - _activitySettings[accountState]->slotRefresh(); - } -} - -void SettingsDialogMac::slotAccountAvatarChanged() -{ - Account *account = static_cast(sender()); - auto list = findChildren(QString()); - foreach (auto p, list) { - if (p->accountsState()->account() == account) { - int idx = indexForPanel(p); - QImage pix = account->avatar(); - if (!pix.isNull()) { - setPreferencesPanelIcon(idx, circleMask(pix)); - } - } - } -} - -void SettingsDialogMac::slotAccountDisplayNameChanged() -{ - Account *account = static_cast(sender()); - auto list = findChildren(QString()); - foreach (auto p, list) { - if (p->accountsState()->account() == account) { - int idx = indexForPanel(p); - QString displayName = account->displayName(); - if (!displayName.isNull()) { - displayName = Theme::instance()->multiAccount() - ? SettingsDialogCommon::shortDisplayNameForSettings(account, 0) - : tr("Account"); - setPreferencesPanelTitle(idx, displayName); - } - } - } -} - -} - diff --git a/src/gui/settingsdialogmac.h b/src/gui/settingsdialogmac.h deleted file mode 100644 index ef0995b53..000000000 --- a/src/gui/settingsdialogmac.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) by Denis Dzyubenko - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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. - */ - - -#ifndef SETTINGSDIALOGMAC_H -#define SETTINGSDIALOGMAC_H - -#include "progressdispatcher.h" -#include "macpreferenceswindow.h" -#include "owncloudgui.h" - -class QStandardItemModel; -class QListWidgetItem; - -namespace OCC { - -class AccountSettings; -class Application; -class FolderMan; -class ownCloudGui; -class Folder; -class AccountState; -class ActivitySettings; - -/** - * @brief The SettingsDialogMac class - * @ingroup gui - */ -class SettingsDialogMac : public MacPreferencesWindow -{ - Q_OBJECT - -public: - explicit SettingsDialogMac(ownCloudGui *gui, QWidget *parent = 0); - -public slots: - void showActivityPage(); - void slotRefreshActivity(AccountState *accountState); - void slotRefreshActivityAccountStateSender(); - -private slots: - void accountAdded(AccountState *); - void accountRemoved(AccountState *); - void slotAccountAvatarChanged(); - void slotAccountDisplayNameChanged(); - -private: - void closeEvent(QCloseEvent *event); - - QAction *_actionBefore; - int _actionsIdx; - QMap _separators; - - QMap _activitySettings; - ownCloudGui *_gui; - - int _protocolIdx; -}; -} - -#endif // SETTINGSDIALOGMAC_H -;