save prompt
parent
10bcacf8c1
commit
bac05e3f68
17
notes
17
notes
|
@ -34,19 +34,14 @@ TODO {
|
|||
immediate frontburner {
|
||||
look into performance/timing/sync of audio engine; it's having buffer issues way more than it feels like it should
|
||||
|
||||
- recent files list and backend {
|
||||
settings manager to handle loading+saving
|
||||
separate files for "settings" and "state"
|
||||
probably an "update all relevant windows" thing for recents
|
||||
- prompt save on... {
|
||||
- new project
|
||||
- open project (any)
|
||||
- close
|
||||
}
|
||||
|
||||
prompt save on... {
|
||||
new project
|
||||
open project (any)
|
||||
close
|
||||
}
|
||||
|
||||
add i/o nodes to default project
|
||||
- add i/o nodes to default project
|
||||
add more
|
||||
|
||||
distortion effect
|
||||
|
||||
|
|
|
@ -509,7 +509,11 @@ MainWindow::~MainWindow() {
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent*) {
|
||||
void MainWindow::closeEvent(QCloseEvent* e) {
|
||||
if (promptSave()) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
undoStack->clear();
|
||||
setAttribute(Qt::WA_DeleteOnClose); // delete when done
|
||||
}
|
||||
|
@ -529,20 +533,6 @@ bool MainWindow::eventFilter(QObject *obj [[maybe_unused]], QEvent *event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::menuFileNew() {
|
||||
auto hold = project; // keep alive until done
|
||||
if (audioEngine->playingProject() == project) audioEngine->stop();
|
||||
project = FileOps::newProject();
|
||||
|
||||
onNewProjectLoaded();
|
||||
}
|
||||
|
||||
void MainWindow::menuFileOpen() {
|
||||
if (auto fileName = FileOps::showOpenDialog(this, "Open project...", Config::Directories::projects, FileOps::Filter::project); !fileName.isEmpty()) {
|
||||
openProject(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::openProject(const QString& fileName) {
|
||||
auto np = FileOps::loadProject(fileName);
|
||||
if (!np) {
|
||||
|
@ -556,6 +546,7 @@ void MainWindow::openProject(const QString& fileName) {
|
|||
}
|
||||
|
||||
void MainWindow::openRecentProject(size_t idx) {
|
||||
if (promptSave()) return;
|
||||
if (idx > UIState::recentFiles.size()) return;
|
||||
auto it = UIState::recentFiles.begin();
|
||||
for (size_t i = 0; i < idx; i++) it++;
|
||||
|
@ -563,6 +554,37 @@ void MainWindow::openRecentProject(size_t idx) {
|
|||
openProject(QString(*it)); // need to copy string before opening
|
||||
}
|
||||
|
||||
bool MainWindow::promptSave() {
|
||||
if (!undoStack->isClean()) {
|
||||
auto ftxt = project->fileName.isEmpty() ? qs("new file") : qs("file \"%1\"").arg(project->fileName);
|
||||
auto r = QMessageBox::warning(this, qs("Save file?"), qs("Save changes to %1?").arg(ftxt),
|
||||
static_cast<QMessageBox::StandardButtons>(QMessageBox::Yes + QMessageBox::No + QMessageBox::Cancel));
|
||||
|
||||
if (r == QMessageBox::Cancel || r == QMessageBox::Escape) return true; // signal abort
|
||||
if (r == QMessageBox::Yes) {
|
||||
menuFileSave();
|
||||
if (project->fileName.isEmpty()) return true; // save-as-new canceled
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::menuFileNew() {
|
||||
if (promptSave()) return;
|
||||
auto hold = project; // keep alive until done
|
||||
if (audioEngine->playingProject() == project) audioEngine->stop();
|
||||
project = FileOps::newProject();
|
||||
|
||||
onNewProjectLoaded();
|
||||
}
|
||||
|
||||
void MainWindow::menuFileOpen() {
|
||||
if (promptSave()) return;
|
||||
if (auto fileName = FileOps::showOpenDialog(this, "Open project...", Config::Directories::projects, FileOps::Filter::project); !fileName.isEmpty()) {
|
||||
openProject(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::menuFileSave() {
|
||||
if (project->fileName.isEmpty()) menuFileSaveAs();
|
||||
else {
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace Xybrid {
|
|||
|
||||
void openProject(const QString& fileName);
|
||||
void openRecentProject(size_t idx);
|
||||
bool promptSave();
|
||||
|
||||
void onNewProjectLoaded();
|
||||
void updatePatternLists();
|
||||
bool selectPatternForEditing(Data::Pattern*);
|
||||
|
|
Loading…
Reference in New Issue