Pimcommon

needupdateversionwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5 code based on kdenlive
6*/
7
8#include "needupdateversionwidget.h"
9#include "pimcommon_debug.h"
10#include <KLocalizedString>
11
12using namespace PimCommon;
13NeedUpdateVersionWidget::NeedUpdateVersionWidget(QWidget *parent)
14 : KMessageWidget(parent)
15{
16 setVisible(false);
17 setPosition(KMessageWidget::Header);
18 setCloseButtonVisible(true);
19 auto action = new QAction(i18nc("@action", "Disable version check"), this);
20 addAction(action);
21 connect(action, &QAction::triggered, this, &NeedUpdateVersionWidget::slotDisableVersionCheck);
22}
23
24NeedUpdateVersionWidget::~NeedUpdateVersionWidget() = default;
25
26void NeedUpdateVersionWidget::setObsoleteVersion(NeedUpdateVersionUtils::ObsoleteVersion obsolete)
27{
28 if (PimCommon::NeedUpdateVersionUtils::checkVersion()) {
29 switch (obsolete) {
30 case NeedUpdateVersionUtils::ObsoleteVersion::Unknown:
31 qCWarning(PIMCOMMON_LOG) << "Unknown value: seems to be a bug";
32 break;
33 case NeedUpdateVersionUtils::ObsoleteVersion::OlderThan6Months:
35 setText(i18n("Your version is older than 6 months, we encourage you to upgrade."));
37 break;
38 case NeedUpdateVersionUtils::ObsoleteVersion::OlderThan12Months:
40 setText(i18n("Your version is older than 1 year, we strongly encourage you to upgrade."));
42 break;
43 case NeedUpdateVersionUtils::ObsoleteVersion::NotObsoleteYet:
44 // It's ok
45 break;
46 }
47 }
48}
49
50void NeedUpdateVersionWidget::slotDisableVersionCheck()
51{
52 PimCommon::NeedUpdateVersionUtils::disableCheckVersion();
54}
55
56#include "moc_needupdateversionwidget.cpp"
void animatedHide()
void animatedShow()
void setMessageType(KMessageWidget::MessageType type)
void setText(const QString &text)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
folderdialogacltab.h
void triggered(bool checked)
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 Fri Nov 22 2024 12:12:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.