forked from qt-creator/qt-creator
QmlDesigner: Confirm deletion when removing custom folder files
Fixes: QDS-15321 Change-Id: Iaf6531d5432a05d6210159ef3957ce9c2d2eca12 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -16,13 +16,17 @@
|
|||||||
#include <qmldesignerconstants.h>
|
#include <qmldesignerconstants.h>
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
|
#include <qmldesignerbase/settings/designersettings.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/filesystemwatcher.h>
|
#include <utils/filesystemwatcher.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -230,6 +234,26 @@ void ContentLibraryUserModel::removeTextures(const QStringList &fileNames, const
|
|||||||
|
|
||||||
void ContentLibraryUserModel::removeTexture(ContentLibraryTexture *tex, bool refresh)
|
void ContentLibraryUserModel::removeTexture(ContentLibraryTexture *tex, bool refresh)
|
||||||
{
|
{
|
||||||
|
bool askBeforeDelete = QmlDesignerPlugin::settings()
|
||||||
|
.value(DesignerSettingsKey::ASK_BEFORE_DELETING_CONTENTLIB_FILE)
|
||||||
|
.toBool();
|
||||||
|
|
||||||
|
if (askBeforeDelete) {
|
||||||
|
QMessageBox msgBox(QMessageBox::Question,
|
||||||
|
tr("Confirm texture deletion"),
|
||||||
|
tr("The selected texture might be in use. Delete anyway?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
|
m_widget);
|
||||||
|
QCheckBox *dontAskAgain = new QCheckBox(tr("Don't ask again"), &msgBox);
|
||||||
|
msgBox.setCheckBox(dontAskAgain);
|
||||||
|
|
||||||
|
if (msgBox.exec() == QMessageBox::No)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (dontAskAgain->isChecked())
|
||||||
|
QmlDesignerPlugin::settings().insert(DesignerSettingsKey::ASK_BEFORE_DELETING_CONTENTLIB_FILE, false);
|
||||||
|
}
|
||||||
|
|
||||||
// remove resources
|
// remove resources
|
||||||
Utils::FilePath::fromString(tex->texturePath()).removeFile();
|
Utils::FilePath::fromString(tex->texturePath()).removeFile();
|
||||||
Utils::FilePath::fromString(tex->iconPath()).removeFile();
|
Utils::FilePath::fromString(tex->iconPath()).removeFile();
|
||||||
|
@@ -82,6 +82,7 @@ private:
|
|||||||
QRadioButton *m_useQsTranslateFunctionRadioButton;
|
QRadioButton *m_useQsTranslateFunctionRadioButton;
|
||||||
QCheckBox *m_designerAlwaysDesignModeCheckBox;
|
QCheckBox *m_designerAlwaysDesignModeCheckBox;
|
||||||
QCheckBox *m_askBeforeDeletingAssetCheckBox;
|
QCheckBox *m_askBeforeDeletingAssetCheckBox;
|
||||||
|
QCheckBox *m_askBeforeDeletingContentLibFileCheckBox;
|
||||||
QCheckBox *m_alwaysAutoFormatUICheckBox;
|
QCheckBox *m_alwaysAutoFormatUICheckBox;
|
||||||
QCheckBox *m_featureTimelineEditorCheckBox;
|
QCheckBox *m_featureTimelineEditorCheckBox;
|
||||||
QCheckBox *m_featureDockWidgetContentMinSize;
|
QCheckBox *m_featureDockWidgetContentMinSize;
|
||||||
@@ -186,6 +187,8 @@ SettingsPageWidget::SettingsPageWidget(ExternalDependencies &externalDependencie
|
|||||||
Tr::tr("Always open ui.qml files in Design mode"));
|
Tr::tr("Always open ui.qml files in Design mode"));
|
||||||
m_askBeforeDeletingAssetCheckBox = new QCheckBox(
|
m_askBeforeDeletingAssetCheckBox = new QCheckBox(
|
||||||
Tr::tr("Ask for confirmation before deleting asset"));
|
Tr::tr("Ask for confirmation before deleting asset"));
|
||||||
|
m_askBeforeDeletingContentLibFileCheckBox = new QCheckBox(
|
||||||
|
Tr::tr("Ask for confirmation before deleting content library files"));
|
||||||
m_alwaysAutoFormatUICheckBox = new QCheckBox(
|
m_alwaysAutoFormatUICheckBox = new QCheckBox(
|
||||||
Tr::tr("Always auto-format ui.qml files in Design mode"));
|
Tr::tr("Always auto-format ui.qml files in Design mode"));
|
||||||
m_featureTimelineEditorCheckBox = new QCheckBox(Tr::tr("Enable Timeline editor"));
|
m_featureTimelineEditorCheckBox = new QCheckBox(Tr::tr("Enable Timeline editor"));
|
||||||
@@ -267,6 +270,8 @@ SettingsPageWidget::SettingsPageWidget(ExternalDependencies &externalDependencie
|
|||||||
m_alwaysAutoFormatUICheckBox,
|
m_alwaysAutoFormatUICheckBox,
|
||||||
br,
|
br,
|
||||||
m_askBeforeDeletingAssetCheckBox,
|
m_askBeforeDeletingAssetCheckBox,
|
||||||
|
m_askBeforeDeletingContentLibFileCheckBox,
|
||||||
|
br,
|
||||||
m_featureTimelineEditorCheckBox,
|
m_featureTimelineEditorCheckBox,
|
||||||
br,
|
br,
|
||||||
m_featureDockWidgetContentMinSize}},
|
m_featureDockWidgetContentMinSize}},
|
||||||
@@ -383,6 +388,8 @@ QHash<QByteArray, QVariant> SettingsPageWidget::newSettings() const
|
|||||||
m_designerAlwaysDesignModeCheckBox->isChecked());
|
m_designerAlwaysDesignModeCheckBox->isChecked());
|
||||||
settings.insert(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET,
|
settings.insert(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET,
|
||||||
m_askBeforeDeletingAssetCheckBox->isChecked());
|
m_askBeforeDeletingAssetCheckBox->isChecked());
|
||||||
|
settings.insert(DesignerSettingsKey::ASK_BEFORE_DELETING_CONTENTLIB_FILE,
|
||||||
|
m_askBeforeDeletingContentLibFileCheckBox->isChecked());
|
||||||
settings.insert(DesignerSettingsKey::SMOOTH_RENDERING, m_smoothRendering->isChecked());
|
settings.insert(DesignerSettingsKey::SMOOTH_RENDERING, m_smoothRendering->isChecked());
|
||||||
|
|
||||||
settings.insert(DesignerSettingsKey::REFORMAT_UI_QML_FILES,
|
settings.insert(DesignerSettingsKey::REFORMAT_UI_QML_FILES,
|
||||||
@@ -463,6 +470,8 @@ void SettingsPageWidget::setSettings(const DesignerSettings &settings)
|
|||||||
|
|
||||||
m_askBeforeDeletingAssetCheckBox->setChecked(
|
m_askBeforeDeletingAssetCheckBox->setChecked(
|
||||||
settings.value(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET).toBool());
|
settings.value(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET).toBool());
|
||||||
|
m_askBeforeDeletingContentLibFileCheckBox->setChecked(
|
||||||
|
settings.value(DesignerSettingsKey::ASK_BEFORE_DELETING_CONTENTLIB_FILE).toBool());
|
||||||
|
|
||||||
const auto showDebugSettings = settings.value(DesignerSettingsKey::SHOW_DEBUG_SETTINGS).toBool()
|
const auto showDebugSettings = settings.value(DesignerSettingsKey::SHOW_DEBUG_SETTINGS).toBool()
|
||||||
|| Utils::qtcEnvironmentVariableIsSet(
|
|| Utils::qtcEnvironmentVariableIsSet(
|
||||||
|
@@ -85,6 +85,7 @@ void DesignerSettings::fromSettings(QtcSettings *settings)
|
|||||||
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
|
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
|
||||||
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, false);
|
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, false);
|
||||||
restoreValue(settings, DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET, true);
|
restoreValue(settings, DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET, true);
|
||||||
|
restoreValue(settings, DesignerSettingsKey::ASK_BEFORE_DELETING_CONTENTLIB_FILE, true);
|
||||||
restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR,
|
restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR,
|
||||||
QStringList{"#222222", "#999999"});
|
QStringList{"#222222", "#999999"});
|
||||||
restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR, "#cccccc");
|
restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR, "#cccccc");
|
||||||
|
@@ -65,6 +65,7 @@ inline constexpr char COLOR_PALETTE_FAVORITE[] = "ColorPaletteFavorite";
|
|||||||
inline constexpr char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
|
inline constexpr char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
|
||||||
inline constexpr char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
|
inline constexpr char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
|
||||||
inline constexpr char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
|
inline constexpr char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
|
||||||
|
inline constexpr char ASK_BEFORE_DELETING_CONTENTLIB_FILE[] = "AskBeforeDeletingContentLibFile";
|
||||||
inline constexpr char SMOOTH_RENDERING[] = "SmoothRendering";
|
inline constexpr char SMOOTH_RENDERING[] = "SmoothRendering";
|
||||||
inline constexpr char EDITOR_ZOOM_FACTOR[] = "EditorZoomFactor";
|
inline constexpr char EDITOR_ZOOM_FACTOR[] = "EditorZoomFactor";
|
||||||
inline constexpr char ACTIONS_MERGE_TEMPLATE_ENABLED[] = "ActionsMergeTemplateEnabled";
|
inline constexpr char ACTIONS_MERGE_TEMPLATE_ENABLED[] = "ActionsMergeTemplateEnabled";
|
||||||
|
Reference in New Issue
Block a user