diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 5935b7749..860aa0da1 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -129,6 +129,12 @@ QMenu::indicator:selected { background-color: #747474; } +FileBrowser QCheckBox +{ + font-size: 10px; + color: white; +} + PositionLine { qproperty-tailGradient: false; qproperty-lineColor: rgb(255, 255, 255); diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 767ac830b..ce476f5a9 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -40,6 +40,12 @@ QMdiArea { background-color: #111314; } +FileBrowser QCheckBox +{ + font-size: 10px; + color: white; +} + Knob { qproperty-lineInactiveColor: rgb(120, 120, 120); qproperty-arcInactiveColor: rgba(120, 120, 120, 70); diff --git a/include/FileBrowser.h b/include/FileBrowser.h index 8cc50f48e..2e26199fc 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -26,6 +26,7 @@ #ifndef FILE_BROWSER_H #define FILE_BROWSER_H +#include #include #include #include @@ -58,7 +59,10 @@ public: */ FileBrowser( const QString & directories, const QString & filter, const QString & title, const QPixmap & pm, - QWidget * parent, bool dirs_as_items = false, bool recurse = false ); + QWidget * parent, bool dirs_as_items = false, bool recurse = false, + const QString& userDir = "", + const QString& factoryDir = ""); + virtual ~FileBrowser() = default; private slots: @@ -83,6 +87,11 @@ private: bool m_dirsAsItems; bool m_recurse; + void addContentCheckBox(); + QCheckBox* m_showUserContent = nullptr; + QCheckBox* m_showFactoryContent = nullptr; + QString m_userDir; + QString m_factoryDir; } ; diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 5a2648aa0..797e19c00 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "FileBrowser.h" #include "BBTrackContainer.h" @@ -63,17 +64,50 @@ enum TreeWidgetItemTypes +void FileBrowser::addContentCheckBox() +{ + auto filterWidget = new QWidget(contentParent()); + filterWidget->setFixedHeight(15); + auto filterWidgetLayout = new QHBoxLayout(filterWidget); + filterWidgetLayout->setMargin(0); + filterWidgetLayout->setSpacing(0); + + auto configCheckBox = [this, &filterWidgetLayout](QCheckBox* box) + { + box->setCheckState(Qt::Checked); + connect(box, SIGNAL(stateChanged(int)), this, SLOT(reloadTree())); + filterWidgetLayout->addWidget(box); + }; + + m_showUserContent = new QCheckBox(tr("User content")); + configCheckBox(m_showUserContent); + m_showFactoryContent = new QCheckBox(tr("Factory content")); + configCheckBox(m_showFactoryContent); + + addContentWidget(filterWidget); +}; + + FileBrowser::FileBrowser(const QString & directories, const QString & filter, const QString & title, const QPixmap & pm, - QWidget * parent, bool dirs_as_items, bool recurse ) : + QWidget * parent, bool dirs_as_items, bool recurse, + const QString& userDir, + const QString& factoryDir): SideBarWidget( title, pm, parent ), m_directories( directories ), m_filter( filter ), m_dirsAsItems( dirs_as_items ), - m_recurse( recurse ) + m_recurse( recurse ), + m_userDir(userDir), + m_factoryDir(factoryDir) { setWindowTitle( tr( "Browser" ) ); + if (!userDir.isEmpty() && !factoryDir.isEmpty()) + { + addContentCheckBox(); + } + QWidget * searchWidget = new QWidget( contentParent() ); searchWidget->setFixedHeight( 24 ); @@ -160,17 +194,28 @@ bool FileBrowser::filterItems( const QString & filter, QTreeWidgetItem * item ) } - void FileBrowser::reloadTree( void ) { QList expandedDirs = m_fileBrowserTreeWidget->expandedDirs(); const QString text = m_filterEdit->text(); m_filterEdit->clear(); m_fileBrowserTreeWidget->clear(); - QStringList paths = m_directories.split( '*' ); - for( QStringList::iterator it = paths.begin(); it != paths.end(); ++it ) + QStringList paths = m_directories.split('*'); + if (m_showUserContent && !m_showUserContent->isChecked()) { - addItems( *it ); + paths.removeAll(m_userDir); + } + if (m_showFactoryContent && !m_showFactoryContent->isChecked()) + { + paths.removeAll(m_factoryDir); + } + + if (!paths.isEmpty()) + { + for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it) + { + addItems(*it); + } } expandItems(nullptr, expandedDirs); m_filterEdit->setText( text ); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 94f337576..7828dcfbc 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -128,20 +128,26 @@ MainWindow::MainWindow() : "*.mmp *.mmpz *.xml *.mid", tr( "My Projects" ), embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ), - splitter, false, true ) ); + splitter, false, true, + confMgr->userProjectsDir(), + confMgr->factoryProjectsDir())); sideBar->appendTab( new FileBrowser( confMgr->userSamplesDir() + "*" + confMgr->factorySamplesDir(), "*", tr( "My Samples" ), embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ), - splitter, false, true ) ); + splitter, false, true, + confMgr->userSamplesDir(), + confMgr->factorySamplesDir())); sideBar->appendTab( new FileBrowser( confMgr->userPresetsDir() + "*" + confMgr->factoryPresetsDir(), "*.xpf *.cs.xml *.xiz *.lv2", tr( "My Presets" ), embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ), - splitter , false, true ) ); + splitter , false, true, + confMgr->userPresetsDir(), + confMgr->factoryPresetsDir())); sideBar->appendTab( new FileBrowser( QDir::homePath(), "*", tr( "My Home" ), embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ),