diff options
author | Markus Goetz <markus@woboq.com> | 2019-09-25 11:16:06 +0300 |
---|---|---|
committer | Markus Goetz <markus@woboq.com> | 2019-10-07 21:50:45 +0300 |
commit | cb4973b7f7ffcb678b9c88528d6ee44da1e87458 (patch) | |
tree | 761bb60315ce6ef5d221d4bbc9877b4a16215bcf | |
parent | c866ac138f5c99cbbb181c397f3a9c3c4e5fdd7c (diff) |
No more MacSettingsDialog #7371
-rw-r--r-- | .gitmodules | 3 | ||||
m--------- | src/3rdparty/qtmacgoodies | 0 | ||||
-rw-r--r-- | src/gui/CMakeLists.txt | 19 | ||||
-rw-r--r-- | src/gui/accountsettings.cpp | 14 | ||||
-rw-r--r-- | src/gui/owncloudgui.cpp | 17 | ||||
-rw-r--r-- | src/gui/owncloudgui.h | 5 | ||||
-rw-r--r-- | src/gui/settingsdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/settingsdialogmac.cpp | 235 | ||||
-rw-r--r-- | src/gui/settingsdialogmac.h | 71 |
9 files changed, 0 insertions, 368 deletions
diff --git a/.gitmodules b/.gitmodules index a25a64fc4..0eef34ac0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "src/3rdparty/qtmacgoodies"] - path = src/3rdparty/qtmacgoodies - url = https://github.com/guruz/qtmacgoodies.git [submodule "src/3rdparty/libcrashreporter-qt"] path = src/3rdparty/libcrashreporter-qt url = git://github.com/dschmidt/libcrashreporter-qt.git diff --git a/src/3rdparty/qtmacgoodies b/src/3rdparty/qtmacgoodies deleted file mode 160000 -Subproject 0dc7bc33282bdf3ea262cbd1e6c380a8ab9d6dc diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 3a38ed209..cd4e82d8f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -121,8 +121,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) @@ -158,14 +156,6 @@ set(3rdparty_SRC ../3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp ) -if (APPLE) - list(APPEND 3rdparty_SRC - ../3rdparty/qtmacgoodies/src/macpreferenceswindow.mm - ../3rdparty/qtmacgoodies/src/macstandardicon.mm - ../3rdparty/qtmacgoodies/src/macwindow.mm - ) -endif() - if(NOT WIN32) list(APPEND 3rdparty_SRC ../3rdparty/qtlockedfile/qtlockedfile_unix.cpp) else() @@ -284,15 +274,6 @@ target_include_directories(${APPLICATION_EXECUTABLE} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) -if (APPLE) - target_include_directories(${APPLICATION_EXECUTABLE} PRIVATE - ${CMAKE_SOURCE_DIR}/src/3rdparty/qtmacgoodies/src - ) - # We want to access Cocoa specific structures in the code above - # and need the platform plugin interface for that - which is private. - target_link_libraries(${APPLICATION_EXECUTABLE} Qt5::GuiPrivate) # not actually a library. Will pull in includes -endif() - ## handle DBUS for Fdo notifications if( UNIX AND NOT APPLE ) find_package(Qt5 COMPONENTS DBus) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 5423272de..da41649fb 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -54,10 +54,6 @@ #include "account.h" -#ifdef Q_OS_MAC -#include "settingsdialogmac.h" -#endif - namespace OCC { Q_LOGGING_CATEGORY(lcAccountSettings, "gui.account.settings", QtInfoMsg) @@ -228,16 +224,6 @@ 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)), 0); } diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 4c903ee6e..05f0cb879 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" @@ -56,11 +51,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) , _recentActionsMenu(nullptr) , _app(parent) @@ -1014,11 +1005,7 @@ void ownCloudGui::slotShowSettings() { if (_settingsDialog.isNull()) { _settingsDialog = -#if defined(Q_OS_MAC) - new SettingsDialogMac(this); -#else new SettingsDialog(this); -#endif _settingsDialog->setAttribute(Qt::WA_DeleteOnClose, true); _settingsDialog->show(); } @@ -1079,10 +1066,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 b76e4e06a..8cbb0d892 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -31,7 +31,6 @@ namespace OCC { class Folder; class SettingsDialog; -class SettingsDialogMac; class ShareDialog; class Application; class LogBrowser; @@ -118,11 +117,7 @@ private: void addAccountContextMenu(AccountStatePtr accountState, QMenu *menu, bool separateMenu); 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; diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index df30ba0d5..b96e28814 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -57,10 +57,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 bd6ce374e..000000000 --- a/src/gui/settingsdialogmac.cpp +++ /dev/null @@ -1,235 +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 "protocolwidget.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")); // on macOS Ctrl is Cmd - 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")); // on macOS Ctrl is Cmd - connect(hideWindowAction, &QAction::triggered, this, &SettingsDialogMac::hide); - addAction(hideWindowAction); - - setObjectName("SettingsMac"); // required as group for saveGeometry call - - setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI())); - - QIcon activityIcon(QLatin1String(":/client/resources/activity.png")); - _activitySettings = new ActivitySettings; - addPreferencesPanel(activityIcon, tr("Activity"), _activitySettings); - connect(_activitySettings, SIGNAL(guiLog(QString, QString)), _gui, - SLOT(slotShowOptionalTrayMessage(QString, QString))); - - connect(AccountManager::instance(), &AccountManager::accountAdded, - this, &SettingsDialogMac::accountAdded); - connect(AccountManager::instance(), &AccountManager::accountRemoved, - this, &SettingsDialogMac::accountRemoved); - foreach (auto ai, AccountManager::instance()->accounts()) { - accountAdded(ai.data()); - } - - QIcon generalIcon = MacStandardIcon::icon(MacStandardIcon::PreferencesGeneral); - GeneralSettings *generalSettings = new GeneralSettings; - addPreferencesPanel(generalIcon, tr("General"), generalSettings); - QObject::connect(generalSettings, &GeneralSettings::showAbout, gui, &ownCloudGui::slotAbout); - - 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); - - QAction *showLogWindow2 = new QAction(this); - showLogWindow2->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); // on macOS Ctrl is Cmd - connect(showLogWindow2, &QAction::triggered, gui, &ownCloudGui::slotToggleLogBrowser); - addAction(showLogWindow2); - - ConfigFile cfg; - cfg.restoreGeometry(this); - _activitySettings->setNotificationRefreshInterval(cfg.notificationRefreshInterval()); -} - -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::showIssuesList(const QString &folderAlias) -{ - // Count backwards (0-based) from the last panel (multiple accounts can be on the left) - setCurrentPanelIndex(preferencePanelCount() - 1 - 2); - _activitySettings->slotShowIssuesTab(folderAlias); -} - - -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"); - - insertPreferencesPanel(0, accountIcon, displayName, accountSettings); - - connect(accountSettings, &AccountSettings::folderChanged, _gui, &ownCloudGui::slotFoldersChanged); - connect(accountSettings, &AccountSettings::openFolderAlias, _gui, &ownCloudGui::slotFolderOpenAction); - connect(accountSettings, &AccountSettings::showIssuesList, this, &SettingsDialogMac::showIssuesList); - - 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); - - slotRefreshActivity(s); - setCurrentPanelIndex(0); -} - -void SettingsDialogMac::accountRemoved(AccountState *s) -{ - auto list = findChildren<AccountSettings *>(QString()); - foreach (auto p, list) { - if (p->accountsState() == s) { - removePreferencesPanel(p); - } - } - - _activitySettings->slotRemoveAccount(s); -} - -void SettingsDialogMac::slotRefreshActivityAccountStateSender() -{ - slotRefreshActivity(qobject_cast<AccountState*>(sender())); -} - -void SettingsDialogMac::slotRefreshActivity(AccountState *accountState) -{ - if (accountState) { - _activitySettings->slotRefresh(accountState); - } -} - -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 index f3f82cd35..000000000 --- a/src/gui/settingsdialogmac.h +++ /dev/null @@ -1,71 +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 ProtocolWidget; -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 showIssuesList(const QString &folderAlias); - void slotRefreshActivity(AccountState *accountState); - void slotRefreshActivityAccountStateSender(); - -private slots: - void accountAdded(AccountState *); - void accountRemoved(AccountState *); - void slotAccountAvatarChanged(); - void slotAccountDisplayNameChanged(); - -private: - void closeEvent(QCloseEvent *event); - - ProtocolWidget *_protocolWidget; - ActivitySettings *_activitySettings; - ownCloudGui *_gui; - - int _protocolIdx; -}; -} - -#endif // SETTINGSDIALOGMAC_H |