Add checkboxes for selecting user and factory content (#5786)
Co-authored-by: IanCaio <iancaio_dev@hotmail.com> Co-authored-by: Dominic Clark <mrdomclark@gmail.com> Co-authored-by: Kevin Zander <veratil@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef FILE_BROWSER_H
|
||||
#define FILE_BROWSER_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QTreeWidget>
|
||||
@@ -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;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QShortcut>
|
||||
#include <QStringList>
|
||||
|
||||
#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<QString> 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 );
|
||||
|
||||
@@ -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 ) ),
|
||||
|
||||
Reference in New Issue
Block a user