2 ******************************************************************************
4 * @file flightlogplugin.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @brief A plugin to view and download flight side logs.
8 *****************************************************************************/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "flightlogplugin.h"
27 #include <QStringList>
28 #include <extensionsystem/pluginmanager.h>
31 #include <coreplugin/coreconstants.h>
32 #include <coreplugin/actionmanager/actionmanager.h>
33 #include <coreplugin/icore.h>
34 #include <QKeySequence>
35 #include <coreplugin/modemanager.h>
36 #include "flightlogmanager.h"
37 #include "uavobject.h"
39 FlightLogPlugin::FlightLogPlugin() : m_logDialog(0)
42 FlightLogPlugin::~FlightLogPlugin()
47 bool FlightLogPlugin::initialize(const QStringList
& args
, QString
*errMsg
)
53 Core::ActionManager
*am
= Core::ICore::instance()->actionManager();
54 Core::ActionContainer
*ac
= am
->actionContainer(Core::Constants::M_TOOLS
);
56 Core::Command
*cmd
= am
->registerAction(new QAction(this),
57 "FlightLogPlugin.ShowFlightLogDialog",
59 Core::Constants::C_GLOBAL_ID
);
60 cmd
->setDefaultKeySequence(QKeySequence("Ctrl+F"));
61 cmd
->action()->setText(tr("Manage flight side logs..."));
63 Core::ModeManager::instance()->addAction(cmd
, 1);
65 ac
->menu()->addSeparator();
66 ac
->appendGroup("FlightLogs");
67 ac
->addAction(cmd
, "FlightLogs");
69 connect(cmd
->action(), SIGNAL(triggered(bool)), this, SLOT(ShowLogManagementDialog()));
73 void FlightLogPlugin::ShowLogManagementDialog()
76 qmlRegisterType
<ExtendedDebugLogEntry
>("org.openpilot", 1, 0, "DebugLogEntry");
77 qmlRegisterType
<UAVOLogSettingsWrapper
>("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
78 FlightLogManager
*flightLogManager
= new FlightLogManager();
79 m_logDialog
= new QQuickView();
80 m_logDialog
->setIcon(QIcon(":/core/images/openpilot_logo_32.png"));
81 m_logDialog
->setTitle(tr("Manage flight side logs"));
82 m_logDialog
->rootContext()->setContextProperty("logStatus", flightLogManager
->flightLogStatus());
83 m_logDialog
->rootContext()->setContextProperty("logControl", flightLogManager
->flightLogControl());
84 m_logDialog
->rootContext()->setContextProperty("logSettings", flightLogManager
->flightLogSettings());
85 m_logDialog
->rootContext()->setContextProperty("logManager", flightLogManager
);
86 m_logDialog
->rootContext()->setContextProperty("logDialog", m_logDialog
);
87 m_logDialog
->setResizeMode(QQuickView::SizeRootObjectToView
);
88 m_logDialog
->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
89 m_logDialog
->setModality(Qt::ApplicationModal
);
90 connect(m_logDialog
, SIGNAL(destroyed()), this, SLOT(LogManagementDialogClosed()));
95 void FlightLogPlugin::LogManagementDialogClosed()
98 m_logDialog
->deleteLater();
103 void FlightLogPlugin::extensionsInitialized()
106 void FlightLogPlugin::shutdown()
109 m_logDialog
->close();
110 LogManagementDialogClosed();