Move to Qt5 and Qt5Multimedia

This commit is contained in:
Bertrand Songis
2016-03-10 07:12:44 +01:00
parent d7a9710a9c
commit aec2170e7e
98 changed files with 355 additions and 438 deletions
+4 -3
View File
@@ -54,7 +54,8 @@ foreach(name ${modeledit_NAMES})
set(modeledit_UIS ${modeledit_UIS} ${name}.ui)
endforeach()
qt4_wrap_ui(modeledit_SRCS ${modeledit_UIS})
qt4_wrap_cpp(modeledit_SRCS ${modeledit_HDRS})
qt5_wrap_ui(modeledit_SRCS ${modeledit_UIS})
qt5_wrap_cpp(modeledit_SRCS ${modeledit_HDRS})
add_library(modeledit ${modeledit_SRCS})
add_library(modeledit ${modeledit_SRCS})
qt5_use_modules(modeledit Widgets Xml Multimedia)
+1 -7
View File
@@ -1,11 +1,5 @@
#include "channels.h"
#include "helpers.h"
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QDoubleSpinBox>
LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, int min, int max, int deflt):
firmware(firmware),
@@ -200,7 +194,7 @@ void Channels::nameEdited()
if (!lock) {
QLineEdit *le = qobject_cast<QLineEdit*>(sender());
int index = le->property("index").toInt();
strcpy(model->limitData[index].name, le->text().toAscii());
strcpy(model->limitData[index].name, le->text().toLatin1());
emit modified();
}
}
-1
View File
@@ -3,7 +3,6 @@
#include "helpers.h"
#include "modeledit.h"
#include <QSpinBox>
class GVarGroup;
+1 -6
View File
@@ -3,11 +3,6 @@
#include "node.h"
#include "edge.h"
#include "helpers.h"
#include <QSpinBox>
#include <QCheckBox>
#include <QPushButton>
#include <QMessageBox>
#include <QAction>
#define GFX_MARGIN 16
@@ -491,7 +486,7 @@ void Curves::on_curveSmooth_currentIndexChanged(int index)
void Curves::on_curveName_editingFinished()
{
memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name));
strcpy(model->curves[currentCurve].name, ui->curveName->text().toAscii());
strcpy(model->curves[currentCurve].name, ui->curveName->text().toLatin1());
emit modified();
}
-1
View File
@@ -3,7 +3,6 @@
#include "modeledit.h"
#include "eeprominterface.h"
#include <QSpinBox>
enum CopyAction {
CURVE_COPY,
+34 -42
View File
@@ -43,13 +43,9 @@ void RepeatComboBox::update()
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware):
GenericPanel(parent, model, generalSettings, firmware),
functions(model ? model->customFn : generalSettings.customFn)
#if defined(PHONON)
,
phononCurrent(-1),
clickObject(NULL),
clickOutput(NULL)
#endif
functions(model ? model->customFn : generalSettings.customFn),
mediaPlayerCurrent(-1),
mediaPlayer(NULL)
{
Stopwatch s1("CustomFunctionsPanel - populate");
lock = true;
@@ -178,14 +174,12 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
paramLayout->addWidget(fswtchBLcolor[i]);
connect(fswtchBLcolor[i], SIGNAL(sliderReleased()), this, SLOT(customFunctionEdited()));
#ifdef PHONON
playBT[i] = new QPushButton(this);
playBT[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
playBT[i]->setProperty("index", i);
playBT[i]->setIcon(playIcon);
paramLayout->addWidget(playBT[i]);
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
#endif
QHBoxLayout * repeatLayout = new QHBoxLayout();
tableLayout->addLayout(i, 4, repeatLayout);
@@ -220,35 +214,42 @@ CustomFunctionsPanel::~CustomFunctionsPanel()
{
}
#ifdef PHONON
void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::State oldState)
void CustomFunctionsPanel::onMediaPlayerStateChanged(QMediaPlayer::State state)
{
if (!lock) {
lock = true;
if ((newState==Phonon::ErrorState || newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) {
clickObject->stop();
clickObject->clearQueue();
clickObject->clear();
if (phononCurrent >= 0) {
playBT[phononCurrent]->setIcon(CompanionIcon("play.png"));
phononCurrent = -1;
if (state==QMediaPlayer::StoppedState || state==QMediaPlayer::PausedState) {
mediaPlayer->stop();
if (mediaPlayerCurrent >= 0) {
playBT[mediaPlayerCurrent]->setIcon(CompanionIcon("play.png"));
mediaPlayerCurrent = -1;
}
}
lock = false;
}
}
void CustomFunctionsPanel::onMediaPlayerError(QMediaPlayer::Error error)
{
if (!lock) {
lock = true;
if (mediaPlayerCurrent >= 0) {
playBT[mediaPlayerCurrent]->setIcon(CompanionIcon("play.png"));
mediaPlayerCurrent = -1;
}
lock = false;
}
}
void CustomFunctionsPanel::playMusic()
{
if (!clickObject) {
clickObject = new Phonon::MediaObject(this);
clickOutput = new Phonon::AudioOutput(Phonon::NoCategory, this);
Phonon::createPath(clickObject, clickOutput);
connect(clickObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(mediaPlayer_state(Phonon::State, Phonon::State)));
if (!mediaPlayer) {
mediaPlayer = new QMediaPlayer(this);
connect(mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(onMediaPlayerStateChanged(QMediaPlayer::State)));
connect(mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(onMediaPlayerError(QMediaPlayer::Error)));
}
QPushButton * button = qobject_cast<QPushButton*>(sender());
int index = button->property("index").toInt();
int index = sender()->property("index").toInt();
QString path = g.profile[g.id()].sdPath();
QDir qd(path);
QString track;
@@ -272,29 +273,22 @@ void CustomFunctionsPanel::playMusic()
return;
}
if (phononCurrent == index) {
clickObject->stop();
clickObject->clear();
if (mediaPlayerCurrent == index) {
mediaPlayer->stop();
playBT[index]->setIcon(CompanionIcon("play.png"));
phononCurrent = -1;
mediaPlayerCurrent = -1;
}
else {
if (phononCurrent >= 0) {
playBT[phononCurrent]->setIcon(CompanionIcon("play.png"));
if (mediaPlayerCurrent >= 0) {
playBT[mediaPlayerCurrent]->setIcon(CompanionIcon("play.png"));
}
phononCurrent = index;
clickObject->clear();
#ifdef __APPLE__
clickObject->setCurrentSource(QUrl("file://"+track));
#else
clickObject->setCurrentSource(QUrl(track));
#endif
clickObject->play();
mediaPlayerCurrent = index;
mediaPlayer->setMedia(QUrl::fromLocalFile(track));
mediaPlayer->play();
playBT[index]->setIcon(CompanionIcon("stop.png"));
}
}
}
#endif
#define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0)
#define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1)
@@ -526,9 +520,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT);
fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE);
fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR);
#ifdef PHONON
playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY);
#endif
}
void CustomFunctionsPanel::update()
+7 -21
View File
@@ -3,24 +3,14 @@
#include "modeledit.h"
#include "eeprominterface.h"
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QTimeEdit>
#ifdef PHONON
#include <phonon/audiooutput.h>
#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#endif
#include <QtMultimedia>
class RepeatComboBox: public QComboBox
{
Q_OBJECT
public:
RepeatComboBox(QWidget *parent, int & repeatParam);
RepeatComboBox(QWidget * parent, int & repeatParam);
void update();
signals:
@@ -35,7 +25,7 @@ class RepeatComboBox: public QComboBox
class CustomFunctionsPanel : public GenericPanel
{
Q_OBJECT
Q_OBJECT
public:
CustomFunctionsPanel(QWidget *parent, ModelData * mode, GeneralSettings & generalSettings, Firmware * firmware);
@@ -52,10 +42,9 @@ class CustomFunctionsPanel : public GenericPanel
void fsw_customContextMenuRequested(QPoint pos);
void refreshCustomFunction(int index, bool modified=false);
void onChildModified();
#ifdef PHONON
void playMusic();
void mediaPlayer_state(Phonon::State newState, Phonon::State oldState);
#endif
void onMediaPlayerStateChanged(QMediaPlayer::State state);
void onMediaPlayerError(QMediaPlayer::Error error);
void fswDelete();
void fswCopy();
void fswPaste();
@@ -68,7 +57,7 @@ class CustomFunctionsPanel : public GenericPanel
QSet<QString> tracksSet;
QSet<QString> scriptsSet;
int phononCurrent;
int mediaPlayerCurrent;
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS];
@@ -81,10 +70,7 @@ class CustomFunctionsPanel : public GenericPanel
RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
QSlider * fswtchBLcolor[C9X_MAX_CUSTOM_FUNCTIONS];
#ifdef PHONON
Phonon::MediaObject *clickObject;
Phonon::AudioOutput *clickOutput;
#endif
QMediaPlayer * mediaPlayer;
int selectedFunction;
+1 -1
View File
@@ -154,7 +154,7 @@ void ExpoDialog::valuesChanged()
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
ed->mode = ui->sideCB->currentIndex() + 1;
strcpy(ed->name, ui->lineName->text().toAscii().data());
strcpy(ed->name, ui->lineName->text().toLatin1().data());
if (firmware->getCapability(VirtualInputs)) {
inputName = ui->inputName->text();
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef EXPODIALOG_H
#define EXPODIALOG_H
#include <QDialog>
#include <QtWidgets>
#include "eeprominterface.h"
#include "modelprinter.h"
+2 -5
View File
@@ -1,9 +1,6 @@
#include "flightmodes.h"
#include "ui_flightmode.h"
// #include "firmwares/opentx/opentxeeprom.h" // TODO shouldn't be there
#include "helpers.h"
#include <QComboBox>
#include <QGridLayout>
FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware),
@@ -244,7 +241,7 @@ void FlightModePanel::update()
void FlightModePanel::phaseName_editingFinished()
{
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender());
strcpy(phase.name, lineEdit->text().toAscii());
strcpy(phase.name, lineEdit->text().toLatin1());
emit modified();
emit nameModified();
}
@@ -312,7 +309,7 @@ void FlightModePanel::GVName_editingFinished()
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
int gvar = lineedit->property("index").toInt();
memset(&model->gvars_names[gvar], 0, sizeof(model->gvars_names[gvar]));
strcpy(model->gvars_names[gvar], lineedit->text().toAscii());
strcpy(model->gvars_names[gvar], lineedit->text().toLatin1());
emit modified();
}
}
-6
View File
@@ -3,12 +3,6 @@
#include "modeledit.h"
#include "eeprominterface.h"
#include <QVector>
#include <QLabel>
#include <QTabWidget>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
namespace Ui {
class FlightMode;
+7 -9
View File
@@ -1,5 +1,4 @@
#include "inputs.h"
#include <QMessageBox>
#include "expodialog.h"
#include "helpers.h"
@@ -199,7 +198,7 @@ void InputsPanel::gm_openExpo(int index)
if (g->exec()) {
model->expoData[index] = mixd;
if (firmware->getCapability(VirtualInputs))
strncpy(model->inputNames[mixd.chn], inputName.toAscii().data(), 4);
strncpy(model->inputNames[mixd.chn], inputName.toLatin1().data(), 4);
emit modified();
update();
}
@@ -288,8 +287,6 @@ void InputsPanel::mimeExpoDropped(int index, const QMimeData *data, Qt::DropActi
pasteExpoMimeData(data, idx);
}
#include <iostream>
#include <QtGui/qwidget.h>
void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
{
if (mimeData->hasFormat("application/x-companion-expo")) {
@@ -325,11 +322,12 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
void InputsPanel::exposPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
QListWidgetItem *item = ExposlistWidget->currentItem();
if (item)
pasteExpoMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0));
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
QListWidgetItem *item = ExposlistWidget->currentItem();
if (item) {
pasteExpoMimeData(mimeData, item->data(Qt::UserRole).toByteArray().at(0));
}
}
void InputsPanel::exposDuplicate()
@@ -1,10 +1,4 @@
#include "logicalswitches.h"
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QDoubleSpinBox>
#include "helpers.h"
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
@@ -3,9 +3,6 @@
#include "modeledit.h"
#include "eeprominterface.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QTimeEdit>
class LogicalSwitchesPanel : public ModelPanel
{
+1 -2
View File
@@ -159,8 +159,7 @@ void MixerDialog::valuesChanged()
md->delayUp = round(ui->delayUpSB->value()*scale);
md->speedDown = round(ui->slowDownSB->value()*scale);
md->speedUp = round(ui->slowUpSB->value()*scale);
strcpy(md->name, ui->mixerName->text().toAscii());
strcpy(md->name, ui->mixerName->text().toLatin1());
md->flightModes = 0;
for (int i=8; i>=0 ; i--) {
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef MIXERDIALOG_H
#define MIXERDIALOG_H
#include <QDialog>
#include <QtWidgets>
#include "eeprominterface.h"
class GVarGroup;
+1 -2
View File
@@ -1,8 +1,7 @@
#ifndef MIXERSLIST_H
#define MIXERSLIST_H
#include <QtGui>
#include <QtWidgets>
#define MIX_ROW_HEIGHT_INCREASE 8 //how much space is added above mixer row (for new channel), if 0 space adding is disabled
const int GroupHeaderRole = (Qt::UserRole+2); //defines new user role for list items. If value is > 0, then space is added before that item
-2
View File
@@ -1,7 +1,5 @@
#include "mixes.h"
#include "helpers.h"
// #include <QMessageBox>
// #include "expodialog.h"
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware),
-1
View File
@@ -13,7 +13,6 @@
#include "customfunctions.h"
#include "telemetry.h"
#include "appdata.h"
#include <QScrollArea>
ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmware * firmware) :
QDialog(parent),
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef MODELEDIT_H
#define MODELEDIT_H
#include <QDialog>
#include <QtWidgets>
#include "genericpanel.h"
class RadioData;
+1 -1
View File
@@ -42,7 +42,7 @@
#ifndef NODE_H
#define NODE_H
#include <QtGui>
#include <QtWidgets>
#define DEFAULT_BALL_SIZE 10
#define BALL_HEIGHT 2
+3 -3
View File
@@ -115,7 +115,7 @@ void TimerPanel::on_minuteBeep_toggled(bool checked)
void TimerPanel::on_name_editingFinished()
{
int length = ui->name->maxLength();
strncpy(timer.name, ui->name->text().toAscii(), length);
strncpy(timer.name, ui->name->text().toLatin1(), length);
emit modified();
}
@@ -728,14 +728,14 @@ void SetupPanel::on_throttleSource_currentIndexChanged(int index)
void SetupPanel::on_name_editingFinished()
{
int length = ui->name->maxLength();
strncpy(model->name, ui->name->text().toAscii(), length);
strncpy(model->name, ui->name->text().toLatin1(), length);
emit modified();
}
void SetupPanel::on_image_currentIndexChanged(int index)
{
if (!lock) {
strncpy(model->bitmap, ui->image->currentText().toAscii(), 10);
strncpy(model->bitmap, ui->image->currentText().toLatin1(), 10);
QString path = g.profile[g.id()].sdPath();
path.append("/BMP/");
QDir qd(path);
-6
View File
@@ -3,12 +3,6 @@
#include "modeledit.h"
#include "eeprominterface.h"
#include <QVector>
#include <QCheckBox>
#include <QSlider>
#include <QSpinBox>
#include <QComboBox>
#include <QLabel>
namespace Ui {
class Setup;
+1 -1
View File
@@ -648,7 +648,7 @@ void TelemetrySensorPanel::updateSourcesComboBox(AutoComboBox * cb, bool negativ
void TelemetrySensorPanel::on_name_editingFinished()
{
if (!lock) {
strcpy(sensor.label, ui->name->text().toAscii());
strcpy(sensor.label, ui->name->text().toLatin1());
emit dataModified();
emit modified();
}
-3
View File
@@ -3,9 +3,6 @@
#include "modeledit.h"
#include "eeprominterface.h"
#include <QGroupBox>
#include <QComboBox>
#include <QDoubleSpinBox>
class AutoComboBox;
-2
View File
@@ -1,6 +1,4 @@
#include "templates.h"
#include <QListWidget>
#include <QMessageBox>
#define CHANNEL_ORDER(x) generalSettings.getDefaultStick(x)
#define CC(x) (CHANNEL_ORDER(x)) //need to invert this to work with dest
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef TEMPLATES_H
#define TEMPLATES_H
#include <QWidget>
#include <QtWidgets>
#include "eeprominterface.h"
class Templates : public QWidget