forked from qt-creator/qt-creator
QmlJSEditor: Remove unneeded indirection via qmljsicontextpane.h
Change-Id: I39989fdb697dc7078a01f9582b790ee91021e3ab Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -32,7 +32,6 @@ add_qtc_library(QmlJS
|
|||||||
qmljsevaluate.cpp qmljsevaluate.h
|
qmljsevaluate.cpp qmljsevaluate.h
|
||||||
qmljsfindexportedcpptypes.cpp qmljsfindexportedcpptypes.h
|
qmljsfindexportedcpptypes.cpp qmljsfindexportedcpptypes.h
|
||||||
qmljsicons.cpp qmljsicons.h
|
qmljsicons.cpp qmljsicons.h
|
||||||
qmljsicontextpane.h
|
|
||||||
qmljsimportdependencies.cpp qmljsimportdependencies.h
|
qmljsimportdependencies.cpp qmljsimportdependencies.h
|
||||||
qmljsindenter.cpp qmljsindenter.h
|
qmljsindenter.cpp qmljsindenter.h
|
||||||
qmljsinterpreter.cpp qmljsinterpreter.h
|
qmljsinterpreter.cpp qmljsinterpreter.h
|
||||||
|
@@ -30,7 +30,6 @@ Project {
|
|||||||
"qmljsevaluate.cpp", "qmljsevaluate.h",
|
"qmljsevaluate.cpp", "qmljsevaluate.h",
|
||||||
"qmljsfindexportedcpptypes.cpp", "qmljsfindexportedcpptypes.h",
|
"qmljsfindexportedcpptypes.cpp", "qmljsfindexportedcpptypes.h",
|
||||||
"qmljsicons.cpp", "qmljsicons.h",
|
"qmljsicons.cpp", "qmljsicons.h",
|
||||||
"qmljsicontextpane.h",
|
|
||||||
"qmljsimportdependencies.cpp", "qmljsimportdependencies.h",
|
"qmljsimportdependencies.cpp", "qmljsimportdependencies.h",
|
||||||
"qmljsindenter.cpp", "qmljsindenter.h",
|
"qmljsindenter.cpp", "qmljsindenter.h",
|
||||||
"qmljsinterpreter.cpp", "qmljsinterpreter.h",
|
"qmljsinterpreter.cpp", "qmljsinterpreter.h",
|
||||||
|
@@ -1,34 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "qmljs_global.h"
|
|
||||||
|
|
||||||
#include <qmljs/qmljsdocument.h>
|
|
||||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
|
||||||
|
|
||||||
namespace TextEditor { class TextEditorWidget; }
|
|
||||||
|
|
||||||
namespace QmlJS {
|
|
||||||
|
|
||||||
class ScopeChain;
|
|
||||||
|
|
||||||
class QMLJS_EXPORT IContextPane : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
IContextPane(QObject *parent = nullptr) : QObject(parent) {}
|
|
||||||
virtual ~IContextPane() {}
|
|
||||||
virtual void apply(TextEditor::TextEditorWidget *editorWidget, Document::Ptr document, const ScopeChain *scopeChain, AST::Node *node, bool update, bool force = false) = 0;
|
|
||||||
virtual void setEnabled(bool) = 0;
|
|
||||||
virtual bool isAvailable(TextEditor::TextEditorWidget *editorWidget, Document::Ptr document, AST::Node *node) = 0;
|
|
||||||
virtual QWidget* widget() = 0;
|
|
||||||
signals:
|
|
||||||
void closed();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlJS
|
|
@@ -126,7 +126,7 @@ void QmlJSEditorWidget::finalizeInitialization()
|
|||||||
if (m_contextPane) {
|
if (m_contextPane) {
|
||||||
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
|
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
|
||||||
&m_contextPaneTimer, QOverload<>::of(&QTimer::start));
|
&m_contextPaneTimer, QOverload<>::of(&QTimer::start));
|
||||||
connect(m_contextPane, &IContextPane::closed, this, &QmlJSEditorWidget::showTextMarker);
|
connect(m_contextPane, &QuickToolBar::closed, this, &QmlJSEditorWidget::showTextMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this->document(), &QTextDocument::modificationChanged,
|
connect(this->document(), &QTextDocument::modificationChanged,
|
||||||
|
@@ -337,13 +337,11 @@ void QuickToolBar::setEnabled(bool b)
|
|||||||
widget()->hide();
|
widget()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *QuickToolBar::widget()
|
||||||
QWidget* QuickToolBar::widget()
|
|
||||||
{
|
{
|
||||||
return contextWidget();
|
return contextWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QuickToolBar::onPropertyChanged(const QString &name, const QVariant &value)
|
void QuickToolBar::onPropertyChanged(const QString &name, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (m_blockWriting)
|
if (m_blockWriting)
|
||||||
@@ -411,7 +409,7 @@ void QuickToolBar::indentLines(int startLine, int endLine)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextPaneWidget* QuickToolBar::contextWidget()
|
ContextPaneWidget *QuickToolBar::contextWidget()
|
||||||
{
|
{
|
||||||
if (m_widget.isNull()) { //lazily recreate widget
|
if (m_widget.isNull()) { //lazily recreate widget
|
||||||
m_widget = new ContextPaneWidget;
|
m_widget = new ContextPaneWidget;
|
||||||
@@ -425,7 +423,8 @@ ContextPaneWidget* QuickToolBar::contextWidget()
|
|||||||
this, &QuickToolBar::onEnabledChanged);
|
this, &QuickToolBar::onEnabledChanged);
|
||||||
connect(m_widget.data(), &ContextPaneWidget::pinnedChanged,
|
connect(m_widget.data(), &ContextPaneWidget::pinnedChanged,
|
||||||
this, &QuickToolBar::onPinnedChanged);
|
this, &QuickToolBar::onPinnedChanged);
|
||||||
connect(m_widget.data(), &ContextPaneWidget::closed, this, &IContextPane::closed);
|
connect(m_widget.data(), &ContextPaneWidget::closed,
|
||||||
|
this, &QuickToolBar::closed);
|
||||||
}
|
}
|
||||||
return m_widget.data();
|
return m_widget.data();
|
||||||
}
|
}
|
||||||
|
@@ -3,30 +3,35 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <qmljs/qmljsicontextpane.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
namespace TextEditor { class TextEditorWidget; }
|
||||||
|
|
||||||
|
namespace QmlJS { class ScopeChain; }
|
||||||
|
|
||||||
namespace QmlEditorWidgets { class ContextPaneWidget; }
|
namespace QmlEditorWidgets { class ContextPaneWidget; }
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
|
|
||||||
class QuickToolBar : public QmlJS::IContextPane
|
class QuickToolBar : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QuickToolBar();
|
QuickToolBar();
|
||||||
public:
|
public:
|
||||||
~QuickToolBar() override;
|
~QuickToolBar();
|
||||||
|
|
||||||
static QuickToolBar *instance();
|
static QuickToolBar *instance();
|
||||||
|
|
||||||
void apply(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, const QmlJS::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false) override;
|
void apply(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, const QmlJS::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false);
|
||||||
bool isAvailable(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, QmlJS::AST::Node *node) override;
|
bool isAvailable(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, QmlJS::AST::Node *node);
|
||||||
void setProperty(const QString &propertyName, const QVariant &value);
|
void setProperty(const QString &propertyName, const QVariant &value);
|
||||||
void removeProperty(const QString &propertyName);
|
void removeProperty(const QString &propertyName);
|
||||||
void setEnabled(bool) override;
|
void setEnabled(bool);
|
||||||
QWidget* widget() override;
|
QWidget *widget();
|
||||||
|
|
||||||
void onPropertyChanged(const QString &, const QVariant &);
|
void onPropertyChanged(const QString &, const QVariant &);
|
||||||
void onPropertyRemoved(const QString &);
|
void onPropertyRemoved(const QString &);
|
||||||
@@ -34,6 +39,9 @@ public:
|
|||||||
void onPinnedChanged(bool);
|
void onPinnedChanged(bool);
|
||||||
void onEnabledChanged(bool);
|
void onEnabledChanged(bool);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void closed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void indentLines(int startLine, int endLine);
|
void indentLines(int startLine, int endLine);
|
||||||
|
|
||||||
@@ -48,4 +56,4 @@ private:
|
|||||||
QString m_oldType;
|
QString m_oldType;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //QmlDesigner
|
} // QmlJSEditor
|
||||||
|
Reference in New Issue
Block a user