Skip to content

Commit

Permalink
Merge pull request OpenMW#2390 from Capostrophic/launcher
Browse files Browse the repository at this point in the history
Launcher: Clone content list button (feature #4784)
  • Loading branch information
akortunov authored May 18, 2019
2 parents 2c95639 + 6860496 commit add3b9d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
Feature #4673: Weapon sheathing
Feature #4675: Support for NiRollController
Feature #4730: Native animated containers support
Feature #4784: Launcher: Duplicate Content Lists
Feature #4812: Support NiSwitchNode
Feature #4836: Daytime node switch
Feature #4859: Make water reflections more configurable
Expand Down
44 changes: 31 additions & 13 deletions apps/launcher/datafilespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
const QString encoding = mGameSettings.value("encoding", "win1252");
mSelector->setEncoding(encoding);

mProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
mNewProfileDialog = new TextInputDialog(tr("New Content List"), tr("Content List name:"), this);
mCloneProfileDialog = new TextInputDialog(tr("Clone Content List"), tr("Content List name:"), this);

connect(mProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
this, SLOT(updateOkButton(QString)));
connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
this, SLOT(updateNewProfileOkButton(QString)));
connect(mCloneProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
this, SLOT(updateCloneProfileOkButton(QString)));

buildView();
loadSettings();
Expand All @@ -61,6 +64,7 @@ void Launcher::DataFilesPage::buildView()

//tool buttons
ui.newProfileButton->setToolTip ("Create a new Content List");
ui.cloneProfileButton->setToolTip ("Clone the current Content List");
ui.deleteProfileButton->setToolTip ("Delete an existing Content List");

//combo box
Expand All @@ -70,6 +74,7 @@ void Launcher::DataFilesPage::buildView()

// Add the actions to the toolbuttons
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
ui.cloneProfileButton->setDefaultAction (ui.cloneProfileAction);
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);

//establish connections
Expand Down Expand Up @@ -246,10 +251,10 @@ void Launcher::DataFilesPage::slotProfileChanged(int index)

void Launcher::DataFilesPage::on_newProfileAction_triggered()
{
if (mProfileDialog->exec() != QDialog::Accepted)
if (mNewProfileDialog->exec() != QDialog::Accepted)
return;

QString profile = mProfileDialog->lineEdit()->text();
QString profile = mNewProfileDialog->lineEdit()->text();

if (profile.isEmpty())
return;
Expand All @@ -273,6 +278,20 @@ void Launcher::DataFilesPage::addProfile (const QString &profile, bool setAsCurr
setProfile (ui.profilesComboBox->findText (profile), false);
}

void Launcher::DataFilesPage::on_cloneProfileAction_triggered()
{
if (mCloneProfileDialog->exec() != QDialog::Accepted)
return;

QString profile = mCloneProfileDialog->lineEdit()->text();

if (profile.isEmpty())
return;

mLauncherSettings.setContentList(profile, selectedFilePaths());
addProfile(profile, true);
}

void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
{
QString profile = ui.profilesComboBox->currentText();
Expand All @@ -295,17 +314,16 @@ void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
checkForDefaultProfile();
}

void Launcher::DataFilesPage::updateOkButton(const QString &text)
void Launcher::DataFilesPage::updateNewProfileOkButton(const QString &text)
{
// We do this here because we need the profiles combobox text
if (text.isEmpty()) {
mProfileDialog->setOkButtonEnabled(false);
return;
}
mNewProfileDialog->setOkButtonEnabled(!text.isEmpty() && ui.profilesComboBox->findText(text) == -1);
}

(ui.profilesComboBox->findText(text) == -1)
? mProfileDialog->setOkButtonEnabled(true)
: mProfileDialog->setOkButtonEnabled(false);
void Launcher::DataFilesPage::updateCloneProfileOkButton(const QString &text)
{
// We do this here because we need the profiles combobox text
mCloneProfileDialog->setOkButtonEnabled(!text.isEmpty() && ui.profilesComboBox->findText(text) == -1);
}

void Launcher::DataFilesPage::checkForDefaultProfile()
Expand Down
7 changes: 5 additions & 2 deletions apps/launcher/datafilespage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ namespace Launcher
void slotProfileDeleted(const QString &item);
void slotAddonDataChanged ();

void updateOkButton(const QString &text);
void updateNewProfileOkButton(const QString &text);
void updateCloneProfileOkButton(const QString &text);

void on_newProfileAction_triggered();
void on_cloneProfileAction_triggered();
void on_deleteProfileAction_triggered();

public:
Expand All @@ -73,7 +75,8 @@ namespace Launcher

private:

TextInputDialog *mProfileDialog;
TextInputDialog *mNewProfileDialog;
TextInputDialog *mCloneProfileDialog;

Files::ConfigurationManager &mCfgMgr;

Expand Down
49 changes: 32 additions & 17 deletions files/ui/datafilespage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
<ui version="4.0">
<class>DataFilesPage</class>
<widget class="QWidget" name="DataFilesPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>108</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
Expand Down Expand Up @@ -79,6 +65,19 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cloneProfileButton">
<property name="toolTip">
<string>Clone Content List</string>
</property>
<property name="text">
<string>Clone Content List</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="deleteProfileButton">
<property name="toolTip">
Expand All @@ -87,9 +86,6 @@
<property name="text">
<string>Delete Content List</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
Expand All @@ -115,6 +111,22 @@
<string>Ctrl+N</string>
</property>
</action>
<action name="cloneProfileAction">
<property name="icon">
<iconset theme="edit-copy">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clone Content List</string>
</property>
<property name="toolTip">
<string>Clone Content List</string>
</property>
<property name="shortcut">
<string>Ctrl+G</string>
</property>
</action>
<action name="deleteProfileAction">
<property name="enabled">
<bool>false</bool>
Expand All @@ -130,6 +142,9 @@
<property name="toolTip">
<string>Delete Content List</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
<action name="checkAction">
<property name="checkable">
Expand Down

0 comments on commit add3b9d

Please sign in to comment.