add button to stop a run via lammps_force_timeout()
This commit is contained in:
@ -67,6 +67,7 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
|
||||
connect(ui->actionUndo, &QAction::triggered, this, &LammpsGui::undo);
|
||||
connect(ui->actionRedo, &QAction::triggered, this, &LammpsGui::redo);
|
||||
connect(ui->actionRun_Buffer, &QAction::triggered, this, &LammpsGui::run_buffer);
|
||||
connect(ui->actionStop_LAMMPS, &QAction::triggered, this, &LammpsGui::stop_run);
|
||||
connect(ui->actionAbout_LAMMPS_GUI, &QAction::triggered, this, &LammpsGui::about);
|
||||
|
||||
#if !QT_CONFIG(clipboard)
|
||||
@ -237,12 +238,20 @@ void LammpsGui::redo()
|
||||
ui->textEdit->redo();
|
||||
}
|
||||
|
||||
void LammpsGui::stop_run()
|
||||
{
|
||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||
((liblammpsplugin_t *)plugin_handle)->force_timeout(lammps_handle);
|
||||
#else
|
||||
lammps_force_timeout(lammps_handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
void LammpsGui::logupdate()
|
||||
{
|
||||
double t_elapsed, t_remain, t_total;
|
||||
int completed = 1000;
|
||||
|
||||
if (is_running) {
|
||||
#if defined(LAMMPS_GUI_USE_PLUGIN)
|
||||
liblammpsplugin_t *lammps = (liblammpsplugin_t *)plugin_handle;
|
||||
if (lammps->is_running(lammps_handle)) {
|
||||
@ -259,7 +268,7 @@ void LammpsGui::logupdate()
|
||||
completed = t_elapsed / t_total * 1000.0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
progress->setValue(completed);
|
||||
if (logwindow) {
|
||||
const auto text = capturer->GetChunk();
|
||||
@ -345,6 +354,8 @@ void LammpsGui::run_buffer()
|
||||
logwindow->setMinimumSize(800, 600);
|
||||
QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), logwindow);
|
||||
QObject::connect(shortcut, &QShortcut::activated, logwindow, &QPlainTextEdit::close);
|
||||
shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Slash), logwindow);
|
||||
QObject::connect(shortcut, &QShortcut::activated, this, &LammpsGui::stop_run);
|
||||
logwindow->show();
|
||||
|
||||
logupdater = new QTimer(this);
|
||||
|
||||
@ -59,6 +59,7 @@ private slots:
|
||||
void redo();
|
||||
void clear();
|
||||
void run_buffer();
|
||||
void stop_run();
|
||||
void about();
|
||||
void logupdate();
|
||||
|
||||
|
||||
@ -68,15 +68,23 @@
|
||||
<addaction name="actionCut"/>
|
||||
<addaction name="actionPaste"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Run">
|
||||
<property name="title">
|
||||
<string>&Run</string>
|
||||
</property>
|
||||
<addaction name="actionRun_Buffer"/>
|
||||
<addaction name="actionStop_LAMMPS"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="actionRun_Buffer"/>
|
||||
<addaction name="menu_Run"/>
|
||||
<addaction name="actionAbout_LAMMPS_GUI"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset theme="document-new"/>
|
||||
<iconset theme="document-new">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&New</string>
|
||||
@ -93,7 +101,8 @@
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open"/>
|
||||
<iconset theme="document-open">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
@ -110,7 +119,8 @@
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save"/>
|
||||
<iconset theme="document-save">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Save</string>
|
||||
@ -127,7 +137,8 @@
|
||||
</action>
|
||||
<action name="actionSave_As">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save-as"/>
|
||||
<iconset theme="document-save-as">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save &As</string>
|
||||
@ -144,7 +155,8 @@
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="application-exit"/>
|
||||
<iconset theme="application-exit">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
@ -161,7 +173,8 @@
|
||||
</action>
|
||||
<action name="actionCut">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-cut"/>
|
||||
<iconset theme="edit-cut">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>C&ut</string>
|
||||
@ -175,7 +188,8 @@
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-copy"/>
|
||||
<iconset theme="edit-copy">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Copy</string>
|
||||
@ -189,7 +203,8 @@
|
||||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-paste"/>
|
||||
<iconset theme="edit-paste">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Paste</string>
|
||||
@ -203,7 +218,8 @@
|
||||
</action>
|
||||
<action name="actionUndo">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-undo"/>
|
||||
<iconset theme="edit-undo">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Undo</string>
|
||||
@ -217,7 +233,8 @@
|
||||
</action>
|
||||
<action name="actionRedo">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-redo"/>
|
||||
<iconset theme="edit-redo">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Redo</string>
|
||||
@ -230,6 +247,9 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRun_Buffer">
|
||||
<property name="icon">
|
||||
<iconset theme="emblem-default"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Run LAMMPS</string>
|
||||
</property>
|
||||
@ -240,6 +260,20 @@
|
||||
<string>Ctrl+Return</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop_LAMMPS">
|
||||
<property name="icon">
|
||||
<iconset theme="process-stop"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Stop LAMMPS</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Stop LAMMPS Process</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+/</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_LAMMPS_GUI">
|
||||
<property name="text">
|
||||
<string>&About</string>
|
||||
|
||||
@ -21,16 +21,10 @@ class LineNumberArea : public QWidget {
|
||||
public:
|
||||
LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor) {}
|
||||
|
||||
QSize sizeHint() const override
|
||||
{
|
||||
return QSize(codeEditor->lineNumberAreaWidth(), 0);
|
||||
}
|
||||
QSize sizeHint() const override { return QSize(codeEditor->lineNumberAreaWidth(), 0); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override
|
||||
{
|
||||
codeEditor->lineNumberAreaPaintEvent(event);
|
||||
}
|
||||
void paintEvent(QPaintEvent *event) override { codeEditor->lineNumberAreaPaintEvent(event); }
|
||||
|
||||
private:
|
||||
CodeEditor *codeEditor;
|
||||
|
||||
Reference in New Issue
Block a user