Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for local paths and project bundles #5735

Merged
merged 36 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5bfad37
Adds a baseDir for the local path
IanCaio Oct 25, 2020
1e89441
Starts implementing the makeBundle functionality
IanCaio Oct 26, 2020
f34e966
Starts implementing logic to go through resources
IanCaio Oct 26, 2020
ff9af55
Adds logic to copy files and update the project
IanCaio Oct 26, 2020
f59cc9c
Makes the writeBundle method more organized
IanCaio Oct 26, 2020
14992ff
Adds a project bundle folder
IanCaio Oct 28, 2020
c174b3e
Handles local paths when a project isn't open
IanCaio Oct 28, 2020
b76e9f8
Sanitizes the bundle name
IanCaio Oct 29, 2020
3aac591
Moves away from projectbundle folder concept
IanCaio Oct 29, 2020
3e86cd6
Adds an option to save project as bundle
IanCaio Oct 29, 2020
218c211
Fix local: prefix saving bug
IanCaio Oct 29, 2020
6b1e5ac
Adds a warning message box
IanCaio Oct 29, 2020
1b13381
Removes unused header
IanCaio Oct 29, 2020
dbffea7
Removes Vestige plugins bundling
IanCaio Oct 31, 2020
2c15d4e
Extracts code from loadProject to another method
IanCaio Oct 31, 2020
598396b
Merge branch 'master' into feature/localPath
IanCaio Nov 9, 2020
93915b9
Merge branch 'master' into feature/localPath
IanCaio Feb 21, 2021
88278ea
Removes debug warnings
IanCaio Feb 21, 2021
14c1d3c
Fixes small bug with error logging
IanCaio Feb 21, 2021
941ad2a
Merge branch 'master' into feature/localPath
IanCaio Mar 18, 2021
465900d
Saves the bundle in a newly created folder
IanCaio Mar 18, 2021
4459d3c
Enhances the name conflict workaround
IanCaio Mar 18, 2021
e0a4c12
Starts addressing Johannes review
IanCaio Mar 25, 2021
43b3dfd
Adds makebundle action to bash completion file
IanCaio Mar 25, 2021
45b62e8
Improves safety check on project files
IanCaio Mar 26, 2021
b8bbea6
Addresses Spekular change request
IanCaio Mar 26, 2021
0ea10ff
Makes hasLocalPlugins method const
IanCaio Mar 26, 2021
8970cc4
Replaces literal uses of "local:"
IanCaio Mar 27, 2021
18c6239
Fix some comments on the header and cpp file
IanCaio Mar 27, 2021
e0eba3c
Changes variable on PathUtil to const
IanCaio Mar 27, 2021
d1d50b5
Leave doxygen comment on CPP file only
IanCaio Mar 28, 2021
9ef814f
Fix doxygen comment @param
IanCaio Mar 28, 2021
64b652d
Remove assert statements
IanCaio Mar 28, 2021
efef46a
Skips local paths when looking for shortest path
IanCaio Mar 28, 2021
5ffc99c
Address Spekular's review
IanCaio Mar 31, 2021
91509bd
Replaces "ok" with "error"
IanCaio Mar 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion doc/bash-completion/lmms
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ _lmms()
pars_render=(--float --bitrate --format --interpolation)
pars_render+=(--loop --mode --output --profile)
pars_render+=(--samplerate --oversampling)
actions=(dump compress render rendertracks upgrade)
actions=(dump compress render rendertracks upgrade makebundle)
actions_old=(-d --dump -r --render --rendertracks -u --upgrade)
shortargs+=(-a -b -c -f -h -i -l -m -o -p -s -v -x)

Expand Down Expand Up @@ -250,6 +250,17 @@ _lmms()
filemode="files"
filetypes="$savefiletypes"
fi
elif [ "$action_found" == "makebundle" ]
then
if [ "$prev" == "makebundle" ]
then
filemode="existing_files"
filetypes="$savefiletypes"
elif [ "$prev2" == "makebundle" ]
then
filemode="files"
filetypes="$savefiletypes"
fi
elif [[ "$action_found" =~ render(tracks)? ]]
then
if [[ "$prev" =~ render(tracks)? ]]
Expand Down
10 changes: 9 additions & 1 deletion include/DataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef DATA_FILE_H
#define DATA_FILE_H

#include <map>
#include <QDomDocument>

#include "lmms_export.h"
Expand Down Expand Up @@ -71,7 +72,9 @@ class LMMS_EXPORT DataFile : public QDomDocument
QString nameWithExtension( const QString& fn ) const;

void write( QTextStream& strm );
bool writeFile( const QString& fn );
bool writeFile(const QString& fn, bool withResources = false);
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
bool copyResources(const QString& resourcesDir); //!< Copies resources to the resourcesDir and changes the DataFile to use local paths to them
bool hasLocalPlugins(QDomElement parent = QDomElement(), bool firstCall = true) const;

QDomElement& content()
{
Expand Down Expand Up @@ -122,6 +125,10 @@ class LMMS_EXPORT DataFile : public QDomDocument
// List of ProjectVersions for the legacyFileVersion method
static const std::vector<ProjectVersion> UPGRADE_VERSIONS;

// Map with DOM elements that access resources (for making bundles)
typedef std::map<QString, std::vector<QString>> ResourcesMap;
static const ResourcesMap ELEMENTS_WITH_RESOURCES;

void upgrade();

void loadData( const QByteArray & _data, const QString & _sourceFile );
Expand All @@ -134,6 +141,7 @@ class LMMS_EXPORT DataFile : public QDomDocument
} ;
static typeDescStruct s_types[TypeCount];

QString m_fileName; //!< The origin file name or "" if this DataFile didn't originate from a file
QDomElement m_content;
QDomElement m_head;
Type m_type;
Expand Down
24 changes: 16 additions & 8 deletions include/PathUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
namespace PathUtil
{
enum class Base { Absolute, ProjectDir, FactorySample, UserSample, UserVST, Preset,
UserLADSPA, DefaultLADSPA, UserSoundfont, DefaultSoundfont, UserGIG, DefaultGIG };
UserLADSPA, DefaultLADSPA, UserSoundfont, DefaultSoundfont, UserGIG, DefaultGIG,
LocalDir };

//! Return the directory associated with a given base as a QString
QString LMMS_EXPORT baseLocation(const Base base);
//! Return the directory associated with a given base as a QDir
QDir LMMS_EXPORT baseQDir (const Base base);
//! Optionally, if a pointer to boolean is given the method will
//! use it to indicate whether the prefix could be resolved properly
//! or not.
QString LMMS_EXPORT baseLocation(const Base base, bool* error = nullptr);
//! Return the directory associated with a given base as a QDir.
//! Optional pointer to boolean to indicate if the prefix could
//! be resolved properly.
QDir LMMS_EXPORT baseQDir (const Base base, bool* error = nullptr);
//! Return the prefix used to denote this base in path strings
QString LMMS_EXPORT basePrefix(const Base base);
//! Check the prefix of a path and return the base it corresponds to
Expand All @@ -28,13 +34,15 @@ namespace PathUtil
//! Upgrade prefix-less relative paths to the new format
QString LMMS_EXPORT oldRelativeUpgrade(const QString & input);

//! Make this path absolute
QString LMMS_EXPORT toAbsolute(const QString & input);
//! Make this path absolute. If a pointer to boolean is given
//! it will indicate whether the path was converted successfully
QString LMMS_EXPORT toAbsolute(const QString & input, bool* error = nullptr);
//! Make this path relative to a given base, return an absolute path if that fails
QString LMMS_EXPORT relativeOrAbsolute(const QString & input, const Base base);
//! Make this path relative to any base, choosing the shortest if there are
//! multiple options. Defaults to an absolute path if all bases fail.
QString LMMS_EXPORT toShortestRelative(const QString & input);
//! multiple options. allowLocal defines whether local paths should be considered.
//! Defaults to an absolute path if all bases fail.
QString LMMS_EXPORT toShortestRelative(const QString & input, bool allowLocal = false);

}

Expand Down
9 changes: 7 additions & 2 deletions include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ class LMMS_EXPORT Song : public TrackContainer
* Should we discard MIDI ControllerConnections from project files?
*/
BoolModel discardMIDIConnections{false};
/**
* Should we save the project as a project bundle? (with resources)
*/
BoolModel saveAsProjectBundle{false};

void setDefaultOptions() {
discardMIDIConnections.setValue(false);
saveAsProjectBundle.setValue(false);
}
};

Expand Down Expand Up @@ -282,8 +287,8 @@ class LMMS_EXPORT Song : public TrackContainer
void createNewProjectFromTemplate( const QString & templ );
void loadProject( const QString & filename );
bool guiSaveProject();
bool guiSaveProjectAs( const QString & filename );
bool saveProjectFile( const QString & filename );
bool guiSaveProjectAs(const QString & filename);
bool saveProjectFile(const QString & filename, bool withResources = false);

const QString & projectFileName() const
{
Expand Down
1 change: 1 addition & 0 deletions include/VersionedSaveDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SaveOptionsWidget : public QWidget {

private:
LedCheckBox *m_discardMIDIConnectionsCheckbox;
LedCheckBox *m_saveAsProjectBundleCheckbox;
};

class VersionedSaveDialog : public FileDialog
Expand Down
Loading