Merge "Merge remote-tracking branch 'origin/14.0'"

This commit is contained in:
The Qt Project
2024-07-25 10:57:26 +00:00
49 changed files with 2465 additions and 1395 deletions

View File

@@ -304,9 +304,9 @@ bool FilePath::equals(const FilePath &first, const FilePath &second, Qt::CaseSen
}
/*!
* Returns true if the two file paths compare equal case-sensitively.
* Returns \c true if this file path compares equal to \a other case-sensitively.
* This is relevant on semi-case sensitive systems like Windows with NTFS.
* @see QTCREATORBUG-30846
* \sa {https://bugreports.qt.io/browse/QTCREATORBUG-30846}{QTCREATORBUG-30846}
*/
bool FilePath::equalsCaseSensitive(const FilePath &other) const
{

View File

@@ -362,7 +362,7 @@ void Layout::setContentsMargins(int left, int top, int right, int bottom)
}
/*!
Attaches the constructed layout to the provided QWidget \a w.
Attaches the constructed layout to the provided QWidget \a widget.
This operation can only be performed once per LayoutBuilder instance.
*/
@@ -373,7 +373,7 @@ void Layout::attachTo(QWidget *widget)
}
/*!
Adds the layout item \a item as sub items.
Adds the layout item \a item as a sub item.
*/
void Layout::addItem(I item)
{

View File

@@ -274,7 +274,10 @@ QString MacroExpander::expand(const QString &stringWithVariables) const
FilePath MacroExpander::expand(const FilePath &fileNameWithVariables) const
{
// We want single variables to expand to fully qualified strings.
return FilePath::fromUserInput(expand(fileNameWithVariables.toString()));
const QString host = expand(fileNameWithVariables.host().toString());
const QString scheme = expand(fileNameWithVariables.scheme().toString());
const QString path = expand(fileNameWithVariables.path());
return FilePath::fromParts(scheme, host, path);
}
QByteArray MacroExpander::expand(const QByteArray &stringWithVariables) const

View File

@@ -46,22 +46,23 @@ AndroidRunner::AndroidRunner(RunControl *runControl, const QString &intentName)
m_packageName = intent.left(intent.indexOf('/'));
qCDebug(androidRunnerLog) << "Intent name:" << intent << "Package name" << m_packageName;
m_worker.reset(new AndroidRunnerWorker(this, m_packageName));
m_worker = new AndroidRunnerWorker(this, m_packageName);
m_worker->setIntentName(intent);
m_worker->moveToThread(&m_thread);
QObject::connect(&m_thread, &QThread::finished, m_worker, &QObject::deleteLater);
connect(this, &AndroidRunner::asyncStart, m_worker.data(), &AndroidRunnerWorker::asyncStart);
connect(this, &AndroidRunner::asyncStop, m_worker.data(), &AndroidRunnerWorker::asyncStop);
connect(this, &AndroidRunner::asyncStart, m_worker, &AndroidRunnerWorker::asyncStart);
connect(this, &AndroidRunner::asyncStop, m_worker, &AndroidRunnerWorker::asyncStop);
connect(this, &AndroidRunner::androidDeviceInfoChanged,
m_worker.data(), &AndroidRunnerWorker::setAndroidDeviceInfo);
connect(m_worker.data(), &AndroidRunnerWorker::remoteProcessStarted,
m_worker, &AndroidRunnerWorker::setAndroidDeviceInfo);
connect(m_worker, &AndroidRunnerWorker::remoteProcessStarted,
this, &AndroidRunner::handleRemoteProcessStarted);
connect(m_worker.data(), &AndroidRunnerWorker::remoteProcessFinished,
connect(m_worker, &AndroidRunnerWorker::remoteProcessFinished,
this, &AndroidRunner::handleRemoteProcessFinished);
connect(m_worker.data(), &AndroidRunnerWorker::remoteOutput,
this, &AndroidRunner::remoteOutput);
connect(m_worker.data(), &AndroidRunnerWorker::remoteErrorOutput,
connect(m_worker, &AndroidRunnerWorker::remoteOutput, this, &AndroidRunner::remoteOutput);
connect(m_worker, &AndroidRunnerWorker::remoteErrorOutput,
this, &AndroidRunner::remoteErrorOutput);
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,

View File

@@ -51,7 +51,7 @@ private:
QString m_packageName;
QThread m_thread;
QScopedPointer<AndroidRunnerWorker> m_worker;
AndroidRunnerWorker *m_worker = nullptr;
QPointer<ProjectExplorer::Target> m_target;
Utils::Port m_debugServerPort;
QUrl m_qmlServer;

View File

@@ -172,24 +172,26 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
m_extraAppParams = runControl->commandLine().arguments();
if (const Store sd = runControl->settingsData(Constants::ANDROID_AM_START_ARGS);
!sd.values().isEmpty()) {
!sd.isEmpty()) {
QTC_CHECK(sd.first().typeId() == QMetaType::QString);
const QString startArgs = sd.first().toString();
m_amStartExtraArgs = ProcessArgs::splitArgs(startArgs, OsTypeOtherUnix);
}
if (const Store sd = runControl->settingsData(Constants::ANDROID_PRESTARTSHELLCMDLIST);
!sd.values().isEmpty()) {
QTC_CHECK(sd.first().typeId() == QMetaType::QString);
const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts);
!sd.isEmpty()) {
const QVariant &first = sd.first();
QTC_CHECK(first.typeId() == QMetaType::QStringList);
const QStringList commands = first.toStringList();
for (const QString &shellCmd : commands)
m_beforeStartAdbCommands.append(QString("shell %1").arg(shellCmd));
}
if (const Store sd = runControl->settingsData(Constants::ANDROID_POSTFINISHSHELLCMDLIST);
!sd.values().isEmpty()) {
QTC_CHECK(sd.first().typeId() == QMetaType::QString);
const QStringList commands = sd.first().toString().split('\n', Qt::SkipEmptyParts);
!sd.isEmpty()) {
const QVariant &first = sd.first();
QTC_CHECK(first.typeId() == QMetaType::QStringList);
const QStringList commands = first.toStringList();
for (const QString &shellCmd : commands)
m_afterFinishAdbCommands.append(QString("shell %1").arg(shellCmd));
}
@@ -204,6 +206,7 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunWorker *runner, const QString &packa
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
m_useAppParamsForQmlDebugger = version->qtVersion() >= QVersionNumber(5, 12);
m_pidRunner.setParent(this); // Move m_pidRunner object together with *this into a separate thread.
}
AndroidRunnerWorker::~AndroidRunnerWorker()

View File

@@ -37,3 +37,8 @@ extend_qtc_plugin(ClangFormat
DEFINES
TESTDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/data"
)
extend_qtc_plugin(ClangFormat
CONDITION TARGET LLVM
DEPENDS LLVM
)

View File

@@ -1168,6 +1168,10 @@ Kit *CMakeProjectImporter::createKit(void *directoryData) const
if (!cmtcd.originalTargetTriple.isEmpty())
toolchain->setExplicitCodeModelTargetTriple(cmtcd.originalTargetTriple);
// Mark CMake presets toolchains as manual
if (!data->cmakePresetDisplayname.isEmpty() && tcd.areTemporary)
toolchain->setDetection(Toolchain::ManualDetection);
ToolchainKitAspect::setToolchain(k, toolchain);
}

View File

@@ -558,12 +558,12 @@ void EditorManagerPrivate::init()
this, &EditorManagerPrivate::closeAllEditorsExceptVisible);
connect(m_openGraphicalShellContextAction, &QAction::triggered, this, [this] {
if (!m_contextMenuEntry || m_contextMenuEntry->filePath().isEmpty())
if (!m_contextMenuDocument || m_contextMenuEntry->filePath().isEmpty())
return;
FileUtils::showInGraphicalShell(ICore::dialogParent(), m_contextMenuEntry->filePath());
});
connect(m_showInFileSystemViewContextAction, &QAction::triggered, this, [this] {
if (!m_contextMenuEntry || m_contextMenuEntry->filePath().isEmpty())
if (!m_contextMenuDocument || m_contextMenuEntry->filePath().isEmpty())
return;
FileUtils::showInFileSystemView(m_contextMenuEntry->filePath());
});
@@ -571,7 +571,7 @@ void EditorManagerPrivate::init()
connect(m_findInDirectoryAction, &QAction::triggered,
this, &EditorManagerPrivate::findInDirectory);
connect(m_filePropertiesAction, &QAction::triggered, this, [this] {
if (!m_contextMenuEntry || m_contextMenuEntry->filePath().isEmpty())
if (!m_contextMenuDocument || m_contextMenuEntry->filePath().isEmpty())
return;
DocumentManager::showFilePropertiesDialog(m_contextMenuEntry->filePath());
});
@@ -2434,14 +2434,14 @@ void EditorManagerPrivate::handleContextChange(const QList<IContext *> &context)
void EditorManagerPrivate::copyFilePathFromContextMenu()
{
if (!d->m_contextMenuEntry)
if (!d->m_contextMenuDocument)
return;
setClipboardAndSelection(d->m_contextMenuEntry->filePath().toUserOutput());
}
void EditorManagerPrivate::copyLocationFromContextMenu()
{
if (!d->m_contextMenuEntry)
if (!d->m_contextMenuDocument)
return;
const QString text = d->m_contextMenuEntry->filePath().toUserOutput()
+ QLatin1Char(':') + m_copyLocationContextAction->data().toString();
@@ -2450,28 +2450,28 @@ void EditorManagerPrivate::copyLocationFromContextMenu()
void EditorManagerPrivate::copyFileNameFromContextMenu()
{
if (!d->m_contextMenuEntry)
if (!d->m_contextMenuDocument)
return;
setClipboardAndSelection(d->m_contextMenuEntry->filePath().fileName());
}
void EditorManagerPrivate::saveDocumentFromContextMenu()
{
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
IDocument *document = d->m_contextMenuDocument.get();
if (document)
saveDocument(document);
}
void EditorManagerPrivate::saveDocumentAsFromContextMenu()
{
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
IDocument *document = d->m_contextMenuDocument.get();
if (document)
saveDocumentAs(document);
}
void EditorManagerPrivate::revertToSavedFromContextMenu()
{
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
IDocument *document = d->m_contextMenuDocument.get();
if (document)
revertToSaved(document);
}
@@ -2481,7 +2481,7 @@ void EditorManagerPrivate::closeEditorFromContextMenu()
if (d->m_contextMenuEditor) {
closeEditorOrDocument(d->m_contextMenuEditor);
} else {
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
IDocument *document = d->m_contextMenuDocument.get();
if (document)
EditorManager::closeDocuments({document});
}
@@ -2489,7 +2489,7 @@ void EditorManagerPrivate::closeEditorFromContextMenu()
void EditorManagerPrivate::closeOtherDocumentsFromContextMenu()
{
IDocument *document = d->m_contextMenuEntry ? d->m_contextMenuEntry->document : nullptr;
IDocument *document = d->m_contextMenuDocument.get();
EditorManager::closeOtherDocuments(document);
}
@@ -2645,14 +2645,14 @@ void EditorManagerPrivate::autoSuspendDocuments()
void EditorManagerPrivate::openTerminal()
{
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
if (!d->m_contextMenuDocument || d->m_contextMenuEntry->filePath().isEmpty())
return;
FileUtils::openTerminal(d->m_contextMenuEntry->filePath().parentDir(), {});
}
void EditorManagerPrivate::findInDirectory()
{
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
if (!d->m_contextMenuDocument || d->m_contextMenuEntry->filePath().isEmpty())
return;
const FilePath path = d->m_contextMenuEntry->filePath();
emit m_instance->findOnFileSystemRequest(
@@ -2661,7 +2661,7 @@ void EditorManagerPrivate::findInDirectory()
void EditorManagerPrivate::togglePinned()
{
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty())
if (!d->m_contextMenuDocument || d->m_contextMenuEntry->filePath().isEmpty())
return;
const bool currentlyPinned = d->m_contextMenuEntry->pinned;
@@ -2864,6 +2864,7 @@ void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, DocumentMod
{
QTC_ASSERT(contextMenu, return);
d->m_contextMenuEntry = entry;
d->m_contextMenuDocument = entry ? entry->document : nullptr;
d->m_contextMenuEditor = editor;
const FilePath filePath = entry ? entry->filePath() : FilePath();
@@ -2943,6 +2944,7 @@ void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentM
{
QTC_ASSERT(contextMenu, return);
d->m_contextMenuEntry = entry;
d->m_contextMenuDocument = entry ? entry->document : nullptr;
bool enabled = entry && !entry->filePath().isEmpty();
d->m_openGraphicalShellContextAction->setEnabled(enabled);
d->m_showInFileSystemViewContextAction->setEnabled(enabled);

View File

@@ -252,7 +252,8 @@ private:
QAction *m_filePropertiesAction = nullptr;
QAction *m_pinAction = nullptr;
DocumentModel::Entry *m_contextMenuEntry = nullptr;
IEditor *m_contextMenuEditor = nullptr;
QPointer<IDocument> m_contextMenuDocument;
QPointer<IEditor> m_contextMenuEditor;
OpenEditorsWindow *m_windowPopup = nullptr;

View File

@@ -201,6 +201,9 @@ bool OpenEditorsWindow::eventFilter(QObject *obj, QEvent *e)
auto ke = static_cast<QKeyEvent*>(e);
qCDebug(openEditorsLog()) << ke;
if (ke->modifiers() == 0
/* On some platforms, the key event can claim both that Ctrl is released and that
Ctrl is still pressed, see QTCREATORBUG-31228 */
|| (ke->modifiers() == Qt::ControlModifier && ke->key() == Qt::Key_Control)
/*HACK this is to overcome some event inconsistencies between platforms*/
|| (ke->modifiers() == Qt::AltModifier
&& (ke->key() == Qt::Key_Alt || ke->key() == -1))) {

View File

@@ -848,7 +848,7 @@ QList<IContext *> ICore::currentContextObjects()
Returns the widget of the top level IContext of the current context, or \c
nullptr if there is none.
\sa currentContextObject()
\sa currentContextObjects()
*/
QWidget *ICore::currentContextWidget()
{
@@ -2256,7 +2256,7 @@ QList<IContext *> ICore::contextObjects(QWidget *widget)
\sa removeContextObject()
\sa updateAdditionalContexts()
\sa currentContextObject()
\sa currentContextObjects()
\sa {The Action Manager and Commands}
*/
@@ -2275,7 +2275,7 @@ void ICore::addContextObject(IContext *context)
\sa addContextObject()
\sa updateAdditionalContexts()
\sa currentContextObject()
\sa currentContextObjects()
*/
void ICore::removeContextObject(IContext *context)

View File

@@ -293,7 +293,16 @@ void OutputWindow::contextMenuEvent(QContextMenuEvent *event)
menu->addSeparator();
QAction *saveAction = menu->addAction(Tr::tr("Save Contents..."));
connect(saveAction, &QAction::triggered, this, [this] {
QFileDialog::saveFileContent(toPlainText().toUtf8(), d->outputFileNameHint);
const FilePath file = FileUtils::getSaveFilePath(
ICore::dialogParent(), {}, FileUtils::homePath() / d->outputFileNameHint);
if (!file.isEmpty()) {
QString error;
Utils::TextFileFormat format;
format.codec = EditorManager::defaultTextCodec();
format.lineTerminationMode = EditorManager::defaultLineEnding();
if (!format.writeFile(file, toPlainText(), &error))
MessageManager::writeDisrupting(error);
}
});
saveAction->setEnabled(!document()->isEmpty());
QAction *openAction = menu->addAction(Tr::tr("Copy Contents to Scratch Buffer"));

View File

@@ -146,6 +146,7 @@ void DebuggerItem::reinitializeFromFile(QString *error, Utils::Environment *cust
}
Environment env = customEnv ? *customEnv : m_command.deviceEnvironment();
DebuggerItem::addAndroidLldbPythonEnv(m_command, env);
// QNX gdb unconditionally checks whether the QNX_TARGET env variable is
// set and bails otherwise, even when it is not used by the specific

View File

@@ -575,9 +575,11 @@ void DebuggerRunTool::start()
connect(engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) {
auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
rc->copyDataFromRunControl(runControl());
rc->resetDataForAttachToCore();
auto name = QString(Tr::tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter));
auto debugger = new DebuggerRunTool(rc);
debugger->setStartMode(AttachToCore);
debugger->setCloseMode(DetachAtClose);
debugger->setRunControlName(name);
debugger->setCoreFilePath(FilePath::fromString(coreFile), true);
debugger->startRunControl();

View File

@@ -282,6 +282,8 @@ public:
}
});
connect(ExtensionSystem::PluginManager::instance(),
&ExtensionSystem::PluginManager::pluginsChanged, this, &PluginStatusWidget::update);
connect(m_restartButton, &QAbstractButton::clicked,
ICore::instance(), &ICore::restart, Qt::QueuedConnection);
@@ -429,6 +431,7 @@ ExtensionManagerWidget::ExtensionManagerWidget()
m_linksTitle = sectionTitle(h6CapitalTF, Tr::tr("More information"));
m_links = tfLabel(contentTF, false);
m_links->setOpenExternalLinks(true);
m_links->setTextInteractionFlags(Qt::TextBrowserInteraction);
m_imageTitle = sectionTitle(h6CapitalTF, {});
m_image = new QLabel;
m_imageMovie.setDevice(&m_imageDataBuffer);

View File

@@ -25,4 +25,17 @@ QtcPlugin {
"haskelltokenizer.cpp", "haskelltokenizer.h",
"stackbuildstep.cpp", "stackbuildstep.h"
]
Qt.core.resourceFileBaseName: "HaskellWizards" // avoid conflicting qrc file
Group {
name: "Wizard files"
Qt.core.resourceSourceBase: sourceDirectory
Qt.core.resourcePrefix: "haskell/"
fileTags: "qt.core.resource_data"
prefix: "share/wizards/"
files: [
"module/file.hs",
"module/wizard.json",
]
}
}

View File

@@ -10,6 +10,11 @@ QtcPlugin {
Depends { name: "sol2" }
Depends { name: "TextEditor" }
Properties {
condition: qbs.toolchain.contains("mingw")
cpp.optimization: "fast"
}
files: [
// "generateqtbindings.cpp", // use this if you need to generate some code
"lua_global.h",

View File

@@ -85,7 +85,7 @@ static QString translatedOrUntranslatedText(QVariantMap &map, const QString &key
{
if (key.size() >= 1) {
const QString trKey = "tr" + key.at(0).toUpper() + key.mid(1); // "text" -> "trText"
const QString trValue = JsonWizardFactory::localizedString(consumeValue(map, trKey).toString());
const QString trValue = JsonWizardFactory::localizedString(consumeValue(map, trKey));
if (!trValue.isEmpty())
return trValue;
}
@@ -188,9 +188,10 @@ JsonFieldPage::Field *JsonFieldPage::Field::parse(const QVariant &input, QString
*errorMessage = Tr::tr("Field \"%1\" has unsupported type \"%2\".").arg(name).arg(type);
return nullptr;
}
data->setTexts(name,
JsonWizardFactory::localizedString(consumeValue(tmp, DISPLAY_NAME_KEY).toString()),
JsonWizardFactory::localizedString(consumeValue(tmp, TOOLTIP_KEY).toString()));
data->setTexts(
name,
JsonWizardFactory::localizedString(consumeValue(tmp, DISPLAY_NAME_KEY)),
JsonWizardFactory::localizedString(consumeValue(tmp, TOOLTIP_KEY)));
data->setVisibleExpression(consumeValue(tmp, VISIBLE_KEY, true));
data->setEnabledExpression(consumeValue(tmp, ENABLED_KEY, true));
@@ -837,6 +838,7 @@ void PathChooserField::setup(JsonFieldPage *page, const QString &name)
QTC_ASSERT(w, return);
page->registerFieldWithName(name, w, "path", SIGNAL(textChanged(QString)));
QObject::connect(w, &PathChooser::textChanged, page, &WizardPage::completeChanged);
QObject::connect(w, &PathChooser::validChanged, page, &WizardPage::completeChanged);
}
bool PathChooserField::validate(MacroExpander *expander, QString *message)
@@ -973,7 +975,7 @@ std::unique_ptr<QStandardItem> createStandardItemFromListItem(const QVariant &it
auto standardItem = std::make_unique<QStandardItem>();
if (item.typeId() == QMetaType::QVariantMap) {
QVariantMap tmp = item.toMap();
const QString key = JsonWizardFactory::localizedString(consumeValue(tmp, "trKey", QString()).toString());
const QString key = JsonWizardFactory::localizedString(consumeValue(tmp, "trKey"));
const QVariant value = consumeValue(tmp, "value", key);
if (key.isNull() || key.isEmpty()) {
@@ -984,7 +986,7 @@ std::unique_ptr<QStandardItem> createStandardItemFromListItem(const QVariant &it
standardItem->setData(value, ListField::ValueRole);
standardItem->setData(consumeValue(tmp, "condition", true), ListField::ConditionRole);
standardItem->setData(consumeValue(tmp, "icon"), ListField::IconStringRole);
standardItem->setToolTip(JsonWizardFactory::localizedString(consumeValue(tmp, "trToolTip", QString()).toString()));
standardItem->setToolTip(JsonWizardFactory::localizedString(consumeValue(tmp, "trToolTip")));
warnAboutUnsupportedKeys(tmp, QString(), "List");
} else {
const QString keyvalue = item.toString();

View File

@@ -769,10 +769,9 @@ QString JsonWizardFactory::localizedString(const QVariant &value)
return {};
if (value.typeId() == QMetaType::QVariantMap) {
QVariantMap tmp = value.toMap();
const QString locale = languageSetting().toLower();
QStringList locales;
locales << locale << QLatin1String("en") << QLatin1String("C") << tmp.keys();
for (const QString &locale : std::as_const(locales)) {
const QString currentLocale = languageSetting().toLower();
const QStringList locales{currentLocale, "en", "C"};
for (const QString &locale : locales) {
QString result = tmp.value(locale, QString()).toString();
if (!result.isEmpty())
return result;

View File

@@ -364,6 +364,12 @@ void RunControl::copyDataFromRunControl(RunControl *runControl)
d->copyData(runControl->d.get());
}
void RunControl::resetDataForAttachToCore()
{
d->m_workers.clear();
d->state = RunControlState::Initialized;
}
void RunControl::copyDataFromRunConfiguration(RunConfiguration *runConfig)
{
QTC_ASSERT(runConfig, return);

View File

@@ -150,6 +150,7 @@ public:
void copyDataFromRunConfiguration(RunConfiguration *runConfig);
void copyDataFromRunControl(RunControl *runControl);
void resetDataForAttachToCore();
void setAutoDeleteOnStop(bool autoDelete);

View File

@@ -49,11 +49,6 @@ TextEditorView::TextEditorView(ExternalDependenciesInterface &externalDependenci
: AbstractView{externalDependencies}
, m_widget(new TextEditorWidget(this))
{
IContext::attach(m_widget,
Context(Constants::C_QMLTEXTEDITOR, Constants::C_QT_QUICK_TOOLS_MENU),
[this](const IContext::HelpCallback &callback) {
m_widget->contextHelp(callback);
});
}
TextEditorView::~TextEditorView()
@@ -70,7 +65,11 @@ void TextEditorView::modelAttached(Model *model)
auto textEditor = Utils::UniqueObjectLatePtr<TextEditor::BaseTextEditor>(
QmlDesignerPlugin::instance()->currentDesignDocument()->textEditor()->duplicate());
IContext::attach(textEditor->widget(),
Context(Constants::C_QMLTEXTEDITOR, Constants::C_QT_QUICK_TOOLS_MENU),
[this](const IContext::HelpCallback &callback) {
m_widget->contextHelp(callback);
});
m_widget->setTextEditor(std::move(textEditor));
}

View File

@@ -63,7 +63,8 @@ const char CUSTOM_COMMAND[] = "QmlJSEditor.useCustomFormatCommand";
const char CUSTOM_ANALYZER[] = "QmlJSEditor.useCustomAnalyzer";
const char DISABLED_MESSAGES[] = "QmlJSEditor.disabledMessages";
const char DISABLED_MESSAGES_NONQUICKUI[] = "QmlJSEditor.disabledMessagesNonQuickUI";
const char DEFAULT_CUSTOM_FORMAT_COMMAND[] = "%{CurrentDocument:Project:QT_HOST_BINS}/qmlformat";
const char DEFAULT_CUSTOM_FORMAT_COMMAND[]
= "%{CurrentDocument:Project:QT_HOST_BINS}/qmlformat%{HostOs:ExecutableSuffix}";
QmlJsEditingSettings &settings()
{

View File

@@ -127,12 +127,15 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
bool QmlJSHoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Document::Ptr &qmlDocument,
const ObjectValue *value, const QStringList &qName)
{
QString moduleName = getModuleName(scopeChain, qmlDocument, value);
const QString moduleName = getModuleName(scopeChain, qmlDocument, value);
static const QRegularExpression anyVersion("((-1|\\d+)\\.-1)|(\\d+\\.\\d+)$");
QStringList helpIdCandidates;
QStringList helpIdPieces(qName);
helpIdPieces.prepend(moduleName);
QString strippedModuleName = moduleName;
strippedModuleName.remove(anyVersion);
helpIdPieces.prepend(strippedModuleName);
helpIdPieces.prepend("QML");
helpIdCandidates += helpIdPieces.join('.');
@@ -155,8 +158,8 @@ bool QmlJSHoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Docum
const HelpItem::Links links = helpItem.links();
// Check if the module name contains a major version.
QRegularExpression version("^([^\\d]*)(\\d+)\\.*\\d*$");
QRegularExpressionMatch m = version.match(moduleName);
static QRegularExpression version("^([^\\d]*)(\\d+)\\.*\\d*$");
const QRegularExpressionMatch m = version.match(moduleName);
if (m.hasMatch()) {
QMap<QString, QUrl> filteredUrlMap;
const QString maj = m.captured(2);

View File

@@ -49,7 +49,7 @@ QString uniqueProjectName(const QString &path)
/***********************/
QdsNewDialog::QdsNewDialog(QWidget *parent)
: m_dialog{new QQuickWidget(parent)}
: m_dialog{Utils::makeUniqueObjectPtr<QQuickWidget>(parent)}
, m_categoryModel{new PresetCategoryModel(&m_presetData, this)}
, m_presetModel{new PresetModel(&m_presetData, this)}
, m_screenSizeModel{new ScreenSizeModel(this)}
@@ -57,7 +57,7 @@ QdsNewDialog::QdsNewDialog(QWidget *parent)
, m_recentsStore{"RecentPresets.json", StorePolicy::UniqueValues}
, m_userPresetsStore{"UserPresets.json", StorePolicy::UniqueNames}
{
setParent(m_dialog);
connect(m_dialog.get(), &QObject::destroyed, this, &QObject::deleteLater);
m_recentsStore.setReverseOrder();
m_recentsStore.setMaximum(10);
@@ -89,9 +89,10 @@ QdsNewDialog::QdsNewDialog(QWidget *parent)
m_dialog->installEventFilter(this);
QObject::connect(&m_wizard, &WizardHandler::wizardCreationFailed, this, [this] {
QMessageBox::critical(m_dialog, tr("New Project"), tr("Failed to initialize data."));
// TODO: if the dialog itself could react on the error
// the would not be necessary
QMessageBox::critical(m_dialog.get(), tr("New Project"), tr("Failed to initialize data."));
reject();
deleteLater();
});
QObject::connect(m_styleModel.data(), &StyleModel::modelAboutToBeReset, this, [this] {
@@ -101,7 +102,7 @@ QdsNewDialog::QdsNewDialog(QWidget *parent)
bool QdsNewDialog::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_dialog && event->type() == QEvent::KeyPress
if (obj == m_dialog.get() && event->type() == QEvent::KeyPress
&& static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape) {
reject();
return true;
@@ -314,7 +315,7 @@ void QdsNewDialog::setWizardFactories(QList<Core::IWizardFactory *> factories_,
{
Utils::Id platform = Utils::Id::fromSetting("Desktop");
WizardFactories factories{factories_, m_dialog, platform};
WizardFactories factories{factories_, m_dialog.get(), platform};
std::vector<UserPresetData> recents = m_recentsStore.fetchAll();
std::vector<UserPresetData> userPresets = m_userPresetsStore.fetchAll();
@@ -404,8 +405,6 @@ void QdsNewDialog::accept()
m_recentsStore.save(preset);
m_dialog->close();
m_dialog->deleteLater();
m_dialog = nullptr;
}
void QdsNewDialog::reject()
@@ -415,12 +414,13 @@ void QdsNewDialog::reject()
m_wizard.destroyWizard();
m_dialog->close();
m_dialog = nullptr;
m_dialog.reset();
}
QString QdsNewDialog::chooseProjectLocation()
{
Utils::FilePath newPath = Utils::FileUtils::getExistingDirectory(m_dialog, tr("Choose Directory"),
Utils::FilePath newPath = Utils::FileUtils::getExistingDirectory(m_dialog.get(),
tr("Choose Directory"),
m_qmlProjectLocation);
return QDir::toNativeSeparators(newPath.toString());
@@ -473,7 +473,7 @@ void QdsNewDialog::savePresetDialogAccept()
UserPresetData preset = currentUserPresetData(m_qmlPresetName);
if (!m_userPresetsStore.save(preset)) {
QMessageBox::warning(m_dialog,
QMessageBox::warning(m_dialog.get(),
tr("Save Preset"),
tr("A preset with this name already exists."));
return;

View File

@@ -7,6 +7,7 @@
#include <coreplugin/dialogs/newdialog.h>
#include <utils/infolabel.h>
#include <utils/uniqueobjectptr.h>
#include "wizardhandler.h"
#include "presetmodel.h"
@@ -64,7 +65,7 @@ public:
explicit QdsNewDialog(QWidget *parent);
QWidget *widget() override { return m_dialog; }
QWidget *widget() override { return m_dialog.get(); }
void setWizardFactories(QList<Core::IWizardFactory *> factories, const Utils::FilePath &defaultLocation,
const QVariantMap &extraVariables) override;
@@ -139,7 +140,7 @@ private slots:
void onWizardCreated(QStandardItemModel *screenSizeModel, QStandardItemModel *styleModel);
private:
QQuickWidget *m_dialog = nullptr;
Utils::UniqueObjectPtr<QQuickWidget> m_dialog;
PresetData m_presetData;
QPointer<PresetCategoryModel> m_categoryModel;

View File

@@ -53,7 +53,10 @@ void WizardHandler::setupWizard()
initializeProjectPage(m_wizard->page(0));
initializeFieldsPage(m_wizard->page(1));
if (!m_detailsPage) {
emit wizardCreationFailed();
return;
}
auto *screenFactorModel = getScreenFactorModel(m_detailsPage);
auto *styleModel = getStyleModel(m_detailsPage);