Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
logviewer.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #include "logviewer.h"
21 #include <QTextStream>
22 #include <QFile>
23 #include <QScroller>
24 #include "../core/config.h"
25 #include "logforqt.h"
26 #include "filemanagerforqt.h"
27 #include "ui_logviewer.h"
28 #include "qtconfig.h"
29 
30 LogViewer::LogViewer(QWidget *parent) :
31  QDialog(parent, Qt::Window),
32  ui(new Ui::LogViewer)
33 {
34  ui->setupUi(this);
35  setModal(true);
36 
37  if (parent) {
38  QRect p(parent->geometry());
39  setGeometry(p.left() + p.width() / 4, p.top() + p.height() / 4, p.width() / 2, p.height() / 2);
40  }
41 
42  QFile f(QString::fromStdString(FileManager::getSingleton().getLogFilePath(LogForQt::LOG_NAME)));
43  if (!f.open(QFile::ReadOnly | QFile::Text)) return;
44  QTextStream in(&f);
45  ui->textBrowser->setText(in.readAll());
46 
47  ui->textBrowser->setReadOnly(true);
48  ui->textBrowser->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
49 
50  SHOW_DIALOG(this);
51 
52  QScroller::grabGesture(ui->textBrowser);
53 }
54 
56 {
57  delete ui;
58 }
static FileManager & getSingleton()
FileManager::getSingleton: Get a reference to the singleton.
Definition: filemanager.cpp:47
#define SHOW_DIALOG(d)
Definition: qtconfig.h:41
Ui::LogViewer * ui
Definition: logviewer.h:38
static const std::string LOG_NAME
Definition: log.h:70
LogViewer(QWidget *parent=nullptr)
Definition: logviewer.cpp:30