Browse Source

Don't display "1_", "42_", "001_", etc at the beginning of preset filenames.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
972cd587f7
2 changed files with 10 additions and 2 deletions
  1. +3
    -1
      include/system.hpp
  2. +7
    -1
      src/app/ModuleWidget.cpp

+ 3
- 1
include/system.hpp View File

@@ -12,7 +12,9 @@ namespace rack {
namespace system { namespace system {




/** Returns a list of all entries (directories, files, symbols) in a directory. */
/** Returns a list of all entries (directories, files, symbols) in a directory.
Sorted alphabetically.
*/
std::list<std::string> getEntries(const std::string& path); std::list<std::string> getEntries(const std::string& path);
std::list<std::string> getEntriesRecursive(const std::string &path, int depth); std::list<std::string> getEntriesRecursive(const std::string &path, int depth);
/** Returns whether the given path is a file. */ /** Returns whether the given path is a file. */


+ 7
- 1
src/app/ModuleWidget.cpp View File

@@ -1,4 +1,5 @@
#include <thread> #include <thread>
#include <regex>


#include <osdialog.h> #include <osdialog.h>


@@ -243,8 +244,13 @@ struct ModulePresetItem : ui::MenuItem {
continue; continue;
hasPresets = true; hasPresets = true;


std::string presetName = string::filenameBase(presetFilename);
// Remove "1_", "42_", "001_", etc at the beginning of preset filenames
std::regex r("^\\d*_");
presetName = std::regex_replace(presetName, r, "");

ModulePresetPathItem* presetItem = new ModulePresetPathItem; ModulePresetPathItem* presetItem = new ModulePresetPathItem;
presetItem->text = string::filenameBase(presetFilename);
presetItem->text = presetName;
presetItem->presetPath = presetPath; presetItem->presetPath = presetPath;
presetItem->moduleWidget = moduleWidget; presetItem->moduleWidget = moduleWidget;
menu->addChild(presetItem); menu->addChild(presetItem);


Loading…
Cancel
Save