mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-04-29 22:24:26 +02:00
Use CustomMessageBox::selectable
Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
parent
02ca6bea8c
commit
da007d6212
@ -389,11 +389,7 @@ void BaseInstance::setName(QString val)
|
|||||||
bool BaseInstance::syncInstanceDirName(const QString& newRoot) const
|
bool BaseInstance::syncInstanceDirName(const QString& newRoot) const
|
||||||
{
|
{
|
||||||
auto oldRoot = instanceRoot();
|
auto oldRoot = instanceRoot();
|
||||||
if (oldRoot == newRoot)
|
return oldRoot == newRoot || QFile::rename(oldRoot, newRoot);
|
||||||
return true;
|
|
||||||
if (!QFile::rename(oldRoot, newRoot))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BaseInstance::name() const
|
QString BaseInstance::name() const
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include "InstanceDirUpdate.h"
|
#include "InstanceDirUpdate.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
@ -69,17 +68,16 @@ QString askToUpdateInstanceDirName(InstancePtr instance, const QString& oldName,
|
|||||||
|
|
||||||
// Ask if we should rename
|
// Ask if we should rename
|
||||||
if (renamingMode == "AskEverytime") {
|
if (renamingMode == "AskEverytime") {
|
||||||
QMessageBox messageBox(parent);
|
|
||||||
messageBox.setText(QObject::tr("Would you also like to rename the instance folder?"));
|
|
||||||
messageBox.setInformativeText(QObject::tr("Renaming \'%1\' -> \'%2\'").arg(oldName, newName));
|
|
||||||
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
||||||
messageBox.setDefaultButton(QMessageBox::Yes);
|
|
||||||
messageBox.setIcon(QMessageBox::Question);
|
|
||||||
|
|
||||||
auto checkBox = new QCheckBox(QObject::tr("&Remember my choice"), parent);
|
auto checkBox = new QCheckBox(QObject::tr("&Remember my choice"), parent);
|
||||||
messageBox.setCheckBox(checkBox);
|
auto dialog =
|
||||||
|
CustomMessageBox::selectable(parent, QObject::tr("Rename instance folder"),
|
||||||
|
QObject::tr("Would you also like to rename the instance folder?\n\n"
|
||||||
|
"Old name: %1\n"
|
||||||
|
"New name: %2")
|
||||||
|
.arg(oldName, newName),
|
||||||
|
QMessageBox::Question, QMessageBox::No | QMessageBox::Yes, QMessageBox::NoButton, checkBox);
|
||||||
|
|
||||||
auto res = messageBox.exec();
|
auto res = dialog->exec();
|
||||||
if (checkBox->isChecked()) {
|
if (checkBox->isChecked()) {
|
||||||
if (res == QMessageBox::Yes)
|
if (res == QMessageBox::Yes)
|
||||||
APPLICATION->settings()->set("InstRenamingMode", "PhysicalDir");
|
APPLICATION->settings()->set("InstRenamingMode", "PhysicalDir");
|
||||||
|
@ -21,7 +21,8 @@ QMessageBox* selectable(QWidget* parent,
|
|||||||
const QString& text,
|
const QString& text,
|
||||||
QMessageBox::Icon icon,
|
QMessageBox::Icon icon,
|
||||||
QMessageBox::StandardButtons buttons,
|
QMessageBox::StandardButtons buttons,
|
||||||
QMessageBox::StandardButton defaultButton)
|
QMessageBox::StandardButton defaultButton,
|
||||||
|
QCheckBox* checkBox)
|
||||||
{
|
{
|
||||||
QMessageBox* messageBox = new QMessageBox(parent);
|
QMessageBox* messageBox = new QMessageBox(parent);
|
||||||
messageBox->setWindowTitle(title);
|
messageBox->setWindowTitle(title);
|
||||||
@ -31,6 +32,8 @@ QMessageBox* selectable(QWidget* parent,
|
|||||||
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
messageBox->setIcon(icon);
|
messageBox->setIcon(icon);
|
||||||
messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
if (checkBox)
|
||||||
|
messageBox->setCheckBox(checkBox);
|
||||||
|
|
||||||
return messageBox;
|
return messageBox;
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,6 @@ QMessageBox* selectable(QWidget* parent,
|
|||||||
const QString& text,
|
const QString& text,
|
||||||
QMessageBox::Icon icon = QMessageBox::NoIcon,
|
QMessageBox::Icon icon = QMessageBox::NoIcon,
|
||||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton,
|
||||||
|
QCheckBox* checkBox = nullptr);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user