[vlmc-devel] [PATCH] ProjectWizard: Don't fake RecentProjects when a project is supposed to be opend

yikei lu luyikei.qmltu at gmail.com
Mon Apr 11 10:36:52 CEST 2016


Oh sorry I misunderstood, you didn't mean removing itself

2016-04-11 17:35 GMT+09:00 yikei lu <luyikei.qmltu at gmail.com>:
> Removing the loadProject() method means the project wizard will lose
> the feature of opening a project. Is that ok?
>
> 2016-04-11 17:31 GMT+09:00 Hugo Beauzée-Luyssen <hugo at beauzee.fr>:
>> On 04/10/2016 05:18 PM, Yikai Lu wrote:
>>>
>>> ---
>>>   src/Gui/wizard/WelcomePage.cpp | 45
>>> +++++++++++++++++++-----------------------
>>>   src/Gui/wizard/WelcomePage.h   |  1 +
>>>   2 files changed, 21 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/src/Gui/wizard/WelcomePage.cpp
>>> b/src/Gui/wizard/WelcomePage.cpp
>>> index 6e44cb8..dfe9fea 100644
>>> --- a/src/Gui/wizard/WelcomePage.cpp
>>> +++ b/src/Gui/wizard/WelcomePage.cpp
>>> @@ -50,6 +50,7 @@ WelcomePage::WelcomePage( QWidget* parent )
>>>                this, SLOT( selectOpenRadio() ) );
>>>       connect( m_ui.projectsListWidget, SIGNAL(
>>> itemDoubleClicked(QListWidgetItem*) ),
>>>                this, SLOT( projectDoubleClicked(QListWidgetItem*) ) );
>>> +    connect( m_ui.projectsListWidget, &QListWidget::itemSelectionChanged,
>>> this, &WelcomePage::itemSelectionChanged);
>>>
>>>       registerField( "loadProject", m_ui.projectsListWidget );
>>>       m_projectPath = new QString();
>>> @@ -94,15 +95,13 @@ WelcomePage::validatePage()
>>>   {
>>>       if ( m_ui.openRadioButton->isChecked() )
>>>       {
>>> -        if ( m_ui.projectsListWidget->selectedItems().count() == 0 )
>>> +        if ( m_projectPath->isEmpty() == true )
>>>           {
>>>               QMessageBox::information( this, tr( "Sorry" ),
>>>                                         tr( "You first need to select a
>>> project from "
>>>                                         "the list.\nThen click next to
>>> continue..." ) );
>>>               return false;
>>>           }
>>> -        QList<QListWidgetItem*> selected =
>>> m_ui.projectsListWidget->selectedItems();
>>> -        setProjectPath( selected.at( 0 )->data( FilePath ).toString() );
>>>           return true;
>>>       }
>>>       return true;
>>> @@ -132,6 +131,7 @@ WelcomePage::loadRecentsProjects()
>>>   void
>>>   WelcomePage::loadProject()
>>>   {
>>> +    m_ui.openRadioButton->setChecked( true );
>>>       QString projectPath =
>>>               QFileDialog::getOpenFileName( nullptr, tr( "Select a project
>>> file" ),
>>>                                             VLMC_GET_STRING(
>>> "vlmc/WorkspaceLocation" ),
>>> @@ -145,29 +145,12 @@ WelcomePage::loadProject()
>>>                                tr("Please use an existing project
>>> file."));
>>>           return;
>>>       }
>>> +    m_ui.projectsListWidget->clearSelection();
>>> +    m_ui.projectsListWidget->clearFocus();
>>>
>>> -    // Search if the item is already in the list
>>> -    QListWidgetItem* item = nullptr;
>>> -    for ( int i = 0; i < m_ui.projectsListWidget->count(); ++i )
>>> -    {
>>> -        item = m_ui.projectsListWidget->item( i );
>>> -        if ( item->data( FilePath ).toString().contains( projectPath ) )
>>> -            break;
>>> -        item = nullptr;
>>> -    }
>>> -
>>> -    // Item not in list, insert it temporarily
>>> -    if ( !item )
>>> -    {
>>> -        QFileInfo fi( projectPath );
>>> -        item = new QListWidgetItem( fi.fileName() );
>>> -        item->setData( FilePath, fi.absoluteFilePath() );
>>> -
>>> -        m_ui.projectsListWidget->addItem( item );
>>> -    }
>>> -
>>> -    item->setSelected( true );
>>> -    selectOpenRadio();
>>> +    setProjectPath( projectPath );
>>> +    if ( wizard() )
>>> +        wizard()->next();
>>>   }
>>>
>>>   void
>>> @@ -193,6 +176,18 @@ WelcomePage::selectOpenRadio()
>>>   }
>>>
>>>   void
>>> +WelcomePage::itemSelectionChanged()
>>> +{
>>> +    if ( m_ui.projectsListWidget->selectedItems().count() == 0 )
>>> +        setProjectPath( "" );
>>> +    else
>>> +    {
>>> +        QList<QListWidgetItem*> selected =
>>> m_ui.projectsListWidget->selectedItems();
>>> +        setProjectPath( selected.at( 0 )->data( FilePath ).toString() );
>>> +    }
>>> +}
>>> +
>>> +void
>>>   WelcomePage::projectDoubleClicked( QListWidgetItem* item )
>>>   {
>>>       Q_UNUSED( item );
>>> diff --git a/src/Gui/wizard/WelcomePage.h b/src/Gui/wizard/WelcomePage.h
>>> index 470b9c3..341edcf 100644
>>> --- a/src/Gui/wizard/WelcomePage.h
>>> +++ b/src/Gui/wizard/WelcomePage.h
>>> @@ -54,6 +54,7 @@ class WelcomePage : public QWizardPage
>>>           void loadRecentsProjects();
>>>           void projectDoubleClicked( QListWidgetItem* item );
>>>           void selectOpenRadio();
>>> +        void itemSelectionChanged();
>>>
>>>       private:
>>>           Ui::WelcomePage m_ui;
>>>
>> I would have expected this patch to simply remove code from the
>> loadProject() method, is the rest of the changes required? Or can it be
>> split in a separate patch?
>>
>> Regards,
>> _______________________________________________
>> Vlmc-devel mailing list
>> Vlmc-devel at videolan.org
>> https://mailman.videolan.org/listinfo/vlmc-devel


More information about the Vlmc-devel mailing list