mirror of https://github.com/nextcloud/desktop
Added Mac-specific settings dialog that looks more native
This commit is contained in:
parent
e34122ad54
commit
a51cb0982b
|
@ -1,3 +1,6 @@
|
||||||
[submodule "doc/ocdoc"]
|
[submodule "doc/ocdoc"]
|
||||||
path = doc/ocdoc
|
path = doc/ocdoc
|
||||||
url = https://github.com/owncloud/documentation
|
url = https://github.com/owncloud/documentation
|
||||||
|
[submodule "src/3rdparty/qtmacgoodies"]
|
||||||
|
path = src/3rdparty/qtmacgoodies
|
||||||
|
url = git://github.com/shadone/qtmacgoodies.git
|
||||||
|
|
|
@ -16,6 +16,9 @@ if( NOT BUILD_WITH_QT4 )
|
||||||
find_package(Qt5Sensors QUIET)
|
find_package(Qt5Sensors QUIET)
|
||||||
find_package(Qt5Xml QUIET)
|
find_package(Qt5Xml QUIET)
|
||||||
# find_package(Qt5WebKitWidgets QUIET)
|
# find_package(Qt5WebKitWidgets QUIET)
|
||||||
|
if(APPLE)
|
||||||
|
find_package(Qt5MacExtras QUIET)
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "Using Qt 5!")
|
message(STATUS "Using Qt 5!")
|
||||||
|
|
||||||
|
@ -31,6 +34,11 @@ if( NOT BUILD_WITH_QT4 )
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
# set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
# set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
include_directories(${Qt5MacExtras_INCLUDE_DIRS})
|
||||||
|
add_definitions(${Qt5MacExtras_DEFINITIONS})
|
||||||
|
set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5MacExtras_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
macro(qt_wrap_ui)
|
macro(qt_wrap_ui)
|
||||||
qt5_wrap_ui(${ARGN})
|
qt5_wrap_ui(${ARGN})
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ab7ee2915f491bca192ad2879547935d7c784c34
|
|
@ -38,6 +38,13 @@ set(3rdparty_SRC
|
||||||
3rdparty/QProgressIndicator/QProgressIndicator.cpp
|
3rdparty/QProgressIndicator/QProgressIndicator.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND 3rdparty_SRC
|
||||||
|
3rdparty/qtmacgoodies/src/macpreferenceswindow.mm
|
||||||
|
3rdparty/qtmacgoodies/src/macstandardicon.mm
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(3rdparty_HEADER
|
set(3rdparty_HEADER
|
||||||
3rdparty/qtsingleapplication/qtlocalpeer.h
|
3rdparty/qtsingleapplication/qtlocalpeer.h
|
||||||
3rdparty/qtsingleapplication/qtsingleapplication.h
|
3rdparty/qtsingleapplication/qtsingleapplication.h
|
||||||
|
@ -46,6 +53,13 @@ set(3rdparty_HEADER
|
||||||
3rdparty/QProgressIndicator/QProgressIndicator.h
|
3rdparty/QProgressIndicator/QProgressIndicator.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND 3rdparty_HEADER
|
||||||
|
3rdparty/qtmacgoodies/src/macpreferenceswindow.h
|
||||||
|
3rdparty/qtmacgoodies/src/macstandardicon.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
qt_wrap_cpp(3rdparty_MOC ${3rdparty_HEADER})
|
qt_wrap_cpp(3rdparty_MOC ${3rdparty_HEADER})
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
|
@ -60,6 +74,7 @@ set(3rdparty_INC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QProgressIndicator
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QProgressIndicator
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/fancylineedit
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/fancylineedit
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qjson
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qjson
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qtmacgoodies/src
|
||||||
)
|
)
|
||||||
|
|
||||||
set(libsync_SRCS
|
set(libsync_SRCS
|
||||||
|
@ -314,6 +329,9 @@ IF( APPLE )
|
||||||
list(APPEND mirall_SRCS mirall/cocoainitializer_mac.mm)
|
list(APPEND mirall_SRCS mirall/cocoainitializer_mac.mm)
|
||||||
list(APPEND mirall_HEADERS mirall/cocoainitializer.h)
|
list(APPEND mirall_HEADERS mirall/cocoainitializer.h)
|
||||||
|
|
||||||
|
list(APPEND mirall_SRCS mirall/settingsdialogmac.cpp)
|
||||||
|
list(APPEND mirall_HEADERS mirall/settingsdialogmac.h)
|
||||||
|
|
||||||
if(SPARKLE_FOUND)
|
if(SPARKLE_FOUND)
|
||||||
# Define this, we need to check in updater.cpp
|
# Define this, we need to check in updater.cpp
|
||||||
add_definitions( -DHAVE_SPARKLE )
|
add_definitions( -DHAVE_SPARKLE )
|
||||||
|
|
|
@ -67,7 +67,11 @@ AccountSettings::AccountSettings(QWidget *parent) :
|
||||||
|
|
||||||
ui->_folderList->setItemDelegate( delegate );
|
ui->_folderList->setItemDelegate( delegate );
|
||||||
ui->_folderList->setModel( _model );
|
ui->_folderList->setModel( _model );
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
ui->_folderList->setMinimumWidth( 400 );
|
||||||
|
#else
|
||||||
ui->_folderList->setMinimumWidth( 300 );
|
ui->_folderList->setMinimumWidth( 300 );
|
||||||
|
#endif
|
||||||
ui->_folderList->setEditTriggers( QAbstractItemView::NoEditTriggers );
|
ui->_folderList->setEditTriggers( QAbstractItemView::NoEditTriggers );
|
||||||
|
|
||||||
ui->_buttonRemove->setEnabled(false);
|
ui->_buttonRemove->setEnabled(false);
|
||||||
|
@ -424,9 +428,18 @@ void AccountSettings::slotEnableCurrentFolder()
|
||||||
if( f && folderEnabled ) {
|
if( f && folderEnabled ) {
|
||||||
// check if a sync is still running and if so, ask if we should terminate.
|
// check if a sync is still running and if so, ask if we should terminate.
|
||||||
if( f->isBusy() ) { // its still running
|
if( f->isBusy() ) { // its still running
|
||||||
int reply = QMessageBox::question( 0, tr("Sync Running"),
|
#if defined(Q_OS_MAC)
|
||||||
tr("The syncing operation is running.<br/>Do you want to terminate it?"),
|
QWidget *parent = this;
|
||||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
|
Qt::WindowFlags flags = Qt::Sheet;
|
||||||
|
#else
|
||||||
|
QWidget *parent = 0;
|
||||||
|
Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint; // default flags
|
||||||
|
#endif
|
||||||
|
QMessageBox msgbox(QMessageBox::Question, tr("Sync Running"),
|
||||||
|
tr("The syncing operation is running.<br/>Do you want to terminate it?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, parent, flags);
|
||||||
|
msgbox.setDefaultButton(QMessageBox::Yes);
|
||||||
|
int reply = msgbox.exec();
|
||||||
if ( reply == QMessageBox::Yes )
|
if ( reply == QMessageBox::Yes )
|
||||||
terminate = true;
|
terminate = true;
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,11 @@
|
||||||
#include "mirall/utility.h"
|
#include "mirall/utility.h"
|
||||||
#include "mirall/progressdispatcher.h"
|
#include "mirall/progressdispatcher.h"
|
||||||
#include "mirall/owncloudsetupwizard.h"
|
#include "mirall/owncloudsetupwizard.h"
|
||||||
#include "mirall/settingsdialog.h"
|
#if defined(Q_OS_MAC)
|
||||||
|
# include "mirall/settingsdialogmac.h"
|
||||||
|
#else
|
||||||
|
# include "mirall/settingsdialog.h"
|
||||||
|
#endif
|
||||||
#include "mirall/logger.h"
|
#include "mirall/logger.h"
|
||||||
#include "mirall/logbrowser.h"
|
#include "mirall/logbrowser.h"
|
||||||
#include "mirall/account.h"
|
#include "mirall/account.h"
|
||||||
|
@ -473,7 +477,12 @@ void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &messag
|
||||||
void ownCloudGui::slotShowSettings()
|
void ownCloudGui::slotShowSettings()
|
||||||
{
|
{
|
||||||
if (_settingsDialog.isNull()) {
|
if (_settingsDialog.isNull()) {
|
||||||
_settingsDialog = new SettingsDialog(this);
|
_settingsDialog =
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
new SettingsDialogMac(this);
|
||||||
|
#else
|
||||||
|
new SettingsDialog(this);
|
||||||
|
#endif
|
||||||
_settingsDialog->setAttribute( Qt::WA_DeleteOnClose, true );
|
_settingsDialog->setAttribute( Qt::WA_DeleteOnClose, true );
|
||||||
_settingsDialog->show();
|
_settingsDialog->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
namespace Mirall {
|
namespace Mirall {
|
||||||
|
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
|
class SettingsDialogMac;
|
||||||
class Application;
|
class Application;
|
||||||
class LogBrowser;
|
class LogBrowser;
|
||||||
|
|
||||||
|
@ -77,7 +78,11 @@ private:
|
||||||
void setupActions();
|
void setupActions();
|
||||||
|
|
||||||
QPointer<Systray> _tray;
|
QPointer<Systray> _tray;
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
QPointer<SettingsDialogMac> _settingsDialog;
|
||||||
|
#else
|
||||||
QPointer<SettingsDialog> _settingsDialog;
|
QPointer<SettingsDialog> _settingsDialog;
|
||||||
|
#endif
|
||||||
QPointer<LogBrowser>_logBrowser;
|
QPointer<LogBrowser>_logBrowser;
|
||||||
// tray's menu
|
// tray's menu
|
||||||
QMenu *_contextMenu;
|
QMenu *_contextMenu;
|
||||||
|
|
|
@ -58,6 +58,9 @@ ProtocolWidget::ProtocolWidget(QWidget *parent) :
|
||||||
_ui->_treeWidget->setRootIsDecorated(false);
|
_ui->_treeWidget->setRootIsDecorated(false);
|
||||||
_ui->_treeWidget->setTextElideMode(Qt::ElideMiddle);
|
_ui->_treeWidget->setTextElideMode(Qt::ElideMiddle);
|
||||||
_ui->_treeWidget->header()->setObjectName("ActivityListHeader");
|
_ui->_treeWidget->header()->setObjectName("ActivityListHeader");
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
_ui->_treeWidget->setMinimumWidth(400);
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(this, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString)));
|
connect(this, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString)));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
#include "settingsdialogmac.h"
|
||||||
|
|
||||||
|
#include "macstandardicon.h"
|
||||||
|
|
||||||
|
#include "mirall/folderman.h"
|
||||||
|
#include "mirall/theme.h"
|
||||||
|
#include "mirall/generalsettings.h"
|
||||||
|
#include "mirall/networksettings.h"
|
||||||
|
#include "mirall/accountsettings.h"
|
||||||
|
#include "mirall/mirallconfigfile.h"
|
||||||
|
#include "mirall/progressdispatcher.h"
|
||||||
|
#include "mirall/owncloudgui.h"
|
||||||
|
#include "mirall/protocolwidget.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
namespace Mirall {
|
||||||
|
|
||||||
|
SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
|
||||||
|
: MacPreferencesWindow(parent)
|
||||||
|
{
|
||||||
|
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
|
setObjectName("SettingsMac"); // required as group for saveGeometry call
|
||||||
|
|
||||||
|
setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI()));
|
||||||
|
|
||||||
|
_accountSettings = new AccountSettings;
|
||||||
|
QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Undefined, true);
|
||||||
|
_accountIdx = addPreferencesPanel(icon, tr("Account"), _accountSettings);
|
||||||
|
|
||||||
|
QIcon protocolIcon(QLatin1String(":/mirall/resources/activity.png"));
|
||||||
|
_protocolWidget = new ProtocolWidget;
|
||||||
|
_protocolIdx = addPreferencesPanel(protocolIcon, tr("Activity"), _protocolWidget);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
connect( folderMan, SIGNAL(folderSyncStateChange(QString)),
|
||||||
|
this, SLOT(slotSyncStateChange(QString)));
|
||||||
|
|
||||||
|
QuotaInfo *quotaInfo = gui->quotaInfo();
|
||||||
|
connect( quotaInfo, SIGNAL(quotaUpdated(qint64,qint64)),
|
||||||
|
_accountSettings, SLOT(slotUpdateQuota(qint64,qint64)));
|
||||||
|
_accountSettings->slotUpdateQuota(quotaInfo->lastQuotaTotalBytes(), quotaInfo->lastQuotaUsedBytes());
|
||||||
|
connect( _accountSettings, SIGNAL(folderChanged()), gui, SLOT(slotFoldersChanged()));
|
||||||
|
connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
|
||||||
|
gui, SLOT(slotFolderOpenAction(QString)));
|
||||||
|
|
||||||
|
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
|
||||||
|
_accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
|
||||||
|
connect( ProgressDispatcher::instance(), SIGNAL(progressSyncProblem(QString,Progress::SyncProblem)),
|
||||||
|
_accountSettings, SLOT(slotProgressProblem(QString,Progress::SyncProblem)) );
|
||||||
|
|
||||||
|
QAction *showLogWindow = new QAction(this);
|
||||||
|
showLogWindow->setShortcut(QKeySequence("F12"));
|
||||||
|
connect(showLogWindow, SIGNAL(triggered()), gui, SLOT(slotToggleLogBrowser()));
|
||||||
|
addAction(showLogWindow);
|
||||||
|
|
||||||
|
MirallConfigFile cfg;
|
||||||
|
cfg.restoreGeometry(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialogMac::slotSyncStateChange(const QString& alias)
|
||||||
|
{
|
||||||
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
SyncResult state = folderMan->accountStatus(folderMan->map().values());
|
||||||
|
QIcon accountIcon = Theme::instance()->syncStateIcon(state.status());
|
||||||
|
setPreferencesPanelIcon(_accountIdx, accountIcon);
|
||||||
|
|
||||||
|
Folder *folder = folderMan->folder(alias);
|
||||||
|
if( folder ) {
|
||||||
|
_accountSettings->slotUpdateFolderState(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialogMac::setGeneralErrors(const QStringList &errors)
|
||||||
|
{
|
||||||
|
if( _accountSettings ) {
|
||||||
|
_accountSettings->setGeneralErrors(errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialogMac::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
MirallConfigFile cfg;
|
||||||
|
cfg.saveGeometry(this);
|
||||||
|
MacPreferencesWindow::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialogMac::slotRefreshResultList()
|
||||||
|
{
|
||||||
|
if( _protocolWidget ) {
|
||||||
|
_protocolWidget->initializeList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialogMac::showActivityPage()
|
||||||
|
{
|
||||||
|
setCurrentPanelIndex(_protocolIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef SETTINGSDIALOGMAC_H
|
||||||
|
#define SETTINGSDIALOGMAC_H
|
||||||
|
|
||||||
|
#include "mirall/progressdispatcher.h"
|
||||||
|
#include "macpreferenceswindow.h"
|
||||||
|
|
||||||
|
class QStandardItemModel;
|
||||||
|
class QListWidgetItem;
|
||||||
|
|
||||||
|
namespace Mirall {
|
||||||
|
|
||||||
|
class AccountSettings;
|
||||||
|
class ProtocolWidget;
|
||||||
|
class Application;
|
||||||
|
class FolderMan;
|
||||||
|
class ownCloudGui;
|
||||||
|
|
||||||
|
class SettingsDialogMac : public MacPreferencesWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SettingsDialogMac(ownCloudGui *gui, QWidget *parent = 0);
|
||||||
|
|
||||||
|
void setGeneralErrors( const QStringList& errors );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotSyncStateChange(const QString& alias);
|
||||||
|
void slotRefreshResultList();
|
||||||
|
void showActivityPage();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
AccountSettings *_accountSettings;
|
||||||
|
QListWidgetItem *_accountItem;
|
||||||
|
ProtocolWidget *_protocolWidget;
|
||||||
|
|
||||||
|
int _accountIdx;
|
||||||
|
int _protocolIdx;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SETTINGSDIALOGMAC_H
|
|
@ -166,11 +166,13 @@ void Utility::raiseDialog( QWidget *raiseWidget )
|
||||||
if( raiseWidget ) {
|
if( raiseWidget ) {
|
||||||
#if defined(Q_OS_WIN) || defined (Q_OS_MAC)
|
#if defined(Q_OS_WIN) || defined (Q_OS_MAC)
|
||||||
Qt::WindowFlags eFlags = raiseWidget->windowFlags();
|
Qt::WindowFlags eFlags = raiseWidget->windowFlags();
|
||||||
eFlags |= Qt::WindowStaysOnTopHint;
|
if (!(eFlags & Qt::WindowStaysOnTopHint)) {
|
||||||
raiseWidget->setWindowFlags(eFlags);
|
eFlags |= Qt::WindowStaysOnTopHint;
|
||||||
raiseWidget->show();
|
raiseWidget->setWindowFlags(eFlags);
|
||||||
eFlags &= ~Qt::WindowStaysOnTopHint;
|
raiseWidget->show();
|
||||||
raiseWidget->setWindowFlags(eFlags);
|
eFlags &= ~Qt::WindowStaysOnTopHint;
|
||||||
|
raiseWidget->setWindowFlags(eFlags);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
raiseWidget->show();
|
raiseWidget->show();
|
||||||
raiseWidget->raise();
|
raiseWidget->raise();
|
||||||
|
|
Loading…
Reference in New Issue