1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
/*
SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "generichandler.h"
// local
#include "genericdialog.h"
namespace Latte {
namespace Settings {
namespace Handler {
Generic::Generic(Dialog::GenericDialog *parent)
: QObject(parent),
m_dialog(parent)
{
}
Generic::Generic(Dialog::GenericDialog *parentDialog, QObject *parent)
: QObject(parent),
m_dialog(parentDialog)
{
}
void Generic::setTwinProperty(QAction *action, const QString &property, QVariant value)
{
if (!m_twinActions.contains(action)) {
return;
}
if (property == TWINVISIBLE) {
action->setVisible(value.toBool());
m_twinActions[action]->setVisible(value.toBool());
} else if (property == TWINENABLED) {
action->setEnabled(value.toBool());
m_twinActions[action]->setEnabled(value.toBool());
} else if (property == TWINCHECKED) {
action->setChecked(value.toBool());
m_twinActions[action]->setChecked(value.toBool());
}
}
void Generic::connectActionWithButton(QPushButton *button, QAction *action)
{
button->setText(action->text());
button->setToolTip(action->toolTip());
button->setWhatsThis(action->whatsThis());
button->setIcon(action->icon());
button->setCheckable(action->isCheckable());
button->setChecked(action->isChecked());
m_twinActions[action] = button;
connect(button, &QPushButton::clicked, action, &QAction::trigger);
}
void Generic::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const bool &isPersistent, QList<QAction *> actions)
{
m_dialog->showInlineMessage(msg, type, isPersistent, actions);
}
}
}
}
|