KTextAddons

grammalecteurlrequesterwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "grammalecteurlrequesterwidget.h"
8#include <KLineEditEventHandler>
9#include <KLocalizedString>
10#include <QFileDialog>
11#include <QHBoxLayout>
12#include <QLineEdit>
13#include <QToolButton>
14
15using namespace TextGrammarCheck;
16GrammalecteUrlRequesterWidget::GrammalecteUrlRequesterWidget(QWidget *parent)
17 : QWidget{parent}
18 , mLineEdit(new QLineEdit(this))
19{
20 auto mainLayout = new QHBoxLayout(this);
21 mainLayout->setObjectName(QStringLiteral("mainLayout"));
22 mainLayout->setContentsMargins({});
23
24 mLineEdit->setObjectName(QStringLiteral("mLineEdit"));
25 mainLayout->addWidget(mLineEdit);
27 auto selectUrlButton = new QToolButton(this);
28 selectUrlButton->setText(QStringLiteral("…"));
29 selectUrlButton->setObjectName(QStringLiteral("selectUrlButton"));
30 mainLayout->addWidget(selectUrlButton);
31
32 connect(selectUrlButton, &QToolButton::clicked, this, [this]() {
33 const QString path = QFileDialog::getOpenFileName(this, i18n("Select Path"));
34 mLineEdit->setText(path);
35 });
36}
37
38GrammalecteUrlRequesterWidget::~GrammalecteUrlRequesterWidget() = default;
39
40void GrammalecteUrlRequesterWidget::setPath(const QString &path)
41{
42 mLineEdit->setText(path);
43}
44
45QString GrammalecteUrlRequesterWidget::path() const
46{
47 return mLineEdit->text();
48}
49
50void GrammalecteUrlRequesterWidget::setPlaceholderText(const QString &text)
51{
52 mLineEdit->setPlaceholderText(text);
53}
54
55#include "moc_grammalecteurlrequesterwidget.cpp"
QString i18n(const char *text, const TYPE &arg...)
QString path(const QString &relativePath)
void catchReturnKey(QObject *lineEdit)
void clicked(bool checked)
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
void setPlaceholderText(const QString &)
void setText(const QString &)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.