<commit_before>/*****************************************************************************
 * mediainfo.cpp : Information about an item
 ****************************************************************************
 * Copyright (C) 2006-2007 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *
 * 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 of the License, 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 ******************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "dialogs/mediainfo.hpp"
#include "input_manager.hpp"
#include "dialogs_provider.hpp"

#include <QTabWidget>
#include <QGridLayout>
#include <QLineEdit>
#include <QLabel>

MediaInfoDialog *MediaInfoDialog::instance = NULL;

/* This Dialog has two main modes:
    - General Mode that shows the current Played item, and the stats
    - Single mode that shows the info on ONE SINGLE Item on the playlist
   Please be Careful of not breaking one the modes behaviour... */

MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
                                  input_item_t *_p_item,
                                  bool _mainInput,
                                  bool _stats ) :
                                  QVLCFrame( _p_intf ), mainInput(_mainInput),
                                  stats( _stats )
{
    p_item = _p_item;
    b_cleaned = true;
    i_runs = 0;

    setWindowTitle( qtr( "Media Information" ) );
    resize( 600 , 480 );

    /* TabWidgets and Tabs creation */
    IT = new QTabWidget;
    MP = new MetaPanel( IT, p_intf );
    IT->addTab( MP, qtr( "&General" ) );
    EMP = new ExtraMetaPanel( IT, p_intf );
    IT->addTab( EMP, qtr( "&Extra Metadata" ) );
    IP = new InfoPanel( IT, p_intf );
    IT->addTab( IP, qtr( "&Codec Details" ) );
    if( stats )
    {
        ISP = new InputStatsPanel( IT, p_intf );
        IT->addTab( ISP, qtr( "&Statistics" ) );
    }

    QGridLayout *layout = new QGridLayout( this );

    /* No need to use a QDialogButtonBox here */
    saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
    saveMetaButton->hide();
    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
    closeButton->setDefault( true );

    uriLine = new QLineEdit;
    QLabel *uriLabel = new QLabel( qtr( "Location:" ) );

    layout->addWidget( IT, 0, 0, 1, 8 );
    layout->addWidget( uriLabel, 1, 0, 1, 1 );
    layout->addWidget( uriLine, 1, 1, 1, 7 );
    layout->addWidget( saveMetaButton, 2, 6 );
    layout->addWidget( closeButton, 2, 7 );

    BUTTONACT( closeButton, close() );

    /* The tabs buttons are shown in the main dialog for space and cosmetics */
    BUTTONACT( saveMetaButton, saveMeta() );

    /* Let the MetaData Panel update the URI */
    CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
    CONNECT( MP, editing(), this, showMetaSaveButton() );

    CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );

    /* If using the General Mode */
    if( !p_item )
    {
        msg_Dbg( p_intf, "Using a general windows" );
        CONNECT( THEMIM, inputChanged( input_thread_t * ),
                 this, update( input_thread_t * ) );

        if( THEMIM->getInput() )
            p_item = input_GetItem( THEMIM->getInput() );
    }

    /* Call update by hand, so info is shown from current item too */
    if( p_item )
        update( p_item, true, true );

    if( stats )
        ON_TIMEOUT( updateOnTimeOut() );
}

MediaInfoDialog::~MediaInfoDialog()
{
    writeSettings( "mediainfo" );
}

void MediaInfoDialog::showTab( int i_tab = 0 )
{
    IT->setCurrentIndex( i_tab );
    show();
}

void MediaInfoDialog::showMetaSaveButton()
{
    saveMetaButton->show();
}

void MediaInfoDialog::saveMeta()
{
    MP->saveMeta();
    saveMetaButton->hide();
}
<commit_msg>Restore MediaInfo size after launch.<commit_after>/*****************************************************************************
 * mediainfo.cpp : Information about an item
 ****************************************************************************
 * Copyright (C) 2006-2007 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *          <NAME> <<EMAIL>>
 *
 * 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 of the License, 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 ******************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "dialogs/mediainfo.hpp"
#include "input_manager.hpp"
#include "dialogs_provider.hpp"

#include <QTabWidget>
#include <QGridLayout>
#include <QLineEdit>
#include <QLabel>

MediaInfoDialog *MediaInfoDialog::instance = NULL;

/* This Dialog has two main modes:
    - General Mode that shows the current Played item, and the stats
    - Single mode that shows the info on ONE SINGLE Item on the playlist
   Please be Careful of not breaking one the modes behaviour... */

MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
                                  input_item_t *_p_item,
                                  bool _mainInput,
                                  bool _stats ) :
                                  QVLCFrame( _p_intf ), mainInput(_mainInput),
                                  stats( _stats )
{
    p_item = _p_item;
    b_cleaned = true;
    i_runs = 0;

    setWindowTitle( qtr( "Media Information" ) );

    /* TabWidgets and Tabs creation */
    IT = new QTabWidget;
    MP = new MetaPanel( IT, p_intf );
    IT->addTab( MP, qtr( "&General" ) );
    EMP = new ExtraMetaPanel( IT, p_intf );
    IT->addTab( EMP, qtr( "&Extra Metadata" ) );
    IP = new InfoPanel( IT, p_intf );
    IT->addTab( IP, qtr( "&Codec Details" ) );
    if( stats )
    {
        ISP = new InputStatsPanel( IT, p_intf );
        IT->addTab( ISP, qtr( "&Statistics" ) );
    }

    QGridLayout *layout = new QGridLayout( this );

    /* No need to use a QDialogButtonBox here */
    saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
    saveMetaButton->hide();
    QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
    closeButton->setDefault( true );

    uriLine = new QLineEdit;
    QLabel *uriLabel = new QLabel( qtr( "Location:" ) );

    layout->addWidget( IT, 0, 0, 1, 8 );
    layout->addWidget( uriLabel, 1, 0, 1, 1 );
    layout->addWidget( uriLine, 1, 1, 1, 7 );
    layout->addWidget( saveMetaButton, 2, 6 );
    layout->addWidget( closeButton, 2, 7 );

    BUTTONACT( closeButton, close() );

    /* The tabs buttons are shown in the main dialog for space and cosmetics */
    BUTTONACT( saveMetaButton, saveMeta() );

    /* Let the MetaData Panel update the URI */
    CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
    CONNECT( MP, editing(), this, showMetaSaveButton() );

    CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );

    /* If using the General Mode */
    if( !p_item )
    {
        msg_Dbg( p_intf, "Using a general windows" );
        CONNECT( THEMIM, inputChanged( input_thread_t * ),
                 this, update( input_thread_t * ) );

        if( THEMIM->getInput() )
            p_item = input_GetItem( THEMIM->getInput() );
    }

    /* Call update by hand, so info is shown from current item too */
    if( p_item )
        update( p_item, true, true );

    if( stats )
        ON_TIMEOUT( updateOnTimeOut() );

    readSettings( "Mediainfo", QSize( 600 , 480 ) );
}

MediaInfoDialog::~MediaInfoDialog()
{
    writeSettings( "Mediainfo" );
}

void MediaInfoDialog::showTab( int i_tab = 0 )
{
    IT->setCurrentIndex( i_tab );
    show();
}

void MediaInfoDialog::showMetaSaveButton()
{
    saveMetaButton->show();
}

void MediaInfoDialog::saveMeta()
{
    MP->saveMeta();
    saveMetaButton->hide();
}

{'fraction_non_alphanumeric': 0.158550144540805, 'fraction_numerical': 0.009784300644874361, 'mean_word_length': 2.9382661996497372, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4610180', 'n_tokens_mistral': 2779, 'n_tokens_neox': 2604, 'n_words': 884}