KPimTextEdit

insertimagedialog.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5
6*/
7
8#include "insertimagedialog.h"
9#include "insertimagewidget.h"
10
11#include <KLocalizedString>
12
13#include <QCheckBox>
14#include <QDialogButtonBox>
15#include <QPushButton>
16#include <QVBoxLayout>
17
18namespace KPIMTextEdit
19{
20class InsertImageDialogPrivate
21{
22public:
23 explicit InsertImageDialogPrivate(InsertImageDialog *qq)
24 : q(qq)
25 {
26 auto vbox = new QVBoxLayout(q);
27 q->setWindowTitle(i18nc("@title:window", "Insert Image"));
28
29 imageWidget = new InsertImageWidget(q);
30 vbox->addWidget(imageWidget);
31 q->connect(imageWidget, &InsertImageWidget::enableButtonOk, q, [this](bool b) {
32 _k_slotEnabledButtonChanged(b);
33 });
35 okButton = buttonBox->button(QDialogButtonBox::Ok);
36 okButton->setText(i18n("Insert"));
38 vbox->addWidget(buttonBox);
39
42 okButton->setEnabled(false);
43 }
44
45 void _k_slotEnabledButtonChanged(bool enabled)
46 {
47 okButton->setEnabled(enabled);
48 }
49
50 InsertImageWidget *imageWidget = nullptr;
51 QPushButton *okButton = nullptr;
52 InsertImageDialog *const q;
53};
54
55InsertImageDialog::InsertImageDialog(QWidget *parent)
56 : QDialog(parent)
57 , d(new InsertImageDialogPrivate(this))
58{
59}
60
61InsertImageDialog::~InsertImageDialog() = default;
62
63int InsertImageDialog::imageWidth() const
64{
65 return d->imageWidget->imageWidth();
66}
67
68int InsertImageDialog::imageHeight() const
69{
70 return d->imageWidget->imageHeight();
71}
72
73void InsertImageDialog::setImageWidth(int value)
74{
75 d->imageWidget->setImageWidth(value);
76}
77
78void InsertImageDialog::setImageHeight(int value)
79{
80 d->imageWidget->setImageHeight(value);
81}
82
83QUrl InsertImageDialog::imageUrl() const
84{
85 return d->imageWidget->imageUrl();
86}
87
88void InsertImageDialog::setImageUrl(const QUrl &url)
89{
90 d->imageWidget->setImageUrl(url);
91}
92
93bool InsertImageDialog::keepOriginalSize() const
94{
95 return d->imageWidget->keepOriginalSize();
96}
97}
98#include "moc_insertimagedialog.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void setShortcut(const QKeySequence &key)
void setText(const QString &text)
virtual void accept()
virtual void reject()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Key_Return
void setEnabled(bool)
void setWindowTitle(const QString &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.