automatically copy "About LAMMPS" dialog text to clipboard

This commit is contained in:
Axel Kohlmeyer
2023-08-19 07:20:25 -04:00
parent b904534ac2
commit a4390529ab
3 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(lammps-gui VERSION 1.2.2 LANGUAGES CXX) project(lammps-gui VERSION 1.2.3 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)

View File

@ -71,6 +71,7 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth); connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth);
connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea); connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea);
updateLineNumberAreaWidth(0); updateLineNumberAreaWidth(0);
setCursorWidth(2);
} }
int CodeEditor::lineNumberAreaWidth() int CodeEditor::lineNumberAreaWidth()

View File

@ -23,11 +23,13 @@
#include "stdcapture.h" #include "stdcapture.h"
#include "ui_lammpsgui.h" #include "ui_lammpsgui.h"
#include <QClipboard>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QFont> #include <QFont>
#include <QGuiApplication>
#include <QLabel> #include <QLabel>
#include <QLocale> #include <QLocale>
#include <QMessageBox> #include <QMessageBox>
@ -957,6 +959,10 @@ void LammpsGui::about()
} else { } else {
version += " - LAMMPS library linked to executable"; version += " - LAMMPS library linked to executable";
} }
QString to_clipboard(version.c_str());
to_clipboard += "\n\n";
std::string info = "LAMMPS is currently running. LAMMPS config info not available."; std::string info = "LAMMPS is currently running. LAMMPS config info not available.";
// LAMMPS is not re-entrant, so we can only query LAMMPS when it is not running // LAMMPS is not re-entrant, so we can only query LAMMPS when it is not running
@ -971,8 +977,12 @@ void LammpsGui::about()
info = std::string(info, start, end - start); info = std::string(info, start, end - start);
} }
to_clipboard += info.c_str();
QGuiApplication::clipboard()->setText(to_clipboard);
info += "(Note: this text has been copied to the clipboard)\n";
QMessageBox msg; QMessageBox msg;
msg.setWindowTitle("About LAMMPS-GUI"); msg.setWindowTitle("About LAMMPS");
msg.setText(version.c_str()); msg.setText(version.c_str());
msg.setInformativeText(info.c_str()); msg.setInformativeText(info.c_str());
msg.setIconPixmap(QPixmap(":/lammps-icon-128x128.png").scaled(64, 64)); msg.setIconPixmap(QPixmap(":/lammps-icon-128x128.png").scaled(64, 64));