Add option to favorite items in the file browser (#7753)
Added the ability to favorite items. This gets added to its own tab named "My Favorites". --------- Co-authored-by: Sotonye Atemie <sakertooth@gmail.com>
This commit is contained in:
@@ -214,6 +214,8 @@ public:
|
||||
return m_recentlyOpenedProjects;
|
||||
}
|
||||
|
||||
const QStringList& favoriteItems() { return m_favoriteItems; }
|
||||
|
||||
QString localeDir() const
|
||||
{
|
||||
return m_dataDir + LOCALE_PATH;
|
||||
@@ -240,6 +242,10 @@ public:
|
||||
|
||||
void addRecentlyOpenedProject(const QString & _file);
|
||||
|
||||
void addFavoriteItem(const QString& item);
|
||||
void removeFavoriteItem(const QString& item);
|
||||
bool isFavoriteItem(const QString& item);
|
||||
|
||||
QString value(const QString& cls, const QString& attribute, const QString& defaultVal = "") const;
|
||||
|
||||
void setValue(const QString & cls, const QString & attribute,
|
||||
@@ -265,6 +271,7 @@ public:
|
||||
|
||||
signals:
|
||||
void valueChanged( QString cls, QString attribute, QString value );
|
||||
void favoritesChanged();
|
||||
|
||||
private:
|
||||
static ConfigManager * s_instanceOfMe;
|
||||
@@ -299,6 +306,7 @@ private:
|
||||
QString m_version;
|
||||
unsigned int m_configVersion;
|
||||
QStringList m_recentlyOpenedProjects;
|
||||
QStringList m_favoriteItems;
|
||||
|
||||
using stringPairVector = std::vector<QPair<QString, QString>>;
|
||||
using settingsMap = QMap<QString, stringPairVector>;
|
||||
|
||||
@@ -61,19 +61,22 @@ class FileBrowser : public SideBarWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Normal,
|
||||
Favorites
|
||||
};
|
||||
|
||||
/**
|
||||
Create a file browser side bar widget
|
||||
@param directories '*'-separated list of directories to search for.
|
||||
If a directory of factory files should be in the list it
|
||||
must be the last one (for the factory files delimiter to work)
|
||||
@param filter Filter as used in QDir::match
|
||||
@param recurse *to be documented*
|
||||
*/
|
||||
FileBrowser( const QString & directories, const QString & filter,
|
||||
const QString & title, const QPixmap & pm,
|
||||
QWidget * parent, bool dirs_as_items = false,
|
||||
const QString& userDir = "",
|
||||
const QString& factoryDir = "");
|
||||
Create a file browser side bar widget
|
||||
@param directories '*'-separated list of directories to search for.
|
||||
If a directory of factory files should be in the list it
|
||||
must be the last one (for the factory files delimiter to work)
|
||||
@param filter Filter as used in QDir::match
|
||||
@param recurse *to be documented*
|
||||
*/
|
||||
FileBrowser(Type type, const QString& directories, const QString& filter, const QString& title, const QPixmap& pm,
|
||||
QWidget* parent, bool dirs_as_items = false, const QString& userDir = "", const QString& factoryDir = "");
|
||||
|
||||
~FileBrowser() override = default;
|
||||
|
||||
@@ -90,6 +93,7 @@ public:
|
||||
};
|
||||
return s_excludedPaths;
|
||||
}
|
||||
|
||||
static QDir::Filters dirFilters() { return QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden; }
|
||||
static QDir::SortFlags sortFlags() { return QDir::LocaleAware | QDir::DirsFirst | QDir::Name | QDir::IgnoreCase; }
|
||||
|
||||
@@ -101,7 +105,7 @@ private slots:
|
||||
private:
|
||||
void keyPressEvent( QKeyEvent * ke ) override;
|
||||
|
||||
void addItems( const QString & path );
|
||||
void addItems(const QString & path);
|
||||
|
||||
void saveDirectoriesStates();
|
||||
void restoreDirectoriesStates();
|
||||
@@ -117,6 +121,7 @@ private:
|
||||
FileBrowserTreeWidget * m_searchTreeWidget;
|
||||
|
||||
QLineEdit * m_filterEdit;
|
||||
Type m_type;
|
||||
|
||||
std::shared_ptr<FileSearch> m_currentSearch;
|
||||
QProgressBar* m_searchIndicator = nullptr;
|
||||
@@ -216,8 +221,7 @@ public:
|
||||
{
|
||||
path += QDir::separator();
|
||||
}
|
||||
return( QDir::cleanPath( path + text( 0 ) ) +
|
||||
QDir::separator() );
|
||||
return QDir::cleanPath(path + text(0));
|
||||
}
|
||||
|
||||
inline void addDirectory( const QString & dir )
|
||||
|
||||
@@ -46,6 +46,7 @@ class ConfigManager;
|
||||
namespace gui
|
||||
{
|
||||
|
||||
class FileBrowser;
|
||||
class PluginView;
|
||||
class SubWindow;
|
||||
class ToolButton;
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
|
||||
namespace lmms::PathUtil
|
||||
{
|
||||
enum class Base { Absolute, ProjectDir, FactorySample, UserSample, UserVST, Preset,
|
||||
UserLADSPA, DefaultLADSPA, UserSoundfont, DefaultSoundfont, UserGIG, DefaultGIG,
|
||||
enum class Base { Absolute, ProjectDir, FactoryProjects, FactorySample, UserSample, UserVST, Preset,
|
||||
FactoryPresets, UserLADSPA, DefaultLADSPA, UserSoundfont, DefaultSoundfont, UserGIG, DefaultGIG,
|
||||
LocalDir };
|
||||
|
||||
//! Return the directory associated with a given base as a QString
|
||||
|
||||
Reference in New Issue
Block a user