#ifndef MAINFRM_H
#define MAINFRM_H

#include <QDialog>
#include <QProcess>
#include <QDirModel>
#include <QListWidgetItem>
#include <QScrollArea>
#include "ui_mainfrm.h"
#include "tetrahedron.h"
#include "imageeditor.h"
#include "mypainter.h"
#include "texteditor.h"
#include "timeline.h"
#include "mylstfiles.h"
#include "diapo.h"
#include "wheel.h"
#include "thimg.h"
#include "ththu.h"
#include "thtra.h"
#include "thani.h"
#include "thptra.h"
#include "timestamp.h"
#include "helpfrm.h"
#include "audio_editor.h"

class mainfrm : public QMainWindow, public Ui::mainfrm
{
	Q_OBJECT
	public:
		mainfrm(QWidget *parent = 0);
		Tetrahedron *pntmygl;
		QDirModel *pntdir;
		QScrollArea *scrollArea_1;
		QScrollArea *scrollArea_2;
		QScrollArea *scrollArea_3;
		QScrollArea *scrollArea_4;
		QScrollArea *scrollArea_5;
		QScrollArea *scrollArea_6;
		QScrollArea *scrollArea_7;
		QScrollArea *scrollArea_8;
		timestamp *pntstamp;
		audio_editor *zik_1;
		QModelIndex idxmod;
		int nbre_threads;
    		QListWidgetItem *mywidget;
		QString current_path;
		QString path_photos_capture;
		QString path_musique_import;
		QString table_photos[400][29];
		int table_compo[20];
		QColor table_color_fog[400];
		QLabel *table_pnt_img[400];
		QLabel *table_pnt_tran[400];
		imageeditor *pntlabel;
		texteditor *pntlabeltxt;
		timeline *pnttimeline;
		wheel *pntwheelback;
		wheel *pntwheelfog;
		wheel *pntwheeltxt;
		wheel *pntwheelouv;
		wheel *pntwheelbac;
		wheel *pntwheeldeg1;
		wheel *pntwheeldeg2;
		wheel *pntwheelpaint;
		wheel *pntwheeleraser;
		QString table_transitions[100];
		QImage table_image_transition[100];
		QImage table_preview_transition[250];
		QString wgcpast;
		QString wpathprojet;
		QString outfilename;
		QString wglob_str_1;
		QString wg_library;
		QString wg_save_filename;
		int size_dia_x;
		int size_dia_y;
		int etat_lecture;
		int nbre_photos;
		int current_diapo;
		int old_current_diapo;
		int poursuite;
		int w_y;
		int w_x;
		int poursuite_1;
		int w_y_1;
		int w_x_1;
		int isgrid;
		int zik_number;
		int total_audio;
		int tmpint_1;
		int tmpint_2;
		int tmpint_3;
		int tmpint_4;
		int tmpint_5;
		int tmpint_6;
		int poursuite_2;
		int nbre_imports;
		QString table_zik[1][2];
		int must_redraw;
		int ispreview;
		int position_flux;
		int nbre_occurs;
		int total_diapo;
		QPixmap wg_comment;
		QPixmap wg_diapositive;
		QPixmap gl_pix_1;
		bool isplaying;
		QFrame *curframe;
		QTimer *mplayer_timer;
		QString wg_tmp_001;
		QString wg_tmp_002;
		QString wg_tmp_003;
		QString wg_tmp_004;
		QString wg_tmp_005;
		QByteArray newData;
		QImage wg_grab_render;
		//
		int nbre_new;
		int is43;
		int state_timeline;
		int must_swap;
		int result_position;
		int old_tab;
		int wfrom;
		int wto;
		int rendering_number;
		int nbre_render_transition;
		int nbre_comment;
		QString myconsole;
		QString global_legende;
		//
		QImageReader reader;
		QSize mysize;
		//
		int gorender;
		QTime mysynctime;

		int startx_legani;
		int starty_legani;
		int endx_legani;
		int endy_legani;
		int deltax_legani;
		int deltay_legani;

		float adjust_transition;
		float compute_adjust_transition;
	private slots:
		void f_align_1();
		void f_align_2();
		void f_align_3();
		void f_align_4();
		void f_gene_vignette(QImage);

		void f_go_start_legani();
		void f_go_end_legani();
		void f_mk_start_legani();
		void f_mk_end_legani();
		void f_empty_diapo();
		void f_duplicate();
		void f_resizer();
		void f_hideright();
		void f_update_move_editor(int,int);
		void f_render_bcle_lecture();
		void f_render_updateMove();
		void f_render_end_ptransition();
		void f_checkrotationeffet(int);

		void f_effet_nombre(int);
		void f_effet_taille(int);
		void f_effet_speed(int);
		void f_apply_effetsup(int);
		void f_play_result();
		void f_random();
		void f_import_background();
		void f_import_dianim();
		void f_stop_zik();
		void f_painter_fermer();
		void f_painter_init();
		void f_close_dep();
		void f_nextstep();
		void lecture_console_dep();
		void end_check_dep(int, QProcess::ExitStatus);
		void f_rotation_spin(int);
		void f_checkinvert(int);
		void f_documentation();
		void f_btrotation_img();
		void f_rotation_img(int);
		void f_scale(int);
		void f_slice(int);
		void f_apropos();
		void f_close_apropos();
		void f_change_color_eraser();
		void f_opac_gommer(int);
		void f_gommer();
		void f_size_gommer(int);
		void f_painter_brush1();
		void f_painter_brush2();
		void f_painter_brush3();
		void f_painter_brush4();
		void f_painter_brush5();
		void f_painter_brush6();
		void f_painter_brush7();
		void f_painter_brush8();
		void f_opencomplex();
		void f_hide_complex();
		void f_calcul_coo();
		void f_follow_timeline(int);
		void f_mark_timeline(int);
		void f_umark_timeline();
		void f_painter_efface();
		void f_painter_draw();
		void f_painteropa(int);
		void f_paintersiz(int);
		void f_change_color_painter();
		void f_painter();
		void f_end_ptransition();
		void f_leg_fondu(int);
		void f_apply_forme(int);
		void f_import_pictures();
		void f_saveas_proj();
		void f_import_folder();
		void f_sizep();
		void f_sizem();
		void f_updfrm(int);
		void f_save_param();
		void f_find_tempfolder();
		void f_update_fade();
		void f_startani();
		void f_close_param_rendering();
		void f_param_rendering();
		void f_leg_filename();
		void f_ext_open(QString);
		void f_lngdeg(int);
		void f_lngdeg_valide();
		void f_deg1_couleur_valide();
		void f_deg2_couleur_valide();
		void f_change_color_deg_1();
		void f_change_color_deg_2();
		void f_rogner();
		void f_ok_rogner();
		void f_forme();
		void f_ok_forme();
		void f_apply_composition(int);
		void f_gliss_left();
		void f_gliss_right();
		void f_leg_size(int);
		void f_leg_bold();
		void f_leg_italic();
		void f_font_comment(const QFont &);
		void f_change_color_txt();
		void f_open_title(int);
		void f_bcle_lecture();
		void f_update_thumbail();
		void f_update_editor();
		void f_tool_editor_2();
		void f_tool_editor_3();
		void f_tool_editor_4();
		void f_tool_editor_5(int);
		void f_tool_editor_6(int);
		void f_tool_editor_7(int);
		void f_tool_editor_8(int);
		void f_tool_editor_9(int);
		void f_tool_editor_10();
		void f_tool_editor_11();
		void f_tool_editor_12();
		void f_tool_editor_13(int);
		void f_tool_editor_13_r(int);
		void f_tool_editor_13_l(int);
		void f_tool_editor_13_o(int);
		void f_tool_editor_14();
		void f_tool_editor_15();
		void insert_photo();
		void f_txtedit_chtxt();
		void f_cancel_editor();
		void f_annuler_editor();
		void f_ok_editor();
		void f_launch_editor();
		void f_resize(QResizeEvent *);
		void f_start_close();
		void f_mblur(int);
		void f_size_anim(int);
		void f_rot_anim(int);
		void f_pos_anim();
		void f_dbl_load_photo();
		void f_change_color_bac();
		void f_change_opacity_back(int);
		void f_splash_load();
		void f_refresh_liste();
		void f_select_new();
		void f_launch_new();
		void f_open_bib();
		void f_open_bib_fond();
		void f_close_bib();
		void f_cancel_new();
		void f_affiche_preview();
		void f_cancel_param_import();
		void f_charge_liste_files(QString);
		void f_chng_directory();
		void f_updateMove();
		void f_fond_couleur();
		void f_fond_couleur_valide();
		void f_reload();
		void f_find_out();
		void f_end_mainfrm();
		void f_ajout_effet();
		void f_remove_effet();
		void f_start_new();
		void f_change_color_fog();
		void f_change_color_ouv();
		void f_changedur_2(int);
		void f_supp_comment();
		void f_swap_swap(int, int);
		void f_calcul_son();
		void f_close_param_import();
		void f_open_comment();
		void f_save_proj();
		void f_open_proj();
		void f_sync();
		void f_raz();
		void f_copy();
		void f_paste();
		void f_chg_tool_a();
		void f_chg_tool_b();
		void f_chg_tool_c();
		void f_chg_tool_d();
		void f_chg_tool_e();
		void f_chg_tool_f();
		void f_change_fond();
		void f_brouillard(int);
		void f_backanim(int);
		void f_percent_blending(int);
		void f_percent_blending_2(int);
		void f_opacity(int);
		void f_opacity_2(int);
		void f_opacity_slide(int);
		void md_fin();
		void md_start();
    		void start_play_all();
		void supp_diapo();
		void affichage_diapo();
		void end_encoding();
		void f_generer_diapo();
		void f_changedur(int valeur);
		void f_render();
		bool eventFilter(QObject *o, QEvent *e);
		void f_scroll_timeline(int valeur);
		void f_transition_changed(int myindex);
		void f_transition_duree_changed(int);
		void f_screenshot();
		void f_affiche_parametres();
		void f_dep_gauche();
		void f_dep_droite();
		void keyPressEvent( QKeyEvent *k );
		void f_apply_effets(int state);
		void f_add_zik();
		void lecture_console_import_zik();
		void end_zik_import(int, QProcess::ExitStatus);
		void fin_fin_encoding();
		void f_sup_zik();
		void end_encoding_audio(int, QProcess::ExitStatus);
		void lecture_console_out_audio_encoding();
		void lecture_console_out_mencoder();
		void lecture_console_outerr_mencoder();
		void lecture_console_extract();
		void end_all_audio(int, QProcess::ExitStatus);
		void end_save_project(int, QProcess::ExitStatus);
		void end_extract_ani(int, QProcess::ExitStatus);
		void sl_go_start();
		void sl_go_end();
		void f_close_player();
		void prepare_insert_photo();
		void f_img_over();
		void f_invert_img_over();
		void f_cancel_img_over();
		// *** MPLAYER ***
		void player_open_video(QString);
		void player_play_video();
		void player_read_stdout();
		void player_percent_change();
		void player_start_percent_change();
		void player_end(int, QProcess::ExitStatus);
		void player_current_percent();
	private:
		QProcess myprocess_1;
		QProcess myprocess_2;
		QProcess myprocess_3;
		QProcess myprocess_4;
		QProcess myprocess_5;
		QProcess myprocess_9;
		QProcess mplayerProcess;

		thimg *thread_img;
		ththu *thread_thu;
		thtra *thread_tra;
		thani *thread_ani;
		thptra *thread_ptra;
	signals:
		void closing();
	protected:
		void resizeEvent(QResizeEvent *e)
		{
			QMainWindow::resizeEvent(e);
			emit f_resize(e);
		}
		virtual void closeEvent(QCloseEvent *e)
		{
			emit closing();
			QMainWindow::closeEvent(e);
		}
};
#endif
