Show current working directory and share space with progress bar. Show/hide the other.
This commit is contained in:
@ -3,7 +3,6 @@ LAMMPS-GUI TODO list:
|
|||||||
# Short term goals
|
# Short term goals
|
||||||
|
|
||||||
- add "Help" entry to menu bar. Should open a popup window with a one page description of how to use it. Use HTML or Markdown text.
|
- add "Help" entry to menu bar. Should open a popup window with a one page description of how to use it. Use HTML or Markdown text.
|
||||||
- display current working directory
|
|
||||||
- add CTRL-q hotkey to log windows so you can exit the entire application (add do you really want to? dialog to this)
|
- add CTRL-q hotkey to log windows so you can exit the entire application (add do you really want to? dialog to this)
|
||||||
- add "syntax check" with enabled "-skiprun" flag
|
- add "syntax check" with enabled "-skiprun" flag
|
||||||
- add settings dialog where certain properties can be set through customizing the LAMMPS command line
|
- add settings dialog where certain properties can be set through customizing the LAMMPS command line
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include "stdcapture.h"
|
#include "stdcapture.h"
|
||||||
#include "ui_lammpsgui.h"
|
#include "ui_lammpsgui.h"
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
@ -31,7 +32,6 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -65,8 +65,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), logupdater(nullptr),
|
status(nullptr), logwindow(nullptr), imagewindow(nullptr), logupdater(nullptr),
|
||||||
progress(nullptr), prefdialog(nullptr), lammps_handle(nullptr), plugin_handle(nullptr),
|
dirstatus(nullptr), progress(nullptr), prefdialog(nullptr), lammps_handle(nullptr),
|
||||||
plugin_path(nullptr), is_running(false)
|
plugin_handle(nullptr), plugin_path(nullptr), is_running(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setCentralWidget(ui->textEdit);
|
this->setCentralWidget(ui->textEdit);
|
||||||
@ -74,6 +74,7 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
|
|||||||
prefdialog = new Preferences(this);
|
prefdialog = new Preferences(this);
|
||||||
capturer = new StdCapture;
|
capturer = new StdCapture;
|
||||||
current_file.clear();
|
current_file.clear();
|
||||||
|
current_dir = QDir(".").absolutePath();
|
||||||
recent_files.clear();
|
recent_files.clear();
|
||||||
|
|
||||||
#if defined(_OPENMP)
|
#if defined(_OPENMP)
|
||||||
@ -142,6 +143,19 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
|
|||||||
ui->actionPaste->setEnabled(false);
|
ui->actionPaste->setEnabled(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
status = new QLabel("Ready.");
|
||||||
|
status->setFixedWidth(250);
|
||||||
|
ui->statusbar->addWidget(status);
|
||||||
|
dirstatus = new QLabel(QString(" Directory: ") + current_dir);
|
||||||
|
dirstatus->setMinimumWidth(500);
|
||||||
|
ui->statusbar->addWidget(dirstatus);
|
||||||
|
progress = new QProgressBar();
|
||||||
|
progress->setRange(0, 1000);
|
||||||
|
progress->setMinimumWidth(500);
|
||||||
|
progress->hide();
|
||||||
|
dirstatus->show();
|
||||||
|
ui->statusbar->addWidget(progress);
|
||||||
|
|
||||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||||
liblammpsplugin_t *lammps = nullptr;
|
liblammpsplugin_t *lammps = nullptr;
|
||||||
for (const auto libfile : {"liblammps.so", "./liblammps.so", "liblammps.dylib",
|
for (const auto libfile : {"liblammps.so", "./liblammps.so", "liblammps.dylib",
|
||||||
@ -161,17 +175,12 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
|
|||||||
if (do_exit) exit(1);
|
if (do_exit) exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (filename)
|
if (filename) {
|
||||||
open_file(filename);
|
open_file(filename);
|
||||||
else
|
} else {
|
||||||
setWindowTitle(QString("LAMMPS-GUI - *unknown*"));
|
setWindowTitle(QString("LAMMPS-GUI - *unknown*"));
|
||||||
status = new QLabel("Ready.");
|
}
|
||||||
status->setFixedWidth(300);
|
|
||||||
ui->statusbar->addWidget(status);
|
|
||||||
progress = new QProgressBar();
|
|
||||||
progress->setRange(0, 1000);
|
|
||||||
progress->setFixedWidth(500);
|
|
||||||
ui->statusbar->addWidget(progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LammpsGui::~LammpsGui()
|
LammpsGui::~LammpsGui()
|
||||||
@ -182,6 +191,7 @@ LammpsGui::~LammpsGui()
|
|||||||
delete status;
|
delete status;
|
||||||
delete logwindow;
|
delete logwindow;
|
||||||
delete imagewindow;
|
delete imagewindow;
|
||||||
|
delete dirstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LammpsGui::new_document()
|
void LammpsGui::new_document()
|
||||||
@ -249,6 +259,7 @@ void LammpsGui::open_file(const QString &fileName)
|
|||||||
ui->textEdit->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
ui->textEdit->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||||
ui->textEdit->document()->setModified(false);
|
ui->textEdit->document()->setModified(false);
|
||||||
file.close();
|
file.close();
|
||||||
|
dirstatus->setText(QString(" Directory: ") + current_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LammpsGui::write_file(const QString &fileName)
|
void LammpsGui::write_file(const QString &fileName)
|
||||||
@ -256,6 +267,8 @@ void LammpsGui::write_file(const QString &fileName)
|
|||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
QFileInfo path(file);
|
QFileInfo path(file);
|
||||||
current_file = path.fileName();
|
current_file = path.fileName();
|
||||||
|
current_dir = path.absolutePath();
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QFile::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QFile::Text)) {
|
||||||
QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
|
QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
|
||||||
return;
|
return;
|
||||||
@ -265,6 +278,7 @@ void LammpsGui::write_file(const QString &fileName)
|
|||||||
QString text = ui->textEdit->toPlainText();
|
QString text = ui->textEdit->toPlainText();
|
||||||
out << text;
|
out << text;
|
||||||
file.close();
|
file.close();
|
||||||
|
dirstatus->setText(QString(" Directory: ") + current_dir);
|
||||||
ui->textEdit->document()->setModified(false);
|
ui->textEdit->document()->setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,10 +460,15 @@ void LammpsGui::run_done()
|
|||||||
QString("Error running LAMMPS:\n\n") + errorbuf);
|
QString("Error running LAMMPS:\n\n") + errorbuf);
|
||||||
}
|
}
|
||||||
is_running = false;
|
is_running = false;
|
||||||
|
progress->hide();
|
||||||
|
dirstatus->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LammpsGui::run_buffer()
|
void LammpsGui::run_buffer()
|
||||||
{
|
{
|
||||||
|
progress->setValue(0);
|
||||||
|
dirstatus->hide();
|
||||||
|
progress->show();
|
||||||
status->setText("Running LAMMPS. Please wait...");
|
status->setText("Running LAMMPS. Please wait...");
|
||||||
status->repaint();
|
status->repaint();
|
||||||
start_lammps();
|
start_lammps();
|
||||||
|
|||||||
@ -81,6 +81,7 @@ private:
|
|||||||
QPlainTextEdit *logwindow;
|
QPlainTextEdit *logwindow;
|
||||||
ImageViewer *imagewindow;
|
ImageViewer *imagewindow;
|
||||||
QTimer *logupdater;
|
QTimer *logupdater;
|
||||||
|
QLabel *dirstatus;
|
||||||
QProgressBar *progress;
|
QProgressBar *progress;
|
||||||
Preferences *prefdialog;
|
Preferences *prefdialog;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user