Skip to content

Commit

Permalink
💎 Alternate jam directory name format (#1118) (close #1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
pljones authored and elieserdejesus committed Jun 1, 2018
1 parent 92212dc commit cb25e05
Show file tree
Hide file tree
Showing 13 changed files with 336 additions and 37 deletions.
11 changes: 11 additions & 0 deletions src/Common/MainController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,17 @@ void MainController::storeMultiTrackRecordingPath(const QString &newPath)
}
}

void MainController::storeDirNameDateFormat(const QString &newDateFormat)
{
settings.setDirNameDateFormat(newDateFormat);
Qt::DateFormat dateFormat = settings.getMultiTrackRecordingSettings().getDirNameDateFormat();
if (settings.isSaveMultiTrackActivated()) {
for (auto jamRecorder : jamRecorders) {
jamRecorder->setDirNameDateFormat(dateFormat);
}
}
}

void MainController::storePrivateServerSettings(const QString &server, int serverPort, const QString &password)
{
settings.addPrivateServer(server, serverPort, password);
Expand Down
1 change: 1 addition & 0 deletions src/Common/MainController.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class MainController : public QObject
void storeMultiTrackRecordingStatus(bool savingMultiTracks);
bool isMultiTrackRecordingActivated() const;
void storeMultiTrackRecordingPath(const QString &newPath);
void storeDirNameDateFormat(const QString &newDateFormat);

void storeJamRecorderStatus(const QString &writerId, bool status);

Expand Down
7 changes: 7 additions & 0 deletions src/Common/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,8 @@ void MainWindow::setupPreferencesDialogSignals(PreferencesDialog *dialog)

connect(dialog, &PreferencesDialog::recordingPathSelected, this, &MainWindow::setRecordingPath);

connect(dialog, &PreferencesDialog::jamDateFormatChanged, this, &MainWindow::setJamDirectoryDateFormat);

connect(dialog, &PreferencesDialog::builtInMetronomeSelected, this, &MainWindow::setBuiltInMetronome);

connect(dialog, &PreferencesDialog::customMetronomeSelected, this, &MainWindow::setCustomMetronome);
Expand Down Expand Up @@ -2453,6 +2455,11 @@ void MainWindow::setRecordingPath(const QString &newRecordingPath)
mainController->storeMultiTrackRecordingPath(newRecordingPath);
}

void MainWindow::setJamDirectoryDateFormat(const QString &newDateFormat)
{
mainController->storeDirNameDateFormat(newDateFormat);
}

void MainWindow::initializeViewMenu()
{
connect(ui.menuMetering, &QMenu::aboutToShow, this, &MainWindow::updateMeteringMenu);
Expand Down
1 change: 1 addition & 0 deletions src/Common/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ private slots:
void setMultiTrackRecordingStatus(bool recording);
void setJamRecorderStatus(const QString &writerId, bool status);
void setRecordingPath(const QString &newRecordingPath);
void setJamDirectoryDateFormat(const QString &newDateFormat);
void setBuiltInMetronome(const QString &metronomeAlias);
void setCustomMetronome(const QString &primaryBeatFile, const QString &offBeatFile, const QString &accentBeatFile);

Expand Down
37 changes: 36 additions & 1 deletion src/Common/gui/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QtWidgets>
#include <QDebug>
#include <QFileDialog>
#include <QDateTime>
#include "persistence/Settings.h"
#include "MetronomeUtils.h"
#include "audio/vorbis/Vorbis.h"
Expand Down Expand Up @@ -74,6 +75,7 @@ void PreferencesDialog::initialize(PreferencesTab initialTab, const persistence:
this->settings = settings;
this->jamRecorders = jamRecorders;
this->jamRecorderCheckBoxes = QMap<QCheckBox *, QString>();
this->jamDateFormatRadioButtons = QMap<const QRadioButton *, QString>();

for (const auto &jamRecorder : jamRecorders.keys()) {
QCheckBox *myCheckBox = new QCheckBox(this);
Expand All @@ -83,6 +85,29 @@ void PreferencesDialog::initialize(PreferencesTab initialTab, const persistence:
jamRecorderCheckBoxes[myCheckBox] = jamRecorder;
}

QDateTime now = QDateTime::currentDateTime();
Qt::DateFormat dateFormat;
QString nowString;
QRadioButton *myRadioButton;

dateFormat = Qt::TextDate;
nowString = "Jam-" + now.toString(dateFormat).replace(QRegExp("[/:]"), "-").replace(QRegExp("[ ]"), "_");
myRadioButton = new QRadioButton(this);
myRadioButton->setObjectName("rbdfTextDate");
myRadioButton->setText(nowString);
myRadioButton->setProperty("buttonGroup", "rbDateFormat");
ui->layoutDateFormats->addWidget(myRadioButton);
jamDateFormatRadioButtons[myRadioButton] = "Qt::TextDate";

dateFormat = Qt::ISODate;
nowString = "Jam-" + now.toString(dateFormat).replace(QRegExp("[/:]"), "-").replace(QRegExp("[ ]"), "_");
myRadioButton = new QRadioButton(this);
myRadioButton->setObjectName("rbdfISODate");
myRadioButton->setText(nowString);
myRadioButton->setProperty("buttonGroup", "rbDateFormat");
ui->layoutDateFormats->addWidget(myRadioButton);
jamDateFormatRadioButtons[myRadioButton] = "Qt::ISODate";

setupSignals();

populateAllTabs();
Expand All @@ -95,8 +120,14 @@ void PreferencesDialog::setupSignals()
connect(ui->prefsTab, SIGNAL(currentChanged(int)), this, SLOT(selectTab(int)));

connect(ui->recordingCheckBox, SIGNAL(clicked(bool)), this, SLOT(toggleRecording(bool)));

connect(ui->browseRecPathButton, SIGNAL(clicked(bool)), this, SLOT(openRecordingPathBrowser()));
for(const QRadioButton *rb : jamDateFormatRadioButtons.keys()) {
connect(rb, &QRadioButton::toggled, [=]() {
if (rb->isChecked()) {
emit jamDateFormatChanged(jamDateFormatRadioButtons[rb]);
}
});
}

connect(ui->groupBoxCustomMetronome, SIGNAL(toggled(bool)), this, SLOT(toggleCustomMetronomeSounds(bool)));
connect(ui->groupBoxBuiltInMetronomes, SIGNAL(toggled(bool)), this, SLOT(toggleBuiltInMetronomeSounds(bool)));
Expand Down Expand Up @@ -290,6 +321,10 @@ void PreferencesDialog::populateMultiTrackRecordingTab()
myCheckBox->setChecked(recordingSettings.isJamRecorderActivated(jamRecorderCheckBoxes[myCheckBox]));
}

for (const QRadioButton * myRadioButton : jamDateFormatRadioButtons.keys()) {
((QRadioButton *)myRadioButton)->setChecked(QString::compare(recordingSettings.dirNameDateFormat, jamDateFormatRadioButtons[myRadioButton]) == 0);
}

QDir recordDir(recordingSettings.recordingPath);
ui->recordPathLineEdit->setText(recordDir.absolutePath());
}
Expand Down
3 changes: 3 additions & 0 deletions src/Common/gui/PreferencesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QDialog>
#include <QCheckBox>
#include <QRadioButton>
#include "persistence/Settings.h"
#include "recorder/JamRecorder.h"

Expand Down Expand Up @@ -38,6 +39,7 @@ class PreferencesDialog : public QDialog
void multiTrackRecordingStatusChanged(bool recording);
void jamRecorderStatusChanged(const QString &writerId, bool status);
void recordingPathSelected(const QString &newRecordingPath);
void jamDateFormatChanged(QString dateFormat);
void encodingQualityChanged(float newEncodingQuality);
void looperAudioEncodingFlagChanged(bool savingEncodedAudio);
void looperWaveFilesBitDepthChanged(quint8 bitDepth);
Expand Down Expand Up @@ -71,6 +73,7 @@ private slots:
void refreshMetronomeControlsStyleSheet();
QString openAudioFileBrowser(const QString caption);
QMap<QCheckBox *, QString> jamRecorderCheckBoxes;
QMap<const QRadioButton *, QString> jamDateFormatRadioButtons;
static QString getAudioFilesFilter();

protected:
Expand Down
62 changes: 38 additions & 24 deletions src/Common/gui/PreferencesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="prefsTab">
<property name="currentIndex">
<number>4</number>
<number>3</number>
</property>
<widget class="QWidget" name="tabAudio">
<attribute name="title">
Expand Down Expand Up @@ -461,7 +461,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<width>467</width>
<height>45</height>
</rect>
</property>
Expand Down Expand Up @@ -510,6 +510,27 @@
<property name="verticalSpacing">
<number>18</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="recordingCheckBox">
<property name="text">
<string>Save multi tracks </string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<layout class="QVBoxLayout" name="layoutRecorders">
<property name="leftMargin">
<number>26</number>
</property>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Record path:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="recordPathLineEdit">
<property name="enabled">
Expand All @@ -524,7 +545,21 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="4" column="0">
<widget class="QLabel" name="lblJamDirectoryName">
<property name="text">
<string>Directory name format:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<layout class="QVBoxLayout" name="layoutDateFormats">
<property name="leftMargin">
<number>26</number>
</property>
</layout>
</item>
<item row="6" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -537,27 +572,6 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="recordingCheckBox">
<property name="text">
<string>Save multi tracks </string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Record path:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<layout class="QVBoxLayout" name="layoutRecorders">
<property name="leftMargin">
<number>26</number>
</property>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabMetronome">
Expand Down
1 change: 1 addition & 0 deletions src/Common/log/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Q_DECLARE_LOGGING_CATEGORY(jtMidi)
// Q_DECLARE_LOGGING_CATEGORY(jtJoystick) ToDOooo
Q_DECLARE_LOGGING_CATEGORY(jtConfigurator)
Q_DECLARE_LOGGING_CATEGORY(jtMetronome)
Q_DECLARE_LOGGING_CATEGORY(jtSettings)

void jamtabaLogHandler(QtMsgType, const QMessageLogContext &, const QString &);

Expand Down
1 change: 1 addition & 0 deletions src/Common/log/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Q_LOGGING_CATEGORY(jtAudio, "jt.Audio")
Q_LOGGING_CATEGORY(jtMidi, "jt.Midi")
Q_LOGGING_CATEGORY(jtConfigurator, "jt.Configurator")
Q_LOGGING_CATEGORY(jtMetronome, "jt.Metronome")
Q_LOGGING_CATEGORY(jtSettings, "jt.Settings")
Loading

0 comments on commit cb25e05

Please sign in to comment.