void Principal::AbrirRed(char* fileName)
{
  red= Abrir(fileName);
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    //Create central widget and set main layout
    wgtMain_ = new QWidget(this);
    lytMain_ = new QGridLayout(wgtMain_);
    wgtMain_->setLayout(lytMain_);
    setCentralWidget(wgtMain_);

    //Initialize widgets
    mediaPlayer_  = new QMediaPlayer(this);
    playerSlider_ = new QSlider(Qt::Horizontal, this);
    videoWidget_  = new QVideoWidget(this);
    //volumeSlider_ = new QSlider(Qt::Horizontal, this);
    volumeSlider_ = new QSlider(Qt::Vertical,this);
    btnOpen_      = new QToolButton(this);
    btnPlay_      = new QToolButton(this);
    btnPause_     = new QToolButton(this);
    btnStop_      = new QToolButton(this);

    btnMinimizar_ = new QToolButton(this);
    //botones nuevos para las tareas
    btnAleatoria_ = new QToolButton(this);
    btnBucle_ = new QToolButton(this);


    //Sliders para el brillo, contraste y saturación
    brightnessSlider_ = new QSlider(Qt::Vertical);
    contrastSlider_ =   new QSlider(Qt::Vertical);
    saturavionSlider_ = new QSlider(Qt::Vertical);


    //Setup widwgets
    videoWidget_->setMinimumSize(600, 400);
    mediaPlayer_->setVideoOutput(videoWidget_);
    mediaPlayer_->setVolume(50);
    videoWidget_->setAspectRatioMode(Qt::KeepAspectRatio);
    volumeSlider_->setRange(0, 100);
    volumeSlider_->setSliderPosition(100);

    //Populate grid layout
    lytMain_->addWidget(videoWidget_,  0, 0, 1, 5);
    lytMain_->addWidget(playerSlider_, 1, 0, 1, 5);
    lytMain_->addWidget(btnOpen_,      2, 0, 1, 1);
    lytMain_->addWidget(btnPlay_,      2, 1, 1, 1);
    lytMain_->addWidget(btnPause_,     2, 2, 1, 1);
    lytMain_->addWidget(btnStop_,      2, 3, 1, 1);

    lytMain_->addWidget(btnMinimizar_, 0, 5, 1, 1);

    //botones nuevos
    lytMain_->addWidget(btnAleatoria_, 2,4,1,1);
    lytMain_->addWidget(btnBucle_, 2,5,1,1);


    lytMain_->addWidget(volumeSlider_, 2, 6, 1, 1);


    //Buttons icons
    btnOpen_->setIcon(QIcon(QPixmap(":/icons/resources/eject.png")));
    btnPause_->setIcon(QIcon(QPixmap(":/icons/resources/pause.png")));
    btnPlay_->setIcon(QIcon(QPixmap(":/icons/resources/play.png")));
    btnStop_->setIcon(QIcon(QPixmap(":/icons/resources/stop.png")));

    btnMinimizar_->setIcon(QIcon(QPixmap(":/icons/resources/minimizar.png")));

    //Buttons nuevos tareas icons
    btnAleatoria_->setIcon(QIcon(QPixmap(":/icons/resources/aleatoria.jpg")));
    btnBucle_->setIcon(QIcon(QPixmap(":/icons/resources/repetir.jpg")));

    //menu principal
    main_menu_= new QMenuBar(this);

    menu_archivo_= new QMenu ("Archivo", this);
    main_menu_->addMenu(menu_archivo_);
    setMenuBar(main_menu_);


    menu_ver_ = new QMenu ("Ver", this);
    main_menu_->addMenu(menu_ver_);
    setMenuBar(main_menu_);


    //Abrir
    Abrir_ = new QAction("Abrir", this);
    menu_archivo_->addAction(Abrir_);

    //Recientes
    Recientes_ = new QAction("Reciente", this);
    menu_archivo_->addAction(Recientes_);
    lista_recientes_ = new QListWidget();

    Cerrar_Recientes_ = new QAction("Cerrar Recientes", this);

    //rrecientes_ = new QMenu(tr("Recientes"),this);
    //rrecientes_->addAction(Recientes_);
    //menu_archivo_->addMenu(rrecientes_);
    menu_archivo_->addAction(Cerrar_Recientes_);

    Cargar_Lista_Reproduccion_ = new QAction("Cargar Lista",this);
    menu_archivo_->addAction(Cargar_Lista_Reproduccion_);


    this->setWindowIcon(QIcon(QPixmap(":/icons/resources/repro.png")));


    playlist_ = new QMediaPlaylist();


    //Ayuda
    Ayuda_ = new QAction("Ayuda", this);
    menu_archivo_->addAction(Ayuda_);


    menu_editar_ = new QMenu("Editar", this);
    main_menu_->addMenu(menu_editar_);
    Editar_ = new QAction("Imagen", this);

    menu_editar_->addAction(Editar_);


    //Ver pantalla completa
    Ver_pantalla_completa_ = new QAction("Ver_completa", this);
    Metadatas_ = new QAction("Metadata", this);
    menu_ver_->addAction(Ver_pantalla_completa_);
    menu_ver_->addAction(Metadatas_);

   // pantalla_completa_deshacer_ = new QAction(this);
   // pantalla_completa_deshacer_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));



    //salir de marcha
    Salir_ = new QAction("Salir", this);
    menu_archivo_->addAction(Salir_);



    //Connections
    connect(btnOpen_,      SIGNAL(pressed()),               this,         SLOT(onOpen()));
    connect(btnPlay_,      SIGNAL(pressed()),               mediaPlayer_, SLOT(play()));
    connect(btnPause_,     SIGNAL(pressed()),               mediaPlayer_, SLOT(pause()));
    connect(btnStop_,      SIGNAL(pressed()),               mediaPlayer_, SLOT(stop()));
    connect(playerSlider_, SIGNAL(sliderReleased()),        this,         SLOT(onSeek()));
    connect(mediaPlayer_,  SIGNAL(durationChanged(qint64)), this,         SLOT(onDurationChanged(qint64)));
    connect(mediaPlayer_,  SIGNAL(positionChanged(qint64)), this,         SLOT(onPositionChanged(qint64)));
    connect(volumeSlider_, SIGNAL(sliderMoved(int)),        this,         SLOT(onVolumeChanged(int)));

    //Connections NEW BUTTONS
    connect(btnBucle_,      SIGNAL(pressed()),              this,         SLOT(Bucle()));
    connect(btnAleatoria_,  SIGNAL(pressed()),              this,         SLOT(Aleatoria()));

    //boton minimizado
    connect(btnMinimizar_, SIGNAL(pressed()),              this,         SLOT(Minimizar()));

    //SLIDERS CONTRASTE SATURACION y BRILLO
    connect(contrastSlider_,      SIGNAL(sliderMoved(int)),               videoWidget_,         SLOT(setContrast(int)));
    connect(saturavionSlider_,      SIGNAL(sliderMoved(int)),               videoWidget_,         SLOT(setSaturation(int)));
    connect(brightnessSlider_,      SIGNAL(sliderMoved(int)),               videoWidget_,         SLOT(setBrightness(int)));


    connect(Editar_, SIGNAL(triggered()), this, SLOT(Ver_controles_edicion()) );

    //menu archivo
    connect(Abrir_, SIGNAL(triggered()), this, SLOT(Abrir()));

    connect(Recientes_, SIGNAL(triggered()), this, SLOT(Recientes_leer()));
    connect(Cerrar_Recientes_, SIGNAL(triggered()), this, SLOT(Cerrar_Recientes()));

    connect(Cargar_Lista_Reproduccion_,SIGNAL(triggered()), this, SLOT(Cargar_lista_reproduccion()));


    connect(Salir_, SIGNAL(triggered()), this, SLOT(Salir()));

    //menu ver pantalla completa
    connect(Ver_pantalla_completa_, SIGNAL(triggered()), this, SLOT(Pantalla_completa()));
    //connect(pantalla_completa_deshacer_, SIGNAL(pressed()), this, SLOT(Deshacer_pantalla_completa()));

    //METADATA
    connect(Metadatas_, SIGNAL(triggered()), this, SLOT(Ver_metadatos()));




}