diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-12-29 02:42:07 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-12-29 02:42:07 -0500 |
| commit | 33a177f1eda90b4d1fff92976635beaa59f85172 (patch) | |
| tree | f8a62cc4ac8fb318ef4e86053e389a3187968940 | |
| parent | cc997c370465629c11b72ebef3ffde1bbd1fa46e (diff) | |
profiles dialog:
- added select button
- select new profile in the list after creating
| -rw-r--r-- | src/mainwindow.cpp | 17 | ||||
| -rw-r--r-- | src/profilesdialog.cpp | 27 | ||||
| -rw-r--r-- | src/profilesdialog.h | 10 | ||||
| -rw-r--r-- | src/profilesdialog.ui | 355 |
4 files changed, 254 insertions, 155 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 08c8ef7c..cfce9bef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1713,9 +1713,22 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) if (ui->profileBox->currentIndex() == 0) { ui->profileBox->setCurrentIndex(previousIndex); - ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore, this).exec(); + + std::optional<QString> newSelection; + + ProfilesDialog dlg(ui->profileBox->currentText(), m_OrganizerCore, this); + dlg.exec(); + newSelection = dlg.selectedProfile(); + while (!refreshProfiles()) { - ProfilesDialog(ui->profileBox->currentText(), m_OrganizerCore, this).exec(); + ProfilesDialog dlg(ui->profileBox->currentText(), m_OrganizerCore, this); + dlg.exec(); + newSelection = dlg.selectedProfile(); + } + + if (newSelection) { + ui->profileBox->setCurrentText(*newSelection); + activateSelectedProfile(); } } else { activateSelectedProfile(); diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index f1468688..d71a4531 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -115,11 +115,29 @@ void ProfilesDialog::showEvent(QShowEvent *event) }
}
-void ProfilesDialog::on_closeButton_clicked()
+void ProfilesDialog::on_close_clicked()
{
close();
}
+void ProfilesDialog::on_select_clicked()
+{
+ const Profile::Ptr currentProfile = ui->profilesList->currentItem()
+ ->data(Qt::UserRole)
+ .value<Profile::Ptr>();
+
+ if (!currentProfile) {
+ return;
+ }
+
+ m_Selected = currentProfile->name();
+ close();
+}
+
+std::optional<QString> ProfilesDialog::selectedProfile() const
+{
+ return m_Selected;
+}
QListWidgetItem *ProfilesDialog::addItem(const QString &name)
{
@@ -142,6 +160,7 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings) newItem->setData(Qt::UserRole, QVariant::fromValue(profile));
ui->profilesList->addItem(newItem);
m_FailState = false;
+ ui->profilesList->setCurrentItem(newItem);
emit profileCreated(profile.get());
} catch (const std::exception&) {
m_FailState = true;
@@ -157,6 +176,7 @@ void ProfilesDialog::createProfile(const QString &name, const Profile &reference newItem->setData(Qt::UserRole, QVariant::fromValue(profile));
ui->profilesList->addItem(newItem);
m_FailState = false;
+ ui->profilesList->setCurrentItem(newItem);
emit profileCreated(profile.get());
} catch (const std::exception&) {
m_FailState = true;
@@ -348,6 +368,11 @@ void ProfilesDialog::on_profilesList_currentItemChanged(QListWidgetItem *current }
}
+void ProfilesDialog::on_profilesList_itemActivated(QListWidgetItem* item)
+{
+ on_select_clicked();
+}
+
void ProfilesDialog::on_localSavesBox_stateChanged(int state)
{
Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value<Profile::Ptr>();
diff --git a/src/profilesdialog.h b/src/profilesdialog.h index 08298d0e..005bc33e 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -63,6 +63,11 @@ public: **/
bool failed() const { return m_FailState; }
+ // if the dialog was closed with the 'select' button, returns the name of the
+ // selected profile; if the dialog was closed with 'cancel', returns empty
+ //
+ std::optional<QString> selectedProfile() const;
+
signals:
/**
@@ -95,7 +100,8 @@ private: private slots:
- void on_closeButton_clicked();
+ void on_close_clicked();
+ void on_select_clicked();
void on_addProfileButton_clicked();
@@ -104,6 +110,7 @@ private slots: void on_copyProfileButton_clicked();
void on_profilesList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
+ void on_profilesList_itemActivated(QListWidgetItem* item);
void on_removeProfileButton_clicked();
@@ -119,6 +126,7 @@ private: bool m_FailState;
MOBase::IPluginGame const *m_Game;
QString m_ActiveProfileName;
+ std::optional<QString> m_Selected;
};
#endif // PROFILESDIALOG_H
diff --git a/src/profilesdialog.ui b/src/profilesdialog.ui index 644b0720..44ab0ee9 100644 --- a/src/profilesdialog.ui +++ b/src/profilesdialog.ui @@ -13,59 +13,74 @@ <property name="windowTitle">
<string>Profiles</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QListWidget" name="profilesList">
- <property name="toolTip">
- <string>List of Profiles</string>
- </property>
- <property name="whatsThis">
- <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+ <widget class="QWidget" name="widget" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QListWidget" name="profilesList">
+ <property name="toolTip">
+ <string>List of Profiles</string>
+ </property>
+ <property name="whatsThis">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8.25pt;">This is the list of profiles. Each profile contains its own list and installation order of enabled mods (from a shared pool), its own list and load order of enabled plugins (esps/esms), a copy of the games ini-file and an optional savegame filter.</span></p></body></html></string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="localSavesBox">
- <property name="toolTip">
- <string><html><head/><body><p>If checked, save games are stored locally to this profile and will not appear when starting with a different profile.</p></body></html></string>
- </property>
- <property name="whatsThis">
- <string>If checked, save games are local to this profile and will not appear when starting with a different profile.</string>
- </property>
- <property name="text">
- <string>Use profile-specific Save Games</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="localIniFilesBox">
- <property name="toolTip">
- <string><html><head/><body><p>If checked MO2 will use his own profile-specific game INI files, so that the &quot;Global&quot; ones in MyGames can be left vanilla. This different set of INI files is then offered to the game instead of the default one.</p></body></html></string>
- </property>
- <property name="whatsThis">
- <string><html><head/><body><p>If checked, MO2 will use a local set of game INI files (configuration and settings files), different from the default ones found in MyGames. This way changes to the INI settings will only affect this profile and the Global INI files can remain vanilla. MO2 will then show the profile INI files to the game instead of the Global ones.</p></body></html></string>
- </property>
- <property name="text">
- <string>Use profile-specific Game INI Files</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="invalidationBox">
- <property name="toolTip">
- <string>This ensures data files from mods are actually used. You want to enable this unless you use a different tool for Archive Invalidation.</string>
- </property>
- <property name="whatsThis">
- <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="localSavesBox">
+ <property name="toolTip">
+ <string><html><head/><body><p>If checked, save games are stored locally to this profile and will not appear when starting with a different profile.</p></body></html></string>
+ </property>
+ <property name="whatsThis">
+ <string>If checked, save games are local to this profile and will not appear when starting with a different profile.</string>
+ </property>
+ <property name="text">
+ <string>Use profile-specific Save Games</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="localIniFilesBox">
+ <property name="toolTip">
+ <string><html><head/><body><p>If checked MO2 will use his own profile-specific game INI files, so that the &quot;Global&quot; ones in MyGames can be left vanilla. This different set of INI files is then offered to the game instead of the default one.</p></body></html></string>
+ </property>
+ <property name="whatsThis">
+ <string><html><head/><body><p>If checked, MO2 will use a local set of game INI files (configuration and settings files), different from the default ones found in MyGames. This way changes to the INI settings will only affect this profile and the Global INI files can remain vanilla. MO2 will then show the profile INI files to the game instead of the Global ones.</p></body></html></string>
+ </property>
+ <property name="text">
+ <string>Use profile-specific Game INI Files</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="invalidationBox">
+ <property name="toolTip">
+ <string>This ensures data files from mods are actually used. You want to enable this unless you use a different tool for Archive Invalidation.</string>
+ </property>
+ <property name="whatsThis">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
@@ -73,111 +88,149 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">The Mod Organizer uses a workaround called &quot;BSA redirection&quot; (google is your friend) to fix this issue reliably and without further work. Simply activate and forget.</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">With Skyrim this bug seems to be fixed to a degree but whether a mod becomes active still depends on file dates. Therefore, it still makes sense to activate this.</span></p></body></html></string>
- </property>
- <property name="text">
- <string>Automatic Archive Invalidation</string>
- </property>
- </widget>
- </item>
- </layout>
+ </property>
+ <property name="text">
+ <string>Automatic Archive Invalidation</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="addProfileButton">
+ <property name="toolTip">
+ <string>Create a new profile from scratch</string>
+ </property>
+ <property name="whatsThis">
+ <string>Create a new profile from scratch</string>
+ </property>
+ <property name="text">
+ <string>Create</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="copyProfileButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Clone the selected profile</string>
+ </property>
+ <property name="whatsThis">
+ <string>This creates a new profile with the same settings and active mods as the selected one.</string>
+ </property>
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="removeProfileButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Delete the selected Profile. This can not be un-done!</string>
+ </property>
+ <property name="whatsThis">
+ <string>Delete the selected Profile. This can not be un-done!</string>
+ </property>
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="renameButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Rename</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="transferButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Transfer save games to the selected profile.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Transfer save games to the selected profile.</string>
+ </property>
+ <property name="text">
+ <string>Transfer Saves</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QPushButton" name="addProfileButton">
- <property name="toolTip">
- <string>Create a new profile from scratch</string>
- </property>
- <property name="whatsThis">
- <string>Create a new profile from scratch</string>
- </property>
- <property name="text">
- <string>Create</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="copyProfileButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Clone the selected profile</string>
- </property>
- <property name="whatsThis">
- <string>This creates a new profile with the same settings and active mods as the selected one.</string>
- </property>
- <property name="text">
- <string>Copy</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="removeProfileButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Delete the selected Profile. This can not be un-done!</string>
- </property>
- <property name="whatsThis">
- <string>Delete the selected Profile. This can not be un-done!</string>
- </property>
- <property name="text">
- <string>Remove</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="renameButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Rename</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="transferButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Transfer save games to the selected profile.</string>
- </property>
- <property name="whatsThis">
- <string>Transfer save games to the selected profile.</string>
- </property>
- <property name="text">
- <string>Transfer Saves</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="closeButton">
- <property name="toolTip">
- <string/>
- </property>
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QWidget" name="widget_2" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="select">
+ <property name="text">
+ <string>Select</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="close">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
|
