/* ============================================================
 * 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"

// ***************************************************************
// *** DEFINITION DU STYLE D'UN SLIDER POUR CHANGEMENT BITRATE ***
// ***************************************************************

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->drawPixmap(0,0,-1,-1,QPixmap(":/Interface/Interface/fond_pb.png"));
        				}
      
      					if (sliderOption->subControls & SC_SliderHandle) 
       					{
						if ( handle.x () > 0 )
						{
							painter->drawPixmap(0,0,-1,-1,QPixmap(":/Interface/Interface/fond_pb2.png"),0,0,handle.x()+10,-1);
						}
						painter->setPen(Qt::SolidLine);
						painter->setBrush(QColor(205,224,228,255));
						QPointF points[3] = {
							QPointF(handle.x(), 0),
							QPointF(handle.x()+10, 0),
							QPointF(handle.x()+10,10),
						};
						painter->drawPolygon(points, 3);
        				}
    				}
      				break;
    				default:
      				QWindowsStyle::drawComplexControl (control, option, painter, widget);
    		}
}

// **************************************************************
// *** DEFINITION DU STYLE D'UN SLIDER POUR DIFFERENTS SLIDER ***
// **************************************************************

class H_Slider_Theme_2 : public QWindowsStyle
{
	protected:

	public:
	const QImage IMG_SLIDER_HANDLE;
	const QImage IMG_SLIDER_GROOVE;

  	H_Slider_Theme_2 ()
    		//: 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_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()) 
        				{
						QLinearGradient Gradient(0.0,0.0,0.0,widget->height());
						Gradient.setColorAt(0.0, QColor(204,204,204));
						Gradient.setColorAt(1.0, QColor(176,176,176));
						painter->setRenderHint(QPainter::Antialiasing,true);
						painter->setPen(QColor(119,119,119));
						painter->setBrush(Gradient);
						painter->drawRect(0,0,widget->width(),widget->height());
        				}
      
      					if (sliderOption->subControls & SC_SliderHandle) 
       					{
						if ( handle.x () > 0 )
						{
							QLinearGradient Gradient(0.0,0.0,0.0,widget->height());
							if ( widget->whatsThis() == "" )
							{
								Gradient.setColorAt(0.0, QColor(162,204,245));
								Gradient.setColorAt(1.0, QColor(120,178,232));
							}
							else
							{
								if ( widget->whatsThis() == "R" )
								{
									Gradient.setColorAt(0.0, QColor(252,98,1));
									Gradient.setColorAt(1.0, QColor(255,37,0));
								}
								else
								{
									if ( widget->whatsThis() == "G" )
									{
										Gradient.setColorAt(0.0, QColor(159,255,0));
										Gradient.setColorAt(1.0, QColor(24,234,0));
									}
									else
									{
										Gradient.setColorAt(0.0, QColor(255,255,255));
										Gradient.setColorAt(1.0, QColor(222,222,222));
									}
								}
							}
							painter->setRenderHint(QPainter::Antialiasing,true);
							painter->setPen(QColor(119,119,119));
							painter->setBrush(Gradient);
							painter->drawRect(0,0,handle.x()+8,widget->height());
						}
						else
						{
							QLinearGradient Gradient(0.0,0.0,0.0,widget->height());
							if ( widget->whatsThis() == "" )
							{
								Gradient.setColorAt(0.0, QColor(162,204,245));
								Gradient.setColorAt(1.0, QColor(120,178,232));
							}
							else
							{
								if ( widget->whatsThis() == "R" )
								{
									Gradient.setColorAt(0.0, QColor(252,98,1));
									Gradient.setColorAt(1.0, QColor(255,37,0));
								}
								else
								{
									if ( widget->whatsThis() == "G" )
									{
										Gradient.setColorAt(0.0, QColor(159,255,0));
										Gradient.setColorAt(1.0, QColor(24,234,0));
									}
									else
									{
										Gradient.setColorAt(0.0, QColor(255,255,255));
										Gradient.setColorAt(1.0, QColor(222,222,222));
									}
								}
							}
							painter->setRenderHint(QPainter::Antialiasing,true);
							painter->setPen(QColor(119,119,119));
							painter->setBrush(Gradient);
							painter->drawRect(0,0,8,widget->height());
						}
						painter->setPen(QColor(255,255,255));
						QFont myfont;
						myfont.setFamily("Nimbus Sans L");
						myfont.setPixelSize ( 10 );
						myfont.setBold(false);
						painter->setPen(QColor(0,0,0));
						painter->setFont(myfont);
						painter->drawText(QRect(5,0,widget->width()-5,widget->height()), Qt::AlignVCenter,widget->statusTip());
						painter->setPen(Qt::SolidLine);
						painter->setBrush(QColor(119,119,119,200));
						painter->drawLine(handle.x()+8,0,handle.x()+8,widget->height());
						painter->setBrush(QColor(0,0,0,255));
						QPointF points[3] = {
							QPointF(handle.x()+6, 0),
							QPointF(handle.x()+10, 0),
							QPointF(handle.x()+8,4),
						};
						painter->drawPolygon(points, 3);
						QPointF points2[3] = {
							QPointF(handle.x()+6, widget->height()),
							QPointF(handle.x()+10, widget->height()),
							QPointF(handle.x()+8,widget->height()-4),
						};
						painter->drawPolygon(points2, 3);
        				}
    				}
      				break;
    				default:
      				QWindowsStyle::drawComplexControl (control, option, painter, widget);
    		}
}

// ***************************************
// *** POINT D'ENTREE DE L'APPLICATION ***
// ***************************************

mainfrm::mainfrm(QWidget *parent) : QMainWindow(parent)
{
	QPixmap pixmap(":/Interface/Interface/splash.png");
	QSplashScreen splash(pixmap);
	Qt::Alignment spal = Qt::AlignRight | Qt::AlignBottom;
	splash.show();
	splash.showMessage("Loading interface",spal,Qt::white);
	//
	qDebug() << "LOCALE : " << QLocale::system().name().left(2) << " " << qApp->applicationDirPath();
	if ( QLocale::system().name().left(2) != "fr" )
	{
		QTranslator *qtTranslator = new QTranslator(this);

		if (qtTranslator->load("2mandvd_" + QLocale::system().name().left(2), qApp->applicationDirPath()) == true )
		{
			qApp->installTranslator(qtTranslator);
		}
		else
		{
			if (qtTranslator->load("2mandvd_en", qApp->applicationDirPath()) == true )
			{
				qApp->installTranslator(qtTranslator);
			}
			else
			{
				qDebug() << "ERROR LOADING ENGLISH LANGUAGE";
			}
		}
	}

	setupUi(this);
	//this->setAttribute(Qt::WA_TranslucentBackground);
	frame_apropos->setStatusTip(tr("A propos ... 2ManDVD ") + "1.2");
	mysynctime.start();

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

	QFont wl_font;
	wl_font.setFamily("Nimbus Sans L");
	wl_font.setPixelSize ( 11 );
	this->setFont(wl_font);

	PictureFlow *newpx = new PictureFlow(label_img_thumb);
	newpx->setBackgroundColor(QColor(171,164,154));
	newpx->setReflectionEffect(PictureFlow::PlainReflection);
	newpx->setSlideSize(QSize(400, 320));
	hdlpf = newpx;
	connect(hdlpf, SIGNAL(nximg()),this, SLOT(f_next_thumb()));
	connect(hdlpf, SIGNAL(pvimg()),this, SLOT(f_prev_thumb()));

	// *** INITIALISATIONS ***
	QDir homeDir = QDir::homePath();

	path_img_menu = homeDir.path();
	path_media_import = homeDir.path();
	path_background = homeDir.path();
	path_save = homeDir.path();
	path_capture = homeDir.path();
	path_language = homeDir.path();

	name_application = "2ManDVD";
	nbre_medias = 0;
	draw_contours = 0;
	current_media = 0;
	is_new_create = 0;
	nbre_menus = 0;
	nbre_menus_wo_label = 0;
	must_update = 1;
	dvd_actual_size = 0;
	hdl_current_menu = 0;
	special_delete = 0;
	dvdzone = 0;
	current_tool = 2;
	player_isplaying = false;
	dvdxsize = 720;
	dvdysize = 576;
	current_menu_audio = "";
	current_menu_intro = "";
	path_always_save = "";

	wg_str_int_001 = tr("Debut de la video");
	wg_str_int_002 = tr("Aucune action");
	wg_str_int_003 = tr("Menu principal");
	wg_str_int_004 = tr("Aucun");
	wg_str_int_005 = tr("Pause");
	wg_str_int_006 = tr("Original soundtrack");

	bt_tool_3->setChecked(true);

	// *** CREATION DE L'INTERFACE ***
	this->setWindowState ( Qt::WindowMaximized );
	frame_player_media->setAttribute(Qt::WA_NoSystemBackground);
        frame_player_media->setAttribute(Qt::WA_PaintOnScreen,true);
        frame_player_media->setAttribute(Qt::WA_PaintUnclipped,true);

	frame_player_result->setAttribute(Qt::WA_NoSystemBackground);
        frame_player_result->setAttribute(Qt::WA_PaintOnScreen,true);
        frame_player_result->setAttribute(Qt::WA_PaintUnclipped,true);

	scrollArea_editor->setWidget(frame_support_editor);
	screen_designer->setGeometry(0,0,dvdxsize,dvdysize);
	background_menu->setGeometry(0,0,dvdxsize,dvdysize);
	safety_zone->setGeometry(0,0,dvdxsize,dvdysize);
	scrollArea_editor->setAlignment(Qt::AlignCenter);
	scrollArea_editor->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	scrollArea_editor->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	scrollArea_editor->setMouseTracking(false);
	scrollArea_editor->setFrameStyle(0);

	H_Slider_Theme_1* style_hslider1 = new H_Slider_Theme_1();
	slider_bitrate->setStyle(style_hslider1);

	H_Slider_Theme_2* style_hslider2 = new H_Slider_Theme_2();
	dial_alpha_menu->setStyle(style_hslider2);
	dial_opacity_shadow->setStyle(style_hslider2);
	dial_angle_shadow->setStyle(style_hslider2);
	slider_player->setStyle(style_hslider2);

	slider_con->setStyle(style_hslider2);
	slider_bri->setStyle(style_hslider2);
	slider_sat->setStyle(style_hslider2);
	designer_brush_width->setStyle(style_hslider2);
	slider_custo_red->setStyle(style_hslider2);
	slider_custo_green->setStyle(style_hslider2);
	slider_custo_blue->setStyle(style_hslider2);
	slider_custo_opacity->setStyle(style_hslider2);

	// *** MISE EN PLACE DE L'INTERFACE ****
	frame_lst_menus->raise();

	QPixmap wl_pix_001(QApplication::desktop()->width(),QApplication::desktop()->height());
	wl_pix_001.fill(QColor(171,164,154,240));

	mask_interface->setGeometry(0,0,QApplication::desktop()->width(),QApplication::desktop()->height());
	mask_interface->setPixmap(wl_pix_001);
	mask_interface->show();
	mask_interface->raise();

	frame_infos->hide();
	frame_render->hide();
	frame_directory->hide();
	frame_scale_background->hide();
	frame_tooltip_media->hide();
	frame_dispatch->hide();
	frame_medias->hide();
	frame_chapitrage->hide();
	frame_endencoding->hide();
	lst_chapters_2->hide();
	h_regle->hide();
	v_regle->hide();
	sur_blend->hide();
	frame_apropos->hide();
	frame_info_navi->hide();
	frame_choose_thumb->hide();
	frame_iso->hide();
	frame_customize->hide();
	frame_burn->hide();
	frame_reencode->hide();
	frame_overlays->hide();
	frame_advanced->hide();
	frame_transitions->hide();
	safety_zone->hide();
	frame_quoifaire_after->hide();
	frame_mapzone->hide();
	frame_organize->hide();
	label_mouse->hide();
	frame_add_theme->hide();
	stamp_position_extract->hide();
	frame_preview_image->hide();
	frame_language->hide();
	frame_edit_overlay->hide();
	frame_preferences->hide();
	frame_tree->hide();
	frame_nummenu->hide();
	list_language_2->hide();
	list_after_2->hide();
	frame_preview_finish->hide();

	bt_bt_img->setDisabled(true);
	bttxt->setDisabled(true);
	frame_advanced_text->setDisabled(true);
	frame_th_msk_idea->setDisabled(true);
	combo_quoilire_media->setDisabled(true);
	combo_quoilire_media_chapitre->setDisabled(true);
	combo_quoilire_menu->setDisabled(true);
	combo_select_langue->setDisabled(true);
	check_anim->setDisabled(true);
	bt_tool_1->setDisabled(true);
	bt_tool_2->setDisabled(true);
	bt_tool_3->setDisabled(true);
	bt_tool_4->setDisabled(true);
	smenuBar->setDisabled(true);
	dial_alpha_menu->setDisabled(true);
	actionEnregistrer_2->setDisabled(true);
	actionGraver_le_DVD->setDisabled(true);
	actionGenerer_l_image_ISO_du_DVD->setDisabled(true);
	actionRevoir_la_derniere_generation->setDisabled(true);
	actionOrdre_de_tabulation->setDisabled(true);
	actionCopier_le_bouton->setDisabled(true);
	actionColler_le_bouton->setDisabled(true);

	fond_preview->setGeometry(0,0,frame_preview_image->width(),frame_preview_image->height());
	frame_advanced_text->setGeometry(20,180,261,0);
	frame_actions->setGeometry(20,200,261,231);

	bt_dispatch_1->pixbt.load(":/Interface/Interface/multi2.png");
	bt_dispatch_2->pixbt.load(":/Interface/Interface/multi3.png");
	bt_dispatch_3->pixbt.load(":/Interface/Interface/multi4.png");
	bt_dispatch_4->pixbt.load(":/Interface/Interface/multi5.png");
	bt_dispatch_5->pixbt.load(":/Interface/Interface/multi6.png");

	bt_dispatch_1->pixbu.load(":/Interface/Interface/multi2_1.png");
	bt_dispatch_2->pixbu.load(":/Interface/Interface/multi3_1.png");
	bt_dispatch_3->pixbu.load(":/Interface/Interface/multi4_1.png");
	bt_dispatch_4->pixbu.load(":/Interface/Interface/multi5_1.png");
	bt_dispatch_5->pixbu.load(":/Interface/Interface/multi6_1.png");

	h_regle->setGeometry(0,(this->height()-31)/2,frame_editor->width(),21);
	v_regle->setGeometry((this->width()-31)/2,0,21,frame_editor->height());

	label_position->setText(tr("Position : 0;0"));
	label_size->setText(tr("Taille : 0x0"));
	label_rotation->setText(tr("Rotation : 0"));

	frame_support_menuthumb->setGeometry(0,0,530,106);

	bt_dispatch_1->hasback = 1;
	bt_dispatch_2->hasback = 1;
	bt_dispatch_3->hasback = 1;
	bt_dispatch_4->hasback = 1;
	bt_dispatch_5->hasback = 1;

	// *** CREATION DES COLOR WHEEL ***
	ColorPickerWidget *pntwheel_1 = new ColorPickerWidget(wheel_over);
	pntwheel1 = pntwheel_1;
	connect(pntwheel1, SIGNAL(finchange()),this, SLOT(f_preview_overlay()));
	pntwheel1->show();

	ColorPickerWidget *pntwheel_2 = new ColorPickerWidget(wheel_clic);
	pntwheel2 = pntwheel_2;
	connect(pntwheel2, SIGNAL(finchange()),this, SLOT(f_preview_overlay()));
	pntwheel2->show();

	ColorPickerWidget *pntwheel_3 = new ColorPickerWidget(wheel_txt);
	pntwheel3 = pntwheel_3;
	pntwheel3->setColor(0,0,0);
	pntwheel3->show();
	connect(pntwheel3, SIGNAL(finchange()),this, SLOT(f_valide_color_txt()));

	ColorPickerWidget *pntwheel_4 = new ColorPickerWidget(wheel_txt_shadow);
	pntwheel4 = pntwheel_4;
	pntwheel4->setColor(0,0,0);
	pntwheel4->show();
	connect(pntwheel4, SIGNAL(finchange()),this, SLOT(f_valide_color_txt_shadow()));

	ColorPickerWidget *pntwheel_5 = new ColorPickerWidget(wheel_txt_dispatch);
	pntwheel5 = pntwheel_5;
	pntwheel5->setColor(255,255,255);
	pntwheel5->show();

	// *** DEFINITION DES THREADS ***
	thani *myta = new thani();
	thread_ani = myta;
	connect(thread_ani, SIGNAL(finanim()),this, SLOT(f_update_thumb_menu()));
	connect(thread_ani, SIGNAL(lockbar()),this, SLOT(f_lockbar()));
	connect(thread_ani, SIGNAL(fincache()),this, SLOT(f_gene_mencoder()));

	thblend *mybl = new thblend();
	thread_blend = mybl;
	connect(thread_blend, SIGNAL(stepend()),this, SLOT(f_update_blend()));
	connect(thread_blend, SIGNAL(endblend()),this, SLOT(f_end_blend()));

	thimg *myti = new thimg();
	thread_img = myti;
	connect(thread_img, SIGNAL(myfin()),this, SLOT(f_refresh_customize()));

	thptra *mytr = new thptra();
	thread_trans = mytr;
	connect(thread_trans, SIGNAL(myfin()),this, SLOT(f_update_trans()));

	thmenu *mymn = new thmenu();
	thread_menu = mymn;
	thread_menu->w1 = frame_advanced_text;
	thread_menu->w2 = frame_actions;

	// *** DEFINITIONS DE BASE DES COMBOS ***
	combo_quoilire_media->insertItem(0,wg_str_int_002);

	combo_quoilire_menu->insertItem(0,wg_str_int_002);
	combo_quoilire_menu->insertItem(1,wg_str_int_003);

	combo_format_dvd->insertItem(0,"PAL 4/3");
	combo_format_dvd->setItemIcon(0, QIcon(":/Interface/Interface/palntsc.png"));
	combo_format_dvd->insertItem(1,"PAL 16/9");
	combo_format_dvd->setItemIcon(1, QIcon(":/Interface/Interface/palntsc.png"));
	combo_format_dvd->insertItem(2,"NTSC 4/3");
	combo_format_dvd->setItemIcon(2, QIcon(":/Interface/Interface/palntsc.png"));
	combo_format_dvd->insertItem(3,"NTSC 16/9");
	combo_format_dvd->setItemIcon(3, QIcon(":/Interface/Interface/palntsc.png"));

	combo_format_vmax->insertItem(0,tr("2600 Kbps (Basse)"));
	combo_format_vmax->insertItem(1,tr("5000 Kbps (Recommande)"));
	combo_format_vmax->insertItem(2,tr("9800 Kbps (Haute)"));

	combo_format_audio->insertItem(0,tr("MP2 - Stereo"));
	combo_format_audio->insertItem(1,tr("AC3 - Dolby"));
	combo_format_audio->setCurrentIndex(1);

	// *** CHARGEMENT DES BIBLIOTHEQUES ***

	splash.showMessage("Loading themes and masks",spal,Qt::white);

	QDir tmpdir;
	tmpdir.setPath(qApp->applicationDirPath()+"/Bibliotheque/Masks/");
	QStringList filters;
	filters << "*.png" << "*.PNG";
	tmpdir.setNameFilters(filters);

	QListWidgetItem *item = new QListWidgetItem(frame_th_msk_idea);
	item->setIcon(QIcon(":/Interface/Interface/error.png"));
	item->setText(wg_str_int_004);

	QPixmap wl_pix_002;
	QPainter p;
	foreach (wg_string_001, tmpdir.entryList(QDir::Files))
	{
		if ( wg_string_001.mid(0,3) != "2t_" )
		{
			wl_pix_001.load(qApp->applicationDirPath()+"/Bibliotheque/Masks/" + wg_string_001);
			if ( wl_pix_002.load(qApp->applicationDirPath()+"/Bibliotheque/Masks/2t_" + wg_string_001) == true )
			{
				p.begin(&wl_pix_001);
				p.drawPixmap(0,0,wl_pix_002);
				p.end();
			}
			QListWidgetItem *item = new QListWidgetItem(frame_th_msk_idea);
			item->setIcon(wl_pix_001);
			item->setText(wg_string_001.mid(0,wg_string_001.length()-4));
		}
	}
	frame_th_msk_idea->sortItems( Qt::AscendingOrder );

	tmpdir.setPath(qApp->applicationDirPath()+"/Bibliotheque/Animations/");
	filters << "*.gif";
	tmpdir.setNameFilters(filters);

	foreach (wg_string_001, tmpdir.entryList(QDir::Files))
	{
		wl_pix_001.load(qApp->applicationDirPath()+"/Bibliotheque/Animations/" + wg_string_001);
		QListWidgetItem *item = new QListWidgetItem(frame_th_obj_idea);
		item->setIcon(wl_pix_001);
		item->setText(wg_string_001.mid(0,wg_string_001.length()-4));
	}
	frame_th_obj_idea->sortItems( Qt::AscendingOrder );

	// *** FLAGS ***
	frame_th_the_idea->pathname = qApp->applicationDirPath()+"/Bibliotheque/Themes/";
	frame_th_the_idea->top_pathname = qApp->applicationDirPath()+"/Bibliotheque/Themes/";
	frame_th_the_idea->f_load_theme(); // *** THEMES ***

	// *** TRANSITIONS ***
	splash.showMessage("Loading transitions",spal,Qt::white);

	tmpdir.setPath(qApp->applicationDirPath()+"/Bibliotheque/Luma/");
	filters << "*.png" << "*.PNG";
	tmpdir.setNameFilters(filters);
	QString wlfile;

	foreach (wlfile, tmpdir.entryList())
	{
		wg_pix_001.load(qApp->applicationDirPath()+"/Bibliotheque/Luma/"+wlfile);
		wg_pix_001 = wg_pix_001.scaledToWidth( 128, Qt::FastTransformation );
		QListWidgetItem *item = new QListWidgetItem(lst_transitions);
		item->setIcon(QIcon(wg_pix_001));
		item->setText(wlfile.mid(0,wlfile.length()-4));
	}

	// *** DECLARATION DES TIMERS ***
 	mplayer_timer = new QTimer(this);

	// *** PROJETS ***
	connect(bt_valid_newproj, SIGNAL(clicked()),this, SLOT(f_valide_new_projet()));
	connect(bt_find_place, SIGNAL(clicked()),this, SLOT(f_find_place()));
	connect(&projectProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(projectend(int, QProcess::ExitStatus)));

	connect(bt_open_old, SIGNAL(clicked()),this, SLOT(f_open_from_start()));

	// *** TOOLBAR ***
	connect(actionAfficher_cacher_les_r_gles, SIGNAL(triggered()),this, SLOT(f_showhide_regle()));
	connect(actionAfficher_cacher_les_coordonn_es, SIGNAL(triggered()),this, SLOT(f_showhide_coor()));
	connect(actionAfficher_cacher_les_zones_de_s_curit, SIGNAL(triggered()),this, SLOT(f_showhide_safe()));

	connect(actionCapturer_une_image_du_menu, SIGNAL(triggered()),this, SLOT(f_screengrab_menu()));

	connect(actionOuvrir, SIGNAL(triggered()),this, SLOT(f_open_1()));
	connect(actionEnregistrer, SIGNAL(triggered()),this, SLOT(f_save_1()));
	connect(actionEnregistrer_2, SIGNAL(triggered()),this, SLOT(f_save_2()));
	connect(actionNouveau, SIGNAL(triggered()),this, SLOT(f_new_1()));
	connect(actionA_propos_de_2ManDVD, SIGNAL(triggered()),this, SLOT(f_apropos_open()));
	connect(bt_close_propos, SIGNAL(clicked()),this, SLOT(f_apropos_close()));
	connect(actionParam_tres_avanc_s, SIGNAL(triggered()),this, SLOT(f_advanced_open()));

	connect(actionMenu_pr_c_dent, SIGNAL(triggered()),this, SLOT(f_previous_menu()));
	connect(actionMenu_suivant, SIGNAL(triggered()),this, SLOT(f_next_menu()));
	connect(actionCouleurs_des_overlays, SIGNAL(triggered()),this, SLOT(f_overlay_menu()));

	connect(actionGraver_le_DVD, SIGNAL(triggered()),this, SLOT(f_open_burn_2()));
	connect(actionGenerer_l_image_ISO_du_DVD, SIGNAL(triggered()),this, SLOT(f_create_iso()));

	connect(actionRevoir_la_derniere_generation, SIGNAL(triggered()),this, SLOT(f_view_result()));

	connect(actionOrdre_de_tabulation, SIGNAL(triggered()),this, SLOT(f_view_tabulation()));

	connect(actionZone_du_DVD, SIGNAL(triggered()),this, SLOT(f_view_zone()));
	connect(actionAfficher_cacher_les_contours, SIGNAL(triggered()),this, SLOT(f_view_contours()));

	connect(actionArborescence_du_projet, SIGNAL(triggered()),this, SLOT(f_view_arborescence()));

	connect(actionManuel_de_2ManDVD, SIGNAL(triggered()),this, SLOT(f_documentation()));
	actionManuel_de_2ManDVD->setShortcut(QKeySequence("F1"));

	// *** PARAMETRES AVANCES ***
	connect(bt_close_advanced, SIGNAL(clicked()),this, SLOT(f_advanced_close()));
	connect(check_loop_back,SIGNAL(stateChanged(int)),this,SLOT(f_put_loop(int)));

	// *** GESTION DES MEDIAS ***
	connect(bt_open_frame_bibimport, SIGNAL(clicked()),this, SLOT(f_open_import_bibmedia()));
	connect(bt_close_navigator, SIGNAL(clicked()),this, SLOT(f_close_import_bibmedia()));
	connect(media_media, SIGNAL(media_chdir()),this, SLOT(f_move_directory()));
	connect(media_media, SIGNAL(media_dble_import()),this, SLOT(f_drop_dble()));

	connect(frame_mediatheque, SIGNAL(drop_to_panel()),this, SLOT(f_drop_to_panel()));
	connect(frame_mediatheque, SIGNAL(load_media()),this, SLOT(f_open_import_bibmedia()));
	connect(bt_close_frame_import, SIGNAL(clicked()),this, SLOT(f_close_import_media()));
	connect(bt_medias, SIGNAL(clicked()),this, SLOT(f_open_import_media()));
	//connect(bt_close_frame_import, SIGNAL(clicked()),this, SLOT(f_close_import_media()));
	connect(bt_open_chapitrage, SIGNAL(clicked()),this, SLOT(f_bt_chapitre_media()));
	connect(bt_remove_media, SIGNAL(clicked()),this, SLOT(f_bt_remove_media()));
	connect(bt_valide_quoifaire_after, SIGNAL(clicked()),this, SLOT(f_close_quoifaire_media()));
	connect(bt_add_tolist_quoifaire, SIGNAL(clicked()),this, SLOT(f_add_quoifaire_media()));
	connect(list_after, SIGNAL(delete_row(int)),this, SLOT(f_delete_quoifaire_media(int)));

	connect(bt_close_language, SIGNAL(clicked()),this, SLOT(f_close_language()));

	connect(bt_add_language, SIGNAL(clicked()),this, SLOT(f_search_language()));
	connect(list_language, SIGNAL(delete_row(int)),this, SLOT(f_delete_language(int)));

	// *** GESTION DES ZONES ***
	connect(bt_zone_0, SIGNAL(clicked()),this, SLOT(f_aff_zone_0()));
	connect(bt_zone_1, SIGNAL(clicked()),this, SLOT(f_aff_zone_1()));
	connect(bt_zone_2, SIGNAL(clicked()),this, SLOT(f_aff_zone_2()));
	connect(bt_zone_3, SIGNAL(clicked()),this, SLOT(f_aff_zone_3()));
	connect(bt_zone_4, SIGNAL(clicked()),this, SLOT(f_aff_zone_4()));
	connect(bt_zone_5, SIGNAL(clicked()),this, SLOT(f_aff_zone_5()));
	connect(bt_zone_6, SIGNAL(clicked()),this, SLOT(f_aff_zone_6()));
	connect(bt_valide_zone, SIGNAL(clicked()),this, SLOT(f_valide_zone()));

	// *** GESTION DES THUMBNAILS ***
	connect(bt_next_thumb, SIGNAL(clicked()),this, SLOT(f_next_thumb()));
	connect(bt_prev_thumb, SIGNAL(clicked()),this, SLOT(f_prev_thumb()));
	connect(bt_valid_thumb, SIGNAL(clicked()),this, SLOT(f_valid_thumb()));

	// *** GESTION DES TITRES ***
	connect(bt_add_label, SIGNAL(clicked()),this, SLOT(f_ajoute_label()));

	// *** GESTION DES MENUS BOUTONS ***
	connect(bt_add_bt, SIGNAL(clicked()),this, SLOT(f_ajoute_menu()));
	connect(bt_add_dispatch, SIGNAL(clicked()),this, SLOT(f_dispatch_menu()));

	connect(bt_dispatch_1, SIGNAL(clicked()),this, SLOT(f_dispatch_1()));
	connect(bt_dispatch_2, SIGNAL(clicked()),this, SLOT(f_dispatch_2()));
	connect(bt_dispatch_3, SIGNAL(clicked()),this, SLOT(f_dispatch_3()));
	connect(bt_dispatch_4, SIGNAL(clicked()),this, SLOT(f_dispatch_4()));
	connect(bt_dispatch_5, SIGNAL(clicked()),this, SLOT(f_dispatch_5()));
	connect(bt_cancel_dispatch, SIGNAL(clicked()),this, SLOT(f_cancel_dispatch()));
	connect(combo_typehelp, SIGNAL(currentIndexChanged(int)),this, SLOT(f_combo_typehelp_changed(int)));
	connect(combo_typehelp_chapter, SIGNAL(currentIndexChanged(int)),this, SLOT(f_combo_typehelpchapter_changed(int)));

	connect(bt_import_mask, SIGNAL(clicked()),this, SLOT(f_import_mask()));
	connect(bt_bt_img, SIGNAL(clicked()),this, SLOT(f_image_menu()));

	connect(bttxt,SIGNAL(textChanged()),this,SLOT(f_put_txt_on_bt()));
	connect(bttxt,SIGNAL(sh_unp()),this,SLOT(extevent()));
	connect(bttxt,SIGNAL(enter_editor_txt()),this,SLOT(f_enter_editor_txt()));

	connect(font_txt,SIGNAL(currentFontChanged(QFont)),this,SLOT(f_font_txt_on_bt(QFont)));

	connect(bt_fmt_1,SIGNAL(clicked()),this,SLOT(f_fmtfont_txt_on_bt_1()));
	connect(bt_fmt_2,SIGNAL(clicked()),this,SLOT(f_fmtfont_txt_on_bt_2()));
	connect(bt_fmt_3,SIGNAL(clicked()),this,SLOT(f_fmtfont_txt_on_bt_3()));
	connect(bt_fmt_4,SIGNAL(clicked()),this,SLOT(f_fmtfont_txt_on_bt_4()));
	connect(bt_fmt_5,SIGNAL(clicked()),this,SLOT(f_fmtfont_txt_on_bt_5()));
	connect(bt_fmt_6,SIGNAL(clicked()),this,SLOT(f_fmtfont_txt_on_bt_6()));

	connect(dial_angle_shadow, SIGNAL(valueChanged(int)),this, SLOT(f_shadowtext_angle(int)));
	connect(dial_opacity_shadow, SIGNAL(valueChanged(int)),this, SLOT(f_shadowtext_opacity(int)));

	connect(frame_th_msk_idea, SIGNAL(itemDoubleClicked ( QListWidgetItem* )),this, SLOT(f_select_mask()));
	connect(frame_th_the_idea, SIGNAL(itemDoubleClicked ( QListWidgetItem* )),this, SLOT(f_select_them()));
	connect(frame_th_obj_idea, SIGNAL(itemDoubleClicked ( QListWidgetItem* )),this, SLOT(f_select_object()));

	connect(bt_tool_1, SIGNAL(clicked()),this, SLOT(f_menu_zoom()));
	connect(bt_tool_2, SIGNAL(clicked()),this, SLOT(f_menu_rotate()));
	connect(bt_tool_3, SIGNAL(clicked()),this, SLOT(f_menu_grab()));
	connect(bt_tool_4, SIGNAL(clicked()),this, SLOT(f_menu_shear()));

	connect(check_anim,SIGNAL(clicked()),this,SLOT(f_put_anim()));

	// *** GESTION DES MENUS ***
	connect(bt_add_menu, SIGNAL(clicked()),this, SLOT(f_add_menu()));
	connect(combo_quoilire_media, SIGNAL(currentIndexChanged(int)),this, SLOT(f_quoilire_changed(int)));
	connect(combo_quoilire_media_chapitre, SIGNAL(currentIndexChanged(int)),this, SLOT(f_quoilire_chapitre_changed(int)));
	connect(combo_quoilire_menu, SIGNAL(currentIndexChanged(int)),this, SLOT(f_quoilire_menu_changed(int)));
	connect(combo_select_langue, SIGNAL(currentIndexChanged(int)),this, SLOT(f_quoilire_audio_changed(int)));

	connect(scroll_timeline, SIGNAL(valueChanged(int)),this, SLOT(f_scroll_timeline(int)));

	connect(solution_scale_1, SIGNAL(clicked()),this, SLOT(f_valide_scale_background_1()));
	connect(solution_scale_2, SIGNAL(clicked()),this, SLOT(f_valide_scale_background_2()));

	connect(bt_valide_overlay, SIGNAL(clicked()),this, SLOT(f_valide_overlay()));

	connect(dial_alpha_menu, SIGNAL(valueChanged(int)),this, SLOT(f_menu_opacity(int)));

	// *** THEMES ***
	connect(bt_add_theme, SIGNAL(clicked()),this, SLOT(f_add_theme()));

	connect(bt_valid_add_theme, SIGNAL(clicked()),this, SLOT(f_add_theme()));
	connect(bt_cancel_add_theme, SIGNAL(clicked()),this, SLOT(f_cancel_add_theme()));
	connect(bt_add_theme_categorie, SIGNAL(clicked()),this, SLOT(f_add_theme_categorie()));

	// *** PROCESS ***
	connect(&process_ident_media, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(f_ident_media(int, QProcess::ExitStatus)));
	connect(&process_ident_media, SIGNAL(readyReadStandardOutput()), this, SLOT(f_lecture_console_extract()));

	connect(&process_extract_img, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(f_generation_vignette(int, QProcess::ExitStatus)));
	connect(&process_extract_thu, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(f_generation_thu(int, QProcess::ExitStatus)));

	// *** CHAPITRAGE ***
	connect(bt_player_play_stop, SIGNAL(clicked()),this, SLOT(player_play_video()));
	connect(bt_player_mark_chapter, SIGNAL(clicked()),this, SLOT(player_add_chapter()));
	connect(lst_chapters, SIGNAL(gochapter(QString)),this, SLOT(player_go_chapter(QString)));
	connect(lst_chapters, SIGNAL(delete_row(QString)),lst_chapters_2, SLOT(f_delete_row(QString)));

	connect(bt_valide_autochapter, SIGNAL(clicked()),this, SLOT(player_auto_chapter()));
	connect(bt_close_chapter, SIGNAL(clicked()),this, SLOT(player_close()));
	connect(bt_mute_sound, SIGNAL(clicked()),this, SLOT(player_mute()));
	connect(bt_capture, SIGNAL(clicked()),this, SLOT(player_capture()));

	// *** MPLAYER ***
        connect(mplayer_timer, SIGNAL(timeout()), this, SLOT(player_current_percent()));
	connect(bt_avance_player, SIGNAL(clicked()),this, SLOT(player_avance()));
	connect(bt_recul_player, SIGNAL(clicked()),this, SLOT(player_recule()));

	connect(slider_player, SIGNAL(sliderPressed()),this, SLOT(player_start_seek()));
	connect(slider_player, SIGNAL(sliderReleased()),this, SLOT(player_stop_seek()));
	connect(slider_player, SIGNAL(sliderMoved(int)),this, SLOT(player_move_seek(int)));

	connect(slider_bri, SIGNAL(valueChanged(int)),this, SLOT(player_bri(int)));
	connect(slider_con, SIGNAL(valueChanged(int)),this, SLOT(player_con(int)));
	connect(slider_sat, SIGNAL(valueChanged(int)),this, SLOT(player_sat(int)));

	connect(bt_init_effects, SIGNAL(clicked()),this, SLOT(f_init_effects()));
	connect(bt_close_effects, SIGNAL(clicked()),this, SLOT(f_close_effects()));

	connect(&mplayerProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(player_read_stdout()));

	// *** GENERATION ***
	connect(actionG_n_rer_le_DVD, SIGNAL(triggered()),this, SLOT(f_go_render_dvd()));
	connect(&renderProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(render_stdout()));
	connect(bt_cancel_encoding, SIGNAL(clicked()),this, SLOT(f_encoding_end()));
	connect(&renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(render_end(int, QProcess::ExitStatus)));
	connect(bt_view_result, SIGNAL(clicked()),this, SLOT(f_view_result()));
	connect(bt_return_edit, SIGNAL(clicked()),this, SLOT(f_close_endencoding()));

	// *** DIVERS ***
	connect(&thviProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(thvi_end(int, QProcess::ExitStatus)));
	connect(bt_close_tim, SIGNAL(clicked()),this, SLOT(f_oclose_tim()));
	connect(bt_create_iso, SIGNAL(clicked()),this, SLOT(f_create_iso()));
	connect(bt_burn_dvd, SIGNAL(clicked()),this, SLOT(f_open_burn()));
	connect(bt_cancel_burn, SIGNAL(clicked()),this, SLOT(f_cancel_burn()));
	connect(bt_go_burn, SIGNAL(clicked()),this, SLOT(f_go_burn()));
	connect(&isoProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(f_read_outiso()));
	connect(&idvProcess, SIGNAL(readyReadStandardError()), this, SLOT(f_read_outiso()));
	connect(&isoProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(f_giso_end(int, QProcess::ExitStatus)));
	connect(&idvProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(f_read_outidv()));
	connect(&idvProcess, SIGNAL(readyReadStandardError()), this, SLOT(f_read_outidv()));
	connect(&idvProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(f_idvd_end(int, QProcess::ExitStatus)));
	connect(bt_valide_customize, SIGNAL(clicked()),this, SLOT(f_valide_customize()));

	connect(&proc_ffmpeg, SIGNAL(readyReadStandardOutput()), this, SLOT(f_read_ffmpeg()));
	connect(&proc_ffmpeg, SIGNAL(readyReadStandardError()), this, SLOT(f_read_ffmpeg()));

	connect(slider_custo_red, SIGNAL(valueChanged(int)),this, SLOT(f_custo_red(int)));
	connect(slider_custo_green, SIGNAL(valueChanged(int)),this, SLOT(f_custo_green(int)));
	connect(slider_custo_blue, SIGNAL(valueChanged(int)),this, SLOT(f_custo_blue(int)));
	connect(slider_custo_opacity, SIGNAL(valueChanged(int)),this, SLOT(f_custo_opacity(int)));

	connect(screen_designer, SIGNAL(customize_background()),this, SLOT(f_select_background()));
	connect(screen_designer, SIGNAL(addone()),this, SLOT(f_ajoute_menu()));
	connect(screen_designer, SIGNAL(addmul()),this, SLOT(f_dispatch_menu()));
	connect(screen_designer, SIGNAL(loadintro()),this, SLOT(f_select_intro()));
	connect(screen_designer, SIGNAL(cancelintro()),this, SLOT(f_cancel_intro()));
	connect(screen_designer, SIGNAL(paste_menu()),this, SLOT(f_paste_menu()));
	connect(screen_designer, SIGNAL(loadzik()),this, SLOT(f_select_sound()));
	connect(screen_designer, SIGNAL(cancelzik()),this, SLOT(f_cancel_sound()));
	connect(screen_designer, SIGNAL(intro_calc()),this, SLOT(f_intro_calc()));
	connect(screen_designer, SIGNAL(color_overlays()),this, SLOT(f_color_overlays()));

	connect(bt_close_reencode, SIGNAL(clicked()),this, SLOT(f_close_reencode()));
	connect(slider_bitrate, SIGNAL(valueChanged(int)),this, SLOT(f_bitarte_change(int)));

	// *** TRANSITIONS CALCULEES ***
	connect(bt_valide_intro_calc, SIGNAL(clicked()),this, SLOT(f_valide_intro_calc()));
	connect(bt_cancel_intro_calc, SIGNAL(clicked()),this, SLOT(f_cancel_intro_calc()));
	connect(lst_transitions, SIGNAL(itemDoubleClicked ( QListWidgetItem* )),this, SLOT(f_change_transition(QListWidgetItem*)));
	connect(bt_find_zik_intro, SIGNAL(clicked()),this, SLOT(f_find_intro_zik()));

	// *** AUTRES FONCTIONS ***
	connect(actionCopier_le_bouton, SIGNAL(triggered()),this, SLOT(f_copy_bt_2()));
	connect(actionColler_le_bouton, SIGNAL(triggered()),this, SLOT(f_paste_bt_2()));

	connect(frame_pro, SIGNAL(show_frame_bk()),this, SLOT(f_show_frame_bk()));
	connect(frame_pro, SIGNAL(hide_frame_bk()),this, SLOT(f_hide_frame_bk()));

	connect(dial_opacity_overlay, SIGNAL(valueChanged(int)),this, SLOT(f_preview_overlay()));

	// *** PREFERENCES ***
	connect(actionPreferences, SIGNAL(triggered()),this, SLOT(f_open_preferences()));
	connect(bt_close_preferences, SIGNAL(clicked()),this, SLOT(f_close_preferences()));

	// *** GESTION DES OVERLAYS ***
	connect(bt_close_editoverlay, SIGNAL(clicked()),this, SLOT(f_close_editoverlay()));
	connect(designer_brush_width, SIGNAL(valueChanged(int)),this, SLOT(f_designer_brush_width(int)));
	connect(bt_tool_designer_1, SIGNAL(clicked()),this, SLOT(f_tool_designer_1()));
	connect(bt_tool_designer_2, SIGNAL(clicked()),this, SLOT(f_tool_designer_2()));
	connect(bt_tool_designer_3, SIGNAL(clicked()),this, SLOT(f_tool_designer_3()));
	connect(bt_tool_designer_4, SIGNAL(clicked()),this, SLOT(f_tool_designer_4()));
	connect(bt_tool_designer_5, SIGNAL(clicked()),this, SLOT(f_tool_designer_5()));

	// *** DVDNAV ***
	connect(dvdnavtop, SIGNAL(clicked()),this, SLOT(f_dvdnav_1()));
	connect(dvdnavleft, SIGNAL(clicked()),this, SLOT(f_dvdnav_2()));
	connect(dvdnavright, SIGNAL(clicked()),this, SLOT(f_dvdnav_3()));
	connect(dvdnavbottom, SIGNAL(clicked()),this, SLOT(f_dvdnav_4()));
	connect(dvdnavok, SIGNAL(clicked()),this, SLOT(f_dvdnav_5()));
	connect(dvdnavmenu, SIGNAL(clicked()),this, SLOT(f_dvdnav_6()));
	connect(dvdnavprevious, SIGNAL(clicked()),this, SLOT(f_dvdnav_7()));
	connect(dvdnavnext, SIGNAL(clicked()),this, SLOT(f_dvdnav_8()));
	connect(dvdnavplay, SIGNAL(clicked()),this, SLOT(f_dvdnav_9()));

	// *** CREATION DU FOND ***
	fond_application.load(":/Interface/Interface/fd_transparent.png");
	fond_application.fill(QColor(0,0,0,0));
	QLinearGradient GradientF(0.0,0.0,0.0,fond_application.height());
	GradientF.setColorAt(0.7, QColor(157,152,144));
	GradientF.setColorAt(0.0, QColor(217,212,204));

	p.begin(&fond_application);
	p.setPen(Qt::NoPen);
	p.setBrush(GradientF);
	p.drawRect(0,0,fond_application.width(),fond_application.height());
	p.end();

	fond_application_2.load(":/Interface/Interface/fd_point.png");

	// *** TEST DES DEPENDANCES ***
	splash.showMessage("Control dependancies",spal,Qt::white);
	QFile wmyficext;
	QTextStream outext(&wmyficext);

	wmyficext.setFileName(homeDir.path() + "/.mdvdep.sh");
	wmyficext.open( QIODevice::WriteOnly );
	outext << "notify-send" << endl;
	outext << "mplex" << endl;
	outext << "ffmpeg" << endl;
	outext << "mencoder" << endl;
	outext << "ffmpegthumbnailer" << endl;
	outext << "sox" << endl;
	outext << "dvdauthor" << endl;
	outext << "mkisofs" << endl;
	outext << "growisofs" << endl;
	outext << "mpeg2enc" << endl;
	outext << "rm -f " + homeDir.path() + "/.mdvdep.sh" << endl;
	outext << "exit" << endl;
	wmyficext.close();
	QString programf = "bash";
	QStringList argumentsf;
	argumentsf << homeDir.path() + "/.mdvdep.sh";

      	proc_ffmpeg.setProcessChannelMode(QProcess::MergedChannels);
	proc_ffmpeg.start(programf,argumentsf);

	proc_ffmpeg.waitForFinished(-1);
	QByteArray buffer(proc_ffmpeg.readAllStandardOutput());
	wg_string_003 = wg_string_003 + buffer;

	wg_int_002 = wg_string_003.lastIndexOf( "summary" );
	if (wg_int_002 != -1)
	{
		isnotify = 1;
	}
	else
	{
		isnotify = 0;
	}

	wg_string_002 = "";

	wg_int_002 = wg_string_003.lastIndexOf( "mjpegtools" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = "MPLEX\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "FFmpeg version" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = "FFMPEG\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "MPlayer" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = wg_string_002 + "MPlayer / Mencoder\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "ffmpegthumbnailer [options]" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = wg_string_002 + "ffmpegthumbnailer\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "SoX" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = wg_string_002 + "sox\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "syntax: dvdauthor" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = wg_string_002 + "dvdauthor\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "Encoding profile" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = wg_string_002 + "mpeg2enc (Bad MJPEGTOOLS)\n";
	}

	wg_int_002 = wg_string_003.lastIndexOf( "growisofs:" );
	if (wg_int_002 == -1)
	{
		wg_string_002 = wg_string_002 + "growisofs\n";
	}

        // *** DOIT ON RECUPERER LES INFOS DE LA DERNIERE SESSION ***
        QDir currentDir = QDir::homePath();
        QByteArray newData;
        QFile configfile( currentDir.path() + "/.2mandvd.cnf" );
        if (configfile.open(QFile::ReadOnly))
        {
                newData = configfile.readLine(0);
                wg_string_001 = QString::fromLocal8Bit(newData);
                wg_string_001 = wg_string_001.simplified();
                wg_string_001 = wg_string_001.mid(0, newData.count() - 1);
                line_path_projet->setText(wg_string_001);
		if (  configfile.atEnd() == false )
		{
		        newData = configfile.readLine(0);
		        wg_string_001 = QString::fromLocal8Bit(newData);
		        wg_string_001 = wg_string_001.simplified();
		        wg_string_001 = wg_string_001.mid(0, newData.count() - 1);
			if ( wg_string_001 == "0" )
			{
				checkBox_save_encode->setChecked(false);
			}
			else
			{
				checkBox_save_encode->setChecked(true);
			}
		}
		if (  configfile.atEnd() == false )
		{
		        newData = configfile.readLine(0);
		        wg_string_001 = QString::fromLocal8Bit(newData);
		        wg_string_001 = wg_string_001.simplified();
		        wg_string_001 = wg_string_001.mid(0, newData.count() - 1);
			wl_vmax = wg_string_001.toInt();
			if ( wl_vmax == 5000 )
			{
				combo_format_vmax->setCurrentIndex(1);
			}
			else
			{
				if ( wl_vmax == 9800 )
				{
					combo_format_vmax->setCurrentIndex(2);
				}
				else
				{
					combo_format_vmax->setCurrentIndex(0);
				}
			}

			if (  configfile.atEnd() == false )
			{
				newData = configfile.readLine(0);
				wg_string_001 = QString::fromLocal8Bit(newData);
				wg_string_001 = wg_string_001.simplified();
				wg_string_001 = wg_string_001.mid(0, newData.count() - 1);
				combo_format_audio->setCurrentIndex(wg_string_001.toInt());
			}
		}
		else
		{
			wl_vmax = 5000;
			combo_format_vmax->setCurrentIndex(1);
		}
                configfile.close();
		bt_open_old->setEnabled(true);
        }
	else
	{
		// *** PREMIER LANCEMENT DE 2MANDVD ***
		QMessageBox::information(this, name_application, tr("Ceci est le premier lancement de 2ManDVD.\n Afin de pouvoir fonctionner 2ManDVD necessite que vous choisissiez un repertoire de travail dans lequel seront stockes vos productions.\n Vous pourrez modifier cet emplacement par la suite si vous le souhaitez."));
		QString mydir = QFileDialog::getExistingDirectory( this, tr("Choisissez un repertoire de travail"), "~", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
		while ( mydir.isNull() == true )
		{
			mydir = QFileDialog::getExistingDirectory( this, tr("Choisissez un repertoire de travail"), "~", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
		}
		line_path_projet->setText(mydir);
	}
	// *** AFFICHAGE DE LA FENETRE NOUVEAU PROJET ***
	if ( wg_string_002 != "" )
	{
		QMessageBox::information(this, name_application, tr("ATTENTION ! il manque certaines dependances pour le bon fonctionnement de l'application. Liste des dependances manquantes : \n") + wg_string_002);
	}

	QString openargument = QCoreApplication::arguments().last();

	if (openargument.right(7) != "2ManDVD" && openargument.right(9) != "./2ManDVD")
	{
		if ( line_path_projet->text() == "" )
		{
			frame_new_proj->show();
			frame_new_proj->raise();
		}
		else
		{
			path_project = line_path_projet->text();
			frame_new_proj->hide();
			f_open_ext(openargument);
			//
			frame_editor->lower();
			mask_interface->hide();
			frame_new_proj->hide();

			smenuBar->setEnabled(true);

			//dvd_actual_size = 0;
			//f_calcul_jauge(0);
		}
	}
	else
	{
		frame_new_proj->show();
		frame_new_proj->raise();
	}
}

// **********************
// *** GESTION PROJET ***
// **********************

void mainfrm::f_valide_new_projet()
{
	if ( line_path_projet->text() != "" )
	{
		// *** DEMARRAGE D'UN NOUVEAU PROJET ***
		if ( combo_format_dvd->currentIndex() == 0 )
		{
			dvdxsize = 720;
			dvdysize = 576;
			dvd_standard = "pal";
			dvd_format = "4/3";
		}
		else
		{
			if ( combo_format_dvd->currentIndex() == 1 )
			{
				dvdxsize = 1024;
				dvdysize = 576;
				dvd_standard = "pal";
				dvd_format = "16/9";
			}
			else
			{
				if ( combo_format_dvd->currentIndex() == 2 )
				{
					dvdxsize = 720;
					dvdysize = 480;
					dvd_standard = "ntsc";
					dvd_format = "4/3";
				}
				else
				{
					dvdxsize = 1024;
					dvdysize = 480;
					dvd_standard = "ntsc";
					dvd_format = "16/9";
				}
			}
		}
		this->setWindowTitle(tr("2ManDVD - Creation de DVD Videos"));

		path_project = line_path_projet->text();
		path_always_save = "";
		actionEnregistrer_2->setDisabled(true);

		QFile wmyficext;
		QTextStream outext(&wmyficext);

		wmyficext.setFileName(path_project + "/DVD/GENE/delall.sh");
		wmyficext.open( QIODevice::WriteOnly );
		outext << "rm -rf " + path_project + "/DVD" << endl;
		outext << "exit" << endl;
		QString programf = "bash";
		QStringList argumentsf;
		argumentsf << path_project + "/DVD/GENE/delall.sh";

	      	proc_ffmpeg.setProcessChannelMode(QProcess::MergedChannels);
		proc_ffmpeg.start(programf,argumentsf);

		proc_ffmpeg.waitForFinished(-1);

		if ( f_create_env() == true )
		{
			frame_editor->lower();
			frame_editor->show();
			thread_ani->hdlmsk = mask_interface;
			thread_ani->progress = 220;
			thread_ani->sens = 0;
			frame_new_proj->hide();

			smenuBar->setEnabled(true);

                        // *** SAUVEGARDE LES INFOS DE LA DERNIERE SESSION ***
                        QDir currentDir = QDir::homePath();
                        QFile configfile( currentDir.path() + "/.2mandvd.cnf" );
                        if (configfile.open(QIODevice::WriteOnly))
                        {
                                QTextStream out(&configfile);
                                out << line_path_projet->text() << endl;
				if ( checkBox_save_encode->isChecked() == true )
				{
	                                out << "1" << endl;
				}
				else
				{
	                                out << "0" << endl;
				}
				if ( combo_format_vmax->currentIndex() == 0 )
				{
					out << "2600" << endl;
					wl_vmax = 2600;
				}
				else
				{
					if ( combo_format_vmax->currentIndex() == 1 )
					{
						out << "5000" << endl;
						wl_vmax = 5000;
					}
					else
					{
						out << "9800" << endl;
						wl_vmax = 9800;
					}
				}
				out << combo_format_audio->currentIndex() << endl;
                                configfile.close();
                        }
			dvd_actual_size = 0;
			f_calcul_jauge(0);
			QTimer::singleShot(5, this, SLOT(f_run_ani()));
		}
		else
		{
			qDebug() << "ERROR CREATING ENVIRONEMENT ************************************";
			QMessageBox::information(this, name_application, tr("Impossible de créer les dossiers de travail"));
		}
	}
	else
	{
		QMessageBox::information(this, name_application, tr("Vous devez choisir un dossier pour les fichiers de travail"));
	}
}

void mainfrm::f_find_place()
{
	// *** DOSSIER POUR FICHIERS TEMPORAIRES DU PROJET ***
	QDir currentDir = QDir::homePath();
	QString wl_preselect = currentDir.path();
	if ( line_path_projet->text() != "" )
	{
		wl_preselect = line_path_projet->text();
	}

	QString mydir = QFileDialog::getExistingDirectory( this, tr("Choisissez un repertoire de travail"), wl_preselect, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
        if ( mydir.isNull() )
        {
        }
	else
	{
		line_path_projet->setText(mydir);
		bt_open_old->setEnabled(true);
	}
}

bool mainfrm::f_create_env()
{
	dvd_total_size=4300;
	frame_support_editor->setGeometry(frame_support_editor->geometry().x(),frame_support_editor->geometry().y(),dvdxsize,dvdysize);
	screen_designer->setGeometry(0,0,dvdxsize,dvdysize);
	background_menu->setGeometry(0,0,dvdxsize,dvdysize);
	safety_zone->setGeometry(0,0,dvdxsize,dvdysize);
	actionGraver_le_DVD->setDisabled(true);
	actionGenerer_l_image_ISO_du_DVD->setDisabled(true);
	actionRevoir_la_derniere_generation->setDisabled(true);

	// *** CREATION MINIATURE DU MENU PRINCIPAL ***
	menu_th *newmenu = new menu_th(frame_support_menuthumb);
	newmenu->setGeometry( 2, 0, 106, 106 );
	newmenu->is_first = 1;
	newmenu->is_edit = 1;
	newmenu->draw_image = QPixmap(":/Interface/Interface/default_bt.png");
	newmenu->show();
	connect(newmenu, SIGNAL(select_menuth(menu_th*) ),this, SLOT(f_select_menuth(menu_th*)));

	item_menu *newmenuarb = new item_menu(frame_syno);
	newmenuarb->setGeometry( 2, 0, 106, 106 );
	newmenuarb->show();
	frame_syno->tab_pnt_item[0] = newmenuarb;
	connect(newmenuarb, SIGNAL(item_move(item_menu*) ),this, SLOT(f_item_move(item_menu*)));
	connect(newmenuarb, SIGNAL(item_select(item_menu*) ),this, SLOT(f_item_select(item_menu*)));
	connect(newmenuarb, SIGNAL(affiche_info(item_menu*) ),this, SLOT(f_affiche_info_arbo(item_menu*)));
	connect(newmenuarb, SIGNAL(hide_info(item_menu*) ),this, SLOT(f_hide_info_arbo(item_menu*)));
	connect(newmenuarb, SIGNAL(add_link(item_menu*,int) ),this, SLOT(f_add_link(item_menu*,int)));
	connect(newmenuarb, SIGNAL(add_link_media(item_menu*,QString) ),this, SLOT(f_add_link_media(item_menu*,QString)));
	connect(newmenuarb, SIGNAL(edit_menu_tree(item_menu*) ),this, SLOT(f_edit_menu_tree(item_menu*)));

	hdl_current_menuth = newmenu;
	nbre_menuth = 0;
	current_loop = 0;
	loop_length = 5;
	table_hdl_menuth[nbre_menuth] = newmenu;

	// *** CREATION DE LA STRUCTURE DE BASE ***
	QDir QDpath_project(path_project);
	if ( QDpath_project.mkpath ( "DVD/MAIN" ) == true )
	{
		if ( QDpath_project.mkpath ( "DVD/MEDIAS" ) == true )
		{
			if ( QDpath_project.mkpath ( "DVD/TEMP" ) == true )
			{
				if ( QDpath_project.mkpath ( "DVD/GENE" ) == true )
				{
					if ( QDpath_project.mkpath ( "DVD/SVP" ) == true )
					{
						// *** CREATION DE L'IMAGE DE FOND DE MENU VIDE ***
						QPixmap wl_pix_001(dvdxsize,dvdysize);
						wl_pix_001.fill(QColor(0,0,0,0));

						QImage wl_img_001(dvdxsize,dvdysize,QImage::Format_ARGB32);
						wl_img_001.fill(0);

						QPainter p;
						p.begin(&wl_img_001);
						QFont myfont;
						p.setPen(QColor(200,200,255));
						myfont.setFamily("Nimbus Sans L");
						myfont.setPixelSize ( 40 );
						myfont.setBold(true);
						p.setFont(myfont);
						p.drawText(QRect(40,dvdysize-250,dvdxsize-40,40), Qt::AlignVCenter, tr("Nouveau menu"));
						myfont.setPixelSize ( 20 );
						myfont.setBold(false);
						p.setFont(myfont);
						p.drawText(QRect(40,dvdysize-200,dvdxsize-40,30), Qt::AlignVCenter, tr("Choisissez un arriere plan pour votre menu"));
						p.end();

						wl_img_001 = blur_shadow(wl_img_001);

						p.begin(&wl_pix_001);
						p.setRenderHint(QPainter::Antialiasing,true);
						p.setPen(QColor(200,200,200));
						p.drawPixmap ( 0, 0, QPixmap(":/Interface/Interface/stripes.jpg") );
						p.drawImage ( 0, 0, wl_img_001 );
						p.setPen(QColor(255,255,255));
						p.drawRect(0,0,dvdxsize,dvdysize);
						myfont.setPixelSize ( 40 );
						myfont.setBold(true);
						p.setFont(myfont);
						p.drawText(QRect(40,dvdysize-250,dvdxsize-40,40), Qt::AlignVCenter, tr("Nouveau menu"));
						myfont.setPixelSize ( 20 );
						myfont.setBold(false);
						p.setFont(myfont);
						p.drawText(QRect(40,dvdysize-200,dvdxsize-40,30), Qt::AlignVCenter, tr("Choisissez un arriere plan pour votre menu"));
						p.end();

						wl_pix_001.save(path_project+"/DVD/TEMP/nofd.png","PNG");

						must_update = 0;

						background_menu->setPixmap(wl_pix_001);
						
						pntwheel1->red = 255;
						pntwheel1->green = 0;
						pntwheel1->blue = 0;
						
						pntwheel2->red = 0;
						pntwheel2->green = 255;
						pntwheel2->blue = 0;
						
						pntwheel1->setColor(255,0,0);
						pntwheel2->setColor(0,255,0);
						dial_opacity_overlay->setValue(100);

						must_update = 1;

						f_update_thumb_menu();

						f_change_directory(path_media_import);

						return true;
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}

// *****************************
// *** GESTION DE LA FENETRE ***
// *****************************

void mainfrm::f_resize(QResizeEvent *)
{
	// *** PARTIES COMMUNES ***

	frame_new_proj->setGeometry((this->width()-frame_new_proj->width())/2,(this->height()-frame_new_proj->height())/2,frame_new_proj->width(),frame_new_proj->height());
	top_window->setGeometry(0,0,this->width(),top_window->height()); //this->height()-(top_window->height()+smenuBar->height())

	frame_left_menu->setGeometry(0,top_window->height(),frame_left_menu->width(),this->height());

        frame_pro->setGeometry(this->width()-40,top_window->height(),frame_pro->width(),this->height()-(smenuBar->height()+top_window->height()));
	tabwidget_main->setGeometry(50,10,frame_pro->width()-60,frame_pro->height()-20);

	frame_th_msk_idea->setGeometry(10,10,tabwidget_main->width()-10,tabwidget_main->height()-75);
	bt_import_mask->setGeometry(10,tabwidget_main->height()-60,frame_th_msk_idea->width(),bt_import_mask->height());

	frame_th_the_idea->setGeometry(10,10,tabwidget_main->width()-10,tabwidget_main->height()-75);
	bt_add_theme->setGeometry(10,tabwidget_main->height()-60,frame_th_the_idea->width(),bt_add_theme->height());

	frame_th_obj_idea->setGeometry(10,10,tabwidget_main->width()-10,tabwidget_main->height()-30);

        frame_editor->setGeometry(frame_left_menu->width(),0,this->width()-frame_left_menu->width(),this->height()-smenuBar->height());
	scrollArea_editor->setGeometry(0,top_window->height(),frame_editor->width(),frame_editor->height()-top_window->height());
	frame_is_is->setGeometry(frame_editor->width()-(frame_is_is->width()+10),frame_editor->height()-(frame_is_is->height()+10),frame_is_is->width(),frame_is_is->height());
	mask_interface->setGeometry(0,0,this->width(),this->height());
	frame_lst_menus->setGeometry(frame_left_menu->width()+((frame_editor->width()-550)/2),frame_editor->height()-(170+smenuBar->height()),550,frame_lst_menus->height());

	frame_support_menu_th_contain->setGeometry(10,36,frame_lst_menus->width()-20,122);
	scroll_timeline->setGeometry(2,frame_support_menu_th_contain->height()-18,frame_support_menu_th_contain->width()-4,14);

	frame_dispatch->setGeometry(0,0,this->width(),this->height()-smenuBar->height());
	frame_help_dispatch->setGeometry(10,frame_dispatch->height()-(frame_help_dispatch->height()+10),frame_help_dispatch->width(),frame_help_dispatch->height());
	label_fond_options->setGeometry(0,0,frame_help_dispatch->width(),frame_help_dispatch->height());
	label_fond_options->lower();
	frame_render->setGeometry((this->width()-frame_render->width())/2,(this->height()-frame_render->height())/2,frame_render->width(),frame_render->height());
        frame_iso->setGeometry((this->width()-frame_iso->width())/2,(this->height()-frame_iso->height())/2,frame_iso->width(),frame_iso->height());
	frame_burn->setGeometry((this->width()-frame_burn->width())/2,(this->height()-frame_burn->height())/2,frame_burn->width(),frame_burn->height());
	frame_customize->setGeometry((this->width()-frame_customize->width())/2,(this->height()-frame_customize->height())/2,frame_customize->width(),frame_customize->height());
	frame_advanced->setGeometry((this->width()-frame_advanced->width())/2,(this->height()-frame_advanced->height())/2,frame_advanced->width(),frame_advanced->height());

	frame_edit_overlay->setGeometry((this->width()-frame_edit_overlay->width())/2,(this->height()-frame_edit_overlay->height())/2,frame_edit_overlay->width(),frame_edit_overlay->height());

	frame_preferences->setGeometry((this->width()-frame_preferences->width())/2,(this->height()-frame_preferences->height())/2,frame_preferences->width(),frame_preferences->height());

	// *** PREVIEW DE FIN ***
	frame_preview_finish->setGeometry(0,0,this->width(),this->height()-smenuBar->height());
	frame_telecommande->setGeometry(frame_preview_finish->width()-260,10,250,frame_preview_finish->height()-20);
	frame_player_result->setGeometry(10,10,frame_preview_finish->width()-280,frame_preview_finish->height()-20);

	// *** DIVERS ***

	frame_tree->setGeometry(0,0,this->width(),this->height());
	frame_syno->setGeometry(20,20,this->width()-40,this->height()-(40+smenuBar->height()));

	frame_preview_image->setGeometry(this->width()-(frame_preview_image->width()+15),this->height()-(frame_preview_image->height()+40),frame_preview_image->width(),frame_preview_image->height());
	frame_scale_background->setGeometry(0,0,this->width(),this->height()-smenuBar->height());
	solution_scale_1->setGeometry((frame_scale_background->width()-650)/2,(frame_scale_background->height()-270)/2,300,300);
	solution_scale_2->setGeometry(solution_scale_1->geometry().x()+350,solution_scale_1->geometry().y(),300,300);
	label_scale_background->setGeometry(0,0,this->width(),solution_scale_1->geometry().y());

	frame_endencoding->setGeometry((this->width()-frame_endencoding->width())/2,(this->height()-frame_endencoding->height())/2,frame_endencoding->width(),frame_endencoding->height());
	frame_transitions->setGeometry((this->width()-frame_transitions->width())/2,(this->height()-frame_transitions->height())/2,frame_transitions->width(),frame_transitions->height());

	bt_dispatch_1->setGeometry((this->width()-470)/2,(this->height()-270)/2,130,130);
	bt_dispatch_2->setGeometry(bt_dispatch_1->geometry().x()+170,bt_dispatch_1->geometry().y(),130,130);
	bt_dispatch_3->setGeometry(bt_dispatch_2->geometry().x()+170,bt_dispatch_2->geometry().y(),130,130);
	bt_dispatch_4->setGeometry((this->width()-300)/2,bt_dispatch_1->geometry().y()+170,130,130);
	bt_dispatch_5->setGeometry(bt_dispatch_4->geometry().x()+170,bt_dispatch_4->geometry().y(),130,130);
	label_dispatch->setGeometry(0,bt_dispatch_1->geometry().y()-200,this->width(),200);
	bt_cancel_dispatch->setGeometry(this->width()-(bt_cancel_dispatch->width()+20),10,bt_cancel_dispatch->width(),bt_cancel_dispatch->height());

	frame_apropos->setGeometry((this->width()-frame_apropos->width())/2,(this->height()-frame_apropos->height())/2,frame_apropos->width(),frame_apropos->height());
	frame_overlays->setGeometry((this->width()-frame_overlays->width())/2,(this->height()-frame_overlays->height())/2,frame_overlays->width(),frame_overlays->height());

	frame_choose_thumb->setGeometry(0,0,this->width(),this->height()-smenuBar->height());
	label_img_thumb->setGeometry(10,40,this->width()-20,this->height()-120);
	hdlpf->setGeometry(0,0,label_img_thumb->width(),label_img_thumb->height());
	hdlpf->resize(label_img_thumb->width(),label_img_thumb->height());
	frame_bt_thumb->setGeometry((this->width() - frame_bt_thumb->width())/2,hdlpf->geometry().y()+hdlpf->height()+smenuBar->height()+4,frame_bt_thumb->width(),frame_bt_thumb->height());
	frame_mapzone->setGeometry((this->width() - frame_mapzone->width())/2,(this->height() - frame_mapzone->height())/2,frame_mapzone->width(),frame_mapzone->height());

	label_mouse->setGeometry(10,this->height()-(label_mouse->height()+30),label_mouse->width(),label_mouse->height());

	frame_add_theme->setGeometry((this->width() - frame_add_theme->width())/2,(this->height() - frame_add_theme->height())/2,frame_add_theme->width(),frame_add_theme->height());
	stamp_position_extract->setGeometry(this->width() - (stamp_position_extract->width()+30),30,stamp_position_extract->width(),stamp_position_extract->height());

	// *** BIBLIOTHEQUE AJOUT DE MEDIAS ***

	frame_reencode->setGeometry((this->width()-frame_reencode->width())/2,(this->height()-frame_reencode->height())/2,frame_reencode->width(),frame_reencode->height());
	frame_medias->setGeometry(0,0,this->width(),this->height()-smenuBar->height());
	support_frame_mediatheque->setGeometry(10,10,frame_medias->width()-20,frame_medias->height()-20); //121
	bottom_mediateque->setGeometry(0,support_frame_mediatheque->height()-90,this->width(),101);
	bottom_mediateque->raise();
	frame_mediatheque->setGeometry(0,0,support_frame_mediatheque->width(),support_frame_mediatheque->height());
	frame_directory->setGeometry((this->width()-frame_directory->width())/2,(this->height()-frame_directory->height())/2,frame_directory->width(),frame_directory->height());
	jauge_dvd->setGeometry(this->width() - 130,this->height() - (130+smenuBar->height()),130,130);
	frame_bt_center_media->setGeometry((this->width()-frame_bt_center_media->width())/2,0,frame_bt_center_media->width(),101);

	frame_chapitrage->setGeometry(0,0,this->width(),this->height()-smenuBar->height());
	frame_fond_menu_chapitrage->setGeometry(frame_chapitrage->width() - frame_fond_menu_chapitrage->width(),0,frame_fond_menu_chapitrage->width(),frame_chapitrage->height());

	frame_reglages->setGeometry(frame_chapitrage->width() - frame_fond_menu_chapitrage->width(),0,frame_fond_menu_chapitrage->width(),frame_chapitrage->height());
	bt_close_effects->setGeometry(10,frame_chapitrage->height()-41,frame_fond_menu_chapitrage->width()-20,31);

	label_sticker_length->setGeometry(frame_fond_menu_chapitrage->geometry().x()-90,frame_fond_menu_chapitrage->height()-100,label_sticker_length->width(),label_sticker_length->height());

	lst_chapters->setGeometry(10,10,frame_fond_menu_chapitrage->width()-20,frame_chapitrage->height()-250);
	frame_autochap->setGeometry((frame_fond_menu_chapitrage->width()-frame_autochap->width())/2,frame_chapitrage->height()-205,frame_autochap->width(),121);
	bt_player_mark_chapter->setGeometry(10,frame_chapitrage->height()-240,frame_fond_menu_chapitrage->width()-20,31);
	bt_close_chapter->setGeometry(10,frame_chapitrage->height()-41,frame_fond_menu_chapitrage->width()-20,31);

	frame_support_player->setGeometry(40,40,frame_chapitrage->width()-(frame_fond_menu_chapitrage->width()+80),frame_chapitrage->height()-80);
	frame_player_media->setGeometry(20,20,frame_support_player->width()-40,frame_support_player->height()-130);
	frame_progress_player->setGeometry(20,21+frame_player_media->height(),frame_support_player->width()-40,frame_progress_player->height());
	frame_ctrl_player->setGeometry((frame_player_media->width()-frame_ctrl_player->width())/2,frame_support_player->height()-75,frame_ctrl_player->width(),frame_ctrl_player->height());
	slider_player->setGeometry(0,5,frame_progress_player->width(),21);
	bt_mute_sound->setGeometry(20,frame_ctrl_player->geometry().y()+17,40,40);
	bt_capture->setGeometry(bt_mute_sound->geometry().x()+50,frame_ctrl_player->geometry().y()+17,40,40);
	frame_quoifaire_after->setGeometry((this->width()-frame_quoifaire_after->width())/2,(this->height()-frame_quoifaire_after->height())/2,frame_quoifaire_after->width(),frame_quoifaire_after->height());

	frame_language->setGeometry((this->width()-frame_language->width())/2,(this->height()-frame_language->height())/2,frame_language->width(),frame_language->height());

	// *** EDITEUR DE MENUS ***

	frame_is_is->raise();

	frame_organize->setGeometry(screen_designer->geometry().x(),screen_designer->geometry().y(),dvdxsize,dvdysize);

	h_regle->wgheight = frame_editor->height()-24;
	v_regle->wgwidth = frame_editor->width()-24;
	h_regle->setGeometry(0,h_regle->geometry().y(),frame_editor->width(),21);
	v_regle->setGeometry(v_regle->geometry().x(),0,21,frame_editor->height());

	thread_ani->pix_001 = thread_ani->pix_001.scaled(this->width(),this->height());
}

void mainfrm::f_show_frame_bk()
{
        frame_pro->setGeometry(this->width()-frame_pro->width(),top_window->height(),frame_pro->width(),this->height()-top_window->height());
}

void mainfrm::f_hide_frame_bk()
{
        frame_pro->setGeometry(this->width()-40,top_window->height(),frame_pro->width(),this->height()-top_window->height());
}

void mainfrm::f_close()
{
	// ****************************************
	// *** Point de sortie de l'application ***
	// ****************************************
	QDir currentDir = QDir::homePath();
      	QFile myfic(currentDir.path() + "/.delete2MANDVD.sh");

	if ( !myfic.open( QIODevice::WriteOnly ))
	{
		qDebug() << "ERROR CREATING EXTRACT SCRIPT IN YOUR HOME DIRECTORY : " + currentDir.path();
		return;
	}
	else
	{
		QTextStream out(&myfic);
		out << "#!/bin/bash" << endl;
		out << "rm -rf " + path_project + "/DVD/" << endl;
		out << "rm -f .delete2MANDVD.sh" << endl;
		myfic.close();

		QString program = "bash";
       		QStringList arguments;
       		arguments << currentDir.path() + "/.delete2MANDVD.sh";
		process_one_shot.setProcessChannelMode ( QProcess::MergedChannels );
		process_one_shot.start( program, arguments );
	}
	if ( mplayerProcess.state() == QProcess::Starting || mplayerProcess.state() == QProcess::Running )
	{
		mplayerProcess.kill();	
	}
	mplayerProcess.waitForFinished(1000);
}

void mainfrm::keyPressEvent( QKeyEvent *k )
{
    	if ( k->key() == Qt::Key_Escape)
    	{
    	}
    	if ( k->key() == Qt::Key_Shift && hdl_current_menu != 0 )
    	{
		hdl_current_menu->shift_press = 1;
    	}
    	if ( k->key() == Qt::Key_Delete && hdl_current_menu != 0 && frame_medias->isVisible() == false && frame_organize->isVisible() == false && frame_editor->isEnabled() == true )
    	{
		hdl_current_menu->supprimer();
    	}
    	if ( k->key() == Qt::Key_Delete && hdl_current_media != 0 && frame_medias->isVisible() == true )
    	{
		hdl_current_media->del_media();
		frame_tooltip_media->hide();
    	}
}

void mainfrm::keyReleaseEvent( QKeyEvent *k )
{
    	if ( k->key() == Qt::Key_Shift && hdl_current_menu != 0 )
    	{
		hdl_current_menu->shift_press = 0;
    	}
}

void mainfrm::extevent()
{
    	if ( hdl_current_menu != 0 )
    	{
		hdl_current_menu->shift_press = 0;
    	}
}

void mainfrm::f_enter_editor_txt()
{
	if ( frame_advanced_text->height() <= 0 && bttxt->isEnabled() == true )
	{
		thread_menu->sens = "O";
		thread_menu->run();
	}
}

void mainfrm::f_close_editor_txt()
{
	if ( frame_advanced_text->height() > 0 )
	{
		thread_menu->sens = "C";
		thread_menu->run();
	}
}

// **************************
// *** GESTION DES MEDIAS ***
// **************************

void mainfrm::f_open_import_media()
{
	// *** OUVERTURE DE LA FENETRE D'IMPORT DES MEDIAS ***

        if ( hdl_current_menu != 0 )
	{
		hdl_current_menu->is_select = 0;
		hdl_current_menu = 0;
		bt_bt_img->setDisabled(true);
		dial_alpha_menu->setDisabled(true);
		combo_quoilire_media->setDisabled(true);
		combo_quoilire_media_chapitre->setDisabled(true);
		combo_select_langue->setDisabled(true);
		combo_quoilire_menu->setDisabled(true);
		bttxt->setDisabled(true);
		frame_th_msk_idea->setDisabled(true);
		bt_tool_1->setDisabled(true);
		bt_tool_2->setDisabled(true);
		bt_tool_3->setDisabled(true);
		bt_tool_4->setDisabled(true);
	}

	f_save_widgetonmenu();

	// *** MISE EN PLACE DES CADENAS SUR MEDIAS UTILISES ***
	wg_int_001=0;
	wg_int_002=0;
	wg_int_003=0; 
	int wl_int_008;

	while ( wg_int_001 <= nbre_medias-1 )
	{
		wg_int_002 = 0;
		wg_int_004 = 0;
		while ( wg_int_002 <= nbre_menuth && wg_int_004 == 0 )
		{
			wg_int_003 = 0;
			while ( table_menus[wg_int_002][wg_int_003][0] != "$$$" && wg_int_004 == 0 )
			{
				if ( table_menus[wg_int_002][wg_int_003][5] == table_hdl_medias[wg_int_001]->pathname_media )
				{
					wg_int_004 = 1;
				}
				wl_int_008 = table_menus[wg_int_002][wg_int_003][22].lastIndexOf( table_hdl_medias[wg_int_001]->pathname_media );
				if ( wl_int_008 != -1 )
				{
					wg_int_004 = 1;
				}
				wg_int_003++;
			}
			wg_int_002++;
		}
		if ( wg_int_004 == 0 )
		{
			table_hdl_medias[wg_int_001]->is_lock = 0;
		}
		else
		{
			table_hdl_medias[wg_int_001]->is_lock = 1;
		}
		wg_int_001++;
	}
	hdl_current_media = 0;
	//
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 2;
	thread_ani->sens = 1;
	thread_ani->isrender = 0;
	mask_interface->show();
	mask_interface->raise();
	frame_medias->show();
	frame_medias->raise();
        QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_open_import_bibmedia()
{
	// *** FENETRE DE RECHERCHE DES MEDIAS ***

	frame_bt_center_media->setDisabled(true);	
	frame_mediatheque->islocked = 1;
	frame_directory->show();
	frame_directory->raise();
}

void mainfrm::f_close_import_bibmedia()
{
	// *** FENETRE DE RECHERCHE DES MEDIAS ***
	frame_mediatheque->islocked = 0;
	frame_bt_center_media->setEnabled(true);	
	frame_directory->hide();
}

void mainfrm::f_close_import_media()
{
	// *** FERMETURE DE LA FENETRE D'IMPORT DES MEDIAS ***
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	// *** AJOUT DES MEDIAS A LA LISTE DES MEDIAS A LIRE ***
	must_update = 0;
	combo_quoilire_media->clear();
	combo_quoilire_media->insertItem(0,wg_str_int_002);
	wg_int_001=0;
	while ( wg_int_001 < nbre_medias )
	{
		hdl_current_media = table_hdl_medias[wg_int_001];
		combo_quoilire_media->insertItem(wg_int_001+1, hdl_current_media->pathname_media);
		combo_quoilire_media->setItemIcon(wg_int_001+1, QIcon(hdl_current_media->miniature));
		wg_int_001++;
	}
	must_update = 1;
	frame_medias->hide();
	hdl_current_media = 0;
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_lecture_console_extract()
{
	Process_Data = process_ident_media.readAllStandardOutput();
	wg_string_001 = wg_string_001 + QString::fromLocal8Bit(Process_Data);
}

void mainfrm::f_ident_media(int, QProcess::ExitStatus)
{
	wg_string_001.replace(QByteArray("\n"), QByteArray(" "));
	wg_string_001.replace(QByteArray("\r"), QByteArray(" "));

      	int i = wg_string_001.indexOf("MPEG-PS", 0);
	int isdvd;
        if ( i != -1 )
        {
		isdvd = 1;
	}
	else
	{
		isdvd = 0;
	}
	// *** IDENTIFICATION DU MEDIA ***
	QString media_width = "";
	QString media_height = "";
	QString media_fps = "";
	QString media_length = "";
	QString media_format = "";
	QString media_audio_channel = "";
	QString media_video_bitrate = "";
	QString media_video_sync = "";

	int j = 0;

	// *** RESOLUTION ***
      	i = wg_string_001.indexOf("ID_VIDEO_WIDTH=", 0);
	if ( i != -1 )
	{
		j = i + 15;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_width = media_width + wg_string_001.mid(j,1);
			j++;
		}
	}
      	i = wg_string_001.indexOf("ID_VIDEO_HEIGHT=", 0);
	if ( i != -1 )
	{
		j = i + 16;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_height = media_height + wg_string_001.mid(j,1);
			j++;
		}
	}

	if ( (media_width.toInt() != 720 || media_height.toInt() != 576) )
	{
		isdvd = 0;
	}

	// *** FPS ***
      	i = wg_string_001.indexOf("ID_VIDEO_FPS=", 0);
	if ( i != -1 )
	{
		j = i + 13;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_fps = media_fps + wg_string_001.mid(j,1);
			j++;
		}
	}

	// *** DUREE DU MEDIA ***
      	i = wg_string_001.indexOf("ID_LENGTH=", 0);
	if ( i != -1 )
	{
		j = i + 10;
		while ( wg_string_001.mid(j,1) != " " && wg_string_001.mid(j,1) != "." )
		{
			media_length = media_length + wg_string_001.mid(j,1);
			j++;
		}
	}

	// *** FORMAT DU MEDIA ***
      	i = wg_string_001.lastIndexOf("ID_VIDEO_ASPECT=");
	if ( i != -1 )
	{
		j = i + 16;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_format = media_format + wg_string_001.mid(j,1);
			j++;
		}
	}

	if (media_format.toFloat() == 0)
	{
		if ( dvd_format == "4/3" )
		{
			media_format = "1.3333";
		}
		else
		{
			media_format = "1.7777";
		}
	}

	// *** NOMBRE DE CANAUX AUDIO ***
      	i = wg_string_001.lastIndexOf("ID_AUDIO_NCH=");
	if ( i != -1 )
	{
		j = i + 13;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_audio_channel = media_audio_channel + wg_string_001.mid(j,1);
			j++;
		}
	}

	// *** NOMBRE DE CANAUX AUDIO ***
      	i = wg_string_001.lastIndexOf("ID_VIDEO_BITRATE=");
	if ( i != -1 )
	{
		j = i + 17;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_video_bitrate = media_video_bitrate + wg_string_001.mid(j,1);
			j++;
		}
	}

	if ( media_video_bitrate == "" || media_video_bitrate == "0" ) //|| media_video_bitrate.toInt() > 5000000 )
	{
		media_video_bitrate = "5000000";
	}

	// *** CODEC AUDIO ***
      	i = wg_string_001.lastIndexOf("ID_AUDIO_CODEC=a52");
	if ( i == -1 )
	{
	      	i = wg_string_001.lastIndexOf("ID_AUDIO_CODEC=ac3");
		if ( i == -1 )
		{
			isdvd = 0;
		}
	}

	// *** NOMBRE DE CANAUX AUDIO ***
      	i = wg_string_001.lastIndexOf("--av_fine_ms");
	if ( i != -1 )
	{
		j = i + 13;
		while ( wg_string_001.mid(j,1) != " " )
		{
			media_video_sync = media_video_sync + wg_string_001.mid(j,1);
			j++;
		}
	}
	if ( media_video_sync != "" && media_video_sync != "0" )
	{
		QMessageBox msgBox;
		msgBox.setText(tr("L'audio et la video ne sont pas synchrones."));
		msgBox.setInformativeText(tr("Voulez vous que le programme les realigne automatiquement lors de la generation ?"));
		msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
		msgBox.setDefaultButton(QMessageBox::Yes);
		int ret = msgBox.exec();

		switch (ret) {
			case QMessageBox::Yes:
				hdl_current_media->wl_video_sync = media_video_sync;
				isdvd = 0;
			break;
			case QMessageBox::No:
				hdl_current_media->wl_video_sync = "";
			break;
		}
	}
	else
	{
		media_video_sync = "";
	}

	// *** SAUVEGARDE DES VALEURS ***
	hdl_current_media->wl_duree = media_length;
	hdl_current_media->wl_width = media_width;
	hdl_current_media->wl_height = media_height;
	hdl_current_media->wl_fps = media_fps;
	hdl_current_media->wl_format = media_format;
	hdl_current_media->wl_audio_channel = media_audio_channel;
	hdl_current_media->isdvd = isdvd;
	hdl_current_media->wl_vbitrate = QString::number(media_video_bitrate.toLong());
	hdl_current_media->wl_vbitrate_encode = hdl_current_media->wl_vbitrate;
	hdl_current_media->wl_video_sync = media_video_sync;

	// *** RECUPERATION TAILLE DU FICHIER ***
	if ( isdvd == 1 )
	{
		QFileInfo fi(hdl_current_media->pathname_media);
		qint64 value = fi.size();
		hdl_current_media->dvdsize = value / 1048576;
	}
	else
	{
		hdl_current_media->dvdsize = (((long)(hdl_current_media->wl_vbitrate_encode.toLong())*(long)hdl_current_media->wl_duree.toInt())/(long)8)/(long)1048576;
	}
	frame_directory->setEnabled(true);
	f_calcul_jauge(hdl_current_media->dvdsize);
	hdl_current_media->repaint();
	nbre_medias++;
}

void mainfrm::f_bt_chapitre_media()
{
	hdl_current_media->cha_media();
}

// ****************************************************
// *** CHANGEMENT DU BITRATE DU MEDIA ET REENCODAGE ***
// ****************************************************

void mainfrm::f_bt_remove_media()
{
	hdl_current_media->del_media();
}

void mainfrm::f_encode_media(media *hdlmedia)
{
	frame_bt_center_media->setDisabled(true);	
	frame_mediatheque->islocked = 1;
	label_actual_bitrate->setText(tr("Bitrate video : ") + QString::number(hdlmedia->wl_vbitrate_encode.toInt()));
	label_taille_video->setText(tr("Taille approximative : ") + QString::number((((long)hdlmedia->wl_vbitrate_encode.toLong()*(long)hdlmedia->wl_duree.toInt())/(long)8)/(long)1048576) + " Mo");
	slider_bitrate->setMaximum(wl_vmax*1000);
	slider_bitrate->setValue(hdlmedia->wl_vbitrate_encode.toLong());
	frame_reencode->show();
	frame_reencode->raise();
}

void mainfrm::f_bitarte_change(int value)
{
	//hdl_current_media->wl_vbitrate_encode = QString::number(value/1000);
	label_actual_bitrate->setText(tr("Bitrate video : ") + QString::number(value));
	label_taille_video->setText(tr("Taille approximative : ") + QString::number((((long)value*(long)hdl_current_media->wl_duree.toInt())/(long)8)/(long)1048576) + " Mo");
}

void mainfrm::f_close_reencode()
{
	if ( hdl_current_media->wl_vbitrate_encode != hdl_current_media->wl_vbitrate )
	{
		hdl_current_media->isdvd = 0;
		hdl_current_media->already_encode = 0;
		hdl_current_media->repaint();
	}

	hdl_current_media->wl_vbitrate_encode = QString::number(slider_bitrate->value());
	f_calcul_jauge(-hdl_current_media->dvdsize);

	hdl_current_media->dvdsize = (((long)(hdl_current_media->wl_vbitrate_encode.toLong())*(long)hdl_current_media->wl_duree.toLong())/(long)8)/(long)1048576;

	f_calcul_jauge(hdl_current_media->dvdsize);
	frame_reencode->hide();
	frame_bt_center_media->setEnabled(true);	
	frame_mediatheque->islocked = 0;
}

void mainfrm::f_delete_media(media *hdlmedia)
{
	// ****************************
	// *** SUPPRESSION DU MEDIA ***
	// ****************************
	QString wl_str_001 = hdlmedia->pathname_media;
	int i=0;
	while ( table_hdl_medias[i] != hdlmedia && i < nbre_medias )
	{
		i++;
	}
	f_calcul_jauge(-hdlmedia->dvdsize);
	bt_open_chapitrage->setDisabled(true);
	bt_remove_media->setDisabled(true);
	//
	if ( table_hdl_medias[i] == hdlmedia )
	{
		delete frame_syno->tab_pnt_media[i];
		int j=i;
		while ( j < nbre_medias-1 )
		{
			table_hdl_medias[j] = table_hdl_medias[j+1];
			frame_syno->tab_pnt_media[j] = frame_syno->tab_pnt_media[j+1];
			j++;
		}
		nbre_medias--;
	}
	else
	{
		qDebug() << "LOGICAL ERROR IN MEMORY WHEN REMOVING A MEDIA";
	}
}

void mainfrm::f_chapitre_media(media *hdlmedia)
{
	// *** OUVERTURE FENETRE CHAPITRAGE DU MEDIA ***

	// **********************************
	// *** RAPPEL CHAPITRAGE DU MEDIA ***
	// **********************************

	lst_chapters->clear();
	lst_chapters_2->clear();

	for (wg_int_001 = 0; wg_int_001 < hdl_current_media->nbre_chapitres; ++wg_int_001) 
	{
		QListWidgetItem *item = new QListWidgetItem(lst_chapters);
		item->setText(hdlmedia->chapitres[wg_int_001]);
		item->setIcon(hdlmedia->icones_chapitres[wg_int_001]);

		QListWidgetItem *item2 = new QListWidgetItem(lst_chapters_2);
		item2->setText(hdlmedia->chapitres[wg_int_001]);
		item2->setIcon(hdlmedia->icones_chapitres[wg_int_001]);
	}

	//
	//frame_medias->hide();
	//mask_interface->hide();
	//frame_editor->hide();

	// *** AFFICHAGE DUREE + AJOUT DES BUTEES DE CONTROLE ***
	QTime wl_time(0,0,0);
	wl_time = wl_time.addSecs(hdlmedia->wl_duree.toInt());

	QPixmap wl_pix_001(":/Interface/Interface/sticker.png");
	QPainter p;
	p.begin(&wl_pix_001);
	QFont myfont("Nimbus Sans L");
	myfont.setPixelSize ( 14 );
	myfont.setBold(true);
	p.setFont(myfont);
	p.setPen(QColor(0,0,0));
	p.drawText(QRect(0,0,wl_pix_001.width(),wl_pix_001.height()), Qt::AlignVCenter | Qt::AlignHCenter, tr("Duree") + "\n" + wl_time.toString("hh:mm:ss"));
	p.end();
	label_sticker_length->setPixmap(wl_pix_001);
	label_sticker_length->show();

	if ( hdlmedia->wl_duree.toInt() < 100 )
	{
		frame_autochap->setDisabled(true);
	}
	else
	{
		frame_autochap->setEnabled(true);
		combo_autochapter->setMaximum(hdlmedia->wl_duree.toInt()/120);
	}

	frame_fond_menu_chapitrage->show();
	frame_reglages->hide();

	slider_player->setStatusTip(hdlmedia->pathname_media);
	frame_chapitrage->show();
	frame_chapitrage->raise();

	// *** LECTURE DU MEDIA ***
	player_open_video(hdlmedia->pathname_media);
}

void mainfrm::f_effets_media(media *hdlmedia)
{
	// *** AFFICHAGE DUREE + AJOUT DES BUTEES DE CONTROLE ***
	label_sticker_length->hide();
	frame_fond_menu_chapitrage->hide();
	frame_reglages->show();

	must_update = 0;

	slider_con->setValue(hdlmedia->contraste);
	slider_bri->setValue(hdlmedia->lumiere);
	slider_sat->setValue(hdlmedia->saturation);

	must_update = 1;

	slider_player->setStatusTip(hdlmedia->pathname_media);
	frame_chapitrage->show();
	frame_chapitrage->raise();

	// *** LECTURE DU MEDIA ***
	player_open_video(hdlmedia->pathname_media);
}

void mainfrm::f_close_effects()
{
	if ( player_isplaying == true )
	{
		mplayerProcess.write("pause \n");
		mplayer_timer->stop();
		player_isplaying = false;
	}
	mplayerProcess.kill();
	if ( hdl_current_media->saturation != slider_sat->value() || hdl_current_media->contraste != slider_con->value() || hdl_current_media->lumiere != slider_bri->value() )
	{
		hdl_current_media->already_encode = 0;
		//hdl_current_media->isdvd = 0;
	}
	hdl_current_media->saturation = slider_sat->value();
	hdl_current_media->contraste = slider_con->value();
	hdl_current_media->lumiere = slider_bri->value();
	must_update = 0;
	frame_chapitrage->hide();
}

void mainfrm::f_select_media(media *hdlmedia, int)
{
	// **************************
	// *** SELECTION DU MEDIA ***
	// **************************

	hdl_current_media = hdlmedia;
	if ( hdl_current_media->is_lock == 0 )
	{
		bt_open_chapitrage->setEnabled(true);
		bt_remove_media->setEnabled(true);
	}
	else
	{
		bt_open_chapitrage->setDisabled(true);
		bt_remove_media->setDisabled(true);
	}

	wg_int_001=0;
	while ( wg_int_001 < nbre_medias )
	{
		if ( table_hdl_medias[wg_int_001] == hdlmedia )
		{
			table_hdl_medias[wg_int_001]->is_select = 1;
		}
		else
		{
			table_hdl_medias[wg_int_001]->is_select = 0;
		}
		table_hdl_medias[wg_int_001]->repaint();
		wg_int_001++;
	}
}

void mainfrm::f_ajoute_label()
{
	// *** NOUVEAU LABEL ***
	f_ajoute_menu_new(100,100,128,128);
	hdl_current_menu->islabel = 1;
	bttxt->setPlainText(tr("Titre"));
	f_update_thumb_menu();
}

// ***********************************
// *** GESTION DES MENUS (BOUTONS) ***
// ***********************************

void mainfrm::f_menu_lower(menu* hdlmenu)
{
	if ( hdlmenu->zindex > 0 )
	{
		int wl_mid_z = hdlmenu->zindex;
		wg_int_002 = 0;
		while ( wg_int_002 < nbre_menus )
		{
			if ( hdlmenu != table_hdl_menus[wg_int_002] )
			{
				if ( table_hdl_menus[wg_int_002]->zindex < wl_mid_z )
				{
					table_hdl_menus[wg_int_002]->zindex = table_hdl_menus[wg_int_002]->zindex++;
				}
			}
			else
			{
				table_hdl_menus[wg_int_002]->zindex = 0;
			}
			wg_int_002++;
		}
		hdlmenu->lower();
		safety_zone->lower();
		background_menu->lower();
	}
}

void mainfrm::f_menu_front(menu* hdlmenu)
{
	if ( hdlmenu->zindex < nbre_menus )
	{
		int wl_mid_z = hdlmenu->zindex;
		wg_int_002 = 0;
		while ( wg_int_002 < nbre_menus )
		{
			if ( hdlmenu != table_hdl_menus[wg_int_002] )
			{
				if ( table_hdl_menus[wg_int_002]->zindex > wl_mid_z )
				{
					table_hdl_menus[wg_int_002]->zindex = table_hdl_menus[wg_int_002]->zindex--;
				}
			}
			else
			{
				table_hdl_menus[wg_int_002]->zindex = nbre_menus-1;
			}
			wg_int_002++;
		}
		hdlmenu->raise();
	}
}

void mainfrm::f_goto_menu(menu* hdlmenu)
{
	if ( hdlmenu->quoilire.mid(3,hdlmenu->quoilire.length()-3) == wg_str_int_003 )
	{
		f_select_menuth(table_hdl_menuth[0]);
	}
	else
	{
		wg_string_001 = hdlmenu->quoilire;
		wg_string_003 = wg_string_001.remove(0,8);
		f_select_menuth(table_hdl_menuth[wg_string_003.toInt()]);
	}
}

void mainfrm::f_redraw_menu(menu*)
{
	f_put_txt_on_bt();
	//hdl_current_menu->repaint();
}

void mainfrm::f_color_overlays()
{
	f_overlay_menu();
}

void mainfrm::f_copy_bt_2()
{
	if ( hdl_current_menu != 0 )
	{
		f_copy_menu(hdl_current_menu);
	}
}

void mainfrm::f_paste_bt_2()
{
	screen_designer->xevent = 100;
	screen_designer->yevent = 100;
	f_paste_menu();
}

void mainfrm::f_copy_menu(menu* hdlmenu)
{
	copy_table_menus[0] = QString::number(hdlmenu->geometry().x());
	copy_table_menus[1] = QString::number(hdlmenu->geometry().y());
	copy_table_menus[2] = QString::number(hdlmenu->width());
	copy_table_menus[3] = QString::number(hdlmenu->height());
	copy_table_menus[4] = hdlmenu->back_image;
	copy_table_menus[5] = hdlmenu->quoilire;
	copy_table_menus[6] = hdlmenu->path_mask;
	copy_table_menus[7] = QString::number(hdlmenu->rotation);
	copy_table_menus[8] = QString::number(hdlmenu->img_x_size);
	copy_table_menus[9] = hdlmenu->quoilirechapitre;
	copy_table_menus[10] = QString::number(hdlmenu->img_y_size);
	copy_table_menus[11] = QString::number(hdlmenu->islabel);
	copy_table_menus[12] = QString::number(hdlmenu->shadow);
	copy_table_menus[13] = hdlmenu->color_mask_over;
	copy_table_menus[14] = QString::number(hdlmenu->anim_thumb);
	copy_table_menus[15] = QString::number(hdlmenu->zindex);
	//copy_table_menus[16] = QString::number(hdlmenu->taborder);
	copy_table_menus[17] = QString::number(hdlmenu->alpha_menu);
	copy_table_menus[18] = hdlmenu->shadow_color + "$" + QString::number(hdlmenu->shadow_opacity) + "$" + QString::number(hdlmenu->shadow_angle) + "$";
	copy_table_menus[19] = hdlmenu->audio_track;
	copy_table_menus[20] = QString::number(hdlmenu->shear_value_x);
	copy_table_menus[21] = QString::number(hdlmenu->shear_value_y);
	copy_table_menus[22] = "";
	copy_table_menus[23] = "";

	QString wl_str_001 = "";

	if ( hdlmenu->isbold == true )
	{
		wl_str_001 = "1";
	}
	else
	{
		wl_str_001 = "0";
	}

	if ( hdlmenu->isitalic == true )
	{
		wl_str_001 = wl_str_001 + "1";
	}
	else
	{
		wl_str_001 = wl_str_001 + "0";
	}

	if ( hdlmenu->isunderline == true )
	{
		wl_str_001 = wl_str_001 + "1";
	}
	else
	{
		wl_str_001 = wl_str_001 + "0";
	}

	wl_str_001 = wl_str_001 + QString::number(hdlmenu->isalign);

	copy_table_menus[24] = wl_str_001;
	screen_designer->is_copy = 1;
	actionColler_le_bouton->setEnabled(true);
}

void mainfrm::f_paste_menu()
{
	if ( nbre_menus < 19 )
	{
		wg_int_001=0;
		while ( table_hdl_menuth[wg_int_001] != hdl_current_menuth && wg_int_001 < nbre_menuth )
		{
			wg_int_001++;
		}

		if ( table_hdl_menuth[wg_int_001] == hdl_current_menuth )
		{
			wg_int_002 = nbre_menus;

			table_menus[wg_int_001][wg_int_002][0] = QString::number(screen_designer->xevent);
			table_menus[wg_int_001][wg_int_002][1] = QString::number(screen_designer->yevent);
			table_menus[wg_int_001][wg_int_002][2] = copy_table_menus[2];
			table_menus[wg_int_001][wg_int_002][3] = copy_table_menus[3];
			table_menus[wg_int_001][wg_int_002][4] = copy_table_menus[4];
			table_menus[wg_int_001][wg_int_002][5] = copy_table_menus[5];
			table_menus[wg_int_001][wg_int_002][6] = copy_table_menus[6];
			table_menus[wg_int_001][wg_int_002][7] = copy_table_menus[7];
			table_menus[wg_int_001][wg_int_002][8] = copy_table_menus[8];
			table_menus[wg_int_001][wg_int_002][9] = copy_table_menus[9];
			table_menus[wg_int_001][wg_int_002][10] = copy_table_menus[10];
			table_menus[wg_int_001][wg_int_002][11] = copy_table_menus[11];
			table_menus[wg_int_001][wg_int_002][12] = copy_table_menus[12];
			table_menus[wg_int_001][wg_int_002][13] = copy_table_menus[13];
			table_menus[wg_int_001][wg_int_002][14] = copy_table_menus[14];
			table_menus[wg_int_001][wg_int_002][15] = QString::number(nbre_menus);
			table_menus[wg_int_001][wg_int_002][16] = QString::number(nbre_menus+1); //nbre_menus_wo_label;
			table_menus[wg_int_001][wg_int_002][17] = copy_table_menus[17];
			table_menus[wg_int_001][wg_int_002][18] = copy_table_menus[18];
			table_menus[wg_int_001][wg_int_002][19] = copy_table_menus[19];
			table_menus[wg_int_001][wg_int_002][20] = copy_table_menus[20];
			table_menus[wg_int_001][wg_int_002][21] = copy_table_menus[21];
			table_menus[wg_int_001][wg_int_002][22] = copy_table_menus[22];
			table_menus[wg_int_001][wg_int_002][23] = copy_table_menus[23];
			table_menus[wg_int_001][wg_int_002][24] = copy_table_menus[24];
	
			f_create_menu_movie();
			if ( hdl_current_menu->islabel == 0 )
			{
				hdl_current_menu->taborder = nbre_menus_wo_label;
			}
		}
	}
	else
	{
		QMessageBox::information(this, name_application, tr("Nombre maximum de boutons sur un menu atteint"));
	}
}

/*void mainfrm::f_put_shadow(int state)
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			hdl_current_menu->shadow = state;
			hdl_current_menu->shadow_color = QString::number(pntwheel4->red) + "^" + QString::number(pntwheel4->green) + "^" + QString::number(pntwheel4->blue) + "^";
			hdl_current_menu->shadow_opacity = dial_opacity_shadow->value();
			hdl_current_menu->shadow_angle = dial_angle_shadow->value();
			f_put_txt_on_bt();
		}
	}
}*/

void mainfrm::f_shadowtext_angle(int angle)
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			hdl_current_menu->shadow_angle = angle;
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_shadowtext_opacity(int value)
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			hdl_current_menu->shadow_opacity = value;
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_put_anim()
{
	if ( check_anim->isChecked() == true )
	{
		f_image_menu_video();
		hdl_current_menu->anim_thumb = 1;
	}
	else
	{
		hdl_current_menu->anim_thumb = 0;
		hdl_current_menu->charge_image(":/Interface/Interface/default_bt.png");
		hdl_current_menu->set_opacity(hdl_current_menu->alpha_menu);
	}
	hdl_current_menu->repaint();
}

void mainfrm::f_ajoute_menu()
{
	// *** NOUVEAU BOUTON MENU ***
	f_ajoute_menu_new(100,100,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_select_menu(hdl_current_menu);
	f_update_thumb_menu();
}

void mainfrm::f_put_txt_on_bt()
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			if ( check_anim->isChecked() == true )
			{
				check_anim->setChecked(false);
			}
			QFont font(font_txt->currentFont());

			if ( hdl_current_menu->isbold == true )
			{
				font.setBold(true);
			}

			if ( hdl_current_menu->isitalic == true )
			{
				font.setItalic(true);
			}

			if ( hdl_current_menu->isunderline == true )
			{
				font.setUnderline(true);
			}

			frame_advanced_text->setEnabled(true);
			QString wl_str_001 = bttxt->toPlainText();
			font.setPixelSize((hdl_current_menu->draw_image.height()-(24*(wl_str_001.count( "\n", Qt::CaseSensitive )+2)))/(wl_str_001.count( "\n", Qt::CaseSensitive )+1));

			// *** RECHERCHE DE LA LIGNE LA PLUS LONGUE ***

			QStringList wl_explode = wl_str_001.split("\n",QString::KeepEmptyParts);
			int wl_int_001 = 0;
			int wl_int_002 = 0;
			int wl_int_003 = 0;

			while ( wl_int_001 < wl_explode.count() )
			{
				if ( wl_explode.at(wl_int_001).length() > wl_int_003 )
				{
					wl_int_003 = wl_explode.at(wl_int_001).length();
					wl_int_002 = wl_int_001;
				}
				wl_int_001++;
			}

			//

			QFontMetrics fm(font);

			int wl_larg_txt = fm.width(wl_explode.at(wl_int_002))+50;

			if ( wl_larg_txt < 50 )
			{
				wl_larg_txt = 50;
			}

			QPixmap wl_pix_001(wl_larg_txt,hdl_current_menu->draw_image.height());
			wl_pix_001.fill(QColor(0,0,0,0));
			QPainter p;
			p.begin(&wl_pix_001);
			p.setRenderHint(QPainter::Antialiasing,true);
			p.setFont(font);

			if ( hdl_current_menu->shadow > 0 )
			{
				QImage wl_ims_1(wl_larg_txt,hdl_current_menu->draw_image.height(),QImage::Format_ARGB32);
				wl_ims_1.fill(0);
				QPainter t;
				t.begin(&wl_ims_1);
				t.setRenderHint(QPainter::Antialiasing,true);
				t.setFont(font);
				t.setPen(QColor(pntwheel4->red,pntwheel4->green,pntwheel4->blue,hdl_current_menu->shadow_opacity));

				int wl_x = 10+(5*cos((M_PI*hdl_current_menu->shadow_angle)/180));
				int wl_y = 10+(5*sin((M_PI*hdl_current_menu->shadow_angle)/180)); 

				t.drawText(QRect(wl_x,wl_y,wl_larg_txt-20,hdl_current_menu->draw_image.height()-20), Qt::AlignVCenter | hdl_current_menu->isalign, bttxt->toPlainText());
				t.end();
				wl_ims_1 = blur_shadow(wl_ims_1);
				p.drawImage(0,0,wl_ims_1,0,0,-1,-1,Qt::AutoColor);
			}

			p.setPen(QColor(pntwheel3->red,pntwheel3->green,pntwheel3->blue));
			p.drawText(QRect(10,10,wl_larg_txt-20,hdl_current_menu->draw_image.height()-20), Qt::AlignVCenter | hdl_current_menu->isalign, bttxt->toPlainText());
			p.end();
			hdl_current_menu->img_x_size = wl_pix_001.width();
			hdl_current_menu->img_y_size = wl_pix_001.height();
			int sx = hdl_current_menu->shear_value_x;
			int sy = hdl_current_menu->shear_value_y;

			if ( hdl_current_menu->shear_value_x < 0 )
			{
				sx = hdl_current_menu->shear_value_x * -1;
			}

			if ( hdl_current_menu->shear_value_y < 0 )
			{
				sy = hdl_current_menu->shear_value_y * -1;
			}

			double angleradian = (M_PI*hdl_current_menu->rotation)/180;
			float mcos = cos(angleradian);
			float msin = sin(angleradian);

			if ( mcos < 0 )
			{
				mcos=mcos*-1;
			}
			if ( msin < 0 )
			{
				msin=msin*-1;
			}

			if ( hdl_current_menu->rotation <= 90)
			{ 
				hdl_current_menu->menu_width = (hdl_current_menu->img_x_size * cos(angleradian))+(hdl_current_menu->img_y_size * sin(angleradian));
				hdl_current_menu->menu_height = (hdl_current_menu->img_y_size * cos(angleradian))+(hdl_current_menu->img_x_size * sin(angleradian));
			}
			else
			{ 
				hdl_current_menu->menu_width = (hdl_current_menu->img_x_size * mcos)+(hdl_current_menu->img_y_size * msin);
				hdl_current_menu->menu_height = (hdl_current_menu->img_x_size * msin)+(hdl_current_menu->img_y_size * mcos);
			}

			//hdl_current_menu->menu_width = hdl_current_menu->menu_width+(sx*3);
			//hdl_current_menu->menu_height = hdl_current_menu->menu_height+(sy*3);

			if ( hdl_current_menu->menu_width >= hdl_current_menu->menu_height )
			{
				hdl_current_menu->menu_width = hdl_current_menu->menu_width+((float)sx*((float)1.2*((float)hdl_current_menu->menu_width/(float)hdl_current_menu->menu_height)));
				hdl_current_menu->menu_height = hdl_current_menu->menu_height+((float)sy*((float)1.2*((float)hdl_current_menu->menu_width/(float)hdl_current_menu->menu_height)));
			}
			else
			{
				hdl_current_menu->menu_width = hdl_current_menu->menu_width+((float)sx*((float)1.2*((float)hdl_current_menu->menu_height/(float)hdl_current_menu->menu_width)));
				hdl_current_menu->menu_height = hdl_current_menu->menu_height+((float)sy*((float)1.2*((float)hdl_current_menu->menu_height/(float)hdl_current_menu->menu_width)));
			}

			if ( is_new_create == 0 )
			{
				//hdl_current_menu->menu_width = ((hdl_current_menu->draw_image.width()+sx) * mcos)+((hdl_current_menu->draw_image.height()+sy) * msin);
				//hdl_current_menu->menu_height = ((hdl_current_menu->draw_image.width()+sx) * msin)+((hdl_current_menu->draw_image.height()+sy) * mcos);

				//hdl_current_menu->img_x_size = hdl_current_menu->menu_width;
				//hdl_current_menu->img_y_size = hdl_current_menu->menu_height;

				hdl_current_menu->menu_x = hdl_current_menu->geometry().x();
				hdl_current_menu->menu_y = hdl_current_menu->geometry().y();
			}
			hdl_current_menu->setGeometry(hdl_current_menu->menu_x,hdl_current_menu->menu_y,hdl_current_menu->menu_width,hdl_current_menu->menu_height);

			hdl_current_menu->draw_image = wl_pix_001; //.scaled(hdl_current_menu->img_x_size,hdl_current_menu->img_y_size);
			hdl_current_menu->original = wl_pix_001;
			hdl_current_menu->set_opacity(hdl_current_menu->alpha_menu);
			hdl_current_menu->anim_thumb = 0;
			hdl_current_menu->repaint();

			hdl_current_menu->back_image = "$TXT$" + QString::number(pntwheel3->red) + "^" + QString::number(pntwheel3->green) + "^" + QString::number(pntwheel3->blue) + "^" + font_txt->currentFont().toString() + "^!" + bttxt->toPlainText();
			if ( hdl_current_menu->path_mask != "" )
			{
				hdl_current_menu->path_mask = "";
				hdl_current_menu->path_over_mask = "";
				hdl_current_menu->color_mask_over = "";
			}
			frame_th_msk_idea->setDisabled(true);
		}
		else
		{
			hdl_current_menu->back_image = "";
			hdl_current_menu->img_x_size = 128;
			hdl_current_menu->img_y_size = 128;
			hdl_current_menu->menu_width = 128;
			hdl_current_menu->menu_height = 128;
			hdl_current_menu->charge_image("");
			hdl_current_menu->path_mask = "";
			hdl_current_menu->path_over_mask = "";
			hdl_current_menu->color_mask_over = "";
			frame_advanced_text->setDisabled(true);
			hdl_current_menu->setGeometry(hdl_current_menu->menu_x,hdl_current_menu->menu_y,hdl_current_menu->menu_width,hdl_current_menu->menu_height);
			hdl_current_menu->repaint();
			frame_th_msk_idea->setEnabled(true);
		}
		hdl_current_menu->set_opacity(hdl_current_menu->alpha_menu);
	}
}

void mainfrm::f_valide_color_txt()
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			f_put_txt_on_bt();
			hdl_current_menu->back_image = "$TXT$" + QString::number(pntwheel3->red) + "^" + QString::number(pntwheel3->green) + "^" + QString::number(pntwheel3->blue) + "^" + font_txt->currentFont().toString() + "^!" + bttxt->toPlainText();
			hdl_current_menu->path_mask = "";
		}
	}
}

void mainfrm::f_valide_color_txt_shadow()
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			f_put_txt_on_bt();
			hdl_current_menu->shadow_color = QString::number(pntwheel4->red) + "^" + QString::number(pntwheel4->green) + "^" + QString::number(pntwheel4->blue) + "^";
		}
	}
}

void mainfrm::f_font_txt_on_bt(QFont)
{
	if ( must_update == 1 )
	{
		if ( bttxt->toPlainText() != "" )
		{
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_fmtfont_txt_on_bt_1()
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu != 0 )
		{
			if ( bt_fmt_1->isChecked() == true )
			{
				hdl_current_menu->isbold = true;
			}
			else
			{
				hdl_current_menu->isbold = false;
			}
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_fmtfont_txt_on_bt_2()
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu != 0 )
		{
			if ( bt_fmt_2->isChecked() == true )
			{
				hdl_current_menu->isitalic = true;
			}
			else
			{
				hdl_current_menu->isitalic = false;
			}
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_fmtfont_txt_on_bt_3()
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu != 0 )
		{
			if ( bt_fmt_3->isChecked() == true )
			{
				hdl_current_menu->isunderline = true;
			}
			else
			{
				hdl_current_menu->isunderline = false;
			}
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_fmtfont_txt_on_bt_4()
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu != 0 )
		{
			hdl_current_menu->isalign = 1;
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_fmtfont_txt_on_bt_5()
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu != 0 )
		{
			hdl_current_menu->isalign = 4;
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_fmtfont_txt_on_bt_6()
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu != 0 )
		{
			hdl_current_menu->isalign = 2;
			f_put_txt_on_bt();
		}
	}
}

void mainfrm::f_dispatch_menu()
{
	// *** FENETRE DISPATCHING AUTO DES BOUTONS ***
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 2;
	thread_ani->sens = 1;
	thread_ani->isrender = 0;
	position_dispatch = 0;
	position_media_dispatch = 9999;
	//
	QPixmap wlpixmap = QPixmap::grabWidget(screen_designer);
	wlpixmap = wlpixmap.scaledToHeight ( 130, Qt::FastTransformation );
	bt_dispatch_1->wl_fond = wlpixmap;
	bt_dispatch_2->wl_fond = wlpixmap;
	bt_dispatch_3->wl_fond = wlpixmap;
	bt_dispatch_4->wl_fond = wlpixmap;
	bt_dispatch_5->wl_fond = wlpixmap;
	//
	combo_typehelp_chapter->setDisabled(true);
	checkBox_typehelp_animated->setDisabled(true);
	checkBox_typehelp_title->setDisabled(true);
	font_txt_dispatch->setDisabled(true);
	wheel_txt_dispatch->setDisabled(true);
	//
	combo_typehelp->clear();
	combo_typehelp_chapter->clear();
	combo_typehelp_chapter->setDisabled(true);
	combo_typehelp->insertItem(0,tr("Boutons vierges"));
	combo_typehelp->setItemIcon(0, QIcon(":/Interface/Interface/default_bt.png"));
	combo_typehelp->insertSeparator( 1 );

	int wl_int_001 = 0;

	while ( wl_int_001 < nbre_medias )
	{
		combo_typehelp->insertItem(wl_int_001+2,table_hdl_medias[wl_int_001]->pathname_media);
		combo_typehelp->setItemIcon(wl_int_001+2, QIcon(table_hdl_medias[wl_int_001]->image));
		wl_int_001++;
	}

	mask_interface->show();
	mask_interface->raise();
	frame_dispatch->show();
	frame_dispatch->raise();
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_combo_typehelp_changed(int valsel)
{
	if ( valsel < 2 )
	{
		combo_typehelp_chapter->clear();
		combo_typehelp_chapter->setDisabled(true);
		checkBox_typehelp_animated->setDisabled(true);
		checkBox_typehelp_title->setDisabled(true);
		font_txt_dispatch->setDisabled(true);
		wheel_txt_dispatch->setDisabled(true);
	}
	else
	{
		combo_typehelp_chapter->clear();
		combo_typehelp_chapter->setEnabled(true);
		position_dispatch = 0;
		position_media_dispatch = 9999;

		int wl_int_001 = 0;

		while ( wl_int_001 < nbre_medias && table_hdl_medias[wl_int_001]->pathname_media != combo_typehelp->currentText())
		{
			wl_int_001++;
		}

		if ( table_hdl_medias[wl_int_001]->pathname_media == combo_typehelp->currentText() )
		{
			int wl_int_002 = 0;
			position_media_dispatch = wl_int_001;
			while ( wl_int_002 < table_hdl_medias[wl_int_001]->nbre_chapitres )
			{
				combo_typehelp_chapter->insertItem(wl_int_002,table_hdl_medias[wl_int_001]->chapitres[wl_int_002]);
				combo_typehelp_chapter->setItemIcon(wl_int_002, QIcon(table_hdl_medias[wl_int_001]->icones_chapitres[wl_int_002]));
				wl_int_002++;
			}
			if ( wl_int_002 > 0 )
			{
				combo_typehelp_chapter->setEnabled(true);
				checkBox_typehelp_animated->setEnabled(true);
				checkBox_typehelp_title->setEnabled(true);
				font_txt_dispatch->setEnabled(true);
				wheel_txt_dispatch->setEnabled(true);
			}
			else
			{
				combo_typehelp_chapter->setDisabled(true);
				checkBox_typehelp_animated->setEnabled(true);
				checkBox_typehelp_title->setEnabled(true);
				font_txt_dispatch->setEnabled(true);
				wheel_txt_dispatch->setEnabled(true);
			}
		}
	}
}

void mainfrm::f_combo_typehelpchapter_changed(int valsel)
{
	position_dispatch = valsel;
}

void mainfrm::f_dispatch_declare()
{
	if ( hdl_current_menu != 0 && combo_typehelp->currentIndex() > 1 && position_media_dispatch != 9999 )
	{
		if ( position_dispatch < combo_typehelp_chapter->count() )
		{
			hdl_current_menu->quoilire = combo_typehelp->currentText();

			hdl_current_menu->quoilirechapitre = combo_typehelp_chapter->itemText(position_dispatch);
			// *** MINIATURE DU CHAPITRE ***
			//hdl_current_menu->draw_image = table_hdl_medias[position_media_dispatch]->miniature.scaledToWidth(hdl_current_menu->img_x_size,Qt::FastTransformation);
			hdl_current_menu->draw_image = table_hdl_medias[position_media_dispatch]->icones_chapitres[position_dispatch].pixmap( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height(), QIcon::Normal, QIcon::On );
			hdl_current_menu->original = table_hdl_medias[position_media_dispatch]->icones_chapitres[position_dispatch].pixmap( 500, 500 / (hdl_current_menu->draw_image.width()/hdl_current_menu->draw_image.height()), QIcon::Normal, QIcon::On );

			hdl_current_menu->charge_image("EXT_VIDEO_EXT");
			hdl_current_menu->back_image="EXT_VIDEO_EXT";

			if ( checkBox_typehelp_animated->isChecked() == true )
			{
				hdl_current_menu->anim_thumb = 1;
			}
			else
			{
				hdl_current_menu->anim_thumb = 0;
			}

			if ( checkBox_typehelp_title->isChecked() == true )
			{
				f_ajoute_menu_new(hdl_current_menu->geometry().x(),hdl_current_menu->geometry().y()+hdl_current_menu->img_y_size+40,hdl_current_menu->width(),60);
				hdl_current_menu->islabel = 1;
				QPixmap wl_pix_001(hdl_current_menu->width(),60);
				wl_pix_001.fill(QColor(0,0,0,0));
				QPainter p;
				p.begin(&wl_pix_001);
				p.setRenderHint(QPainter::Antialiasing,true);
				p.setFont(font_txt_dispatch->currentFont());
				p.setPen(QColor(pntwheel5->red,pntwheel5->green,pntwheel5->blue));
				p.drawText(QRect(0,0,hdl_current_menu->width(),60), Qt::AlignVCenter | Qt::AlignLeft, table_hdl_medias[position_media_dispatch]->chapitres[position_dispatch]);
				p.end();

				hdl_current_menu->img_x_size = wl_pix_001.width();
				hdl_current_menu->img_y_size = wl_pix_001.height();
				hdl_current_menu->draw_image = wl_pix_001; //.scaled(hdl_current_menu->img_x_size,hdl_current_menu->img_y_size);
				hdl_current_menu->original = wl_pix_001;
				hdl_current_menu->anim_thumb = 0;
				hdl_current_menu->repaint();

				hdl_current_menu->back_image = "$TXT$" + QString::number(pntwheel5->red) + "^" + QString::number(pntwheel5->green) + "^" + QString::number(pntwheel5->blue) + "^" + font_txt_dispatch->currentFont().toString() + "^!" + table_hdl_medias[position_media_dispatch]->chapitres[position_dispatch];  //166;195;310;128;*;;;0;310;;128;0;0;;0;0;1;255;0^0^0^$255$0$;
//$TXT$255^255^255^Myriad Apple [adobe],9,-1,5,50,0,0,0,0,0^!coucou
				hdl_current_menu->path_mask = "";
				hdl_current_menu->path_over_mask = "";
				hdl_current_menu->color_mask_over = "";
				hdl_current_menu->setGeometry(hdl_current_menu->geometry().x(),hdl_current_menu->geometry().y(),hdl_current_menu->width(),hdl_current_menu->img_y_size);
				frame_th_msk_idea->setDisabled(true);
			}
			position_dispatch++;
		}
		else
		{
			if ( position_dispatch == 0 )
			{
				hdl_current_menu->quoilire = combo_typehelp->currentText();

				hdl_current_menu->quoilirechapitre = wg_str_int_001;
				// *** MINIATURE DU CHAPITRE ***
				//hdl_current_menu->draw_image = table_hdl_medias[position_media_dispatch]->miniature.scaledToWidth(hdl_current_menu->img_x_size,Qt::FastTransformation);
				hdl_current_menu->draw_image = table_hdl_medias[position_media_dispatch]->miniature.scaled( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height());
				hdl_current_menu->original = table_hdl_medias[position_media_dispatch]->miniature;

				hdl_current_menu->charge_image("EXT_VIDEO_EXT");
				hdl_current_menu->back_image="EXT_VIDEO_EXT";

				if ( checkBox_typehelp_animated->isChecked() == true )
				{
					hdl_current_menu->anim_thumb = 1;
				}
				else
				{
					hdl_current_menu->anim_thumb = 0;
				}

				if ( checkBox_typehelp_title->isChecked() == true )
				{
					f_ajoute_menu_new(hdl_current_menu->geometry().x(),hdl_current_menu->geometry().y()+hdl_current_menu->img_y_size+40,hdl_current_menu->width(),60);
					hdl_current_menu->islabel = 1;
					QPixmap wl_pix_001(hdl_current_menu->width(),60);
					wl_pix_001.fill(QColor(0,0,0,0));
					QPainter p;
					p.begin(&wl_pix_001);
					p.setRenderHint(QPainter::Antialiasing,true);
					p.setFont(font_txt_dispatch->currentFont());
					p.setPen(QColor(pntwheel5->red,pntwheel5->green,pntwheel5->blue));
					int wl2_int_001 = table_hdl_medias[position_media_dispatch]->pathname_media.lastIndexOf( '/' );

					p.drawText(QRect(0,0,hdl_current_menu->width(),60), Qt::AlignVCenter | Qt::AlignLeft, table_hdl_medias[position_media_dispatch]->pathname_media.mid(wl2_int_001 + 1, table_hdl_medias[position_media_dispatch]->pathname_media.length() - (wl2_int_001 + 1)));
					p.end();

					hdl_current_menu->img_x_size = wl_pix_001.width();
					hdl_current_menu->img_y_size = wl_pix_001.height();
					hdl_current_menu->draw_image = wl_pix_001; //.scaled(hdl_current_menu->img_x_size,hdl_current_menu->img_y_size);
					hdl_current_menu->original = wl_pix_001;
					hdl_current_menu->anim_thumb = 0;
					hdl_current_menu->repaint();

					hdl_current_menu->back_image = "$TXT$" + QString::number(pntwheel5->red) + "^" + QString::number(pntwheel5->green) + "^" + QString::number(pntwheel5->blue) + "^" + font_txt_dispatch->currentFont().toString() + "^!" + table_hdl_medias[position_media_dispatch]->pathname_media.mid(wl2_int_001 + 1, table_hdl_medias[position_media_dispatch]->pathname_media.length() - (wl2_int_001 + 1));  
					hdl_current_menu->path_mask = "";
					hdl_current_menu->path_over_mask = "";
					hdl_current_menu->color_mask_over = "";
					hdl_current_menu->setGeometry(hdl_current_menu->geometry().x(),hdl_current_menu->geometry().y(),hdl_current_menu->width(),hdl_current_menu->img_y_size);
					frame_th_msk_idea->setDisabled(true);
				}

			}
		}
	}
}

void mainfrm::f_dispatch_1()
{
	int wl_int_001 = (dvdxsize-296)/2;
	int wl_int_002 = (dvdysize-128)/2;

	f_ajoute_menu_new(wl_int_001,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();

	f_ajoute_menu_new(wl_int_001+168,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();

	//
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	frame_dispatch->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_dispatch_2()
{
	int wl_int_001 = (dvdxsize-296)/2;
	int wl_int_002 = (dvdysize-296)/2;
	f_ajoute_menu_new(wl_int_001,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+168,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+84,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	//
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	frame_dispatch->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_dispatch_3()
{
	int wl_int_001 = (dvdxsize-296)/2;
	int wl_int_002 = (dvdysize-296)/2;
	f_ajoute_menu_new(wl_int_001,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+168,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+168,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	//
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	frame_dispatch->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_dispatch_4()
{
	int wl_int_001 = (dvdxsize-464)/2;
	int wl_int_002 = (dvdysize-296)/2;
	f_ajoute_menu_new(wl_int_001,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+168,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+336,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+84,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+252,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	//
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	frame_dispatch->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_dispatch_5()
{
	int wl_int_001 = (dvdxsize-464)/2;
	int wl_int_002 = (dvdysize-296)/2;
	f_ajoute_menu_new(wl_int_001,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+168,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+336,wl_int_002,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+168,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	f_ajoute_menu_new(wl_int_001+336,wl_int_002+192,128,128);
	hdl_current_menu->islabel = 0;
	nbre_menus_wo_label++;
	hdl_current_menu->taborder = nbre_menus_wo_label;
	f_dispatch_declare();
	//
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	frame_dispatch->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_cancel_dispatch()
{
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 240;
	thread_ani->sens = 0;
	frame_dispatch->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_select_menu(menu *hdlmenu)
{
	// *** SELECTION DU MENU ET AFFICHAGE DES VALEURS ***
	must_update = 0;
	wg_int_001 = 0;
	while ( wg_int_001 < nbre_menus )
	{
		if ( h_regle->isVisible() == true )
		{
			table_hdl_menus[wg_int_001]->is_ruler = 1;
		}
		else
		{
			table_hdl_menus[wg_int_001]->is_ruler = 0;
		}

		if ( table_hdl_menus[wg_int_001] == hdlmenu )
		{
			table_hdl_menus[wg_int_001]->is_select = 1;
		}
		else
		{
			table_hdl_menus[wg_int_001]->is_select = 0;
		}
		table_hdl_menus[wg_int_001]->repaint();
		wg_int_001++;
	}
	bt_bt_img->setEnabled(true);
	dial_alpha_menu->setEnabled(true);
	bttxt->setEnabled(true);

	// *** EXTRACTION POUR LE CAS D'UN BOUTON TEXTE ***
	wg_string_001 = hdlmenu->back_image;
	wg_string_002 = "";
	if ( wg_string_001.mid(0,5) == "$TXT$" )
	{
		wg_int_001 = 5;
		wg_int_002 = 0;
		while ( wg_string_001.mid(wg_int_001,1) != "!" && wg_int_002 < 4 )
		{
			if ( wg_string_001.mid(wg_int_001,1) == "^" )
			{
				if ( wg_int_002 == 0 )
				{
					pntwheel3->red = wg_string_002.toInt();
					wg_string_002 = "";
				}
				if ( wg_int_002 == 1 )
				{
					pntwheel3->green = wg_string_002.toInt();
					wg_string_002 = "";
				}
				if ( wg_int_002 == 2 )
				{
					pntwheel3->blue = wg_string_002.toInt();
					wg_string_002 = "";
					pntwheel3->setColor(pntwheel3->red,pntwheel3->green,pntwheel3->blue);
				}
				if ( wg_int_002 == 3 )
				{
					font_txt->setCurrentFont(QFont(wg_string_002));
				}
				wg_int_002++;
			}
			else
			{
				wg_string_002 = wg_string_002 + wg_string_001.mid(wg_int_001,1);
			}
			wg_int_001++;
		}

		QString wl_string_001 = hdlmenu->shadow_color;
		wg_string_002 = "";
		int wl_int_001 = 0;
		wg_int_002 = 0;
		if ( wl_string_001.length() > 0 )
		{
			while ( wg_int_002 < 3 )
			{
				if ( wl_string_001.mid(wl_int_001,1) == "^" )
				{
					if ( wg_int_002 == 0 )
					{
						pntwheel4->red = wg_string_002.toInt();
						wg_string_002 = "";
					}
					if ( wg_int_002 == 1 )
					{
						pntwheel4->green = wg_string_002.toInt();
						wg_string_002 = "";
					}
					if ( wg_int_002 == 2 )
					{
						pntwheel4->blue = wg_string_002.toInt();
						wg_string_002 = "";
						pntwheel4->setColor(pntwheel4->red,pntwheel4->green,pntwheel4->blue);
					}
					wg_int_002++;
				}
				else
				{
					wg_string_002 = wg_string_002 + wl_string_001.mid(wl_int_001,1);
				}
				wl_int_001++;
			}
		}
		else
		{
		}

		bttxt->setPlainText(wg_string_001.mid(wg_int_001+1,wg_string_001.length() - wg_int_001));
		frame_th_msk_idea->setDisabled(true);
	}
	else
	{
		bttxt->setPlainText("");
		frame_th_msk_idea->setEnabled(true);
	}

	dial_angle_shadow->setValue(hdlmenu->shadow_angle);
	dial_opacity_shadow->setValue(hdlmenu->shadow_opacity);

	if ( hdlmenu->isbold == true )
	{
		bt_fmt_1->setChecked(true);
	}
	else
	{
		bt_fmt_1->setChecked(false);
	}

	if ( hdlmenu->isitalic == true )
	{
		bt_fmt_2->setChecked(true);
	}
	else
	{
		bt_fmt_2->setChecked(false);
	}

	if ( hdlmenu->isunderline == true )
	{
		bt_fmt_3->setChecked(true);
	}
	else
	{
		bt_fmt_3->setChecked(false);
	}

	if ( hdlmenu->isalign == 1 )
	{
		bt_fmt_4->setChecked(true);
	}
	else
	{
		if ( hdlmenu->isalign == 2 )
		{
			bt_fmt_5->setChecked(true);
		}
		else
		{
			if ( hdlmenu->isalign == 4 )
			{
				bt_fmt_6->setChecked(true);
			}
		}	
	}

	if ( hdlmenu->anim_thumb == 0 )
	{
		check_anim->setChecked(false);
	}
	else
	{
		check_anim->setChecked(true);
	}

	frame_th_msk_idea->setEnabled(true);

	// *** AFFICHAGE DES VALEURS ***

	if ( hdlmenu->quoilire.mid(0,3) != "!M!" )
	{
		if ( hdlmenu->islabel == 0 )
		{
			if ( combo_quoilire_media->findText( hdlmenu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive) > 0 )
			{
				combo_quoilire_media->setCurrentIndex(combo_quoilire_media->findText( hdlmenu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive));
				// *** CHARGEMENT DES CHAPITRES S'ILS EXISTENT ***
				wg_int_001=0;
				wg_int_002=0;
				while ( wg_int_001 < nbre_medias && wg_int_002 == 0 )
				{
					if ( table_hdl_medias[wg_int_001]->pathname_media == combo_quoilire_media->currentText() )
					{
						wg_int_002 = 1;
					}
					else
					{
						wg_int_001++;
					}
				}
				if ( wg_int_002 == 1 && table_hdl_medias[wg_int_001]->nbre_chapitres > 0 )
				{
					combo_quoilire_media_chapitre->clear();
					combo_quoilire_media_chapitre->insertItem(0,wg_str_int_001);
					for (wg_int_003 = 0; wg_int_003 < table_hdl_medias[wg_int_001]->nbre_chapitres; ++wg_int_003) 
					{
						combo_quoilire_media_chapitre->insertItem(wg_int_003+1,table_hdl_medias[wg_int_001]->chapitres[wg_int_003]);
						combo_quoilire_media_chapitre->setItemIcon(wg_int_003+1, QIcon(table_hdl_medias[wg_int_001]->icones_chapitres[wg_int_003]));
					}
					combo_quoilire_media_chapitre->setEnabled(true);
				}
				else
				{
					combo_quoilire_media_chapitre->clear();
					combo_quoilire_media_chapitre->insertItem(0,wg_str_int_001);
					combo_quoilire_media_chapitre->setDisabled(true);
				}
				combo_quoilire_media_chapitre->setCurrentIndex(combo_quoilire_media_chapitre->findText( hdlmenu->quoilirechapitre, Qt::MatchExactly | Qt::MatchCaseSensitive));

				if ( combo_quoilire_media->currentIndex() > 0 )
				{
					combo_quoilire_menu->setDisabled(true);
					combo_quoilire_menu->setCurrentIndex(0);
					combo_quoilire_media->setEnabled(true);
					combo_select_langue->setEnabled(true);
					check_anim->setEnabled(true);
				}
				else
				{
					combo_quoilire_media->setEnabled(true);
					combo_quoilire_media_chapitre->setDisabled(true);
					combo_quoilire_media_chapitre->setCurrentIndex(0);
					combo_select_langue->setEnabled(true);
					combo_quoilire_menu->setEnabled(true);
					check_anim->setDisabled(true);
				}
			}
			else
			{
				combo_quoilire_media_chapitre->clear();
				combo_quoilire_media->setCurrentIndex(0);
				combo_quoilire_menu->setCurrentIndex(0);
				combo_quoilire_menu->setEnabled(true);
				combo_quoilire_media->setEnabled(true);
				combo_select_langue->setDisabled(true);
				combo_quoilire_media_chapitre->setDisabled(true);
				check_anim->setDisabled(true);
			}
		}
		else
		{
			frame_th_msk_idea->setDisabled(true);
			combo_quoilire_media_chapitre->clear();
			combo_quoilire_media->setCurrentIndex(0);
			combo_quoilire_menu->setCurrentIndex(0);
			combo_quoilire_menu->setDisabled(true);
			combo_quoilire_media->setDisabled(true);
			combo_quoilire_media_chapitre->setDisabled(true);
			check_anim->setDisabled(true);
		}
	}
	else
	{
		//if ( hdlmenu->quoilire.mid(0,3) == "!M!" )
		//{
			if ( combo_quoilire_menu->findText( hdlmenu->quoilire.mid(3,hdlmenu->quoilire.length()-3), Qt::MatchExactly | Qt::MatchCaseSensitive) >= 0 && hdlmenu->quoilire.mid(3,hdlmenu->quoilire.length()-3) != wg_str_int_002 )
			{
				combo_quoilire_menu->setCurrentIndex(combo_quoilire_menu->findText( hdlmenu->quoilire.mid(3,hdlmenu->quoilire.length()-3), Qt::MatchExactly | Qt::MatchCaseSensitive));
				combo_quoilire_media->setCurrentIndex(0);
				combo_quoilire_media->setDisabled(true);
				check_anim->setDisabled(true);
				combo_quoilire_media_chapitre->clear();
				combo_quoilire_media_chapitre->setDisabled(true);
				combo_quoilire_media_chapitre->setCurrentIndex(0);
				combo_quoilire_menu->setEnabled(true);
				combo_select_langue->setDisabled(true);
			}
			else
			{
				hdlmenu->quoilire = "";
				combo_quoilire_media_chapitre->clear();
				combo_quoilire_menu->setCurrentIndex(0);
				combo_quoilire_media->setCurrentIndex(0);
				combo_quoilire_media->setEnabled(true);
				combo_quoilire_menu->setEnabled(true);
				check_anim->setDisabled(true);
				combo_select_langue->setDisabled(true);
			}
		/*}
		else
		{
			combo_quoilire_media->setEnabled(true);
			combo_quoilire_menu->setEnabled(true);
			check_anim->setDisabled(true);
		}*/
	}
	// *** OPACITE ***
	dial_alpha_menu->setValue(hdlmenu->alpha_menu);

	// *** LANGUAGE ***
	f_display_language();
	if ( hdlmenu->audio_track != "" )
	{
		if ( combo_select_langue->findText( hdlmenu->audio_track, Qt::MatchExactly | Qt::MatchCaseSensitive) >= 0 )
		{
			combo_select_langue->setCurrentIndex(combo_select_langue->findText( hdlmenu->audio_track, Qt::MatchExactly | Qt::MatchCaseSensitive));
		}
		else
		{
			combo_select_langue->setCurrentIndex(-1);
		}
	}
	else
	{
		combo_select_langue->setCurrentIndex(-1);
	}

	// *** ON DEVEROUILLE LE PANNEAU D'EDITION ***
	bt_tool_1->setEnabled(true);
	bt_tool_2->setEnabled(true);
	bt_tool_3->setEnabled(true);
	bt_tool_4->setEnabled(true);

	hdl_current_menu = hdlmenu;
	actionCopier_le_bouton->setEnabled(true);
	hdl_current_menu->tool = current_tool;
	must_update = 1;
	// *** QUE FAIRE DES PROPRIETES SUP DU TEXTE ***
	if ( wg_string_001.mid(0,5) == "$TXT$" )
	{
		f_enter_editor_txt();
	}
	else
	{
		f_close_editor_txt();	
	}
	//
	f_affiche_info_pos(hdl_current_menu);
	hdl_current_menu->change_cursor();
}

void mainfrm::f_image_menu()
{
	// *** CHOIX DE L'IMAGE DU BOUTON MENU ***

	top_window->setDisabled(true);
	frame_pro->setDisabled(true);

	menuProjet->setDisabled(true);
	menuMenu->setDisabled(true);
	menuAffichage->setDisabled(true);
	menuG_n_ration->setDisabled(true);
	menuEdition->setDisabled(true);
	actionMenu_pr_c_dent->setDisabled(true);
	actionMenu_suivant->setDisabled(true);
	actionCouleurs_des_overlays->setDisabled(true);
	actionParam_tres_avanc_s->setDisabled(true);
	menuA_propos->setDisabled(true);
	frame_editor->setDisabled(true);

	frame_lst_menus->hide();

	myfileopen *hdlfopen = new myfileopen(this);
	hdlfopen->setDirectory(path_background);
	hdlfopen->source = 1;
	hdlfopen->setWindowTitle(tr("Image du bouton"));
	hdlfopen->setFilter("(*.PNG *.png *.jpg *.JPG *.jeg *.JPEG *.MPG *.mpg *.AVI *.avi *.gif *.GIF)");
	connect(hdlfopen, SIGNAL(change_image(QString)),this, SLOT(f_open_ipreview(QString)));
	connect(hdlfopen, SIGNAL(filesSelected( const QStringList )),this, SLOT(f_close_ipreview( const QStringList )));
	connect(hdlfopen, SIGNAL(f_close()),this, SLOT(f_cancel_ipreview()));
	connect(hdlfopen, SIGNAL(finished(int)),this, SLOT(f_cancel_ipreview()));

	pntfiled = hdlfopen;

	hdlfopen->show();
	hdlfopen->raise();
}

void mainfrm::f_image_menu_video()
{
	// *** RECUPERATION DE L'IMAGE DE LA VIDEO ASSOCIEE AU BOUTON MENU ***

	wg_int_001=0;
	while ( wg_int_001 < nbre_medias && table_hdl_medias[wg_int_001]->pathname_media != combo_quoilire_media->currentText() )
	{
		wg_int_001++;
	}

	if ( wg_int_001 < nbre_medias )
	{
		if ( table_hdl_medias[wg_int_001]->pathname_media == combo_quoilire_media->currentText() )
		{
			if ( combo_quoilire_media_chapitre->currentIndex() <= 0 )
			{
				// *** IMAGE TOTALITE DU MEDIA ***
				hdl_current_menu->draw_image = table_hdl_medias[wg_int_001]->miniature.scaledToWidth(hdl_current_menu->img_x_size,Qt::FastTransformation);
				hdl_current_menu->original = table_hdl_medias[wg_int_001]->miniature;
			}
			else
			{
				// *** MINIATURE DU CHAPITRE ***
				hdl_current_menu->draw_image = table_hdl_medias[wg_int_001]->miniature.scaledToWidth(hdl_current_menu->img_x_size,Qt::FastTransformation);
				hdl_current_menu->draw_image = table_hdl_medias[wg_int_001]->icones_chapitres[combo_quoilire_media_chapitre->currentIndex()-1].pixmap( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height(), QIcon::Normal, QIcon::On );
				hdl_current_menu->original = table_hdl_medias[wg_int_001]->icones_chapitres[combo_quoilire_media_chapitre->currentIndex()-1].pixmap( 500, 500 / (hdl_current_menu->draw_image.width()/hdl_current_menu->draw_image.height()), QIcon::Normal, QIcon::On );
			}
			hdl_current_menu->charge_image("EXT_VIDEO_EXT");
			hdl_current_menu->back_image="EXT_VIDEO_EXT";
			must_update = 0;
			if ( hdl_current_menu->anim_thumb != 0 )
			{
				hdl_current_menu->anim_thumb = 0;
				check_anim->setChecked(false);
			}
			bttxt->setPlainText("");
			must_update = 1;
			if ( hdl_current_menu->path_mask != "" )
			{
				hdl_current_menu->charge_mask(hdl_current_menu->path_mask);
			}
		}
		else
		{
			qDebug() << "LOGICAL ERROR IN MEMORY WHEN SEARCHING MEDIA FOR PICTURE BUTTON";
		}
	}
}

void mainfrm::f_select_mask()
{
	// *** SELECTION DU MASK DU BOUTON ***
	QList<QListWidgetItem *> selectmsk = frame_th_msk_idea->selectedItems();
	QListWidgetItem *msktxt = new QListWidgetItem;
	msktxt = selectmsk.at(0);

	if ( msktxt->text() != wg_str_int_004 )
	{
		hdl_current_menu->charge_mask(qApp->applicationDirPath()+"/Bibliotheque/Masks/" + msktxt->text() + ".png");
	}
	else
	{
		hdl_current_menu->path_mask = "";
		hdl_current_menu->path_over_mask = "";
		hdl_current_menu->draw_image = hdl_current_menu->original.scaled( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height(), Qt::IgnoreAspectRatio, Qt::FastTransformation );
		hdl_current_menu->set_opacity(hdl_current_menu->alpha_menu);
		hdl_current_menu->repaint();
	}
	frame_th_msk_idea->clearSelection();
}

void mainfrm::f_menu_zoom()
{
	// *** OUTILS SCALE ***
	hdl_current_menu->tool = 0;
	current_tool = 0;
}

void mainfrm::f_menu_rotate()
{
	// *** OUTILS ROTATE ***
	hdl_current_menu->tool = 1;
	current_tool = 1;
}

void mainfrm::f_menu_grab()
{
	// *** OUTILS GRAB ***
	hdl_current_menu->tool = 2;
	current_tool = 2;
}

void mainfrm::f_menu_shear()
{
	// *** OUTILS SHEAR ***
	hdl_current_menu->tool = 3;
	current_tool = 3;
}

void mainfrm::f_quoilire_chapitre_changed(int)
{
	if ( must_update == 1 )
	{
		hdl_current_menu->quoilirechapitre = combo_quoilire_media_chapitre->currentText();
		if ( hdl_current_menu->back_image == "EXT_VIDEO_EXT" )
		{
			f_image_menu_video();
			hdl_current_menu->repaint();
		}
	}
}

void mainfrm::f_quoilire_audio_changed(int)
{
	if ( must_update == 1 )
	{
		hdl_current_menu->audio_track = combo_select_langue->currentText();
	}
}

void mainfrm::f_quoilire_menu_changed(int indexsel)
{
	if ( must_update == 1 )
	{
		if ( indexsel > 0 )
		{
			hdl_current_menu->quoilire = "!M!" + combo_quoilire_menu->currentText();
			combo_quoilire_media->setCurrentIndex(0);
			combo_quoilire_media->setDisabled(true);
			check_anim->setDisabled(true);
		}
		else
		{
			hdl_current_menu->quoilire = "";
			combo_quoilire_media->setCurrentIndex(0);
			combo_quoilire_media->setEnabled(true);
			check_anim->setDisabled(true);
		}
	}
}

void mainfrm::f_quoilire_changed(int indexsel)
{
	// *** QUOI LIRE COMME VIDEO SUR CLIC DU BOUTON ***
	if ( must_update == 1 )
	{
		int ret;
		if ( hdl_current_menu->quoilire != combo_quoilire_media->currentText() && hdl_current_menu->back_image == "EXT_VIDEO_EXT" )
		{
			if ( hdl_current_menu->quoi_faire != "" && indexsel == 0 )
			{
				QMessageBox msgBox;
				msgBox.setText("ATTENTION PLAYLIST");
				msgBox.setInformativeText(tr("Ce bouton contient une playlist qui sera perdue si vous changez l'association a ce media. Etes vous sur de vouloir continuer ?"));
				msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
				msgBox.setDefaultButton(QMessageBox::Yes);
				ret = msgBox.exec();
				switch (ret) {
					case QMessageBox::Yes:
						hdl_current_menu->quoi_faire = "";
						hdl_current_menu->back_image = "";
						hdl_current_menu->charge_image("");
						hdl_current_menu->repaint();
						break;
					case QMessageBox::No:
						must_update = 0;
						if ( combo_quoilire_media->findText( hdl_current_menu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive) > 0 )
						{
							combo_quoilire_media->setCurrentIndex(combo_quoilire_media->findText( hdl_current_menu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive));
						}
						else
						{
							qDebug() << "ERROR FINDING JUMPING MEDIA WHEN CONTROL PLAYLIST";
						}
						must_update = 1;
						return;
						break;
					default:
						break;
				}
			}
			//else
			//{
				//f_image_menu_video();
				//hdl_current_menu->back_image = "";
				//hdl_current_menu->charge_image("");
				//hdl_current_menu->repaint();
			//}
		}

		if ( indexsel > 0 )
		{
			combo_quoilire_menu->setCurrentIndex(0);
			combo_quoilire_menu->setDisabled(true);
			hdl_current_menu->quoilire = combo_quoilire_media->currentText();
			check_anim->setEnabled(true);
		}
		else
		{
			if ( hdl_current_menu->quoi_faire != "" )
			{
				QMessageBox msgBox;
				msgBox.setText("ATTENTION PLAYLIST");
				msgBox.setInformativeText(tr("Ce bouton contient une playlist qui sera perdue si vous changez l'association a ce media. Etes vous sur de vouloir continuer ?"));
				msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
				msgBox.setDefaultButton(QMessageBox::Yes);
				ret = msgBox.exec();
				switch (ret) {
					case QMessageBox::Yes:
						hdl_current_menu->quoi_faire = "";
						hdl_current_menu->quoilire = "";
						hdl_current_menu->quoilirechapitre = "";
						combo_quoilire_menu->setCurrentIndex(0);
						combo_quoilire_menu->setEnabled(true);
						check_anim->setDisabled(true);
						check_anim->setChecked(false);
						break;
					case QMessageBox::No:
						must_update = 0;
						if ( combo_quoilire_media->findText( hdl_current_menu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive) > 0 )
						{
							//qDebug() << hdl_current_menu->quoilire << " " << combo_quoilire_media->findText( hdl_current_menu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive);
							combo_quoilire_media->setCurrentIndex(combo_quoilire_media->findText( hdl_current_menu->quoilire, Qt::MatchExactly | Qt::MatchCaseSensitive));
						}
						else
						{
							qDebug() << "ERROR FINDING JUMPING MEDIA WHEN CONTROL PLAYLIST";
						}
						must_update = 1;
						return;
						break;
					default:
						break;
				}
			}
			else
			{
				hdl_current_menu->quoi_faire = "";
				hdl_current_menu->quoilire = "";
				hdl_current_menu->quoilirechapitre = "";
				combo_quoilire_menu->setCurrentIndex(0);
				combo_quoilire_menu->setEnabled(true);
				check_anim->setDisabled(true);
				check_anim->setChecked(false);
			}
		}

		// *** RECHERCHE DU MEDIA POUR VOIR S'IL Y A DES CHAPITRES ***
		int wl_int_001=0;
		int wl_int_002=0;
		int wl_int_003=0;
		while ( wl_int_001 < nbre_medias && wl_int_002 == 0 )
		{
			if ( table_hdl_medias[wl_int_001]->pathname_media == combo_quoilire_media->currentText() )
			{
				wl_int_002 = 1;
			}
			else
			{
				wl_int_001++;
			}
		}

		if ( wl_int_002 == 1 && table_hdl_medias[wl_int_001]->nbre_chapitres > 0 )
		{
			combo_quoilire_media_chapitre->clear();
			combo_quoilire_media_chapitre->insertItem(0,wg_str_int_001);
			for (wl_int_003 = 0; wl_int_003 < table_hdl_medias[wl_int_001]->nbre_chapitres; ++wl_int_003) 
			{
				combo_quoilire_media_chapitre->insertItem(wl_int_003+1,table_hdl_medias[wl_int_001]->chapitres[wl_int_003]);
				combo_quoilire_media_chapitre->setItemIcon(wl_int_003+1, QIcon(table_hdl_medias[wl_int_001]->icones_chapitres[wl_int_003]));
			}
			combo_quoilire_media_chapitre->setEnabled(true);
		}
		else
		{
			combo_quoilire_media_chapitre->clear();
			combo_quoilire_media_chapitre->insertItem(0,wg_str_int_001);
			combo_quoilire_media_chapitre->setDisabled(true);
		}

		f_display_language();

		if ( hdl_current_menu->back_image == "EXT_VIDEO_EXT" && indexsel > 0 )
		{
			f_image_menu_video();
		}
		else
		{
			if ( hdl_current_menu->back_image == "EXT_VIDEO_EXT" && indexsel == 0 )
			{
				hdl_current_menu->back_image = "";
				hdl_current_menu->charge_image("");
				hdl_current_menu->repaint();
			}
		}
	}
}

void mainfrm::f_delete_menu(menu *hdlmenu)
{
	// *** RECHERCHE DE LA POSITION DU MENU ***
	int wl_int_001=0;
	while ( table_hdl_menus[wl_int_001] != hdlmenu && wl_int_001 < nbre_menus )
	{
		wl_int_001++;
	}
	//
	if ( table_hdl_menus[wl_int_001] == hdlmenu )
	{
		int wl_old_zindex = table_hdl_menus[wl_int_001]->zindex;
		int wl_old_tindex = table_hdl_menus[wl_int_001]->taborder;
		int wl_old_islabel = table_hdl_menus[wl_int_001]->islabel;

		if ( wl_old_islabel == 0 )
		{
			nbre_menus_wo_label--;
		}

		// *** DECALAGE DES POINTEURS ***

		while ( wl_int_001 < nbre_menus-1 )
		{
			table_hdl_menus[wl_int_001] = table_hdl_menus[wl_int_001+1];
			wl_int_001++;
		}
		nbre_menus--;

		// *** ON CACHE LES INFOS DE NAVIGATION ***
		frame_info_navi->hide();

		// *** DECALAGE DES ZINDEX ET DES ORDRES DE TABULATION ***

		wl_int_001 = 0;
		while ( wl_int_001 < nbre_menus )
		{
			if ( table_hdl_menus[wl_int_001]->zindex > wl_old_zindex )
			{
				table_hdl_menus[wl_int_001]->zindex = table_hdl_menus[wl_int_001]->zindex--;
			}

			if ( table_hdl_menus[wl_int_001]->taborder > wl_old_tindex && table_hdl_menus[wl_int_001]->islabel == 0 && wl_old_islabel == 0 )
			{
				if ( table_hdl_menus[wl_int_001]->taborder > 0 )
				{
					table_hdl_menus[wl_int_001]->taborder = table_hdl_menus[wl_int_001]->taborder--;
				}
			}

			wl_int_001++;
		}

		//
		if ( nbre_menus == 0 )
		{
			actionOrdre_de_tabulation->setDisabled(true);
		}

		must_update = 0;
		combo_quoilire_media->setCurrentIndex(0);
		combo_quoilire_media_chapitre->setCurrentIndex(0);
		combo_quoilire_menu->setCurrentIndex(0);
		combo_quoilire_media->setDisabled(true);
		bt_tool_1->setDisabled(true);
		bt_tool_2->setDisabled(true);
		bt_tool_3->setDisabled(true);
		bt_tool_4->setDisabled(true);
		bt_bt_img->setDisabled(true);
		dial_alpha_menu->setDisabled(true);
		bttxt->setPlainText("");
		bttxt->setDisabled(true);
		frame_th_msk_idea->setDisabled(true);
		combo_quoilire_media->setDisabled(true);
		check_anim->setDisabled(true);
		combo_quoilire_media_chapitre->setDisabled(true);
		combo_select_langue->setDisabled(true);
		combo_quoilire_menu->setDisabled(true);
		must_update = 1;
		hdl_current_menu = 0;
		actionCopier_le_bouton->setDisabled(true);

		QTimer::singleShot(5, this, SLOT(f_update_thumb_menu()));
	}
	else
	{
		qDebug() << "LOGICAL ERROR IN MEMORY WHEN REMOVING A MENU";
	}
	f_close_editor_txt();
}

void mainfrm::f_release_menu(menu*)
{
	f_update_thumb_menu();
}

// ************************************
// *** DEFINITION DE FONCTIONS CLES ***
// ************************************

void mainfrm::f_run_ani()
{
	thread_ani->run();
}

void mainfrm::f_run_bld()
{
	thread_blend->run();
}

void mainfrm::f_lockbar()
{
	smenuBar->setDisabled(true);
}

void mainfrm::f_showhide_coor()
{
	if ( frame_infos->isVisible() == true )
	{
		frame_infos->hide();
	}
	else
	{
		frame_infos->setGeometry((this->width() - frame_infos->width())/2,((this->height()-smenuBar->height()) - frame_infos->height())/2, frame_infos->width(), frame_infos->height());
		frame_infos->show();
		frame_infos->raise();
	}
}

void mainfrm::f_showhide_safe()
{
	if ( safety_zone->isVisible() == true )
	{
		safety_zone->hide();
	}
	else
	{
		safety_zone->show();
	}
}

void mainfrm::f_generation_scale()
{
	QPixmap wl_pix_001(dvdxsize,dvdysize);
	QImage wl_img_001(current_menu_background);
	QImage wl_img_002;
	// *** GENERATION DES FORMATS DE SCALE ***
	if ( scale_current_menu_background == 1 )
	{
		wl_pix_001.fill(QColor(0,0,0));
		if ( wl_img_001.width() > wl_img_001.height() )
		{
			wl_img_002 = wl_img_001.scaledToWidth ( dvdxsize, Qt::FastTransformation );
		}
		else
		{
			wl_img_002 = wl_img_001.scaledToHeight ( dvdysize, Qt::FastTransformation );
		}
		QPainter p;
		p.begin(&wl_pix_001);
		p.drawImage((wl_pix_001.width() - wl_img_002.width()) / 2, (wl_pix_001.height() - wl_img_002.height()) / 2, wl_img_002, 0, 0, -1, -1 );
		p.end();

		background_menu->setPixmap(wl_pix_001);
	}
	else
	{
		wl_pix_001.fill(QColor(0,0,0));
		if ( wl_img_001.width() > wl_img_001.height() )
		{
			wl_img_002 = wl_img_001.scaledToHeight ( dvdysize, Qt::FastTransformation );
		}
		else
		{
			wl_img_002 = wl_img_001.scaledToWidth ( dvdxsize, Qt::FastTransformation );
		}
		QPainter p;
		p.begin(&wl_pix_001);
		p.drawImage((wl_pix_001.width() - wl_img_002.width()) / 2, (wl_pix_001.height() - wl_img_002.height()) / 2, wl_img_002, 0, 0, -1, -1 );
		p.end();

		background_menu->setPixmap(wl_pix_001);
	}
}

void mainfrm::f_affiche_info_pos(menu *hdlm)
{
	label_position->setText(tr("Position : ") + QString::number(hdlm->menu_x) + ";" + QString::number(hdlm->menu_y));
	label_size->setText(tr("Taille : ") + QString::number(hdlm->menu_width) + "x" + QString::number(hdlm->menu_height));
	label_rotation->setText(tr("Rotation : ") + QString::number(hdlm->rotation));
}

void mainfrm::f_ajoute_menu_new(int x, int y, int w, int h)
{
	if ( nbre_menus < 19 )
	{
		// *** NOUVEAU BOUTON MENU ***
		menu *newmenu = new menu(screen_designer);
		newmenu->setGeometry(x,y,w,h);
		newmenu->charge_image(":/Interface/Interface/default_bt.png");
		newmenu->show();
		newmenu->menu_x = x;
		newmenu->menu_y = y;
		newmenu->menu_width = w;
		newmenu->menu_height = h;
		newmenu->img_x_size = w;
		newmenu->img_y_size = h;
		newmenu->iscontours = draw_contours;
		newmenu->rotation = 0;
		newmenu->teta0 = 0;
		connect(newmenu, SIGNAL(delete_menu(menu*) ),this, SLOT(f_delete_menu(menu*)));
		connect(newmenu, SIGNAL(customize_menu(menu*) ),this, SLOT(f_customize_menu(menu*)));
		connect(newmenu, SIGNAL(call_charge_image() ),this, SLOT(f_image_menu()));
		connect(newmenu, SIGNAL(call_charge_image_video() ),this, SLOT(f_image_menu_video()));
		connect(newmenu, SIGNAL(change_position(menu*) ),this, SLOT(f_affiche_info_pos(menu*)));
		connect(newmenu, SIGNAL(release_menu(menu*) ),this, SLOT(f_release_menu(menu*)));
		connect(newmenu, SIGNAL(select_menu(menu*) ),this, SLOT(f_select_menu(menu*)));
		connect(newmenu, SIGNAL(affiche_navi(menu*) ),this, SLOT(f_menu_navi_on(menu*)));
		connect(newmenu, SIGNAL(cache_navi(menu*) ),this, SLOT(f_menu_navi_off(menu*)));
		connect(newmenu, SIGNAL(go_lower(menu*) ),this, SLOT(f_menu_lower(menu*)));
		connect(newmenu, SIGNAL(go_front(menu*) ),this, SLOT(f_menu_front(menu*)));
		connect(newmenu, SIGNAL(copy_menu(menu*) ),this, SLOT(f_copy_menu(menu*)));
		connect(newmenu, SIGNAL(goto_menu(menu*) ),this, SLOT(f_goto_menu(menu*)));
		connect(newmenu, SIGNAL(has_scale(menu*) ),this, SLOT(f_redraw_menu(menu*)));
		connect(newmenu, SIGNAL(halign(menu*) ),this, SLOT(f_halign_menu(menu*)));
		connect(newmenu, SIGNAL(valign(menu*) ),this, SLOT(f_valign_menu(menu*)));
		connect(newmenu, SIGNAL(talign(menu*) ),this, SLOT(f_talign_menu(menu*)));
		connect(newmenu, SIGNAL(quoifaire(menu*) ),this, SLOT(f_select_quoifaire_after(menu*)));
		connect(newmenu, SIGNAL(editoverlay(menu*) ),this, SLOT(f_edit_overlay(menu*)));
		connect(newmenu, SIGNAL(tobt(menu*) ),this, SLOT(f_tobt(menu*)));

		table_hdl_menus[nbre_menus] = newmenu;
		newmenu->zindex = nbre_menus;
		newmenu->taborder = 0;
		nbre_menus++;

		hdl_current_menu = newmenu;
		actionCopier_le_bouton->setEnabled(true);

		f_select_menu(hdl_current_menu);
		//dial_angle_shadow->setValue(hdlmenu->shadow_angle);
		//dial_opacity_shadow->setValue(hdlmenu->shadow_opacity);

		actionOrdre_de_tabulation->setEnabled(true);
	}
	else
	{
		hdl_current_menu = 0;
	}
}

void mainfrm::f_create_menu_movie()
{
	// *** CREATION D'UN BOUTON SUR LE MENU LORS DU RECHARGEMENT DU MENU ***
	menu *newmenu = new menu(screen_designer);
	connect(newmenu, SIGNAL(delete_menu(menu*) ),this, SLOT(f_delete_menu(menu*)));
	connect(newmenu, SIGNAL(customize_menu(menu*) ),this, SLOT(f_customize_menu(menu*)));
	connect(newmenu, SIGNAL(call_charge_image() ),this, SLOT(f_image_menu()));
	connect(newmenu, SIGNAL(call_charge_image_video() ),this, SLOT(f_image_menu_video()));
	connect(newmenu, SIGNAL(select_menu(menu*) ),this, SLOT(f_select_menu(menu*)));
	connect(newmenu, SIGNAL(change_position(menu*) ),this, SLOT(f_affiche_info_pos(menu*)));
	connect(newmenu, SIGNAL(release_menu(menu*) ),this, SLOT(f_release_menu(menu*)));
	connect(newmenu, SIGNAL(affiche_navi(menu*) ),this, SLOT(f_menu_navi_on(menu*)));
	connect(newmenu, SIGNAL(cache_navi(menu*) ),this, SLOT(f_menu_navi_off(menu*)));
	connect(newmenu, SIGNAL(go_lower(menu*) ),this, SLOT(f_menu_lower(menu*)));
	connect(newmenu, SIGNAL(go_front(menu*) ),this, SLOT(f_menu_front(menu*)));
	connect(newmenu, SIGNAL(copy_menu(menu*) ),this, SLOT(f_copy_menu(menu*)));
	connect(newmenu, SIGNAL(goto_menu(menu*) ),this, SLOT(f_goto_menu(menu*)));
	connect(newmenu, SIGNAL(has_scale(menu*) ),this, SLOT(f_redraw_menu(menu*)));
	connect(newmenu, SIGNAL(halign(menu*) ),this, SLOT(f_halign_menu(menu*)));
	connect(newmenu, SIGNAL(valign(menu*) ),this, SLOT(f_valign_menu(menu*)));
	connect(newmenu, SIGNAL(talign(menu*) ),this, SLOT(f_talign_menu(menu*)));
	connect(newmenu, SIGNAL(quoifaire(menu*) ),this, SLOT(f_select_quoifaire_after(menu*)));
	connect(newmenu, SIGNAL(editoverlay(menu*) ),this, SLOT(f_edit_overlay(menu*)));
	connect(newmenu, SIGNAL(tobt(menu*) ),this, SLOT(f_tobt(menu*)));
	table_hdl_menus[nbre_menus] = newmenu;
	hdl_current_menu = newmenu;

	actionCopier_le_bouton->setEnabled(true);

	//newmenu->setGeometry(table_menus[wg_int_001][wg_int_002][0].toInt(),table_menus[wg_int_001][wg_int_002][1].toInt(),table_menus[wg_int_001][wg_int_002][2].toInt(),table_menus[wg_int_001][wg_int_002][3].toInt());
	
	newmenu->menu_x = table_menus[wg_int_001][wg_int_002][0].toInt();
	newmenu->menu_y = table_menus[wg_int_001][wg_int_002][1].toInt();
	newmenu->back_image = table_menus[wg_int_001][wg_int_002][4];
	newmenu->is_select = 0;
	newmenu->iscontours = draw_contours;
	newmenu->quoilire = table_menus[wg_int_001][wg_int_002][5];
	newmenu->path_mask = table_menus[wg_int_001][wg_int_002][6];
	newmenu->menu_width = table_menus[wg_int_001][wg_int_002][2].toInt();
	newmenu->menu_height = table_menus[wg_int_001][wg_int_002][3].toInt();
	newmenu->rotation = table_menus[wg_int_001][wg_int_002][7].toInt();
	newmenu->img_x_size = table_menus[wg_int_001][wg_int_002][8].toInt();
	newmenu->quoilirechapitre = table_menus[wg_int_001][wg_int_002][9];
	newmenu->img_y_size = table_menus[wg_int_001][wg_int_002][10].toInt();
	newmenu->islabel = table_menus[wg_int_001][wg_int_002][11].toInt();
	newmenu->shadow = table_menus[wg_int_001][wg_int_002][12].toInt();
	newmenu->color_mask_over = table_menus[wg_int_001][wg_int_002][13];
	newmenu->anim_thumb = table_menus[wg_int_001][wg_int_002][14].toInt();
	newmenu->zindex = table_menus[wg_int_001][wg_int_002][15].toInt();
	newmenu->taborder = table_menus[wg_int_001][wg_int_002][16].toInt();
	newmenu->alpha_menu = table_menus[wg_int_001][wg_int_002][17].toInt();
	newmenu->audio_track = table_menus[wg_int_001][wg_int_002][19];
	newmenu->shear_value_x = table_menus[wg_int_001][wg_int_002][20].toInt();
	newmenu->shear_value_y = table_menus[wg_int_001][wg_int_002][21].toInt();
	newmenu->quoi_faire = table_menus[wg_int_001][wg_int_002][22];
	newmenu->quoi_overlay = table_menus[wg_int_001][wg_int_002][23];

	if ( table_menus[wg_int_001][wg_int_002][24].mid(0,1) == "1" )
	{
		newmenu->isbold = true;
	}
	else
	{
		newmenu->isbold = false;
	}

	if ( table_menus[wg_int_001][wg_int_002][24].mid(1,1) == "1" )
	{
		newmenu->isitalic = true;
	}
	else
	{
		newmenu->isitalic = false;
	}

	if ( table_menus[wg_int_001][wg_int_002][24].mid(2,1) == "1" )
	{
		newmenu->isunderline = true;
	}
	else
	{
		newmenu->isunderline = false;
	}

	newmenu->isalign = table_menus[wg_int_001][wg_int_002][24].mid(3,1).toInt();

	if ( table_menus[wg_int_001][wg_int_002][18].mid(0,1) == "$" || table_menus[wg_int_001][wg_int_002][18].length() < 1 )
	{
		newmenu->shadow_angle = 0;
		newmenu->shadow_opacity = 100;
		newmenu->shadow_color = "";
	}
	else
	{
		QString wl_string_001 = table_menus[wg_int_001][wg_int_002][18];
		QString wl_string_002 = "";
		int wl_int_001 = 0;
		int wl_int_002 = 0;

		while ( wl_int_002 < 3 )
		{
			if ( wl_string_001.mid(wl_int_001,1) == "$" )
			{
				if ( wl_int_002 == 0 )
				{
					newmenu->shadow_color = wl_string_002;
					wl_string_002 = "";
				}
				if ( wl_int_002 == 1 )
				{
					newmenu->shadow_opacity = wl_string_002.toInt();
					wl_string_002 = "";
				}
				if ( wl_int_002 == 2 )
				{
					newmenu->shadow_angle = wl_string_002.toInt();
					wl_string_002 = "";
				}
				wl_int_002++;
			}
			else
			{
				wl_string_002 = wl_string_002 + wl_string_001.mid(wl_int_001,1);
			}
			wl_int_001++;
		}
	}

	if ( newmenu->back_image == "" )
	{
		newmenu->charge_image("");
	}
	else
	{
		if ( newmenu->back_image == "EXT_VIDEO_EXT" )
		{
			wg_int_003=0;
			while ( wg_int_003 < nbre_medias && table_hdl_medias[wg_int_003]->pathname_media != newmenu->quoilire )
			{
				wg_int_003++;
			}
			if ( table_hdl_medias[wg_int_003]->pathname_media == newmenu->quoilire && newmenu->quoilirechapitre == wg_str_int_001 )
			{
				newmenu->draw_image = table_hdl_medias[wg_int_003]->miniature.scaledToWidth(newmenu->img_x_size,Qt::FastTransformation);
				newmenu->original = table_hdl_medias[wg_int_003]->miniature;
				newmenu->back_image="EXT_VIDEO_EXT";
			}
			else
			{
				if ( newmenu->quoilirechapitre != "" )
				{
					wg_int_004=0;
					while ( wg_int_004 < table_hdl_medias[wg_int_003]->nbre_chapitres && table_hdl_medias[wg_int_003]->chapitres[wg_int_004] != newmenu->quoilirechapitre )
					{
						wg_int_004++;
					}

					if ( table_hdl_medias[wg_int_003]->chapitres[wg_int_004] == newmenu->quoilirechapitre )
					{
						// *** MINIATURE DU CHAPITRE ***
						newmenu->draw_image = table_hdl_medias[wg_int_003]->miniature.scaledToWidth(newmenu->img_x_size,Qt::FastTransformation);
						newmenu->draw_image = table_hdl_medias[wg_int_003]->icones_chapitres[wg_int_004].pixmap( newmenu->img_x_size, newmenu->img_x_size/(newmenu->draw_image.width()/newmenu->draw_image.height()), QIcon::Normal, QIcon::On );
						newmenu->original = table_hdl_medias[wg_int_003]->icones_chapitres[wg_int_004].pixmap( 500, 500 / (newmenu->draw_image.width()/newmenu->draw_image.height()), QIcon::Normal, QIcon::On );

						newmenu->reload_charge_image("EXT_VIDEO_EXT");
						newmenu->back_image="EXT_VIDEO_EXT";
					}

				}
				else
				{
					qDebug() << "LOGICAL ERROR IN MEMORY WHEN SEARCHING MEDIA CHAPTER FOR PICTURE BUTTON IN RELOADING MENU";
				}
			}
			newmenu->set_opacity(newmenu->alpha_menu);
		}
		else
		{
			if ( newmenu->back_image.mid(0,5) == "$TXT$" )
			{
				// *** EXTRACTION POUR LE CAS D'UN BOUTON TEXTE ***
				wg_string_001 = newmenu->back_image;
				wg_string_002 = "";
				must_update = 0;

				wg_int_006 = 5;
				wg_int_007 = 0;
				while ( wg_string_001.mid(wg_int_006,1) != "!" && wg_int_007 < 4 )
				{
					if ( wg_string_001.mid(wg_int_006,1) == "^" )
					{
						if ( wg_int_007 == 0 )
						{
							pntwheel3->red = wg_string_002.toInt();
							wg_string_002 = "";
						}
						if ( wg_int_007 == 1 )
						{
							pntwheel3->green = wg_string_002.toInt();
							wg_string_002 = "";
						}
						if ( wg_int_007 == 2 )
						{
							pntwheel3->blue = wg_string_002.toInt();
							wg_string_002 = "";
							pntwheel3->setColor(pntwheel3->red,pntwheel3->green,pntwheel3->blue);
						}
						if ( wg_int_007 == 3 )
						{
							font_txt->setCurrentFont(QFont(wg_string_002));
						}
						wg_int_007++;
					}
					else
					{
						wg_string_002 = wg_string_002 + wg_string_001.mid(wg_int_006,1);
					}
					wg_int_006++;
				}

				//
				wg_string_003 = newmenu->shadow_color;
				wg_string_002 = "";
				wg_int_008 = 0;
				wg_int_007 = 0;
				if ( wg_string_003.length() > 0 )
				{
					while ( wg_int_007 < 3 )
					{
						if ( wg_string_003.mid(wg_int_008,1) == "^" )
						{
							if ( wg_int_007 == 0 )
							{
								pntwheel4->red = wg_string_002.toInt();
								wg_string_002 = "";
							}
							if ( wg_int_007 == 1 )
							{
								pntwheel4->green = wg_string_002.toInt();
								wg_string_002 = "";
							}
							if ( wg_int_007 == 2 )
							{
								pntwheel4->blue = wg_string_002.toInt();
								wg_string_002 = "";
								pntwheel4->setColor(pntwheel4->red,pntwheel4->green,pntwheel4->blue);
							}
							wg_int_007++;
						}
						else
						{
							wg_string_002 = wg_string_002 + wg_string_003.mid(wg_int_008,1);
						}
						wg_int_008++;
					}
				}
				//

				bttxt->setPlainText(wg_string_001.mid(wg_int_006+1,wg_string_001.length() - (wg_int_006+1)));
				must_update = 1;

				QPixmap wl_pix_001(newmenu->img_x_size,newmenu->img_y_size);
				//wl_pix_001.fill(QColor(0,0,0,0));
				newmenu->draw_image = wl_pix_001; //.scaled(newmenu->img_x_size,newmenu->img_y_size);
				is_new_create = 1;
				f_put_txt_on_bt();
				is_new_create = 0;
				//newmenu->draw_image = newmenu->draw_image.scaled(newmenu->img_x_size,newmenu->img_y_size);
				//newmenu->repaint();

				must_update = 0;
				bttxt->setPlainText("");
				must_update = 1;
			}
			else
			{
				newmenu->reload_charge_image(newmenu->back_image);
			}
		}
	}

	if ( newmenu->path_mask != "" )
	{
		newmenu->charge_mask(newmenu->path_mask);
	}

	int sx = newmenu->shear_value_x;
	int sy = newmenu->shear_value_y;

	if ( newmenu->shear_value_x < 0 )
	{
		sx = newmenu->shear_value_x * -1;
	}

	if ( newmenu->shear_value_y < 0 )
	{
		sy = newmenu->shear_value_y * -1;
	}

	double angleradian = (M_PI*newmenu->rotation)/180;

	if ( newmenu->rotation <= 90 )
	{ 
		newmenu->menu_width = (newmenu->draw_image.width() * cos(angleradian))+(newmenu->draw_image.height() * sin(angleradian));
		newmenu->menu_height = (newmenu->draw_image.height() * cos(angleradian))+(newmenu->draw_image.width() * sin(angleradian));
	}
	else
	{ 
		float mcos = cos(angleradian);
		float msin = sin(angleradian);

		if ( mcos < 0 )
		{
			mcos=mcos*-1;
		}
		if ( msin < 0 )
		{
			msin=msin*-1;
		}
		newmenu->menu_width = (newmenu->draw_image.width() * mcos)+(newmenu->draw_image.height() * msin);
		newmenu->menu_height = (newmenu->draw_image.width() * msin)+(newmenu->draw_image.height() * mcos);
	}

	//newmenu->menu_width = newmenu->menu_width+(sx*3);
	//newmenu->menu_height = newmenu->menu_height+(sy*3);

	if ( newmenu->menu_width >= newmenu->menu_height )
	{
		newmenu->menu_width = newmenu->menu_width+((float)sx*((float)1.2*((float)newmenu->menu_width/(float)newmenu->menu_height)));
		newmenu->menu_height = newmenu->menu_height+((float)sy*((float)1.2*((float)newmenu->menu_width/(float)newmenu->menu_height)));
	}
	else
	{
		newmenu->menu_width = newmenu->menu_width+((float)sx*((float)1.2*((float)newmenu->menu_height/(float)newmenu->menu_width)));
		newmenu->menu_height = newmenu->menu_height+((float)sy*((float)1.2*((float)newmenu->menu_height/(float)newmenu->menu_width)));
	}

	newmenu->setGeometry(newmenu->menu_x,newmenu->menu_y,newmenu->menu_width,newmenu->menu_height);

	nbre_menus++;
	if ( newmenu->islabel == 0 )
	{
		nbre_menus_wo_label++;
	}
	actionOrdre_de_tabulation->setEnabled(true);
	newmenu->show();
}

void mainfrm::f_menu_opacity(int value)
{
	if ( must_update == 1 )
	{
		if ( hdl_current_menu->path_mask != "" )
		{
			if ( hdl_current_menu->isovermask == 1 )
			{
				hdl_current_menu->set_opacity(value);
				hdl_current_menu->mask = hdl_current_menu->original_mask.scaled( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height(), Qt::IgnoreAspectRatio, Qt::FastTransformation );
				hdl_current_menu->draw_image.setMask(hdl_current_menu->mask.mask());
				QPainter p;
				p.begin(&hdl_current_menu->draw_image);
				QPixmap wl_pix_002 = hdl_current_menu->over_mask.scaled( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height(), Qt::IgnoreAspectRatio, Qt::FastTransformation );
				p.drawPixmap ( QRect(0,0,-1,-1),wl_pix_002 );
				p.end();
			}
			else
			{
				// *** MASK SPECIAL SANS OVERMASK ***
				hdl_current_menu->set_opacity(value);
				QImage wl_image = hdl_current_menu->draw_image.toImage();
				wl_image = wl_image.convertToFormat ( QImage::Format_ARGB32_Premultiplied, Qt::AutoColor );

				hdl_current_menu->mask = hdl_current_menu->original_mask.scaled( hdl_current_menu->draw_image.width(), hdl_current_menu->draw_image.height(), Qt::IgnoreAspectRatio, Qt::FastTransformation );
				QImage wl_image_2 = hdl_current_menu->mask.toImage();
				wl_image_2 = wl_image_2.convertToFormat ( QImage::Format_ARGB32_Premultiplied, Qt::AutoColor );

				QPainter g;

				QPainter::CompositionMode mode = (QPainter::CompositionMode)6;

				g.begin(&wl_image);
				g.setCompositionMode ( mode );
				g.drawImage(QRect(0,0,-1,-1),wl_image_2);
				g.end();
				hdl_current_menu->draw_image = QPixmap::fromImage( wl_image, Qt::AutoColor );
			}
		}
		else
		{
			hdl_current_menu->set_opacity(value);
		}
		hdl_current_menu->repaint();
	}
}

// *********************************
// *** ALIGNEMENT SUR LES REGLES ***
// *********************************

void mainfrm::f_halign_menu(menu* hdlm)
{
	if ( h_regle->geometry().y()-frame_support_editor->geometry().y()-top_window->height()-hdlm->height() > 0 && h_regle->geometry().y()-frame_support_editor->geometry().y()-top_window->height()-hdlm->height() < dvdysize-hdlm->height() )
	{
		hdlm->setGeometry(hdlm->geometry().x(),h_regle->geometry().y()-frame_support_editor->geometry().y()-top_window->height()-hdlm->height(),hdlm->width(),hdlm->height());
		hdlm->menu_y = h_regle->geometry().y()-frame_support_editor->geometry().y()-top_window->height()-hdlm->height();
	}
	else
	{
		if ( h_regle->geometry().y()-frame_support_editor->geometry().y()-top_window->height()-hdlm->height() < 0 )
		{
			hdlm->setGeometry(hdlm->geometry().x(),0,hdlm->width(),hdlm->height());
			hdlm->menu_y = 0;
		}
		else
		{
			hdlm->setGeometry(hdlm->geometry().x(),dvdysize-hdlm->height(),hdlm->width(),hdlm->height());
			hdlm->menu_y = dvdysize-hdlm->height();
		}
	}
}

void mainfrm::f_valign_menu(menu* hdlm)
{
	if ( (v_regle->geometry().x()-frame_support_editor->geometry().x())+v_regle->width() > 0 && (v_regle->geometry().x()-frame_support_editor->geometry().x())+v_regle->width() < dvdxsize )
	{
		hdlm->setGeometry((v_regle->geometry().x()-frame_support_editor->geometry().x())+v_regle->width(),hdlm->geometry().y(),hdlm->width(),hdlm->height());
		hdlm->menu_x = (v_regle->geometry().x()-frame_support_editor->geometry().x())+v_regle->width();
	}
	else
	{
		if ( (v_regle->geometry().x()-frame_support_editor->geometry().x())+v_regle->width() < 0 )
		{
			hdlm->setGeometry(0,hdlm->geometry().y(),hdlm->width(),hdlm->height());
			hdlm->menu_x = 0;
		}
		else
		{
			hdlm->setGeometry(dvdxsize-hdlm->width(),hdlm->geometry().y(),hdlm->width(),hdlm->height());
			hdlm->menu_x = dvdxsize-hdlm->width();
		}
	}
}

void mainfrm::f_talign_menu(menu* hdlm)
{
	f_halign_menu(hdlm);
	f_valign_menu(hdlm);
}

void mainfrm::f_tobt(menu* hdlm)
{
	hdlm->islabel = 0;
	f_select_menu(hdlm);
}

// *******************************
// *** CUSTOMIZATION DES MASKS ***
// *******************************

void mainfrm::f_customize_menu(menu* hdlm)
{
	QPixmap wl_pix_001(preview_customize->width(),preview_customize->height());
	//wg_pix_002.load(":/Interface/Interface/fd_transparent.png");
	QPixmap wlpixmap = QPixmap::grabWidget(background_menu);
	wg_pix_002 = wlpixmap.copy(hdl_current_menu->menu_x,hdl_current_menu->menu_y,hdl_current_menu->menu_width,hdl_current_menu->menu_height);
	wg_pix_002 = wg_pix_002.scaled(preview_customize->width(),preview_customize->height());
	wg_pix_001.load(hdlm->path_over_mask);

	wg_pix_003 = wg_pix_001.scaledToHeight(preview_customize->height(), Qt::FastTransformation);

	QPainter p;
	p.begin(&wl_pix_001);
	p.drawPixmap(0,0,-1,-1,wg_pix_002);
	p.drawPixmap((wl_pix_001.width()-wg_pix_003.width())/2,(wl_pix_001.height()-wg_pix_003.height())/2,-1,-1,wg_pix_003);
	p.end();

	if ( hdlm->color_mask_over == "" )
	{
		must_update = 0;
		slider_custo_red->setValue(0);
		slider_custo_green->setValue(0);
		slider_custo_blue->setValue(0);
		slider_custo_opacity->setValue(255);
		must_update = 1;
		preview_customize->setPixmap(wl_pix_001);
	}
	else
	{
		QStringList wl_explode = hdlm->color_mask_over.split("$",QString::KeepEmptyParts);
		must_update = 0;
		slider_custo_red->setValue(wl_explode.at(0).toInt());
		slider_custo_green->setValue(wl_explode.at(1).toInt());
		slider_custo_blue->setValue(wl_explode.at(2).toInt());
		slider_custo_opacity->setValue(wl_explode.at(3).toInt());
		must_update = 1;

		thread_img->rouge = slider_custo_red->value();
		thread_img->vert = slider_custo_green->value();
		thread_img->bleu = slider_custo_blue->value();
		thread_img->opacity = slider_custo_opacity->value();

		thread_img->wlimg = wg_pix_001.toImage().convertToFormat(QImage::Format_ARGB32, Qt::AutoColor);
		thread_img->run();
	}

	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 2;
	thread_ani->sens = 1;
	thread_ani->isrender = 0;
	mask_interface->show();
	mask_interface->raise();
	frame_customize->show();
	frame_customize->raise();
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_valide_customize()
{
	hdl_current_menu->color_mask_over = QString::number(slider_custo_red->value()) + "$" + QString::number(slider_custo_green->value()) + "$" + QString::number(slider_custo_blue->value()) + "$" + QString::number(slider_custo_opacity->value());
	hdl_current_menu->charge_mask(hdl_current_menu->path_mask);
	frame_customize->hide();
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 220;
	thread_ani->sens = 0;
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_custo_red(int value)
{
	if ( must_update == 1 )
	{
		thread_img->rouge = value;
		thread_img->vert = slider_custo_green->value();
		thread_img->bleu = slider_custo_blue->value();
		thread_img->opacity = slider_custo_opacity->value();

		thread_img->wlimg = wg_pix_001.toImage().convertToFormat(QImage::Format_ARGB32, Qt::AutoColor);
		thread_img->run();
	}
}

void mainfrm::f_custo_green(int value)
{
	if ( must_update == 1 )
	{
		thread_img->rouge = slider_custo_red->value();
		thread_img->vert = value;
		thread_img->bleu = slider_custo_blue->value();
		thread_img->opacity = slider_custo_opacity->value();

		thread_img->wlimg = wg_pix_001.toImage().convertToFormat(QImage::Format_ARGB32, Qt::AutoColor);
		thread_img->run();
	}
}

void mainfrm::f_custo_blue(int value)
{
	if ( must_update == 1 )
	{
		thread_img->rouge = slider_custo_red->value();
		thread_img->vert = slider_custo_green->value();
		thread_img->bleu = value;
		thread_img->opacity = slider_custo_opacity->value();

		thread_img->wlimg = wg_pix_001.toImage().convertToFormat(QImage::Format_ARGB32, Qt::AutoColor);
		thread_img->run();
	}
}

void mainfrm::f_custo_opacity(int value)
{
	if ( must_update == 1 )
	{
		thread_img->rouge = slider_custo_red->value();
		thread_img->vert = slider_custo_green->value();
		thread_img->bleu = slider_custo_blue->value();
		thread_img->opacity = value;

		thread_img->wlimg = wg_pix_001.toImage().convertToFormat(QImage::Format_ARGB32, Qt::AutoColor);
		thread_img->run();
	}
}

void mainfrm::f_refresh_customize()
{
	QPixmap wl_pix_001(preview_customize->width(),preview_customize->height());
	wl_pix_001.fill(QColor(0,0,0,0));
	QImage wl_img_001 = thread_img->wlimg.scaledToHeight(preview_customize->height(), Qt::FastTransformation);
	QPainter p;
	p.begin(&wl_pix_001);
	p.drawPixmap(0,0,-1,-1,wg_pix_002);
	p.drawImage( (wl_pix_001.width()-wl_img_001.width())/2,(wl_pix_001.height()-wl_img_001.height())/2, wl_img_001, 0, 0, -1, -1, Qt::AutoColor );
	p.end();
	preview_customize->setPixmap(wl_pix_001);
}

void mainfrm::f_update_thumb_menu()
{
	// *** CAPTURE DU MENU ***
	QPixmap wlpixmap = QPixmap::grabWidget(screen_designer);
	hdl_current_menuth->draw_image = wlpixmap.scaledToWidth ( 88, Qt::FastTransformation );
	hdl_current_menuth->repaint();
	//smenuBar->setEnabled(true);
}

void mainfrm::f_delete_widgetonmenu()
{
	// *** SUPPRESSION DE TOUS LES WIDGETS DU MENU COURANT ***
	int wl_int_001 = 0;
	while ( wl_int_001 < nbre_menus )
	{
		table_hdl_menus[wl_int_001]->close();
		wl_int_001++;
	}
	nbre_menus = 0;
	nbre_menus_wo_label = 0;
}

void mainfrm::f_save_widgetonmenu()
{
	// *** SAUVEGARDE DES INFORMATIONS DU MENU ***
	QString wl_str_001 = "";
	wg_int_001=0;
	while ( table_hdl_menuth[wg_int_001] != hdl_current_menuth && wg_int_001 < nbre_menuth )
	{
		wg_int_001++;
	}
	if ( table_hdl_menuth[wg_int_001] == hdl_current_menuth )
	{
		wg_int_002 = 0;
		while ( wg_int_002 < nbre_menus )
		{
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][0] = QString::number(table_hdl_menus[wg_int_002]->geometry().x());
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][1] = QString::number(table_hdl_menus[wg_int_002]->geometry().y());
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][2] = QString::number(table_hdl_menus[wg_int_002]->width());
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][3] = QString::number(table_hdl_menus[wg_int_002]->height());
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][4] = table_hdl_menus[wg_int_002]->back_image;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][5] = table_hdl_menus[wg_int_002]->quoilire;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][6] = table_hdl_menus[wg_int_002]->path_mask;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][7] = QString::number(table_hdl_menus[wg_int_002]->rotation);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][8] = QString::number(table_hdl_menus[wg_int_002]->img_x_size);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][9] = table_hdl_menus[wg_int_002]->quoilirechapitre;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][10] = QString::number(table_hdl_menus[wg_int_002]->img_y_size);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][11] = QString::number(table_hdl_menus[wg_int_002]->islabel);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][12] = QString::number(table_hdl_menus[wg_int_002]->shadow);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][13] = table_hdl_menus[wg_int_002]->color_mask_over;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][14] = QString::number(table_hdl_menus[wg_int_002]->anim_thumb);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][15] = QString::number(table_hdl_menus[wg_int_002]->zindex);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][16] = QString::number(table_hdl_menus[wg_int_002]->taborder);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][17] = QString::number(table_hdl_menus[wg_int_002]->alpha_menu);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][18] = table_hdl_menus[wg_int_002]->shadow_color + "$" + QString::number(table_hdl_menus[wg_int_002]->shadow_opacity) + "$" + QString::number(table_hdl_menus[wg_int_002]->shadow_angle) + "$";
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][19] = table_hdl_menus[wg_int_002]->audio_track;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][20] = QString::number(table_hdl_menus[wg_int_002]->shear_value_x);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][21] = QString::number(table_hdl_menus[wg_int_002]->shear_value_y);
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][22] = table_hdl_menus[wg_int_002]->quoi_faire;
			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][23] = table_hdl_menus[wg_int_002]->quoi_overlay;

			if ( table_hdl_menus[wg_int_002]->isbold == true )
			{
				wl_str_001 = "1";
			}
			else
			{
				wl_str_001 = "0";
			}

			if ( table_hdl_menus[wg_int_002]->isitalic == true )
			{
				wl_str_001 = wl_str_001 + "1";
			}
			else
			{
				wl_str_001 = wl_str_001 + "0";
			}

			if ( table_hdl_menus[wg_int_002]->isunderline == true )
			{
				wl_str_001 = wl_str_001 + "1";
			}
			else
			{
				wl_str_001 = wl_str_001 + "0";
			}

			wl_str_001 = wl_str_001 + QString::number(table_hdl_menus[wg_int_002]->isalign);

			table_menus[wg_int_001][table_hdl_menus[wg_int_002]->zindex][24] = wl_str_001;

			wg_int_002++;
		}
		table_menus[wg_int_001][wg_int_002][0] = "$$$";

		table_menus_property[wg_int_001][0] = current_menu_background;
		table_menus_property[wg_int_001][1] = QString::number(scale_current_menu_background);
		table_menus_property[wg_int_001][2] = QString::number(pntwheel1->red) + ";" + QString::number(pntwheel1->green) + ";" + QString::number(pntwheel1->blue);
		table_menus_property[wg_int_001][3] = QString::number(pntwheel2->red) + ";" + QString::number(pntwheel2->green) + ";" + QString::number(pntwheel2->blue);
		table_menus_property[wg_int_001][4] = current_menu_audio;
		table_menus_property[wg_int_001][5] = current_menu_intro;
		table_menus_property[wg_int_001][6] = QString::number(dial_opacity_overlay->value());
		table_menus_property[wg_int_001][7] = QString::number(current_loop) + QString::number(loop_length);
		table_menus_property[wg_int_001][8] = current_intro_zik;
	}
	else
	{
		qDebug() << "LOGICAL MEMORY ERROR SEARCHING POSITION FOR SAVING MENU";
	}
}

void mainfrm::f_update_blend()
{
	QPixmap wl_pix_001(dvdxsize,dvdysize); //thread_blend->dstImage.width(),thread_blend->dstImage.height());
	QPainter p;
	p.begin(&wl_pix_001);
	p.drawImage ( 0,0,thread_blend->dstImage );
	p.end();
	sur_blend->setPixmap(wl_pix_001);

	QTimer::singleShot(5, this, SLOT(f_run_bld()));
}

void mainfrm::f_end_blend()
{
	frame_support_menuthumb->setEnabled(true);
	sur_blend->hide();
	f_update_thumb_menu();
}

void mainfrm::f_calcul_jauge(long value)
{
	// *** CALCUL TAILLE DVD ***
	dvd_actual_size = dvd_actual_size + value;
	int wl_int_001 = 0;

	// *** GENERATION DE LA JAUGE ***
	QPixmap wl_pix_001(":/Interface/Interface/dvd_empty.png");
	QPixmap wl_pix_002(":/Interface/Interface/dvd_theme.png");

	if ( dvd_actual_size > 0 )
	{
		if ( (wl_pix_001.height() * dvd_actual_size)/dvd_total_size > 1 )
		{
			wl_int_001 = (wl_pix_001.height() * dvd_actual_size)/dvd_total_size;
			QPainter p;
			p.begin(&wl_pix_001);
			QFont myfont("Nimbus Sans L");
			p.setPen(QColor(255,255,255));
			myfont.setPixelSize ( 14 );
			myfont.setBold(true);
			p.setFont(myfont);
			p.drawPixmap(0, wl_pix_001.height()-wl_int_001, wl_pix_002, 0, wl_pix_001.height()-wl_int_001, -1, wl_int_001);
			p.drawText(QRect(7,83,50,30), Qt::AlignVCenter | Qt::AlignHCenter, QString::number((100 * dvd_actual_size)/dvd_total_size) + "%");
			p.end();
			jauge_dvd->setPixmap(wl_pix_001);
		}
		else
		{
			QPainter p;
			p.begin(&wl_pix_001);
			QFont myfont("Nimbus Sans L");
			p.setPen(QColor(255,255,255));
			myfont.setPixelSize ( 14 );
			myfont.setBold(true);
			p.setFont(myfont);
			p.drawText(QRect(7,83,50,30), Qt::AlignVCenter | Qt::AlignHCenter, QString::number((100 * dvd_actual_size)/dvd_total_size) + "%");
			p.end();
			jauge_dvd->setPixmap(wl_pix_001);
		}
	}
	else
	{
		QPainter p;
		p.begin(&wl_pix_001);
		QFont myfont("Nimbus Sans L");
		p.setPen(QColor(255,255,255));
		myfont.setPixelSize ( 14 );
		myfont.setBold(true);
		p.setFont(myfont);
		p.drawPixmap(0, wl_pix_001.height()-wl_int_001, wl_pix_002, 0, wl_pix_001.height()-wl_int_001, -1, wl_int_001);
		p.drawText(QRect(7,83,50,30), Qt::AlignVCenter | Qt::AlignHCenter, QString::number((100 * dvd_actual_size)/dvd_total_size) + "%");
		p.end();
		jauge_dvd->setPixmap(wl_pix_001);
	}
}

// ***********************************
// *** GESTION DES MENUS THUMBNAIL ***
// ***********************************

void mainfrm::f_add_menu()
{
	if ( nbre_menuth < 19 )
	{
		// *** AJOUT D'UN MENU AU PROJET DVD ***
		f_close_editor_txt();
		must_update = 0;
		hdl_current_menuth->is_edit = 0;

		f_update_thumb_menu();
		nbre_menuth++;

		// *** SAUVEGARDE DES INFORMATIONS DU MENU ***
		f_save_widgetonmenu();
		// *** SUPPRESSION DE TOUS LES ELEMENTS DU MENU COURANT ***
		f_delete_widgetonmenu();

		bttxt->setPlainText("");
		// *** CREATION MINIATURE DU NOUVEAU MENU ***
		menu_th *newmenu = new menu_th(frame_support_menuthumb);
		newmenu->setGeometry( 2+(nbre_menuth*106), 0, 106, 106 );
		newmenu->draw_image = QPixmap(path_project+"/DVD/TEMP/nofd.png").scaledToWidth ( 88, Qt::FastTransformation );
		//newmenu->draw_image.fill(QColor(0,0,0));
		newmenu->is_edit = 1;
		newmenu->is_first = nbre_menuth + 1;
		newmenu->show();
		table_hdl_menuth[nbre_menuth] = newmenu;
		connect(newmenu, SIGNAL(select_menuth(menu_th*) ),this, SLOT(f_select_menuth(menu_th*)));
		connect(newmenu, SIGNAL(delete_menu(menu_th*) ),this, SLOT(f_delete_menuth(menu_th*)));
		hdl_current_menuth = newmenu;

		// *** CREATION DU MENU DANS L'ARBORESCENCE ***
		item_menu *newmenuarb = new item_menu(frame_syno);
		if ( nbre_menuth == 0 && nbre_medias == 0 )
		{
			newmenuarb->setGeometry( 2, 0, 106, 106 );
		}
		else
		{
			int wl_calcpos = 2+(110*((nbre_medias+nbre_menuth)-1));
			int wl_multi = 1;
			if ( wl_calcpos > 600 )
			{
				wl_multi = ((float)wl_calcpos/(float)600);
				wl_calcpos = wl_calcpos - (wl_multi*600);
				newmenuarb->setGeometry( 2+wl_calcpos, 110*(wl_multi+1), 106, 106 );
			}
			else
			{
				newmenuarb->setGeometry( wl_calcpos, 110*wl_multi, 106, 106 );
			}
		}
		connect(newmenuarb, SIGNAL(item_move(item_menu*) ),this, SLOT(f_item_move(item_menu*)));
		connect(newmenuarb, SIGNAL(item_select(item_menu*) ),this, SLOT(f_item_select(item_menu*)));
		connect(newmenuarb, SIGNAL(affiche_info(item_menu*) ),this, SLOT(f_affiche_info_arbo(item_menu*)));
		connect(newmenuarb, SIGNAL(hide_info(item_menu*) ),this, SLOT(f_hide_info_arbo(item_menu*)));
		connect(newmenuarb, SIGNAL(add_link(item_menu*,int) ),this, SLOT(f_add_link(item_menu*,int)));
		connect(newmenuarb, SIGNAL(add_link_media(item_menu*,QString) ),this, SLOT(f_add_link_media(item_menu*,QString)));
		connect(newmenuarb, SIGNAL(edit_menu_tree(item_menu*) ),this, SLOT(f_edit_menu_tree(item_menu*)));
		newmenuarb->show();
		frame_syno->tab_pnt_item[nbre_menuth] = newmenuarb;

		combo_quoilire_menu->insertItem(nbre_menuth+1,"Menu " + QString::number(nbre_menuth));

		current_menu_background = path_project+"/DVD/TEMP/nofd.png";
		scale_current_menu_background = 0;
		background_menu->setPixmap(QPixmap(current_menu_background));
		//f_generation_scale();

		// *** ON VEROUILLE LA BARRE D'OUTILS ***
		current_menu_audio = "";
		current_menu_intro = "";
		current_loop = 0;

		is_is_intro->setToolTip("");
		is_is_intro->is_active = 0;
		is_is_intro->repaint();

		is_is_sound->setToolTip("");
		is_is_sound->is_active = 0;
		is_is_sound->repaint();

		bt_bt_img->setDisabled(true);
		dial_alpha_menu->setDisabled(true);
		combo_quoilire_media->setDisabled(true);
		combo_quoilire_media_chapitre->setDisabled(true);
		combo_select_langue->setDisabled(true);
		combo_quoilire_menu->setDisabled(true);
		bttxt->setDisabled(true);
		frame_th_msk_idea->setDisabled(true);
		bt_tool_1->setDisabled(true);
		bt_tool_2->setDisabled(true);
		bt_tool_3->setDisabled(true);
		bt_tool_4->setDisabled(true);
		actionOrdre_de_tabulation->setDisabled(true);
		must_update = 1;

		if ( (nbre_menuth*110) > frame_support_menu_th_contain->width() )
		{
			frame_support_menuthumb->setGeometry(0,0,((nbre_menuth+1)*110),106);
			scroll_timeline->setMaximum(((nbre_menuth+1)*110)-frame_support_menu_th_contain->width());
			scroll_timeline->setEnabled(true);
		}
		else
		{
			frame_support_menuthumb->setGeometry(0,0,frame_support_menu_th_contain->width(),106);
			scroll_timeline->setMaximum(0);
			scroll_timeline->setDisabled(true);
		}
		//f_update_thumb_menu();
	}
	else
	{
		QMessageBox::information(this, name_application, tr("Vous ne pouvez plus ajouter de nouveaux menus. Maximum atteint."));
	}
}

void mainfrm::f_previous_menu()
{
	// *** RECHERCHE DE LA POSITION DU MENU SELECTIONNE ***
	wg_int_001=0;
	while ( table_hdl_menuth[wg_int_001] != hdl_current_menuth && wg_int_001 < nbre_menuth )
	{
		wg_int_001++;
	}
	if ( table_hdl_menuth[wg_int_001] == hdl_current_menuth && wg_int_001 != 0 )
	{
		f_select_menuth(table_hdl_menuth[wg_int_001-1]);
	}
}

void mainfrm::f_next_menu()
{
	// *** RECHERCHE DE LA POSITION DU MENU SELECTIONNE ***
	wg_int_001=0;
	while ( table_hdl_menuth[wg_int_001] != hdl_current_menuth && wg_int_001 < nbre_menuth )
	{
		wg_int_001++;
	}
	if ( table_hdl_menuth[wg_int_001] == hdl_current_menuth && wg_int_001 < nbre_menuth )
	{
		f_select_menuth(table_hdl_menuth[wg_int_001+1]);
	}
}

void mainfrm::f_preview_overlay()
{
	QPixmap wl_pix_001(90,40);
	wl_pix_001.fill(QColor(0,0,0,0));
	QPainter p;
	p.begin(&wl_pix_001);
	p.drawPixmap(0, 0, QPixmap(":/Interface/Interface/fd_transparent.png"), 0, 0, 90, 40);
	p.setPen(Qt::NoPen);
	p.setBrush(QColor(pntwheel1->red,pntwheel1->green,pntwheel1->blue,dial_opacity_overlay->value()));
	p.drawRect(0,0,45,40);
	p.setBrush(QColor(pntwheel2->red,pntwheel2->green,pntwheel2->blue,dial_opacity_overlay->value()));
	p.drawRect(45,0,45,40);
	p.setPen(QColor(0,0,0));
	p.setBrush(QColor(0,0,0,0));
	p.drawRect(0,0,89,39);
	p.end();
	overlay_preview->setPixmap(wl_pix_001);
}

void mainfrm::f_overlay_menu()
{
	mask_interface->show();
	mask_interface->raise();
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 2;
	thread_ani->sens = 1;
	thread_ani->isrender = 0;
	f_preview_overlay();
	frame_overlays->show();
	frame_overlays->raise();
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_valide_overlay()
{
	mask_interface->show();
	mask_interface->raise();
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 220;
	thread_ani->sens = 2;
	thread_ani->isrender = 0;
	smenuBar->setEnabled(true);
	frame_overlays->hide();
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_delete_menuth(menu_th* hdlmenuth)
{
	// *** RECHERCHE DE LA POSITION DU MENU SELECTIONNE ***
	wg_int_001=0;
	while ( table_hdl_menuth[wg_int_001] != hdlmenuth && wg_int_001 < nbre_menuth )
	{
		wg_int_001++;
	}
	if ( table_hdl_menuth[wg_int_001] == hdlmenuth )
	{
		// *** DECALAGE DES POINTEURS DE MENU ***
		wg_int_002 = wg_int_001;
		delete frame_syno->tab_pnt_item[wg_int_002];
		while ( wg_int_002 < nbre_menuth )
		{
			table_hdl_menuth[wg_int_002] = table_hdl_menuth[wg_int_002+1];

			table_menus_property[wg_int_002][0] = table_menus_property[wg_int_002+1][0];
			table_menus_property[wg_int_002][1] = table_menus_property[wg_int_002+1][1];
			table_menus_property[wg_int_002][2] = table_menus_property[wg_int_002+1][2];
			table_menus_property[wg_int_002][3] = table_menus_property[wg_int_002+1][3];
			table_menus_property[wg_int_002][4] = table_menus_property[wg_int_002+1][4];
			table_menus_property[wg_int_002][5] = table_menus_property[wg_int_002+1][5];
			table_menus_property[wg_int_002][6] = table_menus_property[wg_int_002+1][6];
			table_menus_property[wg_int_002][7] = table_menus_property[wg_int_002+1][7];
			table_menus_property[wg_int_002][8] = table_menus_property[wg_int_002+1][8];

			table_hdl_menuth[wg_int_002+1]->setGeometry( 2+(wg_int_002*106), 0, 106, 106 );
			table_hdl_menuth[wg_int_002+1]->is_first = table_hdl_menuth[wg_int_002+1]->is_first--;
			table_hdl_menuth[wg_int_002+1]->repaint();

			// *** DECALAGE DES MENUS DE L'ARBORESCENCE ***
			frame_syno->tab_pnt_item[wg_int_002] = frame_syno->tab_pnt_item[wg_int_002+1];

			wg_int_002++;
		}
		// *** DECALAGE DES BOUTONS ***
		wg_int_002 = wg_int_001;

		while ( wg_int_002 < nbre_menuth )
		{
			wg_int_003 = 0;
			while ( table_menus[wg_int_002+1][wg_int_003][0] != "$$$" )
			{
				wg_int_004 = 0;
				while ( wg_int_004 < 25 )
				{
					table_menus[wg_int_002][wg_int_003][wg_int_004] = table_menus[wg_int_002+1][wg_int_003][wg_int_004];
					wg_int_004++;
				}
				wg_int_003++;
			}
			table_menus[wg_int_002][wg_int_003][0] = "$$$";
			wg_int_002++;
		}
		// *** REVALIDATION DES REFERENCES DES BOUTONS ***
		wg_int_002 = 0;
		while ( wg_int_002 < nbre_menuth )
		{
			wg_int_003 = 0;
			while ( table_menus[wg_int_002][wg_int_003][0] != "$$$" )
			{
				if ( table_menus[wg_int_002][wg_int_003][5] == "!M!Menu " + QString::number(wg_int_001) )
				{
					table_menus[wg_int_002][wg_int_003][5] = "";
				}
				else
				{
					if ( table_menus[wg_int_002][wg_int_003][5].left(8) == "!M!Menu " )
					{
						wg_string_001 = table_menus[wg_int_002][wg_int_003][5];
						wg_string_001.remove(0,8);
						wg_int_004 = wg_string_001.toInt();

						if ( wg_int_004 > wg_int_001 )
						{
							table_menus[wg_int_002][wg_int_003][5] = "!M!Menu " + QString::number(wg_int_004-1);
						}
					}
				}
				wg_int_003++;
			}
			wg_int_002++;
		}
		nbre_menuth--;
		special_delete = 1;
		f_select_menuth(table_hdl_menuth[0]);
		special_delete = 0;
		//
		if ( (nbre_menuth*100) > frame_support_menu_th_contain->width() )
		{
			frame_support_menuthumb->setGeometry(0,0,((nbre_menuth+1)*100),106);
			scroll_timeline->setMaximum(((nbre_menuth+1)*100)-frame_support_menu_th_contain->width());
			scroll_timeline->setEnabled(true);
		}
		else
		{
			frame_support_menuthumb->setGeometry(0,0,frame_support_menu_th_contain->width(),106);
			scroll_timeline->setMaximum(0);
			scroll_timeline->setDisabled(true);
		}
		//
		must_update = 0;

		combo_quoilire_menu->clear();
		combo_quoilire_menu->insertItem(0,wg_str_int_002);
		combo_quoilire_menu->insertItem(1,wg_str_int_003);
		wg_int_002 = 0;
		while ( wg_int_002 < nbre_menuth )
		{
			combo_quoilire_menu->insertItem(wg_int_002+2,"Menu " + QString::number(wg_int_002+1));
			wg_int_002++;
		}

		combo_quoilire_media->setCurrentIndex(0);
		combo_quoilire_media_chapitre->setCurrentIndex(0);
		combo_quoilire_menu->setCurrentIndex(0);
		combo_quoilire_media->setDisabled(true);
		bt_tool_1->setDisabled(true);
		bt_tool_2->setDisabled(true);
		bt_tool_3->setDisabled(true);
		bt_tool_4->setDisabled(true);
		bt_bt_img->setDisabled(true);
		dial_alpha_menu->setDisabled(true);
		bttxt->setDisabled(true);
		frame_th_msk_idea->setDisabled(true);
		combo_quoilire_media->setDisabled(true);
		check_anim->setDisabled(true);
		combo_select_langue->setDisabled(true);
		combo_quoilire_media_chapitre->setDisabled(true);
		combo_quoilire_menu->setDisabled(true);
		must_update = 1;
		hdl_current_menu = 0;
		actionCopier_le_bouton->setDisabled(true);
		f_close_editor_txt();
	}
	else
	{
		qDebug() << "ERROR FINDING MENU FOR DELETING";
	}
}

void mainfrm::f_select_menuth(menu_th* hdlmenuth)
{
	if ( hdlmenuth != hdl_current_menuth )
	{
		frame_support_menuthumb->setDisabled(true);
		sur_blend->setPixmap(QPixmap::grabWidget(screen_designer));
		thread_blend->srcImage = sur_blend->pixmap()->toImage();
		thread_blend->dstImage = thread_blend->srcImage;
		sur_blend->setGeometry(frame_support_editor->geometry().x(),frame_support_editor->geometry().y()+top_window->height(),background_menu->width(),background_menu->height());
		sur_blend->show();
		sur_blend->raise();

		// *** RELEVER L'ENSEMBLE DES CONTROLES ***
		frame_is_is->raise();
		h_regle->raise();
		v_regle->raise();
		frame_lst_menus->raise();

		must_update = 0;
		if ( special_delete == 0 )
		{
			hdl_current_menuth->is_edit = 0;
			// *** CHANGEMENT DU MENU COURANT ***
			f_update_thumb_menu();
			// *** SAUVEGARDE DES INFORMATIONS DU MENU ***
			f_save_widgetonmenu();
		}
		bttxt->setPlainText("");

		// *** SUPPRESSION DE TOUS LES ELEMENTS DU MENU COURANT ***
		f_delete_widgetonmenu();
		actionOrdre_de_tabulation->setDisabled(true);

		// *** RECHERCHE DE LA POSITION DU MENU SELECTIONNE ***
		wg_int_001=0;
		while ( table_hdl_menuth[wg_int_001] != hdlmenuth && wg_int_001 < nbre_menuth )
		{
			wg_int_001++;
		}

		// *** CHARGEMENT BACKGROUND ET AUTRES THEMES ***
		current_menu_background = table_menus_property[wg_int_001][0];
		scale_current_menu_background = table_menus_property[wg_int_001][1].toInt();
		current_menu_audio = table_menus_property[wg_int_001][4];

		current_menu_intro = table_menus_property[wg_int_001][5];
		current_intro_zik = table_menus_property[wg_int_001][8];
		current_loop = table_menus_property[wg_int_001][7].mid(0,1).toInt();
		loop_length = table_menus_property[wg_int_001][7].mid(1,table_menus_property[wg_int_001][7].length()-1).toInt();

		if ( current_menu_intro == "" )
		{
			is_is_intro->setToolTip("");
			is_is_intro->is_active = 0;
			screen_designer->has_intro = 0;
			is_is_intro->repaint();
		}
		else
		{
			is_is_intro->setToolTip(current_menu_intro);
			is_is_intro->is_active = 1;
			screen_designer->has_intro = 1;
			is_is_intro->repaint();
		}

		if ( current_menu_audio == "" )
		{
			is_is_sound->setToolTip("");
			is_is_sound->is_active = 0;
			screen_designer->has_sound = 0;
			is_is_sound->repaint();
		}
		else
		{
			is_is_sound->setToolTip(current_menu_audio);
			is_is_sound->is_active = 1;
			screen_designer->has_sound = 1;
			is_is_sound->repaint();
		}

		if ( current_menu_background != "" && current_menu_background != path_project+"/DVD/TEMP/nofd.png" )
		{
			if ( current_menu_background.right(4) != ".MPG" && current_menu_background.right(4) != ".mpg" && current_menu_background.right(4) != ".AVI" && current_menu_background.right(4) != ".avi" )
			{
				f_generation_scale();
			}
			else
			{
		   		wg_int_002 = current_menu_background.lastIndexOf( '/' );
		    		if ( wg_int_002 != -1 )
		    		{
					background_menu->setPixmap(path_project+"/DVD/TEMP/"+current_menu_background.mid(wg_int_002+1,current_menu_background.length()-(wg_int_002+1))+".jpg");
				}
				else
				{
					qDebug() << "ERROR IN BACKGROUND NAME NO / : " << current_menu_background;
					background_menu->setPixmap(QPixmap(path_project+"/DVD/TEMP/nofd.png"));
				}
			}
		}
		else
		{
			// *** AUCUN FOND DEFINIS ***
			background_menu->setPixmap(QPixmap(path_project+"/DVD/TEMP/nofd.png"));
		}

		QString wl_str_001 = table_menus_property[wg_int_001][2];
		QStringList wl_explode = wl_str_001.split(";",QString::KeepEmptyParts);
		pntwheel1->setColor(wl_explode.at(0).toInt(),wl_explode.at(1).toInt(),wl_explode.at(2).toInt());

		wl_str_001 = table_menus_property[wg_int_001][3];
		wl_explode = wl_str_001.split(";",QString::KeepEmptyParts);
		pntwheel2->setColor(wl_explode.at(0).toInt(),wl_explode.at(1).toInt(),wl_explode.at(2).toInt());

		dial_opacity_overlay->setValue(table_menus_property[wg_int_001][6].toInt());

		// *** CREATION DES BOUTONS SUR LE MENU ***
		if ( table_hdl_menuth[wg_int_001] == hdlmenuth )
		{
			wg_int_002 = 0;
			while ( table_menus[wg_int_001][wg_int_002][0] != "$$$" )
			{
				f_create_menu_movie();
				wg_int_002++;
			}
			hdl_current_menuth = hdlmenuth;
			hdl_current_menuth->is_edit = 1;
			hdl_current_menuth->repaint();
		}
		else
		{
			qDebug() << "MEMORY ERROR SEARCHING SELECT MENUTH";
		}

		// *** BLOCAGE DES BARRES D'OUTILS ***
		hdl_current_menu = 0;
		actionCopier_le_bouton->setDisabled(true);
		must_update = 0;
		combo_quoilire_media->setCurrentIndex(0);
		combo_quoilire_media_chapitre->setCurrentIndex(0);
		combo_quoilire_menu->setCurrentIndex(0);
		combo_quoilire_media->setDisabled(true);
		combo_select_langue->setDisabled(true);
		bt_tool_1->setDisabled(true);
		bt_tool_2->setDisabled(true);
		bt_tool_3->setDisabled(true);
		bt_tool_4->setDisabled(true);
		bt_bt_img->setDisabled(true);
		dial_alpha_menu->setDisabled(true);
		bttxt->setDisabled(true);
		frame_th_msk_idea->setDisabled(true);
		combo_quoilire_media->setDisabled(true);
		check_anim->setDisabled(true);
		combo_quoilire_media_chapitre->setDisabled(true);
		combo_quoilire_menu->setDisabled(true);
		must_update = 1;
		//
		thread_blend->srcImage2 = QPixmap::grabWidget(screen_designer).toImage();
		thread_blend->sequence = 0;
		QTimer::singleShot(5, this, SLOT(f_run_bld()));
		frame_advanced_text->setGeometry(frame_advanced_text->geometry().x(),frame_advanced_text->geometry().y(),frame_advanced_text->width(),0);
		frame_actions->setGeometry(frame_advanced_text->geometry().x(),frame_advanced_text->geometry().y(),frame_actions->width(),frame_actions->height());
		thread_menu->wy = 0;
	}
}

// *************************
// *** GESTION DES MENUS ***
// *************************

void mainfrm::f_select_background()
{
	// *** CHOIX DE L'ARRIERE PLAN ***

	top_window->setDisabled(true);
	frame_pro->setDisabled(true);

	menuProjet->setDisabled(true);
	menuMenu->setDisabled(true);
	menuAffichage->setDisabled(true);
	menuG_n_ration->setDisabled(true);
	menuEdition->setDisabled(true);
	actionMenu_pr_c_dent->setDisabled(true);
	actionMenu_suivant->setDisabled(true);
	actionCouleurs_des_overlays->setDisabled(true);
	actionParam_tres_avanc_s->setDisabled(true);
	menuA_propos->setDisabled(true);
	frame_editor->setDisabled(true);

	frame_lst_menus->hide();

	myfileopen *hdlfopen = new myfileopen(this);
	hdlfopen->setDirectory(path_background);
	hdlfopen->source = 0;
	hdlfopen->setWindowTitle(tr("Arriere plan du menu"));
	hdlfopen->setFilter("(*.PNG *.png *.jpg *.JPG *.jeg *.JPEG *.MPG *.mpg *.AVI *.avi)");
	connect(hdlfopen, SIGNAL(change_image(QString)),this, SLOT(f_open_ipreview(QString)));
	connect(hdlfopen, SIGNAL(filesSelected( const QStringList )),this, SLOT(f_close_ipreview( const QStringList )));
	connect(hdlfopen, SIGNAL(f_close()),this, SLOT(f_cancel_ipreview()));
	connect(hdlfopen, SIGNAL(finished(int)),this, SLOT(f_cancel_ipreview()));

	pntfiled = hdlfopen;

	hdlfopen->show();
	hdlfopen->raise();
}

void mainfrm::thvi_end(int, QProcess::ExitStatus)
{
	QPixmap wl_pix_001(dvdxsize,dvdysize);
	wl_pix_001.fill(QColor(0,0,0));

	QPixmap wl_pix_002(path_project + "/DVD/TEMP/" + wg_string_004 + ".jpg");

	QPixmap wl_pix_003 = wl_pix_002.scaledToWidth(dvdxsize, Qt::FastTransformation);

	QPainter p;
	p.begin(&wl_pix_001);
	p.drawPixmap((wl_pix_001.width() - wl_pix_003.width()) / 2, (wl_pix_001.height() - wl_pix_003.height()) / 2, wl_pix_003 );
	p.end();

	wl_pix_001.save(path_project + "/DVD/TEMP/" + wg_string_004 + ".jpg");

	background_menu->setPixmap(wl_pix_001);
	f_update_thumb_menu();
}

void mainfrm::f_valide_scale_background_1()
{
	current_menu_background = wg_string_001;
	scale_current_menu_background = 1;
	background_menu->setPixmap(wg_pix_001);
	frame_scale_background->hide();
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 220;
	thread_ani->sens = 0;
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_valide_scale_background_2()
{
	current_menu_background = wg_string_001;
	scale_current_menu_background = 2;
	background_menu->setPixmap(wg_pix_002);
	frame_scale_background->hide();
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 220;
	thread_ani->sens = 0;
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

// *************************
// *** DIVERS TRAITEMENT ***
// *************************

void mainfrm::f_apropos_open()
{
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 2;
	thread_ani->sens = 1;
	thread_ani->isrender = 0;
	mask_interface->show();
	mask_interface->raise();
	frame_apropos->show();
	frame_apropos->raise();
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_apropos_close()
{
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 220;
	thread_ani->sens = 0;
	frame_apropos->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_advanced_open()
{
	if ( current_loop == 0 )
	{
		check_loop_back->setChecked(false);
	}
	else
	{
		check_loop_back->setChecked(true);
	}
	spin_duree_vig->setValue(loop_length);
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 2;
	thread_ani->sens = 1;
	thread_ani->isrender = 0;
	mask_interface->show();
	mask_interface->raise();
	frame_advanced->show();
	frame_advanced->raise();
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_advanced_close()
{
	loop_length = spin_duree_vig->value();
	thread_ani->hdlmsk = mask_interface;
	thread_ani->progress = 220;
	thread_ani->sens = 0;
	frame_advanced->hide();
	smenuBar->setEnabled(true);
	QTimer::singleShot(5, this, SLOT(f_run_ani()));
}

void mainfrm::f_put_loop(int)
{
	// *** LE MENU DOIT IL ETRE UNE BOUCLE VIDEO ***
	if ( check_loop_back->isChecked() == true )
	{
		current_loop = 1;
	}
	else
	{
		current_loop = 0;
	}
}

// **********************************
// *** CAPTURE DE L'IMAGE DU MENU ***
// **********************************

void mainfrm::f_screengrab_menu()
{
        if ( hdl_current_menu != 0 )
	{
		hdl_current_menu->is_select = 0;
		hdl_current_menu = 0;
		actionCopier_le_bouton->setDisabled(true);
		bt_bt_img->setDisabled(true);
		dial_alpha_menu->setDisabled(true);
		combo_quoilire_media->setDisabled(true);
		combo_quoilire_media_chapitre->setDisabled(true);
		combo_select_langue->setDisabled(true);
		combo_quoilire_menu->setDisabled(true);
		bttxt->setDisabled(true);
		frame_th_msk_idea->setDisabled(true);
		bt_tool_1->setDisabled(true);
		bt_tool_2->setDisabled(true);
		bt_tool_3->setDisabled(true);
		bt_tool_4->setDisabled(true);
	}
	int wl_int_001=0;
	while ( wl_int_001 < nbre_medias )
	{
		table_hdl_medias[wl_int_001]->is_select = 0;
		table_hdl_medias[wl_int_001]->repaint();
		wl_int_001++;
	}
	QPixmap wlpixmap = QPixmap::grabWidget(screen_designer);
	QString wmyimg = QFileDialog::getSaveFileName(this, tr("Sauvegarder l'image"), path_capture, tr("Image (*.jpg)"));
       	if ( wmyimg.isNull() )
       	{
		return;
       	}
	else
	{
   		wg_int_001 = wmyimg.lastIndexOf( '/' );
    		if ( wg_int_001 != -1 )
    		{
        		path_capture = wmyimg.mid(0,wg_int_001);
    		}

		if ( wmyimg.right(4) != ".jpg" )
		{
			wmyimg = wmyimg + ".jpg";
		}
		wlpixmap.save(wmyimg,"JPEG");
	}
}

// *****************************
// *** FENETRE DOCUMENTATION ***
// *****************************

void mainfrm::f_documentation()
{
	helpfrm *hlpdialog = new helpfrm;
	hlpdialog->show();
}

// ********************************
// *** DESSIN DU FOND DU WIDGET ***
// ********************************

void mainfrm::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);
	p.drawTiledPixmap(0,this->height()-fond_application.height(),this->width(),fond_application.height(),fond_application,0,0);
	p.drawPixmap(10,this->height()-500,-1,-1,fond_application_2);
	p.end();
}

