1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-1347 - Get rid of QDialog and all QWidget stuffs.

Todo: make it modal, the problem right now is with its parent being an QWidget
This commit is contained in:
Alessio Morale 2014-07-07 16:50:03 +02:00
parent 01b01052a8
commit 3f60e75d2c
6 changed files with 23 additions and 98 deletions

View File

@ -9,7 +9,7 @@ import "functions.js" as Functions
Rectangle {
width: 600
height: 400
id: root
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
@ -393,7 +393,7 @@ Rectangle {
text: qsTr("OK")
isDefault: true
activeFocusOnPress: true
onClicked: dialog.close()
onClicked: logDialog.close()
}
}
}

View File

@ -10,11 +10,9 @@ include(../../plugins/uavobjectutil/uavobjectutil.pri)
include(../../plugins/uavtalk/uavtalk.pri)
HEADERS += flightlogplugin.h \
flightlogmanager.h \
flightlogdialog.h
flightlogmanager.h
SOURCES += flightlogplugin.cpp \
flightlogmanager.cpp \
flightlogdialog.cpp
flightlogmanager.cpp
OTHER_FILES += Flightlog.pluginspec \
FlightLogDialog.qml \

View File

@ -1,70 +0,0 @@
/**
******************************************************************************
*
* @file flightlogdialog.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @addtogroup [Group]
* @{
* @addtogroup FlightLogDialog
* @{
* @brief [Brief]
*****************************************************************************/
/*
* 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 3 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "flightlogdialog.h"
#include <QVBoxLayout>
#include <QtQuick>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
#include "flightlogmanager.h"
#include "uavobject.h"
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
QDialog(parent)
{
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
qmlRegisterType<UAVOLogSettingsWrapper>("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
setWindowTitle(tr("Manage flight side logs"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setMinimumSize(600, 400);
QQuickView *view = new QQuickView();
view->rootContext()->setContextProperty("dialog", this);
view->rootContext()->setContextProperty("logStatus", flightLogManager->flightLogStatus());
view->rootContext()->setContextProperty("logControl", flightLogManager->flightLogControl());
view->rootContext()->setContextProperty("logSettings", flightLogManager->flightLogSettings());
view->rootContext()->setContextProperty("logManager", flightLogManager);
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
QWidget *container = QWidget::createWindowContainer(view);
container->setMinimumSize(600, 400);
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *lay = new QVBoxLayout();
lay->setContentsMargins(0, 0, 0, 0);
setLayout(lay);
layout()->addWidget(container);
}
FlightLogDialog::~FlightLogDialog()
{}

View File

@ -1,15 +0,0 @@
#ifndef FLIGHTLOGDIALOG_H
#define FLIGHTLOGDIALOG_H
#include <QDialog>
#include "flightlogmanager.h"
class FlightLogDialog : public QDialog {
Q_OBJECT
public:
explicit FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager);
~FlightLogDialog();
};
#endif // FLIGHTLOGDIALOG_H

View File

@ -26,14 +26,15 @@
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
#include <QtQuick>
#include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <QKeySequence>
#include <coreplugin/modemanager.h>
#include "flightlogdialog.h"
#include "flightlogmanager.h"
#include "uavobject.h"
FlightLogPlugin::FlightLogPlugin() : m_logDialog(0)
{}
@ -72,11 +73,22 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
void FlightLogPlugin::ShowLogManagementDialog()
{
if (!m_logDialog) {
m_logDialog = new FlightLogDialog(0, new FlightLogManager());
connect(m_logDialog, SIGNAL(finished(int)), this, SLOT(LogManagementDialogClosed()));
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
qmlRegisterType<UAVOLogSettingsWrapper>("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
FlightLogManager *flightLogManager = new FlightLogManager();
m_logDialog = new QQuickView();
m_logDialog->rootContext()->setContextProperty("logStatus", flightLogManager->flightLogStatus());
m_logDialog->rootContext()->setContextProperty("logControl", flightLogManager->flightLogControl());
m_logDialog->rootContext()->setContextProperty("logSettings", flightLogManager->flightLogSettings());
m_logDialog->rootContext()->setContextProperty("logManager", flightLogManager);
m_logDialog->rootContext()->setContextProperty("logDialog", m_logDialog);
m_logDialog->setResizeMode(QQuickView::SizeRootObjectToView);
m_logDialog->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
m_logDialog->setModality(Qt::WindowModal);
m_logDialog->show();
connect(m_logDialog, SIGNAL(destroyed()), this, SLOT(LogManagementDialogClosed()));
} else {
m_logDialog->raise();
m_logDialog->show();
}
}

View File

@ -28,7 +28,7 @@
#include <extensionsystem/iplugin.h>
#include "flightlogmanager.h"
#include "flightlogdialog.h"
#include <QQuickView>
class FlightLogPlugin : public ExtensionSystem::IPlugin {
Q_OBJECT
@ -47,7 +47,7 @@ private slots:
void LogManagementDialogClosed();
private:
FlightLogDialog *m_logDialog;
QQuickView *m_logDialog;
};
#endif /* FLIGHTLOGPLUGIN_H_ */