Fork me on GitHub
2.15.20
FGx
A cross-platform launcher for FlightGear
viewlogwidget.cpp
Go to the documentation of this file.
1 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
2 // FGx FlightGear Launcher // viewlogwidget.cpp
3 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
4 // (c) 2010-2012
5 // Yves Sablonier, Pete Morgan
6 // Geoff McLane
7 // GNU GPLv2, see main.cpp and shipped licence.txt for further information
8 
9 #include <QHBoxLayout>
10 
11 #include <QGroupBox>
12 #include <QFile>
13 
14 
15 #include "viewlogwidget.h"
16 
18  QWidget(parent)
19 {
20 
21  mainObject = mOb;
22 
23  setProperty("settings_namespace", QVariant("log_window"));
25 
26  setWindowIcon(QIcon(":/icon/log"));
27  setWindowTitle(tr("View Log"));
28  setMinimumWidth(600);
29  setMinimumHeight(600);
30 
31  QHBoxLayout *mainLayout = new QHBoxLayout();
32 
33  setLayout(mainLayout);
34 
35 
36  QGroupBox *groupBox = new QGroupBox(tr("Log Output"));
37  mainLayout->addWidget(groupBox);
38 
39  QHBoxLayout *layoutBox = new QHBoxLayout();
40  groupBox->setLayout(layoutBox);
41 
42 
43  txtLog = new QPlainTextEdit();
44  layoutBox->addWidget(txtLog);
45 
46 
47  QVBoxLayout *layoutButtons = new QVBoxLayout();
48  layoutBox->addLayout(layoutButtons);
49 
50  buttonRefresh = new QPushButton();
51  buttonRefresh->setText(tr("Refresh"));
52  buttonRefresh->setIcon(QIcon(":/icon/refresh"));
53  connect(buttonRefresh, SIGNAL(clicked()), this, SLOT(on_load_log_file()));
54 
55  layoutButtons->addWidget(buttonRefresh);
56 
57 
58  layoutButtons->addStretch(20);
59 
61 }
62 
63 
65 
66  QString file_name = mainObject->log_file_path();
67  QFile file(file_name);
68  if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
69  return;
70  }
71  txtLog->setPlainText( file.readAll());
72 
73 }
74 
75 //= window close
76 void ViewLogWidget::closeEvent(QCloseEvent *event){
78  event->accept();
79 }
static QString log_file_path()
Log File.
Definition: mainobject.cpp:388
The MainObject is an extended QObject, and the main "controller" for FGx.
Definition: mainobject.h:66
void saveWindow(QWidget *widget)
Saves a window's size and position.
Definition: xsettings.cpp:90
void restoreWindow(QWidget *widget)
Restores a size window position.
Definition: xsettings.cpp:101
QPlainTextEdit * txtLog
Definition: viewlogwidget.h:30
QPushButton * buttonRefresh
Definition: viewlogwidget.h:31
MainObject * mainObject
Definition: viewlogwidget.h:28
void closeEvent(QCloseEvent *event)
XSettings * settings
Definition: mainobject.h:85
ViewLogWidget(MainObject *mob, QWidget *parent=0)
void on_load_log_file()