add option to set visibility of log and chart windows from menu and in preferences

This commit is contained in:
Axel Kohlmeyer
2023-08-07 14:33:48 -04:00
parent d7b5387712
commit 77808cd178
4 changed files with 79 additions and 5 deletions

View File

@ -143,7 +143,9 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
connect(ui->action_Help, &QAction::triggered, this, &LammpsGui::help);
connect(ui->actionLAMMPS_Manual, &QAction::triggered, this, &LammpsGui::manual);
connect(ui->actionPreferences, &QAction::triggered, this, &LammpsGui::preferences);
connect(ui->actionDefaults, &QAction::triggered, this, &LammpsGui::defaults);
connect(ui->actionView_Log_Window, &QAction::triggered, this, &LammpsGui::view_log);
connect(ui->actionView_Graph_Window, &QAction::triggered, this, &LammpsGui::view_chart);
connect(ui->textEdit->document(), &QTextDocument::modificationChanged, this,
&LammpsGui::modified);
@ -404,7 +406,7 @@ void LammpsGui::logupdate()
}
}
// extract chache thermo data
// extract cached thermo data
if (chartwindow) {
void *ptr = lammps.last_thermo("step", 0);
if (ptr) {
@ -567,7 +569,10 @@ void LammpsGui::run_buffer()
QObject::connect(shortcut, &QShortcut::activated, logwindow, &LogWindow::close);
shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Slash), logwindow);
QObject::connect(shortcut, &QShortcut::activated, this, &LammpsGui::stop_run);
logwindow->show();
if (settings.value("viewlog",true).toBool())
logwindow->show();
else
logwindow->hide();
// if configured, delete old log window before opening new one
if (settings.value("chartreplace", false).toBool()) delete chartwindow;
@ -580,7 +585,10 @@ void LammpsGui::run_buffer()
QObject::connect(shortcut, &QShortcut::activated, chartwindow, &ChartWindow::close);
shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Slash), chartwindow);
QObject::connect(shortcut, &QShortcut::activated, this, &LammpsGui::stop_run);
chartwindow->show();
if (settings.value("viewchart",true).toBool())
chartwindow->show();
else
chartwindow->hide();
logupdater = new QTimer(this);
connect(logupdater, &QTimer::timeout, this, &LammpsGui::logupdate);
@ -637,6 +645,34 @@ void LammpsGui::clear()
ui->textEdit->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
}
void LammpsGui::view_chart()
{
QSettings settings;
if (chartwindow) {
if (chartwindow->isVisible()) {
chartwindow->hide();
settings.setValue("viewchart", false);
} else {
chartwindow->show();
settings.setValue("viewchart", true);
}
}
}
void LammpsGui::view_log()
{
QSettings settings;
if (logwindow) {
if (logwindow->isVisible()) {
logwindow->hide();
settings.setValue("viewlog", false);
} else {
logwindow->show();
settings.setValue("viewlog", true);
}
}
}
void LammpsGui::about()
{
std::string version = "This is LAMMPS-GUI version " LAMMPS_GUI_VERSION;

View File

@ -71,6 +71,8 @@ private slots:
void run_buffer();
void stop_run();
void view_image();
void view_chart();
void view_log();
void about();
void help();
void manual();

View File

@ -27,7 +27,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>24</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -73,9 +73,17 @@
<addaction name="action_Help"/>
<addaction name="actionLAMMPS_Manual"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="title">
<string>&amp;View</string>
</property>
<addaction name="actionView_Log_Window"/>
<addaction name="actionView_Graph_Window"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menu_Run"/>
<addaction name="menu_View"/>
<addaction name="menuAbout"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
@ -346,6 +354,22 @@
<string>Reset to &amp;Defaults</string>
</property>
</action>
<action name="actionView_Log_Window">
<property name="icon">
<iconset theme="utilities-terminal"/>
</property>
<property name="text">
<string>&amp;Log Window</string>
</property>
</action>
<action name="actionView_Graph_Window">
<property name="icon">
<iconset theme="x-office-drawing"/>
</property>
<property name="text">
<string>&amp;Chart Window</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -117,6 +117,10 @@ void Preferences::accept()
if (box) settings->setValue("logreplace", box->isChecked());
box = tabWidget->findChild<QCheckBox *>("chartreplace");
if (box) settings->setValue("chartreplace", box->isChecked());
box = tabWidget->findChild<QCheckBox *>("viewlog");
if (box) settings->setValue("viewlog", box->isChecked());
box = tabWidget->findChild<QCheckBox *>("viewchart");
if (box) settings->setValue("viewchart", box->isChecked());
QDialog::accept();
}
@ -131,6 +135,12 @@ GeneralTab::GeneralTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *pa
auto *cite = new QCheckBox("Include citation details");
cite->setObjectName("cite");
cite->setCheckState(settings->value("cite", false).toBool() ? Qt::Checked : Qt::Unchecked);
auto *logv = new QCheckBox("Show log window by default");
logv->setObjectName("viewlog");
logv->setCheckState(settings->value("viewlog", true).toBool() ? Qt::Checked : Qt::Unchecked);
auto *pltv = new QCheckBox("Show chart window by default");
pltv->setObjectName("viewchart");
pltv->setCheckState(settings->value("viewchart", true).toBool() ? Qt::Checked : Qt::Unchecked);
auto *logr = new QCheckBox("Replace log window on new run");
logr->setObjectName("logreplace");
logr->setCheckState(settings->value("logreplace", false).toBool() ? Qt::Checked
@ -164,6 +174,8 @@ GeneralTab::GeneralTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *pa
#endif
layout->addWidget(echo);
layout->addWidget(cite);
layout->addWidget(logv);
layout->addWidget(pltv);
layout->addWidget(logr);
layout->addWidget(pltr);
#if !defined(__APPLE__)