From 8591a1436768ac3a0756e0e75990465807631c29 Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Sun, 8 Jun 2014 18:27:43 +0200 Subject: [PATCH] history now add a "del" buttons after each entry to delete this entry from way --- mainwindow.cpp | 52 +++++++++++++++++++++++++++++++------------------- mainwindow.h | 1 + 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 20ccb65..e5e0580 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -172,7 +172,7 @@ void MainWindow::action(const QString &a){ } else if(b[0]==QString("setint")){ bool ok; - QString e=QInputDialog::getInt(this, "setInt", b[1] , conf->value(QString(b[1])).toInt(), 0, 100, 1, &ok); + int e=QInputDialog::getInt(this, "setInt", b[1] , conf->value(QString(b[1])).toInt(), 0, 100, 1, &ok); if(ok)conf->setValue(b[1], e); } else if(b[0]==QString("start")){ @@ -253,17 +253,26 @@ void MainWindow::action(const QString &a){ } download(a, aa); connect(m, SIGNAL(downloaded()), SLOT(writeFile())); + } + else if(b[0]==QString("play")){ + } else if(b[0]==QString("vid")){ addMedia(c); } else if(b[0]==QString("history")){ flush(); - //addWidget(QString("back"), new CLabel(trUtf8("back", "label of history's \"back\" button"), conf->value(QString("button")).toString())); + QString wi; for(int i=0; ivalue(QString("button")).toString())); + wi=way[i]; + addWidget(QString(wi), new CLabel(QString(wi), conf->value(QString("button")).toString())); + addWidget(QString("rm "+i), new CLabel(QString("del")), conf->value(QString("button")).toString()); + } } + else if(b[0]==QString("rm")){ + way.removeAt(b[1]); + } else if(b[0]==QString("read")){ QFile a(b[1]); a.open(QIODevice::ReadOnly); @@ -568,8 +577,7 @@ void MainWindow::RAWsent(){ QMessageBox::information(this, trUtf8("RAWsent", "message title when data has been send"), trUtf8("sendRAW finish", "message text when data has been send")); } void MainWindow::back(){ - if(label->text()!=QString("video")){ - flush(); + if(!((video)&&(playlist))){ getButtons(conf->value(QString("menuback")).toString()); }else{ getButtons(QString("+video")); @@ -635,10 +643,10 @@ void MainWindow::readData(const QByteArray &in){ for(int i=1; iprepare(d); int b=in.split('\n').at(i).count('$'); - qDebug()<bindValue(j, QString(in.split('\n').at(i).split('$').at(j))); - qDebug()<<"bind "<exec() : "<exec()<<" lastError()="<lastError(); @@ -776,25 +784,29 @@ void MainWindow::writeFile(){ } void MainWindow::addMedia(const QString & a){ if((video)&&(playlist)){ - playlist->addMedia(QMediaResource(a)); + playlist->addMedia(QUrl(a)); }else{ flush(); - video=new QMediaPlayer(this); - videoWidget=new QVideoWidget(this); - playlist=new QMediaPlaylist(this); - video->setVideoOutput(videoWidget); + + playlist = new QMediaPlaylist; + playlist->addMedia(QUrl::fromLocalFile(a)); + playlist->setCurrentIndex(1); + + video = new QMediaPlayer; video->setPlaylist(playlist); - playlist->load(QUrl(a)); - int c=grid->count(); - int maxc=conf->value(QString("maxcolumn")).toInt(); - //if(!orientation) - grid->addWidget(videoWidget, c/maxc, c%maxc, 1, -1, Qt::AlignJustify| Qt::AlignVCenter | Qt::AlignHCenter); - //else grid->addWidget(videoWidget, c/maxc, c%maxc, -1, 1, Qt::AlignJustify| Qt::AlignVCenter | Qt::AlignHCenter); - label->setText(QString("video")); - video->play(); + + videoWidget = new QVideoWidget; + video->setVideoOutput(videoWidget); + videoWidget->show(); + grid->addWidget(videoWidget,0,0,1,-1); + connect(video, SIGNAL(videoAvailableChanged(bool)), video, SLOT(play())); + } } +void MainWindow::play(){ + video->play(); +} void MainWindow::resizeEvent(QResizeEvent *event) { QSize size = event->size(); diff --git a/mainwindow.h b/mainwindow.h index fc06476..b467f99 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -133,6 +133,7 @@ public: const CLabel* addWidget(const QString &, const CLabel *); void resizeEvent(QResizeEvent *); private slots: + void play(); void datasent(); void back(); void start(); -- 2.45.1