added option to not copy screenshots

+ moved select all checkbox to top row, centered.

Signed-off-by: Marcelo Hernandez <marcelohdez.inq@gmail.com>
This commit is contained in:
Marcelo Hernandez 2022-10-29 22:27:31 -04:00
parent c00f96c7ca
commit 5d1aac3c53
No known key found for this signature in database
GPG Key ID: 1405A0E7C9C4D61D
5 changed files with 81 additions and 32 deletions

View File

@ -12,7 +12,8 @@ bool InstanceCopyPrefs::allTrue() const
copyResourcePacks &&
copyShaderPacks &&
copyServers &&
copyMods;
copyMods &&
copyScreenshots;
}
// Returns a single RegEx string of the selected folders/files to filter out (ex: ".minecraft/saves|.minecraft/server.dat")
@ -38,6 +39,9 @@ QString InstanceCopyPrefs::getSelectedFiltersAsRegex() const
if(!copyMods)
filters << "coremods" << "mods" << "config";
if(!copyScreenshots)
filters << "screenshots";
// If we have any filters to add, join them as a single regex string to return:
if (!filters.isEmpty()) {
const QString MC_ROOT = "[.]?minecraft/";
@ -84,6 +88,11 @@ bool InstanceCopyPrefs::isCopyModsEnabled() const
return copyMods;
}
bool InstanceCopyPrefs::isCopyScreenshotsEnabled() const
{
return copyScreenshots;
}
// ======= Setters =======
void InstanceCopyPrefs::enableCopySaves(bool b)
{
@ -119,3 +128,8 @@ void InstanceCopyPrefs::enableCopyMods(bool b)
{
copyMods = b;
}
void InstanceCopyPrefs::enableCopyScreenshots(bool b)
{
copyScreenshots = b;
}

View File

@ -18,6 +18,7 @@ struct InstanceCopyPrefs {
[[nodiscard]] bool isCopyShaderPacksEnabled() const;
[[nodiscard]] bool isCopyServersEnabled() const;
[[nodiscard]] bool isCopyModsEnabled() const;
[[nodiscard]] bool isCopyScreenshotsEnabled() const;
// Setters
void enableCopySaves(bool b);
void enableKeepPlaytime(bool b);
@ -26,6 +27,7 @@ struct InstanceCopyPrefs {
void enableCopyShaderPacks(bool b);
void enableCopyServers(bool b);
void enableCopyMods(bool b);
void enableCopyScreenshots(bool b);
protected: // data
bool copySaves = true;
@ -35,4 +37,5 @@ struct InstanceCopyPrefs {
bool copyShaderPacks = true;
bool copyServers = true;
bool copyMods = true;
bool copyScreenshots = true;
};

View File

@ -84,6 +84,7 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
ui->copyShaderPacksCheckbox->setChecked(m_selectedOptions.isCopyShaderPacksEnabled());
ui->copyServersCheckbox->setChecked(m_selectedOptions.isCopyServersEnabled());
ui->copyModsCheckbox->setChecked(m_selectedOptions.isCopyModsEnabled());
ui->copyScreenshotsCheckbox->setChecked(m_selectedOptions.isCopyScreenshotsEnabled());
}
CopyInstanceDialog::~CopyInstanceDialog()
@ -135,6 +136,7 @@ void CopyInstanceDialog::checkAllCheckboxes(const bool& b)
ui->copyShaderPacksCheckbox->setChecked(b);
ui->copyServersCheckbox->setChecked(b);
ui->copyModsCheckbox->setChecked(b);
ui->copyScreenshotsCheckbox->setChecked(b);
}
// Check the "Select all" checkbox if all options are already selected:
@ -212,3 +214,9 @@ void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
m_selectedOptions.enableCopyMods(state == Qt::Checked);
updateSelectAllCheckbox();
}
void CopyInstanceDialog::on_copyScreenshotsCheckbox_stateChanged(int state)
{
m_selectedOptions.enableCopyScreenshots(state == Qt::Checked);
updateSelectAllCheckbox();
}

View File

@ -54,6 +54,7 @@ slots:
void on_copyShaderPacksCheckbox_stateChanged(int state);
void on_copyServersCheckbox_stateChanged(int state);
void on_copyModsCheckbox_stateChanged(int state);
void on_copyScreenshotsCheckbox_stateChanged(int state);
private:
void checkAllCheckboxes(const bool& b);

View File

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>341</width>
<height>385</height>
<height>399</height>
</rect>
</property>
<property name="windowTitle">
@ -112,25 +112,31 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="selectAllButtonLayout">
<item>
<widget class="QCheckBox" name="selectAllCheckbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Select all</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="copyOptionsLayout">
<item row="3" column="0">
<widget class="QCheckBox" name="copySavesCheckbox">
<property name="text">
<string>Copy saves</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="copyResPacksCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Copy resource packs</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="copyModsCheckbox">
<property name="toolTip">
@ -151,17 +157,10 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="copyServersCheckbox">
<item row="3" column="0">
<widget class="QCheckBox" name="copySavesCheckbox">
<property name="text">
<string>Copy servers</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="keepPlaytimeCheckbox">
<property name="text">
<string>Keep play time</string>
<string>Copy saves</string>
</property>
</widget>
</item>
@ -172,10 +171,34 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="selectAllCheckbox">
<item row="5" column="1">
<widget class="QCheckBox" name="copyServersCheckbox">
<property name="text">
<string>Select all</string>
<string>Copy servers</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="copyResPacksCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Copy resource packs</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="keepPlaytimeCheckbox">
<property name="text">
<string>Keep play time</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="copyScreenshotsCheckbox">
<property name="text">
<string>Copy screenshots</string>
</property>
</widget>
</item>