Remove submodule qtmacgoodies and the MacSettingsDialog class
authorMichael Schuster <michael@schuster.ms>
Sun, 1 Dec 2019 01:45:19 +0000 (02:45 +0100)
committerMichael Schuster <48932272+misch7@users.noreply.github.com>
Mon, 9 Dec 2019 20:37:21 +0000 (21:37 +0100)
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 <michael@schuster.ms>
.gitmodules
src/3rdparty/qtmacgoodies [deleted submodule]
src/gui/CMakeLists.txt
src/gui/accountsettings.cpp
src/gui/owncloudgui.cpp
src/gui/owncloudgui.h
src/gui/settingsdialog.cpp
src/gui/settingsdialogmac.cpp [deleted file]
src/gui/settingsdialogmac.h [deleted file]

index ea2e773908b2e4a54ebd707d5c2c05b2d74ceead..3f303cf1c6d46ec6e26170a2747e44b2f5c0b447 100644 (file)
@@ -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 (submodule)
index b59d091..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit b59d091b3e6b98e7219cf636f7d21fb267242c27
index 9f0f4d12bc793d734dcf0bde2acd9a4bbcb0f791..462173554254355126b5736edd0e968fa9d6e158 100644 (file)
@@ -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}
index c62f29f8694fb353b07d023e74a1142673d7b5be..50ee4e8a6f626d4839e6304defb1aabc0b3db2d2 100644 (file)
 
 #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<SettingsDialogMac *>(topLevelWidget());
 
-    if (sd) {
-        sd->showActivityPage();
-    } else {
-        qFatal("nope");
-    }
-#endif
     OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)), nullptr);
 }
 
index 6ece39b92f00ebad511a9e7462ffe75903d0996b..ee30acf50942518c87ad438da42faa31075f8f71 100644 (file)
 #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();
index 95d078bc6919283031bfd9b40cfccf7ec11e94f1..3df9582d87a6df297790b7da2deca857494639d4 100644 (file)
@@ -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<Systray> _tray;
-#if defined(Q_OS_MAC)
-    QPointer<SettingsDialogMac> _settingsDialog;
-#else
     QPointer<SettingsDialog> _settingsDialog;
-#endif
     QPointer<LogBrowser> _logBrowser;
     // tray's menu
     QScopedPointer<QMenu> _contextMenu;
index e91b96853be9ad85caa2898c2e6db27f9c07ba5e..c96168ca7a14005c5b5ad58c8ccb0e0873e691b9 100644 (file)
@@ -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 (file)
index 938dd6b..0000000
+++ /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 <QLabel>
-#include <QStandardItemModel>
-#include <QPushButton>
-#include <QSettings>
-#include <QPainter>
-#include <QPainterPath>
-
-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<AccountSettings *>(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<AccountState*>(sender()));
-}
-
-void SettingsDialogMac::slotRefreshActivity(AccountState *accountState)
-{
-    if (accountState) {
-        _activitySettings[accountState]->slotRefresh();
-    }
-}
-
-void SettingsDialogMac::slotAccountAvatarChanged()
-{
-    Account *account = static_cast<Account *>(sender());
-    auto list = findChildren<AccountSettings *>(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<Account *>(sender());
-    auto list = findChildren<AccountSettings *>(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 (file)
index ef0995b..0000000
+++ /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<AccountState *, QAction *> _separators;
-
-    QMap<AccountState *, ActivitySettings *> _activitySettings;
-    ownCloudGui *_gui;
-
-    int _protocolIdx;
-};
-}
-
-#endif // SETTINGSDIALOGMAC_H
-;