mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 13:46:06 +00:00
Delete project with pop-up confirmation (#451)
This commit is contained in:
parent
0ae021f9a1
commit
756ebec512
@ -1493,6 +1493,11 @@ void CutterCore::saveProject(const QString &name)
|
||||
emit projectSaved(name);
|
||||
}
|
||||
|
||||
void CutterCore::deleteProject(const QString &name)
|
||||
{
|
||||
cmd("Pd " + name);
|
||||
}
|
||||
|
||||
bool CutterCore::isProjectNameValid(const QString &name)
|
||||
{
|
||||
// see is_valid_project_name() in libr/core/project.c
|
||||
|
@ -408,6 +408,7 @@ public:
|
||||
QStringList getProjectNames();
|
||||
void openProject(const QString &name);
|
||||
void saveProject(const QString &name);
|
||||
void deleteProject(const QString &name);
|
||||
|
||||
static bool isProjectNameValid(const QString &name);
|
||||
|
||||
|
@ -59,6 +59,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
setAcceptDrops(true);
|
||||
ui->recentsListWidget->addAction(ui->actionRemove_item);
|
||||
ui->recentsListWidget->addAction(ui->actionClear_all);
|
||||
ui->projectsListWidget->addAction(ui->actionRemove_project);
|
||||
ui->logoSvgWidget->load(Config()->getLogoFile());
|
||||
|
||||
fillRecentFilesList();
|
||||
@ -191,6 +192,35 @@ void NewFileDialog::on_actionClear_all_triggered()
|
||||
ui->newFileEdit->clear();
|
||||
}
|
||||
|
||||
void NewFileDialog::on_actionRemove_project_triggered()
|
||||
{
|
||||
CutterCore *core = Core();
|
||||
|
||||
QListWidgetItem *item = ui->projectsListWidget->currentItem();
|
||||
|
||||
if (item == nullptr)
|
||||
return;
|
||||
|
||||
QVariant data = item->data(Qt::UserRole);
|
||||
QString sitem = data.toString();
|
||||
|
||||
// Confirmation box
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText(tr("Delete the project \"%1\" from disk ?").arg(sitem));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
switch (ret) {
|
||||
case QMessageBox::Yes:
|
||||
core->deleteProject(sitem);
|
||||
ui->projectsListWidget->takeItem(ui->projectsListWidget->currentRow());
|
||||
break;
|
||||
case QMessageBox::No:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NewFileDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
// Accept drag & drop events only if they provide a URL
|
||||
|
@ -34,6 +34,7 @@ private slots:
|
||||
|
||||
void on_actionRemove_item_triggered();
|
||||
void on_actionClear_all_triggered();
|
||||
void on_actionRemove_project_triggered();
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
|
@ -457,6 +457,11 @@
|
||||
<string>Clear all</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove_project">
|
||||
<property name="text">
|
||||
<string>Delete project</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user