add a small LAMMPS icon to the status bar indicating whether an active LAMMPS instance exists

This commit is contained in:
Axel Kohlmeyer
2023-08-13 02:57:47 -04:00
parent 9f407cae1e
commit 7e3c04aa51
2 changed files with 13 additions and 1 deletions

View File

@ -63,7 +63,8 @@ static char *mystrdup(const std::string &text)
LammpsGui::LammpsGui(QWidget *parent, const char *filename) : LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
QMainWindow(parent), ui(new Ui::LammpsGui), highlighter(nullptr), capturer(nullptr), QMainWindow(parent), ui(new Ui::LammpsGui), highlighter(nullptr), capturer(nullptr),
status(nullptr), logwindow(nullptr), imagewindow(nullptr), chartwindow(nullptr), status(nullptr), logwindow(nullptr), imagewindow(nullptr), chartwindow(nullptr),
logupdater(nullptr), dirstatus(nullptr), progress(nullptr), prefdialog(nullptr) logupdater(nullptr), dirstatus(nullptr), progress(nullptr), prefdialog(nullptr),
lammpsstatus(nullptr)
{ {
// enforce using the plain ASCII C locale within the GUI. // enforce using the plain ASCII C locale within the GUI.
QLocale::setDefault(QLocale("C")); QLocale::setDefault(QLocale("C"));
@ -176,6 +177,11 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
ui->actionPaste->setEnabled(false); ui->actionPaste->setEnabled(false);
#endif #endif
lammpsstatus = new QLabel(QString());
auto pix = QPixmap(":/lammps-icon-128x128.png");
lammpsstatus->setPixmap(pix.scaled(22,22,Qt::KeepAspectRatio));
ui->statusbar->addWidget(lammpsstatus);
lammpsstatus->hide();
status = new QLabel("Ready."); status = new QLabel("Ready.");
status->setFixedWidth(300); status->setFixedWidth(300);
ui->statusbar->addWidget(status); ui->statusbar->addWidget(status);
@ -236,6 +242,7 @@ void LammpsGui::new_document()
ui->textEdit->document()->setPlainText(QString()); ui->textEdit->document()->setPlainText(QString());
lammps.close(); lammps.close();
lammpsstatus->hide();
setWindowTitle(QString("LAMMPS-GUI - *unknown*")); setWindowTitle(QString("LAMMPS-GUI - *unknown*"));
} }
@ -453,6 +460,7 @@ void LammpsGui::save_as()
void LammpsGui::quit() void LammpsGui::quit()
{ {
lammps.close(); lammps.close();
lammpsstatus->hide();
lammps.finalize(); lammps.finalize();
if (ui->textEdit->document()->isModified()) { if (ui->textEdit->document()->isModified()) {
@ -901,6 +909,7 @@ void LammpsGui::edit_variables()
if (vars.exec() == QDialog::Accepted) { if (vars.exec() == QDialog::Accepted) {
variables = newvars; variables = newvars;
lammps.close(); lammps.close();
lammpsstatus->hide();
} }
} }
@ -922,6 +931,7 @@ void LammpsGui::preferences()
(oldecho != settings.value("echo", 0).toInt()) || (oldecho != settings.value("echo", 0).toInt()) ||
(oldcite != settings.value("cite", 0).toInt())) (oldcite != settings.value("cite", 0).toInt()))
lammps.close(); lammps.close();
lammpsstatus->hide();
if (imagewindow) imagewindow->createImage(); if (imagewindow) imagewindow->createImage();
} }
} }
@ -986,6 +996,7 @@ void LammpsGui::start_lammps()
char **args = lammps_args.data(); char **args = lammps_args.data();
int narg = lammps_args.size(); int narg = lammps_args.size();
lammps.open(narg, args); lammps.open(narg, args);
lammpsstatus->show();
// delete additional arguments again (3 were there initially // delete additional arguments again (3 were there initially
while (lammps_args.size() > initial_narg) { while (lammps_args.size() > initial_narg) {

View File

@ -104,6 +104,7 @@ private:
QLabel *dirstatus; QLabel *dirstatus;
QProgressBar *progress; QProgressBar *progress;
Preferences *prefdialog; Preferences *prefdialog;
QLabel *lammpsstatus;
QString current_file; QString current_file;
QString current_dir; QString current_dir;