2015-04-22 13:48:03 -04:00
|
|
|
#include "messageaveraging.h"
|
2016-06-10 11:54:16 -04:00
|
|
|
|
2015-06-09 10:30:23 -04:00
|
|
|
#include <QSettings>
|
2015-11-17 20:28:12 -05:00
|
|
|
#include <QApplication>
|
2016-05-18 19:22:24 -04:00
|
|
|
#include <QTextCharFormat>
|
|
|
|
|
|
|
|
#include "SettingsGroup.hpp"
|
|
|
|
#include "qt_helpers.hpp"
|
2015-04-22 13:48:03 -04:00
|
|
|
#include "ui_messageaveraging.h"
|
|
|
|
|
2016-05-18 19:22:24 -04:00
|
|
|
MessageAveraging::MessageAveraging(QSettings * settings, QFont const& font, QWidget *parent) :
|
2015-04-22 13:48:03 -04:00
|
|
|
QWidget(parent),
|
|
|
|
settings_ {settings},
|
|
|
|
ui(new Ui::MessageAveraging)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-12-19 12:01:38 -05:00
|
|
|
// setWindowTitle (QApplication::applicationName () + " - " + tr ("Message Averaging"));
|
2016-05-18 19:22:24 -04:00
|
|
|
ui->msgAvgPlainTextEdit->setReadOnly (true);
|
|
|
|
changeFont (font);
|
2015-04-22 13:48:03 -04:00
|
|
|
read_settings ();
|
2017-12-19 12:01:38 -05:00
|
|
|
if(m_title_.contains("Fox")) {
|
|
|
|
ui->header_label->setText(" Date Time Call Grid Sent Rcvd Band");
|
|
|
|
} else {
|
|
|
|
ui->header_label->setText(" UTC Sync DT Freq ");
|
2017-12-20 11:19:48 -05:00
|
|
|
ui->lab1->setVisible(false);
|
|
|
|
ui->lab2->setVisible(false);
|
|
|
|
ui->lab3->setVisible(false);
|
2018-01-17 10:32:45 -05:00
|
|
|
ui->lab4->setVisible(false);
|
2017-12-19 12:01:38 -05:00
|
|
|
}
|
|
|
|
setWindowTitle(m_title_);
|
2017-12-22 10:31:09 -05:00
|
|
|
m_nLogged_=0;
|
2015-04-22 13:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageAveraging::~MessageAveraging()
|
|
|
|
{
|
|
|
|
if (isVisible ()) write_settings ();
|
|
|
|
}
|
|
|
|
|
2016-05-18 19:22:24 -04:00
|
|
|
void MessageAveraging::changeFont (QFont const& font)
|
|
|
|
{
|
|
|
|
ui->header_label->setStyleSheet (font_as_stylesheet (font));
|
|
|
|
ui->msgAvgPlainTextEdit->setStyleSheet (font_as_stylesheet (font));
|
|
|
|
setContentFont (font);
|
|
|
|
updateGeometry ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::setContentFont(QFont const& font)
|
|
|
|
{
|
|
|
|
ui->msgAvgPlainTextEdit->setFont (font);
|
|
|
|
QTextCharFormat charFormat;
|
|
|
|
charFormat.setFont (font);
|
|
|
|
ui->msgAvgPlainTextEdit->selectAll ();
|
|
|
|
auto cursor = ui->msgAvgPlainTextEdit->textCursor ();
|
|
|
|
cursor.mergeCharFormat (charFormat);
|
|
|
|
cursor.clearSelection ();
|
|
|
|
cursor.movePosition (QTextCursor::End);
|
|
|
|
|
|
|
|
// position so viewport scrolled to left
|
|
|
|
cursor.movePosition (QTextCursor::Up);
|
|
|
|
cursor.movePosition (QTextCursor::StartOfLine);
|
|
|
|
|
|
|
|
ui->msgAvgPlainTextEdit->setTextCursor (cursor);
|
|
|
|
ui->msgAvgPlainTextEdit->ensureCursorVisible ();
|
|
|
|
}
|
|
|
|
|
2015-04-22 13:48:03 -04:00
|
|
|
void MessageAveraging::closeEvent (QCloseEvent * e)
|
|
|
|
{
|
|
|
|
write_settings ();
|
|
|
|
QWidget::closeEvent (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::read_settings ()
|
|
|
|
{
|
2016-05-18 19:22:24 -04:00
|
|
|
SettingsGroup group {settings_, "MessageAveraging"};
|
2015-12-10 09:15:43 -05:00
|
|
|
restoreGeometry (settings_->value ("window/geometry").toByteArray ());
|
2017-12-19 12:01:38 -05:00
|
|
|
m_title_=settings_->value("window/title","Message Averaging").toString();
|
2015-04-22 13:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::write_settings ()
|
|
|
|
{
|
2016-05-18 19:22:24 -04:00
|
|
|
SettingsGroup group {settings_, "MessageAveraging"};
|
2015-12-10 09:15:43 -05:00
|
|
|
settings_->setValue ("window/geometry", saveGeometry ());
|
2017-12-19 12:01:38 -05:00
|
|
|
settings_->setValue("window/title",m_title_);
|
2015-04-22 13:48:03 -04:00
|
|
|
}
|
|
|
|
|
2016-05-18 19:22:24 -04:00
|
|
|
void MessageAveraging::displayAvg(QString const& t)
|
2015-04-22 13:48:03 -04:00
|
|
|
{
|
2016-05-18 19:22:24 -04:00
|
|
|
ui->msgAvgPlainTextEdit->setPlainText(t);
|
2015-04-22 13:48:03 -04:00
|
|
|
}
|
2017-12-19 12:01:38 -05:00
|
|
|
|
|
|
|
void MessageAveraging::foxLogSetup()
|
|
|
|
{
|
|
|
|
m_title_=QApplication::applicationName () + " - Fox Log";
|
|
|
|
setWindowTitle(m_title_);
|
2017-12-20 11:19:48 -05:00
|
|
|
ui->header_label->setText(" Date Time Call Grid Sent Rcvd Band");
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::foxLabCallers(int n)
|
|
|
|
{
|
|
|
|
QString t;
|
|
|
|
t.sprintf("Callers: %3d",n);
|
|
|
|
ui->lab1->setText(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::foxLabQueued(int n)
|
|
|
|
{
|
|
|
|
QString t;
|
|
|
|
t.sprintf("Queued: %3d",n);
|
|
|
|
ui->lab2->setText(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::foxLabRate(int n)
|
|
|
|
{
|
|
|
|
QString t;
|
|
|
|
t.sprintf("Rate: %3d",n);
|
2017-12-22 10:31:09 -05:00
|
|
|
ui->lab4->setText(t);
|
2017-12-20 11:19:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessageAveraging::foxAddLog(QString logLine)
|
|
|
|
{
|
|
|
|
ui->msgAvgPlainTextEdit->insertPlainText(logLine + "\n");
|
2017-12-22 10:31:09 -05:00
|
|
|
m_nLogged_++;
|
|
|
|
QString t;
|
|
|
|
t.sprintf("Logged: %d",m_nLogged_);
|
|
|
|
ui->lab3->setText(t);
|
2017-12-19 12:01:38 -05:00
|
|
|
}
|