Browse Source

code review

Laserlicht 7 months ago
parent
commit
a371501005

+ 3 - 0
launcher/helper.cpp

@@ -54,7 +54,10 @@ void reLoadSettings()
 	loadSettings();
 	for(const auto widget : qApp->allWidgets())
 		if(auto settingsView = qobject_cast<CSettingsView *>(widget))
+		{
 			settingsView->loadSettings();
+			break;
+		}
 	getMainWindow()->updateTranslation();
 	getMainWindow()->getModView()->reload();
 }

+ 3 - 3
launcher/settingsView/configeditordialog_moc.cpp

@@ -63,9 +63,9 @@ void ConfigEditorDialog::showConfigEditorDialog()
 	dialog->setAttribute(Qt::WA_DeleteOnClose);
 }
 
-bool askUnsavedChanges(QWidget *parent)
+bool ConfigEditorDialog::askUnsavedChanges(QWidget *parent)
 {
-	auto reply = QMessageBox::question(parent, QObject::tr("Unsaved changes"), QObject::tr("Do you want to discard changes?"), QMessageBox::Yes | QMessageBox::No);
+	auto reply = QMessageBox::question(parent, tr("Unsaved changes"), tr("Do you want to discard changes?"), QMessageBox::Yes | QMessageBox::No);
 	return reply != QMessageBox::Yes;
 }
 
@@ -137,7 +137,7 @@ QString ConfigEditorDialog::loadFile(QString filename)
 	if(!f.open(QFile::ReadOnly | QFile::Text))
 	{
 		logGlobal->error("ConfigEditor can not open config for reading!");
-		return "";
+		return {};
 	}
 	loadedText = QString::fromUtf8(f.readAll());
 	loadedFile = filename;

+ 1 - 0
launcher/settingsView/configeditordialog_moc.h

@@ -41,6 +41,7 @@ private:
 	QString loadedText;
 	QString loadedFile;
 
+	bool askUnsavedChanges(QWidget *parent);
 	QString loadFile(QString filename);
 	void saveFile(QString filename, QString content);
 };