2022-03-11 15:12:32 -05:00
|
|
|
#include "activeStations.h"
|
2022-03-11 13:11:39 -05:00
|
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QTextCharFormat>
|
|
|
|
|
|
|
|
#include "SettingsGroup.hpp"
|
|
|
|
#include "qt_helpers.hpp"
|
2022-03-11 15:12:32 -05:00
|
|
|
#include "ui_activeStations.h"
|
2022-03-11 13:11:39 -05:00
|
|
|
|
2022-03-11 15:12:32 -05:00
|
|
|
#include "moc_activeStations.cpp"
|
2022-03-11 13:11:39 -05:00
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
ActiveStations::ActiveStations(QSettings * settings, QFont const& font, QWidget *parent) :
|
2022-03-11 13:11:39 -05:00
|
|
|
QWidget(parent),
|
|
|
|
settings_ {settings},
|
2022-03-11 14:58:13 -05:00
|
|
|
ui(new Ui::ActiveStations)
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2022-03-11 15:03:16 -05:00
|
|
|
setWindowTitle (QApplication::applicationName () + " - " + tr ("Active Stations"));
|
2022-03-11 14:58:13 -05:00
|
|
|
ui->ActiveStationsPlainTextEdit->setReadOnly (true);
|
2022-03-11 13:11:39 -05:00
|
|
|
changeFont (font);
|
|
|
|
read_settings ();
|
2022-03-11 14:46:58 -05:00
|
|
|
ui->header_label->setText("Pts Call Grid Az S/N Dial Freq");
|
2022-03-11 13:11:39 -05:00
|
|
|
}
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
ActiveStations::~ActiveStations()
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
|
|
|
write_settings ();
|
|
|
|
}
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
void ActiveStations::changeFont (QFont const& font)
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
|
|
|
ui->header_label->setStyleSheet (font_as_stylesheet (font));
|
2022-03-11 14:58:13 -05:00
|
|
|
ui->ActiveStationsPlainTextEdit->setStyleSheet (font_as_stylesheet (font));
|
2022-03-11 13:11:39 -05:00
|
|
|
setContentFont (font);
|
|
|
|
updateGeometry ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
void ActiveStations::setContentFont(QFont const& font)
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
2022-03-11 14:58:13 -05:00
|
|
|
ui->ActiveStationsPlainTextEdit->setFont (font);
|
2022-03-11 13:11:39 -05:00
|
|
|
QTextCharFormat charFormat;
|
|
|
|
charFormat.setFont (font);
|
2022-03-11 14:58:13 -05:00
|
|
|
ui->ActiveStationsPlainTextEdit->selectAll ();
|
|
|
|
auto cursor = ui->ActiveStationsPlainTextEdit->textCursor ();
|
2022-03-11 13:11:39 -05:00
|
|
|
cursor.mergeCharFormat (charFormat);
|
|
|
|
cursor.clearSelection ();
|
|
|
|
cursor.movePosition (QTextCursor::End);
|
|
|
|
|
|
|
|
// position so viewport scrolled to left
|
|
|
|
cursor.movePosition (QTextCursor::Up);
|
|
|
|
cursor.movePosition (QTextCursor::StartOfLine);
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
ui->ActiveStationsPlainTextEdit->setTextCursor (cursor);
|
|
|
|
ui->ActiveStationsPlainTextEdit->ensureCursorVisible ();
|
2022-03-11 13:11:39 -05:00
|
|
|
}
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
void ActiveStations::read_settings ()
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
2022-03-11 14:58:13 -05:00
|
|
|
SettingsGroup group {settings_, "ActiveStations"};
|
2022-03-11 13:11:39 -05:00
|
|
|
restoreGeometry (settings_->value ("window/geometry").toByteArray ());
|
|
|
|
}
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
void ActiveStations::write_settings ()
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
2022-03-11 14:58:13 -05:00
|
|
|
SettingsGroup group {settings_, "ActiveStations"};
|
2022-03-11 13:11:39 -05:00
|
|
|
settings_->setValue ("window/geometry", saveGeometry ());
|
|
|
|
}
|
|
|
|
|
2022-03-11 14:58:13 -05:00
|
|
|
void ActiveStations::displayActiveStations(QString const& t)
|
2022-03-11 13:11:39 -05:00
|
|
|
{
|
2022-03-11 14:58:13 -05:00
|
|
|
ui->ActiveStationsPlainTextEdit->setPlainText(t);
|
2022-03-11 13:11:39 -05:00
|
|
|
}
|