File: generichandler.cpp

package info (click to toggle)
latte-dock 0.10.9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 11,480 kB
  • sloc: cpp: 43,957; xml: 833; javascript: 734; sh: 43; makefile: 3
file content (67 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download
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);
}

}
}
}