forked from qt-creator/qt-creator
BaseEditor: Open locator "l <line:column>" on toolbar line widget click
Task-number: QTCREATORBUG-8811 Change-Id: Ia3ece9efb7e2c6d227ab3395aca636a27f667f0d Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
ad0331a2a9
commit
e89c30feb8
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "linecolumnlabel.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
/*!
|
||||
\class Utils::LineColumnLabel
|
||||
|
||||
@@ -39,7 +41,8 @@
|
||||
namespace Utils {
|
||||
|
||||
LineColumnLabel::LineColumnLabel(QWidget *parent)
|
||||
: QLabel(parent), m_unused(0)
|
||||
: QLabel(parent)
|
||||
, m_pressed(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,6 +51,7 @@ void LineColumnLabel::setText(const QString &text, const QString &maxText)
|
||||
QLabel::setText(text);
|
||||
m_maxText = maxText;
|
||||
}
|
||||
|
||||
QSize LineColumnLabel::sizeHint() const
|
||||
{
|
||||
return fontMetrics().boundingRect(m_maxText).size();
|
||||
@@ -63,4 +67,21 @@ void LineColumnLabel::setMaxText(const QString &maxText)
|
||||
m_maxText = maxText;
|
||||
}
|
||||
|
||||
void LineColumnLabel::mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
QLabel::mousePressEvent(ev);
|
||||
if (ev->button() == Qt::LeftButton)
|
||||
m_pressed = true;
|
||||
}
|
||||
|
||||
void LineColumnLabel::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
QLabel::mouseReleaseEvent(ev);
|
||||
if (ev->button() != Qt::LeftButton)
|
||||
return;
|
||||
if (m_pressed && rect().contains(ev->pos()))
|
||||
emit clicked();
|
||||
m_pressed = false;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -49,9 +49,16 @@ public:
|
||||
QString maxText() const;
|
||||
void setMaxText(const QString &maxText);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
void mouseReleaseEvent(QMouseEvent *ev);
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
QString m_maxText;
|
||||
void *m_unused;
|
||||
bool m_pressed;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -54,6 +54,7 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/manhattanstyle.h>
|
||||
#include <find/basetextfind.h>
|
||||
@@ -6285,6 +6286,7 @@ BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
|
||||
m_cursorPositionLabelAction = m_toolBar->addWidget(m_cursorPositionLabel);
|
||||
|
||||
connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
|
||||
connect(m_cursorPositionLabel, SIGNAL(clicked()), this, SLOT(openGotoLocator()));
|
||||
}
|
||||
|
||||
BaseTextEditor::~BaseTextEditor()
|
||||
@@ -6420,6 +6422,16 @@ void BaseTextEditor::updateCursorPosition()
|
||||
|
||||
}
|
||||
|
||||
void BaseTextEditor::openGotoLocator()
|
||||
{
|
||||
Core::EditorManager::activateEditor(this, Core::EditorManager::IgnoreNavigationHistory);
|
||||
if (Core::Command *cmd = Core::ActionManager::command(Core::Constants::GOTO)) {
|
||||
if (QAction *act = cmd->action()) {
|
||||
act->trigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString BaseTextEditor::contextHelpId() const
|
||||
{
|
||||
if (m_contextHelpId.isEmpty())
|
||||
|
@@ -669,8 +669,10 @@ public:
|
||||
void setCursorPosition(int pos);
|
||||
void select(int toPos);
|
||||
const Utils::CommentDefinition* commentDefinition() const;
|
||||
|
||||
private slots:
|
||||
void updateCursorPosition();
|
||||
void openGotoLocator();
|
||||
|
||||
private:
|
||||
BaseTextEditorWidget *e;
|
||||
|
Reference in New Issue
Block a user