diff options
author | Robert Jonsson <spamatica@gmail.com> | 2010-12-27 00:39:58 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2010-12-27 00:39:58 +0000 |
commit | 8092776083f70a25b8615c7b8d6299e2daba8865 (patch) | |
tree | 43b919a724811690dfbff86c043ced76e632e2f8 /muse2/muse | |
parent | 64e73dd6d68da03c6c7fad0d314f237703e3996d (diff) |
create new project dialog added
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/app.cpp | 30 | ||||
-rw-r--r-- | muse2/muse/audiotrack.cpp | 24 | ||||
-rw-r--r-- | muse2/muse/conf.cpp | 7 | ||||
-rw-r--r-- | muse2/muse/gconfig.cpp | 4 | ||||
-rw-r--r-- | muse2/muse/gconfig.h | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/CMakeLists.txt | 1 | ||||
-rw-r--r-- | muse2/muse/song.cpp | 14 | ||||
-rw-r--r-- | muse2/muse/track.h | 3 | ||||
-rw-r--r-- | muse2/muse/widgets/CMakeLists.txt | 9 | ||||
-rw-r--r-- | muse2/muse/widgets/filedialog.cpp | 10 | ||||
-rw-r--r-- | muse2/muse/widgets/filedialog.h | 9 | ||||
-rw-r--r-- | muse2/muse/widgets/projectcreate.ui | 145 | ||||
-rw-r--r-- | muse2/muse/widgets/projectcreateimpl.cpp | 63 | ||||
-rw-r--r-- | muse2/muse/widgets/projectcreateimpl.h | 26 |
14 files changed, 320 insertions, 27 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index eecc94ff..596c4f19 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -48,6 +48,7 @@ #include "transport.h" #include "transpose.h" #include "waveedit.h" +#include "widgets/projectcreateimpl.h" #ifdef DSSI_SUPPORT #include "dssihost.h" @@ -1678,6 +1679,7 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll return; } project.setFile("untitled"); + museProject = museProjectInitPath; } else { printf("Setting project path to %s\n", fi.absolutePath().toLatin1().constData()); @@ -1832,7 +1834,7 @@ void MusE::setUntitledProject() { setConfigDefaults(); QString name("untitled"); - museProject = QFileInfo(name).absolutePath(); + museProject = "./"; //QFileInfo(name).absolutePath(); project.setFile(name); setWindowTitle(tr("MusE: Song: ") + project.completeBaseName()); } @@ -1913,7 +1915,7 @@ void MusE::loadProject() void MusE::loadTemplate() { QString fn = getOpenFileName(QString("templates"), med_file_pattern, this, - tr("MusE: load template"), 0); + tr("MusE: load template"), 0, MFileDialog::GLOBAL_VIEW); if (!fn.isEmpty()) { // museProject = QFileInfo(fn).absolutePath(); loadProjectFile(fn, true, true); @@ -3046,10 +3048,25 @@ PopupView* MusE::prepareRoutingPopupView(Track* track, bool dst) bool MusE::saveAs() { -// QString name = getSaveFileName(museProject, med_file_pattern, this, -// QString name = getSaveFileName(QString(""), med_file_pattern, this, - QString name = getSaveFileName(QString(""), med_file_save_pattern, this, - tr("MusE: Save As")); + QString name; + if (museProject == museProjectInitPath ) { + ProjectCreateImpl pci(muse); + if (pci.exec() == QDialog::Rejected) { + return false; + } + + name = pci.getProjectPath(); + song->setSongInfo(pci.getSongInfo()); + museProject = QFileInfo(name).absolutePath(); + QDir dirmanipulator; + if (!dirmanipulator.mkpath(museProject)) { + QMessageBox::warning(this,"Path error","Can't create project path", QMessageBox::Ok); + return false; + } + } + else { + name = getSaveFileName(QString(""), med_file_save_pattern, this, tr("MusE: Save As")); + } bool ok = false; if (!name.isEmpty()) { QString tempOldProj = museProject; @@ -4843,4 +4860,3 @@ void MusE::execUserScript(int id) { song->executeScript(song->getScriptPath(id, false).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger } - diff --git a/muse2/muse/audiotrack.cpp b/muse2/muse/audiotrack.cpp index 0ced1b8b..959ce7f2 100644 --- a/muse2/muse/audiotrack.cpp +++ b/muse2/muse/audiotrack.cpp @@ -1587,13 +1587,13 @@ bool AudioTrack::setRecordFlag1(bool f) SF_FORMAT_WAV | SF_FORMAT_FLOAT, _channels, sampleRate); } - if(_recFile->openWrite()) - { - QMessageBox::critical(NULL, "MusE write error.", "Error creating target wave file\n" - "Check your configuration."); - return false; - - } +// if(_recFile->openWrite()) +// { +// QMessageBox::critical(NULL, "MusE write error.", "Error creating target wave file\n" +// "Check your configuration."); +// return false; +// +// } if (debugMsg) printf("AudioNode::setRecordFlag1: create internal file %s\n", _recFile->path().toLatin1().constData()); @@ -1619,6 +1619,16 @@ bool AudioTrack::setRecordFlag1(bool f) } return true; } +bool AudioTrack::prepareRecording() +{ + if(_recFile->openWrite()) + { + QMessageBox::critical(NULL, "MusE write error.", "Error creating target wave file\n" + "Check your configuration."); + return false; + + } +} double AudioTrack::auxSend(int idx) const { if (unsigned(idx) >= _auxSend.size()) { diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp index 180578e2..02565712 100644 --- a/muse2/muse/conf.cpp +++ b/muse2/muse/conf.cpp @@ -848,6 +848,10 @@ void readConfiguration(Xml& xml, bool readOnlySequencer) config.startMode = xml.parseInt(); else if (tag == "startSong") config.startSong = xml.parse1(); + else if (tag == "projectBaseFolder") + config.projectBaseFolder = xml.parse1(); + else if (tag == "projectStoreInFolder") + config.projectStoreInFolder = xml.parseInt(); else xml.unknown("configuration"); break; @@ -1096,7 +1100,8 @@ void MusE::writeGlobalConfiguration(int level, Xml& xml) const xml.intTag(level, "importMidiSplitParts", config.importMidiSplitParts); xml.intTag(level, "startMode", config.startMode); xml.strTag(level, "startSong", config.startSong); - + xml.strTag(level, "projectBaseFolder", config.projectBaseFolder); + xml.intTag(level, "projectStoreInFolder", config.projectStoreInFolder); xml.intTag(level, "midiInputDevice", midiInputPorts); xml.intTag(level, "midiInputChannel", midiInputChannel); xml.intTag(level, "midiRecordType", midiRecordType); diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index f4e07c63..2b0caafb 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -134,6 +134,8 @@ GlobalConfigValues config = { true, // showDidYouKnow false, // vstInPlace Enable VST in-place processing 44100, // Dummy audio preferred sample rate - 512 // Dummy audio buffer size + 512, // Dummy audio buffer size + QString("./"), // projectBaseFolder + true // projectStoreInFolder }; diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h index f9c2793a..f58b1a51 100644 --- a/muse2/muse/gconfig.h +++ b/muse2/muse/gconfig.h @@ -127,6 +127,8 @@ struct GlobalConfigValues { bool vstInPlace; // Enable VST in-place processing int dummyAudioSampleRate; int dummyAudioBufSize; + QString projectBaseFolder; + bool projectStoreInFolder; }; extern GlobalConfigValues config; diff --git a/muse2/muse/midiedit/CMakeLists.txt b/muse2/muse/midiedit/CMakeLists.txt index d7bdd8ed..3d0efe82 100644 --- a/muse2/muse/midiedit/CMakeLists.txt +++ b/muse2/muse/midiedit/CMakeLists.txt @@ -93,6 +93,7 @@ target_link_libraries ( midiedit al icons widgets + ctrl ) ## diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index 999cfefd..4feda40f 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -1073,6 +1073,11 @@ void Song::clearTrackRec() //--------------------------------------------------------- void Song::setRecord(bool f, bool autoRecEnable) { + if (f && museProject == museProjectInitPath ) { // check that there is a project stored before commencing + // no project, we need to create one. + if (!muse->saveAs()) + return; // could not store project, won't enable record + } if (recordFlag != f) { if (f && autoRecEnable) { bool alreadyRecEnabled = false; @@ -1114,6 +1119,14 @@ void Song::setRecord(bool f, bool autoRecEnable) f = false; } } + // prepare recording of wave files for all record enabled wave tracks + for (iWaveTrack i = wtl->begin(); i != wtl->end(); ++i) { + if((*i)->recordFlag()) + { + (*i)->prepareRecording(); + } + } + #if 0 // check for midi devices suitable for recording bool portFound = false; @@ -1752,6 +1765,7 @@ void Song::setRecordFlag(Track* track, bool val) } // updateFlags |= SC_RECFLAG; update(SC_RECFLAG); + } //--------------------------------------------------------- diff --git a/muse2/muse/track.h b/muse2/muse/track.h index eb5db071..48c9474e 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -318,7 +318,8 @@ class AudioTrack : public Track { virtual bool setRecordFlag1(bool f); virtual void setRecordFlag2(bool f); - + bool prepareRecording(); + bool processed() { return _processed; } //void setProcessed(bool v) { _processed = v; } diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt index 24785709..92eacc66 100644 --- a/muse2/muse/widgets/CMakeLists.txt +++ b/muse2/muse/widgets/CMakeLists.txt @@ -55,6 +55,7 @@ QT4_WRAP_CPP (widget_mocs popupmenu.h # posedit.h poslabel.h + projectcreateimpl.h scrollscale.h shortcutcapturedialog.h shortcutconfig.h @@ -98,14 +99,15 @@ file (GLOB widgets_ui_files midisync.ui mittransposebase.ui mixdowndialogbase.ui - mtrackinfobase.ui + mtrackinfobase.ui + projectcreate.ui shortcutcapturedialogbase.ui shortcutconfigbase.ui songinfo.ui synthconfigbase.ui transformbase.ui transposebase.ui - velocitybase.ui + velocitybase.ui ) QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files}) @@ -147,7 +149,8 @@ file (GLOB widgets_source_files pitchlabel.cpp popupmenu.cpp # posedit.cpp - poslabel.cpp + poslabel.cpp + projectcreateimpl.cpp scldiv.cpp scldraw.cpp sclif.cpp diff --git a/muse2/muse/widgets/filedialog.cpp b/muse2/muse/widgets/filedialog.cpp index 81791f6b..02d4efb9 100644 --- a/muse2/muse/widgets/filedialog.cpp +++ b/muse2/muse/widgets/filedialog.cpp @@ -308,15 +308,19 @@ QString getFilterExtension(const QString &filter) //--------------------------------------------------------- // getOpenFileName //--------------------------------------------------------- - QString getOpenFileName(const QString &startWith, - //const char** filters, QWidget* parent, const QString& name, bool* all) - const QStringList& filters, QWidget* parent, const QString& name, bool* all) + const QStringList& filters, QWidget* parent, const QString& name, bool* all, MFileDialog::ViewType viewType) { QString initialSelection; // FIXME Tim. MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, false); dlg->setNameFilters(filters); dlg->setWindowTitle(name); + if (viewType == MFileDialog::GLOBAL_VIEW) + dlg->globalToggled(true); + else if (viewType == MFileDialog::PROJECT_VIEW) + dlg->projectToggled(true); + else if (viewType == MFileDialog::USER_VIEW) + dlg->userToggled(true); if (all) { dlg->buttons.loadAllGroup->setVisible(true); //dlg->buttons.globalButton->setVisible(false); diff --git a/muse2/muse/widgets/filedialog.h b/muse2/muse/widgets/filedialog.h index a7c8a1f7..0d3dfc8c 100644 --- a/muse2/muse/widgets/filedialog.h +++ b/muse2/muse/widgets/filedialog.h @@ -33,19 +33,20 @@ class FileDialogButtonsWidget : public QWidget, public Ui::FileDialogButtons class MFileDialog : public QFileDialog { Q_OBJECT - enum ViewType { GLOBAL_VIEW, PROJECT_VIEW, USER_VIEW }; //!< The three different viewtypes - static ViewType lastViewUsed; static QString lastUserDir, lastGlobalDir; bool showButtons; QString baseDir; private slots: + void directoryChanged(const QString& directory); + public slots: void globalToggled(bool); void userToggled(bool); void projectToggled(bool); - void directoryChanged(const QString& directory); public: + enum ViewType { GLOBAL_VIEW, PROJECT_VIEW, USER_VIEW }; //!< The three different viewtypes + static ViewType lastViewUsed; FileDialogButtonsWidget buttons; MFileDialog(const QString& dir, const QString& filter = QString::null, QWidget* parent = 0, bool writeFlag = false); @@ -78,7 +79,7 @@ QString getSaveFileName(const QString& startWidth, const QStringList& filters, QWidget* parent, const QString& name); //QString getOpenFileName(const QString& startWidth, const char** filter, QString getOpenFileName(const QString& startWidth, const QStringList& filters, - QWidget* parent, const QString& name, bool* openAll); + QWidget* parent, const QString& name, bool* openAll, MFileDialog::ViewType viewType = MFileDialog::PROJECT_VIEW); //QString getImageFileName(const QString& startWith, const char** filters, QString getImageFileName(const QString& startWith, const QStringList& filters, QWidget* parent, const QString& name); diff --git a/muse2/muse/widgets/projectcreate.ui b/muse2/muse/widgets/projectcreate.ui new file mode 100644 index 00000000..7cb73a82 --- /dev/null +++ b/muse2/muse/widgets/projectcreate.ui @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ProjectCreate</class> + <widget class="QDialog" name="ProjectCreate"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>569</width> + <height>340</height> + </rect> + </property> + <property name="windowTitle"> + <string>Create Project</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Project Name:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLineEdit" name="projectNameEdit"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>75</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Project Path to song file:</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="createFolderCheckbox"> + <property name="text"> + <string>Create project folder (always use for audio projects)</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="storageDirEdit"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="browseDirButton"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Song information:</string> + </property> + </widget> + </item> + <item> + <widget class="QPlainTextEdit" name="commentEdit"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>ProjectCreate</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/muse2/muse/widgets/projectcreateimpl.cpp b/muse2/muse/widgets/projectcreateimpl.cpp new file mode 100644 index 00000000..5e81cfe4 --- /dev/null +++ b/muse2/muse/widgets/projectcreateimpl.cpp @@ -0,0 +1,63 @@ +#include <stdio.h> +#include <qfiledialog.h> +#include <qdir.h> +#include "projectcreateimpl.h" +#include "gconfig.h" +#include "globals.h" +#include "app.h" + +ProjectCreateImpl::ProjectCreateImpl(QWidget *parent) : + QDialog(parent) +{ + setupUi(this); + + createFolderCheckbox->setChecked(config.projectStoreInFolder); + connect(browseDirButton,SIGNAL(clicked()), this, SLOT(selectDirectory())); + connect(projectNameEdit,SIGNAL(textChanged(QString)), this, SLOT(updateDirectoryPath())); + connect(createFolderCheckbox,SIGNAL(clicked()), this, SLOT(updateDirectoryPath())); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(ok())); +#if QT_VERSION >= 0x040700 + projectNameEdit->setPlaceholderText("<Project Name>"); + commentEdit->setPlaceholderText("<Add information about project here>"); +#endif + directoryPath = config.projectBaseFolder; + updateDirectoryPath(); + show(); +} + +void ProjectCreateImpl::selectDirectory() +{ + QFileDialog qfd; + qfd.selectFile(directoryPath); + qfd.setFileMode(QFileDialog::DirectoryOnly); + if (qfd.exec() == QDialog::Rejected) { + return; + } + directoryPath=qfd.selectedFiles().first(); + updateDirectoryPath(); +} + +void ProjectCreateImpl::updateDirectoryPath() +{ + if (createFolderCheckbox->isChecked()) { + storageDirEdit->setText(directoryPath + projectNameEdit->text() + "/" + projectNameEdit->text() + ".med"); + } else { + storageDirEdit->setText(directoryPath + projectNameEdit->text() + ".med"); + } +} + +QString ProjectCreateImpl::getProjectPath() +{ + return storageDirEdit->text(); +} +QString ProjectCreateImpl::getSongInfo() +{ + return commentEdit->toPlainText(); +} +void ProjectCreateImpl::ok() +{ + config.projectStoreInFolder = createFolderCheckbox->isChecked(); + config.projectBaseFolder = directoryPath; + muse->changeConfig(true); + emit accept(); +} diff --git a/muse2/muse/widgets/projectcreateimpl.h b/muse2/muse/widgets/projectcreateimpl.h new file mode 100644 index 00000000..77547c1a --- /dev/null +++ b/muse2/muse/widgets/projectcreateimpl.h @@ -0,0 +1,26 @@ +#ifndef PROJECTCREATEIMPL_H +#define PROJECTCREATEIMPL_H + +#include <QDialog> +#include "ui_projectcreate.h" + +class ProjectCreateImpl : public QDialog, Ui::ProjectCreate +{ +Q_OBJECT + + QString directoryPath; +public: + explicit ProjectCreateImpl(QWidget *parent = 0); + QString getProjectPath(); + QString getSongInfo(); + +signals: + +public slots: + void updateDirectoryPath(); + void selectDirectory(); + void ok(); + +}; + +#endif // PROJECTCREATEIMPL_H |