Pimcommon

verifynewversionwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2024-2025 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "verifynewversionwidget.h"
8#include "pimcommon_debug.h"
9#include "verifynewversion/checknewversiondialog.h"
10#include "verifynewversionutils.h"
11#include <KLocalizedString>
12#include <QAction>
13#include <QDesktopServices>
14#include <QUrl>
15using namespace PimCommon;
16using namespace Qt::Literals::StringLiterals;
17VerifyNewVersionWidget::VerifyNewVersionWidget(QObject *parent)
18 : QObject{parent}
19{
20}
21
22VerifyNewVersionWidget::~VerifyNewVersionWidget() = default;
23
24bool VerifyNewVersionWidget::canVerifyNewVersion() const
25{
26 return VerifyNewVersionUtils::canVerifyNewVersion();
27}
28
29QAction *VerifyNewVersionWidget::verifyNewVersionAction()
30{
31 if (!mVerifyNewVersionAction) {
32 // TODO add icon
33 mVerifyNewVersionAction = new QAction(i18n("Check New Version"), this);
34 connect(mVerifyNewVersionAction, &QAction::triggered, this, &VerifyNewVersionWidget::slotVerifyNewVersion);
35 }
36 return mVerifyNewVersionAction;
37}
38
39void VerifyNewVersionWidget::addOsUrlInfo(OsVersion os, const QString &url)
40{
41 mUrls.insert(os, url);
42}
43
44void VerifyNewVersionWidget::slotVerifyNewVersion()
45{
46 QUrl url;
47#if defined(Q_OS_WIN)
48 url = QUrl(mUrls.value(VerifyNewVersionWidget::OsVersion::Windows));
49#endif
50
51#if defined(Q_OS_MACOS)
52#ifdef Q_PROCESSOR_ARM_64
53 url = QUrl(mUrls.value(VerifyNewVersionWidget::OsVersion::MacOsArm64));
54#else
55 url = QUrl(mUrls.value(VerifyNewVersionWidget::OsVersion::MacOs));
56#endif
57#endif
58 if (!url.isEmpty()) {
59 CheckNewVersionDialog dlg(nullptr);
60 dlg.checkNewVersion();
61 dlg.exec();
62 }
63}
64
65#include "moc_verifynewversionwidget.cpp"
QString i18n(const char *text, const TYPE &arg...)
folderdialogacltab.h
void triggered(bool checked)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:47:24 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.