add support for "modified" indicator to window title
This commit is contained in:
@ -2,7 +2,6 @@ LAMMPS-GUI TODO list:
|
||||
|
||||
# Short term goals
|
||||
|
||||
- add indicator for when the file in editor is modified (-> status bar?)
|
||||
- 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 dialog when exiting asking if file should be saved when it is modified, similar dialog when opening a new file
|
||||
- add CTRL-q hotkey to log windows so you can exit the entire application (add do you really want to? dialog to this)
|
||||
|
||||
@ -70,6 +70,8 @@ LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
|
||||
connect(ui->actionStop_LAMMPS, &QAction::triggered, this, &LammpsGui::stop_run);
|
||||
connect(ui->actionAbout_LAMMPS_GUI, &QAction::triggered, this, &LammpsGui::about);
|
||||
connect(ui->action_Help, &QAction::triggered, this, &LammpsGui::help);
|
||||
connect(ui->textEdit->document(), &QTextDocument::modificationChanged, this,
|
||||
&LammpsGui::modified);
|
||||
|
||||
#if !QT_CONFIG(clipboard)
|
||||
ui->actionCut->setEnabled(false);
|
||||
@ -158,6 +160,7 @@ void LammpsGui::open_file(const QString &fileName)
|
||||
QString text = in.readAll();
|
||||
ui->textEdit->document()->setPlainText(text);
|
||||
ui->textEdit->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||
ui->textEdit->document()->setModified(false);
|
||||
file.close();
|
||||
}
|
||||
|
||||
@ -175,6 +178,7 @@ void LammpsGui::write_file(const QString &fileName)
|
||||
QString text = ui->textEdit->toPlainText();
|
||||
out << text;
|
||||
file.close();
|
||||
ui->textEdit->document()->setModified(false);
|
||||
}
|
||||
|
||||
void LammpsGui::save()
|
||||
@ -286,6 +290,16 @@ void LammpsGui::logupdate()
|
||||
}
|
||||
}
|
||||
|
||||
void LammpsGui::modified()
|
||||
{
|
||||
const QString modflag(" - *modified*");
|
||||
auto title = windowTitle().remove(modflag);
|
||||
if (ui->textEdit->document()->isModified())
|
||||
setWindowTitle(title + modflag);
|
||||
else
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
void LammpsGui::run_done()
|
||||
{
|
||||
logupdater->stop();
|
||||
|
||||
@ -64,6 +64,7 @@ private slots:
|
||||
void about();
|
||||
void help();
|
||||
void logupdate();
|
||||
void modified();
|
||||
|
||||
private:
|
||||
Ui::LammpsGui *ui;
|
||||
|
||||
Reference in New Issue
Block a user