mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Code Review
This commit is contained in:
parent
eb59950186
commit
04f5ad5f89
@ -15,6 +15,7 @@ set(launcher_SRCS
|
||||
settingsView/csettingsview_moc.cpp
|
||||
firstLaunch/firstlaunch_moc.cpp
|
||||
main.cpp
|
||||
helper.cpp
|
||||
mainwindow_moc.cpp
|
||||
languages.cpp
|
||||
launcherdirs.cpp
|
||||
@ -39,6 +40,7 @@ set(launcher_HEADERS
|
||||
jsonutils.h
|
||||
updatedialog_moc.h
|
||||
main.h
|
||||
helper.cpp
|
||||
)
|
||||
|
||||
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 "main.h"
|
||||
#include "helper.h"
|
||||
|
||||
void MainWindow::load()
|
||||
{
|
||||
@ -45,12 +46,7 @@ void MainWindow::load()
|
||||
QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons"));
|
||||
#endif
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
void MainWindow::loadSettings()
|
||||
{
|
||||
settings.init("config/settings.json", "vcmi:settings");
|
||||
Helper::loadSettings();
|
||||
}
|
||||
|
||||
void MainWindow::computeSidePanelSizes()
|
||||
|
@ -47,8 +47,6 @@ public:
|
||||
explicit MainWindow(QWidget * parent = nullptr);
|
||||
~MainWindow() override;
|
||||
|
||||
void loadSettings();
|
||||
|
||||
const CModList & getModList() const;
|
||||
CModListView * getModView();
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../settingsView/csettingsview_moc.h"
|
||||
#include "../launcherdirs.h"
|
||||
#include "../jsonutils.h"
|
||||
#include "../helper.h"
|
||||
|
||||
#include "../../lib/VCMIDirs.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
|
||||
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]));
|
||||
QFile::copy(url.toLocalFile(), configDir.filePath(configFile[0]));
|
||||
const auto configFilePath = configDir.filePath(configFile[0]);
|
||||
QFile::remove(configFilePath);
|
||||
QFile::copy(url.toLocalFile(), configFilePath);
|
||||
|
||||
// reload settings
|
||||
for(auto widget : qApp->topLevelWidgets())
|
||||
if(auto mainWindow = qobject_cast<MainWindow *>(widget))
|
||||
mainWindow->loadSettings();
|
||||
Helper::loadSettings();
|
||||
for(auto widget : qApp->allWidgets())
|
||||
if(auto settingsView = qobject_cast<CSettingsView *>(widget))
|
||||
settingsView->loadSettings();
|
||||
|
Loading…
Reference in New Issue
Block a user