Commit bc81930f authored by Eike Ziller's avatar Eike Ziller
Browse files

Give preprocessor dialog button a tool tip.



Change-Id: Iad756a8f18736da79cca63232eb00fcee8a2f38c
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent a2c0b91e
...@@ -518,6 +518,7 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent) ...@@ -518,6 +518,7 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent)
, m_objcEnabled(false) , m_objcEnabled(false)
, m_commentsSettings(CppTools::CppToolsSettings::instance()->commentsSettings()) , m_commentsSettings(CppTools::CppToolsSettings::instance()->commentsSettings())
, m_followSymbolUnderCursor(new FollowSymbolUnderCursor(this)) , m_followSymbolUnderCursor(new FollowSymbolUnderCursor(this))
, m_preprocessorButton(0)
{ {
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo"); qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
...@@ -647,10 +648,13 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor) ...@@ -647,10 +648,13 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor)
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateUses())); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateUses()));
connect(this, SIGNAL(textChanged()), this, SLOT(updateUses())); connect(this, SIGNAL(textChanged()), this, SLOT(updateUses()));
QToolButton *hashButton = new QToolButton(this); m_preprocessorButton = new QToolButton(this);
hashButton->setText(QLatin1String("#")); m_preprocessorButton->setText(QLatin1String("#"));
connect(hashButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget())); Core::Command *cmd = Core::ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG);
editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, hashButton); 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); editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_outlineCombo);
} }
...@@ -1012,6 +1016,14 @@ void CPPEditorWidget::onContentsChanged(int position, int charsRemoved, int char ...@@ -1012,6 +1016,14 @@ void CPPEditorWidget::onContentsChanged(int position, int charsRemoved, int char
updateUses(); 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) void CPPEditorWidget::jumpToOutlineElement(int index)
{ {
QModelIndex modelIndex = m_outlineCombo->view()->currentIndex(); QModelIndex modelIndex = m_outlineCombo->view()->currentIndex();
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QComboBox; class QComboBox;
class QSortFilterProxyModel; class QSortFilterProxyModel;
class QToolButton;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace CPlusPlus { namespace CPlusPlus {
...@@ -175,6 +176,7 @@ private Q_SLOTS: ...@@ -175,6 +176,7 @@ private Q_SLOTS:
void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link); void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link);
void onDocumentUpdated(); void onDocumentUpdated();
void onContentsChanged(int position, int charsRemoved, int charsAdded); void onContentsChanged(int position, int charsRemoved, int charsAdded);
void updatePreprocessorButtonTooltip();
void updateSemanticInfo(const CppTools::SemanticInfo &semanticInfo); void updateSemanticInfo(const CppTools::SemanticInfo &semanticInfo);
void highlightSymbolUsages(int from, int to); void highlightSymbolUsages(int from, int to);
...@@ -259,6 +261,7 @@ private: ...@@ -259,6 +261,7 @@ private:
QScopedPointer<FollowSymbolUnderCursor> m_followSymbolUnderCursor; QScopedPointer<FollowSymbolUnderCursor> m_followSymbolUnderCursor;
QString m_preProcessorAdditions; QString m_preProcessorAdditions;
QToolButton *m_preprocessorButton;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -210,7 +210,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err ...@@ -210,7 +210,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
contextMenu->addAction(cmd); contextMenu->addAction(cmd);
cppToolsMenu->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, cmd = ActionManager::registerAction(openPreprocessorDialog,
Constants::OPEN_PREPROCESSOR_DIALOG, context); Constants::OPEN_PREPROCESSOR_DIALOG, context);
cmd->setDefaultKeySequence(QKeySequence()); cmd->setDefaultKeySequence(QKeySequence());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment