Isis 3 Programmer Reference
GuiLog.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include <QVBoxLayout>
8#include <QLabel>
9#include <QFileDialog>
10#include <iostream>
11#include <fstream>
12
13#include "GuiLog.h"
14
15namespace Isis {
17 GuiLog::GuiLog(QWidget *parent) : QWidget(parent) {
18
19 QVBoxLayout *lo = new QVBoxLayout;
20 setLayout(lo);
21
22// QLabel *lb = new QLabel("Log");
23// lo->addWidget(lb);
24
25 p_textEdit = new QTextEdit;
26 p_textEdit->setFont(QFont("Courier"));
27 p_textEdit->setFontPointSize(10);
28// p_textEdit->setReadOnly(true);
29
30 lo->addWidget(p_textEdit);
31 }
32
36
38 void GuiLog::Write(const QString &string) {
39 p_textEdit->append(string);
40 }
41
44 p_textEdit->clear();
45 p_textEdit->setFont(QFont("Courier"));
46 p_textEdit->setFontPointSize(10);
47 }
48
50 void GuiLog::Save() {
51 QString s = QFileDialog::getSaveFileName(this, "Save log to file");
52 if(s != "") {
53 std::ofstream fout;
54 std::string filename(s.toStdString());
55 fout.open(filename.c_str());
56 fout << p_textEdit->toPlainText().toStdString();
57 fout.close();
58 }
59 }
60}
~GuiLog()
Destructor.
Definition GuiLog.cpp:34
void Write(const QString &string)
Add more information to the log widget.
Definition GuiLog.cpp:38
void Save()
Save the contents of the log widget to a file.
Definition GuiLog.cpp:50
void Clear()
Clear the contents of the log widget.
Definition GuiLog.cpp:43
GuiLog(QWidget *parent=0)
Constructor.
Definition GuiLog.cpp:17
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16