void MuseScore::deleteWorkspace() { if (!workspaces) return; QAction* a = workspaces->checkedAction(); if (!a) return; preferences.dirty = true; Workspace* workspace = 0; for (Workspace* p : Workspace::workspaces()) { if (p->name() == a->text()) { // no need for qApp->translate since "Basic" and "Advanced" are not deletable workspace = p; break; } } if (!workspace) return; QMessageBox::StandardButton reply; reply = QMessageBox::question(0, QWidget::tr("Are you sure?"), QWidget::tr("Do you really want to delete the '%1' workspace?").arg(workspace->name()), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ); if (reply != QMessageBox::Yes) return; Workspace::workspaces().removeOne(workspace); QFile f(workspace->path()); f.remove(); delete workspace; PaletteBox* paletteBox = mscore->getPaletteBox(); paletteBox->clear(); Workspace::currentWorkspace = Workspace::workspaces().first(); preferences.workspace = Workspace::currentWorkspace->name(); changeWorkspace(Workspace::currentWorkspace); paletteBox = mscore->getPaletteBox(); paletteBox->updateWorkspaces(); }
void MuseScore::deleteWorkspace() { if (!workspaces) return; QAction* a = workspaces->checkedAction(); if (!a) return; Workspace* workspace = 0; for (Workspace* p : Workspace::workspaces()) { if (p->name() == a->text()) { workspace = p; break; } } if (!workspace) return; QMessageBox::StandardButton reply; reply = QMessageBox::question(0, QWidget::tr("Are you sure?"), QWidget::tr("Do you really want to delete the '%1' workspace?").arg(workspace->name()), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ); if (reply != QMessageBox::Yes) return; Workspace::workspaces().removeOne(workspace); QFile f(workspace->path()); f.remove(); delete workspace; PaletteBox* pb = mscore->getPaletteBox(); pb->clear(); Workspace::currentWorkspace = Workspace::workspaces().first(); preferences.setPreference(PREF_APP_WORKSPACE, Workspace::currentWorkspace->name()); changeWorkspace(Workspace::currentWorkspace); pb = mscore->getPaletteBox(); pb->updateWorkspaces(); updateIcons(); }