CppEditor: Fix highlight of '#' Button for duplication case

Change-Id: Ib97f31912c9b2d619e3b92287ca8b192604f3831
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-02-03 11:38:15 +01:00
parent dd3ba874b4
commit 93fe64e789
3 changed files with 21 additions and 3 deletions

View File

@@ -203,8 +203,7 @@ void CppEditorWidget::finalizeInitialization()
connect(cppEditorDocument(), &CppEditorDocument::preprocessorSettingsChanged, this, connect(cppEditorDocument(), &CppEditorDocument::preprocessorSettingsChanged, this,
[this](bool customSettings) { [this](bool customSettings) {
d->m_preprocessorButton->setProperty("highlightWidget", customSettings); updateWidgetHighlighting(d->m_preprocessorButton, customSettings);
d->m_preprocessorButton->update();
}); });
// set up function declaration - definition link // set up function declaration - definition link
@@ -267,6 +266,9 @@ void CppEditorWidget::finalizeInitializationAfterDuplication(TextEditorWidget *o
const Id selectionKind = CodeWarningsSelection; const Id selectionKind = CodeWarningsSelection;
setExtraSelections(selectionKind, cppEditorWidget->extraSelections(selectionKind)); setExtraSelections(selectionKind, cppEditorWidget->extraSelections(selectionKind));
if (isWidgetHighlighted(cppEditorWidget->d->m_preprocessorButton))
updateWidgetHighlighting(d->m_preprocessorButton, true);
d->m_parseContextWidget->syncToModel(); d->m_parseContextWidget->syncToModel();
d->m_parseContextAction->setVisible( d->m_parseContextAction->setVisible(
d->m_cppEditorDocument->parseContextModel().areMultipleAvailable()); d->m_cppEditorDocument->parseContextModel().areMultipleAvailable());
@@ -418,6 +420,17 @@ bool CppEditorWidget::selectBlockDown()
return changed; return changed;
} }
void CppEditorWidget::updateWidgetHighlighting(QWidget *widget, bool highlight)
{
widget->setProperty("highlightWidget", highlight);
widget->update();
}
bool CppEditorWidget::isWidgetHighlighted(QWidget *widget)
{
return widget->property("highlightWidget").toBool();
}
void CppEditorWidget::renameSymbolUnderCursor() void CppEditorWidget::renameSymbolUnderCursor()
{ {
if (refactoringEngine()) if (refactoringEngine())

View File

@@ -95,6 +95,9 @@ public:
bool selectBlockUp() override; bool selectBlockUp() override;
bool selectBlockDown() override; bool selectBlockDown() override;
static void updateWidgetHighlighting(QWidget *widget, bool highlight);
static bool isWidgetHighlighted(QWidget *widget);
protected: protected:
bool event(QEvent *e) override; bool event(QEvent *e) override;
void contextMenuEvent(QContextMenuEvent *) override; void contextMenuEvent(QContextMenuEvent *) override;

View File

@@ -25,6 +25,8 @@
#include "cppparsecontext.h" #include "cppparsecontext.h"
#include "cppeditor.h"
#include <QAction> #include <QAction>
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
@@ -165,7 +167,7 @@ void ParseContextWidget::syncToModel()
const bool isPreferred = m_parseContextModel.isCurrentPreferred(); const bool isPreferred = m_parseContextModel.isCurrentPreferred();
m_clearPreferredAction->setEnabled(isPreferred); m_clearPreferredAction->setEnabled(isPreferred);
QComboBox::setProperty("highlightWidget", isPreferred); CppEditorWidget::updateWidgetHighlighting(this, isPreferred);
} }
} // namespace Internal } // namespace Internal