mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Code Review
This commit is contained in:
parent
eb59950186
commit
04f5ad5f89
@ -15,6 +15,7 @@ set(launcher_SRCS
|
|||||||
settingsView/csettingsview_moc.cpp
|
settingsView/csettingsview_moc.cpp
|
||||||
firstLaunch/firstlaunch_moc.cpp
|
firstLaunch/firstlaunch_moc.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
|
helper.cpp
|
||||||
mainwindow_moc.cpp
|
mainwindow_moc.cpp
|
||||||
languages.cpp
|
languages.cpp
|
||||||
launcherdirs.cpp
|
launcherdirs.cpp
|
||||||
@ -39,6 +40,7 @@ set(launcher_HEADERS
|
|||||||
jsonutils.h
|
jsonutils.h
|
||||||
updatedialog_moc.h
|
updatedialog_moc.h
|
||||||
main.h
|
main.h
|
||||||
|
helper.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(launcher_FORMS
|
set(launcher_FORMS
|
||||||
|
18
launcher/helper.cpp
Normal file
18
launcher/helper.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* jsonutils.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
|
#include "../lib/CConfigHandler.h"
|
||||||
|
|
||||||
|
void Helper::loadSettings()
|
||||||
|
{
|
||||||
|
settings.init("config/settings.json", "vcmi:settings");
|
||||||
|
}
|
17
launcher/helper.h
Normal file
17
launcher/helper.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* jsonutils.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
namespace Helper
|
||||||
|
{
|
||||||
|
void loadSettings();
|
||||||
|
}
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "updatedialog_moc.h"
|
#include "updatedialog_moc.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
void MainWindow::load()
|
void MainWindow::load()
|
||||||
{
|
{
|
||||||
@ -45,12 +46,7 @@ void MainWindow::load()
|
|||||||
QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons"));
|
QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
loadSettings();
|
Helper::loadSettings();
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::loadSettings()
|
|
||||||
{
|
|
||||||
settings.init("config/settings.json", "vcmi:settings");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::computeSidePanelSizes()
|
void MainWindow::computeSidePanelSizes()
|
||||||
|
@ -47,8 +47,6 @@ public:
|
|||||||
explicit MainWindow(QWidget * parent = nullptr);
|
explicit MainWindow(QWidget * parent = nullptr);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
void loadSettings();
|
|
||||||
|
|
||||||
const CModList & getModList() const;
|
const CModList & getModList() const;
|
||||||
CModListView * getModView();
|
CModListView * getModView();
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "../settingsView/csettingsview_moc.h"
|
#include "../settingsView/csettingsview_moc.h"
|
||||||
#include "../launcherdirs.h"
|
#include "../launcherdirs.h"
|
||||||
#include "../jsonutils.h"
|
#include "../jsonutils.h"
|
||||||
|
#include "../helper.h"
|
||||||
|
|
||||||
#include "../../lib/VCMIDirs.h"
|
#include "../../lib/VCMIDirs.h"
|
||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
@ -636,15 +637,15 @@ void CModListView::manualInstallFile(QUrl url)
|
|||||||
QStringList configFile = configDir.entryList({fileName}, QDir::Filter::Files); // case insensitive check
|
QStringList configFile = configDir.entryList({fileName}, QDir::Filter::Files); // case insensitive check
|
||||||
if(!configFile.empty())
|
if(!configFile.empty())
|
||||||
{
|
{
|
||||||
if(QMessageBox::warning(this, tr("Replace config file?"), tr("Do you want to replace %1?").arg(configFile[0]), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
|
auto dialogResult = QMessageBox::warning(this, tr("Replace config file?"), tr("Do you want to replace %1?").arg(configFile[0]), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||||
|
if(dialogResult == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
QFile::remove(configDir.filePath(configFile[0]));
|
const auto configFilePath = configDir.filePath(configFile[0]);
|
||||||
QFile::copy(url.toLocalFile(), configDir.filePath(configFile[0]));
|
QFile::remove(configFilePath);
|
||||||
|
QFile::copy(url.toLocalFile(), configFilePath);
|
||||||
|
|
||||||
// reload settings
|
// reload settings
|
||||||
for(auto widget : qApp->topLevelWidgets())
|
Helper::loadSettings();
|
||||||
if(auto mainWindow = qobject_cast<MainWindow *>(widget))
|
|
||||||
mainWindow->loadSettings();
|
|
||||||
for(auto widget : qApp->allWidgets())
|
for(auto widget : qApp->allWidgets())
|
||||||
if(auto settingsView = qobject_cast<CSettingsView *>(widget))
|
if(auto settingsView = qobject_cast<CSettingsView *>(widget))
|
||||||
settingsView->loadSettings();
|
settingsView->loadSettings();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user