File indexing completed on 2024-04-28 13:25:35

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "generichandler.h"
0007 
0008 // local
0009 #include "genericdialog.h"
0010 
0011 namespace Latte {
0012 namespace Settings {
0013 namespace Handler {
0014 
0015 Generic::Generic(Dialog::GenericDialog *parent)
0016     : QObject(parent),
0017       m_dialog(parent)
0018 {
0019 }
0020 
0021 Generic::Generic(Dialog::GenericDialog *parentDialog, QObject *parent)
0022     : QObject(parent),
0023       m_dialog(parentDialog)
0024 {
0025 }
0026 
0027 
0028 void Generic::setTwinProperty(QAction *action, const QString &property, QVariant value)
0029 {
0030     if (!m_twinActions.contains(action)) {
0031         return;
0032     }
0033 
0034     if (property == TWINVISIBLE) {
0035         action->setVisible(value.toBool());
0036         m_twinActions[action]->setVisible(value.toBool());
0037     } else if (property == TWINENABLED) {
0038         action->setEnabled(value.toBool());
0039         m_twinActions[action]->setEnabled(value.toBool());
0040     } else if (property == TWINCHECKED) {
0041         action->setChecked(value.toBool());
0042         m_twinActions[action]->setChecked(value.toBool());
0043     }
0044 }
0045 
0046 void Generic::connectActionWithButton(QPushButton *button, QAction *action)
0047 {
0048     button->setText(action->text());
0049     button->setToolTip(action->toolTip());
0050     button->setWhatsThis(action->whatsThis());
0051     button->setIcon(action->icon());
0052     button->setCheckable(action->isCheckable());
0053     button->setChecked(action->isChecked());
0054 
0055     m_twinActions[action] = button;
0056 
0057     connect(button, &QPushButton::clicked, action, &QAction::trigger);
0058 }
0059 
0060 void Generic::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const bool &isPersistent, QList<QAction *> actions)
0061 {
0062     m_dialog->showInlineMessage(msg, type, isPersistent, actions);
0063 }
0064 
0065 }
0066 }
0067 }