summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2011-05-13 20:18:01 +0000
committerRobert Jonsson <spamatica@gmail.com>2011-05-13 20:18:01 +0000
commit99ccbebf8ce4e7070843fff94f2953c2818ca5c8 (patch)
tree8eb163af0b78724036ce088169bb8f432d2d178c /muse2
parent7a980874149d99539b65cc9df66c217e7be33adf (diff)
find unused wave files
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog1
-rw-r--r--muse2/muse/app.cpp23
-rw-r--r--muse2/muse/app.h7
-rw-r--r--muse2/muse/widgets/CMakeLists.txt9
-rw-r--r--muse2/muse/widgets/unusedwavefiles.cpp96
-rw-r--r--muse2/muse/widgets/unusedwavefiles.h25
-rw-r--r--muse2/muse/widgets/unusedwavefiles.ui131
7 files changed, 283 insertions, 9 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 2e3fa20f..32382091 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,5 +1,6 @@
13.05.2011:
- New spanish translation from Cristian Ramos (rj)
+ - Added dialog to remove unused wave files (rj)
- Changed default imported midi song type to GM. (Tim)
12.05.2011:
- Changed template song "default.med" song type from NO to GM, to help new users. (Tim)
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 59993911..c42a1a7c 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -55,6 +55,7 @@
#include "widgets/menutitleitem.h"
#include "tools.h"
#include "visibletracks.h"
+#include "widgets/unusedwavefiles.h"
#ifdef DSSI_SUPPORT
#include "dssihost.h"
@@ -966,6 +967,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
fileImportPartAction = new QAction(tr("Import Part"), this);
fileImportWaveAction = new QAction(tr("Import Wave File"), this);
+ fileMoveWaveFiles = new QAction(tr("Find unused wave files"), this);
quitAction = new QAction(tr("&Quit"), this);
@@ -1000,10 +1002,9 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
scoreAllInOneSubsubmenu = new QMenu(tr("all parts in one staff"), this);
scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per part"), this);
- scoreSubmenu->addMenu(scoreAllInOneSubsubmenu);
- scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu);
-
- updateScoreMenus();
+ scoreSubmenu->addMenu(scoreAllInOneSubsubmenu);
+ scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu);
+ updateScoreMenus();
startScoreEditAction = new QAction(*scoreIconSet, tr("New score window"), this);
startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this);
@@ -1075,6 +1076,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
autoClearAction = new QAction(QIcon(*automation_clear_dataIcon), tr("Clear Automation Data"), this);
autoClearAction->setEnabled(false);
+
//-------- Settings Actions
settingsGlobalAction = new QAction(QIcon(*settings_globalsettingsIcon), tr("Global Settings"), this);
settingsShortcutsAction = new QAction(QIcon(*settings_configureshortcutsIcon), tr("Configure Shortcuts"), this);
@@ -1116,6 +1118,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
connect(fileImportPartAction, SIGNAL(activated()), SLOT(importPart()));
connect(fileImportWaveAction, SIGNAL(activated()), SLOT(importWave()));
+ connect(fileMoveWaveFiles, SIGNAL(activated()), SLOT(findUnusedWaveFiles()));
connect(quitAction, SIGNAL(activated()), SLOT(quitDoc()));
//-------- Edit connections
@@ -1342,6 +1345,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
menu_file->addSeparator();
menu_file->addAction(fileImportWaveAction);
menu_file->addSeparator();
+ menu_file->addAction(fileMoveWaveFiles);
+ menu_file->addSeparator();
menu_file->addAction(quitAction);
menu_file->addSeparator();
@@ -5098,6 +5103,7 @@ void MusE::execDeliveredScript(int id)
//QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
song->executeScript(song->getScriptPath(id, true).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
}
+
//---------------------------------------------------------
// execUserScript
//---------------------------------------------------------
@@ -5105,3 +5111,12 @@ void MusE::execUserScript(int id)
{
song->executeScript(song->getScriptPath(id, false).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
}
+
+//---------------------------------------------------------
+// findUnusedWaveFiles
+//---------------------------------------------------------
+void MusE::findUnusedWaveFiles()
+{
+ UnusedWaveFiles unused(muse);
+ unused.exec();
+}
diff --git a/muse2/muse/app.h b/muse2/muse/app.h
index 42aebf3b..e940c1ad 100644
--- a/muse2/muse/app.h
+++ b/muse2/muse/app.h
@@ -104,7 +104,8 @@ class MusE : public QMainWindow
// File menu actions
QAction *fileSaveAction, *fileOpenAction, *fileNewAction, *testAction;
- QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction, *fileImportPartAction, *fileImportWaveAction, *quitAction;
+ QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction;
+ QAction *fileImportPartAction, *fileImportWaveAction, *fileMoveWaveFiles, *quitAction;
// Edit Menu actions
QAction *editCutAction, *editCopyAction, *editPasteAction, *editInsertAction, *editPasteCloneAction, *editPaste2TrackAction;
@@ -160,7 +161,7 @@ class MusE : public QMainWindow
QMenu *menu_file, *menuView, *menuSettings, *menu_help;
QMenu *menuEdit, *menuStructure;
- QMenu* menu_audio, *menuAutomation;
+ QMenu* menu_audio, *menuAutomation, *menuUtils;
QMenu* menu_functions, *menuScriptPlugins;
QMenu* select, *master, *midiEdit, *addTrack;
@@ -247,6 +248,7 @@ class MusE : public QMainWindow
void importWave();
void importPart();
void exportMidi();
+ void findUnusedWaveFiles();
void toggleTransport(bool);
void toggleMarker(bool);
@@ -375,6 +377,7 @@ class MusE : public QMainWindow
bool seqStart();
void setHeartBeat();
void importController(int, MidiPort*, int);
+ QString projectName() { return project.fileName(); }
//QWidget* mixerWindow();
QWidget* mixer1Window();
QWidget* mixer2Window();
diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt
index 261c27a2..9a3f993a 100644
--- a/muse2/muse/widgets/CMakeLists.txt
+++ b/muse2/muse/widgets/CMakeLists.txt
@@ -75,7 +75,8 @@ QT4_WRAP_CPP (widget_mocs
tools.h
# ttoolbar.h
ttoolbutton.h
- velocity.h
+ unusedwavefiles.h
+ velocity.h
verticalmeter.h
view.h
vscale.h
@@ -109,7 +110,8 @@ file (GLOB widgets_ui_files
songinfo.ui
synthconfigbase.ui
transformbase.ui
- transposebase.ui
+ transposebase.ui
+ unusedwavefiles.ui
velocitybase.ui
)
QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files})
@@ -175,7 +177,8 @@ file (GLOB widgets_source_files
tools.cpp
ttoolbar.cpp
ttoolbutton.cpp
- utils.cpp
+ unusedwavefiles.cpp
+ utils.cpp
velocity.cpp
verticalmeter.cpp
view.cpp
diff --git a/muse2/muse/widgets/unusedwavefiles.cpp b/muse2/muse/widgets/unusedwavefiles.cpp
new file mode 100644
index 00000000..7cba1bd5
--- /dev/null
+++ b/muse2/muse/widgets/unusedwavefiles.cpp
@@ -0,0 +1,96 @@
+#include <stdio.h>
+#include <qdir.h>
+#include <qfileinfo.h>
+#include <qstringlist.h>
+#include <qtextstream.h>
+#include <qmessagebox.h>
+#include "unusedwavefiles.h"
+#include "ui_unusedwavefiles.h"
+#include "globals.h"
+#include "app.h"
+
+UnusedWaveFiles::UnusedWaveFiles(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::UnusedWaveFiles)
+{
+
+ ui->setupUi(this);
+ ui->currentProjRadioButton->setChecked(true);
+ connect(ui->currentProjRadioButton, SIGNAL(clicked()), SLOT(findWaveFiles()));
+ connect(ui->allProjRadioButton, SIGNAL(clicked()), SLOT(findWaveFiles()));
+ findWaveFiles();
+
+}
+
+void UnusedWaveFiles::findWaveFiles()
+{
+ ui->filelistWidget->clear();
+ printf("museProject =%s\n", museProject.toLatin1().data());
+// QFileInfo proj(museProject);
+// QString projPath = proj.absolutePath();
+ QDir dir(museProject);
+ QStringList filter;
+ filter.append("*.wav");
+ filter.append("*.ogg");
+ allWaveFiles= dir.entryList(filter);
+ if (!allWaveFiles.count())
+ return;
+ // get med files
+ QStringList medFiles;
+ if (ui->currentProjRadioButton->isChecked()) {
+ medFiles.append(muse->projectName());
+ } else {
+ printf("get ALLL *.med files!\n");
+ QStringList medFilter("*.med");
+ medFiles = dir.entryList(medFilter);
+ }
+ foreach (QString medFile, medFiles) {
+ QString fname = museProject+"/"+ medFile;
+ //printf("fopen %s\n", fname.toLatin1().data());
+ FILE *fp =fopen(fname.toLatin1().data(),"r");
+ QTextStream fileContent(fp);
+ while (!fileContent.atEnd()) {
+ QString line = fileContent.readLine();
+ if (line.contains(".wav") || line.contains(".ogg")) { // optimization
+ foreach (QString wav, allWaveFiles) {
+ //printf("checking wav [%s]\n", wav.toLatin1().data() );
+ if (line.contains(wav)) {
+ //int beforeSize=allWaveFiles.size();
+ allWaveFiles.removeOne(wav);
+ //printf("removed one from list, %d %d\n", beforeSize, allWaveFiles.size());
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ ui->filelistWidget->addItems(allWaveFiles);
+ update();
+}
+
+UnusedWaveFiles::~UnusedWaveFiles()
+{
+ delete ui;
+}
+
+void UnusedWaveFiles::accept()
+{
+ int ret = QMessageBox::question(this,"Move files", "Are you sure you want to move away the unused files?",
+ QMessageBox::Ok, QMessageBox::Cancel);
+ if (ret == QMessageBox::Ok) {
+ QDir currDir(museProject);
+ currDir.mkdir("unused");
+
+ foreach(QString file, allWaveFiles) {
+ QFile::rename(museProject+ "/"+file, museProject + "/unused/" +file);
+ // move the wca file if it exists
+ QFileInfo wf(museProject + "/" + file);
+ if (QFile::exists(museProject + "/" + wf.baseName()+".wca")) {
+ QFile::rename(museProject + "/" + wf.baseName()+".wca", museProject + "/unused/" +wf.baseName()+".wca");
+
+ }
+ }
+ }
+ QDialog::accept();
+}
diff --git a/muse2/muse/widgets/unusedwavefiles.h b/muse2/muse/widgets/unusedwavefiles.h
new file mode 100644
index 00000000..fd1f524c
--- /dev/null
+++ b/muse2/muse/widgets/unusedwavefiles.h
@@ -0,0 +1,25 @@
+#ifndef UNUSEDWAVEFILES_H
+#define UNUSEDWAVEFILES_H
+
+#include <QDialog>
+
+namespace Ui {
+ class UnusedWaveFiles;
+}
+
+class UnusedWaveFiles : public QDialog
+{
+ Q_OBJECT
+ QStringList allWaveFiles;
+public:
+ explicit UnusedWaveFiles(QWidget *parent = 0);
+ ~UnusedWaveFiles();
+
+public slots:
+ void accept();
+ void findWaveFiles();
+private:
+ Ui::UnusedWaveFiles *ui;
+};
+
+#endif // UNUSEDWAVEFILES_H
diff --git a/muse2/muse/widgets/unusedwavefiles.ui b/muse2/muse/widgets/unusedwavefiles.ui
new file mode 100644
index 00000000..65c8c804
--- /dev/null
+++ b/muse2/muse/widgets/unusedwavefiles.ui
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UnusedWaveFiles</class>
+ <widget class="QDialog" name="UnusedWaveFiles">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>508</width>
+ <height>241</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>List of unused audio files in current project directory:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" rowspan="2">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="currentProjRadioButton">
+ <property name="text">
+ <string>Current project</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="allProjRadioButton">
+ <property name="text">
+ <string>All .med files
+in current
+ directory</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QListWidget" name="filelistWidget"/>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>98</width>
+ <height>17</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="moveButton">
+ <property name="text">
+ <string>Move files to 'unused' subdir</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>cancelButton</sender>
+ <signal>clicked()</signal>
+ <receiver>UnusedWaveFiles</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>416</x>
+ <y>331</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>305</x>
+ <y>183</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>moveButton</sender>
+ <signal>clicked()</signal>
+ <receiver>UnusedWaveFiles</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>266</x>
+ <y>321</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>305</x>
+ <y>183</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>