/* ============================================================
 * File  : mainfrm.cpp
 * Author: Stephane Gibault
 * Date  : Sun Feb 4 2007
 * Description :
 *
 * 
 *  (C) 2007 by Stephane Gibault
 *
 * 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 2, 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.
 *
 * ============================================================ */

#include <QtGui>
#include "mainfrm.h"
/*#include "tetrahedron.h"
#include "texteditor.h"
#include "timeline.h"
#include "diapo.h"
#include "wheel.h"
#include "imageeditor.h"*/

/*class H_Slider_Theme_1 : public QWindowsStyle
{
	public:
	const QImage IMG_SLIDER_HANDLE;
	const QImage IMG_SLIDER_GROOVE;

  	H_Slider_Theme_1 ()
    		//: IMG_SLIDER_HANDLE (":/new/prefix2/Interface/Theme/folder.png"),
      		//IMG_SLIDER_GROOVE (":/new/prefix2/Interface/Theme/folder.png")
  	{
  	};
  
  	virtual void drawComplexControl (ComplexControl control,
                   const QStyleOptionComplex* option,
                   QPainter* painter,
                   const QWidget* widget) const;
};

void
	H_Slider_Theme_1::drawComplexControl (ComplexControl control,
		const QStyleOptionComplex* option,
        	QPainter* painter,
        	const QWidget* widget) const
{
  		switch (control)
    		{
    			case (QStyle::CC_Slider):
      				if (const QStyleOptionSlider *sliderOption = qstyleoption_cast<const QStyleOptionSlider *>(option)) 
    				{
      					QRect groove = QCommonStyle::subControlRect (CC_Slider, sliderOption, SC_SliderGroove, widget);
     					QRect handle = QCommonStyle::subControlRect (CC_Slider, sliderOption, SC_SliderHandle, widget);
      
      					if ((sliderOption->subControls & SC_SliderGroove) && groove.isValid()) 
        				{
						painter->setRenderHint(QPainter::Antialiasing,true);
						painter->setPen(QColor(100,100,100,255));
						QLinearGradient Gradient1(5.0, 5.0,0.0,5.0);
						Gradient1.setColorAt(1.0, QColor(20,20,20,255));
						Gradient1.setColorAt(0.0, QColor(50,50,50,255));
						painter->setBrush(Gradient1);
						painter->drawEllipse(0, 1, 10, 10);
						QLinearGradient Gradient2(groove.width () - 5.0, 5.0,groove.width (),5.0);
						Gradient2.setColorAt(1.0, QColor(20,20,20,255));
						Gradient2.setColorAt(0.0, QColor(80,80,80,255));
						painter->setBrush(Gradient2);
						painter->drawEllipse(groove.width () - 10, 1, 10, 10);
						QLinearGradient Gradient3(0.0, 6.0,groove.width ()-12.0,5.0);
						Gradient3.setColorAt(0.0, QColor(50,50,50,255));
						Gradient3.setColorAt(1.0, QColor(80,80,80,255));
						painter->drawRect ( 6.0, 1.0, groove.width ()-12.0, 10.0 ); //, QBrush(Gradient3)
						painter->setPen(Qt::NoPen);
						painter->fillRect ( 5.0, 2.0, groove.width ()-10.0, 8.0, QBrush(Gradient3));
        				}
      
      					if (sliderOption->subControls & SC_SliderHandle) 
       					{
						if ( handle.x () > 0 )
						{
							painter->setBrush(QColor(255,255,255,255));
							painter->drawEllipse(2.0, 3.0, 6.0, 6.0);
							painter->fillRect ( 5.0, 3.0, handle.x (), 6.0, QBrush(QColor(255,255,255,255)));
						}
						painter->setPen(Qt::SolidLine);
						painter->setBrush(QColor(205,224,228,255));
						painter->drawEllipse(handle.x () + 1 , handle.y ()+2, 10, 8);
        				}
    				}
      				break;
    				default:
      				QWindowsStyle::drawComplexControl (control, option, painter, widget);
    		}
}*/

class H_Slider_Theme_2 : public QWindowsStyle
{
	public:
	const QImage IMG_SLIDER_HANDLE;
	const QImage IMG_SLIDER_GROOVE;

  	H_Slider_Theme_2 ()
  	{
  	};
  
  	virtual void drawComplexControl (ComplexControl control,
                   const QStyleOptionComplex* option,
                   QPainter* painter,
                   const QWidget* widget) const;
};

void
	H_Slider_Theme_2::drawComplexControl (ComplexControl control,
		const QStyleOptionComplex* option,
        	QPainter* painter,
        	const QWidget* widget) const
{
  		switch (control)
    		{
    			case (QStyle::CC_Slider):
      				if (const QStyleOptionSlider *sliderOption = qstyleoption_cast<const QStyleOptionSlider *>(option)) 
    				{
      					QRect groove = QCommonStyle::subControlRect (CC_Slider, sliderOption, SC_SliderGroove, widget);
     					QRect handle = QCommonStyle::subControlRect (CC_Slider, sliderOption, SC_SliderHandle, widget);
      
      					if ((sliderOption->subControls & SC_SliderGroove) && groove.isValid()) 
        				{
						painter->setRenderHint(QPainter::Antialiasing,true);
						painter->setPen(QColor(100,100,100,255));
						QLinearGradient Gradient1(5.0, 5.0,0.0,5.0);
						Gradient1.setColorAt(1.0, QColor(120,120,120,255));
						Gradient1.setColorAt(0.0, QColor(150,150,150,255));
						painter->setBrush(Gradient1);
						painter->drawEllipse(0, 1, 10, 10);
						QLinearGradient Gradient2(groove.width () - 5.0, 5.0,groove.width (),5.0);
						Gradient2.setColorAt(1.0, QColor(120,120,120,255));
						Gradient2.setColorAt(0.0, QColor(180,180,180,255));
						painter->setBrush(Gradient2);
						painter->drawEllipse(groove.width () - 10, 1, 10, 10);
						QLinearGradient Gradient3(0.0, 6.0,groove.width ()-12.0,5.0);
						Gradient3.setColorAt(0.0, QColor(150,150,150,255));
						Gradient3.setColorAt(1.0, QColor(180,180,180,255));
						painter->drawRect ( 6.0, 1.0, groove.width ()-12.0, 10.0 ); //, QBrush(Gradient3)
						painter->setPen(Qt::NoPen);
						painter->fillRect ( 5.0, 2.0, groove.width ()-10.0, 8.0, QBrush(Gradient3));
        				}
      
      					if (sliderOption->subControls & SC_SliderHandle) 
       					{
						if ( handle.x () > 0 )
						{
							painter->setBrush(QColor(255,255,255,255));
							painter->drawEllipse(2.0, 3.0, 6.0, 6.0);
							painter->fillRect ( 5.0, 3.0, handle.x (), 6.0, QBrush(QColor(255,255,255,255)));
						}
						painter->setPen(Qt::SolidLine);
						painter->setBrush(QColor(205,224,228,255));
						painter->drawEllipse(handle.x () + 1 , handle.y ()+2, 10, 8);
        				}
    				}
      				break;
    				default:
      				QWindowsStyle::drawComplexControl (control, option, painter, widget);
    		}
}

mainfrm::mainfrm(QWidget *parent) : QMainWindow(parent)
{
	QPixmap yopixmap(":/new/prefix2/Interface/Theme/splash_smile.jpg");
	QSplashScreen splashy(yopixmap);
	Qt::Alignment sypal = Qt::AlignRight | Qt::AlignBottom;
	splashy.show();
	splashy.showMessage("Loading interface ...",sypal,Qt::black);

	qDebug() << "LOCALE : " << QLocale::system().name().left(2);
	if ( QLocale::system().name().left(2) != "fr" )
	{
		QString wlpack = QLocale::system().name();
		qDebug() << "LOADING LANGUAGE ... smile_" + wlpack.left(2);
		QTranslator *qtTranslator = new QTranslator(this);
		if (qtTranslator->load("smile_" + wlpack.left(2), qApp->applicationDirPath()) == true )
		{
			qApp->installTranslator(qtTranslator);
		}
		else
		{
			if (qtTranslator->load("smile_en", qApp->applicationDirPath()) == true )
			{
				qApp->installTranslator(qtTranslator);
			}
		}
	}
	//
	setupUi(this);

        // *** ZONE 3D ET REGLES DE BASE ***
        Tetrahedron *mygl = new Tetrahedron(frame_ed3d);
        pntmygl = mygl;
        connect(pntmygl, SIGNAL(updfrm(int) ),this, SLOT(f_updfrm(int)));
        connect(pntmygl, SIGNAL(c_copy()),this, SLOT(f_copy()));
        connect(pntmygl, SIGNAL(c_paste()),this, SLOT(f_paste()));
        connect(pntmygl, SIGNAL(c_iedit()),this, SLOT(f_launch_editor()));
        connect(pntmygl, SIGNAL(c_eraser()),this, SLOT(f_raz()));
        connect(pntmygl, SIGNAL(chg_pos_legende()),this, SLOT(f_pos_anim()));
        connect(pntmygl, SIGNAL(sizep()),this, SLOT(f_sizep()));
        connect(pntmygl, SIGNAL(sizem()),this, SLOT(f_sizem()));
        connect(pntmygl, SIGNAL(loadback()),this, SLOT(f_open_bib_fond()));
        connect(actionAfficher_la_grille, SIGNAL(triggered()),pntmygl, SLOT(sl_grille()));
        connect(actionAfficher_rightmenu, SIGNAL(triggered()),this, SLOT(f_hideright()));

	label_version->setText("v0.9.9"); // ***TODO CHANGER A CHAQUE VERSION ***
	mysynctime.start();

	// *** DEFINITION DE LA POLICE ***
	QFont wl_font;
	wl_font.setFamily("DejaVu Sans Condensed");
	wl_font.setPixelSize ( 11 );
	this->setFont(wl_font);

	// *** DEFINITION DU NOMBRE D'OCCURS DE LA TABLE DE TRAVAIL ***
	nbre_occurs = 29;
	nbre_imports = 0;
	etat_lecture = 0;
	old_tab = 0;
	size_dia_x = 720;
	size_dia_y = 576;
	state_timeline = 0;
	frame_ed3d->setGeometry(0,0,size_dia_x,size_dia_y);

	nbre_threads = QThread::idealThreadCount();
	if ( nbre_threads <= 0 )
	{
		nbre_threads = 1;
	}
	if ( nbre_threads > 4 )
	{
		nbre_threads = 4;
	}

	// *** INITIALISATION DES FLAKES ***

	int wl_i = 0;
	srand(time(NULL));
	while ( wl_i < 1500 )
	{
		pntmygl->elements[wl_i][0] = (float)(((float)rand() / ((float)RAND_MAX + 1) * 40)-20); //(float)(rand()%(40))-20;
		pntmygl->elements[wl_i][1] = (float)(((float)rand() / ((float)RAND_MAX + 1) * 40)-20); //(float)(rand()%(40))-32;
		pntmygl->elements[wl_i][2] = (float)(((float)rand() / ((float)RAND_MAX + 1) * 20)*-1); //(float)(rand()%(20))*-1;
		if ( pntmygl->elements[wl_i][2] > -1.90f )
		{
			pntmygl->elements[wl_i][2] = -1.90f;
		}
		wl_i++;
	}

	//

	actionAfficher_la_grille->setShortcut(QKeySequence("Ctrl+G | Ctrl+g"));
	actionAfficher_rightmenu->setShortcut(QKeySequence("Ctrl+M | Ctrl+m"));

	this->setWindowState ( Qt::WindowMaximized );
	this->setFocusPolicy(Qt::StrongFocus);
	frame_ed3d->setFocusPolicy(Qt::NoFocus);
	frame_design->setFocusPolicy(Qt::NoFocus);

	texteditor *pntlabeltxt_1 = new texteditor(frame_widget_txt);
	pntlabeltxt_1->setGeometry(0,0,size_dia_x,size_dia_y);
	pntlabeltxt = pntlabeltxt_1;
	pntlabeltxt->size_dia_x = size_dia_x;
	pntlabeltxt->size_dia_y = size_dia_y;

	// *** DECLARATION DES THREADS ***
	thimg *myth = new thimg();
	thread_img = myth;

	ththu *mytu = new ththu();
	thread_thu = mytu;

	thtra *mytr = new thtra();
	thread_tra = mytr;

	thani *myta = new thani();
	thread_ani = myta;
	connect(thread_ani, SIGNAL(hidecomplex()),this, SLOT(f_hide_complex()));

	thptra *mytp = new thptra();
	thread_ptra = mytp;

	// *** PREPARATION DE L'INTERFACE ***

	/*H_Slider_Theme_1* style_hslider1 = new H_Slider_Theme_1();
	slider_R->setStyle (style_hslider1);
	slider_V->setStyle (style_hslider1);
	slider_B->setStyle (style_hslider1);
	slider_ouverture_radius->setStyle (style_hslider1);
	slider_ouverture_longueur->setStyle (style_hslider1);
	player_progress->setStyle (style_hslider1);
	slider_opacity_eraser->setStyle (style_hslider1);
	slider_rotation_img->setStyle (style_hslider1);
	slider_gomme->setStyle (style_hslider1);*/

	H_Slider_Theme_2* style_hslider2 = new H_Slider_Theme_2();
	dial_opacity_slide->setStyle (style_hslider2);
	slider_lngdeg->setStyle (style_hslider2);
	slider_backtxt->setStyle (style_hslider2);
	dial_opacity->setStyle (style_hslider2);
	dial_opacity_2->setStyle (style_hslider2);
	slider_paintopacity->setStyle (style_hslider2);
	slider_paintsize->setStyle (style_hslider2);
	slider_scale->setStyle (style_hslider2);
	nbre_effet_sup->setStyle (style_hslider2);
	size_effet_sup->setStyle (style_hslider2);
	speed_effet_sup->setStyle (style_hslider2);

	slider_R->setStyle (style_hslider2);
	slider_V->setStyle (style_hslider2);
	slider_B->setStyle (style_hslider2);
	slider_ouverture_radius->setStyle (style_hslider2);
	slider_ouverture_longueur->setStyle (style_hslider2);
	player_progress->setStyle (style_hslider2);
	slider_opacity_eraser->setStyle (style_hslider2);
	slider_rotation_img->setStyle (style_hslider2);
	slider_gomme->setStyle (style_hslider2);

	QPixmap mask1(":/new/prefix2/Interface/Theme/player_mask_play.png");
	QPixmap mask2(":/new/prefix2/Interface/Theme/mask_close.png");
	bt_start->setMask(mask1);
	bt_end->setMask(mask1);
	bt_play->setMask(mask1);
	bt_play_tv->setMask(mask1);
	bt_close_player->setMask(mask2);

	frame_bibliotheque->hide();
	frame_widget_txt->hide();
	frame_realplay->hide();
	//
	toolsmenu->setGeometry(10,10,53,389);
	frame_toolspainter->setGeometry(100,100,371,321);
	apropos->hide();
	frame_control_dep->hide();
	frame_xperttimeline->hide();
	zone_painter->hide();
	img_selection->hide();
	frame_new_proj->hide();
	frame_editor->hide();
	frame_toolspainter->hide();
	frame_encode->hide();
	frame_player->hide();
	scroll_timeline->hide();
	frame_parametres->hide();
	param_encoding->hide();
	frame_import_mng->hide();

	label_nbrediapo->setText(tr("Duree du diaporama : ") + "0 s");
	label_curdiapo->setText(tr("Diapositive actuelle : 0"));

	scrollArea_1 = new QScrollArea(frame_fond_editor);
	scrollArea_1->setAlignment(Qt::AlignCenter);
	scrollArea_2 = new QScrollArea(frame_realplay);
	scrollArea_2->setAlignment(Qt::AlignCenter);
	scrollArea_2->setWidget(frame_play);
	scrollArea_3 = new QScrollArea(frame_design);
	scrollArea_3->setAlignment(Qt::AlignCenter);
	scrollArea_3->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	scrollArea_3->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	scrollArea_3->setFrameShape(QFrame::NoFrame);
	scrollArea_3->setWidget(frame_ed3d);
	scrollArea_4 = new QScrollArea(frame_widget_txt);
	scrollArea_4->setAlignment(Qt::AlignCenter);
	scrollArea_4->setWidget(pntlabeltxt);
	scrollArea_5 = new QScrollArea(frame_property);
	scrollArea_5->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea_5->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	scrollArea_5->setFrameShape(QFrame::NoFrame);
	scrollArea_5->setWidget(tabmenus);
	scrollArea_6 = new QScrollArea(zone_painter);
	scrollArea_6->setAlignment(Qt::AlignCenter);
	scrollArea_6->setWidget(frame_painter);
	scrollArea_7 = new QScrollArea(frame_support_brush);
	scrollArea_7->setAlignment(Qt::AlignCenter);
	scrollArea_7->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea_7->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	scrollArea_7->setGeometry(0,0,frame_support_brush->width(),frame_support_brush->height());
	scrollArea_7->setWidget(frame_brush);
	scrollArea_8 = new QScrollArea(frame_lsteffedi);
	scrollArea_8->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
	scrollArea_8->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea_8->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	scrollArea_8->setWidget(frame_supportefferdi);

	// *** CREATIONS DES ELEMENTS DU DECOR ***
	wg_diapositive.load(":/new/prefix2/Interface/Theme/diapositive.png");
	QPalette mypal(QApplication::palette());
	QBrush mybrush_1 = mypal.window();
	QBrush mybrush_3 = mypal.dark();
	QPainter p;
	QLinearGradient mygradient(0,0,0,151);
	mygradient.setColorAt(0.4,mybrush_3.color());
	mygradient.setColorAt(0.8,mybrush_1.color());

	splashy.showMessage("Preparing interface ...",sypal,Qt::black);

	// *** CREATION DE LA TIMELINE ***
	timeline *mytimeline = new timeline(support_timeline);
	pnttimeline = mytimeline;
	connect(pnttimeline, SIGNAL(dia_delete()),this, SLOT(supp_diapo()));
	connect(pnttimeline, SIGNAL(dia_edit()),this, SLOT(f_launch_editor()));
	connect(pnttimeline, SIGNAL(dia_copy()),this, SLOT(f_copy()));
	connect(pnttimeline, SIGNAL(dia_paste()),this, SLOT(f_paste()));
	connect(pnttimeline, SIGNAL(dia_melange()), this, SLOT(f_random()));
	connect(pnttimeline, SIGNAL(dia_duplicate()), this, SLOT(f_duplicate()));
	connect(pnttimeline, SIGNAL(slice(int)),this, SLOT(f_slice(int)));
	connect(pnttimeline, SIGNAL(s_addaudio()),this, SLOT(f_add_zik()));
	connect(pnttimeline, SIGNAL(s_syncaudio()),this, SLOT(f_sync()));
	connect(pnttimeline, SIGNAL(s_delaudio()),this, SLOT(f_sup_zik()));
	connect(pnttimeline, SIGNAL(s_stopaudio()),this, SLOT(f_stop_zik()));
	connect(pnttimeline, SIGNAL(dia_comment()),this, SLOT(f_open_comment()));
	connect(pnttimeline, SIGNAL(dia_delcomment()),this, SLOT(f_supp_comment()));
	pnttimeline->setGeometry(0,0,10000,113);
	pnttimeline->show();
	pnttimeline->setDisabled(true);
	connect(pnttimeline, SIGNAL(godrop() ),this, SLOT(insert_photo()));
	connect(pnttimeline, SIGNAL(prepare_drop() ),this, SLOT(prepare_insert_photo()));
	connect(pnttimeline, SIGNAL(move_left() ),this, SLOT(f_gliss_left()));
	connect(pnttimeline, SIGNAL(move_right() ),this, SLOT(f_gliss_right()));
	img_selection->setParent(pnttimeline);

	audio_editor *myaudioedit1 = new audio_editor(pnttimeline);
	zik_1 = myaudioedit1;
	connect(zik_1, SIGNAL(recalc() ),this, SLOT(f_calcul_son()));
	zik_1->setPalette(QColor(248,94,20));
        QFont font("Sans", 7);
        zik_1->setFont(font);
	pnttimeline->zik_1 = zik_1;

	img_selection->raise();

	// *** CREATION DES COLOR WHEEL ***
	QPixmap wlwheel;
	wlwheel.load(":/new/prefix2/Interface/Theme/colorwheel.png");
	wheel *pntwheelback_1 = new wheel(frame_couleur_fond);
	pntwheelback = pntwheelback_1;
	pntwheelback->setGeometry(0,0,120,120);
	pntwheelback->setPixmap(wlwheel);
	pntwheelback->tmpwheel = wlwheel.toImage();
	pntwheelback->wlimg = pntwheelback->tmpwheel;
	pntwheelback->show();
	pntwheelback->setColor(255,255,255);
	connect(pntwheelback, SIGNAL(gochange() ),this, SLOT(f_fond_couleur()));
	connect(pntwheelback, SIGNAL(finchange() ),this, SLOT(f_fond_couleur_valide()));

	wheel *pntwheelfog_1 = new wheel(frame_couleur_fog);
	pntwheelfog = pntwheelfog_1;
	pntwheelfog->setGeometry(0,0,120,120);
	pntwheelfog->setPixmap(wlwheel);
	pntwheelfog->tmpwheel = wlwheel.toImage();
	pntwheelfog->wlimg = pntwheelfog->tmpwheel;
	pntwheelfog->show();
	pntwheelfog->setColor(255,255,255);
	connect(pntwheelfog, SIGNAL(gochange() ),this, SLOT(f_change_color_fog()));

	wheel *pntwheeltxt_1 = new wheel(frame_couleur_txt);
	pntwheeltxt = pntwheeltxt_1;
	pntwheeltxt->setGeometry(0,0,120,120);
	pntwheeltxt->setPixmap(wlwheel);
	pntwheeltxt->tmpwheel = wlwheel.toImage();
	pntwheeltxt->wlimg = pntwheeltxt->tmpwheel;
	pntwheeltxt->show();
	pntwheeltxt->setColor(255,255,255);
	connect(pntwheeltxt, SIGNAL(gochange() ),this, SLOT(f_change_color_txt()));

	wheel *pntwheelouv_1 = new wheel(frame_couleur_ouverture);
	pntwheelouv = pntwheelouv_1;
	pntwheelouv->setGeometry(0,0,120,120);
	pntwheelouv->setPixmap(wlwheel);
	pntwheelouv->tmpwheel = wlwheel.toImage();
	pntwheelouv->wlimg = pntwheelouv->tmpwheel;
	pntwheelouv->show();
	pntwheelouv->setColor(255,255,255);
	connect(pntwheelouv, SIGNAL(gochange() ),this, SLOT(f_change_color_ouv()));

	wheel *pntwheelbac_1 = new wheel(frame_back_txt);
	pntwheelbac = pntwheelbac_1;
	pntwheelbac->setGeometry(0,0,120,120);
	pntwheelbac->setPixmap(wlwheel);
	pntwheelbac->tmpwheel = wlwheel.toImage();
	pntwheelbac->wlimg = pntwheelbac->tmpwheel;
	pntwheelbac->show();
	pntwheelbac->setColor(255,255,255);
	connect(pntwheelbac, SIGNAL(gochange() ),this, SLOT(f_change_color_bac()));

	wheel *pntwheeldeg_1 = new wheel(frame_couleur_degrade_1);
	pntwheeldeg1 = pntwheeldeg_1;
	pntwheeldeg1->setGeometry(0,0,120,120);
	pntwheeldeg1->setPixmap(wlwheel);
	pntwheeldeg1->tmpwheel = wlwheel.toImage();
	pntwheeldeg1->wlimg = pntwheeldeg1->tmpwheel;
	pntwheeldeg1->show();
	pntwheeldeg1->setColor(255,255,255);
	connect(pntwheeldeg1, SIGNAL(gochange() ),this, SLOT(f_change_color_deg_1()));
	connect(pntwheeldeg1, SIGNAL(finchange() ),this, SLOT(f_deg1_couleur_valide()));

	wheel *pntwheeldeg_2 = new wheel(frame_couleur_degrade_2);
	pntwheeldeg2 = pntwheeldeg_2;
	pntwheeldeg2->setGeometry(0,0,120,120);
	pntwheeldeg2->setPixmap(wlwheel);
	pntwheeldeg2->tmpwheel = wlwheel.toImage();
	pntwheeldeg2->wlimg = pntwheeldeg2->tmpwheel;
	pntwheeldeg2->show();
	pntwheeldeg2->setColor(255,255,255);
	connect(pntwheeldeg2, SIGNAL(gochange() ),this, SLOT(f_change_color_deg_2()));
	connect(pntwheeldeg2, SIGNAL(finchange() ),this, SLOT(f_deg2_couleur_valide()));

	wheel *pntwheelpainter = new wheel(frame_couleur_painter);
	pntwheelpaint = pntwheelpainter;
	pntwheelpaint->setGeometry(0,0,120,120);
	pntwheelpaint->setPixmap(wlwheel);
	pntwheelpaint->tmpwheel = wlwheel.toImage();
	pntwheelpaint->wlimg = pntwheelpaint->tmpwheel;
	pntwheelpaint->show();
	pntwheelpaint->setColor(255,255,255);
	connect(pntwheelpaint, SIGNAL(gochange() ),this, SLOT(f_change_color_painter()));

	wheel *pntwheeleraserer = new wheel(frame_couleur_eraser);
	pntwheeleraser = pntwheeleraserer;
	pntwheeleraser->setGeometry(0,0,120,120);
	pntwheeleraser->setPixmap(wlwheel);
	pntwheeleraser->tmpwheel = wlwheel.toImage();
	pntwheeleraser->wlimg = pntwheeleraser->tmpwheel;
	pntwheeleraser->show();
	pntwheeleraser->setColor(255,255,255);
	connect(pntwheeleraser, SIGNAL(gochange() ),this, SLOT(f_change_color_eraser()));

	// *** CREATION DE LA TIMELINE CLE ***
	timestamp *wpnt = new timestamp(frame_xperttimeline);
	pntstamp = wpnt;
	pntstamp->duree_diapo = 1;
	pntstamp->initpos();
	pntstamp->setFrameShape(QFrame::Box);
	connect(pntstamp, SIGNAL(follow(int) ),this, SLOT(f_follow_timeline(int)));
	connect(pntstamp, SIGNAL(mark_coo(int) ),this, SLOT(f_mark_timeline(int)));
	connect(pntstamp, SIGNAL(umark_coo() ),this, SLOT(f_umark_timeline()));
	pntstamp->show();
	pntstamp->raise();
	//
	tabmenus->setDisabled(true);
	toolsmenu->setDisabled(true);
	actionEnregistrer->setEnabled(false);
	actionEnregistrer_sous->setEnabled(false);
	actionAjouter_des_diapositives->setEnabled(false);
	actionAjouter_une_diapositive_transparente->setEnabled(false);
	actionAjouter_une_vid_o_comme_diapositive->setEnabled(false);
	actionSupprimer_diapositive->setEnabled(false);
	actionCopier->setEnabled(false);
	actionColler->setEnabled(false);
	actionPrendre_photo->setEnabled(false);
	actionDeplacer_gauche->setEnabled(false);
	actionDeplacer_droite->setEnabled(false);
	actionEditer_diapositive->setEnabled(false);
	actionRender->setEnabled(false);
	actionDeplacement->setEnabled(false);
	actionDupliquer_la_diapositive_actuelle->setEnabled(false);
	actionZoom->setEnabled(false);
	actionRotation_X->setEnabled(false);
	actionRotation_Y->setEnabled(false);
	actionRotation_Z->setEnabled(false);
	actionRotation_libre->setEnabled(false);
	actionReinitialiser->setEnabled(false);
	actionMarquer_depart->setEnabled(false);
	actionMarquer_fin->setEnabled(false);
	top_timeline->setDisabled(true);
	checkinvert->setDisabled(true);
	//
	pntdir = new QDirModel;
	pntdir->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
	idxmod = pntdir->index(QDir::homePath());
	thread_thu->current_path = QDir::homePath();

	pntmygl->path_render = "";
	pntmygl->tool = 0;
	path_musique_import = "~";
	path_photos_capture = "~";
	wg_save_filename = "";
	zik_number = 0;
	zik_1->hide();
	total_audio = 0;
	must_redraw = 0;
	poursuite_2 = 0;
	global_legende = "$N$U$L$L";
	spindurtrans->setMinimum(1);
	//

	splashy.showMessage("Loading themes ...",sypal,Qt::black);

	wg_comment.load(":/new/prefix2/Interface/Theme/comment.png");
	//
    	combocodec->insertItem(0,"MPEG2");
    	combocodec->insertItem(1,"XVID");
    	combocodec->insertItem(2,"DV");
    	combocodec->insertItem(3,"FLV (Flash)");
	combocodec->setCurrentIndex(0);
	//
    	comboforme->insertItem(0,tr("Aucune"));
    	comboforme->insertItem(1,tr("Coeur"));
	comboforme->setItemIcon(1, QIcon(":/new/prefix2/Interface/Theme/coeur.png"));
    	comboforme->insertItem(2,tr("Etoile"));
	comboforme->setItemIcon(2, QIcon(":/new/prefix2/Interface/Theme/star.png"));
    	comboforme->insertItem(3,tr("Fleur"));
	comboforme->setItemIcon(3, QIcon(":/new/prefix2/Interface/Theme/fleur.png"));
    	comboforme->insertItem(4,tr("Lune"));
	comboforme->setItemIcon(4, QIcon(":/new/prefix2/Interface/Theme/lune.png"));
    	comboforme->insertItem(5,tr("Nuage"));
	comboforme->setItemIcon(5, QIcon(":/new/prefix2/Interface/Theme/nuage.png"));
    	comboforme->insertItem(6,tr("Soleil"));
	comboforme->setItemIcon(6, QIcon(":/new/prefix2/Interface/Theme/soleil.png"));
    	comboforme->insertItem(7,tr("Puzzle"));
	comboforme->setItemIcon(7, QIcon(":/new/prefix2/Interface/Theme/puzzle.png"));
	comboforme->setCurrentIndex(0);
	//
    	lst_transitions->insertItem(0,tr("Pas de transitions"));
    	lst_transitions->insertItem(1,tr("Fondu enchaine"));
	//
    	lst_transitions_2->insertItem(0,tr("Pas de transitions"));
    	lst_transitions_2->insertItem(1,tr("Transition aleatoire"));
   	lst_transitions_2->insertItem(2,tr("Fondu enchaine"));
	//
    	effetsup->insertItem(0,tr("Pas d'effet"));
    	effetsup->insertItem(1,tr("Neige"));
	effetsup->setItemIcon(1, QIcon(":/new/prefix2/Interface/Theme/snowflakes.png"));
   	effetsup->insertItem(2,tr("Coeur"));
	effetsup->setItemIcon(2, QIcon(":/new/prefix2/Interface/Theme/heartsnow.png"));
   	effetsup->insertItem(3,tr("Fleurs"));
	effetsup->setItemIcon(3, QIcon(":/new/prefix2/Interface/Theme/flowersnow.png"));
   	effetsup->insertItem(4,tr("Nounours"));
	effetsup->setItemIcon(4, QIcon(":/new/prefix2/Interface/Theme/nounourssnow.png"));
   	effetsup->insertItem(5,tr("Pluie"));
	effetsup->setItemIcon(5, QIcon(":/new/prefix2/Interface/Theme/rainsnow.png"));
   	effetsup->insertItem(6,tr("Feuille"));
	effetsup->setItemIcon(6, QIcon(":/new/prefix2/Interface/Theme/feuillesnow.png"));
   	effetsup->insertItem(7,tr("Importer votre image"));
	effetsup->setItemIcon(7, QIcon(":/new/prefix2/Interface/Theme/folder.png"));
	effetsup->setCurrentIndex(0);
	//
	comboqualite->insertItem(0,tr("Haute"));
	comboqualite->insertItem(1,tr("Normale"));
	comboqualite->insertItem(2,tr("Basse"));
	comboqualite->insertItem(3,tr("Tres basse"));
	comboqualite->setCurrentIndex(1);
	//
	comboeffets->insertItem(0,tr("Aucun"));
	comboeffets->setCurrentIndex(0);
	bt_remove_effet->setDisabled(true);
	//
	combofscale->insertItem(0,"PAL 4/3");
	combofscale->insertItem(1,"PAL 16/9");
	combofscale->insertItem(2,"NTSC 4/3");
	combofscale->setCurrentIndex(0);
	//
    	combo_composition->insertItem(0,"SourceOver");
	combo_composition->insertItem(1,"Xor");
    	combo_composition->insertItem(2,"Plus");
    	combo_composition->insertItem(3,"Multiply");
    	combo_composition->insertItem(4,"Screen");
    	combo_composition->insertItem(5,"Overlay");
    	combo_composition->insertItem(6,"Darken");
    	combo_composition->insertItem(7,"Lighten");
    	combo_composition->insertItem(8,"ColorDodge");
    	combo_composition->insertItem(9,"ColorBurn");
    	combo_composition->insertItem(10,"HardLight");
    	combo_composition->insertItem(11,"SoftLight");
    	combo_composition->insertItem(12,"Difference");
    	combo_composition->insertItem(13,"Exclusion");
    	combo_composition->insertItem(14,"SourceIn");
    	combo_composition->insertItem(15,"DestinationIn");
    	combo_composition->insertItem(16,"DestinationOut");
	combo_composition->insertItem(17,"SourceAtop");
	combo_composition->insertItem(18,"DestinationAtop");

	table_compo[0] = 0;
	table_compo[1] = 11;
	table_compo[2] = 12;
	table_compo[3] = 13;
	table_compo[4] = 14;
	table_compo[5] = 15;
	table_compo[6] = 16;
	table_compo[7] = 17;
	table_compo[8] = 18;
	table_compo[9] = 19;
	table_compo[10] = 20;
	table_compo[11] = 21;
	table_compo[12] = 22;
	table_compo[13] = 23;
	table_compo[14] = 5;
	table_compo[15] = 6;
	table_compo[16] = 8;
	table_compo[17] = 9;
	table_compo[18] = 10;

	//combo_composition->setCurrentIndex(0);
	//

	splashy.showMessage("Control dependencies ...",sypal,Qt::black);

	pntmygl->iseffect = 0;
	nbre_photos = -1;
	current_diapo = -1;
	old_current_diapo = -1;
	pntmygl->resize(0,0);
	//mygl->setGeometry(0,0,size_dia_x,size_dia_y);
	// *** DECLARATION DES TIMERS ***
 	mplayer_timer = new QTimer(this);
	//
	connect(this, SIGNAL(closing()),this, SLOT(f_end_mainfrm()));
	connect(actionFermer, SIGNAL(triggered()),this, SLOT(f_start_close()));
	//
	connect(bt_choose_temp, SIGNAL(clicked()),this, SLOT(f_find_tempfolder()));
	connect(bt_valide_paramw, SIGNAL(clicked()),this, SLOT(f_save_param()));
	// *** EDITEUR DE TEXTE ***
	connect(txtondiapo, SIGNAL(textChanged()),this, SLOT(f_txtedit_chtxt()));
	connect(tabmenus, SIGNAL(currentChanged(int)),this, SLOT(f_open_title(int)));
	connect(fontlegende,SIGNAL(currentFontChanged ( const QFont &)), this, SLOT(f_font_comment(const QFont &))); 
	connect(bt_leg_bold, SIGNAL(clicked()),this, SLOT(f_leg_bold()));
	connect(bt_leg_italic, SIGNAL(clicked()),this, SLOT(f_leg_italic()));
	connect(legend_size,SIGNAL(valueChanged ( int )),this, SLOT(f_leg_size(int)));
	connect(slider_backtxt, SIGNAL(valueChanged(int)),this, SLOT(f_change_opacity_back(int)));
	connect(bt_leg_filename, SIGNAL(clicked()),this, SLOT(f_leg_filename()));

	connect(chk_fondu_entrant, SIGNAL(stateChanged(int)),this, SLOT(f_leg_fondu(int)));
	connect(chk_fondu_sortant, SIGNAL(stateChanged(int)),this, SLOT(f_leg_fondu(int)));
	connect(spindurleg, SIGNAL(valueChanged(int)),this, SLOT(f_leg_fondu(int)));	

	connect(bt_go_start_legani, SIGNAL(clicked()),this, SLOT(f_go_start_legani()));
	connect(bt_go_end_legani, SIGNAL(clicked()),this, SLOT(f_go_end_legani()));
	connect(bt_mk_start_legani, SIGNAL(clicked()),this, SLOT(f_mk_start_legani()));
	connect(bt_mk_end_legani, SIGNAL(clicked()),this, SLOT(f_mk_end_legani()));

	connect(bt_leg_align_1, SIGNAL(clicked()),this, SLOT(f_align_1()));
	connect(bt_leg_align_2, SIGNAL(clicked()),this, SLOT(f_align_2()));
	connect(bt_leg_align_3, SIGNAL(clicked()),this, SLOT(f_align_3()));
	connect(bt_leg_align_4, SIGNAL(clicked()),this, SLOT(f_align_4()));

	connect(check_mblur, SIGNAL(stateChanged(int)),this, SLOT(f_mblur(int)));

	// *** BIBLIOTHEQUE DE MEDIAS ***
	connect(actionAjouter_des_diapositives, SIGNAL(triggered()),this, SLOT(f_open_bib()));
	connect(bt_close_biblio, SIGNAL(clicked()),this, SLOT(f_close_bib()));
	connect(lstfiles, SIGNAL(itemDoubleClicked ( QListWidgetItem* )),this, SLOT(f_dbl_load_photo()));
	connect(thread_thu, SIGNAL(myfin() ),this, SLOT(f_update_thumbail()));
	connect(lstfiles, SIGNAL(folder_import()),this, SLOT(f_import_folder()));
	connect(lstfiles, SIGNAL(pictures_import()),this, SLOT(f_import_pictures()));
	connect(lstfiles, SIGNAL(background_import()),this, SLOT(f_import_background()));
	connect(bt_refresh_liste, SIGNAL(clicked()),this, SLOT(f_refresh_liste()));

	// *** EDITEUR D'IMAGE ***
	connect(bt_cancel_editor, SIGNAL(clicked()),this, SLOT(f_cancel_editor()));
	connect(bt_ok_editor, SIGNAL(clicked()),this, SLOT(f_ok_editor()));
	connect(actionEditer_diapositive, SIGNAL(triggered()),this, SLOT(f_launch_editor()));
	connect(bt_annuler_editor, SIGNAL(clicked()),this, SLOT(f_annuler_editor()));
	connect(bt_rogner, SIGNAL(clicked()),this, SLOT(f_rogner()));
	connect(bt_ok_rogner, SIGNAL(clicked()),this, SLOT(f_ok_rogner()));
	connect(bt_rotation_img, SIGNAL(clicked()),this, SLOT(f_btrotation_img()));
	connect(slider_rotation_img, SIGNAL(valueChanged(int)),this, SLOT(f_rotation_img(int)));

	connect(bt_image_over, SIGNAL(clicked()),this, SLOT(f_img_over()));
	connect(bt_image_over_invert, SIGNAL(clicked()),this, SLOT(f_invert_img_over()));
	connect(bt_image_over_cancel, SIGNAL(clicked()),this, SLOT(f_cancel_img_over()));

	connect(bt_forme, SIGNAL(clicked()),this, SLOT(f_forme()));
	connect(bt_ok_forme, SIGNAL(clicked()),this, SLOT(f_ok_forme()));
	connect(comboforme, SIGNAL(currentIndexChanged(int)),this, SLOT(f_apply_forme(int)));
	connect(bt_gommer, SIGNAL(clicked()),this, SLOT(f_gommer()));
	connect(slider_gomme, SIGNAL(valueChanged(int)),this, SLOT(f_size_gommer(int)));
	connect(slider_opacity_eraser, SIGNAL(valueChanged(int)),this, SLOT(f_opac_gommer(int)));

	connect(bt_tool_editor_2, SIGNAL(clicked()),this, SLOT(f_tool_editor_2()));
	connect(bt_tool_editor_3, SIGNAL(clicked()),this, SLOT(f_tool_editor_3()));
	connect(bt_tool_editor_4, SIGNAL(clicked()),this, SLOT(f_tool_editor_4()));
	connect(bt_tool_editor_5, SIGNAL(clicked()),this, SLOT(f_tool_editor_10()));
	connect(bt_tool_editor_6, SIGNAL(clicked()),this, SLOT(f_tool_editor_11()));
	connect(bt_tool_editor_7, SIGNAL(clicked()),this, SLOT(f_tool_editor_12()));
	connect(bt_tool_editor_8, SIGNAL(clicked()),this, SLOT(f_tool_editor_14()));
	connect(bt_tool_editor_9, SIGNAL(clicked()),this, SLOT(f_tool_editor_15()));

	connect(spinrotation, SIGNAL(valueChanged(int)),this, SLOT(f_rotation_spin(int)));

	connect(slider_lumiere, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_5(int)));
	connect(slider_contraste, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_9(int)));
	connect(slider_R, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_6(int)));
	connect(slider_V, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_7(int)));
	connect(slider_B, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_8(int)));
	connect(slider_ouverture, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_13(int)));
	connect(slider_ouverture_radius, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_13_r(int)));
	connect(slider_ouverture_longueur, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_13_l(int)));
	connect(slider_ouverture_opacity, SIGNAL(valueChanged(int)),this, SLOT(f_tool_editor_13_o(int)));
	connect(combo_composition, SIGNAL(currentIndexChanged(int)),this, SLOT(f_apply_composition(int)));

	connect(thread_img, SIGNAL(myfin() ),this, SLOT(f_update_editor()));

	// *** RENDERING ***
	connect(thread_tra, SIGNAL(myfin() ),this, SLOT(f_render_end_ptransition()));

	connect(actionRender, SIGNAL(triggered() ),this, SLOT(f_param_rendering()));
	connect(bt_close_encoding, SIGNAL(clicked() ),this, SLOT(f_close_param_rendering()));

	// *** TOOLBAR DE DROITE ***
	connect(slider_lngdeg, SIGNAL(valueChanged(int)),this, SLOT(f_lngdeg(int)));
	connect(slider_lngdeg, SIGNAL(sliderReleased()),this, SLOT(f_lngdeg_valide()));
	connect(slider_scale, SIGNAL(valueChanged(int)),this, SLOT(f_scale(int)));

	connect(bt_ajout_effet, SIGNAL(clicked()),this, SLOT(f_ajout_effet()));
	connect(bt_remove_effet, SIGNAL(clicked()),this, SLOT(f_remove_effet()));
	connect(bt_find_out, SIGNAL(clicked()),this, SLOT(f_find_out()));

	connect(bt_zoom, SIGNAL(clicked()),this, SLOT(f_chg_tool_a()));
	connect(bt_rotate1, SIGNAL(clicked()),this, SLOT(f_chg_tool_c()));
	connect(bt_rotate2, SIGNAL(clicked()),this, SLOT(f_chg_tool_d()));
	connect(bt_rotate3, SIGNAL(clicked()),this, SLOT(f_chg_tool_e()));
	connect(bt_rotate4, SIGNAL(clicked()),this, SLOT(f_chg_tool_f()));
	connect(bt_deplace, SIGNAL(clicked()),this, SLOT(f_chg_tool_b()));
	connect(checkinvert, SIGNAL(stateChanged(int)),this, SLOT(f_checkinvert(int)));

	connect(bt_pstart, SIGNAL(clicked()),this, SLOT(md_start()));
	connect(bt_pend, SIGNAL(clicked()),this, SLOT(md_fin()));

	connect(bt_painter, SIGNAL(clicked()),this, SLOT(f_painter()));
	connect(slider_paintopacity, SIGNAL(valueChanged(int)),this, SLOT(f_painteropa(int)));
	connect(slider_paintsize, SIGNAL(valueChanged(int)),this, SLOT(f_paintersiz(int)));
	connect(bt_painter_paint, SIGNAL(clicked()),this, SLOT(f_painter_draw()));
	connect(bt_painter_efface, SIGNAL(clicked()),this, SLOT(f_painter_efface()));
	connect(brush1, SIGNAL(clicked()),this, SLOT(f_painter_brush1()));
	connect(brush2, SIGNAL(clicked()),this, SLOT(f_painter_brush2()));
	connect(brush3, SIGNAL(clicked()),this, SLOT(f_painter_brush3()));
	connect(brush4, SIGNAL(clicked()),this, SLOT(f_painter_brush4()));
	connect(brush5, SIGNAL(clicked()),this, SLOT(f_painter_brush5()));
	connect(brush6, SIGNAL(clicked()),this, SLOT(f_painter_brush6()));
	connect(brush7, SIGNAL(clicked()),this, SLOT(f_painter_brush7()));
	connect(brush8, SIGNAL(clicked()),this, SLOT(f_painter_brush8()));

	connect(bt_painter_fermer, SIGNAL(clicked()),this, SLOT(f_painter_fermer()));
	connect(bt_painter_init, SIGNAL(clicked()),this, SLOT(f_painter_init()));

	// *** FONCTIONS DE LECTURE DE LA TIMELINE ***
	connect(bt_play, SIGNAL(clicked()),this, SLOT(start_play_all()));
	connect(bt_start, SIGNAL(clicked()),this, SLOT(sl_go_start()));
	connect(bt_end, SIGNAL(clicked()),this, SLOT(sl_go_end()));
	connect(bt_complex, SIGNAL(clicked()),this, SLOT(f_opencomplex()));

	connect(bt_fond, SIGNAL(clicked()),this, SLOT(f_open_bib_fond()));
	connect(check_fog, SIGNAL(stateChanged(int)),this, SLOT(f_brouillard(int)));
	connect(check_backanim, SIGNAL(stateChanged(int)),this, SLOT(f_backanim(int)));
	connect(dial_opacity, SIGNAL(valueChanged(int)),this, SLOT(f_opacity(int)));
	connect(dial_opacity_2, SIGNAL(valueChanged(int)),this, SLOT(f_opacity_2(int)));
	connect(dial_opacity_slide, SIGNAL(valueChanged(int)),this, SLOT(f_opacity_slide(int)));
	connect(dial_percent_blending, SIGNAL(valueChanged(int)),this, SLOT(f_percent_blending(int)));
	connect(dial_percent_blending_2, SIGNAL(valueChanged(int)),this, SLOT(f_percent_blending_2(int)));

	connect(slider_size_anim, SIGNAL(valueChanged(int)),this, SLOT(f_size_anim(int)));
	connect(slider_rot_anim, SIGNAL(valueChanged(int)),this, SLOT(f_rot_anim(int)));

	connect(spindurdiapo, SIGNAL(valueChanged(int)),this, SLOT(f_changedur(int)));
	connect(spindurdiapo_2, SIGNAL(valueChanged(int)),this, SLOT(f_changedur_2(int)));

	connect(actionPrendre_photo, SIGNAL(triggered()),this, SLOT(f_screenshot()));
	connect(actionDeplacer_gauche, SIGNAL(triggered()),this, SLOT(f_dep_gauche()));
	connect(actionDeplacer_droite, SIGNAL(triggered()),this, SLOT(f_dep_droite()));

	connect(bt_start_encoding, SIGNAL(clicked()),this, SLOT(f_generer_diapo()));

	connect(scroll_timeline, SIGNAL(valueChanged(int)),this, SLOT(f_scroll_timeline(int)));
	connect(lst_transitions, SIGNAL(currentIndexChanged(int)),this, SLOT(f_transition_changed(int)));
	connect(spindurtrans, SIGNAL(valueChanged(int)),this, SLOT(f_transition_duree_changed(int)));

	connect(comboeffets, SIGNAL(currentIndexChanged(int)),this, SLOT(f_apply_effets(int)));
	connect(effetsup, SIGNAL(currentIndexChanged(int)),this, SLOT(f_apply_effetsup(int)));
	connect(nbre_effet_sup, SIGNAL(valueChanged(int)),this, SLOT(f_effet_nombre(int)));
	connect(size_effet_sup, SIGNAL(valueChanged(int)),this, SLOT(f_effet_taille(int)));
	connect(speed_effet_sup, SIGNAL(valueChanged(int)),this, SLOT(f_effet_speed(int)));
	connect(check_rotationeffet, SIGNAL(stateChanged(int)),this, SLOT(f_checkrotationeffet(int)));

	// *** OUTILS ***
	connect(actionZoom, SIGNAL(triggered()),this, SLOT(f_chg_tool_a()));
	connect(actionDeplacement, SIGNAL(triggered()),this, SLOT(f_chg_tool_b()));
	connect(actionRotation_X, SIGNAL(triggered()),this, SLOT(f_chg_tool_c()));
	connect(actionRotation_Y, SIGNAL(triggered()),this, SLOT(f_chg_tool_d()));
	connect(actionRotation_Z, SIGNAL(triggered()),this, SLOT(f_chg_tool_e()));
	connect(actionRotation_libre, SIGNAL(triggered()),this, SLOT(f_chg_tool_f()));
	connect(actionCopier, SIGNAL(triggered()),this, SLOT(f_copy()));
	actionCopier->setShortcut(QKeySequence("Ctrl+C | Ctrl+c"));
	connect(actionColler, SIGNAL(triggered()),this, SLOT(f_paste()));
	actionColler->setShortcut(QKeySequence("Ctrl+V | Ctrl+v"));
	connect(actionReinitialiser, SIGNAL(triggered()),this, SLOT(f_raz()));
	actionReinitialiser->setShortcut(QKeySequence("Ctrl+Z | Ctrl+z"));

	connect(actionDupliquer_la_diapositive_actuelle, SIGNAL(triggered()),this, SLOT(f_duplicate()));
	actionDupliquer_la_diapositive_actuelle->setShortcut(QKeySequence("Ctrl+D | Ctrl+d"));

	connect(actionAjouter_une_diapositive_transparente, SIGNAL(triggered()),this, SLOT(f_empty_diapo()));
	actionAjouter_une_diapositive_transparente->setShortcut(QKeySequence("Ctrl+T | Ctrl+t"));

	connect(actionMarquer_depart, SIGNAL(triggered()),this, SLOT(md_start()));
	actionMarquer_depart->setShortcut(QKeySequence("Ctrl+B | Ctrl+b"));

	connect(actionMarquer_fin, SIGNAL(triggered()),this, SLOT(md_fin()));
	actionMarquer_fin->setShortcut(QKeySequence("Ctrl+E | Ctrl+e"));

	connect(actionAjouter_une_vid_o_comme_diapositive, SIGNAL(triggered()),this, SLOT(f_import_dianim()));

	// *** FONCTIONS INTERFACE ***
	connect(thread_ptra, SIGNAL(myfin() ),this, SLOT(f_end_ptransition()));
	connect(actionA_propos_de_smile, SIGNAL(triggered()),this, SLOT(f_apropos()));
	connect(bt_close_apropos, SIGNAL(clicked()),this, SLOT(f_close_apropos()));
	connect(actionDocumentation, SIGNAL(triggered()),this, SLOT(f_documentation()));
	actionDocumentation->setShortcut(QKeySequence("F1"));

	// *** MENU FICHIER ***
	connect(actionEnregistrer, SIGNAL(triggered()),this, SLOT(f_save_proj()));
	actionEnregistrer->setShortcut(QKeySequence("Ctrl+S | Ctrl+s"));
	connect(actionEnregistrer_sous, SIGNAL(triggered()),this, SLOT(f_saveas_proj()));
	actionEnregistrer_sous->setShortcut(QKeySequence("Ctrl+Shift+S | Ctrl+Shift+s"));
	connect(actionOuvrir, SIGNAL(triggered()),this, SLOT(f_open_proj()));
	connect(actionNouveau, SIGNAL(triggered()),this, SLOT(f_select_new()));
	actionNouveau->setShortcut(QKeySequence("Ctrl+N | Ctrl+n"));

	// *** MENU EDITION ***
	connect(actionParametres_import, SIGNAL(triggered()),this, SLOT(f_affiche_parametres()));
	connect(actionSupprimer_diapositive, SIGNAL(triggered()),this, SLOT(supp_diapo()));

	connect(bt_valid_newproj, SIGNAL(clicked()),this, SLOT(f_launch_new()));
	connect(bt_cancel_newproj, SIGNAL(clicked()),this, SLOT(f_cancel_new()));

	connect(&myprocess_1, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(end_extract_ani(int, QProcess::ExitStatus)));
	connect(&myprocess_1, SIGNAL(readyReadStandardOutput()), this, SLOT(lecture_console_extract()));
	connect(&myprocess_2, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(end_check_dep(int, QProcess::ExitStatus)));
	connect(&myprocess_2, SIGNAL(readyReadStandardOutput()), this, SLOT(lecture_console_dep()));
	connect(&myprocess_3, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(end_encoding_audio(int, QProcess::ExitStatus)));
	connect(&myprocess_3, SIGNAL(readyReadStandardOutput()), this, SLOT(lecture_console_out_audio_encoding()));
	connect(&myprocess_4, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(end_all_audio(int, QProcess::ExitStatus)));
	connect(&myprocess_4, SIGNAL(readyReadStandardOutput()), this, SLOT(lecture_console_out_mencoder()));
	connect(&myprocess_4, SIGNAL(readyReadStandardError()), this, SLOT(lecture_console_outerr_mencoder()));
	connect(&myprocess_5, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(end_zik_import(int, QProcess::ExitStatus)));
	connect(&myprocess_5, SIGNAL(readyReadStandardOutput()), this, SLOT(lecture_console_import_zik()));
	connect(&myprocess_9, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(end_save_project(int, QProcess::ExitStatus)));

	connect(bt_close_param_import, SIGNAL(clicked()),this, SLOT(f_close_param_import()));
	connect(bt_cancel_param_import, SIGNAL(clicked()),this, SLOT(f_cancel_param_import()));

	// *** SIGNAUX MPLAYER ***
	connect(player_progress, SIGNAL(sliderReleased()),this, SLOT(player_percent_change()));
	connect(player_progress, SIGNAL(sliderPressed()),this, SLOT(player_start_percent_change()));
	connect(bt_play_tv, SIGNAL(clicked()),this, SLOT(player_play_video()));
	connect(bt_close_player, SIGNAL(clicked()),this, SLOT(f_close_player()));

        connect(mplayer_timer, SIGNAL(timeout()), this, SLOT(player_current_percent()));

	connect(&mplayerProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(player_read_stdout()));
	connect(&mplayerProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
                        this, SLOT(player_end(int, QProcess::ExitStatus)));

	// *** DIVERS ***
	connect(bt_cancel_dep, SIGNAL(clicked()),this, SLOT(f_close_dep()));

	//
	menubar->setDisabled(true);
	toolBar->setDisabled(true);
	//
	QDir currentDir = QDir::homePath();
      	QFile myfic(currentDir.path() + "/.testdep.sh");

        if ( !myfic.open( QIODevice::WriteOnly ))
        {
		qDebug() << "ERROR CREATING TEST SCRIPT IN YOUR HOME DIRECTORY : " + currentDir.path();
		menubar->setEnabled(true);
		toolBar->setEnabled(true);
		this->setEnabled(true);
		return;
	}
	else
	{
		QTextStream out(&myfic);
		out << "#!/bin/bash" << endl;
		out << "cd \"" + currentDir.path() + "\"" << endl;
		out << "sox -h" << endl;
		out << "mplayer" << endl;
		out << "mencoder" << endl;
		//out << "rm -f .testdep.sh" << endl;
		out << "exit" << endl;
		myfic.close();
		// *** Lancement du process de generation de l'audio ***
		QString program = "bash";

		myconsole = "";
       		QStringList arguments;
       		arguments << currentDir.path() + "/.testdep.sh";
		myprocess_2.setProcessChannelMode ( QProcess::MergedChannels );
		myprocess_2.start( program, arguments );
	}
}

void mainfrm::f_hideright()
{
	if ( tabmenus->isVisible() == true )
	{
		scrollArea_5->hide();
		f_resizer();
	}
	else
	{
		scrollArea_5->show();
		scrollArea_5->raise();
		f_resizer();
	}
}

void mainfrm::f_import_dianim()
{
	QString myfic2 = QFileDialog::getOpenFileName(
        	this,
        	tr("Importer une video comme diapositive"),
        	path_musique_import,
        	"Videos (*.MPG *.mpg *.avi *.AVI)");
	if ( myfic2.isNull() )
	{
	}
	else
	{
		QFileInfo myficimp(myfic2);
		QDir currentDir = QDir::homePath();
		menubar->setDisabled(true);
		toolBar->setDisabled(true);
		toolsmenu->setDisabled(true);
		tabmenus->setDisabled(true);
		frame_xperttimeline->setDisabled(true);
		contain_timeline->setDisabled(true);
		pntmygl->setDisabled(true);
		//
	      	QFile myfic(currentDir.path() + "/.genediani.sh");

		if ( !myfic.open( QIODevice::WriteOnly ))
		{
			qDebug() << "ERROR CREATING EXTRACT SCRIPT IN YOUR HOME DIRECTORY : " + currentDir.path();
			menubar->setEnabled(true);
			toolBar->setEnabled(true);
			toolsmenu->setEnabled(true);
			tabmenus->setEnabled(true);
			frame_xperttimeline->setEnabled(true);
			contain_timeline->setEnabled(true);
			pntmygl->setEnabled(true);
			return;
		}
		else
		{
			QTextStream out(&myfic);
			#ifdef Q_WS_WIN
			#else
				out << "#!/bin/bash" << endl;
				out << "mkdir " + currentDir.path() + "/.smilextract" << endl;
			#endif
	
			out << "cd \"" + currentDir.path() + "/.smilextract\"" << endl;
			out << "mplayer -vo gif89a:fps=25 -vf scale=360:288 \"" + myfic2 + "\"" << endl; 
			out << "echo \"-=S-M=-\"" << endl;
			out << "mv out.gif \"" + wpathprojet + "/" + QString::number(nbre_imports) + myficimp.fileName() + ".gif\"" << endl;
			out << "rm -rf " + currentDir.path() + "/.smilextract" << endl;
			out << "rm -f " + currentDir.path() + "/.genediani.sh" << endl;
			myfic.close();
			// *** Lancement du process de generation de l'audio ***
			#ifdef Q_WS_WIN
				QString program = "cmd";
			#else
				QString program = "bash";
			#endif
			wg_tmp_001 = QString::number(nbre_imports) + myficimp.fileName() + ".gif";
	       		QStringList arguments;
	       		arguments << currentDir.path() + "/.genediani.sh";
			myprocess_1.setProcessChannelMode ( QProcess::MergedChannels );
			myprocess_1.start( program, arguments );
		}
		pbimportmng_1->setValue(0);
		frame_import_mng->setGeometry((this->width()-frame_import_mng->width())/2,(this->height() - (toolBar->height()+menubar->height()+frame_import_mng->height()))/2,frame_import_mng->width(),frame_import_mng->height());
		frame_import_mng->show();
		frame_import_mng->raise();
	}
}

void mainfrm::lecture_console_extract()
{
	myprocess_1.write("get_percent_pos \n");

	newData = myprocess_1.readAllStandardOutput();
	wg_tmp_002 = QString::fromLocal8Bit(newData);
       	tmpint_3 = wg_tmp_002.indexOf("PERCENT_POSITION=", 0);

        if ( tmpint_3 != -1 )
        {
		wg_tmp_002.remove(0, 21);
                wg_tmp_002.replace(QByteArray(" "), QByteArray(""));
                wg_tmp_002.replace(QByteArray("\n"), QByteArray(""));
                wg_tmp_002.replace(QByteArray("\r"), QByteArray(""));
		if ( wg_tmp_002.toInt() > pbimportmng_1->value() )
		{
			pbimportmng_1->setValue(wg_tmp_002.toInt());
		}
	}
}

void mainfrm::end_extract_ani(int, QProcess::ExitStatus)
{
	if ( QFile::rename (  wpathprojet + "/" + wg_tmp_001,  wpathprojet + "/" + QString::number(pntmygl->nbre_ani_slide) + "STP" + wg_tmp_001 ) == true)
	{
		nbre_imports++;
		menubar->setEnabled(true);
		toolBar->setEnabled(true);
		toolsmenu->setEnabled(true);
		tabmenus->setEnabled(true);
		frame_xperttimeline->setEnabled(true);
		contain_timeline->setEnabled(true);
		pntmygl->setEnabled(true);

		frame_import_mng->hide();

		// *** Chargement de la diapositive ***
		if ( current_diapo >= 0 )
		{
			pnttimeline->drop_x = 10 + ((current_diapo+1) * 107);
		}
		else
		{
			pnttimeline->drop_x = 0;
		}
		pnttimeline->wl_pathname = wpathprojet + "/" + QString::number(pntmygl->nbre_ani_slide) + "STP" + wg_tmp_001;
		insert_photo();
	}
	else
	{
		qDebug() << "ERROR CAN'T RENAME TEMP FILE VIDEO IN IMPORT MODULE";
	}
}

void mainfrm::f_close_dep()
{
	frame_control_dep->hide();
	menubar->setEnabled(true);
	toolBar->setEnabled(true);
	f_nextstep();
}

void mainfrm::lecture_console_dep()
{
	newData = myprocess_2.readAllStandardOutput();
	wg_tmp_002 = QString::fromLocal8Bit(newData);
	myconsole = myconsole + wg_tmp_002;
}

void mainfrm::end_check_dep(int, QProcess::ExitStatus)
{   
	// *** CONTROLE SOX ***
	tmpint_5 = 0;
        tmpint_3 = myconsole.indexOf("SoX v", 0);
        if ( tmpint_3 != -1 )
        {
		chkd1->setChecked(true);
		tmpint_5++;
	}
	else
        {
		chkd1->setChecked(false);
	}
	// *** CONTROLE OGG ET MP3 ***
        tmpint_3 = myconsole.indexOf("FILE FORMATS", 0);
        if ( tmpint_3 != -1 )
        {
	        tmpint_1 = myconsole.indexOf("mp3", tmpint_3);
	        if ( tmpint_1 != -1 )
	        {
			chkd3->setChecked(true);
			tmpint_5++;
		}
		else
	        {
			chkd3->setChecked(false);
		}
	        tmpint_1 = myconsole.indexOf("ogg", tmpint_3);
	        if ( tmpint_1 != -1 )
	        {
			chkd2->setChecked(true);
			tmpint_5++;
		}
		else
	        {
			chkd2->setChecked(false);
		}
	}
	else
        {
		qDebug() << "STRANGE SOX IS PRESENT BUT NO AUDIO FORMAT SUPPORT";
	}
	// *** MPLAYER ET MENCODER ***
        tmpint_3 = myconsole.indexOf("MPlayer ", 0);
        if ( tmpint_3 != -1 )
        {
		chkd4->setChecked(true);
		tmpint_5++;
	}
	else
        {
		chkd4->setChecked(false);
	}
        tmpint_3 = myconsole.indexOf("MEncoder ", 0);
        if ( tmpint_3 != -1 || chkd4->isChecked() == true )
        {
		chkd5->setChecked(true);
		tmpint_5++;
	}
	else
        {
		chkd5->setChecked(false);
	}
	// *** RESULTAT ***

	if ( tmpint_5 == 5 )
	{
		frame_control_dep->hide();
		menubar->setEnabled(true);
		toolBar->setEnabled(true);
		f_nextstep();
	}
	else
	{
		frame_control_dep->setGeometry((this->width()-551)/2,(this->height()-310)/2,551,281);
		frame_control_dep->show();
		frame_control_dep->raise();
	}
}

void mainfrm::f_nextstep()
{
	QDir currentDir = QDir::homePath();
	// *** FIRST LAUNCH ***
	QFile configfile( currentDir.path() + "/.smile.cnf" );
	if (configfile.open(QFile::ReadOnly)) 
	{
		newData = configfile.readLine(0);
		wg_tmp_002 = QString::fromLocal8Bit(newData);
		if (wg_tmp_002.left(8) != "SMILE_V3")
		{
			configfile.close();
			// *** FENETRE DE PARAMETRAGE ***
			menubar->setDisabled(true);
			actionNouveau->setDisabled(true);
			actionOuvrir->setDisabled(true);
			actionParametres_import->setDisabled(true);
			param_window->setGeometry((this->width() - 500)/2,(this->height() - 341)/2,500,341);
			param_window->show();
		}
		else
		{
			param_window->hide();
			newData = configfile.readLine(0);
			wg_tmp_002 = QString::fromLocal8Bit(newData);
			configfile.close();
			path_out_render->setText(wg_tmp_002);
			current_path = QDir::homePath();
			wg_library = wg_tmp_002;
			pntmygl->wg_tet_library = wg_library;
			f_charge_liste_files(current_path);
			QTimer::singleShot(2, this, SLOT(f_splash_load()));
		}
	}
	else
	{
		// *** FENETRE DE PARAMETRAGE ***
		menubar->setDisabled(true);
		actionNouveau->setDisabled(true);
		actionOuvrir->setDisabled(true);
		actionParametres_import->setDisabled(true);
		param_window->setGeometry((this->width() - 500)/2,(this->height() - 341)/2,500,341);
		param_window->show();
	}
}

void mainfrm::f_apropos()
{
	toolBar->setDisabled(true);
	menubar->setDisabled(true);
	tabmenus->setDisabled(true);
	toolsmenu->setDisabled(true);
	contain_timeline->setDisabled(true);
	pntmygl->setDisabled(true);
	apropos->show();
	apropos->raise();
}

void mainfrm::f_close_apropos()
{
	toolBar->setEnabled(true);
	menubar->setEnabled(true);
	if ( nbre_photos >= 0 )
	{
		tabmenus->setEnabled(true);
		toolsmenu->setEnabled(true);
	}
	contain_timeline->setEnabled(true);
	pntmygl->setEnabled(true);
	apropos->hide();
}

void mainfrm::f_scale(int value)
{
	label_scale->setText(QString::number(value) + "%");
	table_photos[current_diapo][7] = QString::number(value);
	pntmygl->size_factor = (float)((float)value/(float)100);
	pntmygl->updateGL();
}

void mainfrm::f_updfrm(int forme)
{
	table_photos[current_diapo][27] = QString::number(forme);
}

void mainfrm::f_save_param()
{
	if (tempfolder->text() != "" )
	{
		QDir currentDir = QDir::homePath();
		#ifdef Q_WS_WIN
			QFile configfile( currentDir.path() + "\.smile.cnf" );
		#else
			QFile configfile( currentDir.path() + "/.smile.cnf" );
		#endif
		if (configfile.open(QFile::WriteOnly)) 
		{
			QTextStream out(&configfile);
			out << "SMILE_V3" << endl;
			#ifdef Q_WS_WIN
				out << tempfolder->text() + "\\";
			#else
				out << tempfolder->text();
			#endif
			configfile.close();
			//
			QString program;
			QStringList arguments;
			#ifdef Q_WS_WIN
				program = "xcopy";
				arguments << "/e";
				arguments << "/s";
				arguments << QApplication::applicationDirPath() + "\BIB_ManSlide\\";
				arguments << tempfolder->text();
			#else
				program = "cp";
				arguments << "-r";
				arguments << "-f";
				arguments << QApplication::applicationDirPath() + "/BIB_ManSlide/";
				arguments << tempfolder->text();
			#endif
			ispreview = 4;
			myprocess_9.start( program, arguments );
			//
			path_out_render->setText(tempfolder->text());
			current_path = QDir::homePath();
			wg_library = tempfolder->text(); //QCoreApplication::applicationDirPath();  
			pntmygl->wg_tet_library = wg_library;
			f_charge_liste_files(current_path);
			param_window->hide();
		}
		else
		{
			QMessageBox::information(this, "SMILE", tr("Erreur... Smile ne parvient pas �  créer le fichier de configuration."));
		}
	}
	else
	{
		QMessageBox::information(this, "SMILE", tr("Vous devez choisir un dossier pour les fichiers de travail."));
	}
}

void mainfrm::f_find_tempfolder()
{
	QString mydir = QFileDialog::getExistingDirectory( this, tr("Choisissez un repertoire de travail"), "~", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
        if ( mydir.isNull() )
        {
        }
	else
	{
		if ( mydir.right(1) != "/" )
		{
			mydir = mydir + "/";
		}
		tempfolder->setText(mydir);
	}
}

void mainfrm::f_gliss_left()
{
	scroll_timeline->setValue(scroll_timeline->value() + 10);
}

void mainfrm::f_gliss_right()
{
	scroll_timeline->setValue(scroll_timeline->value() - 10);
}

void mainfrm::f_resize(QResizeEvent *)
{
	f_resizer();
}

void mainfrm::f_resizer()
{
	// *** RESIZE DE LA FENTRE ***
	SUPPORT_FRAME->setGeometry(0,0,this->width(),this->height() - (contain_timeline->height() + toolBar->height()+menubar->height()));
	if ( tabmenus->isVisible() == true )
	{
		frame_design->setGeometry(0,0,this->width()-311,SUPPORT_FRAME->height());
		frame_realplay->setGeometry(0,0,this->width()-311,SUPPORT_FRAME->height());
		zone_painter->setGeometry(0,0,this->width()-311,SUPPORT_FRAME->height());
		bt_start->setGeometry(((frame_design->width() - 84)/2)-30,1,28,28);
		bt_end->setGeometry(((frame_design->width() - 84)/2)+30,1,28,28);
		bt_play->setGeometry((frame_design->width() - 84)/2,1,28,28);
		frame_xperttimeline->setGeometry(25,SUPPORT_FRAME->height()-80,this->width()-361,70);
	}
	else
	{
		frame_design->setGeometry(0,0,this->width(),SUPPORT_FRAME->height());
		frame_realplay->setGeometry(0,0,this->width(),SUPPORT_FRAME->height());
		zone_painter->setGeometry(0,0,this->width(),SUPPORT_FRAME->height());
		bt_start->setGeometry(((frame_design->width() - 84)/2)-30,1,28,28);
		bt_end->setGeometry(((frame_design->width() - 84)/2)+30,1,28,28);
		bt_play->setGeometry((frame_design->width() - 84)/2,1,28,28);
		frame_xperttimeline->setGeometry(25,SUPPORT_FRAME->height()-80,this->width()-50,70);
	}
	pntstamp->setGeometry(0,0,frame_xperttimeline->width(),80);
	pntstamp->repaint();
	frame_property->setGeometry(frame_design->width(),0,311,SUPPORT_FRAME->height());
	if ( SUPPORT_FRAME->height() > 710 )
	{
		tabmenus->setGeometry(0,0,292,SUPPORT_FRAME->height()-10);
	}
	else
	{
		tabmenus->setGeometry(0,0,292,710);
	}
	frame_ed3d->setGeometry((frame_design->width() - size_dia_x)/2,(frame_design->height() - size_dia_y) / 2,size_dia_x,size_dia_y);
	contain_timeline->setGeometry(0,this->height() - (151+toolBar->height()+menubar->height()),this->width(),151);
	support_timeline->setGeometry(10,33,this->width()-20,91);
	top_timeline->setGeometry(0,0,this->width(),31);
	pnttimeline->lengthtimeline = support_timeline->width();
	scroll_timeline->setGeometry(10,130,this->width()-20,15);
	label_curdiapo->setGeometry(this->width() - 220,0,211,31);
	label_nbrediapo->setGeometry(this->width() - 430,0,211,31);
	apropos->setGeometry((this->width()-441)/2,(this->height()-(461+toolBar->height()+menubar->height()))/2,441,461);
	//
	frame_bibliotheque->setGeometry(0,0,this->width(),this->height() - (151+toolBar->height()+menubar->height()));
	bt_close_biblio->setGeometry(this->width()-115,4,105,32);
	bt_refresh_liste->setGeometry(this->width()-230,4,105,32);
	lstfiles->setGeometry(10,40,frame_bibliotheque->width() - 20,frame_bibliotheque->height() - 50);
	lstfiles->reset();

	frame_editor->setGeometry(0,0,this->width(),this->height() - (toolBar->height()+menubar->height()));
	frame_fond_editor->setGeometry(130,50,frame_editor->width()-130,frame_editor->height()-50);
	frame_widget_txt->setGeometry(0,0,this->width()-311,SUPPORT_FRAME->height());
	frame_lsteffedi->setGeometry(0,50,130,frame_editor->height()-50);
	scrollArea_8->setGeometry(0,0,frame_lsteffedi->width(),frame_lsteffedi->height());

	scrollArea_1->setGeometry(0,0,frame_fond_editor->width(),frame_fond_editor->height());
	scrollArea_2->setGeometry(0,0,frame_design->width(),frame_design->height());
	scrollArea_3->setGeometry(0,0,frame_design->width(),frame_design->height());
	scrollArea_4->setGeometry(0,0,frame_widget_txt->width(),frame_widget_txt->height());
	scrollArea_5->setGeometry(0,0,frame_property->width(),frame_property->height());
	scrollArea_6->setGeometry(0,0,frame_design->width(),frame_design->height());
	if (frame_editor->isVisible() == true )
	{
		pntlabel->setGeometry((frame_fond_editor->width()-pntlabel->width())/2,(frame_fond_editor->height()-pntlabel->height())/2,pntlabel->width(),pntlabel->height());
	}
	//
	frame_new_proj->setGeometry((this->width() - 441)/2,(this->height()-(221+toolBar->height()+menubar->height()))/2,441,221);
	frame_encode->setGeometry((this->width() - 321)/2,(this->height()-(toolBar->height()+menubar->height()+111))/2,321,111);
	frame_parametres->setGeometry((this->width() - 201)/2,(this->height() - (261+toolBar->height()+menubar->height()))/2,201,261);
	// *** PLAYER ***
	frame_player->setGeometry(0,0,this->width(),this->height() - (toolBar->height()+menubar->height()));
	player_progress->setGeometry(80,18,frame_player->width() - 90,20);
	frame_tv->setGeometry(0,0,this->width(),this->height() - (toolBar->height()+menubar->height()+51));
	frame_ctrl_player->setGeometry(0,this->height() - (toolBar->height()+menubar->height())-51,this->width(),51);
	menu_imgedit->setGeometry(frame_fond_editor->width() - 230,10,menu_imgedit->width(),menu_imgedit->height());
	//
	if ( frame_editor->isVisible() == true )
	{
		pntlabel->repaint();
	}
	bt_ok_editor->setGeometry(this->width()-121,9,111,32);
	bt_cancel_editor->setGeometry(this->width()-241,9,111,32);

	//
	if ( pntmygl->ismblur != 0 )
	{
		pntmygl->bcle_render = 1;
		pntmygl->updateGL();
	}
}

void mainfrm::f_size_anim(int valeur)
{
	if ( must_redraw == 0 )
	{
		QString istheblur;
		if  (check_mblur->isChecked() == true)
		{
			istheblur = "1";
		}
		else
		{
			istheblur = "0";
		}
		table_photos[current_diapo][12] = QString::number(valeur) + ";" + QString::number(pntmygl->posanim_x) + "$" + QString::number(pntmygl->posanim_y) + "@" + QString::number(slider_rot_anim->value()) + "#&" + istheblur;
		pntmygl->sizanim = (float)valeur / 100;
		pntmygl->updateGL();
	}
}

void mainfrm::f_opencomplex()
{
	if ( frame_xperttimeline->isVisible() == false )
	{
		frame_xperttimeline->hide();
		if ( tabmenus->isVisible() == true )
		{
			frame_xperttimeline->setGeometry(25,SUPPORT_FRAME->height()+80,this->width()-361,70);
		}
		else
		{
			frame_xperttimeline->setGeometry(25,SUPPORT_FRAME->height()+80,this->width()-50,70);
		}
		bt_complex->setIcon(QIcon(":/new/prefix2/Interface/Theme/1downarrow.png"));
		thread_ani->scr_width = SUPPORT_FRAME->width()-361;
		thread_ani->scr_height = SUPPORT_FRAME->height();
		thread_ani->hdlfra = frame_xperttimeline;
		thread_ani->wlwidth = frame_xperttimeline->width();
		thread_ani->wlheight = frame_xperttimeline->height();
		thread_ani->type_ani = 1;
		state_timeline = 1;
		thread_ani->y = SUPPORT_FRAME->height()+10;
		frame_xperttimeline->show();
		QTimer::singleShot(5, this, SLOT(f_startani()));
	}
	else
	{
		bt_complex->setIcon(QIcon(":/new/prefix2/Interface/Theme/1uparrow.png"));
		bt_complex->setDisabled(true);
		thread_ani->scr_width = SUPPORT_FRAME->width()-361;
		thread_ani->scr_height = SUPPORT_FRAME->height();
		thread_ani->hdlfra = frame_xperttimeline;
		thread_ani->wlwidth = frame_xperttimeline->width();
		thread_ani->wlheight = frame_xperttimeline->height();
		thread_ani->type_ani = 2;
		state_timeline = 0;
		thread_ani->y = SUPPORT_FRAME->height()-80;
		/*if ( tabmenus->isVisible() == true )
		{
			frame_xperttimeline->setGeometry(25,SUPPORT_FRAME->height()-80,this->width()-361,70);
		}
		else
		{
			frame_xperttimeline->setGeometry(25,SUPPORT_FRAME->height()-80,this->width()-50,70);
		}*/
		QTimer::singleShot(5, this, SLOT(f_startani()));
	}
}

void mainfrm::f_hide_complex()
{
	frame_xperttimeline->hide();
	bt_complex->setEnabled(true);
}

void mainfrm::f_sizep()
{
	slider_size_anim->setValue(slider_size_anim->value()+1);
}

void mainfrm::f_sizem()
{
	slider_size_anim->setValue(slider_size_anim->value()-1);
}

void mainfrm::f_pos_anim()
{
	QString istheblur;
	if  (check_mblur->isChecked() == true)
	{
		istheblur = "1";
	}
	else
	{
		istheblur = "0";
	}
	table_photos[current_diapo][12] = QString::number(slider_size_anim->value()) + ";" + QString::number(pntmygl->posanim_x) + "$" + QString::number(pntmygl->posanim_y) + "@" + QString::number(slider_rot_anim->value()) + "#&" + istheblur;
	pntmygl->updateGL();
}

void mainfrm::f_rot_anim(int valeur)
{
	if ( must_redraw == 0 )
	{
		QString istheblur;
		if  (check_mblur->isChecked() == true)
		{
			istheblur = "1";
		}
		else
		{
			istheblur = "0";
		}
		table_photos[current_diapo][12] = QString::number(slider_size_anim->value()) + ";" + QString::number(pntmygl->posanim_x) + "$" + QString::number(pntmygl->posanim_y) + "@" + QString::number(valeur) + "#&" + istheblur;
		pntmygl->rotanim = (float)valeur;
		pntmygl->updateGL();
	}
}

void mainfrm::f_mblur(int valeur)
{
	if ( valeur == 0)
	{
		table_photos[current_diapo][12] = QString::number(slider_size_anim->value()) + ";" + QString::number(pntmygl->posanim_x) + "$" + QString::number(pntmygl->posanim_y) + "@" + QString::number(slider_rot_anim->value()) + "#" + "&0";
		pntmygl->ismblur = 0;
	}
	else
	{
		table_photos[current_diapo][12] = QString::number(slider_size_anim->value()) + ";" + QString::number(pntmygl->posanim_x) + "$" + QString::number(pntmygl->posanim_y) + "@" + QString::number(slider_rot_anim->value()) + "#" + "&1";
		pntmygl->ismblur = 1;
	}
	pntmygl->updateGL();
}

void mainfrm::f_splash_load()
{
	QDir tmpdir;
	tmpdir.setPath(wg_library + "/BIB_ManSlide/Eff_sup/");
	QStringList filters;
	filters << "*.mng" << "*.MNG" << "*.gif" << "*.GIF" << "*.png" << "*.PNG";
	tmpdir.setNameFilters(filters);
	int positem = 1;
	QString wlfile;

	foreach (wlfile, tmpdir.entryList(QDir::Files))
	{
		comboeffets->insertItem(positem, wlfile);
		comboeffets->setItemIcon(positem, QIcon(wg_library + "/BIB_ManSlide/Eff_sup/" + wlfile));
		positem++;
	}
	//
	tmpdir.setPath(wg_library + "/BIB_ManSlide/Luma/");
	//filters << "MINI*.png";
	//tmpdir.setNameFilters(filters);
	positem = 2;
	QPixmap transpix;
	QString nametra;

	lst_transitions->setItemIcon(1, QIcon(":/new/prefix2/Interface/Theme/crossfade.png"));
	lst_transitions_2->setItemIcon(2, QIcon(":/new/prefix2/Interface/Theme/crossfade.png"));

	QImage loadtra;

	foreach (wlfile, tmpdir.entryList())
	{
		if ( positem < 99 )
		{
			if ( wlfile != "crossfade.png" )
			{
				nametra = wlfile.mid(0,wlfile.length() - 4);
				transpix.load(wg_library + "/BIB_ManSlide/Luma/" + wlfile);
				transpix = transpix.scaledToWidth( 128, Qt::FastTransformation );
    				lst_transitions->insertItem(positem,nametra);
				lst_transitions->setItemIcon(positem, QIcon(transpix));
    				lst_transitions_2->insertItem(positem+1,nametra);
				lst_transitions_2->setItemIcon(positem+1, QIcon(transpix));
				table_transitions[positem] = wg_library + "/BIB_ManSlide/Luma/" + nametra + ".png";
				loadtra.load(wg_library + "/BIB_ManSlide/Luma/" + nametra + ".png");
				table_image_transition[positem-2] = loadtra;
				++positem;
			}
		}
	}
	this->setFocus();
	QString openargument = QCoreApplication::arguments().last();
	if (openargument.right(5) != "smile" && openargument.right(7) != "./smile")
	{
		qDebug() << openargument;
		f_ext_open(openargument);
	}
}

void mainfrm::f_select_new()
{
	actionNouveau->setEnabled(false);
	actionOuvrir->setEnabled(false);
	actionEnregistrer->setEnabled(false);
	actionEnregistrer_sous->setEnabled(false);
	actionAjouter_des_diapositives->setEnabled(false);
	actionAjouter_une_diapositive_transparente->setEnabled(false);
	actionAjouter_une_vid_o_comme_diapositive->setEnabled(false);
	actionSupprimer_diapositive->setEnabled(false);
	actionCopier->setEnabled(false);
	actionColler->setEnabled(false);
	actionPrendre_photo->setEnabled(false);
	actionDeplacer_gauche->setEnabled(false);
	actionDeplacer_droite->setEnabled(false);
	actionRender->setEnabled(false);
	actionDeplacement->setEnabled(false);
	actionDupliquer_la_diapositive_actuelle->setEnabled(false);
	actionZoom->setEnabled(false);
	actionRotation_X->setEnabled(false);
	actionRotation_Y->setEnabled(false);
	actionRotation_Z->setEnabled(false);
	actionRotation_libre->setEnabled(false);
	actionReinitialiser->setEnabled(false);
	actionMarquer_depart->setEnabled(false);
	actionMarquer_fin->setEnabled(false);
	actionEditer_diapositive->setDisabled(true);
	top_timeline->setDisabled(true);
	toolsmenu->setDisabled(true);
	tabmenus->setDisabled(true);
	contain_timeline->setDisabled(true);
	pntmygl->resize(0,0);
	if ( frame_xperttimeline->isVisible() == true )
	{
		bt_complex->setIcon(QIcon(":/new/prefix2/Interface/Theme/1uparrow.png"));
		frame_xperttimeline->hide();
	}
	myconsole = path_out_render->text();
	frame_new_proj->show();
	frame_new_proj->raise();
}

void mainfrm::f_cancel_new()
{
	frame_new_proj->hide();
	actionNouveau->setEnabled(true);
	actionOuvrir->setEnabled(true);
	path_out_render->setText(myconsole);
	if ( pntmygl->path_render != "" )
	{
		actionAjouter_des_diapositives->setEnabled(true);
		actionAjouter_une_vid_o_comme_diapositive->setEnabled(true);
		actionAjouter_une_diapositive_transparente->setEnabled(true);

		pnttimeline->setEnabled(true);
		actionNouveau->setEnabled(true);
		actionOuvrir->setEnabled(true);
		tabmenus->setEnabled(true);
		contain_timeline->setEnabled(true);

		if ( nbre_photos >= 0 )
		{
			actionEnregistrer->setEnabled(true);
			actionEnregistrer_sous->setEnabled(true);
			actionSupprimer_diapositive->setEnabled(true);
			actionCopier->setEnabled(true);
			actionColler->setEnabled(true);
			actionPrendre_photo->setEnabled(true);
			actionDeplacer_gauche->setEnabled(true);
			actionDeplacer_droite->setEnabled(true);
			actionRender->setEnabled(true);
			actionDeplacement->setEnabled(true);
			actionDupliquer_la_diapositive_actuelle->setEnabled(true);
			actionZoom->setEnabled(true);
			actionRotation_X->setEnabled(true);
			actionRotation_Y->setEnabled(true);
			actionRotation_Z->setEnabled(true);
			actionRotation_libre->setEnabled(true);
			actionReinitialiser->setEnabled(true);
			actionMarquer_depart->setEnabled(true);
			actionMarquer_fin->setEnabled(true);
			actionEditer_diapositive->setEnabled(true);
			top_timeline->setEnabled(true);
			toolsmenu->setEnabled(true);
		}
		pntmygl->resize(size_dia_x,size_dia_y);
	}
}

void mainfrm::f_launch_new()
{
	if ( path_out_render->text() != "" )
	{
		if ( combofscale->currentIndex() == 1 )
		{
			size_dia_x = 1024;
			size_dia_y = 576;
			pntmygl->is43 = 0;
			is43 = 0;
		}
		else
		{
			if ( combofscale->currentIndex() == 0 )
			{
				size_dia_x = 720;
				size_dia_y = 576;
				pntmygl->is43 = 1;
				is43 = 1;
			}
			else
			{
				size_dia_x = 720;
				size_dia_y = 480;
				pntmygl->is43 = 2;
				is43 = 2;
			}
		}
		frame_play->setGeometry(0,0,size_dia_x,size_dia_y);
		pntlabeltxt->size_dia_x = size_dia_x;
		pntlabeltxt->size_dia_y = size_dia_y;
		pntlabeltxt->setGeometry(0,0,size_dia_x,size_dia_y);
		frame_painter->setGeometry(0,0,size_dia_x,size_dia_y);
		frame_painter->scaledp(size_dia_x,size_dia_y);
		frame_ed3d->setGeometry((frame_design->width() - size_dia_x)/2,(frame_design->height() - size_dia_y) / 2,size_dia_x,size_dia_y);
		frame_new_proj->hide();
		nbre_imports = 0;
		QDir tmpdir(path_out_render->text() + "/.TmpManSlide");
		pntmygl->path_render = path_out_render->text() + "/.TmpManSlide";
		wg_save_filename = "";
		if ( tmpdir.exists() == false )
		{
			QDir credir(path_out_render->text());
			if ( credir.mkpath(".TmpManSlide") == true )
			{
				wpathprojet = path_out_render->text() + ".TmpManSlide";
				pntmygl->path_render = wpathprojet;
				contain_timeline->setEnabled(true);
			}
			else
			{
				QMessageBox::information(this, "SMILE", tr("SMILE n a pas reussi a creer un repertoire temporaire dans votre dossier tmp : ") + path_out_render->text());
			}
		}
		else 
		{
			wpathprojet = path_out_render->text() + ".TmpManSlide";
			pntmygl->path_render = wpathprojet;
			QDir wcurrentDir(wpathprojet);
			QStringList filters;
			filters << "*.*";
			QString wl_tmp_1;

			foreach (QString file, wcurrentDir.entryList(QDir::Files))
			{
				wl_tmp_1 = wpathprojet + "/" + file;
				if ( QFile::remove ( wl_tmp_1 ) == false )
				{
					qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY : " << wl_tmp_1;
				}
			}
			contain_timeline->setEnabled(true);
		}
		tabmenus->setDisabled(true);
		actionNouveau->setEnabled(true);
		actionOuvrir->setEnabled(true);
		pnttimeline->setEnabled(true);
		actionAjouter_des_diapositives->setEnabled(true);
		actionAjouter_une_diapositive_transparente->setEnabled(true);
		actionAjouter_une_vid_o_comme_diapositive->setEnabled(true);
		contain_timeline->setEnabled(true);
		pntmygl->iseffect = 0;
		pntmygl->isdraw = 0;
		pntmygl->max_diapo = -1;
		scroll_timeline->setValue(0);
		scroll_timeline->hide();
		pntmygl->resize(size_dia_x,size_dia_y);
		//
		QTimer::singleShot(5, this, SLOT(f_start_new()));
	}
}

void mainfrm::f_close_player()
{
	player_end(0, QProcess::NormalExit);
	if ( ispreview == 1 || ispreview == 9 )
	{
		QString wl_tmp_1 = wpathprojet + "/MSpreview.mpg";
		if ( QFile::remove ( wl_tmp_1 ) == false )
		{
			//qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY ...";
		}
	}
}

void mainfrm::f_remove_effet()
{
	if ( comboeffets->currentIndex() > 0 )
	{
		int result = QMessageBox::information(this, "SMILE", tr("Voulez vous vraiment supprimer cet effet : ") + comboeffets->currentText() , tr("Oui"), tr("Non"), 0, 1 );
		if (result == 0)
		{
			if ( QFile::remove(wg_library + "BIB_ManSlide/Eff_sup/" + comboeffets->currentText()) == false )
			{
				qDebug() << "ERROR REMOVING EFFECT FILE : " << wg_library + "BIB_ManSlide/Eff_sup/" + comboeffets->currentText();
			}
			f_reload();
			comboeffets->setCurrentIndex(0);
		}
	}
}

void mainfrm::f_find_out()
{
	QString mydir = QFileDialog::getExistingDirectory( this, tr("Choisissez un repertoire pour le diaporama"), "~", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
        if ( mydir.isNull() )
        {
        }
	else
	{
		if ( mydir.right(1) != "/" )
		{
			mydir = mydir + "/";
		}
		path_out_render->setText(mydir);
	}
}

void mainfrm::f_start_close()
{
	this->close();
}

void mainfrm::f_end_mainfrm()
{
	// ****************************************
	// *** Point de sortie de l'application ***
	// ****************************************
	QString program = "rm";
       	QStringList arguments;
	arguments << "-rf";
	ispreview = 9;
       	arguments << path_out_render->text() + "/.TmpManSlide";
       	myprocess_5.start( program, arguments );
	//
	if ( mplayerProcess.state() == QProcess::Starting || mplayerProcess.state() == QProcess::Running )
	{
		mplayerProcess.kill();	
	}
	mplayerProcess.waitForFinished(1000);
	//
	thread_img->quit();
	thread_thu->quit();
	thread_tra->quit();
	thread_ani->quit();
	thread_ptra->quit();
}

void mainfrm::f_ajout_effet()
{
	QString wmyfic = QFileDialog::getOpenFileName(this, tr("Ajouter une animation"), "~", tr("Animations (*.gif *.GIF *.mng *.MNG)"));
        if ( wmyfic.isNull() )
        {
        }
        else
        {
		int i = wmyfic.lastIndexOf( '/' );
		outfilename = wmyfic.mid(i + 1, wmyfic.length() - (i + 1));
		QFile::copy ( wmyfic, wg_library + "BIB_ManSlide/Eff_sup/" + outfilename );
		f_reload();
	}
}

void mainfrm::f_reload()
{
	QDir tmpdir;
	tmpdir.setPath(wg_library + "BIB_ManSlide/Eff_sup/");
	QStringList filters;
	filters << "*.mng" << "*.MNG" << "*.gif" << "*.GIF" << "*.png" << "*.PNG";
	tmpdir.setNameFilters(filters);
	int positem = 1;
	QString wlfile;
	comboeffets->clear();
	comboeffets->insertItem(0,tr("Aucun"));
	foreach (wlfile, tmpdir.entryList(QDir::Files))
	{
		comboeffets->insertItem(positem, wlfile);
		comboeffets->setItemIcon(positem, QIcon(wg_library + "/BIB_ManSlide/Eff_sup/" + wlfile));
		positem++;
	}
}

void mainfrm::sl_go_start()
{
	position_flux = 0;
	pntmygl->wg_percent = table_photos[current_diapo][25].toFloat() / 100;
	pntmygl->posxleg = pntmygl->startx_legani;
	pntmygl->posyleg = pntmygl->starty_legani;

	pntmygl->debut_rx = pntstamp->table_coo[0][0];
	pntmygl->debut_ry = pntstamp->table_coo[0][1];
	pntmygl->debut_rz = pntstamp->table_coo[0][2];
	pntmygl->debut_px = pntstamp->table_coo[0][3];
	pntmygl->debut_py = pntstamp->table_coo[0][4];
	pntmygl->debut_pz = pntstamp->table_coo[0][5];


	pntmygl->sl_go_start();
	if ( table_photos[current_diapo][14] == "1" )
	{
		pntmygl->sl_opacity(table_photos[current_diapo][15].toInt());
	}
}

void mainfrm::sl_go_end()
{
	position_flux = 1;
	pntmygl->wg_percent = table_photos[current_diapo][26].toFloat() / 100;
	pntmygl->posxleg = pntmygl->endx_legani;
	pntmygl->posyleg = pntmygl->endy_legani;

	pntmygl->fin_rx = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][0];
	pntmygl->fin_ry = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][1];
	pntmygl->fin_rz = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][2];
	pntmygl->fin_px = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][3];
	pntmygl->fin_py = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][4];
	pntmygl->fin_pz = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][5];

	pntmygl->sl_go_end();
	if ( table_photos[current_diapo][14] == "1" )
	{
		pntmygl->sl_opacity(table_photos[current_diapo][28].toInt());
	}
}

void mainfrm::f_start_new()
{
	int destruct_i_1 = 0;

	while ( destruct_i_1 <= nbre_photos && destruct_i_1 < 400 )
	{
		delete table_pnt_img[destruct_i_1];
		table_color_fog[destruct_i_1] = QColor(128,128,128);
		destruct_i_1++;
	}
	QDir wcurrentDir(wpathprojet);
	QStringList filters;
	filters << "*.*";
	QString wl_tmp_1;

	foreach (QString file, wcurrentDir.entryList(QDir::Files))
	{
		wl_tmp_1 = wpathprojet + "/" + file;
		if ( QFile::remove ( wl_tmp_1 ) == false )
		{
			qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY : " << wl_tmp_1;
		}
	}
	pntmygl->tool = 0;
	zik_number = 0;
	zik_1->hide();
	zik_1->position = 0;
	pnttimeline->zik_number = 0;
	total_audio = 0;
	must_redraw = 0;
	img_selection->hide();
	nbre_photos = -1;
	current_diapo = -1;
	pnttimeline->max_diapo = -1;

	pntmygl->sl_charge_image("$N$U$L$L","$N$U$L$L","$N$U$L$L");
	pntmygl->updateGL();
}

void mainfrm::f_change_color_fog()
{
	QColor wlcolor(pntwheelfog->red,pntwheelfog->green,pntwheelfog->blue);
	if ( wlcolor.isValid() == true )
	{
		table_color_fog[current_diapo] = wlcolor;
		pntmygl->fogcolor[0] = (float)table_color_fog[current_diapo].red() / (float)255;
		pntmygl->fogcolor[1] = (float)table_color_fog[current_diapo].green() / (float)255;
		pntmygl->fogcolor[2] = (float)table_color_fog[current_diapo].blue() / (float)255;
		pntmygl->fogcolor[3] = 0.5;
		pntmygl->change_fog_color();
		pntmygl->updateGL();
	}
}

void mainfrm::f_changedur_2(int valeur)
{
	spindurtrans_2->setMaximum(valeur-1);
}

void mainfrm::f_supp_comment()
{
	if ( QFile::remove ( wpathprojet + "/" + table_photos[current_diapo][24] ) == false )
	{
		qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY ...";
	}
	table_photos[current_diapo][24] = "";
	pnttimeline->iscomment = 0;
	//
	QLabel *mylabel;
	mylabel = table_pnt_img[current_diapo];
	QImage wl_pix_1(wpathprojet + "/" + table_photos[current_diapo][0]);
	QPixmap wl_pix_2(wg_diapositive);
	QImage wl_pix_3;
	if ( wl_pix_1.height() >= wl_pix_1.width() || (float)((float)wl_pix_1.width() / (float)wl_pix_1.height()) < (float)1.32 )
	{
		wl_pix_3 = wl_pix_1.scaledToHeight ( 63, Qt::FastTransformation );
	}
	else
	{
		wl_pix_3 = wl_pix_1.scaledToWidth ( 83, Qt::FastTransformation );
	}
	QPainter p;
	p.begin(&wl_pix_2);
	p.drawImage(7 + ((83 - wl_pix_3.width()) / 2), 7 + ((63 - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, wl_pix_3.width(), wl_pix_3.height() );
	QIcon myicon = lst_transitions->itemIcon(lst_transitions->currentIndex());
	myicon.paint ( &p, 5, 40, 32, 32, Qt::AlignCenter, QIcon::Normal, QIcon::On );
	p.end();
	mylabel->setPixmap(wl_pix_2);
}

void mainfrm::f_open_comment()
{
	QString wmyfic = QFileDialog::getOpenFileName(this, tr("Ouvrir un fichier audio"), path_musique_import, tr("Audio (*.OGG *.ogg *.WAV *.wav *.mp3 *.MP3)"));
        if ( wmyfic.isNull() )
        {
        }
        else
        {
            	int i = wmyfic.lastIndexOf( '/' );
            	if ( i != -1 )
            	{
                	path_musique_import = wmyfic.mid(0,i);
            	}
		int tmpvar2 = wmyfic.lastIndexOf("/");
		if (QFile::copy ( wmyfic, wpathprojet + "/COMMENT" + QString::number(nbre_imports) + wmyfic.mid(tmpvar2 + 1,wmyfic.length() - (tmpvar2+1)) ) == false)
		{
			QMessageBox::information(this, "SMILE", tr("Erreur lors de la copie de ce fichier audio a cet emplacement : ") + wpathprojet + "/COMMENT" + QString::number(nbre_imports) + wmyfic.mid(tmpvar2 + 1,wmyfic.length() - (tmpvar2+1)));
			qDebug() << "ERROR COPYING AUDIO FILE TO TMP PROJECT FOLDER";
		}
		else
		{
			pnttimeline->iscomment = 1;
			table_photos[current_diapo][24] = "COMMENT" + QString::number(nbre_imports) + wmyfic.mid(tmpvar2 + 1,wmyfic.length() - (tmpvar2+1));
			//
			QLabel *mylabel;
			mylabel = table_pnt_img[current_diapo];
			QImage wl_pix_1(wpathprojet + "/" + table_photos[current_diapo][0]);
			QPixmap wl_pix_2(wg_diapositive);
			QImage wl_pix_3;
			if ( wl_pix_1.height() >= wl_pix_1.width() || (float)((float)wl_pix_1.width() / (float)wl_pix_1.height()) < (float)1.32 )
			{
				wl_pix_3 = wl_pix_1.scaledToHeight ( 63, Qt::FastTransformation );
			}
			else
			{
				wl_pix_3 = wl_pix_1.scaledToWidth ( 83, Qt::FastTransformation );
			}
			QPainter p;
			p.begin(&wl_pix_2);
			p.drawImage(7 + ((83 - wl_pix_3.width()) / 2), 7 + ((63 - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, wl_pix_3.width(), wl_pix_3.height() );
			p.drawPixmap(68, 57, wg_comment, 0, 0, -1, -1 );
			QIcon myicon = lst_transitions->itemIcon(lst_transitions->currentIndex());
			myicon.paint ( &p, 5, 40, 32, 32, Qt::AlignCenter, QIcon::Normal, QIcon::On );
			p.end();
			mylabel->setPixmap(wl_pix_2);
			nbre_imports++;
		}
	}
}

void mainfrm::f_save_proj()
{
	if ( wg_save_filename == "" )
	{
		QString wmyfic = QFileDialog::getSaveFileName(this, tr("Sauvegarder votre projet"), "~", tr("Projet (*.smi *.SMI)"));
        	if ( wmyfic.isNull() )
        	{
			return;
        	}
		else
		{
			if ( wmyfic.right(4) != ".smi" && wmyfic.right(4) != ".SMI" )
			{
				wmyfic = wmyfic + ".smi";
			}
			wg_save_filename = wmyfic;
		}
	}
	this->setDisabled(true);
       	QFile myfic(wpathprojet + "/projet.gib");
       	if ( !myfic.open( QIODevice::WriteOnly ))
      	{
		QMessageBox::information(this, "SMILE", tr("Erreur lors de la sauvegarde du projet. SMILE ne peut pas créer le fichier de sauvegarde : ") + wg_save_filename);
		return;
	}
	else
	{
		QTextStream out(&myfic);
		int i = 0;
		int n = 0;
		ispreview = 1;
		QString wlstrwork;
		//
		if ( is43 == 1 )
		{
			out << "R0" << endl;
		}
		else
		{
			if ( is43 == 0 )
			{
				out << "R1" << endl;
			}
			else
			{
				if ( is43 == 2 )
				{
					out << "R2" << endl;
				}
			}
		}

		if ( zik_number > 0 )
		{
			out << "AUDIO:" << table_zik[0][0] << endl;
			out << "AUDIOLENGTH:" << table_zik[0][1] << endl;
			out << "AUDIOPOS:" << zik_1->position << endl;
		}
		else
		{
			out << "AUDIO:" << endl;
			out << "AUDIOLENGTH:" << endl;
			out << "AUDIOPOS:" << endl;
		}
		//
		while ( i <= nbre_photos )
		{
			n = 0;
			while ( n < nbre_occurs )
			{
				wlstrwork = table_photos[i][n];
				wlstrwork.replace(QString("\n"), QString("$NW$LINE$"));
				out << wlstrwork << endl;
				n = n + 1;
			}
			out << table_color_fog[i].red() << endl;
			out << table_color_fog[i].green() << endl;
			out << table_color_fog[i].blue() << endl;
			i = i + 1;
		}
		myfic.close();
       		QFile myfic2(QDir::homePath() + "/save.sh");

      		if ( !myfic2.open( QIODevice::WriteOnly ))
       		{
			QMessageBox::information(this, "SMILE", tr("Erreur lors de la sauvegarde du projet"));
			return;
		}
		else
		{
			QTextStream out2(&myfic2);
			//
			#ifdef Q_WS_WIN
			#else
				out2 << "#!/bin/bash" << endl;
			#endif
			out2 << "cd \"" << path_out_render->text() + "\"" << endl;
			out2 << "tar -cf \"" << wg_save_filename << "\" .TmpManSlide" << endl;
			out2 << "rm -f " + QDir::homePath() + "/save.sh" << endl;
			myfic2.close();
			#ifdef Q_WS_WIN
				QString program = "cmd";
			#else
				QString program = "bash";
			#endif
			QStringList arguments;
			arguments << QDir::homePath() + "/save.sh";
			myprocess_9.start( program, arguments );
		}
	}
}

void mainfrm::f_saveas_proj()
{
	QString wmyfic = QFileDialog::getSaveFileName(this, tr("Sauvegarder votre projet"), "~", tr("Projet (*.smi *.SMI)"));
       	if ( wmyfic.isNull() )
       	{
		return;
       	}
	else
	{
		if ( wmyfic.right(4) != ".smi" && wmyfic.right(4) != ".SMI" )
		{
			wmyfic = wmyfic + ".smi";
		}
		wg_save_filename = wmyfic;
	}
	this->setDisabled(true);
	QString wlstrwork;
       	QFile myfic(wpathprojet + "/projet.gib");
       	if ( !myfic.open( QIODevice::WriteOnly ))
      	{
		QMessageBox::information(this, "SMILE", tr("Erreur lors de la sauvegarde du projet. SMILE ne peut pas créer le fichier de sauvegarde : ") + wg_save_filename);
		return;
	}
	else
	{
		QTextStream out(&myfic);
		int i = 0;
		int n = 0;
		ispreview = 1;
		//
		if ( is43 == 1 )
		{
			out << "R0" << endl;
		}
		else
		{
			if ( is43 == 0 )
			{
				out << "R1" << endl;
			}
			else
			{
				if ( is43 == 2 )
				{
					out << "R2" << endl;
				}
			}
		}
		out << "AUDIO:" << table_zik[0][0] << endl;
		out << "AUDIOLENGTH:" << table_zik[0][1] << endl;
		out << "AUDIOPOS:" << zik_1->position << endl;
		//
		while ( i <= nbre_photos )
		{
			n = 0;
			while ( n < nbre_occurs )
			{
				wlstrwork = table_photos[i][n];
				wlstrwork.replace(QString("\n"), QString("$NW$LINE$"));
				out << wlstrwork << endl;
				n = n + 1;
			}

			out << table_color_fog[i].red() << endl;
			out << table_color_fog[i].green() << endl;
			out << table_color_fog[i].blue() << endl;
			i = i + 1;
		}
		myfic.close();
       		QFile myfic2(QDir::homePath() + "/save.sh");

      		if ( !myfic2.open( QIODevice::WriteOnly ))
       		{
			QMessageBox::information(this, "SMILE", tr("Erreur lors de la sauvegarde du projet"));
			return;
		}
		else
		{
			QTextStream out2(&myfic2);
			//
			#ifdef Q_WS_WIN
			#else
				out2 << "#!/bin/bash" << endl;
			#endif
			out2 << "cd \"" << path_out_render->text() + "\"" << endl;
			out2 << "tar -cf \"" << wg_save_filename << "\" .TmpManSlide" << endl;
			out2 << "rm -f " + QDir::homePath() + "/save.sh" << endl;
			myfic2.close();
			#ifdef Q_WS_WIN
				QString program = "cmd";
			#else
				QString program = "bash";
			#endif
			QStringList arguments;
			arguments << QDir::homePath() + "/save.sh";
			myprocess_9.start( program, arguments );
		}
	}
}

void mainfrm::end_save_project(int, QProcess::ExitStatus)
{
	if ( ispreview == 1 )
	{
		QMessageBox::information(this, "SMILE", tr("Sauvegarde du projet terminee."));
		this->setEnabled(true);
	}
	else
	{
		if ( ispreview == 0 )
		{
			int destruct_i_1 = 0;
			nbre_imports = 0;
			while ( destruct_i_1 <= nbre_photos && destruct_i_1 < 400 )
			{
				delete table_pnt_img[destruct_i_1];
				table_color_fog[destruct_i_1] = QColor(128,128,128);
				destruct_i_1 = destruct_i_1 + 1;
			}
        		QFile myfic(wpathprojet + "/projet.gib");
			QString wl_var_1;
			int tmp_num_001;
			zik_number = 0;
			zik_1->hide();
        		if ( !myfic.open( QIODevice::ReadOnly ))
        		{
				QMessageBox::information(this, "SMILE", tr("Erreur lors de l'ouverture du projet : ") + wpathprojet + "/projet.gib");
				return;
			}
			else
			{
				newData = myfic.readLine(0);
				wl_var_1 = QString::fromLocal8Bit(newData);

				if ( wl_var_1.mid(1,1) == "1" )
				{
					is43 = 0;
					size_dia_x = 1024;
					size_dia_y = 576;
					pntmygl->is43 = 0;
				}
				else
				{
					if ( wl_var_1.mid(1,1) == "0" )
					{
						is43 = 1;
						size_dia_x = 720;
						size_dia_y = 576;
						pntmygl->is43 = 1;
					}
					else
					{
						is43 = 2;
						size_dia_x = 720;
						size_dia_y = 480;
						pntmygl->is43 = 2;
					}
				}
				frame_play->setGeometry(0,0,size_dia_x,size_dia_y);
				pntlabeltxt->size_dia_x = size_dia_x;
				pntlabeltxt->size_dia_y = size_dia_y;
				pntlabeltxt->setGeometry(0,0,size_dia_x,size_dia_y);
				frame_painter->setGeometry(0,0,size_dia_x,size_dia_y);
				frame_painter->scaledp(size_dia_x,size_dia_y);
				pntmygl->resize(size_dia_x,size_dia_y);
				frame_ed3d->setGeometry((frame_design->width() - size_dia_x)/2,(frame_design->height() - size_dia_y) / 2,size_dia_x,size_dia_y);
				// *** Musique pathname ***
				newData = myfic.readLine(0);
				wl_var_1 = QString::fromLocal8Bit(newData);
				if ( wl_var_1.length() > 7 )
				{
					table_zik[0][0] = wl_var_1.mid(6,wl_var_1.length() - 7);
					zik_number = 1;
				}

				// *** Musique duree ***
				newData = myfic.readLine(0);
				wl_var_1 = QString::fromLocal8Bit(newData);
				if ( wl_var_1.length() > 12 )
				{
					table_zik[0][1] = wl_var_1.mid(12,wl_var_1.length() - 13);
				}

				// *** Musique position ***
				newData = myfic.readLine(0);
				wl_var_1 = QString::fromLocal8Bit(newData);
				if ( wl_var_1.length() > 9 )
				{
					zik_1->position = wl_var_1.mid(9,wl_var_1.length() - 10).toInt();
				}
				// *** Photos ***
				int i = 0;
				int j = 0;
				int k = 0;
				QImage wl_pix_1;
				QPixmap wl_pix_2(97,77);
				QImage wl_pix_3;
				QPainter p;
				QIcon myicon;
				QColor wl_mycolor;

				newData = myfic.readLine(0);
				while ( myfic.atEnd() == false )
				{
					j = 0;
					while ( j < nbre_occurs )
					{
						wl_var_1 = QString::fromLocal8Bit(newData);
						wl_var_1.replace(QString("$NW$LINE$"), QString("\n"));
						if ( j == 7 )
						{
							if ( wl_var_1.mid(0,wl_var_1.length() - 1) == "0" )
							{
								table_photos[i][j] = "100";
							}
							else
							{
								table_photos[i][j] = wl_var_1.mid(0,wl_var_1.length() - 1);
							}
						}
						else
						{
							// *** CAS EFFET SUP OLD PROJ ***
							if ( j == 19 )
							{
								if ( wl_var_1.indexOf( "!",0,Qt::CaseSensitive ) < 0 )
								{
									table_photos[i][j] = "0;600:10!10";
								}
								else
								{
									table_photos[i][j] = wl_var_1.mid(0,wl_var_1.length() - 1);
								}
							}
							else
							{
								table_photos[i][j] = wl_var_1.mid(0,wl_var_1.length() - 1);
							}
						}
						j++;
						newData = myfic.readLine(0);
					}
					// *** Rouge ***
					wl_var_1 = QString::fromLocal8Bit(newData);
					tmp_num_001 = wl_var_1.mid(0, newData.count() - 1).toInt();
					wl_mycolor.setRed( tmp_num_001 );
			
					// *** Vert ***
					newData = myfic.readLine(0);
					wl_var_1 = QString::fromLocal8Bit(newData);
					tmp_num_001 = wl_var_1.mid(0, newData.count() - 1).toInt();
					wl_mycolor.setGreen( tmp_num_001 );

					// *** Bleu ***
					newData = myfic.readLine(0);
					wl_var_1 = QString::fromLocal8Bit(newData);
					tmp_num_001 = wl_var_1.mid(0, newData.count() - 1).toInt();
					wl_mycolor.setBlue( tmp_num_001 );
					table_color_fog[i] = wl_mycolor;
					newData = myfic.readLine(0);

					myicon = lst_transitions->itemIcon(table_photos[i][20].toInt());
					if ( wl_pix_1.load( wpathprojet + "/" + table_photos[i][0]) == true )
					{
						wl_pix_2 = wg_diapositive;
						if ( wl_pix_1.height() >= wl_pix_1.width() || (float)((float)wl_pix_1.width() / (float)wl_pix_1.height()) < (float)1.32 )
						{
							wl_pix_3 = wl_pix_1.scaledToHeight ( 63, Qt::FastTransformation );
						}
						else
						{
							wl_pix_3 = wl_pix_1.scaledToWidth ( 83, Qt::FastTransformation );
						}
        					p.begin(&wl_pix_2);
						p.drawImage(7 + ((83 - wl_pix_3.width()) / 2), 7 + ((63 - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, wl_pix_3.width(), wl_pix_3.height() );
						myicon.paint ( &p, 5, 40, 32, 32, Qt::AlignCenter, QIcon::Normal, QIcon::On );
						if ( table_photos[i][24] != "" )
						{
							p.drawPixmap(68, 57, wg_comment, 0, 0, -1, -1 );
						}
						p.end();
						//
						img_selection->show();
						diapo *mylabel = new diapo(pnttimeline);
						mylabel->installEventFilter(this);
						table_pnt_img[i] = mylabel;
						mylabel->setGeometry( ((i * 97) + ((i + 1) * 10)), 0, 97, 77);
        					mylabel->setPixmap ( wl_pix_2 );
            					k = table_photos[i][0].indexOf( '$' );
						mylabel->setToolTip(table_photos[i][0].mid(k + 1, table_photos[i][0].length() - (k + 1)));
        					mylabel->show();
						//
						i++;
						nbre_imports++;
					}
				}
				myfic.close();
				nbre_photos = i - 1;
				current_diapo = 0;
				//
				if ( ((nbre_photos + 1) * 110) - support_timeline->width() > 0 )
				{
					scroll_timeline->setMaximum(((nbre_photos + 1) * 110) - support_timeline->width());
					scroll_timeline->show();
				}
				if ( i >= 0 )
				{
					pnttimeline->max_diapo = nbre_photos;
					pntmygl->max_diapo = nbre_photos;
					pntmygl->resize(size_dia_x,size_dia_y);
					actionNouveau->setEnabled(true);
					actionOuvrir->setEnabled(true);
					pnttimeline->setEnabled(true);
					tabmenus->setEnabled(true);
					toolsmenu->setEnabled(true);
					actionEnregistrer->setEnabled(true);
					actionEnregistrer_sous->setEnabled(true);
					actionAjouter_des_diapositives->setEnabled(true);
					actionAjouter_une_diapositive_transparente->setEnabled(true);
					actionAjouter_une_vid_o_comme_diapositive->setEnabled(true);
					actionSupprimer_diapositive->setEnabled(true);
					actionDupliquer_la_diapositive_actuelle->setEnabled(true);
					actionCopier->setEnabled(true);
					actionColler->setEnabled(false);
					actionPrendre_photo->setEnabled(true);
					actionDeplacer_gauche->setEnabled(true);
					actionDeplacer_droite->setEnabled(true);
					actionEditer_diapositive->setEnabled(true);
					actionRender->setEnabled(true);
					actionDeplacement->setEnabled(true);
					actionZoom->setEnabled(true);
					actionRotation_X->setEnabled(true);
					actionRotation_Y->setEnabled(true);
					actionRotation_Z->setEnabled(true);
					actionRotation_libre->setEnabled(true);
					actionReinitialiser->setEnabled(true);
					actionMarquer_depart->setEnabled(true);
					actionMarquer_fin->setEnabled(true);
					top_timeline->setEnabled(true);
					affichage_diapo();
					f_calcul_son();
				}
				if ( zik_number > 0 )
				{
					int duree = table_zik[0][1].toInt();
					total_audio = 0;
					total_audio = total_audio + duree;
					zik_1->setText(table_zik[0][0] + " - " + QString::number(duree) + " " + tr(" secondes"));
					zik_1->show();
					f_calcul_son();
					//
					pnttimeline->zik_number = zik_number;
				}
				else
				{
					pnttimeline->zik_number = 0;
				}
			}
		}
		else
		{

			if ( ispreview == 5 )
			{
				qDebug() << "NORMALEMENT JE DEVRAIS PAS PASSER ICI";
			}
			else
			{
				if ( ispreview == 6 )
				{
					this->setEnabled(true);
					player_open_video("$"); //wpathprojet + "/stepTFI"
				}
				else
				{
					if ( ispreview == 4 )
					{
						actionNouveau->setEnabled(true);
						actionOuvrir->setEnabled(true);
						actionParametres_import->setEnabled(true);
						QTimer::singleShot(5, this, SLOT(f_splash_load()));
						menubar->setEnabled(true);
					}
				}
			}
		}
	}
}

void mainfrm::f_open_proj()
{
	QString wmyfic = QFileDialog::getOpenFileName(this, tr("Ouvrir un projet"), "~", tr("Projet (*.smi *.SMI)"));
        if ( wmyfic.isNull() )
        {
        }
        else
        {
		f_ext_open(wmyfic);
	}
}

void mainfrm::f_ext_open(QString pathname)
{
	if ( path_out_render->text() == "" )
	{
		QString mydir;
	       	while ( mydir.isNull() )
		{
			mydir = QFileDialog::getExistingDirectory( this, tr("Choisissez votre dossier de travail"), current_path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
			if ( mydir.right(1) != "/" )
			{
				mydir = mydir + "/";
			}
		}
		wg_tmp_002 = mydir;
		path_out_render->setText(wg_tmp_002);
	}
	wg_save_filename = pathname;
	wpathprojet = path_out_render->text() + "/.TmpManSlide/";
	pntmygl->path_render = path_out_render->text() + "/.TmpManSlide";
	QDir wcurrentDir(wpathprojet);
	QStringList filters;
	filters << "*.*";
	QString wl_tmp_1;

	foreach (QString file, wcurrentDir.entryList(QDir::Files))
	{
		wl_tmp_1 = wpathprojet + "/" + file;
		if ( QFile::remove ( wl_tmp_1 ) == false )
		{
			qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY : " << wl_tmp_1;
		}
	}
	QFile myfic2(QDir::homePath() + "/open.sh");
	if ( !myfic2.open( QIODevice::WriteOnly ))
	{
		QMessageBox::information(this, "SMILE", tr("Erreur lors de l ouverture du projet"));
		return;
	}
	else
	{
		QTextStream out2(&myfic2);
		//
		ispreview = 0;
		#ifdef Q_WS_WIN
		#else
			out2 << "#!/bin/bash" << endl;
		#endif
		out2 << "cd \"" << path_out_render->text() + "\"" << endl;
		out2 << "tar -xf \"" << pathname << "\"" << endl;
		out2 << "rm -f " + QDir::homePath() + "/open.sh" << endl;
		myfic2.close();
		#ifdef Q_WS_WIN
			QString program = "cmd";
		#else
			QString program = "bash";
		#endif
		QStringList arguments;
		arguments << QDir::homePath() + "/open.sh";
		myprocess_9.start( program, arguments );
	}
}

void mainfrm::f_sync()
{
	this->setDisabled(true);
	int dur_by_slide = total_audio / (nbre_photos + 1);
	if ( dur_by_slide > 20 )
	{
		dur_by_slide = 20;
	}
	int dur_by_trans = 2;
	if ( dur_by_slide < 1 )
	{
		dur_by_slide = 1;
		dur_by_trans = 1;
	}
	int i = 0;
	while ( i <= nbre_photos )
	{
		if ( table_photos[i][20].toInt() > 0 )
		{
			table_photos[i][16] = QString::number(dur_by_slide);
			table_photos[i][21] = QString::number(dur_by_trans);
		}
		else
		{
			table_photos[i][16] = QString::number(dur_by_slide);
		}
		i = i + 1;
	}
	spindurtrans->setValue(table_photos[i][current_diapo].toInt());
	spindurdiapo->setValue(dur_by_slide);
	zik_1->position = 0;
	f_calcul_son();
	affichage_diapo();
	this->setEnabled(true);
}

void mainfrm::f_raz()
{
	if ( nbre_photos >= 0 )
	{
		table_photos[current_diapo][10] = "|0>0 0 0 0 0 -3.8|" + QString::number(spindurdiapo_2->value()) + ">0 0 0 0 0 -3.8$";
        	affichage_diapo();
	}
}

void mainfrm::f_copy()
{
	wgcpast = table_photos[current_diapo][10];
	actionColler->setEnabled(true);
	affichage_diapo();
}

void mainfrm::f_paste()
{
	table_photos[current_diapo][10] = wgcpast;
	affichage_diapo();
}

void mainfrm::f_slice(int value)
{
	scroll_timeline->setValue(scroll_timeline->value() + value);
}

void mainfrm::f_chg_tool_a()
{
	pntmygl->tool = 1;
}

void mainfrm::f_chg_tool_b()
{
	pntmygl->tool = 2;
}

void mainfrm::f_chg_tool_c()
{
	pntmygl->tool = 3;
}

void mainfrm::f_chg_tool_d()
{
	pntmygl->tool = 4;
}

void mainfrm::f_chg_tool_e()
{
	pntmygl->tool = 5;
}

void mainfrm::f_chg_tool_f()
{
	pntmygl->tool = 6;
}

void mainfrm::f_opacity(int valeur)
{
	table_photos[current_diapo][15] = QString::number(dial_opacity->value());
	if ( position_flux == 0 )
	{
		pntmygl->sl_opacity(valeur);
	}
}

void mainfrm::f_opacity_slide(int valeur)
{
	table_photos[current_diapo][11] = QString::number(valeur);
	pntmygl->wg_percent_slide = (float)((float)valeur / 100);
	pntmygl->updateGL();
}

void mainfrm::f_opacity_2(int valeur)
{
	table_photos[current_diapo][28] = QString::number(valeur);
	if ( position_flux == 1 )
	{
		pntmygl->sl_opacity(valeur);
	}
}

void mainfrm::f_percent_blending(int valeur)
{
	table_photos[current_diapo][25] = QString::number(valeur);
	pntmygl->wg_percent = (float)((float)valeur / 100);
	if ( position_flux == 0 )
	{
		pntmygl->updateGL();
	}
}

void mainfrm::f_percent_blending_2(int valeur)
{
	table_photos[current_diapo][26] = QString::number(valeur);
	pntmygl->wg_percent = (float)((float)valeur / 100);
	if ( position_flux == 1 )
	{
		pntmygl->updateGL();
	}
}

void mainfrm::f_brouillard(int valeur)
{
	if ( valeur == 0)
	{
		table_photos[current_diapo][14] = "0";
	}
	else
	{
		table_photos[current_diapo][14] = "1";
		pntmygl->change_fog_color();
	}
	pntmygl->sl_brouillard(valeur);
}

void mainfrm::f_backanim(int valeur)
{
	if ( valeur == 0)
	{
		table_photos[current_diapo][8] = "0";
		pntmygl->isbackanim = 0;
	}
	else
	{
		table_photos[current_diapo][8] = "1";
		pntmygl->isbackanim = 1;
	}
	pntmygl->updateGL();
}

void mainfrm::f_change_fond()
{
    	QList<QListWidgetItem *> listsfile = lstfiles->selectedItems();
    	QListWidgetItem *mywidget = new QListWidgetItem;

       	if ( listsfile.empty() == true )
       	{
		qDebug() << "ERROR INSERT BACKGROUND IMAGE";
       	}
       	else
       	{
     		QString myfic;
		mywidget = listsfile.at(0);
		myfic = current_path + "/" + mywidget->toolTip();

		QPixmap wl_pix_1(myfic);
		QPixmap wl_pix_2(size_dia_x,size_dia_y);
		QPixmap wl_pix_3;
		wl_pix_2.fill(Qt::black);

		if ( wl_pix_1.width() > wl_pix_1.height() )
		{
			wl_pix_3 = wl_pix_1.scaledToWidth ( size_dia_x, Qt::FastTransformation );
		}
		else
		{
			wl_pix_3 = wl_pix_1.scaledToHeight ( size_dia_y, Qt::FastTransformation );
		}
		QPainter p;
        	p.begin(&wl_pix_2);
		p.drawPixmap(((size_dia_x - wl_pix_3.width()) / 2), ((size_dia_y - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, -1, -1 );
		p.end();
            	int i = myfic.lastIndexOf( '/' );
            	if ( i != -1 )
            	{
			if (table_photos[current_diapo][13] == "$N$U$L$L")
			{
                		outfilename = myfic.mid(i+1, myfic.length() - (i + 1));
				wl_pix_2.save(wpathprojet + "/" + QString::number(nbre_imports) + "$" + outfilename + ".jpg","JPEG",75);
				//
				table_photos[current_diapo][13] = QString::number(nbre_imports) + "$" + outfilename + ".jpg";
				pntmygl->sl_change_fond(wpathprojet + "/" + QString::number(nbre_imports) + "$" + outfilename + ".jpg");
				pntmygl->updateGL();
				nbre_imports = nbre_imports + 1;
			}
			else
			{
                		outfilename = table_photos[current_diapo][13];
				wl_pix_2.save(wpathprojet + "/" + outfilename,"JPEG",75);
				//
				pntmygl->sl_change_fond(wpathprojet + "/" + outfilename);
				pntmygl->updateGL();
			}
		}
	}
}

void mainfrm::f_fond_couleur_valide()
{
	QPixmap wl_pix_2(size_dia_x,size_dia_y);
	QColor paintcolor(pntwheelback->red,pntwheelback->green,pntwheelback->blue);
	if ( paintcolor.isValid() == true )
	{
		wl_pix_2.fill(paintcolor);
		if (table_photos[current_diapo][13] == "$N$U$L$L")
		{
			outfilename = "fdcolor";
			wl_pix_2.save(wpathprojet + "/" + QString::number(nbre_imports) + "$" + outfilename + ".jpg","JPEG",75);
			//
			table_photos[current_diapo][13] = QString::number(nbre_imports) + "$" + outfilename + ".jpg";
			pntmygl->sl_change_fond(wpathprojet + "/" + QString::number(nbre_imports) + "$" + outfilename + ".jpg");
			pntmygl->updateGL();
			nbre_imports = nbre_imports + 1;
		}
		else
		{
	      		outfilename = table_photos[current_diapo][13];
			wl_pix_2.save(wpathprojet + "/" + outfilename,"JPEG",75);
			//
			pntmygl->sl_change_fond(wpathprojet + "/" + outfilename);
			pntmygl->updateGL();
		}
	}
}

void mainfrm::f_fond_couleur()
{
	if ( pntmygl->path_fond == "$N$U$L$L" )
	{
		pntmygl->path_fond = "";
	}
	pntmygl->sl_fond_color(pntwheelback->red,pntwheelback->green,pntwheelback->blue);
}

void mainfrm::f_empty_diapo()
{
	pnttimeline->wl_pathname = ":/new/prefix2/Interface/Theme/emptydiapo.png";
	pnttimeline->drop_x = (current_diapo+1) * 107;
	insert_photo();
	affichage_diapo();
}

void mainfrm::f_duplicate()
{
	int wl_current_diapo = current_diapo;
	pnttimeline->wl_pathname = wpathprojet + "/" + table_photos[current_diapo][0];
	pnttimeline->drop_x = (current_diapo+1) * 107;
	insert_photo();
	for (int i=1; i<29; i++)
	{
		table_photos[wl_current_diapo+1][i] = table_photos[wl_current_diapo][i];
	}
	current_diapo = wl_current_diapo+1;
	QFile::copy ( wpathprojet + "/_DRAW" + table_photos[wl_current_diapo][0] + ".png", wpathprojet + "/_DRAW" + table_photos[wl_current_diapo+1][0] + ".png" );
	QFile::copy ( wpathprojet + "/TITLE_" + table_photos[wl_current_diapo][0] + ".png", wpathprojet + "/TITLE_" + table_photos[wl_current_diapo+1][0] + ".png" );
	QLabel *mylabel;
	mylabel = table_pnt_img[current_diapo];
	QImage wl_pix_1(wpathprojet + "/" + table_photos[current_diapo][0]);
	QPixmap wl_pix_2(wg_diapositive);
	QImage wl_pix_3;
	if ( wl_pix_1.height() >= wl_pix_1.width() || (float)((float)wl_pix_1.width() / (float)wl_pix_1.height()) < (float)1.32 )
	{
		wl_pix_3 = wl_pix_1.scaledToHeight ( 63, Qt::FastTransformation );
	}
	else
	{
		wl_pix_3 = wl_pix_1.scaledToWidth ( 83, Qt::FastTransformation );
	}
	QPainter p;
	p.begin(&wl_pix_2);
	p.drawImage(7 + ((83 - wl_pix_3.width()) / 2), 7 + ((63 - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, wl_pix_3.width(), wl_pix_3.height() );
	QIcon myicon = lst_transitions->itemIcon(table_photos[current_diapo][20].toInt());
	myicon.paint ( &p, 5, 40, 32, 32, Qt::AlignCenter, QIcon::Normal, QIcon::On );
	if ( table_photos[current_diapo][24] != "" )
	{
		p.drawPixmap(68, 57, wg_comment, 0, 0, -1, -1 );
	}
	p.end();
	mylabel->setPixmap(wl_pix_2);
	//
	affichage_diapo();
}

void mainfrm::f_random()
{
	if ( nbre_photos > 1 )
	{
		this->setDisabled(true);
		int wl_random_value = 0;
		for (int i=0; i <= nbre_photos; i++ )
		{
			wl_random_value = rand()%(nbre_photos);
			if ( i != wl_random_value )
			{
				f_swap_swap(i,wl_random_value);
			}
		}
		affichage_diapo();
		this->setEnabled(true);
	}
}

void mainfrm::f_stop_zik()
{
	// *** CALCUL DUREE ZIK ***
	int j = zik_1->position;
	int lngcoupe = 0;
	while ( j <= current_diapo )
	{
		if ( table_photos[j][20] == "0" )
		{
			lngcoupe = lngcoupe + table_photos[j][16].toInt();
		}
		else
		{
			lngcoupe = lngcoupe + (table_photos[j][16].toInt() - table_photos[j][21].toInt());
		}
		j++;
	}
	zik_1->setText(table_zik[0][0] + " - " + QString::number(lngcoupe) + " " + tr(" secondes"));
	table_zik[0][1] = QString::number(lngcoupe);
	f_calcul_son();
}

void mainfrm::f_sup_zik()
{
	if ( QFile::remove ( wpathprojet + "/" + table_zik[0][0] ) == false )
	{
		qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY ...";
	}
	zik_number = zik_number - 1;
	total_audio = 0;
	zik_1->position = 0;
	pnttimeline->zik_number = zik_number;
	zik_1->hide();
}

void mainfrm::f_add_zik()
{
	if ( zik_number < 1 )
	{
        	QString myfic = QFileDialog::getOpenFileName(
                	this,
                	tr("Ouvrir un fichier"),
                	path_musique_import,
                	"Musiques (*.OGG *.ogg *.WAV *.wav *.mp3 *.MP3)");
        	if ( myfic.isNull() )
        	{
        	}
        	else
        	{
            		int i = myfic.lastIndexOf( '/' );
            		if ( i != -1 )
            		{
                		path_musique_import = myfic.mid(0,i);
            		}
			int tmpvar2 = myfic.lastIndexOf("/");
			QFile::copy ( myfic, wpathprojet + "/" + myfic.mid(tmpvar2 + 1,myfic.length() - (tmpvar2+1)) );
			table_zik[0][0] = myfic.mid(tmpvar2 + 1,myfic.length() - (tmpvar2+1));
			wglob_str_1 = "";
			QString program = "mplayer";
       			QStringList arguments;
       			arguments << "-identify";
       			arguments << "-frames";
       			arguments << "0";
       			arguments << myfic;
       			myprocess_5.start( program, arguments );
		}
	}
	else
	{
		QMessageBox::information(this, "SMILE", tr("le nombre maximum de bandes son est de 1 pour l'instant. Desole ..."));
	}
}

void mainfrm::lecture_console_import_zik()
{
	newData = myprocess_5.readAllStandardOutput();
	QString wl_var_1 = QString::fromLocal8Bit(newData);
	wglob_str_1 = wglob_str_1 + wl_var_1;
}

void mainfrm::end_zik_import(int, QProcess::ExitStatus)
{
	myprocess_5.terminate();
        int i = wglob_str_1.indexOf("ID_LENGTH=", 0);
        if ( i != -1 )
        {
		QString wl_str_1 = "0";

		while ( wglob_str_1.mid(i + 10, 1) != "." )
		{
			wl_str_1 = wl_str_1 + wglob_str_1.mid(i + 10,1);
			i = i + 1;
		}
		int wz1 = wl_str_1.toInt();
		total_audio = wz1;

		zik_1->setText(table_zik[0][0] + " - " + QString::number(wz1) + " " + tr(" secondes"));
		zik_1->show();
		table_zik[0][1] = QString::number(total_audio);
		zik_number = zik_number + 1;
		pnttimeline->zik_number = zik_number;
		f_calcul_son();
        }
}

void mainfrm::f_calcul_son()
{
	int j=0;
	int cumul_diapo = 0;
	total_diapo = 0;
	int duree = table_zik[0][1].toInt();
	zik_1->nbre_diapo = nbre_photos;
	while ( j <= nbre_photos )
	{
		if ( table_photos[j][20] != "0" )
		{
			if ( j > 0 )
			{
				if ( table_photos[j][21].toInt() > table_photos[j-1][16].toInt() )
				{
					if ( table_photos[j-1][16].toInt() - table_photos[j][21].toInt() > 0 ) // -1 =
					{
						//table_photos[j][21] = QString::number(table_photos[j-1][16].toInt() - 1);
					}
					else
					{
						table_photos[j][21] = QString::number(1);
					}
				}
				total_diapo = total_diapo + ( table_photos[j][16].toInt() - table_photos[j][21].toInt());
			}
			else
			{
				total_diapo = total_diapo + table_photos[j][16].toInt();
			}
		}
		else
		{
			total_diapo = total_diapo + table_photos[j][16].toInt();
		}
		j++;
	}
	label_nbrediapo->setText(tr("Duree du diaporama : ") + QString::number(total_diapo) + "s");
	if ( zik_number > 0 )
	{
		j = zik_1->position;
		while ( cumul_diapo < duree && j <= nbre_photos )
		{
			if ( table_photos[j][20] != "0" )
			{
				cumul_diapo = cumul_diapo + ( table_photos[j][16].toInt() - table_photos[j][21].toInt());
			}
			else
			{
				cumul_diapo = cumul_diapo + table_photos[j][16].toInt();
			}
			j ++;
		}
		zik_1->fin = j;
		if ( duree > cumul_diapo )
		{
			zik_1->setGeometry(10+(zik_1->position*107),80,((j + 1) * 107),10);
		}
		else
		{
			zik_1->setGeometry(10+(zik_1->position*107),80,((j-zik_1->position) * 107) - 10,10);
		}
	}
}

void mainfrm::f_apply_effetsup(int state)
{
	if ( must_redraw == 0 )
	{
		if ( state == 7 )
		{
			QString myfic = QFileDialog::getOpenFileName(
				this,
				tr("Importer une image sur vos flocons"),
				path_musique_import,
				"Images (*.PNG *.png)");
			if ( myfic.isNull() )
			{
				return;
			}
			else
			{
				table_photos[current_diapo][5] = myfic;
				pntmygl->effetsup = state;
				table_photos[current_diapo][19] = QString::number(state) + ";" + QString::number(nbre_effet_sup->value()) + ":" + QString::number(size_effet_sup->value()) + "!" + QString::number(speed_effet_sup->value());
				pntmygl->chemin_flocon = myfic;
				pntmygl->loadeffetsup(state);
			}
		}
		else
		{
			pntmygl->effetsup = state;
			table_photos[current_diapo][19] = QString::number(state) + ";" + QString::number(nbre_effet_sup->value()) + ":" + QString::number(size_effet_sup->value()) + "!" + QString::number(speed_effet_sup->value());
			if ( state > 0 )
			{
				pntmygl->loadeffetsup(state);
			}
			else
			{
				pntmygl->updateGL();
			}
		}
	}
	if ( state > 0 )
	{
		nbre_effet_sup->setEnabled(true);
		size_effet_sup->setEnabled(true);
		speed_effet_sup->setEnabled(true);
		check_rotationeffet->setEnabled(true);
	}
	else
	{
		nbre_effet_sup->setDisabled(true);
		size_effet_sup->setDisabled(true);
		speed_effet_sup->setDisabled(true);
		check_rotationeffet->setDisabled(true);
	}
}

void mainfrm::f_checkrotationeffet(int value)
{
	if ( must_redraw == 0 )
	{
		table_photos[current_diapo][18] = QString::number(value);
		pntmygl->rotation_effet = value;
	}
}

void mainfrm::f_effet_nombre(int value)
{
	if ( must_redraw == 0 )
	{
		pntmygl->nombre_effet = value;
		table_photos[current_diapo][19] = QString::number(effetsup->currentIndex()) + ";" + QString::number(nbre_effet_sup->value()) + ":" + QString::number(size_effet_sup->value()) + "!" + QString::number(speed_effet_sup->value());
		pntmygl->updateGL();
	}
}

void mainfrm::f_effet_taille(int value)
{
	if ( must_redraw == 0 )
	{
		pntmygl->size_effet = (float)((float)value/(float)100);
		table_photos[current_diapo][19] = QString::number(effetsup->currentIndex()) + ";" + QString::number(nbre_effet_sup->value()) + ":" + QString::number(size_effet_sup->value()) + "!" + QString::number(speed_effet_sup->value());
		pntmygl->updateGL();
	}
}

void mainfrm::f_effet_speed(int value)
{
	if ( must_redraw == 0 )
	{
		pntmygl->speed_effet = (float)((float)value/(float)100);
		table_photos[current_diapo][19] = QString::number(effetsup->currentIndex()) + ";" + QString::number(nbre_effet_sup->value()) + ":" + QString::number(size_effet_sup->value()) + "!" + QString::number(speed_effet_sup->value());
		pntmygl->updateGL();
	}
}

void mainfrm::f_apply_effets(int state)
{
	if ( state == 0 )
	{
		bt_remove_effet->setDisabled(true);
	}
	else
	{
		bt_remove_effet->setEnabled(true);
	}
	// 
	if ( comboeffets->count() > 0 )
	{
		if (state == 0)
		{
			pntmygl->iseffect = 0;
			table_photos[current_diapo][22] = "0";
			pntmygl->updateGL();
		}
		else
		{
			QString istheblur;
			if  (check_mblur->isChecked() == true)
			{
				istheblur = "1";
			}
			else
			{
				istheblur = "0";
			}
			pntmygl->iseffect = 1;
			table_photos[current_diapo][22] = comboeffets->currentText();
			table_photos[current_diapo][12] = QString::number(slider_size_anim->value()) + ";" + QString::number(pntmygl->posanim_x) + "$" + QString::number(pntmygl->posanim_y) + "@" + QString::number(slider_rot_anim->value()) + "#" + "&" + istheblur;
			pntmygl->sizanim = (float)slider_size_anim->value()/100;
			pntmygl->rotanim = (float)slider_rot_anim->value();
			pntmygl->load_effet(comboeffets->currentText());
			pntmygl->updateGL();
		}
	}
}

void mainfrm::f_screenshot()
{
	QString s = QFileDialog::getSaveFileName(
        	this,
                tr("Nom de l'image enregistree"),
                path_photos_capture,
                "Images (*.jpg)");
        if ( s.isNull() )
        {
        }
        else
	{
            	int i = s.lastIndexOf( '/' );
            	if ( i != -1 )
            	{
                	path_photos_capture = s.mid(0,i);
            	}
		if ( s.mid(s.length() - 4,4) != ".jpg" )
		{
			s = s + ".jpg";
		}
		pntmygl->grabframe(s);
	}
}

void mainfrm::f_cancel_param_import()
{
	lst_transitions_2->setCurrentIndex(tmpint_1);
	spindurdiapo_2->setValue(tmpint_2);
	spindurtrans_2->setValue(tmpint_3);
	menubar->setEnabled(true);
	toolBar->setEnabled(true);
	contain_timeline->setEnabled(true);
	if ( nbre_photos >= 0 )
	{
		tabmenus->setEnabled(true);
		toolsmenu->setEnabled(true);
	}
	frame_parametres->hide();
}

void mainfrm::f_close_param_import()
{
	if ( nbre_photos >= 0 )
	{
		int result = QMessageBox::information(this, "SMILE", tr("Voulez vous appliquer ces nouveaux parametres a l'ensemble des diapositives ?") , tr("Oui"), tr("Non"), 0, 1 );
		if (result == 0)
		{
			int wl_compteur = 0;
			int wl_random_value;
			must_redraw = 0;
			while ( wl_compteur <= nbre_photos )
			{
				current_diapo = wl_compteur;
				if ( lst_transitions_2->currentIndex() == 1 )
				{
					wl_random_value = rand()%(lst_transitions_2->count() - 1);
					if ( wl_random_value <= 2 )
					{
						wl_random_value = 2;
					}
				}
				else
				{
					if ( lst_transitions_2->currentIndex() > 0 )
					{
						wl_random_value = lst_transitions_2->currentIndex() - 1;
					}
					else
					{
						wl_random_value = 0;
					}
				}
				table_photos[wl_compteur][16] = QString::number(spindurdiapo_2->value());
				table_photos[wl_compteur][21] = QString::number(spindurtrans_2->value());
				f_transition_changed(wl_random_value);
				wl_compteur = wl_compteur + 1;
			}
			f_calcul_son();
			affichage_diapo();
		}
	}
	menubar->setEnabled(true);
	toolBar->setEnabled(true);
	contain_timeline->setEnabled(true);
	if ( nbre_photos >= 0 )
	{
		tabmenus->setEnabled(true);
		toolsmenu->setEnabled(true);
	}
	frame_parametres->hide();
}

void mainfrm::f_affiche_parametres()
{
	tmpint_1 = lst_transitions_2->currentIndex();
	tmpint_2 = spindurdiapo_2->value();
	tmpint_3 = spindurtrans_2->value();
	//
	spindurtrans_2->setMaximum(spindurdiapo_2->value()-1);
	//
	menubar->setDisabled(true);
	toolBar->setDisabled(true);
	contain_timeline->setDisabled(true);
	tabmenus->setDisabled(true);
	toolsmenu->setDisabled(true);
	thread_ani->scr_width = this->width();
	thread_ani->scr_height = this->height();
	thread_ani->hdlfra = frame_parametres;
	thread_ani->wlwidth = frame_parametres->width();
	thread_ani->wlheight = frame_parametres->height();
	thread_ani->type_ani = 0;
	thread_ani->y = (frame_parametres->height()*-1)+(menubar->height() + toolBar->height());
	frame_parametres->setGeometry((this->width() - frame_parametres->width())/2,frame_parametres->height()*-1,frame_parametres->width(),frame_parametres->height());
	frame_parametres->show();
	frame_parametres->raise();
	QTimer::singleShot(10, this, SLOT(f_startani()));
}

void mainfrm::f_changedur(int valeur)
{
	if ( nbre_photos >= 0 )
	{
		/*int sch = table_photos[current_diapo][10].lastIndexOf( "|" + QString::number(table_photos[current_diapo][16].toInt()) );
		if ( sch > 0 )
		{
			int sch = table_photos[current_diapo][10].lastIndexOf( "|" + QString::number(table_photos[current_diapo][16].toInt()-1) );
			if ( sch < 0 )
			{
				int j = table_photos[current_diapo][16].toInt() * 25;
			       	pntmygl->rotationX = pntstamp->table_coo[j][0];
			       	pntmygl->rotationY = pntstamp->table_coo[j][1];
			       	pntmygl->rotationZ = pntstamp->table_coo[j][2];
			       	pntmygl->deplacementX = pntstamp->table_coo[j][3];
			       	pntmygl->deplacementY = pntstamp->table_coo[j][4];
			       	pntmygl->zoom = pntstamp->table_coo[j][5];

				f_mark_timeline((table_photos[current_diapo][16].toInt()*25));
			}
		}*/

		if ( current_diapo > 0 )
		{
			int wl_valcalc = valeur;
			if ( table_photos[current_diapo-1][20].toInt() > 0 )
			{
				if ( wl_valcalc - table_photos[current_diapo-1][21].toInt() >= 0 )
				{
					wl_valcalc = wl_valcalc - table_photos[current_diapo-1][21].toInt();
				}
				else
				{
					wl_valcalc = 0;
;				}
			}

			if ( current_diapo < nbre_photos )
			{
				if ( table_photos[current_diapo+1][20].toInt() >= 0 )
				{
					wl_valcalc = wl_valcalc - table_photos[current_diapo+1][21].toInt();
				}
				else
				{
					wl_valcalc = 0;
;				}
			}

			spindurtrans->setMaximum(wl_valcalc);
		}
		else
		{
			int wl_valcalc = valeur;

			if ( current_diapo < nbre_photos )
			{
				if ( table_photos[current_diapo+1][20].toInt() >= 0 )
				{
					wl_valcalc = wl_valcalc - table_photos[current_diapo+1][21].toInt();
				}
				else
				{
					wl_valcalc = 0;
;				}
			}
			spindurtrans->setMaximum(wl_valcalc);
		}

		int wl_valeur = valeur;

                if ( table_photos[current_diapo][16].toInt() < valeur )
                {
                        int k = table_photos[current_diapo][16].toInt();
                        while ( pntstamp->table_markpos[k] == 0 && k > 0 )
                        {
                                k--;
                        }

                        if ( k > 0 )
                        {
                            pntstamp->table_markpos[valeur] = 1;
                            pntstamp->table_coo[(valeur*25)-1][0] = pntstamp->table_coo[(k*25)-1][0];
                            pntstamp->table_coo[(valeur*25)-1][1] = pntstamp->table_coo[(k*25)-1][1];
                            pntstamp->table_coo[(valeur*25)-1][2] = pntstamp->table_coo[(k*25)-1][2];
                            pntstamp->table_coo[(valeur*25)-1][3] = pntstamp->table_coo[(k*25)-1][3];
                            pntstamp->table_coo[(valeur*25)-1][4] = pntstamp->table_coo[(k*25)-1][4];
                            pntstamp->table_coo[(valeur*25)-1][5] = pntstamp->table_coo[(k*25)-1][5];
                            pntstamp->table_markpos[k] = 0;
                        }
                        else
                        {
                            pntstamp->table_markpos[valeur] = 1;
                            pntstamp->table_coo[(valeur*25)-1][0] = pntstamp->table_coo[0][0];
                            pntstamp->table_coo[(valeur*25)-1][1] = pntstamp->table_coo[0][1];
                            pntstamp->table_coo[(valeur*25)-1][2] = pntstamp->table_coo[0][2];
                            pntstamp->table_coo[(valeur*25)-1][3] = pntstamp->table_coo[0][3];
                            pntstamp->table_coo[(valeur*25)-1][4] = pntstamp->table_coo[0][4];
                            pntstamp->table_coo[(valeur*25)-1][5] = pntstamp->table_coo[0][5];
                        }
                }
                else
                {
                    if ( table_photos[current_diapo][16].toInt() > valeur )
                    {
                        int k = table_photos[current_diapo][16].toInt()-1;
                        if ( pntstamp->table_markpos[k] == 0 )
                        {
                            pntstamp->table_markpos[valeur] = 1;
                            pntstamp->table_coo[(valeur-1)*25][0] = pntstamp->table_coo[k*25][0];
                            pntstamp->table_coo[(valeur-1)*25][1] = pntstamp->table_coo[k*25][1];
                            pntstamp->table_coo[(valeur-1)*25][2] = pntstamp->table_coo[k*25][2];
                            pntstamp->table_coo[(valeur-1)*25][3] = pntstamp->table_coo[k*25][3];
                            pntstamp->table_coo[(valeur-1)*25][4] = pntstamp->table_coo[k*25][4];
                            pntstamp->table_coo[(valeur-1)*25][5] = pntstamp->table_coo[k*25][5];
                        }
                    }
                }

		table_photos[current_diapo][16] = QString::number(wl_valeur);
		pntmygl->wg_duree = valeur;
		if ( current_diapo < nbre_photos && table_photos[current_diapo+1][21].toInt() > valeur)
		{
			table_photos[current_diapo+1][21] = QString::number(valeur);
		}

		f_calcul_son();
		pntstamp->duree_diapo = pntmygl->wg_duree;
		pntstamp->repaint();

		//
		int i = 0;
		QString wl_stamp = "";
		while ( i <= table_photos[current_diapo][16].toInt() )
		{
			if ( pntstamp->table_markpos[i] == 1 )
			{
				if ( i == 0 )
				{
					wl_stamp = "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[0][0]) + " " + QString::number(pntstamp->table_coo[0][1]) + " " + QString::number(pntstamp->table_coo[0][2]) + " " + QString::number(pntstamp->table_coo[0][3]) + " " + QString::number(pntstamp->table_coo[0][4]) + " " + QString::number(pntstamp->table_coo[0][5]);

				}
				else
				{
					wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[(i*25)-1][0]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][1]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][2]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][3]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][4]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][5]);
				}
			}
			i++;
		}
		if ( wl_stamp != "" )
		{
			wl_stamp = wl_stamp + "$";
		}
		table_photos[current_diapo][10] = wl_stamp;

		f_calcul_coo();
		//
	}
	else
	{
		pntmygl->wg_duree = 1;
		spindurdiapo->setValue(1);
	}
}


void mainfrm::supp_diapo()
{
	must_redraw = 0;
	// *** Recherche la presence d'autres occurences ***
	int wl_cpt_001 = 0;
	while ( wl_cpt_001 <= nbre_photos )
	{
		if ( table_photos[wl_cpt_001][0] == table_photos[current_diapo][0] && wl_cpt_001 != current_diapo )
		{
			wl_cpt_001 = 999;
		}
		wl_cpt_001 = wl_cpt_001 + 1;
	}
	if ( wl_cpt_001 < 999 )
	{
		if ( zik_1->position >= current_diapo && zik_1->position > 0 )
		{
			zik_1->position--;
		}
		if ( QFile::remove ( wpathprojet + "/" + table_photos[current_diapo][0] ) == false )
		{
			qDebug() << "ERROR REMOVING FILE FROM TMP DIRECTORY ...";
		}
		if ( QFile::remove ( wpathprojet + "/TITLE_" + table_photos[current_diapo][0] + ".png" ) == false )
		{
		}
		if ( QFile::remove ( wpathprojet + "/_DRAW" + table_photos[current_diapo][0] + ".png" ) == false )
		{
		}
	}

	if ( current_diapo == nbre_photos && wl_cpt_001 < 999 )
	{
		if ( nbre_photos > 0 )
		{
			delete table_pnt_img[current_diapo];
			nbre_photos = nbre_photos - 1;
			current_diapo = current_diapo - 1;
			affichage_diapo();
		}
		else
		{
			if ( nbre_photos == 0 )
			{
				delete table_pnt_img[current_diapo];
				current_diapo = current_diapo - 1;
				nbre_photos = nbre_photos - 1;
				QPixmap nullpix(791,571);
				QColor wlmycolor(0,0,0);
				nullpix.fill(wlmycolor);
				//
				actionDeplacement->setEnabled(false);
				actionDupliquer_la_diapositive_actuelle->setEnabled(false);
				actionZoom->setEnabled(false);
				actionRotation_X->setEnabled(false);
				actionRotation_Y->setEnabled(false);
				actionRotation_Z->setEnabled(false);
				actionRotation_libre->setEnabled(false);
				actionReinitialiser->setEnabled(false);
				actionMarquer_depart->setEnabled(false);
				actionMarquer_fin->setEnabled(false);

				actionEditer_diapositive->setEnabled(false);
				actionSupprimer_diapositive->setEnabled(false);
				actionCopier->setEnabled(false);
				actionColler->setEnabled(false);
				actionPrendre_photo->setEnabled(false);
				actionDeplacer_gauche->setEnabled(false);
				actionDeplacer_droite->setEnabled(false);
				actionRender->setEnabled(false);
				actionEnregistrer->setEnabled(true);
				actionEnregistrer_sous->setEnabled(true);
				top_timeline->setDisabled(true);

				zik_1->hide();
				tabmenus->setDisabled(true);
				toolsmenu->setDisabled(true);
				pnttimeline->zik_number = 0;
				table_zik[0][1] = QString::number(0);
				zik_number = 0;

				img_selection->hide();
				pntmygl->iseffect = 0;
				pnttimeline->max_diapo = -1;
				pntmygl->max_diapo = -1;
				pntmygl->bcle_render = 1;
				pntmygl->effetsup = 0;
				//
				pntmygl->sl_charge_image("$N$U$L$L","$N$U$L$L","$N$U$L$L");
				pntmygl->updateGL();
				//param_encoding->hide();
			}
		}
	}
	else
	{
		delete table_pnt_img[current_diapo];
		QLabel *mylabel;
		QPoint mypoint;
		int i = current_diapo;
		int j = nbre_photos;
		while (i < j)
		{
			table_photos[i][0] = table_photos[i+1][0];
			table_photos[i][1] = table_photos[i+1][1];
			table_photos[i][2] = table_photos[i+1][2];
			table_photos[i][3] = table_photos[i+1][3];
			table_photos[i][4] = table_photos[i+1][4];
			table_photos[i][5] = table_photos[i+1][5];
			table_photos[i][6] = table_photos[i+1][6];
			table_photos[i][7] = table_photos[i+1][7];
			table_photos[i][8] = table_photos[i+1][8];
			table_photos[i][9] = table_photos[i+1][9];
			table_photos[i][10] = table_photos[i+1][10];
			table_photos[i][11] = table_photos[i+1][11];
			table_photos[i][12] = table_photos[i+1][12];
			table_photos[i][13] = table_photos[i+1][13];
			table_photos[i][14] = table_photos[i+1][14];
			table_photos[i][15] = table_photos[i+1][15];
			table_photos[i][16] = table_photos[i+1][16];
			table_photos[i][17] = table_photos[i+1][17];
			table_photos[i][18] = table_photos[i+1][18];
			table_photos[i][19] = table_photos[i+1][19];
			table_photos[i][20] = table_photos[i+1][20];
			table_photos[i][21] = table_photos[i+1][21];
			table_photos[i][22] = table_photos[i+1][22];
			table_photos[i][23] = table_photos[i+1][23];
			table_photos[i][24] = table_photos[i+1][24];
			table_pnt_img[i] = table_pnt_img[i+1];
			mylabel = table_pnt_img[i];
			mypoint = mylabel->pos();
			mylabel->setGeometry( mypoint.x() - 107, 0 , 97, 77);
			i = i + 1;
		}
		if ( current_diapo > 0 )
		{
			if ( current_diapo > nbre_photos )
			{
				current_diapo = current_diapo - 1;
			}
		}
		nbre_photos = nbre_photos - 1;
		affichage_diapo();
	}
	f_calcul_son();
	label_nbrediapo->setText(tr("Duree du diaporama : ") + QString::number(total_diapo) + "s");
	label_curdiapo->setText(tr("Diapositive actuelle : ") + QString::number(current_diapo + 1));
	if ( ((nbre_photos + 1) * 110) - support_timeline->width() > 0 )
	{
		scroll_timeline->setMaximum(((nbre_photos + 1) * 110) - support_timeline->width());
	}
	else
	{
		scroll_timeline->hide();
		scroll_timeline->setMaximum(0);
	}
}

void mainfrm::md_start()
{
	if ( nbre_photos >= 0 )
	{
		pntstamp->table_coo[0][0] = pntmygl->rotationX;
		pntstamp->table_coo[0][1] = pntmygl->rotationY;
		pntstamp->table_coo[0][2] = pntmygl->rotationZ;
		pntstamp->table_coo[0][3] = pntmygl->deplacementX;
		pntstamp->table_coo[0][4] = pntmygl->deplacementY;
		pntstamp->table_coo[0][5] = pntmygl->zoom;
		pntstamp->table_markpos[0] = 1;
		pntstamp->repaint();
		//
		int i = 0;
		QString wl_stamp = "";
		while ( i <= table_photos[current_diapo][16].toInt() )
		{
			if ( pntstamp->table_markpos[i] == 1 )
			{
				if ( i == 0 )
				{
					wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[0][0]) + " " + QString::number(pntstamp->table_coo[0][1]) + " " + QString::number(pntstamp->table_coo[0][2]) + " " + QString::number(pntstamp->table_coo[0][3]) + " " + QString::number(pntstamp->table_coo[0][4]) + " " + QString::number(pntstamp->table_coo[0][5]);

				}
				else
				{
					wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[(i*25)-1][0]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][1]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][2]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][3]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][4]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][5]);
				}
			}
			i++;
		}
		if ( wl_stamp != "" )
		{
			wl_stamp = wl_stamp + "$";
		}
		table_photos[current_diapo][10] = wl_stamp;
		//
		pntmygl->sl_mark_deb();
		f_calcul_coo();
	}
}

void mainfrm::md_fin()
{
	if ( nbre_photos >= 0 )
	{
		pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][0] = pntmygl->rotationX;
		pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][1] = pntmygl->rotationY;
		pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][2] = pntmygl->rotationZ;
		pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][3] = pntmygl->deplacementX;
		pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][4] = pntmygl->deplacementY;
		pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][5] = pntmygl->zoom;
		pntstamp->table_markpos[table_photos[current_diapo][16].toInt()] = 1;
		pntstamp->repaint();
		//
		int i = 0;
		QString wl_stamp = "";
		while ( i <= table_photos[current_diapo][16].toInt() )
		{
			if ( pntstamp->table_markpos[i] == 1 )
			{
				if ( i == 0 )
				{
					wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[0][0]) + " " + QString::number(pntstamp->table_coo[0][1]) + " " + QString::number(pntstamp->table_coo[0][2]) + " " + QString::number(pntstamp->table_coo[0][3]) + " " + QString::number(pntstamp->table_coo[0][4]) + " " + QString::number(pntstamp->table_coo[0][5]);

				}
				else
				{
					wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[(i*25)-1][0]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][1]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][2]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][3]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][4]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][5]);
				}
			}
			i++;
		}
		if ( wl_stamp != "" )
		{
			wl_stamp = wl_stamp + "$";
		}
		table_photos[current_diapo][10] = wl_stamp;
		//
		pntmygl->sl_mark_fin();
		f_calcul_coo();
	}
}

void mainfrm::insert_photo()
{
	if (  pnttimeline->wl_pathname.mid(0,13) == "$$DRAGINTO$$$" )
	{
		result_position = (int)(pnttimeline->drop_x / 107);
		if ( result_position < current_diapo )
		{
			int posbcl = current_diapo-1;
			int wl_cpt_001 = 0;
			QLabel *mylabel;
			QString tmp_tab[1][nbre_occurs];
			QLabel *tmppnt;
			QColor tmpcolor[2];
			// *** Sauvegarde diapo déplacée ***
			tmppnt = table_pnt_img[current_diapo];

			while ( wl_cpt_001 < nbre_occurs )
			{
				tmp_tab[0][wl_cpt_001] = table_photos[current_diapo][wl_cpt_001];
				++wl_cpt_001;
			}
			tmpcolor[0] = table_color_fog[current_diapo];

			//
			while ( posbcl >= result_position )
			{
				wl_cpt_001 = 0;
				while ( wl_cpt_001 < nbre_occurs )
				{
			        	table_photos[posbcl+1][wl_cpt_001] = table_photos[posbcl][wl_cpt_001];
					++wl_cpt_001;
				}
				table_color_fog[posbcl+1] = table_color_fog[posbcl];
				//pntmygl->table_color[posbcl+1] = pntmygl->table_color[posbcl];
			        table_pnt_img[posbcl+1] = table_pnt_img[posbcl];
				mylabel =  table_pnt_img[posbcl+1];
			        mylabel->setGeometry( ((posbcl+1) * 97) + ((posbcl + 2) * 10), 0 , 97, 77);
				posbcl--;
			}

			// *** Restore diapo déplacée ***
			table_pnt_img[result_position] = tmppnt;
			wl_cpt_001 = 0;
			while ( wl_cpt_001 < nbre_occurs )
			{
				table_photos[result_position][wl_cpt_001] = tmp_tab[0][wl_cpt_001];
				++wl_cpt_001;
			}
			table_color_fog[result_position] = tmpcolor[0];
			mylabel =  table_pnt_img[result_position];
		        mylabel->setGeometry( ((result_position * 97) + ((result_position+1) * 10)), 0 , 97, 77);
			current_diapo = result_position; //-1
			img_selection->setGeometry( ((current_diapo * 97) + ((current_diapo+1) * 10))-5, 0, 30, 30);
			label_curdiapo->setText(tr("Diapositive actuelle : ") + QString::number(current_diapo + 1));
		}
		else
		{
			if ( result_position > current_diapo )
			{
				if ( result_position > nbre_photos + 1 )
				{
					result_position = nbre_photos+1;
				}
				int posbcl = current_diapo;
				int wl_cpt_001 = 0;
       				QLabel *mylabel;
				QString tmp_tab[1][nbre_occurs];
				QLabel *tmppnt;
				QColor tmpcolor[2];
				// *** Sauvegarde diapo déplacée ***
       				tmppnt = table_pnt_img[current_diapo];

				while ( wl_cpt_001 < nbre_occurs )
				{
					tmp_tab[0][wl_cpt_001] = table_photos[current_diapo][wl_cpt_001];
					++wl_cpt_001;
				}
				tmpcolor[0] = table_color_fog[current_diapo];

				//
				while ( posbcl < result_position - 1 )
				{
					wl_cpt_001 = 0;
					while ( wl_cpt_001 < nbre_occurs )
					{
						table_photos[posbcl][wl_cpt_001] = table_photos[posbcl+1][wl_cpt_001];
						++wl_cpt_001;
					}
					table_color_fog[posbcl] = table_color_fog[posbcl+1];
					table_pnt_img[posbcl] = table_pnt_img[posbcl+1];
					mylabel =  table_pnt_img[posbcl];
					mylabel->setGeometry( (posbcl * 97) + ((posbcl + 1) * 10), 0 , 97, 77);
					posbcl++;
				}

				// *** Restore diapo déplacée ***
       				table_pnt_img[result_position-1] = tmppnt;
				wl_cpt_001 = 0;
				while ( wl_cpt_001 < nbre_occurs )
				{
					table_photos[result_position-1][wl_cpt_001] = tmp_tab[0][wl_cpt_001];
					++wl_cpt_001;
				}
				table_color_fog[result_position-1] = tmpcolor[0];
				mylabel =  table_pnt_img[result_position-1];
				mylabel->setGeometry( (((result_position-1)* 97) + (result_position * 10)), 0 , 97, 77);
				current_diapo = result_position-1;
				img_selection->setGeometry( ((current_diapo * 97) + ((current_diapo+1) * 10))-5, 0, 30, 30);
				label_curdiapo->setText(tr("Diapositive actuelle : ") + QString::number(current_diapo + 1));
			}
		}
	}
	else
	{
		nbre_new = 0;
		int wl_oldcurrent = current_diapo;
		if ( wl_oldcurrent < 0 )
		{
			wl_oldcurrent = 0;
		}
		if ( nbre_photos < 399 )
		{
			int wl_random_value;
			int i;
			int posbcl=0;
			QImage wl_pix_1;
			QPixmap wl_pix_2(97,77);
			QImage wl_pix_3;
			QImage wl_pix_4;
			QPainter p;
			QIcon myicon;

			if ( pnttimeline->wl_pathname.mid(0,7) == "file://" )
			{
				wg_tmp_002 = pnttimeline->wl_pathname.mid(7,pnttimeline->wl_pathname.length() - 7);
				wg_tmp_002 = wg_tmp_002.trimmed();
			}
			else
			{
				wg_tmp_002 = pnttimeline->wl_pathname;
			}

			if ( pnttimeline->drop_x < (((nbre_photos+1) * 97) + (nbre_photos * 10) ))
			{
				must_swap = 1;
				result_position = (int)(pnttimeline->drop_x / 107);
				if ( result_position > nbre_photos )
				{
					result_position = nbre_photos;
				}
				posbcl =  nbre_photos;
				int wl_cpt_001 = 0;
			        QLabel *mylabel;
	
				while ( posbcl >= result_position )
				{
					wl_cpt_001 = 0;
					while ( wl_cpt_001 < nbre_occurs )
					{
				        	table_photos[posbcl + 1][wl_cpt_001] = table_photos[posbcl][wl_cpt_001];
						++wl_cpt_001;
					}
					table_color_fog[posbcl + 1] = table_color_fog[posbcl];
				        table_pnt_img[posbcl + 1] = table_pnt_img[posbcl];
					mylabel =  table_pnt_img[posbcl + 1];
				        mylabel->setGeometry( ((((posbcl+1) * 97)) + ((posbcl+2) * 10)), 0 , 97, 77);
					posbcl--;
				}
			}
			else
			{
				must_swap = 0;
			}
			if ( wl_pix_1.load(wg_tmp_002) == true )
			{
				// *** Creation de la miniature pour la timeline ***
				wl_pix_2 = wg_diapositive;
				i = wg_tmp_002.lastIndexOf( '/' );
    	  			wg_tmp_003 = wg_tmp_002.mid(i + 1, wg_tmp_002.length() - (i + 1));
				if ( wg_tmp_002.right(4) != ".gif" )
				{
					if ( wl_pix_1.height() >= wl_pix_1.width() )
					{
						if (  wl_pix_1.height() > 1023 )
						{
							wl_pix_4 = wl_pix_1.scaledToHeight ( 1023, Qt::SmoothTransformation ); 
							wl_pix_4.save(wpathprojet + "/" + QString::number(nbre_imports) + "$" + wg_tmp_003 + ".png","PNG",85);

						}
						else
						{
							wl_pix_1.save(wpathprojet + "/" + QString::number(nbre_imports) + "$" + wg_tmp_003 + ".png","PNG",85);
						}
					}
					else
					{
						if (  wl_pix_1.width() > 1023 )
						{
							wl_pix_4 = wl_pix_1.scaledToWidth ( 1023, Qt::SmoothTransformation ); 
							wl_pix_4.save(wpathprojet + "/" + QString::number(nbre_imports) + "$" + wg_tmp_003 + ".png","PNG",85);
						}
						else
						{
							wl_pix_1.save(wpathprojet + "/" + QString::number(nbre_imports) + "$" + wg_tmp_003 + ".png","PNG",85);
						}
					}
				}
				if ( wl_pix_1.height() >= wl_pix_1.width() || (float)((float)wl_pix_1.width() / (float)wl_pix_1.height()) < (float)1.32)
				{
					wl_pix_3 = wl_pix_1.scaledToHeight ( 63, Qt::FastTransformation );
				}
				else
				{
					wl_pix_3 = wl_pix_1.scaledToWidth ( 83, Qt::FastTransformation );
				}
				// *** SELECTION DE LA TRANSITION ***
				if ( lst_transitions_2->currentIndex() == 1 )
				{
					wl_random_value = rand()%(lst_transitions_2->count() - 1);
				}
				else
				{
					if ( lst_transitions_2->currentIndex() == 0 )
					{
						wl_random_value = 0;
					}
					else
					{
						wl_random_value = lst_transitions_2->currentIndex() - 1;
					}
				}
				p.begin(&wl_pix_2);
				p.drawImage(7 + ((83 - wl_pix_3.width()) / 2), 7 + ((63 - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, wl_pix_3.width(), wl_pix_3.height());
				if ( wl_random_value > 0 )
				{
					QIcon myicon = lst_transitions->itemIcon(wl_random_value);
					myicon.paint ( &p, 5, 40, 32, 32, Qt::AlignCenter, QIcon::Normal, QIcon::On );
				}
				p.end();
				//
				nbre_new++;
				nbre_photos++;
				if ( must_swap == 1 )
				{
					posbcl = nbre_photos;
					nbre_photos = result_position;
				}
			
				if ( wg_tmp_003.right(4) != ".gif" )
				{
					table_photos[nbre_photos][0] = QString::number(nbre_imports) + "$" + wg_tmp_003 + ".png";
				}
				else
				{
					table_photos[nbre_photos][0] = wg_tmp_003;
				}
				table_photos[nbre_photos][1] = ""; // *** TODO VERIFIER DISPO ***
				table_photos[nbre_photos][2] = ""; // *** TODO VERIFIER DISPO ***
				table_photos[nbre_photos][3] = "0"; // *** ALIGNEMENT DE LA LEGENDE ***
				table_photos[nbre_photos][4] = "100A100Z100E100"; // *** ANIMATION DE LA LEGENDE ***
				table_photos[nbre_photos][5] = ""; // *** CHEMIN VERS LE FICHIER IMAGE DES FLOCONS ***
				table_photos[nbre_photos][6] = "0"; // *** TRANSITION INVERSEE ***
				table_photos[nbre_photos][7] = "100"; // *** TAILLE DE LA DIAPO (SCALE FACTOR) ***
				table_photos[nbre_photos][8] = "0"; // *** ANIMATION EN ARRIERE PLAN ***
				table_photos[nbre_photos][9] = "0"; // *** COUCHE DE DESSIN ***
				table_photos[nbre_photos][10] = "|0>0 0 0 0 0 -3.8|" + QString::number(spindurdiapo_2->value()) + ">0 0 0 0 0 -3.8$"; // *** KEYFRAMES ***
				table_photos[nbre_photos][11] = "100"; // *** OPACITE DE LA DIAPO ***
				table_photos[nbre_photos][12] = ""; // *** PARAMETRES DE L'ANIMATION ***
				table_photos[nbre_photos][13] = "$N$U$L$L";
				table_photos[nbre_photos][14] = "0"; // *** BROUILLARD ***
				table_photos[nbre_photos][15] = "30";
				table_photos[nbre_photos][16] = QString::number(spindurdiapo_2->value()); // *** DUREE DE LA DIAPO ***
				table_photos[nbre_photos][17] = ""; // *** LEGENDE DIAPO ***
				table_photos[nbre_photos][18] = "0"; // *** ROTATION PARTICULES ***
				table_photos[nbre_photos][19] = "0;600:10!10"; // *** EFFETS SUPPLEMENTAIRES ***
				table_photos[nbre_photos][20] = QString::number(wl_random_value); // *** TRANSITION ***
				table_photos[nbre_photos][21] = QString::number(spindurtrans_2->value()); // *** DUREE TRANSITION ***
				table_photos[nbre_photos][22] = "0"; // *** NOM DE L'ANIMATION SUPPERPOSEE ***
				table_photos[nbre_photos][23] = "00" + table_photos[nbre_photos][16]; // *** EFFET FONDU TITRE ***
				table_photos[nbre_photos][24] = ""; // *** COMMENTAIRE AUDIO ***
				table_photos[nbre_photos][25] = "100";
				table_photos[nbre_photos][26] = "100";
				table_photos[nbre_photos][27] = "0";
				table_photos[nbre_photos][28] = "30";
				table_color_fog[nbre_photos] = QColor(128,128,128);
				//
				diapo *mylabel = new diapo(pnttimeline);
				mylabel->installEventFilter(this);
				mylabel->setGeometry( ((nbre_photos * 97) + ((nbre_photos + 1) * 10)), 0, 97, 77);
				int k = table_photos[nbre_photos][0].indexOf( '$' );
				mylabel->setToolTip(table_photos[nbre_photos][0].mid(k + 1, table_photos[nbre_photos][0].length() - (k + 1)));
				mylabel->setPixmap ( wl_pix_2 );
				mylabel->show();
				table_pnt_img[nbre_photos] = mylabel;
				nbre_imports++;
				//
				if ( must_swap == 1 )
				{
					nbre_photos = posbcl;
				}
			}
			else
			{
				QMessageBox::information(this, "SMILE", tr("Echec du chargement de l'image : ") + wg_tmp_002);
			}
		}
		else
		{
			QMessageBox::information(this, "SMILE", tr("Le nombre maximum de diapos est de 400. Desole ..."));
		}
		if ( pnttimeline->typeimport == 1 )
		{
			pb_import->setValue(pnttimeline->wl_importation);
		}
		//
		if ( nbre_new > 0 )
		{
			current_diapo = wl_oldcurrent;
			pnttimeline->max_diapo = nbre_photos;
			pntmygl->max_diapo = nbre_photos;
			if ( ((nbre_photos + 1) * 110) - support_timeline->width() > 0 )
			{
				scroll_timeline->setMaximum(((nbre_photos + 1) * 110) - support_timeline->width());
				scroll_timeline->show();
			}
			if ( frame_bibliotheque->isVisible() == false )
			{
				tabmenus->setEnabled(true);
				toolsmenu->setEnabled(true);
				actionDeplacement->setEnabled(true);
				actionDupliquer_la_diapositive_actuelle->setEnabled(true);
				actionZoom->setEnabled(true);
				actionRotation_X->setEnabled(true);
				actionRotation_Y->setEnabled(true);
				actionRotation_Z->setEnabled(true);
				actionRotation_libre->setEnabled(true);
				actionReinitialiser->setEnabled(true);
				actionMarquer_depart->setEnabled(true);
				actionMarquer_fin->setEnabled(true);
				actionEditer_diapositive->setEnabled(true);
				actionSupprimer_diapositive->setEnabled(true);
				actionCopier->setEnabled(true);
				actionColler->setEnabled(true);
				actionPrendre_photo->setEnabled(true);
				actionDeplacer_gauche->setEnabled(true);
				actionDeplacer_droite->setEnabled(true);
				actionRender->setEnabled(true);
				actionEnregistrer->setEnabled(true);
				actionEnregistrer_sous->setEnabled(true);
				top_timeline->setEnabled(true);
				//
				affichage_diapo();
			}
			f_calcul_son();
			//label_nbrediapo->setText(tr("Duree du diaporama : ") + QString::number(total_diapo) + "s");
			//lstfiles->clearSelection();
		}
	}
}

void mainfrm::f_scroll_timeline(int valeur)
{
	if (valeur >= 0)
	{
		pnttimeline->setGeometry(0-valeur,0,50000,91);
		pnttimeline->postimeline = valeur;
	}
}

void mainfrm::keyPressEvent( QKeyEvent *k )
{
// *** Gestion du clavier *** 
    	if ( k->key() == Qt::Key_Escape)
    	{
    	}
	if ( nbre_photos >= 0 && tabmenus->currentIndex() == 0 )
	{
	    	if ( k->key() == Qt::Key_Delete)
	    	{
			supp_diapo();
	    	}
	}
	if ( nbre_photos >= 0 )
	{
		if ( k->key() == Qt::Key_Left )
		{
			if ( current_diapo-1 >= 0 )
			{
				must_redraw = 0;
				current_diapo--;
				if ( ((current_diapo*107) - pnttimeline->postimeline) <= 0 )
				{
					scroll_timeline->setValue(scroll_timeline->value() - 107);
				} 
               			affichage_diapo();
			}
		}
		if ( k->key() == Qt::Key_Right )
		{
			if ( current_diapo+1 <= nbre_photos )
			{
				must_redraw = 0;
				current_diapo++;
				if ( ((current_diapo*107) - pnttimeline->postimeline) > (pnttimeline->lengthtimeline - 100) )
				{
					scroll_timeline->setValue(scroll_timeline->value() + 107);
				}  
               			affichage_diapo();
			}
		}	
	}
}

bool mainfrm::eventFilter(QObject *o, QEvent *e)
{
// *** Filtrage des events ***
    	if ( contain_timeline->isEnabled() == true )
    	{
        	if (e->type() == QEvent::MouseButtonPress )
        	{
            		int i = 0;
            		while (table_pnt_img[i] != o && i < 399)
            		{
                		i = i + 1;
            		}
            		if (table_pnt_img[i] == o)
            		{
				must_redraw = 0;
				current_diapo = i;
                		affichage_diapo();
            		}
        	}
	}
	return QMainWindow::eventFilter(o,e);
}

void mainfrm::affichage_diapo()
{
	if ( old_tab == 2 )
	{
		//frame_widget_txt->hide();
		if ( pntlabeltxt->current_text != "" )
		{
			//QPixmap wlpix1(size_dia_x,size_dia_y);
			QFontMetrics fm(pntlabeltxt->myfont);
			QPixmap wlpix1(size_dia_x*2,(pntlabeltxt->current_text.count(QRegExp("\n")) + 1) * (fm.height()+pntlabeltxt->leading));
			wlpix1.fill(QColor(255,255,255,0));
			//
			if ( startx_legani == 0 && starty_legani == 0 && endx_legani == 0 && endy_legani == 0 )
			{
				startx_legani = pntlabeltxt->textx;
				starty_legani = pntlabeltxt->texty;
				endx_legani = pntlabeltxt->textx;
				endy_legani = pntlabeltxt->texty;
			}
			//
			QPainter p;
			p.begin(&wlpix1);
			p.setRenderHint(QPainter::Antialiasing,true);
			p.setPen (pntlabeltxt->mycolor);
			p.setFont(pntlabeltxt->myfont);
			p.fillRect ( 0, pntlabeltxt->texty, size_dia_x, (pntlabeltxt->current_text.count(QRegExp("\n")) + 1) * (fm.height()+pntlabeltxt->leading), QBrush( QColor(pntlabeltxt->backcolor.red(),pntlabeltxt->backcolor.green(),pntlabeltxt->backcolor.blue(),pntlabeltxt->opacity), Qt::SolidPattern ) );
			//p.drawText ( QRect(pntlabeltxt->textx,pntlabeltxt->texty,size_dia_x,size_dia_y), (Qt::AlignLeft | Qt::AlignTop),pntlabeltxt->current_text );
			if ( pntlabeltxt->alignement == 0 )
			{
				p.drawText ( QRect(size_dia_x,0,pntlabeltxt->myrect.width(),size_dia_y), (Qt::AlignLeft | Qt::AlignTop | Qt::TextExpandTabs),pntlabeltxt->current_text );
			}
			else
			{
				if ( pntlabeltxt->alignement == 1 )
				{
					p.drawText ( QRect(size_dia_x,0,pntlabeltxt->myrect.width(),size_dia_y), (Qt::AlignHCenter | Qt::AlignTop | Qt::TextExpandTabs),pntlabeltxt->current_text );
				}
				else
				{
					if ( pntlabeltxt->alignement == 2 )
					{
						p.drawText ( QRect(size_dia_x,0,pntlabeltxt->myrect.width(),size_dia_y), (Qt::AlignJustify | Qt::AlignTop | Qt::TextExpandTabs),pntlabeltxt->current_text );
					}
					else
					{
						p.drawText ( QRect(size_dia_x,0,pntlabeltxt->myrect.width(),size_dia_y), (Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs),pntlabeltxt->current_text );
					}
				}
			}
			p.end();
			QString isbold = "0";
			QString isitalic = "0";
			if ( bt_leg_bold->isChecked() == true )
			{
				isbold = "1";
			}
			if ( bt_leg_italic->isChecked() == true )
			{
				isitalic = "1";
			}
			wlpix1.save(wpathprojet + "/TITLE_" + table_photos[old_current_diapo][0] + ".png","PNG");
			table_photos[old_current_diapo][17] = "PX=" + QString::number(pntlabeltxt->textx) + "PY=" + QString::number(pntlabeltxt->texty) + "TEXT=" + pntlabeltxt->current_text + "FONT=" + pntlabeltxt->myfont.toString() + "COLORRED=" + QString::number(pntlabeltxt->mycolor.red()) + "COLORGREEN=" + QString::number(pntlabeltxt->mycolor.green()) + "COLORBLUE=" + QString::number(pntlabeltxt->mycolor.blue()) + "SIZE=" + QString::number(pntlabeltxt->size) + "BOLD=" + isbold + "ITALIC=" + isitalic + "BACKRED=" + QString::number(pntlabeltxt->backcolor.red()) + "BACKGREEN=" + QString::number(pntlabeltxt->backcolor.green()) + "BACKBLUE=" + QString::number(pntlabeltxt->backcolor.blue()) + "BACKOPACITY=" + QString::number(pntlabeltxt->opacity);
			table_photos[old_current_diapo][4] = QString::number(startx_legani) + "A" + QString::number(starty_legani) + "Z" + QString::number(endx_legani) + "E" + QString::number(endy_legani);
		}
	}
	must_redraw = 1;
	// *** LEGENDES ***
	if ( table_photos[current_diapo][17] == "" )
	{
		pntmygl->state_mode = 0;
		pntmygl->wg_cpt_002 = 0;
		global_legende = "$N$U$L$L";
	}
	else
	{
		pntmygl->state_mode = 1;
		pntmygl->wg_cpt_002 = table_photos[current_diapo][23].mid(2,table_photos[current_diapo][23].length()-2).toInt() * 25;
		global_legende = wpathprojet + "/TITLE_" + table_photos[current_diapo][0] + ".png";
		if ( table_photos[current_diapo][23].left(1) == "1" )
		{
			pntmygl->fadels = 1;
			chk_fondu_entrant->setChecked(true);
			pntmygl->wg_percent_trans = 0.0f;
		}
		else
		{
			pntmygl->fadels = 0;
			chk_fondu_entrant->setChecked(false);
			pntmygl->wg_percent_trans = 1.0f;
		}
		if ( table_photos[current_diapo][23].mid(1,1) == "1" )
		{
			pntmygl->fadele = 1;
			chk_fondu_sortant->setChecked(true);
		}
		else
		{
			pntmygl->fadele = 0;
			chk_fondu_sortant->setChecked(false);
		}
		spindurleg->setValue(table_photos[current_diapo][23].mid(2,table_photos[current_diapo][23].length()-2).toInt());
	}
	tmpint_1 = table_photos[current_diapo][4].lastIndexOf( "A" );
	tmpint_2 = table_photos[current_diapo][4].lastIndexOf( "Z" );
	tmpint_3 = table_photos[current_diapo][4].lastIndexOf( "E" );

	float wl_rx;
	float wl_ry;

	if ( is43 == 1 )
	{
		wl_rx = 2.616;
		wl_ry = 2.092;
	}
	else
	{
		if ( is43 == 0 )
		{
			wl_rx = 3.720; //734;
			wl_ry = 2.102;
		}
		else
		{
			wl_rx = 3.14;
			wl_ry = 2.092;
		}
	}

	wg_tmp_002 = table_photos[current_diapo][4].mid(0, tmpint_1);
	pntmygl->startx_legani = (float)((float)((float)wg_tmp_002.toInt()*(float)wl_rx)/(float)size_dia_x);
	pntlabeltxt->posdep.setX(wg_tmp_002.toInt());
	pntlabeltxt->textx = wg_tmp_002.toInt();
	pntlabeltxt->oldx = wg_tmp_002.toInt();
	wg_tmp_002 = table_photos[current_diapo][4].mid(tmpint_1 + 1, tmpint_2-(tmpint_1+1));
	pntmygl->starty_legani = (float)((float)((float)wg_tmp_002.toInt()*(float)wl_ry)/(float)size_dia_y);
	pntlabeltxt->posdep.setY(wg_tmp_002.toInt());
	pntlabeltxt->texty = wg_tmp_002.toInt();
	pntlabeltxt->oldy = wg_tmp_002.toInt();

	pntmygl->starty_legani = (wl_ry/2) - pntmygl->starty_legani;
	//
	pntmygl->posxleg = pntmygl->startx_legani;
	pntmygl->posyleg = pntmygl->starty_legani;
	//
	wg_tmp_002 = table_photos[current_diapo][4].mid(tmpint_2 + 1, tmpint_3-(tmpint_2+1));
	pntmygl->endx_legani = ((float)((float)wg_tmp_002.toInt()*(float)wl_rx)/(float)size_dia_x);
	pntlabeltxt->posend.setX(wg_tmp_002.toInt());
	wg_tmp_002 = table_photos[current_diapo][4].mid(tmpint_3 + 1, tmpint_3-(table_photos[current_diapo][4].length()+1));
	pntmygl->endy_legani = ((float)((float)wg_tmp_002.toInt()*(float)wl_ry)/(float)size_dia_y);
	pntlabeltxt->posend.setY(wg_tmp_002.toInt());

	pntmygl->endx_legani = pntmygl->endx_legani;
	pntmygl->endy_legani = (wl_ry/2) - pntmygl->endy_legani;

	// *** CHARGEMENT DES IMAGES ***
	if ( table_photos[current_diapo][9] == "1" )
	{
		pntmygl->sl_charge_dessin(wpathprojet + "/_DRAW" + table_photos[current_diapo][0] + ".png");
		pntmygl->isdraw = 1;
	}
	else
	{
		pntmygl->isdraw = 0;
	}
	//
	pntmygl->sl_charge_image(wpathprojet + "/" + table_photos[current_diapo][0], wpathprojet + "/" + table_photos[current_diapo][13],global_legende);
	//
	pntmygl->type3D = table_photos[current_diapo][27].toInt();
	//
	pntmygl->wg_percent = table_photos[current_diapo][25].toFloat() / 100;
	pntmygl->wg_percent_slide = table_photos[current_diapo][11].toFloat() / 100;
	slider_scale->setValue(table_photos[current_diapo][7].toInt());
	pntmygl->size_factor = (float)((float)table_photos[current_diapo][7].toInt()/(float)100);
	// *** DUREE **
	zik_1->current = current_diapo;
	pntmygl->wg_duree = table_photos[current_diapo][16].toInt();
	pntmygl->duree = pntmygl->wg_duree * 25;
	pntstamp->duree_diapo = pntmygl->wg_duree;
	pntstamp->initpos();
	if ( table_photos[current_diapo][10] != "" )
	{
		pntstamp->paraframes = table_photos[current_diapo][10];
		pntstamp->charge_frames();
	       	pntmygl->debut_rx = pntstamp->table_coo[0][0];
	       	pntmygl->debut_ry = pntstamp->table_coo[0][1];
	       	pntmygl->debut_rz = pntstamp->table_coo[0][2];
		pntmygl->debut_px = pntstamp->table_coo[0][3];
	       	pntmygl->debut_py = pntstamp->table_coo[0][4];
	       	pntmygl->debut_pz = pntstamp->table_coo[0][5];
		//
	       	pntmygl->fin_rx = pntstamp->table_coo[pntmygl->duree-1][0];
       		pntmygl->fin_ry = pntstamp->table_coo[pntmygl->duree-1][1];
       		pntmygl->fin_rz = pntstamp->table_coo[pntmygl->duree-1][2];
		pntmygl->fin_px = pntstamp->table_coo[pntmygl->duree-1][3];
       		pntmygl->fin_py = pntstamp->table_coo[pntmygl->duree-1][4];
       		pntmygl->fin_pz = pntstamp->table_coo[pntmygl->duree-1][5];

		pntstamp->repaint();
		f_calcul_coo();
	}
	else
	{
	       	pntmygl->debut_px = 0;
	       	pntmygl->debut_py = 0;
	       	pntmygl->debut_pz = -3.8;
	       	pntmygl->debut_rx = 0;
	       	pntmygl->debut_ry = 0;
	       	pntmygl->debut_rz = 0;
		//
	       	pntmygl->fin_px = 0;
	       	pntmygl->fin_py = 0;
	       	pntmygl->fin_pz = -3.8;
	       	pntmygl->fin_rx = 0;
	       	pntmygl->fin_ry = 0;
	       	pntmygl->fin_rz = 0;
		f_calcul_coo();
	}
	pntmygl->rotationX = pntmygl->debut_rx;
	pntmygl->rotationY = pntmygl->debut_ry;
	pntmygl->rotationZ = pntmygl->debut_rz;
	pntmygl->zoom = pntmygl->debut_pz;
	pntmygl->deplacementX = pntmygl->debut_px;
	pntmygl->deplacementY = pntmygl->debut_py;
	//
	tmpint_1 = table_photos[current_diapo][19].indexOf( ";",0,Qt::CaseSensitive );
	tmpint_2 = table_photos[current_diapo][19].indexOf( ":",0,Qt::CaseSensitive );
	tmpint_3 = table_photos[current_diapo][19].indexOf( "!",0,Qt::CaseSensitive );
	
	wg_tmp_002 = table_photos[current_diapo][19].mid(0, tmpint_1);
	pntmygl->effetsup = wg_tmp_002.toInt();
	effetsup->setCurrentIndex(pntmygl->effetsup);
	if ( pntmygl->effetsup > 0 )
	{
		if ( pntmygl->effetsup == 7 )
		{
			pntmygl->chemin_flocon = table_photos[current_diapo][5];
		}
		pntmygl->loadeffetsup(pntmygl->effetsup);
	}
	wg_tmp_002 = table_photos[current_diapo][19].mid(tmpint_1+1, (tmpint_2 - tmpint_1)-1);
	nbre_effet_sup->setValue(wg_tmp_002.toInt());
	pntmygl->nombre_effet = wg_tmp_002.toInt();

	wg_tmp_002 = table_photos[current_diapo][19].mid(tmpint_2+1, (tmpint_3 - tmpint_2)-1);
	size_effet_sup->setValue(wg_tmp_002.toInt());
	pntmygl->size_effet = (float)((float)wg_tmp_002.toInt() / (float)100);

	wg_tmp_002 = table_photos[current_diapo][19].mid(tmpint_3+1, wg_tmp_002.length() - (tmpint_3 + 1));
	speed_effet_sup->setValue(wg_tmp_002.toInt());
	pntmygl->speed_effet = (float)((float)wg_tmp_002.toInt() / (float)100);
	//
	if ( table_photos[current_diapo][18] == "2" )
	{
		check_rotationeffet->setChecked(true);
		pntmygl->rotation_effet = 2;
	}
	else
	{
		check_rotationeffet->setChecked(false);
		pntmygl->rotation_effet = 0;
	}
	//
	pntmygl->progress = 0;
	//
	if ( table_photos[current_diapo][8] == "1" )
	{
		pntmygl->isbackanim = 1;
		check_backanim->setChecked(true);
	}
	else
	{
		pntmygl->isbackanim = 0;
		check_backanim->setChecked(false);
	}

	// *** MISE EN PLACE DE L'INTERFACE ***
	dial_percent_blending->setValue(table_photos[current_diapo][25].toInt());
	dial_percent_blending_2->setValue(table_photos[current_diapo][26].toInt());
	dial_opacity_slide->setValue(table_photos[current_diapo][11].toInt());
	spindurdiapo->setValue(table_photos[current_diapo][16].toInt());
	//
	if ( table_photos[current_diapo][14] == "1" )
	{
		pntmygl->fogcolor[0] = (float)table_color_fog[current_diapo].red() / (float)255;
		pntmygl->fogcolor[1] = (float)table_color_fog[current_diapo].green() / (float)255;
		pntmygl->fogcolor[2] = (float)table_color_fog[current_diapo].blue() / (float)255;
		pntmygl->fogcolor[3] = 0.5;
		pntmygl->isfog = 1;
		check_fog->setChecked(true);
		dial_opacity->setValue(table_photos[current_diapo][15].toInt());
		dial_opacity_2->setValue(table_photos[current_diapo][28].toInt());
		pntmygl->change_fog_color();
	}
	else
	{
		pntmygl->isfog = 0;
		dial_opacity->setValue(30);
		dial_opacity_2->setValue(30);
		check_fog->setChecked(false);
	}
	//
	if ( current_diapo == 0 )
	{
		int wl_valcalc = table_photos[current_diapo][16].toInt();

		if ( current_diapo <= nbre_photos )
		{
			if ( table_photos[current_diapo+1][20].toInt() > 0 )
			{
				wl_valcalc = wl_valcalc - table_photos[current_diapo+1][21].toInt();
			}
		}
		if ( wl_valcalc < 0 )
		{
			spindurtrans->setMaximum(0);
		}
		else
		{
			spindurtrans->setMaximum(wl_valcalc);
		}
	}
	else
	{
		int wl_valcalc = table_photos[current_diapo][16].toInt();
		
		if ( current_diapo < nbre_photos )
		{
			if ( table_photos[current_diapo+1][20].toInt() > 0 )
			{
				wl_valcalc = wl_valcalc - table_photos[current_diapo+1][21].toInt();
			}
		}
		if ( wl_valcalc < 0 )
		{
			spindurtrans->setMaximum(0);
		}
		else
		{
			spindurtrans->setMaximum(wl_valcalc);
		}
	}
	//
	spindurtrans->setValue(table_photos[current_diapo][21].toInt());
	if ( table_photos[current_diapo][24] == "" )
	{
		pnttimeline->iscomment = 0;
	}
	else
	{
		pnttimeline->iscomment = 1;
	}
	lst_transitions->setCurrentIndex(table_photos[current_diapo][20].toInt());
	if ( table_photos[current_diapo][20].toInt() > 1 )
	{
		checkinvert->setEnabled(true);
		if ( table_photos[current_diapo][6] == "2" )
		{
			checkinvert->setChecked(true);
		}
		else
		{
			checkinvert->setChecked(false);
		}
	}
	else
	{
		checkinvert->setChecked(false);
		checkinvert->setDisabled(true);
	}
	//
	if ( table_photos[current_diapo][22] != "0" )
	{
		QString nomeffet = table_photos[current_diapo][22];
		pntmygl->iseffect = 1;
		//
		tmpint_1 = table_photos[current_diapo][12].indexOf( ";",0,Qt::CaseSensitive );
		tmpint_2 = table_photos[current_diapo][12].indexOf( "$",0,Qt::CaseSensitive );
		tmpint_3 = table_photos[current_diapo][12].indexOf( "@",0,Qt::CaseSensitive );
		tmpint_4 = table_photos[current_diapo][12].indexOf( "#",0,Qt::CaseSensitive );
	
		wg_tmp_002 = table_photos[current_diapo][12].mid(0, tmpint_1);
		slider_size_anim->setValue(wg_tmp_002.toFloat());
		pntmygl->sizanim = (float)wg_tmp_002.toFloat()/100;

		wg_tmp_002 = table_photos[current_diapo][12].mid(tmpint_1+1, (tmpint_2 - tmpint_1)-1);
		pntmygl->posanim_x = (float)wg_tmp_002.toFloat();

		wg_tmp_002 = table_photos[current_diapo][12].mid(tmpint_2+1, (tmpint_3 - tmpint_2)-1);
		pntmygl->posanim_y = (float)wg_tmp_002.toFloat();

		wg_tmp_002 = table_photos[current_diapo][12].mid(tmpint_3+1, (tmpint_4 - tmpint_3)-1);
		slider_rot_anim->setValue(wg_tmp_002.toFloat());
		pntmygl->rotanim = (float)wg_tmp_002.toFloat();

		tmpint_4 = comboeffets->findText ( table_photos[current_diapo][22], Qt::MatchExactly );
		comboeffets->setCurrentIndex(tmpint_4);
	}
	else
	{
		comboeffets->setCurrentIndex(0);
		pntmygl->iseffect = 0;
	}
	tmpint_6 = table_photos[current_diapo][12].lastIndexOf( '&' );
	if ( tmpint_6 > -1 )
	{
		wg_tmp_002 = table_photos[current_diapo][12].mid(tmpint_6+1, 1);
		if ( wg_tmp_002.toInt() == 1 )
		{
			check_mblur->setChecked(true);
		}
		else
		{
			check_mblur->setChecked(false);
		}
		pntmygl->ismblur = wg_tmp_002.toInt();
		pntmygl->bcle_render = 1;
	}
	else
	{
		check_mblur->setChecked(false);
		pntmygl->ismblur = 0;
	}
	//
	must_redraw = 0;
	pntmygl->updateGL();
	//
	position_flux = 0;
	//
	if ( pntmygl->isdiapoanim == 1 || table_photos[current_diapo][0].lastIndexOf( "emptydiapo" ) >= 0 )
	{
		actionEditer_diapositive->setDisabled(true);
	}
	else
	{
		actionEditer_diapositive->setEnabled(true);
	}

	label_curdiapo->setText(tr("Diapositive actuelle : ") + QString::number(current_diapo + 1));

	img_selection->setGeometry( ((current_diapo * 97) + ((current_diapo+1) * 10))-5, 0, 30, 30);
	img_selection->show();
	img_selection->raise();
	old_current_diapo = current_diapo;
	//
	if ( old_tab == 2 )
	{
		f_open_title(2);
	}
}

void mainfrm::f_follow_timeline(int position)
{
    	pntmygl->rotationX = pntstamp->table_coo[position][0];
    	pntmygl->rotationY = pntstamp->table_coo[position][1];
    	pntmygl->rotationZ = pntstamp->table_coo[position][2];
    	pntmygl->deplacementX = pntstamp->table_coo[position][3];
    	pntmygl->deplacementY = pntstamp->table_coo[position][4];
	pntmygl->zoom = pntstamp->table_coo[position][5];

	pntmygl->posxleg = pntmygl->startx_legani - (position * ((pntmygl->startx_legani - pntmygl->endx_legani) / (spindurdiapo->value()*25)));
	pntmygl->posyleg = pntmygl->starty_legani - (position * ((pntmygl->starty_legani - pntmygl->endy_legani) / (spindurdiapo->value()*25)));
	if ( pntmygl->isdiapoanim == 1 )
	{
		if ( position < pntmygl->nbre_ani_slide )
		{
			if ( pntmygl->movie_object->jumpToFrame(position) == false )
			{
					//pntmygl->movie_object->setCacheMode( QMovie::CacheAll );
					pntmygl->movie_object->jumpToFrame(0);
			}
		}
		else
		{
			int realpos = position % pntmygl->nbre_ani_slide-1;
			pntmygl->movie_object->jumpToFrame(realpos);
		}
		pntmygl->b = pntmygl->movie_object->currentImage();

		QImage wl_puis_001(1024,1024,QImage::Format_ARGB32_Premultiplied);
		wl_puis_001 = pntmygl->b.copy ( 0, 0, 1024, 1024);
		pntmygl->f = QGLWidget::convertToGLFormat( wl_puis_001 );
		glGenTextures( 1, &pntmygl->texture2 );
		glBindTexture( GL_TEXTURE_2D, pntmygl->texture2 );
		glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, pntmygl->f.width(), pntmygl->f.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pntmygl->f.bits() );
		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
	}
	pntmygl->wg_percent_trans = 1.0f;
	pntmygl->updateGL();
}

void mainfrm::f_mark_timeline(int position)
{
	if ( position > 0 )
	{
		pntstamp->table_coo[position-1][0] = pntmygl->rotationX;
		pntstamp->table_coo[position-1][1] = pntmygl->rotationY;
		pntstamp->table_coo[position-1][2] = pntmygl->rotationZ;
		pntstamp->table_coo[position-1][3] = pntmygl->deplacementX;
		pntstamp->table_coo[position-1][4] = pntmygl->deplacementY;
		pntstamp->table_coo[position-1][5] = pntmygl->zoom;
	}
	else
	{
		pntstamp->table_coo[position][0] = pntmygl->rotationX;
		pntstamp->table_coo[position][1] = pntmygl->rotationY;
		pntstamp->table_coo[position][2] = pntmygl->rotationZ;
		pntstamp->table_coo[position][3] = pntmygl->deplacementX;
		pntstamp->table_coo[position][4] = pntmygl->deplacementY;
		pntstamp->table_coo[position][5] = pntmygl->zoom;
	}
       	pntmygl->debut_rx = pntstamp->table_coo[0][0];
       	pntmygl->debut_ry = pntstamp->table_coo[0][1];
       	pntmygl->debut_rz = pntstamp->table_coo[0][2];
	pntmygl->debut_px = pntstamp->table_coo[0][3];
       	pntmygl->debut_py = pntstamp->table_coo[0][4];
       	pntmygl->debut_pz = pntstamp->table_coo[0][5];
	//
       	pntmygl->fin_rx = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][0];
	pntmygl->fin_ry = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][1];
	pntmygl->fin_rz = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][2];
	pntmygl->fin_px = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][3];
	pntmygl->fin_py = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][4];
	pntmygl->fin_pz = pntstamp->table_coo[(table_photos[current_diapo][16].toInt()*25)-1][5];
	//
	int i = 0;
	QString wl_stamp = "";
	while ( i <= table_photos[current_diapo][16].toInt() )
	{
		if ( pntstamp->table_markpos[i] == 1 )
		{
			if ( i == 0 )
			{
				wl_stamp = "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[0][0]) + " " + QString::number(pntstamp->table_coo[0][1]) + " " + QString::number(pntstamp->table_coo[0][2]) + " " + QString::number(pntstamp->table_coo[0][3]) + " " + QString::number(pntstamp->table_coo[0][4]) + " " + QString::number(pntstamp->table_coo[0][5]);

			}
			else
			{
				wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[(i*25)-1][0]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][1]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][2]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][3]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][4]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][5]);
			}
		}
		i++;
	}
	if ( wl_stamp != "" )
	{
		wl_stamp = wl_stamp + "$";
	}
	table_photos[current_diapo][10] = wl_stamp;
	//
	f_calcul_coo();
}

void mainfrm::f_umark_timeline()
{
	int i = 0;
	QString wl_stamp = "";
	while ( i <= table_photos[current_diapo][16].toInt() )
	{
		if ( pntstamp->table_markpos[i] == 1 )
		{
			if ( i == 0 )
			{
				wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[0][0]) + " " + QString::number(pntstamp->table_coo[0][1]) + " " + QString::number(pntstamp->table_coo[0][2]) + " " + QString::number(pntstamp->table_coo[0][3]) + " " + QString::number(pntstamp->table_coo[0][4]) + " " + QString::number(pntstamp->table_coo[0][5]);

			}
			else
			{
				wl_stamp = wl_stamp + "|" + QString::number(i) + ">" + QString::number(pntstamp->table_coo[(i*25)-1][0]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][1]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][2]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][3]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][4]) + " " + QString::number(pntstamp->table_coo[(i*25)-1][5]);
			}
		}
		i++;
	}
	if ( wl_stamp != "" )
	{
		wl_stamp = wl_stamp + "$";
	}
	table_photos[current_diapo][10] = wl_stamp;
	f_calcul_coo();
}

void mainfrm::f_calcul_coo()
{
	int i = 1;
	int j = table_photos[current_diapo][16].toInt() * 25;
	// *** CALCUL DES DELTAS ***

        if (table_photos[current_diapo][10].mid(1,1) != "0")
        {
                pntstamp->table_coo[0][0] = 0;
                pntstamp->table_coo[0][1] = 0;
                pntstamp->table_coo[0][2] = 0;
                pntstamp->table_coo[0][3] = 0;
                pntstamp->table_coo[0][4] = 0;
                pntstamp->table_coo[0][5] = -3.8;
        }

	int sch = table_photos[current_diapo][10].lastIndexOf( "|" + QString::number(table_photos[current_diapo][16].toInt()) );
	if ( sch < 0 )
	{
	       	pntstamp->table_coo[j-1][0] = 0;
	       	pntstamp->table_coo[j-1][1] = 0;
	       	pntstamp->table_coo[j-1][2] = 0;
	       	pntstamp->table_coo[j-1][3] = 0;
	       	pntstamp->table_coo[j-1][4] = 0;
	       	pntstamp->table_coo[j-1][5] = -3.8;
	}

	while ( pntstamp->table_markpos[i] == 0 && i < table_photos[current_diapo][16].toInt() )
	{
		i++;
	}

        if ( i == table_photos[current_diapo][16].toInt() ) // *** SI LE SEUL STOP EST LE DERNIER ***
	{
		pntmygl->delta_rx = (pntstamp->table_coo[j-1][0] - pntstamp->table_coo[0][0]) / (j-1);
		pntmygl->delta_ry = (pntstamp->table_coo[j-1][1] - pntstamp->table_coo[0][1]) / (j-1);
		pntmygl->delta_rz = (pntstamp->table_coo[j-1][2] - pntstamp->table_coo[0][2]) / (j-1);
		pntmygl->delta_px = (pntstamp->table_coo[j-1][3] - pntstamp->table_coo[0][3]) / (j-1);
		pntmygl->delta_py = (pntstamp->table_coo[j-1][4] - pntstamp->table_coo[0][4]) / (j-1);
		pntmygl->delta_pz = (pntstamp->table_coo[j-1][5] - pntstamp->table_coo[0][5]) / (j-1);

		i = 1;

		while ( i < j )
		{
			pntstamp->table_coo[i][0] = pntstamp->table_coo[i-1][0] + pntmygl->delta_rx;
			pntstamp->table_coo[i][1] = pntstamp->table_coo[i-1][1] + pntmygl->delta_ry;
			pntstamp->table_coo[i][2] = pntstamp->table_coo[i-1][2] + pntmygl->delta_rz;
			pntstamp->table_coo[i][3] = pntstamp->table_coo[i-1][3] + pntmygl->delta_px;
			pntstamp->table_coo[i][4] = pntstamp->table_coo[i-1][4] + pntmygl->delta_py;
			pntstamp->table_coo[i][5] = pntstamp->table_coo[i-1][5] + pntmygl->delta_pz;
			i++;
		}
	}
	else
	{
		i = 1;
		int k = 1;
		int l;

		while ( i < j )
		{
			// *** CHERCHE PROCHAIN STOP ***
			while ( pntstamp->table_markpos[k] == 0 && k < table_photos[current_diapo][16].toInt() )
			{
				k++;
			}
			l = k*25;

			pntmygl->delta_rx = (pntstamp->table_coo[l-1][0] - pntstamp->table_coo[i-1][0]) / (l-i);
			pntmygl->delta_ry = (pntstamp->table_coo[l-1][1] - pntstamp->table_coo[i-1][1]) / (l-i);
			pntmygl->delta_rz = (pntstamp->table_coo[l-1][2] - pntstamp->table_coo[i-1][2]) / (l-i);
			pntmygl->delta_px = (pntstamp->table_coo[l-1][3] - pntstamp->table_coo[i-1][3]) / (l-i);
			pntmygl->delta_py = (pntstamp->table_coo[l-1][4] - pntstamp->table_coo[i-1][4]) / (l-i);
			pntmygl->delta_pz = (pntstamp->table_coo[l-1][5] - pntstamp->table_coo[i-1][5]) / (l-i);
			// *** BOUCLE JUSQU A PIT ***
			while ( i < l )
			{
				pntstamp->table_coo[i][0] = pntstamp->table_coo[i-1][0] + pntmygl->delta_rx;
				pntstamp->table_coo[i][1] = pntstamp->table_coo[i-1][1] + pntmygl->delta_ry;
				pntstamp->table_coo[i][2] = pntstamp->table_coo[i-1][2] + pntmygl->delta_rz;
				pntstamp->table_coo[i][3] = pntstamp->table_coo[i-1][3] + pntmygl->delta_px;
				pntstamp->table_coo[i][4] = pntstamp->table_coo[i-1][4] + pntmygl->delta_py;
				pntstamp->table_coo[i][5] = pntstamp->table_coo[i-1][5] + pntmygl->delta_pz;
				i++;
			}
			k++;
		}
	}
}

void mainfrm::f_transition_changed(int myindex)
{
	if ( nbre_photos >= 0 && must_redraw == 0 )
	{
		QLabel *mylabel;
		mylabel = table_pnt_img[current_diapo];
		QImage wl_pix_1(wpathprojet + "/" + table_photos[current_diapo][0]);
		QPixmap wl_pix_2(wg_diapositive);
		QImage wl_pix_3;
		if ( wl_pix_1.height() >= wl_pix_1.width() || (float)((float)wl_pix_1.width() / (float)wl_pix_1.height()) < (float)1.32 )
		{
			wl_pix_3 = wl_pix_1.scaledToHeight ( 63, Qt::FastTransformation );
		}
		else
		{
			wl_pix_3 = wl_pix_1.scaledToWidth ( 83, Qt::FastTransformation );
		}
		QPainter p;
		p.begin(&wl_pix_2);
		p.drawImage(7 + ((83 - wl_pix_3.width()) / 2), 7 + ((63 - wl_pix_3.height()) / 2), wl_pix_3, 0, 0, wl_pix_3.width(), wl_pix_3.height() );
		QIcon myicon = lst_transitions->itemIcon(myindex);
		myicon.paint ( &p, 5, 40, 32, 32, Qt::AlignCenter, QIcon::Normal, QIcon::On );
		if ( table_photos[current_diapo][24] != "" )
		{
			p.drawPixmap(68, 57, wg_comment, 0, 0, -1, -1 );
		}
		p.end();
		mylabel->setPixmap(wl_pix_2);
		//
		if ( myindex > 1 )
		{
			checkinvert->setEnabled(true);
		}
		else
		{
			checkinvert->setDisabled(true);
			checkinvert->setChecked(false);
		}
		//
		table_photos[current_diapo][20] = QString::number(myindex);
		f_calcul_son();
	}
}

void mainfrm::f_transition_duree_changed(int myduree)
{
	table_photos[current_diapo][21] = QString::number(myduree);
	f_calcul_son();
}

void mainfrm::start_play_all()
{
	// *** CHANGEMENT ETAT BOUTON PLAY ***
	if ( etat_lecture == 0 )
	{
		etat_lecture = 1;
		tmpint_5 = 0;
		isgrid = pntmygl->affiche_grille;
		pntmygl->affiche_grille = 0;
		poursuite_1 = 0;
		pntmygl->poursuite = 0;
		pntmygl->bcle_render = 1;
		pntmygl->resize(size_dia_x/2,size_dia_y/2);
		thread_ptra->scaleimg(size_dia_x/2,size_dia_y/2);
		frame_play->setGeometry(0,0,size_dia_x,size_dia_y);
		frame_play->setPixmap(QPixmap(":/new/prefix2/Interface/Theme/nullpixmap.png"));
		bt_play->setIcon(QIcon(":/new/prefix2/Interface/Theme/player_stop.png"));
		frame_realplay->show();
		frame_realplay->raise();
		tabmenus->setDisabled(true);
		ispreview=0;
		menubar->setDisabled(true);
		toolBar->setDisabled(true);
		bt_complex->setDisabled(true);
		toolsmenu->hide();
		mysynctime.restart();
		QTimer::singleShot(10, this, SLOT(f_bcle_lecture()));
	}
	else
	{
		pntmygl->affiche_grille = isgrid;
		etat_lecture = 0;
		pntmygl->poursuite = 1;
		pntmygl->sl_wait_stop();
		bt_play->setIcon(QIcon(":/new/prefix2/Interface/Theme/player_play.png"));
		if ( pntmygl->isdiapoanim == 1 )
		{
			pntmygl->movie_object->setCacheMode( QMovie::CacheAll );
			pntmygl->movie_object->jumpToFrame(0);
		}
		position_flux = 0; 
		frame_realplay->hide();
		menubar->setEnabled(true);
		toolBar->setEnabled(true);
		tabmenus->setEnabled(true);
		bt_complex->setEnabled(true);
		if ( tabmenus->currentIndex() < 2 )
		{
			toolsmenu->show();
		}
		pntmygl->resize(size_dia_x,size_dia_y);
		pntmygl->bcle_render = 1;
		pntmygl->updateGL();
	}
}

void mainfrm::f_bcle_lecture()
{
	pntmygl->wg_duree = table_photos[current_diapo][16].toInt();
	pntmygl->start_opacity = table_photos[current_diapo][25].toFloat() / 100;
	pntmygl->end_opacity = table_photos[current_diapo][26].toFloat() / 100;
	pntmygl->wg_percent_slide = table_photos[current_diapo][11].toFloat() / 100;
	//
	pntmygl->progress = 0;
    	pntmygl->rotationX = pntmygl->debut_rx;
    	pntmygl->rotationY = pntmygl->debut_ry;
    	pntmygl->rotationZ = pntmygl->debut_rz;
    	pntmygl->deplacementX = pntmygl->debut_px;
    	pntmygl->deplacementY = pntmygl->debut_py;
	pntmygl->zoom = pntmygl->debut_pz;
	pntmygl->delta_opacity = (pntmygl->end_opacity - pntmygl->start_opacity) / (pntmygl->duree-1);
	pntmygl->wg_percent = pntmygl->start_opacity;
	pntmygl->start_fog_opacity = table_photos[current_diapo][15].toFloat();
	pntmygl->end_fog_opacity = table_photos[current_diapo][28].toFloat();
	pntmygl->isfog = table_photos[current_diapo][14].toFloat();
	pntmygl->delta_fog_opacity = (pntmygl->end_fog_opacity - pntmygl->start_fog_opacity) / (pntmygl->duree-1);
	pntmygl->wg_percent_fog = pntmygl->start_fog_opacity;
	pntmygl->bcle_tempo = 0;

	if ( pntmygl->isdiapoanim == 1 )
	{
		pntmygl->movie_object->setCacheMode( QMovie::CacheAll );
		pntmygl->movie_object->jumpToFrame(0);
	}

	if ( pntmygl->fadels == 0 )
	{
		pntmygl->wg_percent_trans = 1.0f;
	}
	else
	{
		pntmygl->wg_percent_trans = 0.0f;
	}
	if ( pntmygl->iseffect > 0 )
	{
		pntmygl->bcle_tempo = 0;
		pntmygl->movie->setCacheMode( QMovie::CacheAll );
		pntmygl->movie->jumpToFrame(0);
	}
	if ( current_diapo == 0 && table_photos[current_diapo][20] != "0" )
	{
		for (int i = 0; i < table_photos[current_diapo][21].toInt() * 25 ; i++)
		{
			table_preview_transition[i].load(":/new/prefix2/Interface/Theme/nullpixmap.png");
			table_preview_transition[i] = table_preview_transition[i].scaled( size_dia_x/2, size_dia_y/2, Qt::IgnoreAspectRatio, Qt::FastTransformation );
		}
		poursuite_1 = table_photos[current_diapo][21].toInt() * 25;
	}

	if ( poursuite_1 > 0 )
	{
		tmpint_5 = 1;
		thread_ptra->invert = table_photos[current_diapo][6];
		if ( table_photos[current_diapo][6] == "0" )
		{
			thread_ptra->sequence = 0;
			thread_ptra->invert = "0";
		}
		else
		{
			thread_ptra->sequence = 100;
			thread_ptra->invert = "2";
		}
		thread_ptra->increment_sequence = 100 / (table_photos[current_diapo][21].toInt()*25);

		adjust_transition = (float)((float)100 / (float)(table_photos[current_diapo][21].toInt()*25)) - ((100 / (table_photos[current_diapo][21].toInt()*25)));
		compute_adjust_transition = 0;
	}
	else
	{
		tmpint_5 = 0;
	}
	if ( current_diapo+1 <= nbre_photos && tmpint_5 == 0 )
	{
		if ( table_photos[current_diapo+1][20] != "0" )
		{
			poursuite_1 = table_photos[current_diapo+1][21].toInt()*25;
		}
		else
		{
			poursuite_1 = 0;
		}
	}

	if ( table_photos[current_diapo][20].toInt() > 1 )
	{
		thread_ptra->srcImage3 = table_image_transition[table_photos[current_diapo][20].toInt() - 2].scaled( size_dia_x / 2, size_dia_y / 2, Qt::IgnoreAspectRatio, Qt::FastTransformation );
		//thread_ptra->numtrans = table_photos[current_diapo][20].toInt();
	}

	ispreview = 0;
	pntmygl->bcle_render = 1;
	f_updateMove();
}

void mainfrm::f_updateMove()
{
	int wl_wait = mysynctime.elapsed();
	if ( wl_wait < 40 )
	{
		wl_wait = 40-wl_wait;
	}
	else
	{
		wl_wait = 3;
	}
	mysynctime.restart();

	if ( pntmygl->progress > pntmygl->duree+1 )
	{
		current_diapo++;
		if ( current_diapo > nbre_photos )
		{
			current_diapo = 0;
		}
		pntmygl->bcle_render = 1;
		affichage_diapo();
		f_bcle_lecture();
		return;
	}
	else
	{
		if ( pntmygl->isdiapoanim == 1 )
		{
			if ( pntmygl->movie_object->jumpToNextFrame() == false )
			{
				pntmygl->movie_object->setCacheMode( QMovie::CacheAll );
				pntmygl->movie_object->jumpToFrame(0);
			}
			pntmygl->b = pntmygl->movie_object->currentImage();

			QImage wl_puis_001(1024,1024,QImage::Format_ARGB32_Premultiplied);
			wl_puis_001 = pntmygl->b.copy ( 0, 0, 1024, 1024);
    			pntmygl->f = QGLWidget::convertToGLFormat( wl_puis_001 );
    			glGenTextures( 1, &pntmygl->texture2 );
			glBindTexture( GL_TEXTURE_2D, pntmygl->texture2 );
			glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, pntmygl->f.width(), pntmygl->f.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pntmygl->f.bits() );
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
		}
	    	pntmygl->rotationX = pntstamp->table_coo[pntmygl->progress][0];
	    	pntmygl->rotationY = pntstamp->table_coo[pntmygl->progress][1];
	    	pntmygl->rotationZ = pntstamp->table_coo[pntmygl->progress][2];
	    	pntmygl->deplacementX = pntstamp->table_coo[pntmygl->progress][3];
	    	pntmygl->deplacementY = pntstamp->table_coo[pntmygl->progress][4];
		pntmygl->zoom = pntstamp->table_coo[pntmygl->progress][5];
		//
		pntmygl->wg_percent = pntmygl->wg_percent + pntmygl->delta_opacity;
		pntmygl->wg_percent_fog = pntmygl->wg_percent_fog + pntmygl->delta_fog_opacity;
		if ( pntmygl->state_mode == 1 )
		{
			if ( pntmygl->fadels == 1 )
			{
				if ( pntmygl->progress < 10 )
				{
					pntmygl->wg_percent_trans = pntmygl->wg_percent_trans + 0.1;
				}
			}
			if ( pntmygl->fadele == 1 )
			{
				if ( pntmygl->progress >= pntmygl->wg_cpt_002 - 10 )
				{
					pntmygl->wg_percent_trans = pntmygl->wg_percent_trans - 0.1;
				}
			}
		}
	}

	if ( pntmygl->iseffect > 0 )
	{
		if ( pntmygl->long_effet != 1 )
		{
			if ( pntmygl->movie->jumpToNextFrame() == false )
			{
				pntmygl->movie->setCacheMode( QMovie::CacheAll );
				pntmygl->movie->jumpToFrame(0);
			}
			pntmygl->a = pntmygl->movie->currentImage();
			pntmygl->wg_puis_001 = pntmygl->a.copy ( 0, 0, pntmygl->size_anim, pntmygl->size_anim);
			pntmygl->d = QGLWidget::convertToGLFormat( pntmygl->wg_puis_001 );
			glDeleteTextures( 1, &pntmygl->texture3 );
			glGenTextures( 1, &pntmygl->texture3 );
			glBindTexture( GL_TEXTURE_2D, pntmygl->texture3 );
			glTexImage2D( GL_TEXTURE_2D, 0, 4, pntmygl->d.width(), pntmygl->d.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pntmygl->d.bits() );
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
		}
		else
		{
			if ( pntmygl->bcle_tempo == 0 )
			{
				pntmygl->movie->jumpToFrame(0);
				pntmygl->a = pntmygl->movie->currentImage();
				pntmygl->wg_puis_001 = pntmygl->a.copy ( 0, 0, pntmygl->size_anim, pntmygl->size_anim);
				pntmygl->d = QGLWidget::convertToGLFormat( pntmygl->wg_puis_001 );
				glDeleteTextures( 1, &pntmygl->texture3 );
				glGenTextures( 1, &pntmygl->texture3 );
				glBindTexture( GL_TEXTURE_2D, pntmygl->texture3 );
				glTexImage2D( GL_TEXTURE_2D, 0, 4, pntmygl->d.width(), pntmygl->d.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pntmygl->d.bits() );
				glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
				pntmygl->bcle_tempo = 1;
			}
		}
	}

	if ( table_photos[current_diapo][17] != "" )
	{
		pntmygl->posxleg = pntmygl->startx_legani - ( pntmygl->progress * ((pntmygl->startx_legani - pntmygl->endx_legani) / (pntmygl->duree-1)));
		pntmygl->posyleg = pntmygl->starty_legani - ( pntmygl->progress * ((pntmygl->starty_legani - pntmygl->endy_legani) / (pntmygl->duree-1)));
	}

	if ( pntmygl->isfog == 1 )
	{
		pntmygl->sl_opacity(pntmygl->wg_percent_fog);
	}

	if ( pntmygl->poursuite == 0 )
	{
		pntmygl->progress++;
		pntmygl->updateGL();
		if ( tmpint_5 == 0 )
		{
			if ( pntmygl->progress < (pntmygl->duree+1) - poursuite_1 )
			{
				frame_play->setPixmap(QPixmap::fromImage( pntmygl->grabFrameBuffer( false ) ));
				QTimer::singleShot(wl_wait, this, SLOT(f_updateMove()));
			}
			else
			{
				table_preview_transition[ispreview] = pntmygl->grabFrameBuffer( false );
				ispreview++;
				f_updateMove();
			}
		}
		else
		{
			thread_ptra->srcImage = table_preview_transition[ispreview];
			thread_ptra->srcImage2 = pntmygl->grabFrameBuffer( false );
			thread_ptra->numtrans = table_photos[current_diapo][20].toInt();
			ispreview++;
			thread_ptra->run();
		}
	}
}

void mainfrm::f_end_ptransition()
{
	frame_play->setPixmap(QPixmap::fromImage( thread_ptra->dstImage, (Qt::ColorOnly | Qt::ThresholdDither) ));
	table_preview_transition[ispreview-1] = thread_ptra->srcImage2;
	if ( table_photos[current_diapo][6] == "0" )
	{
		if ( thread_ptra->sequence + thread_ptra->increment_sequence <= 100 )
		{
			thread_ptra->sequence = thread_ptra->sequence + thread_ptra->increment_sequence;
		}
		else
		{
			thread_ptra->sequence = 100;
		}
	}
	else
	{
		if ( thread_ptra->sequence - thread_ptra->increment_sequence >= 0 )
		{
			thread_ptra->sequence = thread_ptra->sequence - thread_ptra->increment_sequence;
		}
		else
		{
			thread_ptra->sequence = 0;
		}
	}	
	
	compute_adjust_transition = compute_adjust_transition + adjust_transition;
	if ( compute_adjust_transition >= 0.9 )
	{
		compute_adjust_transition = compute_adjust_transition-0.9;
		if ( table_photos[current_diapo][6] == "0" )
		{
			if ( thread_ptra->sequence + thread_ptra->increment_sequence <= 100 )
			{
				thread_ptra->sequence = thread_ptra->sequence + thread_ptra->increment_sequence;
			}
			else
			{
				thread_ptra->sequence = 100;
			}
		}
		else
		{
			if ( thread_ptra->sequence - thread_ptra->increment_sequence >= 0 )
			{
				thread_ptra->sequence = thread_ptra->sequence - thread_ptra->increment_sequence;
			}
			else
			{
				thread_ptra->sequence = 0;
			}
		}	
	}

	if ( ispreview >= table_photos[current_diapo][21].toInt()*25 )
	{
		tmpint_5 = 0;
		ispreview = 0;
		if ( current_diapo+1 <= nbre_photos )
		{
			if ( table_photos[current_diapo+1][20] != "0" )
			{
				poursuite_1 = table_photos[current_diapo+1][21].toInt()*25;
			}
			else
			{
				poursuite_1 = 0;
			}
		}
		else
		{
			poursuite_1 = 0;
		}
	}
	QTimer::singleShot(1, this, SLOT(f_updateMove()));
}

void mainfrm::f_checkinvert(int value)
{
	table_photos[current_diapo][6] = QString::number(value);
}

void mainfrm::prepare_insert_photo()
{
	pb_import->setValue(0);
	pb_import->setMaximum(pnttimeline->myurl.count());
}

