Commit fa14fde0 authored by floreal797's avatar floreal797

add insert video youtube, improve insert image, activer bootons toolbar quand...

add insert video youtube, improve insert image, activer bootons toolbar quand utiles, edit insert image and movie tags, ...
parent 24d8fb9c
......@@ -26,5 +26,8 @@
<file>images/QCeCWriter.png</file>
<file>images/print.png</file>
<file>images/noprint.png</file>
<file>images/movie.png</file>
<file>images/media_aspect_ratio.png</file>
<file>images/media_aspect_ratio_blanc.png</file>
</qresource>
</RCC>
This diff is collapsed.
......@@ -23,6 +23,8 @@
#include "sendautomatic.h"
#include "spellcheckdialog.h"
#include "spellchecker.h"
#include "insertvideo.h"
#include "insertpicture.h"
#include "filedownloader.h"
#include <QMainWindow>
......@@ -175,6 +177,18 @@ private slots:
void on_minRep_editingFinished();
void on_movie_clicked();
void on_editIngr_selectionChanged();
void on_editMat_selectionChanged();
void on_editPrep_selectionChanged();
void on_editCons_selectionChanged();
void on_description_selectionChanged();
public slots:
void init();
void config();
......
......@@ -26,7 +26,9 @@ SOURCES += main.cpp\
sendautomatic.cpp \
spellcheckdialog.cpp \
spellchecker.cpp \
filedownloader.cpp
filedownloader.cpp \
insertvideo.cpp \
insertpicture.cpp
HEADERS += cecwriter.h \
options.h \
......@@ -41,7 +43,9 @@ HEADERS += cecwriter.h \
sendautomatic.h \
spellcheckdialog.h \
spellchecker.h \
filedownloader.h
filedownloader.h \
insertvideo.h \
insertpicture.h
FORMS += cecwriter.ui \
options.ui \
......@@ -49,7 +53,9 @@ FORMS += cecwriter.ui \
apropos.ui \
sendmanual.ui \
sendautomatic.ui \
spellcheckdialog.ui
spellcheckdialog.ui \
insertvideo.ui \
insertpicture.ui
RESOURCES += \
Ressources.qrc
......
This diff is collapsed.
......@@ -30,6 +30,7 @@ extern QString addrPub;
extern QString systExp;
extern QString editPict;
extern QString corrOrtho;
extern bool cecPrinter;
extern QMap<QString, QString> liens;
......@@ -124,6 +125,11 @@ void Functions::loadConfig()
dirDistPict = xml.text().toString();
continue;
}
if(xml.name() == "cecPrinter") {
xml.readNext();
cecPrinter = xml.text().toString() == "1" ? true: false;
continue;
}
}
}
......@@ -632,23 +638,73 @@ QString Functions::insertLinks(QString data)
*/
QString Functions::insertPictures(QString data)
{
QRegExp exp ("\\[IMG:(\\w+):([^\\]]+)\\]");
QRegExp exp ("\\[IMG:(\\w+):(\\d+):(\\d+):([^\\]]+)\\]");
while (data.contains(exp))
{
QString imgBal = exp.cap(0);
QString className = exp.cap(1);
QString img = exp.cap(2);
QString largeur = exp.cap(2);
QString hauteur = exp.cap(3);
QString img = exp.cap(4);
QString classDef = "";
if (className != "all") {
classDef = " class=\"" + className + "\"";
}
data.replace(imgBal, "<img src=\"" + dirDistPict + img.split("/").last() + "\" alt=\"Image d'illustration\"" + classDef + " /><br/>");
data.replace(imgBal, "<img src=\"" + dirDistPict + img.split("/").last() + "\" alt=\"Image d'illustration\" width=\"" + largeur + "\" height=\"" + hauteur + "\"" + classDef + " /><br/>");
if (!otherPicts.contains(img))
otherPicts.append(img);
}
return data;
}
QString Functions::insertMovies(QString data)
{
QRegExp exp ("\\[VIDEO:(\\d+):(\\d+):(\\d+):(\\d+):([01]+):([01]+):([01]+):([01]+):([01]+):([\\w-]+)\\]");
while (data.contains(exp)) {
QString balise = exp.cap(0);
QString largeur = exp.cap(1);
QString hauteur = exp.cap(2);
QString startTime = exp.cap(3);
QString bordure = exp.cap(4);
bool fullscreen = (exp.cap(5) == "1" ? true : false);
bool suggestions = (exp.cap(6) == "1" ? true : false);
bool commandes = (exp.cap(7) == "1" ? true : false);
bool titreVideo = (exp.cap(8) == "1" ? true : false);
bool confidentialite = (exp.cap(9) == "1" ? true : false);
QString idVideo = exp.cap(10);
QStringList params;
if (!suggestions) {
params.append("rel=0");
}
if (!commandes) {
params.append("controls=0");
}
if (!titreVideo) {
params.append("showinfo=0");
}
QString url = "https://www.youtube";
if (confidentialite) {
url += "-nocookie";
}
url += ".com/embed/" + idVideo;
params.append("start=" + startTime);
if (params.size() > 0) {
QString stringParams = params.join("&amp;");
url += "?";
url += stringParams;
}
QString html = "<iframe class=\"noprint\" width=\"" + largeur + "\" height=\"" + hauteur + "\" src=\"" + url + "\" frameborder=\"" + bordure + "\"";
if (fullscreen) {
html += " allowfullscreen";
}
html +="></iframe>";
data.replace(balise, html);
}
return data;
}
/**
* @brief Functions::makeTimes
* @param hPrep
......@@ -779,7 +835,7 @@ QString Functions::generateHtmlCode(QString titre, QString mainPicture, int hPre
htmlCode = htmlCode + "<conseils><p><b>Conseils :</b></p>"+conseils+"</conseils>";
}
//Adding "Version imprimable" balise, only if the website is Conseils En Cuisine !, because others might not use it:
if (addrSite == "http://www.conseilsencuisine.fr") {
if (cecPrinter) {
htmlCode = htmlCode + "<br/>[VERSION_IMPRIMABLE]";
}
//Replace oe by "e dans l'o", because we speak French :
......@@ -787,6 +843,8 @@ QString Functions::generateHtmlCode(QString titre, QString mainPicture, int hPre
htmlCode = setPrintTags(htmlCode);
htmlCode = insertMovies(htmlCode);
return htmlCode;
}
......
......@@ -64,6 +64,7 @@ public:
static QString getNumberedList(QStringList items);
static QString insertLinks(QString data);
static QString insertPictures(QString data);
static QString insertMovies(QString data);
static QStringList getSelectedCategories(QMap<QCheckBox*, QString> categories);
static QStringList makeTimes (int hPrep, int minPrep, int hCuis, int minCuis, int jRep,
int hRep, int minRep);
......
images/abc.png

1.03 KB | W: | H:

images/abc.png

638 Bytes | W: | H:

images/abc.png
images/abc.png
images/abc.png
images/abc.png
  • 2-up
  • Swipe
  • Onion skin
images/img.png

3.97 KB | W: | H:

images/img.png

3.66 KB | W: | H:

images/img.png
images/img.png
images/img.png
images/img.png
  • 2-up
  • Swipe
  • Onion skin
images/lien_button.png

1.42 KB | W: | H:

images/lien_button.png

1.14 KB | W: | H:

images/lien_button.png
images/lien_button.png
images/lien_button.png
images/lien_button.png
  • 2-up
  • Swipe
  • Onion skin
images/splash.jpg

368 KB | W: | H:

images/splash.jpg

308 KB | W: | H:

images/splash.jpg
images/splash.jpg
images/splash.jpg
images/splash.jpg
  • 2-up
  • Swipe
  • Onion skin
#include "insertpicture.h"
#include "ui_insertpicture.h"
extern QString dirPict;
extern bool cecPrinter;
InsertPicture::InsertPicture(QWidget *parent) :
QDialog(parent),
ui(new Ui::InsertPicture)
{
ui->setupUi(this);
}
void InsertPicture::init(QString imgFile, QString afficher, int width, int height, QString filename) {
ok = false;
//Icon of keepRation button:
QColor colorBut = ui->keepRatio->palette().color(QPalette::Background);
if ((colorBut.red() + colorBut.green() + colorBut.blue()) / 3 < 127.5)
{
ui->keepRatio->setIcon(QPixmap(":/images/media_aspect_ratio_blanc.png"));
}
//Set width and height;
if (width == -1 || height == -1) {
QPixmap* img = new QPixmap(imgFile);
w = img->width();
h = img->height();
delete img;
img = NULL;
}
else {
w = width;
h = height;
}
ui->largeur->setValue(w);
ui->hauteur->setValue(h);
ui->filename->setText(filename);
//Set conf affichage :
if (afficher == "all") {
ui->printAll->setChecked(true);
}
else if (afficher == "noprint") {
ui->noPrint->setChecked(true);
}
else if (afficher == "printonly") {
ui->printOnly->setChecked(true);
}
if (!cecPrinter) {
ui->noPrint->setDisabled(true);
ui->noPrint->setToolTip("Nécessite d'activer CeC printer");
ui->printOnly->setDisabled(true);
ui->printOnly->setToolTip("Nécessite d'activer CeC printer");
}
}
InsertPicture::~InsertPicture()
{
delete ui;
}
void InsertPicture::on_buttonBox_accepted()
{
ok = true;
if (ui->printAll->isChecked()) {
print = "all";
}
else if (ui->printOnly->isChecked()) {
print = "printonly";
}
else if (ui->noPrint->isChecked()) {
print = "noprint";
}
else {
ok = false;
}
filename = ui->filename->text();
if (filename != "") {
largeur = QString::number(ui->largeur->value());
hauteur = QString::number(ui->hauteur->value());
this->close();
}
else {
QMessageBox::critical(this, "Fichier image requis", "Veuillez entrer un nom de fichier image !");
}
}
void InsertPicture::on_buttonBox_rejected()
{
this->close();
}
void InsertPicture::on_largeur_valueChanged(int arg1)
{
if (ui->keepRatio->isChecked() && ui->largeur->hasFocus()) {
ui->hauteur->setValue((arg1 * h) / w);
}
}
void InsertPicture::on_hauteur_valueChanged(int arg1)
{
if (ui->keepRatio->isChecked() && ui->hauteur->hasFocus()) {
ui->largeur->setValue((arg1 * w) / h);
}
}
void InsertPicture::on_changePicture_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, "Choisir une image",
dirPict,
"Images : *.jpg, *.JPG (*.jpg *.JPG)");
if (fileName != "") {
ui->filename->setText(fileName);
QPixmap* img = new QPixmap(fileName);
w = img->width();
h = img->height();
delete img;
img = NULL;
ui->largeur->setValue(w);
ui->hauteur->setValue(h);
}
}
#ifndef INSERTPICTURE_H
#define INSERTPICTURE_H
#include <QDialog>
#include <QFileDialog>
#include <QMessageBox>
#include <QPixmap>
namespace Ui {
class InsertPicture;
}
class InsertPicture : public QDialog
{
Q_OBJECT
public:
explicit InsertPicture(QWidget *parent = 0);
~InsertPicture();
private:
Ui::InsertPicture *ui;
public:
int w,h;
bool ok;
void init(QString imgFile, QString afficher, int width, int height, QString filename);
QString print, largeur, hauteur, filename;
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_largeur_valueChanged(int arg1);
void on_hauteur_valueChanged(int arg1);
void on_changePicture_clicked();
};
#endif // INSERTPICTURE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InsertPicture</class>
<widget class="QDialog" name="InsertPicture">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>444</width>
<height>286</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>444</width>
<height>286</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>444</width>
<height>286</height>
</size>
</property>
<property name="windowTitle">
<string>Configuration de l'image</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="filename">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="changePicture">
<property name="text">
<string>Changer d'image...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>201</width>
<height>161</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>201</width>
<height>161</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Affichage de l'image :</string>
</property>
<widget class="QRadioButton" name="printAll">
<property name="geometry">
<rect>
<x>0</x>
<y>40</y>
<width>171</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Afficher et imprimer</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="noPrint">
<property name="geometry">
<rect>
<x>0</x>
<y>70</y>
<width>171</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Afficher seulement</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QRadioButton" name="printOnly">
<property name="geometry">
<rect>
<x>0</x>
<y>100</y>
<width>171</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Imprimer seulement</string>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>201</width>
<height>161</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>201</width>
<height>161</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Taille de l'image :</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Largeur :</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>0</x>
<y>90</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Hauteur :</string>
</property>
</widget>
<widget class="QSpinBox" name="largeur">
<property name="geometry">
<rect>
<x>0</x>
<y>60</y>
<width>91</width>
<height>28</height>
</rect>
</property>
<property name="maximum">
<number>1000000000</number>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>100</x>
<y>60</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>pixels</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>100</x>
<y>120</y>
<width>61</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>pixels</string>
</property>
</widget>
<widget class="QSpinBox" name="hauteur">
<property name="geometry">
<rect>
<x>0</x>
<y>120</y>
<width>91</width>
<height>28</height>
</rect>
</property>
<property name="maximum">
<number>1000000000</number>
</property>
</widget>
<widget class="QPushButton" name="keepRatio">
<property name="geometry">
<rect>
<x>150</x>
<y>90</y>
<width>30</width>
<height>28</height>
</rect>
</property>
<property name="toolTip">
<string>Conserver le ratio</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="Ressources.qrc">
<normaloff>:/images/media_aspect_ratio.png</normaloff>:/images/media_aspect_ratio.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="Ressources.qrc"/>
</resources>
<connections/>
</ui>
#include "insertvideo.h"
#include "ui_insertvideo.h"
InsertVideo::InsertVideo(QWidget *parent) :
QDialog(parent),
ui(new Ui::InsertVideo)
{
ui->setupUi(this);
}
void InsertVideo::init(int largeur, int hauteur, int startTime, int bordure, bool fullscreen, bool suggestions, bool commandes, bool titreVideo, bool confidentialite, QString idVideo) {
//Reset values: