File indexing completed on 2024-11-24 04:39:33

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "grantleecontactviewer.h"
0008 #include <Akonadi/GrantleeContactFormatter>
0009 #include <KSharedConfig>
0010 
0011 #include <GrantleeTheme/GrantleeThemeManager>
0012 
0013 using namespace KAddressBookGrantlee;
0014 
0015 GrantleeContactViewer::GrantleeContactViewer(QWidget *parent)
0016     : Akonadi::ContactViewer(parent)
0017     , mFormatter(new KAddressBookGrantlee::GrantleeContactFormatter)
0018 {
0019     setContactFormatter(mFormatter);
0020     mFormatter->setAbsoluteThemePath(kaddressBookAbsoluteThemePath());
0021 }
0022 
0023 GrantleeContactViewer::~GrantleeContactViewer()
0024 {
0025     delete mFormatter;
0026 }
0027 
0028 QString GrantleeContactViewer::kaddressBookAbsoluteThemePath() const
0029 {
0030     QString themeName = GrantleeTheme::ThemeManager::configuredThemeName(QStringLiteral("addressbook"));
0031     if (themeName.isEmpty()) {
0032         themeName = QStringLiteral("default");
0033     }
0034     const QString absolutePath =
0035         GrantleeTheme::ThemeManager::pathFromThemes(QStringLiteral("kaddressbook/viewertemplates/"), themeName, QStringLiteral("theme.desktop"));
0036     return absolutePath;
0037 }
0038 
0039 void GrantleeContactViewer::setForceDisableQRCode(bool b)
0040 {
0041     if (b != mFormatter->forceDisableQRCode()) {
0042         mFormatter->setForceDisableQRCode(b);
0043         updateView();
0044     }
0045 }
0046 
0047 #include "moc_grantleecontactviewer.cpp"