From af6e1c3ab4f3687c88715dffff8b1bf2f38a15d6 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 11 Sep 2013 22:54:45 +0200 Subject: - when installing mods from outside the download directory the absolute path is now stored - added a context menu to the toolbar buttons so tool icons can be removed directly - initweaks modinfo tab is now always available and allows new ini tweaks to be created - fake esms are now treated as masters (as they should) - MO will now display a warning if not all masters of an esp are enabled. The tooltip gives a list of required masters - bugfix: path returned by getfullpathname was sometimes not correctly terminated - bugfix: path after reverse-rerouting was sometimes incorrect, missing a path separator - bugfix: change of current directory sometimes used a fake directory without need - bugfix: icons in shortcut menu were not alwayscorrectly updated --- src/modinfodialog.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/modinfodialog.cpp') diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 3cf31f7e..75e7e499 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -38,6 +38,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include using QtJson::Json; @@ -146,7 +147,7 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo QTabWidget *tabWidget = findChild("tabWidget"); tabWidget->setTabEnabled(TAB_TEXTFILES, textFileList->count() != 0); - tabWidget->setTabEnabled(TAB_INIFILES, (iniFileList->count() != 0) || (iniTweaksList->count() != 0)); + //tabWidget->setTabEnabled(TAB_INIFILES, (iniFileList->count() != 0) || (iniTweaksList->count() != 0)); tabWidget->setTabEnabled(TAB_IMAGES, thumbnailArea->count() != 0); tabWidget->setTabEnabled(TAB_ESPS, (inactiveESPList->count() != 0) || (activeESPList->count() != 0)); tabWidget->setTabEnabled(TAB_CONFLICTS, m_Origin != NULL); @@ -409,8 +410,6 @@ void ModInfoDialog::openTextFile(const QString &fileName) void ModInfoDialog::openIniFile(const QString &fileName) { - QPushButton* saveButton = findChild("saveButton"); - QFile iniFile(fileName); iniFile.open(QIODevice::ReadOnly); QByteArray buffer = iniFile.readAll(); @@ -421,7 +420,7 @@ void ModInfoDialog::openIniFile(const QString &fileName) iniFileView->setProperty("encoding", codec->name()); iniFile.close(); - saveButton->setEnabled(false); + ui->saveButton->setEnabled(false); } @@ -515,8 +514,9 @@ void ModInfoDialog::saveCurrentIniFile() { QVariant fileNameVar = ui->iniFileView->property("currentFile"); QVariant encodingVar = ui->iniFileView->property("encoding"); - if (fileNameVar.isValid()) { + if (fileNameVar.isValid() && !fileNameVar.toString().isEmpty()) { QString fileName = fileNameVar.toString(); + QDir().mkpath(QFileInfo(fileName).absolutePath()); QFile txtFile(fileName); txtFile.open(QIODevice::WriteOnly); txtFile.resize(0); @@ -1171,3 +1171,29 @@ void ModInfoDialog::on_prevButton_clicked() emit modOpenPrev(); this->accept(); } + + +void ModInfoDialog::createTweak() +{ + QString name = QInputDialog::getText(this, tr("Name"), tr("Please enter a name")); + if (!fixDirectoryName(name)) { + QMessageBox::critical(this, tr("Error"), tr("Invalid name. Must be a valid file name")); + return; + } else if (name.isEmpty()) { + return; + } else if (ui->iniTweaksList->findItems(name, Qt::MatchFixedString).count() != 0) { + QMessageBox::critical(this, tr("Error"), tr("A tweak by that name exists")); + return; + } + + QListWidgetItem *newTweak = new QListWidgetItem(name); + newTweak->setData(Qt::UserRole, "INI Tweaks/" + name + ".ini"); + ui->iniTweaksList->addItem(newTweak); +} + +void ModInfoDialog::on_iniTweaksList_customContextMenuRequested(const QPoint &pos) +{ + QMenu menu; + menu.addAction(tr("Create Tweak"), this, SLOT(createTweak())); + menu.exec(ui->iniTweaksList->mapToGlobal(pos)); +} -- cgit v1.3.1