Delete confusing PREF macro and replace as required

This commit is contained in:
Phil Olynyk 2019-03-25 19:36:41 -04:00
parent 6f34f2605a
commit 26f5854c6b
6 changed files with 60 additions and 59 deletions

View File

@ -51,41 +51,41 @@ bool InitGraphGlobals()
return true;
}
if (!PREF.contains("Fonts_Graph_Name")) {
PREF["Fonts_Graph_Name"] = "Sans Serif";
PREF["Fonts_Graph_Size"] = 10;
PREF["Fonts_Graph_Bold"] = false;
PREF["Fonts_Graph_Italic"] = false;
if (!p_pref->contains("Fonts_Graph_Name")) {
(*p_pref)["Fonts_Graph_Name"] = "Sans Serif";
(*p_pref)["Fonts_Graph_Size"] = 10;
(*p_pref)["Fonts_Graph_Bold"] = false;
(*p_pref)["Fonts_Graph_Italic"] = false;
}
if (!PREF.contains("Fonts_Title_Name")) {
PREF["Fonts_Title_Name"] = "Sans Serif";
PREF["Fonts_Title_Size"] = 12;
PREF["Fonts_Title_Bold"] = true;
PREF["Fonts_Title_Italic"] = false;
if (!p_pref->contains("Fonts_Title_Name")) {
(*p_pref)["Fonts_Title_Name"] = "Sans Serif";
(*p_pref)["Fonts_Title_Size"] = 12;
(*p_pref)["Fonts_Title_Bold"] = true;
(*p_pref)["Fonts_Title_Italic"] = false;
}
if (!PREF.contains("Fonts_Big_Name")) {
PREF["Fonts_Big_Name"] = "Serif";
PREF["Fonts_Big_Size"] = 35;
PREF["Fonts_Big_Bold"] = false;
PREF["Fonts_Big_Italic"] = false;
if (!p_pref->contains("Fonts_Big_Name")) {
(*p_pref)["Fonts_Big_Name"] = "Serif";
(*p_pref)["Fonts_Big_Size"] = 35;
(*p_pref)["Fonts_Big_Bold"] = false;
(*p_pref)["Fonts_Big_Italic"] = false;
}
defaultfont = new QFont(PREF["Fonts_Graph_Name"].toString(),
PREF["Fonts_Graph_Size"].toInt(),
PREF["Fonts_Graph_Bold"].toBool() ? QFont::Bold : QFont::Normal,
PREF["Fonts_Graph_Italic"].toBool()
defaultfont = new QFont((*p_pref)["Fonts_Graph_Name"].toString(),
(*p_pref)["Fonts_Graph_Size"].toInt(),
(*p_pref)["Fonts_Graph_Bold"].toBool() ? QFont::Bold : QFont::Normal,
(*p_pref)["Fonts_Graph_Italic"].toBool()
);
mediumfont = new QFont(PREF["Fonts_Title_Name"].toString(),
PREF["Fonts_Title_Size"].toInt(),
PREF["Fonts_Title_Bold"].toBool() ? QFont::Bold : QFont::Normal,
PREF["Fonts_Title_Italic"].toBool()
mediumfont = new QFont((*p_pref)["Fonts_Title_Name"].toString(),
(*p_pref)["Fonts_Title_Size"].toInt(),
(*p_pref)["Fonts_Title_Bold"].toBool() ? QFont::Bold : QFont::Normal,
(*p_pref)["Fonts_Title_Italic"].toBool()
);
bigfont = new QFont(PREF["Fonts_Big_Name"].toString(),
PREF["Fonts_Big_Size"].toInt(),
PREF["Fonts_Big_Bold"].toBool() ? QFont::Bold : QFont::Normal,
PREF["Fonts_Big_Italic"].toBool()
bigfont = new QFont((*p_pref)["Fonts_Big_Name"].toString(),
(*p_pref)["Fonts_Big_Size"].toInt(),
(*p_pref)["Fonts_Big_Bold"].toBool() ? QFont::Bold : QFont::Normal,
(*p_pref)["Fonts_Big_Italic"].toBool()
);
defaultfont->setStyleHint(QFont::AnyStyle, QFont::OpenGLCompatible);

View File

@ -544,7 +544,7 @@ void Machine::setInfo(MachineInfo inf)
const QString Machine::getDataPath()
{
m_dataPath = PREF.Get("{home}/Profiles/")+profile->user->userName()+"/"+info.loadername + "_" + (info.serial.isEmpty() ? hexid() : info.serial) + "/";
m_dataPath = p_pref->Get("{home}/Profiles/")+profile->user->userName()+"/"+info.loadername + "_" + (info.serial.isEmpty() ? hexid() : info.serial) + "/";
//if (m_dataPath.isEmpty()) {
// m_dataPath = profile->Get("{" + STR_GEN_DataFolder + "}/" + info.loadername + "_" + (info.serial.isEmpty() ? hexid() : info.serial)) + "/";

View File

@ -42,7 +42,7 @@ Profile::Profile(QString path)
p_name = STR_GEN_Profile;
if (path.isEmpty()) {
p_path = GetAppRoot();
p_path = GetAppData();
} else {
p_path = path;
}
@ -493,7 +493,7 @@ void Profile::DataFormatError(Machine *m)
{
QString msg;
msg = "<font size=+1>"+QObject::tr("OSCT (%1) needs to upgrade its database for %2 %3 %4").
msg = "<font size=+1>"+QObject::tr("OSCAR (%1) needs to upgrade its database for %2 %3 %4").
arg(VersionString).
arg(m->brand()).arg(m->model()).arg(m->serial())
+ "</font><br/><br/>";
@ -900,10 +900,10 @@ Machine *Profile::GetMachine(MachineType t)
//{
// QMap<QDate, QList<Day *> >::iterator it_end = daylist.end();
// QMap<QDate, QList<Day *> >::iterator it;
//
// QList<QDate> datelist;
// QList<Day *> days;
//
// for (it = daylist.begin(); it != it_end; ++it) {
// for (int i = 0; i< it.value().size(); ++i) {
// Day * day = it.value().at(i);
@ -913,7 +913,7 @@ Machine *Profile::GetMachine(MachineType t)
// }
// }
// }
//
// for (int i=0; i < datelist.size(); ++i) {
// Day * day = days.at(i);
// it = daylist.find(datelist.at(i));
@ -925,7 +925,7 @@ Machine *Profile::GetMachine(MachineType t)
// }
// mach->unlinkDay(days.at(i));
// }
//
//}
bool Profile::unlinkDay(Day * day)
@ -953,7 +953,7 @@ QMap<QString, Profile *> profiles;
void Done()
{
PREF.Save();
p_pref->Save();
profiles.clear();
delete p_pref;
@ -973,7 +973,7 @@ Profile *Get(QString name)
Profile *Create(QString name)
{
QString path = PREF.Get("{home}/Profiles/") + name;
QString path = p_pref->Get("{home}/Profiles/") + name;
QDir dir(path);
if (!dir.exists(path)) {
@ -1009,7 +1009,7 @@ Profile *Get()
void saveProfileList()
{
QString filename = PREF.Get("{home}/profiles.xml");
QString filename = p_pref->Get("{home}/profiles.xml");
QDomDocument doc("profiles");
@ -1051,7 +1051,7 @@ int CleanupProfile(Profile *prof)
for (auto & prf :migrateList) {
if (prof->contains(prf)) {
qDebug() << "Migrating profile preference" << prf;
PREF[prf] = (*prof)[prf];
(*p_pref)[prf] = (*prof)[prf];
prof->Erase(prf);
cnt++;
}
@ -1068,8 +1068,9 @@ int CleanupProfile(Profile *prof)
*/
void Scan()
{
QString path = PREF.Get("{home}/Profiles");
QString path = p_pref->Get("{home}/Profiles");
QDir dir(path);
profiles.clear();
if (!dir.exists(path)) {
return;
@ -1101,7 +1102,7 @@ void Scan()
if (cleanup > 0) {
qDebug() << "Saving preferences after migration";
PREF.Save();
p_pref->Save();
}
// Update profiles.xml for mobile version
saveProfileList();

View File

@ -249,7 +249,7 @@ extern Preferences *p_pref;
extern Profile *p_profile;
// these are bad and must change
#define PREF (*p_pref)
// #define PREF (*p_pref)
//! \brief Returns a count of all files & directories in a supplied folder

View File

@ -885,26 +885,26 @@ bool PreferencesDialog::Save()
#endif
PREF["Fonts_Application_Name"] = ui->applicationFont->currentText();
PREF["Fonts_Application_Size"] = ui->applicationFontSize->value();
PREF["Fonts_Application_Bold"] = ui->applicationFontBold->isChecked();
PREF["Fonts_Application_Italic"] = ui->applicationFontItalic->isChecked();
(*p_pref)["Fonts_Application_Name"] = ui->applicationFont->currentText();
(*p_pref)["Fonts_Application_Size"] = ui->applicationFontSize->value();
(*p_pref)["Fonts_Application_Bold"] = ui->applicationFontBold->isChecked();
(*p_pref)["Fonts_Application_Italic"] = ui->applicationFontItalic->isChecked();
PREF["Fonts_Graph_Name"] = ui->graphFont->currentText();
PREF["Fonts_Graph_Size"] = ui->graphFontSize->value();
PREF["Fonts_Graph_Bold"] = ui->graphFontBold->isChecked();
PREF["Fonts_Graph_Italic"] = ui->graphFontItalic->isChecked();
(*p_pref)["Fonts_Graph_Name"] = ui->graphFont->currentText();
(*p_pref)["Fonts_Graph_Size"] = ui->graphFontSize->value();
(*p_pref)["Fonts_Graph_Bold"] = ui->graphFontBold->isChecked();
(*p_pref)["Fonts_Graph_Italic"] = ui->graphFontItalic->isChecked();
PREF["Fonts_Title_Name"] = ui->titleFont->currentText();
PREF["Fonts_Title_Size"] = ui->titleFontSize->value();
PREF["Fonts_Title_Bold"] = ui->titleFontBold->isChecked();
PREF["Fonts_Title_Italic"] = ui->titleFontItalic->isChecked();
(*p_pref)["Fonts_Title_Name"] = ui->titleFont->currentText();
(*p_pref)["Fonts_Title_Size"] = ui->titleFontSize->value();
(*p_pref)["Fonts_Title_Bold"] = ui->titleFontBold->isChecked();
(*p_pref)["Fonts_Title_Italic"] = ui->titleFontItalic->isChecked();
PREF["Fonts_Big_Name"] = ui->bigFont->currentText();
PREF["Fonts_Big_Size"] = ui->bigFontSize->value();
PREF["Fonts_Big_Bold"] = ui->bigFontBold->isChecked();
PREF["Fonts_Big_Italic"] = ui->bigFontItalic->isChecked();
(*p_pref)["Fonts_Big_Name"] = ui->bigFont->currentText();
(*p_pref)["Fonts_Big_Size"] = ui->bigFontSize->value();
(*p_pref)["Fonts_Big_Bold"] = ui->bigFontBold->isChecked();
(*p_pref)["Fonts_Big_Italic"] = ui->bigFontItalic->isChecked();
QFont font = ui->applicationFont->currentFont();
font.setPointSize(ui->applicationFontSize->value());
@ -933,7 +933,7 @@ bool PreferencesDialog::Save()
saveWaveInfo();
//qDebug() << "TODO: Save channels.xml to update channel data";
PREF.Save();
p_pref->Save();
profile->Save();
if (recompress_events) {

View File

@ -72,7 +72,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
#ifdef Q_WS_X11
printer->setPrinterName("Print to File (PDF)");
printer->setOutputFormat(QPrinter::PdfFormat);
QString filename = PREF.Get("{home}/" + name + username + date.toString(Qt::ISODate) + ".pdf");
QString filename = p_pref->Get("{home}/") + name + username + date.toString(Qt::ISODate) + ".pdf";
printer->setOutputFileName(filename);
#endif