diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/listdialog.cpp | 46 | ||||
| -rw-r--r-- | src/listdialog.h | 25 | ||||
| -rw-r--r-- | src/listdialog.ui | 96 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 57 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/organizer.pro | 9 |
7 files changed, 230 insertions, 7 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 372b9519..3f004ddc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -91,6 +91,7 @@ SET(organizer_SRCS usvfsconnector.cpp eventfilter.cpp moshortcut.cpp + listdialog.cpp shared/windows_error.cpp shared/error_report.cpp @@ -185,6 +186,7 @@ SET(organizer_HDRS eventfilter.h descriptionpage.h moshortcut.h + listdialog.h shared/windows_error.h shared/error_report.h @@ -225,6 +227,7 @@ SET(organizer_UIS previewdialog.ui browserdialog.ui aboutdialog.ui + listdialog.ui ) SET(organizer_QRCS diff --git a/src/listdialog.cpp b/src/listdialog.cpp new file mode 100644 index 00000000..4acfa5de --- /dev/null +++ b/src/listdialog.cpp @@ -0,0 +1,46 @@ +/* +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "listdialog.h" +#include "ui_listdialog.h" + +ListDialog::ListDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ListDialog) +{ + ui->setupUi(this); +} + +ListDialog::~ListDialog() +{ + delete ui; +} + +void ListDialog::setChoices(QStringList choices) +{ + ui->listWidget->clear(); + ui->listWidget->addItems(choices); +} + +QString ListDialog::getChoice() const +{ + if (ui->listWidget->selectedItems().length()) { + return ui->listWidget->currentItem()->text(); + } else { + return ""; + } +} diff --git a/src/listdialog.h b/src/listdialog.h new file mode 100644 index 00000000..5e826a30 --- /dev/null +++ b/src/listdialog.h @@ -0,0 +1,25 @@ +#ifndef LISTDIALOG_H +#define LISTDIALOG_H + +#include <QDialog> + +namespace Ui { +class ListDialog; +} + +class ListDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ListDialog(QWidget *parent = nullptr); + ~ListDialog(); + + void setChoices(QStringList choices); + QString getChoice() const; + +private: + Ui::ListDialog *ui; +}; + +#endif // LISTDIALOG_H diff --git a/src/listdialog.ui b/src/listdialog.ui new file mode 100644 index 00000000..38819c87 --- /dev/null +++ b/src/listdialog.ui @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ListDialog</class> + <widget class="QDialog" name="ListDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>260</width> + <height>340</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>90</x> + <y>299</y> + <width>161</width> + <height>32</height> + </rect> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + <widget class="QListWidget" name="listWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>240</width> + <height>280</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>240</width> + <height>280</height> + </size> + </property> + <property name="verticalScrollMode"> + <enum>QAbstractItemView::ScrollPerPixel</enum> + </property> + </widget> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>ListDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ListDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 704ce838..44fc0bf3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -85,6 +85,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <scopeguard.h>
#include <usvfs.h>
#include "localsavegames.h"
+#include "listdialog.h"
#include <QAbstractItemDelegate>
#include <QAbstractProxyModel>
@@ -1149,7 +1150,7 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) void MainWindow::updateTo(QTreeWidgetItem *subTree, const std::wstring &directorySoFar, const DirectoryEntry &directoryEntry, bool conflictsOnly)
{
bool isDirectory = false;
- {
+ {
for (const FileEntry::Ptr current : directoryEntry.getFiles()) {
if (conflictsOnly && (current->getAlternatives().size() == 0)) {
continue;
@@ -3721,6 +3722,7 @@ void MainWindow::addModSendToContextMenu(QMenu *menu) sub_menu->addAction(tr("Top"), this, SLOT(sendSelectedModsToTop_clicked()));
sub_menu->addAction(tr("Bottom"), this, SLOT(sendSelectedModsToBottom_clicked()));
sub_menu->addAction(tr("Priority..."), this, SLOT(sendSelectedModsToPriority_clicked()));
+ sub_menu->addAction(tr("Separator..."), this, SLOT(sendSelectedModsToSeparator_clicked()));
menu->addMenu(sub_menu);
menu->addSeparator();
@@ -4574,7 +4576,7 @@ void MainWindow::on_dataTree_customContextMenuRequested(const QPoint &pos) m_ContextItem = dataTree->itemAt(pos.x(), pos.y());
QMenu menu;
- if ((m_ContextItem != nullptr) && (m_ContextItem->childCount() == 0)
+ if ((m_ContextItem != nullptr) && (m_ContextItem->childCount() == 0)
&& (m_ContextItem->data(0, Qt::UserRole + 3).toBool() != true)) {
menu.addAction(tr("Open/Execute"), this, SLOT(openDataFile()));
menu.addAction(tr("Add as Executable"), this, SLOT(addAsExecutable()));
@@ -5673,8 +5675,8 @@ void MainWindow::sendSelectedModsToPriority(int newPriority) QItemSelectionModel *selection = ui->modList->selectionModel();
if (selection->hasSelection() && selection->selectedRows().count() > 1) {
std::vector<int> modsToMove;
- for (QModelIndex idx : selection->selectedRows()) {
- modsToMove.push_back(idx.data().toInt());
+ for (auto idx : selection->selectedRows(ModList::COL_PRIORITY)) {
+ modsToMove.push_back(m_OrganizerCore.currentProfile()->modIndexByPriority(idx.data().toInt()));
}
m_OrganizerCore.modList()->changeModPriority(modsToMove, newPriority);
} else {
@@ -5702,3 +5704,50 @@ void MainWindow::sendSelectedModsToPriority_clicked() sendSelectedModsToPriority(newPriority);
}
+
+void MainWindow::sendSelectedModsToSeparator_clicked()
+{
+ QStringList separators;
+ for (auto mod : m_OrganizerCore.modList()->allMods()) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(ModInfo::getIndex(mod));
+ if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR)) {
+ separators << mod.chopped(10);
+ }
+ }
+
+ ListDialog dialog(this);
+ dialog.setChoices(separators);
+ if (dialog.exec() == QDialog::Accepted) {
+ QString result = dialog.getChoice();
+ if (!result.isEmpty()) {
+ result += "_separator";
+
+ int newPriority = INT_MAX;
+ bool foundSection = false;
+ for (auto mod : m_OrganizerCore.modsSortedByProfilePriority()) {
+ unsigned int modIndex = ModInfo::getIndex(mod);
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
+ if (!foundSection && result.compare(mod) == 0) {
+ foundSection = true;
+ } else if (foundSection && modInfo->hasFlag(ModInfo::FLAG_SEPARATOR)) {
+ newPriority = m_OrganizerCore.currentProfile()->getModPriority(modIndex);
+ break;
+ }
+ }
+
+ QItemSelectionModel *selection = ui->modList->selectionModel();
+ if (selection->hasSelection() && selection->selectedRows().count() > 1) {
+ std::vector<int> modsToMove;
+ for (QModelIndex idx : selection->selectedRows(ModList::COL_PRIORITY)) {
+ modsToMove.push_back(m_OrganizerCore.currentProfile()->modIndexByPriority(idx.data().toInt()));
+ }
+ m_OrganizerCore.modList()->changeModPriority(modsToMove, newPriority);
+ } else {
+ int oldPriority = m_OrganizerCore.currentProfile()->getModPriority(m_ContextRow);
+ if (oldPriority < newPriority)
+ --newPriority;
+ m_OrganizerCore.modList()->changeModPriority(m_ContextRow, newPriority);
+ }
+ }
+ }
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h index 06219a5a..62ffe3de 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -431,6 +431,7 @@ private slots: void sendSelectedModsToTop_clicked();
void sendSelectedModsToBottom_clicked();
void sendSelectedModsToPriority_clicked();
+ void sendSelectedModsToSeparator_clicked();
// savegame context menu
void deleteSavegame_clicked();
void fixMods_clicked(SaveGameInfo::MissingAssets const &missingAssets);
diff --git a/src/organizer.pro b/src/organizer.pro index 0ef2638b..582fde9f 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -91,7 +91,8 @@ SOURCES += \ modinforegular.cpp \
modinfobackup.cpp \
modinfooverwrite.cpp \
- modinfoforeign.cpp
+ modinfoforeign.cpp \
+ listdialog.cpp
HEADERS += \
@@ -167,7 +168,8 @@ HEADERS += \ modinforegular.h \
modinfobackup.h \
modinfooverwrite.h \
- modinfoforeign.h
+ modinfoforeign.h \
+ listdialog.h
FORMS += \
transfersavesdialog.ui \
@@ -196,7 +198,8 @@ FORMS += \ problemsdialog.ui \
previewdialog.ui \
browserdialog.ui \
- aboutdialog.ui
+ aboutdialog.ui \
+ listdialog.ui
RESOURCES += \
resources.qrc \
|
