vlc | branch: master | Abel Tesfaye <[email protected]> | Thu Jul 25 12:48:23 2019 +0300| [68d9852c7b261c0c959e502e793947dd8cb2479c] | committer: Jean-Baptiste Kempf
qt: make ml entry point manager ui Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=68d9852c7b261c0c959e502e793947dd8cb2479c --- modules/gui/qt/components/simple_preferences.cpp | 96 ++++++++++++++++++++++++ modules/gui/qt/components/simple_preferences.hpp | 13 ++++ modules/gui/qt/ui/sprefs_interface.ui | 66 +++++++++++++++- 3 files changed, 171 insertions(+), 4 deletions(-) diff --git a/modules/gui/qt/components/simple_preferences.cpp b/modules/gui/qt/components/simple_preferences.cpp index 6f8afa01c5..f80c48cc1b 100644 --- a/modules/gui/qt/components/simple_preferences.cpp +++ b/modules/gui/qt/components/simple_preferences.cpp @@ -47,6 +47,17 @@ #include <QScreen> #include <QtAlgorithms> #include <QDir> + +#include <QSpinBox> +#include <QCheckBox> +#include <QLabel> +#include <QPushButton> +#include <QGridLayout> +#include <QWidget> +#include <QHBoxLayout> +#include <QDialog> +#include <QBoxLayout> + #include <assert.h> #include <math.h> @@ -719,6 +730,24 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, + qtr( "VLC skins website" )+ QString( "</a>." ) ); ui.skinsLabel->setFont( italicFont ); + if ( vlc_ml_instance_get( p_intf ) != NULL ) + { + mlModel = new MlFoldersModel( vlc_ml_instance_get( p_intf ) , this ); + + mlTableView = ui.entryPointsTV; + + mlTableView->setModel( mlModel ); + + connect( mlModel , &QAbstractItemModel::modelReset , this , &SPrefsPanel::MLdrawControls ); + + BUTTONACT( ui.addButton , MLaddNewEntryPoint() ); + + MLdrawControls( ); + + }else { + ui.mlGroupBox->hide( ); + } + #ifdef _WIN32 BUTTONACT( ui.assoButton, assoDialog() ); #else @@ -1475,3 +1504,70 @@ void SPrefsPanel::saveAsso() #endif /* _WIN32 */ +void SPrefsPanel::MLaddNewEntryPoint( ){ + QUrl newEntryPoints = QFileDialog::getExistingDirectoryUrl( this , qtr("Please choose an entry point folder") , + QUrl( QDir::homePath( ) ) ); + + if(! newEntryPoints.isEmpty() ) + mlModel->add( newEntryPoints ); +} + +QWidget *SPrefsPanel::MLgenerateWidget( QModelIndex index , MlFoldersModel *mlf , QWidget *parent){ + if ( index.column() == 0 ){ + + QWidget *wid = new QWidget( parent ); + + QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight , wid ); + + QCheckBox*cb = new QCheckBox( wid ); + cb->setFixedSize( 16 , 16 ); + + //cb->setChecked(mlf->data(index, MlFoldersModel::CustomCheckBoxRole).toBool()); //TODO: disable banning till un-banning works + cb->setEnabled( false ); + + layout->addWidget( cb , Qt::AlignCenter ); + wid->setLayout( layout ); + + connect( cb , &QPushButton::clicked, [=]( ) { + mlf->setData( index , cb->isChecked() , MlFoldersModel::CustomCheckBoxRole); + } ); + return wid; + } + else if ( index.column( ) == 2 ){ + QWidget *wid = new QWidget( parent ); + + QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight , wid ); + + QPushButton *pb = new QPushButton( "-" , wid ); + pb->setFixedSize( 16 , 16 ); + + layout->addWidget( pb , Qt::AlignCenter ); + wid->setLayout( layout ); + + + connect( pb , &QPushButton::clicked , [=]() { + mlf->setData( index , {} , MlFoldersModel::CustomRemoveRole); + } ); + + return wid; + } + + return nullptr; +} + +void SPrefsPanel::MLdrawControls( ) { + for ( int col = 0 ; col < mlModel->columnCount( ) ; col++ ) + for (int row = 0 ; row < mlModel->rowCount() ; row++ ) + { + QModelIndex index = mlModel->index ( row , col ); + mlTableView->setIndexWidget ( index, MLgenerateWidget ( index, mlModel, + mlTableView ) ); + } + + mlTableView->resizeColumnsToContents( ); + mlTableView->horizontalHeader()->setMinimumSectionSize( 100 ); + mlTableView->horizontalHeader()->setSectionResizeMode( 1 , QHeaderView::Stretch ); + + mlTableView->horizontalHeader()->setFixedHeight( 24 ); +} + diff --git a/modules/gui/qt/components/simple_preferences.hpp b/modules/gui/qt/components/simple_preferences.hpp index e249cfadc8..b8a9286c7e 100644 --- a/modules/gui/qt/components/simple_preferences.hpp +++ b/modules/gui/qt/components/simple_preferences.hpp @@ -36,6 +36,12 @@ #include "ui_sprefs_subtitles.h" #include "ui_sprefs_interface.h" +#include <vlc_media_library.h> +#include <QDialogButtonBox> +#include <QTableView> +#include <QFileDialog> +#include "components/mediacenter/ml_folders_model.hpp" + #ifdef _WIN32 # include "util/registry.hpp" #endif @@ -107,6 +113,9 @@ private: char *lang; + MlFoldersModel *mlModel; + QTableView * mlTableView; + #ifdef _WIN32 QList<QTreeWidgetItem *> listAsso; bool addType( const char * psz_ext, QTreeWidgetItem*, QTreeWidgetItem*, QVLCRegistry* ); @@ -124,6 +133,10 @@ private slots: void updateCheckBoxes( QTreeWidgetItem*, int ); void saveAsso(); #endif + void MLaddNewEntryPoint( ); + QWidget * MLgenerateWidget( QModelIndex index , MlFoldersModel *mlf , QWidget *parent ); + void MLdrawControls( ); + void configML(); void changeStyle( QString ); }; diff --git a/modules/gui/qt/ui/sprefs_interface.ui b/modules/gui/qt/ui/sprefs_interface.ui index da2faf548c..9e187f767e 100644 --- a/modules/gui/qt/ui/sprefs_interface.ui +++ b/modules/gui/qt/ui/sprefs_interface.ui @@ -8,7 +8,7 @@ <x>0</x> <y>0</y> <width>700</width> - <height>785</height> + <height>1069</height> </rect> </property> <property name="sizePolicy"> @@ -577,9 +577,6 @@ <property name="text"> <string>File extensions association</string> </property> - <property name="buddy"> - <cstring>assoButton</cstring> - </property> </widget> </item> <item row="2" column="1"> @@ -634,6 +631,67 @@ </widget> </item> <item> + <widget class="QGroupBox" name="mlGroupBox"> + <property name="title"> + <string>Media Library</string> + </property> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="2"> + <widget class="QPushButton" name="addButton"> + <property name="maximumSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="text"> + <string>+</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0" colspan="3"> + <widget class="QTableView" name="entryPointsTV"> + <property name="editTriggers"> + <set>QAbstractItemView::AllEditTriggers</set> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="showGrid"> + <bool>false</bool> + </property> + <attribute name="horizontalHeaderVisible"> + <bool>true</bool> + </attribute> + <attribute name="verticalHeaderVisible"> + <bool>false</bool> + </attribute> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Folders scanned by the Media Library:</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
