- a few hooks will now somewhat handle file names starting with \\?\

- mod meta information is now (also) saved by a timer to reduce the likelyhood
of a data loss in case of a crash
- mod meta files are now written to a temporary file and then renamed to real name to
reduce chance of breaking the file
- updated minimum compatible nmm version to 0.47.0
- bugfix: defaults for newestVersion, version and installationFile when creating
an empty mod were integers instead of strings
- bugfix: "Plugins" and "Archives" weren't translatable
This commit is contained in:
Tannin
2014-02-12 21:00:49 +01:00
parent 7aadb47637
commit 9c8e43853d
14 changed files with 2111 additions and 1973 deletions
+16 -3
View File
@@ -295,6 +295,10 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget
m_CheckBSATimer.setSingleShot(true);
connect(&m_CheckBSATimer, SIGNAL(timeout()), this, SLOT(checkBSAList()));
m_SaveMetaTimer.setSingleShot(false);
connect(&m_SaveMetaTimer, SIGNAL(timeout()), this, SLOT(saveModMetas()));
m_SaveMetaTimer.start(5000);
m_DirectoryRefresher.moveToThread(&m_RefresherThread);
m_RefresherThread.start();
@@ -1208,10 +1212,10 @@ IModInterface *MainWindow::createMod(GuessedValue<QString> &name)
QSettings settingsFile(targetDirectory.mid(0).append("/meta.ini"), QSettings::IniFormat);
settingsFile.setValue("modid", 0);
settingsFile.setValue("version", 0);
settingsFile.setValue("newestVersion", 0);
settingsFile.setValue("version", "");
settingsFile.setValue("newestVersion", "");
settingsFile.setValue("category", 0);
settingsFile.setValue("installationFile", 0);
settingsFile.setValue("installationFile", "");
return ModInfo::createFrom(QDir(targetDirectory), &m_DirectoryStructure).data();
// }
}
@@ -1956,6 +1960,15 @@ void MainWindow::checkBSAList()
}
void MainWindow::saveModMetas()
{
for (unsigned int i = 0; i < ModInfo::getNumMods(); ++i) {
ModInfo::Ptr modInfo = ModInfo::getByIndex(i);
modInfo->saveMeta();
}
}
void MainWindow::fixCategories()
{
for (unsigned int i = 0; i < ModInfo::getNumMods(); ++i) {
+3
View File
@@ -352,6 +352,7 @@ private:
bool m_DirectoryUpdate;
bool m_ArchivesInit;
QTimer m_CheckBSATimer;
QTimer m_SaveMetaTimer;
QTime m_StartTime;
SaveGameInfoWidget *m_CurrentSaveView;
@@ -495,6 +496,8 @@ private slots:
void startExeAction();
void checkBSAList();
void saveModMetas();
void updateStyle(const QString &style);
void modlistChanged(const QModelIndex &index, int role);
+2 -2
View File
@@ -602,7 +602,7 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<attribute name="title">
<string notr="true">Plugins</string>
<string>Plugins</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
@@ -738,7 +738,7 @@ p, li { white-space: pre-wrap; }
</widget>
<widget class="QWidget" name="bsaTab">
<attribute name="title">
<string notr="true">Archives</string>
<string>Archives</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="leftMargin">
+44 -18
View File
@@ -373,26 +373,48 @@ void ModInfoRegular::saveMeta()
{
// only write meta data if the mod directory exists
if (m_MetaInfoChanged && QFile::exists(absolutePath())) {
QSettings metaFile(absolutePath().append("/meta.ini"), QSettings::IniFormat);
if (metaFile.status() == QSettings::NoError) {
std::set<int> temp = m_Categories;
temp.erase(m_PrimaryCategory);
metaFile.setValue("category", QString("%1").arg(m_PrimaryCategory) + "," + SetJoin(temp, ","));
metaFile.setValue("newestVersion", m_NewestVersion.canonicalString());
metaFile.setValue("ignoredVersion", m_IgnoredVersion.canonicalString());
metaFile.setValue("version", m_Version.canonicalString());
metaFile.setValue("modid", m_NexusID);
metaFile.setValue("notes", m_Notes);
metaFile.setValue("nexusDescription", m_NexusDescription);
metaFile.setValue("lastNexusQuery", m_LastNexusQuery.toString(Qt::ISODate));
if (m_EndorsedState != ENDORSED_UNKNOWN) {
metaFile.setValue("endorsed", m_EndorsedState);
bool success = false;
{
QSettings metaFile(absolutePath().append("/meta.ini.new"), QSettings::IniFormat);
if (metaFile.status() == QSettings::NoError) {
std::set<int> temp = m_Categories;
temp.erase(m_PrimaryCategory);
metaFile.setValue("category", QString("%1").arg(m_PrimaryCategory) + "," + SetJoin(temp, ","));
metaFile.setValue("newestVersion", m_NewestVersion.canonicalString());
metaFile.setValue("ignoredVersion", m_IgnoredVersion.canonicalString());
metaFile.setValue("version", m_Version.canonicalString());
if (m_NexusID != -1) {
metaFile.setValue("modid", m_NexusID);
}
metaFile.setValue("notes", m_Notes);
metaFile.setValue("nexusDescription", m_NexusDescription);
metaFile.setValue("lastNexusQuery", m_LastNexusQuery.toString(Qt::ISODate));
if (m_EndorsedState != ENDORSED_UNKNOWN) {
metaFile.setValue("endorsed", m_EndorsedState);
}
metaFile.sync(); // sync needs to be called to ensure the file is created
if (metaFile.status() == QSettings::NoError) {
success = true;
m_MetaInfoChanged = false;
} else {
reportError(tr("failed to write %1/meta.ini: error %2").arg(absolutePath()).arg(metaFile.status()));
}
} else {
reportError(tr("failed to write %1/meta.ini: error %2").arg(absolutePath()).arg(metaFile.status()));
}
}
if (success) {
if (!QFile::remove(absolutePath().append("/meta.ini"))) {
qCritical("failed to remove %s", qPrintable(absolutePath().append("/meta.ini")));
return;
}
if (QFile::rename(absolutePath().append("/meta.ini.new"), absolutePath().append("/meta.ini"))) {
qDebug("%s written", qPrintable(absolutePath().append("/meta.ini")));
} else {
qCritical("writing %s failed", qPrintable(absolutePath().append("/meta.ini")));
}
metaFile.sync(); // sync needs to be called to ensure the file is created
} else {
reportError(tr("failed to write %1/meta.ini: %2").arg(absolutePath()).arg(metaFile.status()));
}
m_MetaInfoChanged = false;
}
}
@@ -556,6 +578,10 @@ void ModInfoRegular::setVersion(const VersionInfo &version)
m_MetaInfoChanged = true;
}
void ModInfoRegular::setNewestVersion(const VersionInfo &version) {
m_NewestVersion = version;
}
void ModInfoRegular::setNexusDescription(const QString &description)
{
m_NexusDescription = description;
+1 -1
View File
@@ -592,7 +592,7 @@ public:
* @todo this function should be made obsolete. All queries for mod information should go through
* this class so no public function for this change is required
**/
void setNewestVersion(const MOBase::VersionInfo &version) { m_NewestVersion = version; }
void setNewestVersion(const MOBase::VersionInfo &version);
/**
* @brief changes/updates the nexus description text
+256 -242
View File
File diff suppressed because it is too large Load Diff
+255 -245
View File
File diff suppressed because it is too large Load Diff
+255 -245
View File
File diff suppressed because it is too large Load Diff
+255 -245
View File
File diff suppressed because it is too large Load Diff
+256 -242
View File
File diff suppressed because it is too large Load Diff
+255 -245
View File
File diff suppressed because it is too large Load Diff
+256 -242
View File
File diff suppressed because it is too large Load Diff
+256 -242
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -223,7 +223,7 @@ QString Settings::getModDirectory() const
QString Settings::getNMMVersion() const
{
static const QString MIN_NMM_VERSION = "0.46.0";
static const QString MIN_NMM_VERSION = "0.47.0";
QString result = m_Settings.value("Settings/nmm_version", MIN_NMM_VERSION).toString();
if (VersionInfo(result) < VersionInfo(MIN_NMM_VERSION)) {
result = MIN_NMM_VERSION;