Changeset 97f221eb4d6876bb37de2e4c3adbc622b4908101

Show
Ignore:
Timestamp:
21/12/07 01:40:47 (10 months ago)
Author:
Jean-Baptiste Kempf <jb@videolan.org>
git-committer:
Jean-Baptiste Kempf <jb@videolan.org> 1198197647 +0000
git-parent:

[fee86c5d53af1cfb6edca8404348201c12469c17]

git-author:
Jean-Baptiste Kempf <jb@videolan.org> 1198197647 +0000
Message:

Qt4 - Small open dialog refactoring for use for vlm dialog.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/qt4/dialogs/open.cpp

    r9649521 r97f221e  
    22 * open.cpp : Advanced open dialog 
    33 ***************************************************************************** 
    4  * Copyright (C) 2006-2007 the VideoLAN team 
     4 * Copyright ( C ) 2006-2007 the VideoLAN team 
    55 * $Id$ 
    66 * 
     
    1010 * it under the terms of the GNU General Public License as published by 
    1111 * the Free Software Foundation; either version 2 of the License, or 
    12  * (at your option) any later version. 
     12 * ( at your option ) any later version. 
    1313 * 
    1414 * This program is distributed in the hope that it will be useful, 
     
    3434OpenDialog *OpenDialog::instance = NULL; 
    3535 
    36 OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal, 
     36OpenDialog* OpenDialog::getInstance( QWidget *parent, intf_thread_t *p_intf, 
     37        int _action_flag, bool modal ) 
     38
     39    /* Creation */ 
     40    if( !instance ) 
     41        instance = new OpenDialog( parent, p_intf, modal, _action_flag ); 
     42    else 
     43    { 
     44        /* Request the instance but change small details: 
     45           - Button menu 
     46           - Modality on top of the parent dialog */ 
     47        instance->i_action_flag = _action_flag; 
     48        instance->setMenuAction(); 
     49        if( modal ) instance->setWindowModality( Qt::WindowModal ); 
     50    } 
     51    return instance; 
     52
     53 
     54OpenDialog::OpenDialog( QWidget *parent, 
     55                        intf_thread_t *_p_intf, 
     56                        bool modal, 
    3757                        int _action_flag )  :  QVLCDialog( parent, _p_intf ) 
    3858{ 
    39     setModal( modal ); 
    4059    i_action_flag = _action_flag; 
     60 
     61    if( modal ) /* Select mode */ 
     62    { 
     63        setWindowModality( Qt::WindowModal ); 
     64        i_action_flag = SELECT; 
     65    } 
    4166 
    4267    /* Basic Creation of the Window */ 
    4368    ui.setupUi( this ); 
    44     setWindowTitle( qtr("Open" ) ); 
    45     resize( 410, 300); 
     69    setWindowTitle( qtr( "Open" ) ); 
     70    resize( 410, 300 ); 
    4671 
    4772    /* Tab definition and creation */ 
    48     fileOpenPanel = new FileOpenPanel( ui.Tab, p_intf ); 
    49     discOpenPanel = new DiscOpenPanel( ui.Tab, p_intf ); 
    50     netOpenPanel = new NetOpenPanel( ui.Tab, p_intf ); 
     73    fileOpenPanel    = new FileOpenPanel( ui.Tab, p_intf ); 
     74    discOpenPanel    = new DiscOpenPanel( ui.Tab, p_intf ); 
     75    netOpenPanel     = new NetOpenPanel( ui.Tab, p_intf ); 
    5176    captureOpenPanel = new CaptureOpenPanel( ui.Tab, p_intf ); 
    5277 
     
    5681    ui.Tab->insertTab( OPEN_NETWORK_TAB, netOpenPanel, qtr( "&Network" ) ); 
    5782    ui.Tab->insertTab( OPEN_CAPTURE_TAB, captureOpenPanel, 
    58                                 qtr( "Capture &Device" ) ); 
     83                       qtr( "Capture &Device" ) ); 
    5984 
    6085    /* Hide the Slave input widgets */ 
     
    6388    ui.slaveBrowseButton->hide(); 
    6489 
    65     /* Hide the advancedPanel */ 
    66     if(! config_GetInt( p_intf, "qt-adv-options") ) 
    67         ui.advancedFrame->hide(); 
    68     else 
    69         ui.advancedCheckBox->setChecked( true ); 
    70  
    7190    /* Buttons Creation */ 
    7291    QSizePolicy buttonSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); 
     
    7897    playButton->setText( qtr( "&Play" ) ); 
    7998    playButton->setSizePolicy( buttonSizePolicy ); 
    80     playButton->setMinimumSize( QSize(90, 0) ); 
     99    playButton->setMinimumSize( QSize( 90, 0 ) ); 
    81100    playButton->setPopupMode( QToolButton::MenuButtonPopup ); 
    82101    playButton->setToolButtonStyle( Qt::ToolButtonTextOnly ); 
     
    87106    cancelButton->setSizePolicy( buttonSizePolicy ); 
    88107 
     108    /* Select Button */ 
     109    selectButton = new QPushButton; 
     110    selectButton->setText( qtr( "Select" ) ); 
     111    selectButton->setSizePolicy( buttonSizePolicy ); 
     112 
    89113    /* Menu for the Play button */ 
    90114    QMenu * openButtonMenu = new QMenu( "Open" ); 
    91115    openButtonMenu->addAction( qtr( "&Enqueue" ), this, SLOT( enqueue() ), 
    92                                     QKeySequence( "Alt+E") ); 
     116                                    QKeySequence( "Alt+E" ) ); 
    93117    openButtonMenu->addAction( qtr( "&Play" ), this, SLOT( play() ), 
    94118                                    QKeySequence( "Alt+P" ) ); 
     
    100124    playButton->setMenu( openButtonMenu ); 
    101125 
    102     ui.buttonsBox->addButton( playButton, QDialogButtonBox::AcceptRole ); 
     126    /* Add the three Buttons */ 
     127    ui.buttonsBox->addButton( playButton, QDialogButtonBox::ActionRole ); 
     128    ui.buttonsBox->addButton( selectButton, QDialogButtonBox::AcceptRole ); 
    103129    ui.buttonsBox->addButton( cancelButton, QDialogButtonBox::RejectRole ); 
    104130 
     131    /* At creation time, modify the default buttons */ 
     132    setMenuAction(); 
     133 
    105134    /* Force MRL update on tab change */ 
    106     CONNECT( ui.Tab, currentChanged(int), this, signalCurrent() ); 
    107  
    108     CONNECT( fileOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) ); 
    109     CONNECT( netOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) ); 
    110     CONNECT( discOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) ); 
    111     CONNECT( captureOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) ); 
     135    CONNECT( ui.Tab, currentChanged( int ), this, signalCurrent() ); 
     136 
     137    CONNECT( fileOpenPanel, mrlUpdated( QString ), this, updateMRL( QString ) ); 
     138    CONNECT( netOpenPanel, mrlUpdated( QString ), this, updateMRL( QString ) ); 
     139    CONNECT( discOpenPanel, mrlUpdated( QString ), this, updateMRL( QString ) ); 
     140    CONNECT( captureOpenPanel, mrlUpdated( QString ), this, updateMRL( QString ) ); 
    112141 
    113142    CONNECT( fileOpenPanel, methodChanged( QString ), 
    114                                                  this, newCachingMethod(QString) ); 
     143             this, newCachingMethod( QString ) ); 
    115144    CONNECT( netOpenPanel, methodChanged( QString ), 
    116                                                  this, newCachingMethod(QString) ); 
     145             this, newCachingMethod( QString ) ); 
    117146    CONNECT( discOpenPanel, methodChanged( QString ), 
    118                                                  this, newCachingMethod(QString) ); 
     147             this, newCachingMethod( QString ) ); 
    119148    CONNECT( captureOpenPanel, methodChanged( QString ), 
    120                                                  this, newCachingMethod(QString) ); 
     149             this, newCachingMethod( QString ) ); 
    121150 
    122151    /* Advanced frame Connects */ 
    123     CONNECT( ui.slaveText, textChanged(QString), this, updateMRL() ); 
    124     CONNECT( ui.cacheSpinBox, valueChanged(int), this, updateMRL() ); 
    125     CONNECT( ui.startTimeSpinBox, valueChanged(int), this, updateMRL() ); 
     152    CONNECT( ui.slaveText, textChanged( QString ), this, updateMRL() ); 
     153    CONNECT( ui.cacheSpinBox, valueChanged( int ), this, updateMRL() ); 
     154    CONNECT( ui.startTimeSpinBox, valueChanged( int ), this, updateMRL() ); 
    126155    BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() ); 
    127156 
    128157    /* Buttons action */ 
    129158    BUTTONACT( playButton, selectSlots() ); 
     159    BUTTONACT( selectButton, close() ); 
    130160    BUTTONACT( cancelButton, cancel() ); 
    131161 
    132     /* At creation time, modify the default buttons */ 
    133     if ( i_action_flag ) setMenuAction(); 
     162    /* Hide the advancedPanel */ 
     163    if( !config_GetInt( p_intf, "qt-adv-options" ) ) 
     164        ui.advancedFrame->hide(); 
     165    else 
     166        ui.advancedCheckBox->setChecked( true ); 
    134167 
    135168    /* Initialize caching */ 
    136169    storedMethod = ""; 
    137170    newCachingMethod( "file-caching" ); 
    138  
    139     mainHeight = advHeight = 0; 
    140171} 
    141172 
    142173OpenDialog::~OpenDialog() 
    143 
    144 
     174{} 
    145175 
    146176/* Finish the dialog and decide if you open another one after */ 
    147177void OpenDialog::setMenuAction() 
    148178{ 
    149     switch ( i_action_flag ) 
    150     { 
    151     case OPEN_AND_STREAM: 
    152         playButton->setText( qtr( "&Stream" ) ); 
    153         break; 
    154     case OPEN_AND_SAVE: 
    155         playButton->setText( qtr( "&Convert / Save" ) ); 
    156         break; 
    157     case OPEN_AND_ENQUEUE: 
    158         playButton->setText( qtr( "&Enqueue" ) ); 
    159         break; 
    160     case OPEN_AND_PLAY: 
    161     default: 
    162         playButton->setText( qtr( "&Play" ) ); 
    163    } 
     179    if( i_action_flag == SELECT ) 
     180    { 
     181        playButton->hide(); 
     182        selectButton->show(); 
     183    } 
     184    else 
     185    { 
     186        switch ( i_action_flag ) 
     187        { 
     188        case OPEN_AND_STREAM: 
     189            playButton->setText( qtr( "&Stream" ) ); 
     190            break; 
     191        case OPEN_AND_SAVE: 
     192            playButton->setText( qtr( "&Convert / Save" ) ); 
     193            break; 
     194        case OPEN_AND_ENQUEUE: 
     195            playButton->setText( qtr( "&Enqueue" ) ); 
     196            break; 
     197        case OPEN_AND_PLAY: 
     198        default: 
     199            playButton->setText( qtr( "&Play" ) ); 
     200        } 
     201        playButton->show(); 
     202        selectButton->hide(); 
     203    } 
    164204} 
    165205 
    166206void OpenDialog::showTab( int i_tab=0 ) 
    167207{ 
    168     this->show(); 
    169208    ui.Tab->setCurrentIndex( i_tab ); 
    170 
    171  
    172 void OpenDialog::signalCurrent() { 
    173     if (ui.Tab->currentWidget() != NULL) 
    174         (dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() ))->updateMRL(); 
     209    show(); 
     210
     211 
     212/* Function called on signal currentChanged triggered */ 
     213void OpenDialog::signalCurrent() 
     214
     215    if( ui.Tab->currentWidget() != NULL ) 
     216        ( dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() ) )->updateMRL(); 
    175217} 
    176218 
    177219void OpenDialog::toggleAdvancedPanel() 
    178220{ 
    179     //FIXME does not work under Windows 
    180     if( ui.advancedFrame->isVisible() )
     221    if( ui.advancedFrame->isVisible() ) 
     222   
    181223        ui.advancedFrame->hide(); 
    182 #ifndef WIN32 
    183         setMinimumHeight( 1 ); 
    184         resize( width(), mainHeight ); 
    185 #endif 
    186     } else { 
    187 #ifndef WIN32 
    188         if( mainHeight == 0 ) 
    189             mainHeight = height(); 
    190 #endif 
    191  
     224        //FIXME: Clear Bug here. Qt ? 
     225        resize( size().width(), size().height() - ui.advancedFrame->height() ); 
     226    } 
     227    else 
     228    { 
    192229        ui.advancedFrame->show(); 
    193 #ifndef WIN32 
    194         if( advHeight == 0 ) { 
    195             advHeight = height() - mainHeight; 
    196         } 
    197         resize( width(), mainHeight + advHeight ); 
    198 #endif 
    199230    } 
    200231} 
     
    206237void OpenDialog::cancel() 
    207238{ 
     239    /* Clear the panels */ 
    208240    for( int i = 0; i < OPEN_TAB_MAX; i++ ) 
    209         dynamic_cast<OpenPanel*>(ui.Tab->widget( i ))->clear(); 
    210     toggleVisible(); 
    211     if( isModal() ) reject(); 
     241        dynamic_cast<OpenPanel*>( ui.Tab->widget( i ) )->clear(); 
     242 
     243    /* Clear the variables */ 
     244    mrl.clear(); 
     245    mainMRL.clear(); 
     246 
     247    /* If in Select Mode, reject instead of hiding */ 
     248    if( windowModality() != Qt::NonModal ) reject(); 
     249    else hide(); 
    212250} 
    213251 
     
    215253void OpenDialog::close() 
    216254{ 
    217     selectSlots(); 
     255    if( windowModality() != Qt::NonModal ) 
     256        accept(); 
     257    else 
     258        selectSlots(); 
    218259} 
    219260 
     
    248289} 
    249290 
    250 void OpenDialog::transcode() 
    251 { 
    252     stream( true ); 
    253 } 
    254  
    255 void OpenDialog::stream( bool b_transcode_only ) 
    256 { 
    257     /* not finished FIXME */ 
    258     /* Should go through the finish function */ 
    259     THEDP->streamingDialog( mrl, b_transcode_only ); 
    260 } 
    261291 
    262292void OpenDialog::finish( bool b_enqueue = false ) 
     
    265295    mrl = ui.advancedLineInput->text(); 
    266296 
    267     if( !isModal()
     297    if( windowModality() == Qt::NonModal
    268298    { 
    269299        QStringList tempMRL = SeparateEntries( mrl ); 
     
    301331} 
    302332 
     333void OpenDialog::transcode() 
     334{ 
     335    stream( true ); 
     336} 
     337 
     338void OpenDialog::stream( bool b_transcode_only ) 
     339{ 
     340    mrl = ui.advancedLineInput->text(); 
     341    toggleVisible(); 
     342    THEDP->streamingDialog( mrl, b_transcode_only ); 
     343} 
    303344 
    304345/* Update the MRL */ 
  • modules/gui/qt4/dialogs/open.hpp

    r352de5a r97f221e  
    4141public: 
    4242    static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf, 
    43                  int _action_flag = 0 ) 
    44     { 
    45         if( !instance ) 
    46             instance = new OpenDialog( parent, p_intf, false, _action_flag ); 
    47         else 
    48         { 
    49             instance->i_action_flag = _action_flag; 
    50             instance->setMenuAction(); 
    51         } 
    52         return instance; 
    53     } 
    54     OpenDialog( QWidget *parent, intf_thread_t *, bool modal, 
    55                 int _action_flag = 0 ); 
     43                                     int _action_flag = 0, bool modal = false  ); 
     44 
    5645    virtual ~OpenDialog(); 
    5746 
    5847    void showTab( int ); 
    59  
    60     QString mrl; 
    61     QString mainMRL; 
     48    QString getMRL(){ return mrl; } 
    6249 
    6350public slots: 
     
    6754    void enqueue(); 
    6855    void transcode(); 
     56 
    6957private: 
     58    OpenDialog( QWidget *parent, intf_thread_t *, bool modal, 
     59                int _action_flag = 0 ); 
     60 
    7061    static OpenDialog *instance; 
    7162    input_thread_t *p_input; 
     63 
     64    QString mrl; 
     65    QString mainMRL; 
     66    QString storedMethod; 
    7267 
    7368    Ui::Open ui; 
     
    7772    CaptureOpenPanel *captureOpenPanel; 
    7873 
    79     QString storedMethod; 
    80     QString mrlSub; 
    81     int advHeight, mainHeight; 
    8274    int i_action_flag; 
    8375    QStringList SeparateEntries( QString ); 
    8476 
    85     QPushButton *cancelButton
     77    QPushButton *cancelButton, *selectButton
    8678    QToolButton *playButton; 
     79 
    8780    void finish( bool ); 
    8881 
  • modules/gui/qt4/dialogs_provider.cpp

    r4c9b6e2 r97f221e  
    128128        case INTF_DIALOG_WIZARD: 
    129129        case INTF_DIALOG_STREAMWIZARD: 
     130            openThenStreamingDialogs(); break; 
    130131#ifdef UPDATE_CHECK 
    131132        case INTF_DIALOG_UPDATEVLC: 
     
    250251/* Unimplemmented yet - Usefull ? */ 
    251252void DialogsProvider::MLAppendDialog() 
    252 
    253 
     253{} 
    254254 
    255255/** 
     
    415415 ****************************************************************************/ 
    416416 
    417 //FIXME !! 
    418417void DialogsProvider::streamingDialog( QString mrl, bool b_transcode_only ) 
    419418{ 
     
    422421    if( s->exec() == QDialog::Accepted ) 
    423422    { 
    424         msg_Err( p_intf, "mrl %s", qta( s->getMrl() ) ); 
     423        msg_Err( p_intf, "Sout mrl %s", qta( s->getMrl() ) ); 
    425424        /* Just do it */ 
    426425        int i_len = strlen( qtu( s->getMrl() ) ) + 10; 
  • modules/gui/qt4/dialogs_provider.hpp

    r4c9b6e2 r97f221e  
    8585    OPEN_AND_STREAM, 
    8686    OPEN_AND_SAVE, 
    87     OPEN_AND_ENQUEUE 
     87    OPEN_AND_ENQUEUE, 
     88    SELECT 
    8889}; 
    8990 
  • modules/gui/qt4/ui/open.ui

    r5f73c52 r97f221e  
    1515  </property> 
    1616  <property name="sizePolicy" > 
    17    <sizepolicy> 
    18     <hsizetype>5</hsizetype> 
    19     <vsizetype>1</vsizetype> 
     17   <sizepolicy vsizetype="Maximum" hsizetype="Preferred" > 
    2018    <horstretch>0</horstretch> 
    2119    <verstretch>0</verstretch> 
     
    2624  </property> 
    2725  <layout class="QVBoxLayout" > 
    28    <property name="margin" > 
    29     <number>9</number> 
    30    </property> 
    3126   <property name="spacing" > 
    3227    <number>6</number> 
    3328   </property> 
     29   <property name="leftMargin" > 
     30    <number>9</number> 
     31   </property> 
     32   <property name="topMargin" > 
     33    <number>9</number> 
     34   </property> 
     35   <property name="rightMargin" > 
     36    <number>9</number> 
     37   </property> 
     38   <property name="bottomMargin" > 
     39    <number>9</number> 
     40   </property> 
    3441   <item> 
    3542    <widget class="QTabWidget" name="Tab" > 
    3643     <property name="sizePolicy" > 
    37       <sizepolicy> 
    38        <hsizetype>5</hsizetype> 
    39        <vsizetype>0</vsizetype> 
     44      <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > 
    4045       <horstretch>0</horstretch> 
    4146       <verstretch>0</verstretch> 
     
    6065    <widget class="QFrame" name="advancedFrame" > 
    6166     <property name="sizePolicy" > 
    62       <sizepolicy> 
    63        <hsizetype>1</hsizetype> 
    64        <vsizetype>5</vsizetype> 
     67      <sizepolicy vsizetype="Preferred" hsizetype="Minimum" > 
    6568       <horstretch>0</horstretch> 
    6669       <verstretch>0</verstretch> 
     
    7174     </property> 
    7275     <layout class="QGridLayout" > 
    73       <property name="margin" > 
     76      <property name="leftMargin" > 
    7477       <number>9</number> 
    7578      </property> 
    76       <property name="spacing" > 
     79      <property name="topMargin" > 
     80       <number>9</number> 
     81      </property> 
     82      <property name="rightMargin" > 
     83       <number>9</number> 
     84      </property> 
     85      <property name="bottomMargin" > 
     86       <number>9</number> 
     87      </property> 
     88      <property name="horizontalSpacing" > 
     89       <number>6</number> 
     90      </property> 
     91      <property name="verticalSpacing" > 
    7792       <number>6</number> 
    7893      </property> 
     
    87102       <widget class="QSpinBox" name="startTimeSpinBox" > 
    88103        <property name="sizePolicy" > 
    89          <sizepolicy> 
    90           <hsizetype>0</hsizetype> 
    91           <vsizetype>0</vsizetype> 
     104         <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > 
    92105          <horstretch>0</horstretch> 
    93106          <verstretch>0</verstretch> 
     
    111124       <widget class="QLabel" name="cacheLabel" > 
    112125        <property name="sizePolicy" > 
    113          <sizepolicy> 
    114           <hsizetype>0</hsizetype> 
    115           <vsizetype>5</vsizetype> 
     126         <sizepolicy vsizetype="Preferred" hsizetype="Fixed" > 
    116127          <horstretch>0</horstretch> 
    117128          <verstretch>0</verstretch> 
     
    181192       <widget class="QSpinBox" name="cacheSpinBox" > 
    182193        <property name="sizePolicy" > 
    183          <sizepolicy> 
    184           <hsizetype>0</hsizetype> 
    185           <vsizetype>0</vsizetype> 
     194         <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > 
    186195          <horstretch>0</horstretch> 
    187196          <verstretch>0</verstretch> 
     
    223232   <item> 
    224233    <layout class="QHBoxLayout" > 
    225      <property name="margin" > 
    226       <number>0</number> 
    227      </property> 
    228234     <property name="spacing" > 
    229235      <number>6</number> 
     236     </property> 
     237     <property name="leftMargin" > 
     238      <number>0</number> 
     239     </property> 
     240     <property name="topMargin" > 
     241      <number>0</number> 
     242     </property> 
     243     <property name="rightMargin" > 
     244      <number>0</number> 
     245     </property> 
     246     <property name="bottomMargin" > 
     247      <number>0</number> 
    230248     </property> 
    231249     <item>