implement delete-all-images function with pushbutton in slideshow viewer

This commit is contained in:
Axel Kohlmeyer
2024-07-16 22:54:38 -04:00
parent dc84078156
commit 1b9302299a
5 changed files with 17 additions and 2 deletions

View File

@ -2,7 +2,6 @@ LAMMPS-GUI TODO list:
# Short term goals (v1.x) # Short term goals (v1.x)
- add "delete image files" option to Slide Show, plus pushbutton
- add "export YAML data" to Output viewer, if YAML thermo data is detected. - add "export YAML data" to Output viewer, if YAML thermo data is detected.
- add "export to YAML" to chart viewer. - add "export to YAML" to chart viewer.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -53,6 +53,7 @@
<file>icons/system-box.png</file> <file>icons/system-box.png</file>
<file>icons/system-help.png</file> <file>icons/system-help.png</file>
<file>icons/system-run.png</file> <file>icons/system-run.png</file>
<file>icons/trash.png</file>
<file>icons/utilities-terminal.png</file> <file>icons/utilities-terminal.png</file>
<file>icons/vdw-style.png</file> <file>icons/vdw-style.png</file>
<file>icons/vmd.png</file> <file>icons/vmd.png</file>

View File

@ -19,6 +19,7 @@
#include <QApplication> #include <QApplication>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QDir> #include <QDir>
#include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QGuiApplication> #include <QGuiApplication>
@ -75,6 +76,9 @@ SlideShow::SlideShow(const QString &fileName, QWidget *parent) :
tomovie->setToolTip("Export to movie file"); tomovie->setToolTip("Export to movie file");
tomovie->setEnabled(has_exe("ffmpeg")); tomovie->setEnabled(has_exe("ffmpeg"));
auto *totrash = new QPushButton(QIcon(":/icons/trash.png"), "");
totrash->setToolTip("Delete all image files");
auto *gofirst = new QPushButton(QIcon(":/icons/go-first.png"), ""); auto *gofirst = new QPushButton(QIcon(":/icons/go-first.png"), "");
gofirst->setToolTip("Go to first Image"); gofirst->setToolTip("Go to first Image");
auto *goprev = new QPushButton(QIcon(":/icons/go-previous-2.png"), ""); auto *goprev = new QPushButton(QIcon(":/icons/go-previous-2.png"), "");
@ -101,6 +105,7 @@ SlideShow::SlideShow(const QString &fileName, QWidget *parent) :
normal->setToolTip("Reset zoom to normal"); normal->setToolTip("Reset zoom to normal");
connect(tomovie, &QPushButton::released, this, &SlideShow::movie); connect(tomovie, &QPushButton::released, this, &SlideShow::movie);
connect(totrash, &QPushButton::released, this, &SlideShow::delete_images);
connect(gofirst, &QPushButton::released, this, &SlideShow::first); connect(gofirst, &QPushButton::released, this, &SlideShow::first);
connect(goprev, &QPushButton::released, this, &SlideShow::prev); connect(goprev, &QPushButton::released, this, &SlideShow::prev);
connect(goplay, &QPushButton::released, this, &SlideShow::play); connect(goplay, &QPushButton::released, this, &SlideShow::play);
@ -115,6 +120,7 @@ SlideShow::SlideShow(const QString &fileName, QWidget *parent) :
navLayout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum)); navLayout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum));
navLayout->addWidget(dummy); navLayout->addWidget(dummy);
navLayout->addWidget(tomovie); navLayout->addWidget(tomovie);
navLayout->addWidget(totrash);
navLayout->addWidget(gofirst); navLayout->addWidget(gofirst);
navLayout->addWidget(goprev); navLayout->addWidget(goprev);
navLayout->addWidget(goplay); navLayout->addWidget(goplay);
@ -157,6 +163,14 @@ void SlideShow::add_image(const QString &filename)
} }
} }
void SlideShow::delete_images()
{
for (const auto &file : imagefiles) {
QFile::remove(file);
}
clear();
}
void SlideShow::clear() void SlideShow::clear()
{ {
imagefiles.clear(); imagefiles.clear();
@ -316,7 +330,7 @@ void SlideShow::prev()
void SlideShow::loop() void SlideShow::loop()
{ {
auto *button = qobject_cast<QPushButton *>(sender()); auto *button = qobject_cast<QPushButton *>(sender());
do_loop = !do_loop; do_loop = !do_loop;
button->setChecked(do_loop); button->setChecked(do_loop);
} }

View File

@ -33,6 +33,7 @@ public:
private slots: private slots:
void quit(); void quit();
void delete_images();
void stop_run(); void stop_run();
void movie(); void movie();
void first(); void first();