diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-10-23 14:13:06 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-10-24 10:26:27 +0200 |
commit | bc81930f17f5fe897fd0ede57169a52751b72f73 (patch) | |
tree | 1c611f5c6bfe181c13d6a09d884bd85d38f90786 /src | |
parent | a2c0b91ec5890584716175aa18310b158cf016ff (diff) | |
download | qt-creator-bc81930f17f5fe897fd0ede57169a52751b72f73.tar.gz |
Give preprocessor dialog button a tool tip.
Change-Id: Iad756a8f18736da79cca63232eb00fcee8a2f38c
Reviewed-by: David Schulz <david.schulz@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 20 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditor.h | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.cpp | 2 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 0604edde96..fe072bde82 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -518,6 +518,7 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent) , m_objcEnabled(false) , m_commentsSettings(CppTools::CppToolsSettings::instance()->commentsSettings()) , m_followSymbolUnderCursor(new FollowSymbolUnderCursor(this)) + , m_preprocessorButton(0) { qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo"); @@ -647,10 +648,13 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor) connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateUses())); connect(this, SIGNAL(textChanged()), this, SLOT(updateUses())); - QToolButton *hashButton = new QToolButton(this); - hashButton->setText(QLatin1String("#")); - connect(hashButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget())); - editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, hashButton); + m_preprocessorButton = new QToolButton(this); + m_preprocessorButton->setText(QLatin1String("#")); + Core::Command *cmd = Core::ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); + connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePreprocessorButtonTooltip())); + updatePreprocessorButtonTooltip(); + connect(m_preprocessorButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget())); + editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_preprocessorButton); editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_outlineCombo); } @@ -1012,6 +1016,14 @@ void CPPEditorWidget::onContentsChanged(int position, int charsRemoved, int char updateUses(); } +void CPPEditorWidget::updatePreprocessorButtonTooltip() +{ + QTC_ASSERT(m_preprocessorButton, return); + Core::Command *cmd = Core::ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); + QTC_ASSERT(cmd, return); + m_preprocessorButton->setToolTip(cmd->action()->toolTip()); +} + void CPPEditorWidget::jumpToOutlineElement(int index) { QModelIndex modelIndex = m_outlineCombo->view()->currentIndex(); diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index ae1f57e31b..5546a20fae 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QComboBox; class QSortFilterProxyModel; +class QToolButton; QT_END_NAMESPACE namespace CPlusPlus { @@ -175,6 +176,7 @@ private Q_SLOTS: void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link); void onDocumentUpdated(); void onContentsChanged(int position, int charsRemoved, int charsAdded); + void updatePreprocessorButtonTooltip(); void updateSemanticInfo(const CppTools::SemanticInfo &semanticInfo); void highlightSymbolUsages(int from, int to); @@ -259,6 +261,7 @@ private: QScopedPointer<FollowSymbolUnderCursor> m_followSymbolUnderCursor; QString m_preProcessorAdditions; + QToolButton *m_preprocessorButton; }; } // namespace Internal diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index b9c66de4a1..d7dd630a43 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -210,7 +210,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); - QAction *openPreprocessorDialog = new QAction(tr("Additional Preprocessor Directives"), this); + QAction *openPreprocessorDialog = new QAction(tr("Additional Preprocessor Directives..."), this); cmd = ActionManager::registerAction(openPreprocessorDialog, Constants::OPEN_PREPROCESSOR_DIALOG, context); cmd->setDefaultKeySequence(QKeySequence()); |