documentationpanelplugin.cpp 2.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1301, USA.

    ---
    Copyright (C) 2020 Shubham <aryan100jangid@gmail.com>
 */

#include "documentationpanelplugin.h"
22
#include "session.h"
Shubham  .'s avatar
Shubham . committed
23

24
#include <QIcon>
25

Shubham  .'s avatar
Shubham . committed
26
DocumentationPanelPlugin::DocumentationPanelPlugin(QObject* parent, QList<QVariant> args) : Cantor::PanelPlugin(parent), m_widget(nullptr)
27
28
29
30
31
32
33
34
35
{
    Q_UNUSED(args);
}

DocumentationPanelPlugin::~DocumentationPanelPlugin()
{
    delete m_widget;
}

36
37
void DocumentationPanelPlugin::onSessionChanged()
{
Shubham  .'s avatar
Shubham . committed
38
39
40
    m_backendName = session()->backend()->name();
    m_backendIcon = session()->backend()->icon();

41
    if(m_widget)
42
43
44
45
    {
        m_widget->setBackend(m_backendName);
        m_widget->setBackendIcon(m_backendIcon);
    }
46
47
}

48
49
QWidget* DocumentationPanelPlugin::widget()
{
Shubham  .'s avatar
Shubham . committed
50
    if(!m_widget)
51
    {
52
        m_widget = new DocumentationPanelWidget(m_backendName, m_backendIcon, parentWidget());
53
        connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), m_widget, SLOT(contextSensitiveHelp(QString)));
54
        connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), this, SIGNAL(visibilityRequested()));
55
56
57
58
59
60
61
    }

    return m_widget;
}

bool DocumentationPanelPlugin::showOnStartup()
{
Shubham  .'s avatar
Shubham . committed
62
    return true;
63
64
}

65
66
QIcon DocumentationPanelPlugin::icon() const
{
67
    return QIcon::fromTheme(m_backendIcon);
68
69
70
71
}

QString DocumentationPanelPlugin::backendName() const
{
72
    return m_backendName;
73
74
}

Shubham  .'s avatar
Shubham . committed
75
K_PLUGIN_FACTORY_WITH_JSON(documentationpanelplugin, "documentationpanelplugin.json", registerPlugin<DocumentationPanelPlugin>();)
76
#include "documentationpanelplugin.moc"