Skip to content

Commit

Permalink
Merge 15c19df into ed60768
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Feb 27, 2019
2 parents ed60768 + 15c19df commit b577dd1
Show file tree
Hide file tree
Showing 111 changed files with 972 additions and 788 deletions.
31 changes: 16 additions & 15 deletions src/checkforupdatesdialog.cpp
Expand Up @@ -164,16 +164,19 @@ bool CheckForUpdatesEngine::hasNewerOfficialVersion() const

//==============================================================================

CheckForUpdatesDialog::CheckForUpdatesDialog(QSettings *pSettings,
const QString &pApplicationDate,
CheckForUpdatesDialog::CheckForUpdatesDialog(const QString &pApplicationDate,
CheckForUpdatesEngine *pEngine,
QWidget *pParent) :
Dialog(pSettings, pParent)
Dialog(pParent)
{
// We are not yet initialised

mInitialized = false;

// Customise our settings

mSettings.beginGroup(SettingsCheckForUpdatesDialog);

// Set up the GUI

mGui = new Ui::CheckForUpdatesDialog;
Expand Down Expand Up @@ -203,8 +206,8 @@ CheckForUpdatesDialog::CheckForUpdatesDialog(QSettings *pSettings,

// Retrieve and set some properties

mGui->checkForUpdatesAtStartupCheckBox->setChecked(mSettings->value(SettingsCheckForUpdatesAtStartup, true).toBool());
mGui->includeSnapshotsCheckBox->setChecked(mSettings->value(SettingsIncludeSnapshots, false).toBool());
mGui->checkForUpdatesAtStartupCheckBox->setChecked(mSettings.value(SettingsCheckForUpdatesAtStartup, true).toBool());
mGui->includeSnapshotsCheckBox->setChecked(mSettings.value(SettingsIncludeSnapshots, false).toBool());

// Update our GUI

Expand All @@ -215,18 +218,16 @@ CheckForUpdatesDialog::CheckForUpdatesDialog(QSettings *pSettings,

//==============================================================================

CheckForUpdatesDialog::CheckForUpdatesDialog(QSettings *pSettings,
const QString &pApplicationDate,
CheckForUpdatesDialog::CheckForUpdatesDialog(const QString &pApplicationDate,
QWidget *pParent) :
CheckForUpdatesDialog(pSettings, pApplicationDate, nullptr, pParent)
CheckForUpdatesDialog(pApplicationDate, nullptr, pParent)
{
}

//==============================================================================

CheckForUpdatesDialog::CheckForUpdatesDialog(QSettings *pSettings,
CheckForUpdatesEngine *pEngine) :
CheckForUpdatesDialog(pSettings, QString(), pEngine, nullptr)
CheckForUpdatesDialog::CheckForUpdatesDialog(CheckForUpdatesEngine *pEngine) :
CheckForUpdatesDialog(QString(), pEngine, nullptr)
{
}

Expand Down Expand Up @@ -338,8 +339,8 @@ void CheckForUpdatesDialog::checkForUpdatesAtStartupCheckBoxToggled(bool pChecke

// Keep track of our property

mSettings->setValue(SettingsCheckForUpdatesAtStartup,
mGui->checkForUpdatesAtStartupCheckBox->isChecked());
mSettings.setValue(SettingsCheckForUpdatesAtStartup,
mGui->checkForUpdatesAtStartupCheckBox->isChecked());
}

//==============================================================================
Expand All @@ -350,8 +351,8 @@ void CheckForUpdatesDialog::includeSnapshotsCheckBoxToggled(bool pChecked)

// Keep track of our property

mSettings->setValue(SettingsIncludeSnapshots,
mGui->includeSnapshotsCheckBox->isChecked());
mSettings.setValue(SettingsIncludeSnapshots,
mGui->includeSnapshotsCheckBox->isChecked());

updateGui();
}
Expand Down
9 changes: 3 additions & 6 deletions src/checkforupdatesdialog.h
Expand Up @@ -84,11 +84,9 @@ class CheckForUpdatesDialog : public Dialog
Q_OBJECT

public:
explicit CheckForUpdatesDialog(QSettings *pSettings,
const QString &pApplicationDate,
explicit CheckForUpdatesDialog(const QString &pApplicationDate,
QWidget *pParent);
explicit CheckForUpdatesDialog(QSettings *pSettings,
CheckForUpdatesEngine *pEngine);
explicit CheckForUpdatesDialog(CheckForUpdatesEngine *pEngine);
~CheckForUpdatesDialog() override;

private:
Expand All @@ -98,8 +96,7 @@ class CheckForUpdatesDialog : public Dialog

bool mInitialized;

explicit CheckForUpdatesDialog(QSettings *pSettings,
const QString &pApplicationDate,
explicit CheckForUpdatesDialog(const QString &pApplicationDate,
CheckForUpdatesEngine *pEngine,
QWidget *pParent);

Expand Down
4 changes: 2 additions & 2 deletions src/generalpreferenceswidget.cpp
Expand Up @@ -53,7 +53,7 @@ GeneralPreferencesWidget::GeneralPreferencesWidget(QWidget *pParent) :

mGui->styleValue->addItems(styles);

mStyle = mSettings->value(SettingsPreferencesStyle, SettingsPreferencesStyleDefault).toString();
mStyle = mSettings.value(SettingsPreferencesStyle, SettingsPreferencesStyleDefault).toString();

mGui->styleValue->setCurrentText(mStyle);

Expand Down Expand Up @@ -95,7 +95,7 @@ void GeneralPreferencesWidget::savePreferences()

QString style = mGui->styleValue->currentText();

mSettings->setValue(SettingsPreferencesStyle, style);
mSettings.setValue(SettingsPreferencesStyle, style);

// Update our style

Expand Down
8 changes: 2 additions & 6 deletions src/main.cpp
Expand Up @@ -21,28 +21,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Main
//==============================================================================

#include "checkforupdatesdialog.h"
#include "cliapplication.h"
#include "cliutils.h"
#include "guiapplication.h"
#include "guiutils.h"
#include "mainwindow.h"

#ifdef Q_OS_MAC
#include "macos.h"
#endif

#ifndef QT_DEBUG
#include "checkforupdatesdialog.h"
#include "splashscreenwindow.h"
#endif

//==============================================================================

#include <QDir>
#include <QLocale>
#include <QProcess>
#include <QSettings>
#include <QVariant>

#if defined(Q_OS_WIN) && defined(USE_PREBUILT_QTWEBKIT_PACKAGE)
#include <QWebSettings>
Expand Down Expand Up @@ -231,7 +227,7 @@ int main(int pArgC, char *pArgV[])
// Note: checkForUpdatesEngine gets deleted by
// checkForUpdatesDialog...

OpenCOR::CheckForUpdatesDialog checkForUpdatesDialog(&settings, checkForUpdatesEngine);
OpenCOR::CheckForUpdatesDialog checkForUpdatesDialog(checkForUpdatesEngine);

checkForUpdatesDialog.exec();
} else {
Expand Down
81 changes: 38 additions & 43 deletions src/mainwindow.cpp
Expand Up @@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "checkforupdatesdialog.h"
#include "cliutils.h"
#include "guiapplication.h"
#include "guiinterface.h"
#include "guiutils.h"
#include "i18ninterface.h"
#include "mainwindow.h"
Expand Down Expand Up @@ -53,7 +54,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QLocale>
#include <QRect>
#include <QScreen>
#include <QSettings>
#include <QShortcut>
#include <QTimer>
#include <QUrl>
Expand Down Expand Up @@ -125,10 +125,6 @@ MainWindow::MainWindow(const QString &pApplicationDate) :

registerOpencorUrlScheme();

// Create our settings object

mSettings = new QSettings();

// Create our plugin manager (which will automatically load our various
// plugins)

Expand Down Expand Up @@ -350,7 +346,6 @@ MainWindow::~MainWindow()
// Delete some internal objects

delete mPluginManager;
delete mSettings;

// Delete the GUI

Expand Down Expand Up @@ -685,8 +680,10 @@ void MainWindow::loadSettings()

// Retrieve the geometry and state of the main window

if ( !restoreGeometry(mSettings->value(SettingsGeometry).toByteArray())
|| !restoreState(mSettings->value(SettingsState).toByteArray())) {
QSettings settings;

if ( !restoreGeometry(settings.value(SettingsGeometry).toByteArray())
|| !restoreState(settings.value(SettingsState).toByteArray())) {
// The geometry and/or state of the main window couldn't be retrieved,
// so go with some default settings

Expand All @@ -704,22 +701,24 @@ void MainWindow::loadSettings()

// Retrieve whether the docked windows are to be shown

showDockedWindows(mSettings->value(SettingsDockedWindowsVisible, true).toBool(), true);
showDockedWindows(settings.value(SettingsDockedWindowsVisible, true).toBool(), true);

// Retrieve the state of the docked windows

mDockedWindowsState = mSettings->value(SettingsDockedWindowsState, QByteArray()).toByteArray();
mDockedWindowsState = settings.value(SettingsDockedWindowsState, QByteArray()).toByteArray();

// Retrieve the settings of our various plugins

settings.beginGroup(SettingsPlugins);

for (auto plugin : mLoadedPluginPlugins) {
mSettings->beginGroup(SettingsPlugins);
mSettings->beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->loadSettings(mSettings);
mSettings->endGroup();
mSettings->endGroup();
settings.beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->loadSettings(settings);
settings.endGroup();
}

settings.endGroup();

// Let our core plugin know that all of the plugins have loaded their
// settings
// Note: this is similar to initializePlugin() vs. pluginsInitialized()...
Expand All @@ -737,7 +736,7 @@ void MainWindow::loadSettings()

// Retrieve whether the status bar is to be shown

mGui->actionStatusBar->setChecked(mSettings->value(SettingsStatusBarVisible, true).toBool());
mGui->actionStatusBar->setChecked(settings.value(SettingsStatusBarVisible, true).toBool());
}

//==============================================================================
Expand All @@ -746,31 +745,34 @@ void MainWindow::saveSettings() const
{
// Keep track of the geometry and state of the main window

mSettings->setValue(SettingsGeometry, saveGeometry());
mSettings->setValue(SettingsState, saveState());
QSettings settings;

settings.setValue(SettingsGeometry, saveGeometry());
settings.setValue(SettingsState, saveState());

// Keep track of whether the docked windows are to be shown

mSettings->setValue(SettingsDockedWindowsVisible, mDockedWindowsVisible);
settings.setValue(SettingsDockedWindowsVisible, mDockedWindowsVisible);

// Keep track of the state of the docked windows

mSettings->setValue(SettingsDockedWindowsState, mDockedWindowsState);

// Keep track of whether the status bar is to be shown

mSettings->setValue(SettingsStatusBarVisible,
mGui->statusBar->isVisible());
settings.setValue(SettingsDockedWindowsState, mDockedWindowsState);

// Keep track of the settings of our various plugins

settings.beginGroup(SettingsPlugins);

for (auto plugin : mLoadedPluginPlugins) {
mSettings->beginGroup(SettingsPlugins);
mSettings->beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->saveSettings(mSettings);
mSettings->endGroup();
mSettings->endGroup();
settings.beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->saveSettings(settings);
settings.endGroup();
}

settings.endGroup();

// Keep track of whether the status bar is to be shown

settings.setValue(SettingsStatusBarVisible, mGui->statusBar->isVisible());
}

//==============================================================================
Expand Down Expand Up @@ -1181,11 +1183,9 @@ void MainWindow::actionPluginsTriggered()
if (mPluginManager->plugins().count()) {
// There are some plugins, so we can show the plugins dialog

mSettings->beginGroup("PluginsDialog");
PluginsDialog pluginsDialog(mSettings, mPluginManager, this);
PluginsDialog pluginsDialog(mPluginManager, this);

pluginsDialog.exec();
mSettings->endGroup();
pluginsDialog.exec();

// Restart OpenCOR (after having saved its settings) in case the user
// asked for his/her plugin-related settings to be applied
Expand All @@ -1204,12 +1204,9 @@ void MainWindow::showPreferencesDialog(const QString &pPluginName)
{
// Show the preferences dialog

mSettings->beginGroup("PreferencesDialog");
PreferencesDialog preferencesDialog(mSettings, mPluginManager,
pPluginName, this);
PreferencesDialog preferencesDialog(mPluginManager, pPluginName, this);

preferencesDialog.exec();
mSettings->endGroup();
preferencesDialog.exec();

// Let people know about the plugins that had their preferences changed, if
// any and if requested
Expand Down Expand Up @@ -1249,11 +1246,9 @@ void MainWindow::actionCheckForUpdatesTriggered()
{
// Show the check for updates dialog

mSettings->beginGroup(SettingsCheckForUpdatesDialog);
CheckForUpdatesDialog checkForUpdatesDialog(mSettings, mApplicationDate, this);
CheckForUpdatesDialog checkForUpdatesDialog(mApplicationDate, this);

checkForUpdatesDialog.exec();
mSettings->endGroup();
checkForUpdatesDialog.exec();
}

//==============================================================================
Expand Down
6 changes: 0 additions & 6 deletions src/mainwindow.h
Expand Up @@ -42,10 +42,6 @@ namespace Ui {

//==============================================================================

class QSettings;

//==============================================================================

namespace OpenCOR {

//==============================================================================
Expand Down Expand Up @@ -86,8 +82,6 @@ class MainWindow : public QMainWindow

QString mApplicationDate;

QSettings *mSettings;

PluginManager *mPluginManager;

Plugins mLoadedPluginPlugins;
Expand Down
12 changes: 7 additions & 5 deletions src/misc/cliapplication.cpp
Expand Up @@ -65,7 +65,7 @@ CliApplication::~CliApplication()

for (auto plugin : mLoadedPluginPlugins) {
settings.beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->saveSettings(&settings);
qobject_cast<PluginInterface *>(plugin->instance())->saveSettings(settings);
settings.endGroup();
}

Expand Down Expand Up @@ -112,13 +112,15 @@ void CliApplication::loadPlugins()

QSettings settings;

settings.beginGroup(SettingsPlugins);

for (auto plugin : mLoadedPluginPlugins) {
settings.beginGroup(SettingsPlugins);
settings.beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->loadSettings(&settings);
settings.endGroup();
settings.beginGroup(plugin->name());
qobject_cast<PluginInterface *>(plugin->instance())->loadSettings(settings);
settings.endGroup();
}

settings.endGroup();
}

//==============================================================================
Expand Down

0 comments on commit b577dd1

Please sign in to comment.