Messagelib

shownextmessagewidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2019-2021 Laurent Montel <[email protected]>
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 
12 using namespace MessageViewer;
13 ShowNextMessageWidget::ShowNextMessageWidget(QWidget *parent)
14  : QWidget(parent)
15  , mNextMessage(new QPushButton(i18n("Next Message"), this))
16  , mPreviousMessage(new QPushButton(i18n("Previous Message"), this))
17 {
18  auto mainLayout = new QHBoxLayout(this);
19  mainLayout->setObjectName(QStringLiteral("mainlayout"));
20  mainLayout->setContentsMargins({});
21 
22  mPreviousMessage->setObjectName(QStringLiteral("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(QStringLiteral("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 
35 ShowNextMessageWidget::~ShowNextMessageWidget() = default;
36 
37 void ShowNextMessageWidget::updateButton(bool hasPreviousMessage, bool hasNextMessage)
38 {
39  mPreviousMessage->setEnabled(hasPreviousMessage);
40  mNextMessage->setEnabled(hasNextMessage);
41 }
void clicked(bool checked)
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Dec 4 2021 23:12:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.