diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-02-09 02:02:40 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-03-20 14:56:32 -0700 |
commit | 397e7f036339b09569317300423261f2b37d6119 (patch) | |
tree | f4854cbe7d4737704f3f3580fd0e81bcd772047d /launcher/ui/dialogs | |
parent | c5bbe42b57075a4b428d0be1c1ca9f51701a1a7c (diff) | |
download | PrismLauncher-397e7f036339b09569317300423261f2b37d6119.tar.gz PrismLauncher-397e7f036339b09569317300423261f2b37d6119.tar.bz2 PrismLauncher-397e7f036339b09569317300423261f2b37d6119.zip |
feat(reflink): hook up relink / clone on the copy dialog
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/ui/dialogs')
-rw-r--r-- | launcher/ui/dialogs/CopyInstanceDialog.cpp | 28 | ||||
-rw-r--r-- | launcher/ui/dialogs/CopyInstanceDialog.h | 5 | ||||
-rw-r--r-- | launcher/ui/dialogs/CopyInstanceDialog.ui | 43 |
3 files changed, 72 insertions, 4 deletions
diff --git a/launcher/ui/dialogs/CopyInstanceDialog.cpp b/launcher/ui/dialogs/CopyInstanceDialog.cpp index 55962c5a..c51bc067 100644 --- a/launcher/ui/dialogs/CopyInstanceDialog.cpp +++ b/launcher/ui/dialogs/CopyInstanceDialog.cpp @@ -46,6 +46,7 @@ #include "icons/IconList.h" #include "BaseInstance.h" #include "InstanceList.h" +#include "FileSystem.h" CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent) :QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original) @@ -85,11 +86,22 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent) ui->copyServersCheckbox->setChecked(m_selectedOptions.isCopyServersEnabled()); ui->copyModsCheckbox->setChecked(m_selectedOptions.isCopyModsEnabled()); ui->copyScreenshotsCheckbox->setChecked(m_selectedOptions.isCopyScreenshotsEnabled()); - + ui->linkFilesGroup->setChecked(m_selectedOptions.isLinkFilesEnabled()); ui->recursiveLinkCheckbox->setChecked(m_selectedOptions.isLinkRecursivelyEnabled()); ui->hardLinksCheckbox->setChecked(m_selectedOptions.isUseHardLinksEnabled()); ui->dontLinkSavesCheckbox->setChecked(m_selectedOptions.isDontLinkSavesEnabled()); + + auto detectedOS = FS::statFS(m_original->instanceRoot()).fsType; + m_cloneSupported = FS::canCloneOnFS(detectedOS); + + if (m_cloneSupported) { + ui->cloneSupportedLabel->setText(tr("Clone / Reflink is supported on (%1)").arg(FS::getFilesystemTypeName(detectedOS))); + } else { + ui->cloneSupportedLabel->setText(tr("Clone / Reflink not supported on (%1)").arg(FS::getFilesystemTypeName(detectedOS))); + } + + updateUseCloneCheckbox(); } CopyInstanceDialog::~CopyInstanceDialog() @@ -152,6 +164,12 @@ void CopyInstanceDialog::updateSelectAllCheckbox() ui->selectAllCheckbox->blockSignals(false); } +void CopyInstanceDialog::updateUseCloneCheckbox() +{ + ui->useCloneCheckbox->setEnabled(m_cloneSupported && !ui->linkFilesGroup->isChecked()); + ui->useCloneCheckbox->setChecked(m_cloneSupported && m_selectedOptions.isUseCloneEnabled()); +} + void CopyInstanceDialog::on_iconButton_clicked() { IconPickerDialog dlg(this); @@ -230,6 +248,7 @@ void CopyInstanceDialog::on_copyScreenshotsCheckbox_stateChanged(int state) void CopyInstanceDialog::on_linkFilesGroup_toggled(bool checked) { m_selectedOptions.enableLinkFiles(checked); + updateUseCloneCheckbox(); } void CopyInstanceDialog::on_recursiveLinkCheckbox_stateChanged(int state) @@ -254,3 +273,10 @@ void CopyInstanceDialog::on_dontLinkSavesCheckbox_stateChanged(int state) { m_selectedOptions.enableDontLinkSaves(state == Qt::Checked); } + +void CopyInstanceDialog::on_useCloneCheckbox_stateChanged(int state) +{ + m_selectedOptions.enableUseClone(m_cloneSupported && (state == Qt::Checked)); + ui->linkFilesGroup->setEnabled(!m_selectedOptions.isUseCloneEnabled()); + updateUseCloneCheckbox(); +}
\ No newline at end of file diff --git a/launcher/ui/dialogs/CopyInstanceDialog.h b/launcher/ui/dialogs/CopyInstanceDialog.h index 2fc6f38a..859c643c 100644 --- a/launcher/ui/dialogs/CopyInstanceDialog.h +++ b/launcher/ui/dialogs/CopyInstanceDialog.h @@ -16,6 +16,7 @@ #pragma once #include <QDialog> +#include "BaseInstance.h" #include "BaseVersion.h" #include "InstanceCopyPrefs.h" @@ -59,13 +60,17 @@ slots: void on_recursiveLinkCheckbox_stateChanged(int state); void on_hardLinksCheckbox_stateChanged(int state); void on_dontLinkSavesCheckbox_stateChanged(int state); + void on_useCloneCheckbox_stateChanged(int state); private: void checkAllCheckboxes(const bool& b); void updateSelectAllCheckbox(); + void updateUseCloneCheckbox(); + /* data */ Ui::CopyInstanceDialog *ui; QString InstIconKey; InstancePtr m_original; InstanceCopyPrefs m_selectedOptions; + bool m_cloneSupported = false; }; diff --git a/launcher/ui/dialogs/CopyInstanceDialog.ui b/launcher/ui/dialogs/CopyInstanceDialog.ui index 8df0d3db..ce8657f6 100644 --- a/launcher/ui/dialogs/CopyInstanceDialog.ui +++ b/launcher/ui/dialogs/CopyInstanceDialog.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>525</width> - <height>581</height> + <width>531</width> + <height>640</height> </rect> </property> <property name="windowTitle"> @@ -275,6 +275,44 @@ </layout> </widget> </item> + <item> + <widget class="QGroupBox" name="horizontalGroupBox"> + <property name="title"> + <string>Clone / Reflink (Copy On Write) Options</string> + </property> + <layout class="QHBoxLayout" name="useCloneLayout"> + <item> + <widget class="QCheckBox" name="useCloneCheckbox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Use Clone / Reflink</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="cloneSupportedLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Clone / Reflink not supported on this filesystem</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="margin"> + <number>4</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </item> <item> @@ -302,7 +340,6 @@ <tabstop>copyServersCheckbox</tabstop> <tabstop>copyResPacksCheckbox</tabstop> <tabstop>copyModsCheckbox</tabstop> - <tabstop>linkFilesGroup</tabstop> <tabstop>recursiveLinkCheckbox</tabstop> <tabstop>hardLinksCheckbox</tabstop> <tabstop>dontLinkSavesCheckbox</tabstop> |