7#include "textgotolinewidget.h"
9#include <KLocalizedString>
19using namespace TextCustomEditor;
21class Q_DECL_HIDDEN TextCustomEditor::TextGoToLineWidgetPrivate
24 TextGoToLineWidgetPrivate() =
default;
26 QSpinBox *mSpinbox =
nullptr;
27 QPushButton *mGoToLine =
nullptr;
30TextGoToLineWidget::TextGoToLineWidget(
QWidget *parent)
32 , d(new TextCustomEditor::TextGoToLineWidgetPrivate)
35 hbox->setContentsMargins(2, 2, 2, 2);
38 closeBtn->setIconSize(
QSize(16, 16));
39 closeBtn->setToolTip(
i18nc(
"@info:tooltip",
"Close"));
40 closeBtn->setObjectName(QStringLiteral(
"closebutton"));
41#ifndef QT_NO_ACCESSIBILITY
42 closeBtn->setAccessibleName(
i18n(
"Close"));
45 closeBtn->setAutoRaise(
true);
47 hbox->addWidget(closeBtn);
49 auto lab =
new QLabel(
i18nc(
"@label:textbox",
"Go to Line:"));
52 d->mSpinbox->setMinimum(1);
53 d->mSpinbox->setObjectName(QStringLiteral(
"line"));
55 hbox->addWidget(d->mSpinbox);
57 d->mGoToLine->setFlat(
true);
59 d->mGoToLine->setObjectName(QStringLiteral(
"gotoline"));
60 hbox->addWidget(d->mGoToLine);
62 d->mSpinbox->setFocus();
63 d->mSpinbox->installEventFilter(
this);
66TextGoToLineWidget::~TextGoToLineWidget()
73bool TextGoToLineWidget::eventFilter(QObject *obj, QEvent *event)
75 if (obj == d->mSpinbox) {
77 auto e =
static_cast<QKeyEvent *
>(event);
87void TextGoToLineWidget::setMaximumLineCount(
int max)
89 d->mSpinbox->setMaximum(max);
92void TextGoToLineWidget::goToLine()
95 d->mSpinbox->setFocus();
96 d->mSpinbox->selectAll();
99void TextGoToLineWidget::slotGoToLine()
101 Q_EMIT moveToLine(d->mSpinbox->value());
104void TextGoToLineWidget::showEvent(QShowEvent *e)
107 d->mSpinbox->setFocus();
112void TextGoToLineWidget::slotBlockCountChanged(
int numberBlockCount)
115 setMaximumLineCount(numberBlockCount);
119void TextGoToLineWidget::slotCloseBar()
125bool TextGoToLineWidget::event(QEvent *e)
133 auto kev =
static_cast<QKeyEvent *
>(e);
143#include "moc_textgotolinewidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
bool spontaneous() const const
QIcon fromTheme(const QString &name)
virtual bool eventFilter(QObject *watched, QEvent *event)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)