forked from qt-creator/qt-creator
Open only designer related project files in Design Studio
DocumentManager::setFileDialogFilter allows overriding the open Project/File filter. In QDS we only allow the relevant suffixes. Task-number: QDS-5825 Change-Id: I6cdc0f15628a215edc41cdaeb485bd17e08ef4ec Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -199,6 +199,7 @@ public:
|
|||||||
IDocument *m_blockedIDocument = nullptr;
|
IDocument *m_blockedIDocument = nullptr;
|
||||||
|
|
||||||
QAction *m_saveAllAction;
|
QAction *m_saveAllAction;
|
||||||
|
QString fileDialogFilterOverride;
|
||||||
};
|
};
|
||||||
|
|
||||||
static DocumentManager *m_instance;
|
static DocumentManager *m_instance;
|
||||||
@@ -770,6 +771,16 @@ bool DocumentManager::saveDocument(IDocument *document,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DocumentManager::fileDialogFilter(QString *selectedFilter)
|
||||||
|
{
|
||||||
|
if (!d->fileDialogFilterOverride.isEmpty()) {
|
||||||
|
if (selectedFilter)
|
||||||
|
*selectedFilter = d->fileDialogFilterOverride.split(";;").first();
|
||||||
|
return d->fileDialogFilterOverride;
|
||||||
|
}
|
||||||
|
return allDocumentFactoryFiltersString(selectedFilter);
|
||||||
|
}
|
||||||
|
|
||||||
QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = nullptr)
|
QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = nullptr)
|
||||||
{
|
{
|
||||||
QSet<QString> uniqueFilters;
|
QSet<QString> uniqueFilters;
|
||||||
@@ -1531,6 +1542,11 @@ void DocumentManager::notifyFilesChangedInternally(const FilePaths &filePaths)
|
|||||||
emit m_instance->filesChangedInternally(filePaths);
|
emit m_instance->filesChangedInternally(filePaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocumentManager::setFileDialogFilter(const QString &filter)
|
||||||
|
{
|
||||||
|
d->fileDialogFilterOverride = filter;
|
||||||
|
}
|
||||||
|
|
||||||
void DocumentManager::registerSaveAllAction()
|
void DocumentManager::registerSaveAllAction()
|
||||||
{
|
{
|
||||||
d->registerSaveAllAction();
|
d->registerSaveAllAction();
|
||||||
|
@@ -142,6 +142,10 @@ public:
|
|||||||
lead to any editors to reload or any other editor manager actions. */
|
lead to any editors to reload or any other editor manager actions. */
|
||||||
static void notifyFilesChangedInternally(const Utils::FilePaths &filePaths);
|
static void notifyFilesChangedInternally(const Utils::FilePaths &filePaths);
|
||||||
|
|
||||||
|
static void setFileDialogFilter(const QString &filter);
|
||||||
|
|
||||||
|
static QString fileDialogFilter(QString *selectedFilter = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/* Used to notify e.g. the code model to update the given files. Does *not*
|
/* Used to notify e.g. the code model to update the given files. Does *not*
|
||||||
lead to any editors to reload or any other editor manager actions. */
|
lead to any editors to reload or any other editor manager actions. */
|
||||||
|
@@ -3231,7 +3231,7 @@ void EditorManager::addCloseEditorListener(const std::function<bool (IEditor *)>
|
|||||||
FilePaths EditorManager::getOpenFilePaths()
|
FilePaths EditorManager::getOpenFilePaths()
|
||||||
{
|
{
|
||||||
QString selectedFilter;
|
QString selectedFilter;
|
||||||
const QString &fileFilters = DocumentManager::allDocumentFactoryFiltersString(&selectedFilter);
|
const QString &fileFilters = DocumentManager::fileDialogFilter(&selectedFilter);
|
||||||
return DocumentManager::getOpenFileNames(fileFilters, {}, &selectedFilter);
|
return DocumentManager::getOpenFileNames(fileFilters, {}, &selectedFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/dialogs/restartdialog.h>
|
#include <coreplugin/dialogs/restartdialog.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/imode.h>
|
#include <coreplugin/imode.h>
|
||||||
@@ -52,11 +53,12 @@
|
|||||||
#include <qmldesigner/components/componentcore/theme.h>
|
#include <qmldesigner/components/componentcore/theme.h>
|
||||||
|
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/infobar.h>
|
#include <utils/infobar.h>
|
||||||
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/hostosinfo.h>
|
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -605,6 +607,12 @@ void StudioWelcomePlugin::extensionsInitialized()
|
|||||||
Core::ICore::resourcePath("qmldesigner/studio_templates"));
|
Core::ICore::resourcePath("qmldesigner/studio_templates"));
|
||||||
|
|
||||||
Core::ICore::setNewDialogFactory([](QWidget *parent) { return new QdsNewDialog(parent); });
|
Core::ICore::setNewDialogFactory([](QWidget *parent) { return new QdsNewDialog(parent); });
|
||||||
|
|
||||||
|
const QString filters = QString("Project (*.qmlproject);;UI file (*.ui.qml);;QML file "
|
||||||
|
"(*.qml);;JavaScript file (*.js);;%1")
|
||||||
|
.arg(Utils::allFilesFilterString());
|
||||||
|
|
||||||
|
Core::DocumentManager::setFileDialogFilter(filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showSplashScreen()) {
|
if (showSplashScreen()) {
|
||||||
|
Reference in New Issue
Block a user