Messagelib

shownextmessagewidget.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "shownextmessagewidget.h"
8#include <KLocalizedString>
9#include <QHBoxLayout>
10#include <QPushButton>
11
12using namespace MessageViewer;
13ShowNextMessageWidget::ShowNextMessageWidget(QWidget *parent)
14 : QWidget(parent)
15 , mNextMessage(new QPushButton(i18nc("@action:button", "Next Message"), this))
16 , mPreviousMessage(new QPushButton(i18nc("@action:button", "Previous Message"), this))
17{
18 auto mainLayout = new QHBoxLayout(this);
19 mainLayout->setObjectName(QLatin1StringView("mainlayout"));
20 mainLayout->setContentsMargins({});
21
22 mPreviousMessage->setObjectName(QLatin1StringView("previous_message"));
23 mPreviousMessage->setEnabled(false);
24 mainLayout->addWidget(mPreviousMessage);
25 connect(mPreviousMessage, &QPushButton::clicked, this, &ShowNextMessageWidget::showPreviousMessage);
26
27 mainLayout->addStretch(1);
28 mNextMessage->setObjectName(QLatin1StringView("next_message"));
29 mNextMessage->setEnabled(false);
30 connect(mNextMessage, &QPushButton::clicked, this, &ShowNextMessageWidget::showNextMessage);
31 mainLayout->addWidget(mNextMessage);
32 setMaximumHeight(mNextMessage->height() + 4);
33}
34
35ShowNextMessageWidget::~ShowNextMessageWidget() = default;
36
37void ShowNextMessageWidget::updateButton(bool hasPreviousMessage, bool hasNextMessage)
38{
39 mPreviousMessage->setEnabled(hasPreviousMessage);
40 mNextMessage->setEnabled(hasNextMessage);
41}
42
43#include "moc_shownextmessagewidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void clicked(bool checked)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setEnabled(bool)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.