forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.2'
Change-Id: Ib466094b4d234869cd7e122830ca4f9a11667e58
This commit is contained in:
@@ -219,8 +219,12 @@ class Dumper(DumperBase):
|
|||||||
base = nativeType.GetVirtualBaseClassAtIndex(i)
|
base = nativeType.GetVirtualBaseClassAtIndex(i)
|
||||||
virtualNames[base.GetName()] = i
|
virtualNames[base.GetName()] = i
|
||||||
|
|
||||||
fieldBits = dict((field.name, (field.GetBitfieldSizeInBits(), field.GetOffsetInBits()))
|
fieldBits = dict((f.name,
|
||||||
for field in nativeType.get_fields_array())
|
((f.GetBitfieldSizeInBits()
|
||||||
|
if f.GetBitfieldSizeInBits() else
|
||||||
|
(f.GetType().GetByteSize() * 8)),
|
||||||
|
f.GetOffsetInBits()))
|
||||||
|
for f in nativeType.get_fields_array())
|
||||||
|
|
||||||
#warn("BASE NAMES: %s" % baseNames)
|
#warn("BASE NAMES: %s" % baseNames)
|
||||||
#warn("VIRTUAL NAMES: %s" % virtualNames)
|
#warn("VIRTUAL NAMES: %s" % virtualNames)
|
||||||
@@ -279,7 +283,7 @@ class Dumper(DumperBase):
|
|||||||
field.parentType = fieldParentType
|
field.parentType = fieldParentType
|
||||||
field.ltype = self.fromNativeType(fieldType)
|
field.ltype = self.fromNativeType(fieldType)
|
||||||
field.name = fieldName
|
field.name = fieldName
|
||||||
field.lbitsize = 0
|
field.lbitsize = field.ltype.lbitsize * 8
|
||||||
field.lbitpos = 0
|
field.lbitpos = 0
|
||||||
fields.append(field)
|
fields.append(field)
|
||||||
|
|
||||||
|
@@ -504,7 +504,9 @@ SynchronousProcessResponse SynchronousProcess::runBlocking(const QString &binary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(d->m_process.state() == QProcess::NotRunning, return d->m_result);
|
if (d->m_process.state() != QProcess::NotRunning)
|
||||||
|
return d->m_result;
|
||||||
|
|
||||||
d->m_result.exitCode = d->m_process.exitCode();
|
d->m_result.exitCode = d->m_process.exitCode();
|
||||||
if (d->m_result.result == SynchronousProcessResponse::StartFailed) {
|
if (d->m_result.result == SynchronousProcessResponse::StartFailed) {
|
||||||
if (d->m_process.exitStatus() != QProcess::NormalExit)
|
if (d->m_process.exitStatus() != QProcess::NormalExit)
|
||||||
|
@@ -254,6 +254,8 @@ CdbEngine::CdbEngine(const DebuggerRunParameters &sp) :
|
|||||||
this, &CdbEngine::readyReadStandardOut);
|
this, &CdbEngine::readyReadStandardOut);
|
||||||
connect(&m_process, &QProcess::readyReadStandardError,
|
connect(&m_process, &QProcess::readyReadStandardError,
|
||||||
this, &CdbEngine::readyReadStandardOut);
|
this, &CdbEngine::readyReadStandardOut);
|
||||||
|
connect(action(UseDebuggingHelpers), &SavedAction::valueChanged,
|
||||||
|
this, &CdbEngine::updateLocals);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::init()
|
void CdbEngine::init()
|
||||||
|
@@ -68,7 +68,6 @@ public:
|
|||||||
QString fallbackSaveAsPath() const override;
|
QString fallbackSaveAsPath() const override;
|
||||||
QString fallbackSaveAsFileName() const override;
|
QString fallbackSaveAsFileName() const override;
|
||||||
|
|
||||||
bool isModified() const override { return false; }
|
|
||||||
bool isSaveAsAllowed() const override { return true; }
|
bool isSaveAsAllowed() const override { return true; }
|
||||||
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
|
||||||
void reload();
|
void reload();
|
||||||
|
@@ -33,25 +33,189 @@
|
|||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QMenu>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/editormanager/documentmodel.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <texteditor/texteditor.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
namespace DiffEditor {
|
namespace DiffEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class FileDiffController : public DiffEditorController
|
class DiffFilesController : public DiffEditorController
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FileDiffController(Core::IDocument *document, const QString &leftFileName,
|
DiffFilesController(Core::IDocument *document);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FileData diffFiles(const QString &leftContents, const QString &rightContents);
|
||||||
|
};
|
||||||
|
|
||||||
|
DiffFilesController::DiffFilesController(Core::IDocument *document)
|
||||||
|
: DiffEditorController(document)
|
||||||
|
{}
|
||||||
|
|
||||||
|
FileData DiffFilesController::diffFiles(const QString &leftContents, const QString &rightContents)
|
||||||
|
{
|
||||||
|
Differ differ;
|
||||||
|
QList<Diff> diffList = differ.cleanupSemantics(differ.diff(leftContents, rightContents));
|
||||||
|
|
||||||
|
QList<Diff> leftDiffList;
|
||||||
|
QList<Diff> rightDiffList;
|
||||||
|
Differ::splitDiffList(diffList, &leftDiffList, &rightDiffList);
|
||||||
|
QList<Diff> outputLeftDiffList;
|
||||||
|
QList<Diff> outputRightDiffList;
|
||||||
|
|
||||||
|
if (ignoreWhitespace()) {
|
||||||
|
const QList<Diff> leftIntermediate
|
||||||
|
= Differ::moveWhitespaceIntoEqualities(leftDiffList);
|
||||||
|
const QList<Diff> rightIntermediate
|
||||||
|
= Differ::moveWhitespaceIntoEqualities(rightDiffList);
|
||||||
|
Differ::ignoreWhitespaceBetweenEqualities(leftIntermediate, rightIntermediate,
|
||||||
|
&outputLeftDiffList, &outputRightDiffList);
|
||||||
|
} else {
|
||||||
|
outputLeftDiffList = leftDiffList;
|
||||||
|
outputRightDiffList = rightDiffList;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ChunkData chunkData = DiffUtils::calculateOriginalData(
|
||||||
|
outputLeftDiffList, outputRightDiffList);
|
||||||
|
FileData fileData = DiffUtils::calculateContextData(chunkData, contextLineCount(), 0);
|
||||||
|
|
||||||
|
return fileData;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiffCurrentFileController : public DiffFilesController
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DiffCurrentFileController(Core::IDocument *document, const QString &fileName);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reload();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_fileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
DiffCurrentFileController::DiffCurrentFileController(Core::IDocument *document, const QString &fileName) :
|
||||||
|
DiffFilesController(document), m_fileName(fileName)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void DiffCurrentFileController::reload()
|
||||||
|
{
|
||||||
|
QList<FileData> fileDataList;
|
||||||
|
|
||||||
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||||
|
Core::DocumentModel::documentForFilePath(m_fileName));
|
||||||
|
|
||||||
|
if (textDocument && textDocument->isModified()) {
|
||||||
|
QString errorString;
|
||||||
|
Utils::TextFileFormat format = textDocument->format();
|
||||||
|
|
||||||
|
QString leftText;
|
||||||
|
bool leftFileExists = true;
|
||||||
|
if (Utils::TextFileFormat::readFile(m_fileName,
|
||||||
|
format.codec,
|
||||||
|
&leftText, &format, &errorString)
|
||||||
|
!= Utils::TextFileFormat::ReadSuccess) {
|
||||||
|
leftFileExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString rightText = textDocument->plainText();
|
||||||
|
|
||||||
|
FileData fileData = diffFiles(leftText, rightText);
|
||||||
|
fileData.leftFileInfo.fileName = m_fileName;
|
||||||
|
fileData.rightFileInfo.fileName = m_fileName;
|
||||||
|
fileData.leftFileInfo.typeInfo = tr("Saved");
|
||||||
|
fileData.rightFileInfo.typeInfo = tr("Modified");
|
||||||
|
|
||||||
|
if (!leftFileExists)
|
||||||
|
fileData.fileOperation = FileData::NewFile;
|
||||||
|
|
||||||
|
fileDataList << fileData;
|
||||||
|
}
|
||||||
|
|
||||||
|
setDiffFiles(fileDataList);
|
||||||
|
reloadFinished(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
|
||||||
|
class DiffAllModifiedFilesController : public DiffFilesController
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DiffAllModifiedFilesController(Core::IDocument *document);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
DiffAllModifiedFilesController::DiffAllModifiedFilesController(Core::IDocument *document) :
|
||||||
|
DiffFilesController(document)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void DiffAllModifiedFilesController::reload()
|
||||||
|
{
|
||||||
|
QList<Core::IDocument *> openedDocuments =
|
||||||
|
Core::DocumentModel::openedDocuments();
|
||||||
|
|
||||||
|
QList<FileData> fileDataList;
|
||||||
|
|
||||||
|
foreach (Core::IDocument *doc, openedDocuments) {
|
||||||
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(doc);
|
||||||
|
|
||||||
|
if (textDocument && textDocument->isModified()) {
|
||||||
|
QString errorString;
|
||||||
|
Utils::TextFileFormat format = textDocument->format();
|
||||||
|
|
||||||
|
QString leftText;
|
||||||
|
bool leftFileExists = true;
|
||||||
|
const QString fileName = textDocument->filePath().toString();
|
||||||
|
if (Utils::TextFileFormat::readFile(fileName,
|
||||||
|
format.codec,
|
||||||
|
&leftText, &format, &errorString)
|
||||||
|
!= Utils::TextFileFormat::ReadSuccess) {
|
||||||
|
leftFileExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString rightText = textDocument->plainText();
|
||||||
|
|
||||||
|
FileData fileData = diffFiles(leftText, rightText);
|
||||||
|
fileData.leftFileInfo.fileName = fileName;
|
||||||
|
fileData.rightFileInfo.fileName = fileName;
|
||||||
|
fileData.leftFileInfo.typeInfo = tr("Saved");
|
||||||
|
fileData.rightFileInfo.typeInfo = tr("Modified");
|
||||||
|
|
||||||
|
if (!leftFileExists)
|
||||||
|
fileData.fileOperation = FileData::NewFile;
|
||||||
|
|
||||||
|
fileDataList << fileData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setDiffFiles(fileDataList);
|
||||||
|
reloadFinished(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
|
||||||
|
class DiffExternalFilesController : public DiffFilesController
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DiffExternalFilesController(Core::IDocument *document, const QString &leftFileName,
|
||||||
const QString &rightFileName);
|
const QString &rightFileName);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -62,12 +226,12 @@ private:
|
|||||||
QString m_rightFileName;
|
QString m_rightFileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
FileDiffController::FileDiffController(Core::IDocument *document, const QString &leftFileName,
|
DiffExternalFilesController::DiffExternalFilesController(Core::IDocument *document, const QString &leftFileName,
|
||||||
const QString &rightFileName) :
|
const QString &rightFileName) :
|
||||||
DiffEditorController(document), m_leftFileName(leftFileName), m_rightFileName(rightFileName)
|
DiffFilesController(document), m_leftFileName(leftFileName), m_rightFileName(rightFileName)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void FileDiffController::reload()
|
void DiffExternalFilesController::reload()
|
||||||
{
|
{
|
||||||
QString errorString;
|
QString errorString;
|
||||||
Utils::TextFileFormat format;
|
Utils::TextFileFormat format;
|
||||||
@@ -91,30 +255,7 @@ void FileDiffController::reload()
|
|||||||
rightFileExists = false;
|
rightFileExists = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Differ differ;
|
FileData fileData = diffFiles(leftText, rightText);
|
||||||
QList<Diff> diffList = differ.cleanupSemantics(differ.diff(leftText, rightText));
|
|
||||||
|
|
||||||
QList<Diff> leftDiffList;
|
|
||||||
QList<Diff> rightDiffList;
|
|
||||||
Differ::splitDiffList(diffList, &leftDiffList, &rightDiffList);
|
|
||||||
QList<Diff> outputLeftDiffList;
|
|
||||||
QList<Diff> outputRightDiffList;
|
|
||||||
|
|
||||||
if (ignoreWhitespace()) {
|
|
||||||
const QList<Diff> leftIntermediate
|
|
||||||
= Differ::moveWhitespaceIntoEqualities(leftDiffList);
|
|
||||||
const QList<Diff> rightIntermediate
|
|
||||||
= Differ::moveWhitespaceIntoEqualities(rightDiffList);
|
|
||||||
Differ::ignoreWhitespaceBetweenEqualities(leftIntermediate, rightIntermediate,
|
|
||||||
&outputLeftDiffList, &outputRightDiffList);
|
|
||||||
} else {
|
|
||||||
outputLeftDiffList = leftDiffList;
|
|
||||||
outputRightDiffList = rightDiffList;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ChunkData chunkData = DiffUtils::calculateOriginalData(
|
|
||||||
outputLeftDiffList, outputRightDiffList);
|
|
||||||
FileData fileData = DiffUtils::calculateContextData(chunkData, contextLineCount(), 0);
|
|
||||||
fileData.leftFileInfo.fileName = m_leftFileName;
|
fileData.leftFileInfo.fileName = m_leftFileName;
|
||||||
fileData.rightFileInfo.fileName = m_rightFileName;
|
fileData.rightFileInfo.fileName = m_rightFileName;
|
||||||
if (!leftFileExists && rightFileExists)
|
if (!leftFileExists && rightFileExists)
|
||||||
@@ -123,6 +264,7 @@ void FileDiffController::reload()
|
|||||||
fileData.fileOperation = FileData::DeleteFile;
|
fileData.fileOperation = FileData::DeleteFile;
|
||||||
|
|
||||||
QList<FileData> fileDataList;
|
QList<FileData> fileDataList;
|
||||||
|
if (leftFileExists || rightFileExists)
|
||||||
fileDataList << fileData;
|
fileDataList << fileData;
|
||||||
|
|
||||||
setDiffFiles(fileDataList);
|
setDiffFiles(fileDataList);
|
||||||
@@ -140,11 +282,31 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
|||||||
Core::ActionContainer *toolsContainer
|
Core::ActionContainer *toolsContainer
|
||||||
= Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
= Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||||
toolsContainer->insertGroup(Core::Constants::G_TOOLS_OPTIONS, Constants::G_TOOLS_DIFF);
|
toolsContainer->insertGroup(Core::Constants::G_TOOLS_OPTIONS, Constants::G_TOOLS_DIFF);
|
||||||
|
Core::ActionContainer *diffContainer = Core::ActionManager::createMenu("Diff");
|
||||||
|
diffContainer->menu()->setTitle(tr("&Diff"));
|
||||||
|
toolsContainer->addMenu(diffContainer, Constants::G_TOOLS_DIFF);
|
||||||
|
|
||||||
QAction *diffAction = new QAction(tr("Diff..."), this);
|
m_diffCurrentFileAction = new QAction(tr("Diff Current File"), this);
|
||||||
Core::Command *diffCommand = Core::ActionManager::registerAction(diffAction, "DiffEditor.Diff");
|
Core::Command *diffCurrentFileCommand = Core::ActionManager::registerAction(m_diffCurrentFileAction, "DiffEditor.DiffCurrentFile");
|
||||||
connect(diffAction, &QAction::triggered, this, &DiffEditorPlugin::diff);
|
diffCurrentFileCommand->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H") : tr("Ctrl+H")));
|
||||||
toolsContainer->addAction(diffCommand, Constants::G_TOOLS_DIFF);
|
connect(m_diffCurrentFileAction, &QAction::triggered, this, &DiffEditorPlugin::diffCurrentFile);
|
||||||
|
diffContainer->addAction(diffCurrentFileCommand);
|
||||||
|
|
||||||
|
QAction *diffAllModifiedFilesAction = new QAction(tr("Diff All Modified Files"), this);
|
||||||
|
Core::Command *diffAllModifiedFilesCommand = Core::ActionManager::registerAction(diffAllModifiedFilesAction, "DiffEditor.DiffAllModifiedFiles");
|
||||||
|
diffAllModifiedFilesCommand->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+H") : tr("Ctrl+Shift+H")));
|
||||||
|
connect(diffAllModifiedFilesAction, &QAction::triggered, this, &DiffEditorPlugin::diffAllModifiedFiles);
|
||||||
|
diffContainer->addAction(diffAllModifiedFilesCommand);
|
||||||
|
|
||||||
|
QAction *diffExternalFilesAction = new QAction(tr("Diff External Files..."), this);
|
||||||
|
Core::Command *diffExternalFilesCommand = Core::ActionManager::registerAction(diffExternalFilesAction, "DiffEditor.DiffExternalFiles");
|
||||||
|
connect(diffExternalFilesAction, &QAction::triggered, this, &DiffEditorPlugin::diffExternalFiles);
|
||||||
|
diffContainer->addAction(diffExternalFilesCommand);
|
||||||
|
|
||||||
|
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
||||||
|
this, &DiffEditorPlugin::updateCurrentEditor);
|
||||||
|
|
||||||
|
updateActions();
|
||||||
|
|
||||||
addAutoReleasedObject(new DiffEditorFactory(this));
|
addAutoReleasedObject(new DiffEditorFactory(this));
|
||||||
|
|
||||||
@@ -154,15 +316,77 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
|||||||
void DiffEditorPlugin::extensionsInitialized()
|
void DiffEditorPlugin::extensionsInitialized()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void DiffEditorPlugin::diff()
|
void DiffEditorPlugin::updateCurrentEditor(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
QString fileName1 = QFileDialog::getOpenFileName(Core::ICore::dialogParent(),
|
if (m_currentTextDocument)
|
||||||
|
m_currentTextDocument->disconnect(this);
|
||||||
|
m_currentTextDocument = 0;
|
||||||
|
|
||||||
|
if (editor) {
|
||||||
|
TextEditor::TextEditorWidget *editorWidget = qobject_cast<TextEditor::TextEditorWidget *>(editor->widget());
|
||||||
|
if (editorWidget) {
|
||||||
|
m_currentTextDocument = editorWidget->textDocument();
|
||||||
|
connect(m_currentTextDocument.data(), &Core::IDocument::changed,
|
||||||
|
this, &DiffEditorPlugin::updateActions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiffEditorPlugin::updateActions()
|
||||||
|
{
|
||||||
|
const bool diffCurrentFileEnabled = m_currentTextDocument && m_currentTextDocument->isModified();
|
||||||
|
m_diffCurrentFileAction->setEnabled(diffCurrentFileEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiffEditorPlugin::diffCurrentFile()
|
||||||
|
{
|
||||||
|
if (!m_currentTextDocument)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString fileName = m_currentTextDocument->filePath().toString();
|
||||||
|
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString documentId = QLatin1String("Diff ") + fileName;
|
||||||
|
const QString title = tr("Diff \"%1\"").arg(fileName);
|
||||||
|
auto const document = qobject_cast<DiffEditorDocument *>(
|
||||||
|
DiffEditorController::findOrCreateDocument(documentId, title));
|
||||||
|
if (!document)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!DiffEditorController::controller(document))
|
||||||
|
new DiffCurrentFileController(document, fileName);
|
||||||
|
Core::EditorManager::activateEditorForDocument(document);
|
||||||
|
document->reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiffEditorPlugin::diffAllModifiedFiles()
|
||||||
|
{
|
||||||
|
const QString documentId = QLatin1String("Diff All Modified Files");
|
||||||
|
const QString title = tr("Diff All Modified Files");
|
||||||
|
auto const document = qobject_cast<DiffEditorDocument *>(
|
||||||
|
DiffEditorController::findOrCreateDocument(documentId, title));
|
||||||
|
if (!document)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!DiffEditorController::controller(document))
|
||||||
|
new DiffAllModifiedFilesController(document);
|
||||||
|
Core::EditorManager::activateEditorForDocument(document);
|
||||||
|
document->reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiffEditorPlugin::diffExternalFiles()
|
||||||
|
{
|
||||||
|
const QString fileName1 = QFileDialog::getOpenFileName(Core::ICore::dialogParent(),
|
||||||
tr("Select First File for Diff"),
|
tr("Select First File for Diff"),
|
||||||
QString());
|
QString());
|
||||||
if (fileName1.isNull())
|
if (fileName1.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString fileName2 = QFileDialog::getOpenFileName(Core::ICore::dialogParent(),
|
const QString fileName2 = QFileDialog::getOpenFileName(Core::ICore::dialogParent(),
|
||||||
tr("Select Second File for Diff"),
|
tr("Select Second File for Diff"),
|
||||||
QString());
|
QString());
|
||||||
if (fileName2.isNull())
|
if (fileName2.isNull())
|
||||||
@@ -170,14 +394,14 @@ void DiffEditorPlugin::diff()
|
|||||||
|
|
||||||
|
|
||||||
const QString documentId = QLatin1String("Diff ") + fileName1 + QLatin1String(", ") + fileName2;
|
const QString documentId = QLatin1String("Diff ") + fileName1 + QLatin1String(", ") + fileName2;
|
||||||
QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1).arg(fileName2);
|
const QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1, fileName2);
|
||||||
auto const document = qobject_cast<DiffEditorDocument *>(
|
auto const document = qobject_cast<DiffEditorDocument *>(
|
||||||
DiffEditorController::findOrCreateDocument(documentId, title));
|
DiffEditorController::findOrCreateDocument(documentId, title));
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!DiffEditorController::controller(document))
|
if (!DiffEditorController::controller(document))
|
||||||
new FileDiffController(document, fileName1, fileName2);
|
new DiffExternalFilesController(document, fileName1, fileName2);
|
||||||
Core::EditorManager::activateEditorForDocument(document);
|
Core::EditorManager::activateEditorForDocument(document);
|
||||||
document->reload();
|
document->reload();
|
||||||
}
|
}
|
||||||
|
@@ -27,8 +27,13 @@
|
|||||||
|
|
||||||
#include "diffeditor_global.h"
|
#include "diffeditor_global.h"
|
||||||
|
|
||||||
|
#include <texteditor/textdocument.h>
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||||
|
|
||||||
|
namespace Core { class IEditor; }
|
||||||
|
|
||||||
namespace DiffEditor {
|
namespace DiffEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -42,7 +47,11 @@ public:
|
|||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void diff();
|
void updateCurrentEditor(Core::IEditor *editor);
|
||||||
|
void updateActions();
|
||||||
|
void diffCurrentFile();
|
||||||
|
void diffAllModifiedFiles();
|
||||||
|
void diffExternalFiles();
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
void testMakePatch_data();
|
void testMakePatch_data();
|
||||||
@@ -50,6 +59,9 @@ private slots:
|
|||||||
void testReadPatch_data();
|
void testReadPatch_data();
|
||||||
void testReadPatch();
|
void testReadPatch();
|
||||||
#endif // WITH_TESTS
|
#endif // WITH_TESTS
|
||||||
|
private:
|
||||||
|
QAction *m_diffCurrentFileAction;
|
||||||
|
QPointer<TextEditor::TextDocument> m_currentTextDocument;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -622,7 +622,12 @@ void QbsProject::cancelParsing()
|
|||||||
void QbsProject::updateAfterBuild()
|
void QbsProject::updateAfterBuild()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_qbsProject.isValid(), return);
|
QTC_ASSERT(m_qbsProject.isValid(), return);
|
||||||
m_projectData = m_qbsProject.projectData();
|
const qbs::ProjectData &projectData = m_qbsProject.projectData();
|
||||||
|
if (projectData == m_projectData)
|
||||||
|
return;
|
||||||
|
qCDebug(qbsPmLog) << "Updating data after build";
|
||||||
|
m_projectData = projectData;
|
||||||
|
rootProjectNode()->update();
|
||||||
updateBuildTargetData();
|
updateBuildTargetData();
|
||||||
updateCppCompilerCallData();
|
updateCppCompilerCallData();
|
||||||
if (m_extraCompilersPending) {
|
if (m_extraCompilersPending) {
|
||||||
@@ -993,8 +998,6 @@ void QbsProject::updateDeploymentInfo()
|
|||||||
{
|
{
|
||||||
DeploymentData deploymentData;
|
DeploymentData deploymentData;
|
||||||
if (m_qbsProject.isValid()) {
|
if (m_qbsProject.isValid()) {
|
||||||
qbs::InstallOptions installOptions;
|
|
||||||
installOptions.setInstallRoot(QLatin1String("/"));
|
|
||||||
foreach (const qbs::ArtifactData &f, m_projectData.installableArtifacts()) {
|
foreach (const qbs::ArtifactData &f, m_projectData.installableArtifacts()) {
|
||||||
deploymentData.addFile(f.filePath(), f.installData().installDir(),
|
deploymentData.addFile(f.filePath(), f.installData().installDir(),
|
||||||
f.isExecutable() ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal);
|
f.isExecutable() ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal);
|
||||||
|
@@ -40,6 +40,7 @@ PuppetBuildProgressDialog::PuppetBuildProgressDialog() :
|
|||||||
m_useFallbackPuppet(false)
|
m_useFallbackPuppet(false)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::SplashScreen);
|
setWindowFlags(Qt::SplashScreen);
|
||||||
|
setWindowModality(Qt::ApplicationModal);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->buildProgressBar->setMaximum(85);
|
ui->buildProgressBar->setMaximum(85);
|
||||||
connect(ui->useFallbackPuppetPushButton, SIGNAL(clicked()), this, SLOT(setUseFallbackPuppet()));
|
connect(ui->useFallbackPuppetPushButton, SIGNAL(clicked()), this, SLOT(setUseFallbackPuppet()));
|
||||||
|
@@ -68,6 +68,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
|
|||||||
restoreValue(settings, DesignerSettingsKey::PUPPET_KILL_TIMEOUT, 3000); // this has no ui at the moment
|
restoreValue(settings, DesignerSettingsKey::PUPPET_KILL_TIMEOUT, 3000); // this has no ui at the moment
|
||||||
restoreValue(settings, DesignerSettingsKey::DEBUG_PUPPET, QString());
|
restoreValue(settings, DesignerSettingsKey::DEBUG_PUPPET, QString());
|
||||||
restoreValue(settings, DesignerSettingsKey::FORWARD_PUPPET_OUTPUT, QString());
|
restoreValue(settings, DesignerSettingsKey::FORWARD_PUPPET_OUTPUT, QString());
|
||||||
|
restoreValue(settings, DesignerSettingsKey::REFORMAT_UI_QML_FILES, true);
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
@@ -57,7 +57,9 @@ const char ENABLE_MODEL_EXCEPTION_OUTPUT[] = "WarnException";
|
|||||||
const char PUPPET_KILL_TIMEOUT[] = "PuppetKillTimeout";
|
const char PUPPET_KILL_TIMEOUT[] = "PuppetKillTimeout";
|
||||||
const char DEBUG_PUPPET[] = "DebugPuppet";
|
const char DEBUG_PUPPET[] = "DebugPuppet";
|
||||||
const char FORWARD_PUPPET_OUTPUT[] = "ForwardPuppetOutput";
|
const char FORWARD_PUPPET_OUTPUT[] = "ForwardPuppetOutput";
|
||||||
|
const char REFORMAT_UI_QML_FILES[] = "ReformatUiQmlFiles"; /* This Setting is not exposed in ui.
|
||||||
|
The setting can be used to turn off the feature,
|
||||||
|
if there are serious issues */
|
||||||
}
|
}
|
||||||
|
|
||||||
class DesignerSettings : public QHash<QByteArray, QVariant>
|
class DesignerSettings : public QHash<QByteArray, QVariant>
|
||||||
|
@@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@@ -170,6 +174,13 @@ bool DocumentWarningWidget::eventFilter(QObject *object, QEvent *event)
|
|||||||
|
|
||||||
void DocumentWarningWidget::showEvent(QShowEvent *event)
|
void DocumentWarningWidget::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
|
const QColor backgroundColor = Utils::creatorTheme()->color(Utils::Theme::QmlDesigner_BackgroundColor);
|
||||||
|
QPalette pal = palette();
|
||||||
|
QColor color = pal.color(QPalette::ToolTipBase);
|
||||||
|
const QColor backgroundNoAlpha = Utils::StyleHelper::alphaBlendedColors(color, backgroundColor);
|
||||||
|
color.setAlpha(255);
|
||||||
|
pal.setColor(QPalette::ToolTipBase, backgroundNoAlpha);
|
||||||
|
setPalette(pal);
|
||||||
m_gotoCodeWasClicked = false;
|
m_gotoCodeWasClicked = false;
|
||||||
moveToParentCenter();
|
moveToParentCenter();
|
||||||
refreshContent();
|
refreshContent();
|
||||||
|
@@ -13,6 +13,12 @@ QTableView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTabBar QToolButton {
|
||||||
|
background-color: creatorTheme.QmlDesignerBackgroundColorDarkAlternate;
|
||||||
|
border: 1px solid creatorTheme.QmlDesignerBackgroundColorDarker;
|
||||||
|
border-radius: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
QTableView::item
|
QTableView::item
|
||||||
{
|
{
|
||||||
border: 0px;
|
border: 0px;
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "shortcutmanager.h"
|
#include "shortcutmanager.h"
|
||||||
|
|
||||||
|
#include "designersettings.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
@@ -33,7 +35,13 @@
|
|||||||
#include <coreplugin/editormanager/documentmodel.h>
|
#include <coreplugin/editormanager/documentmodel.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <qmljseditor/qmljseditorconstants.h>
|
||||||
|
#include <qmljseditor/qmljseditordocument.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <qmljs/qmljsreformatter.h>
|
||||||
|
|
||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
#include "qmldesignerplugin.h"
|
#include "qmldesignerplugin.h"
|
||||||
@@ -106,13 +114,29 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
SLOT(toggleRightSidebar()));
|
SLOT(toggleRightSidebar()));
|
||||||
|
|
||||||
// Revert to saved
|
// Revert to saved
|
||||||
QObject *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
Core::ActionManager::registerAction(&m_revertToSavedAction,Core::Constants::REVERTTOSAVED, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_revertToSavedAction,Core::Constants::REVERTTOSAVED, qmlDesignerMainContext);
|
||||||
connect(&m_revertToSavedAction, SIGNAL(triggered()), em, SLOT(revertToSaved()));
|
connect(&m_revertToSavedAction, SIGNAL(triggered()), em, SLOT(revertToSaved()));
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
Core::ActionManager::registerAction(&m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext);
|
||||||
connect(&m_saveAction, SIGNAL(triggered()), em, SLOT(saveDocument()));
|
connect(&m_saveAction, &QAction::triggered, em, [em] {
|
||||||
|
DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
|
||||||
|
/* Reformat document if we have a .ui.qml file */
|
||||||
|
if (settings.value(DesignerSettingsKey::REFORMAT_UI_QML_FILES).toBool()
|
||||||
|
&& em->currentDocument()->filePath().toString().endsWith(".ui.qml"))
|
||||||
|
if (QmlJSEditor::QmlJSEditorDocument *document
|
||||||
|
= qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(em->currentDocument())) {
|
||||||
|
const QString &newText = QmlJS::reformat(document->semanticInfo().document);
|
||||||
|
QTextCursor tc(document->document());
|
||||||
|
tc.movePosition(QTextCursor::Start);
|
||||||
|
tc.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
|
||||||
|
tc.insertText(newText);
|
||||||
|
}
|
||||||
|
em->saveDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Save As
|
//Save As
|
||||||
Core::ActionManager::registerAction(&m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext);
|
||||||
|
@@ -113,8 +113,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
//#define DO_FOO
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\namespace TextEditor
|
\namespace TextEditor
|
||||||
\brief The TextEditor namespace contains the base text editor and several classes which
|
\brief The TextEditor namespace contains the base text editor and several classes which
|
||||||
@@ -727,14 +725,6 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc)
|
|||||||
QObject::connect(q, &QPlainTextEdit::selectionChanged,
|
QObject::connect(q, &QPlainTextEdit::selectionChanged,
|
||||||
this, &TextEditorWidgetPrivate::slotSelectionChanged);
|
this, &TextEditorWidgetPrivate::slotSelectionChanged);
|
||||||
|
|
||||||
// (void) new QShortcut(tr("CTRL+L"), this, SLOT(centerCursor()), 0, Qt::WidgetShortcut);
|
|
||||||
// (void) new QShortcut(tr("F9"), this, SLOT(slotToggleMark()), 0, Qt::WidgetShortcut);
|
|
||||||
// (void) new QShortcut(tr("F11"), this, SLOT(slotToggleBlockVisible()));
|
|
||||||
|
|
||||||
#ifdef DO_FOO
|
|
||||||
(void) new QShortcut(TextEditorWidget::tr("CTRL+D"), this, SLOT(doFoo()));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// parentheses matcher
|
// parentheses matcher
|
||||||
m_formatRange = true;
|
m_formatRange = true;
|
||||||
m_parenthesesMatchingTimer.setSingleShot(true);
|
m_parenthesesMatchingTimer.setSingleShot(true);
|
||||||
@@ -7217,19 +7207,6 @@ void TextEditorWidget::setRefactorMarkers(const RefactorMarkers &markers)
|
|||||||
requestBlockUpdate(marker.cursor.block());
|
requestBlockUpdate(marker.cursor.block());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorWidget::doFoo()
|
|
||||||
{
|
|
||||||
#ifdef DO_FOO
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
RefactorMarkers markers = d->m_refactorOverlay->markers();
|
|
||||||
RefactorMarker marker;
|
|
||||||
marker.tooltip = "Hello World";
|
|
||||||
marker.cursor = textCursor();
|
|
||||||
markers += marker;
|
|
||||||
setRefactorMarkers(markers);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
TextBlockSelection::TextBlockSelection(const TextBlockSelection &other)
|
TextBlockSelection::TextBlockSelection(const TextBlockSelection &other)
|
||||||
{
|
{
|
||||||
positionBlock = other.positionBlock;
|
positionBlock = other.positionBlock;
|
||||||
|
@@ -593,8 +593,6 @@ protected slots:
|
|||||||
bool inFindScope(const QTextCursor &cursor);
|
bool inFindScope(const QTextCursor &cursor);
|
||||||
bool inFindScope(int selectionStart, int selectionEnd);
|
bool inFindScope(int selectionStart, int selectionEnd);
|
||||||
|
|
||||||
void doFoo();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internal::TextEditorWidgetPrivate *d;
|
Internal::TextEditorWidgetPrivate *d;
|
||||||
friend class BaseTextEditor;
|
friend class BaseTextEditor;
|
||||||
|
Reference in New Issue
Block a user