File indexing completed on 2024-12-01 04:36:51
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "messagestylelayoutmenu.h" 0008 #include <KLocalizedString> 0009 #include <QActionGroup> 0010 #include <QMenu> 0011 0012 MessageStyleLayoutMenu::MessageStyleLayoutMenu(QObject *parent) 0013 : KActionMenu{parent} 0014 , mActionGroup(new QActionGroup(this)) 0015 { 0016 setText(i18n("Message Style")); 0017 mActionGroup->setExclusive(true); 0018 0019 addMessageStyleAction(i18nc("Message Style", "Normal"), RuqolaGlobalConfig::EnumMessageStyle::Normal); 0020 addMessageStyleAction(i18nc("Message Style", "Compact"), RuqolaGlobalConfig::EnumMessageStyle::Compact); 0021 // Disable for the moment as Cozy is not implemented 0022 // addMessageStyleAction(i18nc("Message Style", "Cozy"), RuqolaGlobalConfig::EnumMessageStyle::Cozy); 0023 } 0024 0025 MessageStyleLayoutMenu::~MessageStyleLayoutMenu() = default; 0026 0027 void MessageStyleLayoutMenu::addMessageStyleAction(const QString &name, RuqolaGlobalConfig::EnumMessageStyle::type status) 0028 { 0029 auto action = new QAction(name, this); 0030 action->setData(status); 0031 action->setChecked(RuqolaGlobalConfig::self()->messageStyle() == status); 0032 mActionGroup->addAction(action); 0033 menu()->addAction(action); 0034 action->setCheckable(true); 0035 connect(action, &QAction::triggered, this, [this, status]() { 0036 RuqolaGlobalConfig::self()->setMessageStyle(status); 0037 RuqolaGlobalConfig::self()->save(); 0038 Q_EMIT styleChanged(); 0039 }); 0040 } 0041 0042 #include "moc_messagestylelayoutmenu.cpp"