More debug output
This commit is contained in:
parent
0d6e844def
commit
3ce4a88a25
@ -3,6 +3,8 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include "unit.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -17,12 +19,14 @@ Calibration::Calibration()
|
|||||||
measurements[Measurement::Port2Load].datapoints = vector<Protocol::Datapoint>();
|
measurements[Measurement::Port2Load].datapoints = vector<Protocol::Datapoint>();
|
||||||
measurements[Measurement::Isolation].datapoints = vector<Protocol::Datapoint>();
|
measurements[Measurement::Isolation].datapoints = vector<Protocol::Datapoint>();
|
||||||
measurements[Measurement::Through].datapoints = vector<Protocol::Datapoint>();
|
measurements[Measurement::Through].datapoints = vector<Protocol::Datapoint>();
|
||||||
|
measurements[Measurement::Line].datapoints = vector<Protocol::Datapoint>();
|
||||||
|
|
||||||
type = Type::None;
|
type = Type::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calibration::clearMeasurements()
|
void Calibration::clearMeasurements()
|
||||||
{
|
{
|
||||||
|
qDebug() << "Clearing all calibration measurements...";
|
||||||
for(auto m : measurements) {
|
for(auto m : measurements) {
|
||||||
clearMeasurement(m.first);
|
clearMeasurement(m.first);
|
||||||
}
|
}
|
||||||
@ -32,6 +36,7 @@ void Calibration::clearMeasurement(Calibration::Measurement type)
|
|||||||
{
|
{
|
||||||
measurements[type].datapoints.clear();
|
measurements[type].datapoints.clear();
|
||||||
measurements[type].timestamp = QDateTime();
|
measurements[type].timestamp = QDateTime();
|
||||||
|
qDebug() << "Deleted" << MeasurementToString(type) << "measurement";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calibration::addMeasurement(Calibration::Measurement type, Protocol::Datapoint &d)
|
void Calibration::addMeasurement(Calibration::Measurement type, Protocol::Datapoint &d)
|
||||||
@ -46,9 +51,16 @@ bool Calibration::calculationPossible(Calibration::Type type)
|
|||||||
// always possible to reset to None
|
// always possible to reset to None
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
qDebug() << "Checking if" << TypeToString(type) << "calibration is possible...";
|
||||||
|
auto ret = SanityCheckSamples(Measurements(type, false));
|
||||||
|
if(ret) {
|
||||||
|
qDebug() << "...calibration possible";
|
||||||
|
} else {
|
||||||
|
qDebug() << "...calibration not possible";
|
||||||
|
}
|
||||||
return SanityCheckSamples(Measurements(type, false));
|
return SanityCheckSamples(Measurements(type, false));
|
||||||
}
|
}
|
||||||
#include <QDebug>
|
|
||||||
bool Calibration::constructErrorTerms(Calibration::Type type)
|
bool Calibration::constructErrorTerms(Calibration::Type type)
|
||||||
{
|
{
|
||||||
if(type == Type::None) {
|
if(type == Type::None) {
|
||||||
@ -58,10 +70,18 @@ bool Calibration::constructErrorTerms(Calibration::Type type)
|
|||||||
if(!calculationPossible(type)) {
|
if(!calculationPossible(type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
qDebug() << "Constructing error terms for" << TypeToString(type) << "calibration";
|
||||||
bool isTRL = type == Type::TRL;
|
bool isTRL = type == Type::TRL;
|
||||||
if(minFreq < kit.minFreq(isTRL) || maxFreq > kit.maxFreq(isTRL)) {
|
double kit_minFreq = kit.minFreq(isTRL);
|
||||||
|
double kit_maxFreq = kit.maxFreq(isTRL);
|
||||||
|
if(minFreq < kit_minFreq || maxFreq > kit_maxFreq) {
|
||||||
// Calkit does not support complete calibration range
|
// Calkit does not support complete calibration range
|
||||||
QMessageBox::critical(nullptr, "Unable to perform calibration", "The calibration kit does not support the complete span. Please choose a different calibration kit or a narrower span.");
|
QString msg = QString("The calibration kit does not support the complete span.\n\n")
|
||||||
|
+ "The measured calibration data covers " + Unit::ToString(minFreq, "Hz", " kMG", 4) + " to " + Unit::ToString(maxFreq, "Hz", " kMG", 4)
|
||||||
|
+ ", however the calibration kit is only valid from " + Unit::ToString(kit_minFreq, "Hz", " kMG", 4) + " to " + Unit::ToString(kit_maxFreq, "Hz", " kMG", 4) + ".\n\n"
|
||||||
|
+ "Please adjust the calibration kit or the span and take the calibration measurements again.";
|
||||||
|
QMessageBox::critical(nullptr, "Unable to perform calibration", msg);
|
||||||
|
qWarning() << msg;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch(type) {
|
switch(type) {
|
||||||
@ -80,6 +100,7 @@ void Calibration::resetErrorTerms()
|
|||||||
{
|
{
|
||||||
type = Type::None;
|
type = Type::None;
|
||||||
points.clear();
|
points.clear();
|
||||||
|
qDebug() << "Error terms reset";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calibration::construct12TermPoints()
|
void Calibration::construct12TermPoints()
|
||||||
@ -609,6 +630,7 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << "Attempting to open calibration from file" << filename;
|
||||||
|
|
||||||
// reset all data before loading new calibration
|
// reset all data before loading new calibration
|
||||||
clearMeasurements();
|
clearMeasurements();
|
||||||
@ -621,10 +643,12 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
calkit_file.truncate(dotPos);
|
calkit_file.truncate(dotPos);
|
||||||
}
|
}
|
||||||
calkit_file.append(".calkit");
|
calkit_file.append(".calkit");
|
||||||
|
qDebug() << "Associated calibration kit expected in" << calkit_file;
|
||||||
try {
|
try {
|
||||||
kit = Calkit::fromFile(calkit_file);
|
kit = Calkit::fromFile(calkit_file);
|
||||||
} catch (runtime_error e) {
|
} catch (runtime_error e) {
|
||||||
QMessageBox::warning(nullptr, "Missing calibration kit", "The calibration kit file associated with the selected calibration could not be parsed. The calibration might not be accurate. (" + QString(e.what()) + ")");
|
QMessageBox::warning(nullptr, "Missing calibration kit", "The calibration kit file associated with the selected calibration could not be parsed. The calibration might not be accurate. (" + QString(e.what()) + ")");
|
||||||
|
qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
ifstream file;
|
ifstream file;
|
||||||
@ -633,6 +657,7 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
file >> *this;
|
file >> *this;
|
||||||
} catch(runtime_error e) {
|
} catch(runtime_error e) {
|
||||||
QMessageBox::warning(nullptr, "File parsing error", e.what());
|
QMessageBox::warning(nullptr, "File parsing error", e.what());
|
||||||
|
qWarning() << "Calibration file parsing failed: " << e.what();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,6 +683,7 @@ bool Calibration::saveToFile(QString filename)
|
|||||||
file << *this;
|
file << *this;
|
||||||
|
|
||||||
auto calkit_file = filename + ".calkit";
|
auto calkit_file = filename + ".calkit";
|
||||||
|
qDebug() << "Saving associated calibration kit to file" << calkit_file;
|
||||||
kit.toFile(calkit_file);
|
kit.toFile(calkit_file);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -689,12 +715,13 @@ istream& operator >>(istream &in, Calibration &c)
|
|||||||
for(auto m : c.Measurements()) {
|
for(auto m : c.Measurements()) {
|
||||||
if(Calibration::MeasurementToString(m) == qLine) {
|
if(Calibration::MeasurementToString(m) == qLine) {
|
||||||
// this is the correct measurement
|
// this is the correct measurement
|
||||||
c.clearMeasurement(m);
|
c.measurements[m].datapoints.clear();
|
||||||
uint timestamp;
|
uint timestamp;
|
||||||
in >> timestamp;
|
in >> timestamp;
|
||||||
c.measurements[m].timestamp = QDateTime::fromSecsSinceEpoch(timestamp);
|
c.measurements[m].timestamp = QDateTime::fromSecsSinceEpoch(timestamp);
|
||||||
unsigned int points;
|
unsigned int points;
|
||||||
in >> points;
|
in >> points;
|
||||||
|
qDebug() << "Found measurement" << Calibration::MeasurementToString(m) << ", containing" << points << "points";
|
||||||
for(unsigned int i=0;i<points;i++) {
|
for(unsigned int i=0;i<points;i++) {
|
||||||
Protocol::Datapoint p;
|
Protocol::Datapoint p;
|
||||||
in >> p.pointNum >> p.frequency;
|
in >> p.pointNum >> p.frequency;
|
||||||
@ -711,6 +738,7 @@ istream& operator >>(istream &in, Calibration &c)
|
|||||||
for(auto t : Calibration::Types()) {
|
for(auto t : Calibration::Types()) {
|
||||||
if(Calibration::TypeToString(t) == qLine) {
|
if(Calibration::TypeToString(t) == qLine) {
|
||||||
// try to apply this calibration type
|
// try to apply this calibration type
|
||||||
|
qDebug() << "Specified calibration in file is" << Calibration::TypeToString(t);
|
||||||
if(c.calculationPossible(t)) {
|
if(c.calculationPossible(t)) {
|
||||||
c.constructErrorTerms(t);
|
c.constructErrorTerms(t);
|
||||||
} else {
|
} else {
|
||||||
@ -720,6 +748,7 @@ istream& operator >>(istream &in, Calibration &c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << "Calibration file parsing complete";
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -24,13 +25,10 @@ Calkit::Calkit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
void Calkit::toFile(QString filename)
|
void Calkit::toFile(QString filename)
|
||||||
{
|
{
|
||||||
if(!filename.endsWith(".calkit")) {
|
qDebug() << "Saving calkit to file" << filename;
|
||||||
filename.append(".calkit");
|
|
||||||
}
|
|
||||||
TransformPathsToRelative(filename);
|
TransformPathsToRelative(filename);
|
||||||
|
|
||||||
json j;
|
json j;
|
||||||
@ -67,6 +65,8 @@ static QString readLine(ifstream &file) {
|
|||||||
|
|
||||||
Calkit Calkit::fromFile(QString filename)
|
Calkit Calkit::fromFile(QString filename)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Opening calkit to file" << filename;
|
||||||
|
|
||||||
auto c = Calkit();
|
auto c = Calkit();
|
||||||
ifstream file;
|
ifstream file;
|
||||||
file.open(filename.toStdString());
|
file.open(filename.toStdString());
|
||||||
@ -77,6 +77,7 @@ Calkit Calkit::fromFile(QString filename)
|
|||||||
json j;
|
json j;
|
||||||
file >> j;
|
file >> j;
|
||||||
if(j.contains("SOLT")) {
|
if(j.contains("SOLT")) {
|
||||||
|
qDebug() << "JSON format detected";
|
||||||
// calkit file uses json format, parse
|
// calkit file uses json format, parse
|
||||||
for(auto e : c.json_descr) {
|
for(auto e : c.json_descr) {
|
||||||
auto list = e.name.split("/");
|
auto list = e.name.split("/");
|
||||||
@ -93,6 +94,7 @@ Calkit Calkit::fromFile(QString filename)
|
|||||||
}
|
}
|
||||||
if(!entry_exists) {
|
if(!entry_exists) {
|
||||||
// missing entry in json file, nothing to do (default values already set in constructor)
|
// missing entry in json file, nothing to do (default values already set in constructor)
|
||||||
|
qWarning() << "Entry" << e.name << "not present in file, assuming default value";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// json library does not now about QVariant, handle used cases
|
// json library does not now about QVariant, handle used cases
|
||||||
@ -112,6 +114,7 @@ Calkit Calkit::fromFile(QString filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << "Legacy format detected";
|
||||||
// legacy file format, return to beginning of file
|
// legacy file format, return to beginning of file
|
||||||
file.clear();
|
file.clear();
|
||||||
file.seekg(0);
|
file.seekg(0);
|
||||||
@ -337,7 +340,9 @@ void Calkit::TransformPathsToRelative(QFileInfo d)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(QFileInfo(*f).isAbsolute()) {
|
if(QFileInfo(*f).isAbsolute()) {
|
||||||
|
QString buf = *f;
|
||||||
*f = d.dir().relativeFilePath(*f);
|
*f = d.dir().relativeFilePath(*f);
|
||||||
|
qDebug() << "Transformed" << buf << "to" << *f << "(to relative)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,7 +356,9 @@ void Calkit::TransformPathsToAbsolute(QFileInfo d)
|
|||||||
}
|
}
|
||||||
if(QFileInfo(*f).isRelative()) {
|
if(QFileInfo(*f).isRelative()) {
|
||||||
auto absDir = QDir(d.dir().path() + "/" + *f);
|
auto absDir = QDir(d.dir().path() + "/" + *f);
|
||||||
|
QString buf = *f;
|
||||||
*f = absDir.absolutePath();
|
*f = absDir.absolutePath();
|
||||||
|
qDebug() << "Transformed" << buf << "to" << *f << "(to absolute)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,6 @@ Protocol::DeviceInfo Device::lastInfo = defaultInfo;
|
|||||||
|
|
||||||
Device::Device(QString serial)
|
Device::Device(QString serial)
|
||||||
{
|
{
|
||||||
qDebug() << "Starting device connection...";
|
|
||||||
|
|
||||||
lastInfo = defaultInfo;
|
lastInfo = defaultInfo;
|
||||||
|
|
||||||
m_handle = nullptr;
|
m_handle = nullptr;
|
||||||
@ -302,7 +300,7 @@ std::set<QString> Device::GetDevices()
|
|||||||
|
|
||||||
void Device::USBHandleThread()
|
void Device::USBHandleThread()
|
||||||
{
|
{
|
||||||
qInfo() << "Receive thread started" << flush;
|
qDebug() << "Receive thread started";
|
||||||
while (m_connected) {
|
while (m_connected) {
|
||||||
libusb_handle_events(m_context);
|
libusb_handle_events(m_context);
|
||||||
}
|
}
|
||||||
@ -362,7 +360,6 @@ void Device::SearchDevices(std::function<bool (libusb_device_handle *, QString)>
|
|||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
/* managed to read the product string */
|
/* managed to read the product string */
|
||||||
QString product(c_product);
|
QString product(c_product);
|
||||||
qDebug() << "Opened device: " << product;
|
|
||||||
if (product == "VNA") {
|
if (product == "VNA") {
|
||||||
// this is a match
|
// this is a match
|
||||||
if(!foundCallback(handle, QString(c_serial))) {
|
if(!foundCallback(handle, QString(c_serial))) {
|
||||||
|
@ -403,7 +403,7 @@ void VNA::initializeDevice()
|
|||||||
auto key = "DefaultCalibration"+window->getDevice()->serial();
|
auto key = "DefaultCalibration"+window->getDevice()->serial();
|
||||||
if (s.contains(key)) {
|
if (s.contains(key)) {
|
||||||
auto filename = s.value(key).toString();
|
auto filename = s.value(key).toString();
|
||||||
qDebug() << "Attempting to load default calibration file \"" << filename << "\"";
|
qDebug() << "Attempting to load default calibration file " << filename;
|
||||||
if(QFile::exists(filename)) {
|
if(QFile::exists(filename)) {
|
||||||
if(cal.openFromFile(filename)) {
|
if(cal.openFromFile(filename)) {
|
||||||
ApplyCalibration(cal.getType());
|
ApplyCalibration(cal.getType());
|
||||||
@ -430,7 +430,6 @@ void VNA::NewDatapoint(Protocol::Datapoint d)
|
|||||||
{
|
{
|
||||||
d = average.process(d);
|
d = average.process(d);
|
||||||
if(calMeasuring) {
|
if(calMeasuring) {
|
||||||
|
|
||||||
if(average.currentSweep() == averages) {
|
if(average.currentSweep() == averages) {
|
||||||
// this is the last averaging sweep, use values for calibration
|
// this is the last averaging sweep, use values for calibration
|
||||||
if(!calWaitFirst || d.pointNum == 0) {
|
if(!calWaitFirst || d.pointNum == 0) {
|
||||||
@ -438,6 +437,7 @@ void VNA::NewDatapoint(Protocol::Datapoint d)
|
|||||||
cal.addMeasurement(calMeasurement, d);
|
cal.addMeasurement(calMeasurement, d);
|
||||||
if(d.pointNum == settings.points - 1) {
|
if(d.pointNum == settings.points - 1) {
|
||||||
calMeasuring = false;
|
calMeasuring = false;
|
||||||
|
qDebug() << "Calibration measurement" << cal.MeasurementToString(calMeasurement) << "complete";
|
||||||
emit CalibrationMeasurementComplete(calMeasurement);
|
emit CalibrationMeasurementComplete(calMeasurement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -627,6 +627,8 @@ void VNA::ApplyCalibration(Calibration::Type type)
|
|||||||
if(cal.constructErrorTerms(type)) {
|
if(cal.constructErrorTerms(type)) {
|
||||||
calValid = true;
|
calValid = true;
|
||||||
emit CalibrationApplied(type);
|
emit CalibrationApplied(type);
|
||||||
|
} else {
|
||||||
|
DisableCalibration(true);
|
||||||
}
|
}
|
||||||
} catch (runtime_error e) {
|
} catch (runtime_error e) {
|
||||||
QMessageBox::critical(window, "Calibration failure", e.what());
|
QMessageBox::critical(window, "Calibration failure", e.what());
|
||||||
@ -648,6 +650,7 @@ void VNA::StartCalibrationMeasurement(Calibration::Measurement m)
|
|||||||
}
|
}
|
||||||
// Stop sweep
|
// Stop sweep
|
||||||
StopSweep();
|
StopSweep();
|
||||||
|
qDebug() << "Taking" << Calibration::MeasurementToString(m) << "measurement";
|
||||||
calMeasurement = m;
|
calMeasurement = m;
|
||||||
// Delete any already captured data of this measurement
|
// Delete any already captured data of this measurement
|
||||||
cal.clearMeasurement(m);
|
cal.clearMeasurement(m);
|
||||||
|
@ -55,6 +55,10 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
QCoreApplication::setOrganizationName("VNA");
|
QCoreApplication::setOrganizationName("VNA");
|
||||||
QCoreApplication::setApplicationName("Application");
|
QCoreApplication::setApplicationName("Application");
|
||||||
|
|
||||||
|
qSetMessagePattern("%{time process}: [%{type}] %{message}");
|
||||||
|
|
||||||
|
qDebug() << "Application start";
|
||||||
|
|
||||||
Preferences::getInstance().load();
|
Preferences::getInstance().load();
|
||||||
device = nullptr;
|
device = nullptr;
|
||||||
|
|
||||||
@ -153,7 +157,13 @@ void AppWindow::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
void AppWindow::ConnectToDevice(QString serial)
|
void AppWindow::ConnectToDevice(QString serial)
|
||||||
{
|
{
|
||||||
|
if(serial.isEmpty()) {
|
||||||
|
qDebug() << "Trying to connect to any device";
|
||||||
|
} else {
|
||||||
|
qDebug() << "Trying to connect to" << serial;
|
||||||
|
}
|
||||||
if(device) {
|
if(device) {
|
||||||
|
qDebug() << "Already connected to a device, disconnecting first...";
|
||||||
DisconnectDevice();
|
DisconnectDevice();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -184,6 +194,7 @@ void AppWindow::ConnectToDevice(QString serial)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const runtime_error e) {
|
} catch (const runtime_error e) {
|
||||||
|
qWarning() << "Failed to connect:" << e.what();
|
||||||
DisconnectDevice();
|
DisconnectDevice();
|
||||||
UpdateDeviceList();
|
UpdateDeviceList();
|
||||||
}
|
}
|
||||||
@ -269,6 +280,7 @@ int AppWindow::UpdateDeviceList()
|
|||||||
// no devices available, disable connection option
|
// no devices available, disable connection option
|
||||||
ui->menuConnect_to->setEnabled(false);
|
ui->menuConnect_to->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
qDebug() << "Updated device list, found" << devices.size();
|
||||||
return devices.size();
|
return devices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
Mode* Mode::activeMode = nullptr;
|
Mode* Mode::activeMode = nullptr;
|
||||||
QWidget* Mode::cornerWidget = nullptr;
|
QWidget* Mode::cornerWidget = nullptr;
|
||||||
@ -47,6 +48,7 @@ void Mode::activate()
|
|||||||
activeMode->deactivate();
|
activeMode->deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "Activating mode" << name;
|
||||||
// show all mode specific GUI elements
|
// show all mode specific GUI elements
|
||||||
for(auto t : toolbars) {
|
for(auto t : toolbars) {
|
||||||
t->show();
|
t->show();
|
||||||
@ -64,13 +66,10 @@ void Mode::activate()
|
|||||||
window->getCentral()->setCurrentWidget(central);
|
window->getCentral()->setCurrentWidget(central);
|
||||||
|
|
||||||
// restore dock and toolbar positions
|
// restore dock and toolbar positions
|
||||||
// window->restoreGeometry(settings.value("geometry_"+name).toByteArray());
|
|
||||||
window->restoreState(settings.value("windowState_"+name).toByteArray());
|
window->restoreState(settings.value("windowState_"+name).toByteArray());
|
||||||
|
|
||||||
// restore visibility of toolbars and docks
|
// restore visibility of toolbars and docks
|
||||||
// window->getUi()->menuDocks->clear();
|
|
||||||
for(auto d : docks) {
|
for(auto d : docks) {
|
||||||
// window->getUi()->menuDocks->addAction(d->toggleViewAction());
|
|
||||||
bool hidden = settings.value("dock_"+name+"_"+d->windowTitle(), d->isHidden()).toBool();
|
bool hidden = settings.value("dock_"+name+"_"+d->windowTitle(), d->isHidden()).toBool();
|
||||||
if(hidden) {
|
if(hidden) {
|
||||||
d->hide();
|
d->hide();
|
||||||
@ -78,9 +77,7 @@ void Mode::activate()
|
|||||||
d->show();
|
d->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// window->getUi()->menuToolbars->clear();
|
|
||||||
for(auto t : toolbars) {
|
for(auto t : toolbars) {
|
||||||
// window->getUi()->menuToolbars->addAction(t->toggleViewAction());
|
|
||||||
bool hidden = settings.value("toolbar_"+name+"_"+t->windowTitle(), t->isHidden()).toBool();
|
bool hidden = settings.value("toolbar_"+name+"_"+t->windowTitle(), t->isHidden()).toBool();
|
||||||
if(hidden) {
|
if(hidden) {
|
||||||
t->hide();
|
t->hide();
|
||||||
@ -106,7 +103,6 @@ void Mode::deactivate()
|
|||||||
for(auto t : toolbars) {
|
for(auto t : toolbars) {
|
||||||
settings.setValue("toolbar_"+name+"_"+t->windowTitle(), t->isHidden());
|
settings.setValue("toolbar_"+name+"_"+t->windowTitle(), t->isHidden());
|
||||||
}
|
}
|
||||||
// settings.setValue("geometry_"+name, window->saveGeometry());
|
|
||||||
settings.setValue("windowState_"+name, window->saveState());
|
settings.setValue("windowState_"+name, window->saveState());
|
||||||
|
|
||||||
// hide all mode specific GUI elements
|
// hide all mode specific GUI elements
|
||||||
@ -122,6 +118,7 @@ void Mode::deactivate()
|
|||||||
a->setVisible(false);
|
a->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "Deactivated mode" << name;
|
||||||
activeMode = nullptr;
|
activeMode = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ class Mode : public QObject
|
|||||||
public:
|
public:
|
||||||
Mode(AppWindow *window, QString name);
|
Mode(AppWindow *window, QString name);
|
||||||
|
|
||||||
virtual void activate();
|
virtual void activate(); // derived classes must call Mode::activate before doing anything
|
||||||
virtual void deactivate();
|
virtual void deactivate(); // derived classes must call Mode::deactivate before returning
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
static Mode *getActiveMode();
|
static Mode *getActiveMode();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -168,11 +169,14 @@ void Preferences::load()
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
// load settings, using default values if not present
|
// load settings, using default values if not present
|
||||||
|
qInfo() << "Loading preferences";
|
||||||
for(auto d : descr) {
|
for(auto d : descr) {
|
||||||
try {
|
try {
|
||||||
d.var.setValue(settings.value(d.name, d.def));
|
d.var.setValue(settings.value(d.name, d.def));
|
||||||
|
qDebug() << "Setting" << d.name << "is set to" << d.var.value();
|
||||||
} catch (const exception& e){
|
} catch (const exception& e){
|
||||||
d.var.setValue(d.def);
|
d.var.setValue(d.def);
|
||||||
|
qDebug() << "Setting" << d.name << "reset to default:" << d.def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user