From 17913ce7f7ad1ba13b959fe2aed26054b412de59 Mon Sep 17 00:00:00 2001 From: Alan Edwards Date: Tue, 15 Mar 2016 23:58:13 -0400 Subject: [PATCH 1/8] Removed TextLabel value Reference: code/sleepyhead#22 --- sleepyhead/newprofile.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sleepyhead/newprofile.ui b/sleepyhead/newprofile.ui index 29b04f8a..2ecd175f 100644 --- a/sleepyhead/newprofile.ui +++ b/sleepyhead/newprofile.ui @@ -864,7 +864,7 @@ - TextLabel + Qt::AlignCenter From 85485d383ec70f45ef2aa41470924a323735e8ce Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Thu, 17 Mar 2016 07:38:35 +1000 Subject: [PATCH 2/8] Be realistic and force reset channel names on every language change --- sleepyhead/SleepLib/common.h | 2 +- sleepyhead/SleepLib/schema.cpp | 3 ++- sleepyhead/main.cpp | 2 +- sleepyhead/mainwindow.cpp | 13 +++++++++---- sleepyhead/preferencesdialog.cpp | 3 --- sleepyhead/preferencesdialog.ui | 9 +-------- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/sleepyhead/SleepLib/common.h b/sleepyhead/SleepLib/common.h index 17dcf9cd..829777c2 100644 --- a/sleepyhead/SleepLib/common.h +++ b/sleepyhead/SleepLib/common.h @@ -123,7 +123,7 @@ const QString STR_GEN_UpdatesAutoCheck = "Updates_AutoCheck"; const QString STR_GEN_UpdateCheckFrequency = "Updates_CheckFrequency"; const QString STR_GEN_DataFolder = "DataFolder"; -const QString STR_PREF_AllowEventRenaming = "AllowEventRenaming"; +const QString STR_PREF_ResetChannelNames = "ResetChannelNames"; const QString STR_PREF_AllowEarlyUpdates = "AllowEarlyUpdates"; const QString STR_PREF_ReimportBackup = "ReimportBackup"; const QString STR_PREF_LastCPAPPath = "LastCPAPPath"; diff --git a/sleepyhead/SleepLib/schema.cpp b/sleepyhead/SleepLib/schema.cpp index 4437d19e..2ce84b86 100644 --- a/sleepyhead/SleepLib/schema.cpp +++ b/sleepyhead/SleepLib/schema.cpp @@ -106,6 +106,7 @@ void init() DataTypes["datetime"] = DATETIME; DataTypes["time"] = TIME; + // Note: Old channel names stored in channels.xml are not translatable.. they need to be moved to be defined AFTER here instead if (!schema::channel.Load(":/docs/channels.xml")) { QMessageBox::critical(0, STR_MessageBox_Error, QObject::tr("Couldn't parse Channels.xml, this build is seriously borked, no choice but to abort!!"), @@ -753,7 +754,7 @@ bool ChannelList::Load(QString filename) scope = Scopes[scopestr]; -// if (PREF[STR_PREF_AllowEventRenaming].toBool()) { +// if (PREF[STR_PREF_ResetEventNames].toBool()) { name = e.attribute("name", ""); details = e.attribute("details", ""); label = e.attribute("label", ""); diff --git a/sleepyhead/main.cpp b/sleepyhead/main.cpp index 98da0244..0388a2bb 100644 --- a/sleepyhead/main.cpp +++ b/sleepyhead/main.cpp @@ -402,7 +402,7 @@ retry_directory: PREF.init(STR_GEN_UpdateCheckFrequency, 7); // days PREF.init(STR_PREF_AllowEarlyUpdates, false); - PREF.init(STR_PREF_AllowEventRenaming, true); + PREF.init(STR_PREF_ResetChannelNames, false); //////////////////////////////////////////////////////////////////////////////////////////// // Check when last checked for updates.. diff --git a/sleepyhead/mainwindow.cpp b/sleepyhead/mainwindow.cpp index 7d65c519..f1a8d660 100644 --- a/sleepyhead/mainwindow.cpp +++ b/sleepyhead/mainwindow.cpp @@ -478,11 +478,12 @@ void loadChannels() chan->setDefaultColor(color); // Don't import channel descriptions if event renaming is turned off. (helps pick up new translations) - if (PREF[STR_PREF_AllowEventRenaming].toBool()) { + if (!PREF[STR_PREF_ResetChannelNames].toBool()) { chan->setFullname(fullname); chan->setLabel(label); chan->setDescription(description); } + PREF[STR_PREF_ResetChannelNames]=false; chan->setLowerThreshold(lowerThreshold); chan->setLowerThresholdColor(lowerThresholdColor); @@ -2567,9 +2568,13 @@ void MainWindow::on_actionHelp_Support_SleepyHead_Development_triggered() void MainWindow::on_actionChange_Language_triggered() { - //QSettings *settings = new QSettings(getDeveloperName(), getAppName()); - //settings->remove("Settings/Language"); - //delete settings; + // Pop up a message box asking if you would like to reset Channel event/waveform names + // Sorry Translators who frequently language hop, this is an extra step, but this one is for the users. :/ + if (QMessageBox::question(this,STR_MessageBox_Warning,tr("Changing the language will reset custom Event and Waveform names/labels/descriptions.")+"\n\n"+tr("Are you sure you want to do this?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { + return; + } + PREF[STR_PREF_ResetChannelNames]=true; + p_profile->Save(); PREF.Save(); diff --git a/sleepyhead/preferencesdialog.cpp b/sleepyhead/preferencesdialog.cpp index 50e7233c..60afa2da 100644 --- a/sleepyhead/preferencesdialog.cpp +++ b/sleepyhead/preferencesdialog.cpp @@ -201,8 +201,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : RefreshLastChecked(); } else { ui->updateLastChecked->setText("Never"); } - ui->allowEventRenaming->setChecked(PREF[STR_PREF_AllowEventRenaming].toBool()); - ui->overlayFlagsCombo->setCurrentIndex(profile->appearance->overlayType()); ui->overviewLinecharts->setCurrentIndex(profile->appearance->overviewLinechartMode()); @@ -805,7 +803,6 @@ bool PreferencesDialog::Save() PREF[STR_GEN_UpdatesAutoCheck] = ui->automaticallyCheckUpdates->isChecked(); PREF[STR_GEN_UpdateCheckFrequency] = ui->updateCheckEvery->value(); PREF[STR_PREF_AllowEarlyUpdates] = ui->allowEarlyUpdates->isChecked(); - PREF[STR_PREF_AllowEventRenaming] = ui->allowEventRenaming->isChecked(); PREF["Fonts_Application_Name"] = ui->applicationFont->currentText(); diff --git a/sleepyhead/preferencesdialog.ui b/sleepyhead/preferencesdialog.ui index 3c4a43ef..8be4c266 100644 --- a/sleepyhead/preferencesdialog.ui +++ b/sleepyhead/preferencesdialog.ui @@ -57,7 +57,7 @@ - 4 + 1 @@ -1244,13 +1244,6 @@ Defaults to 60 minutes.. Highly recommend it's left at this value. - - - - Allow Event Renaming - - - From 037289e6bed054e815584353ea12855b03b41e68 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Thu, 17 Mar 2016 08:56:59 +1000 Subject: [PATCH 3/8] Migrate some more old settings from old Channels.xml so they are translatable --- sleepyhead/SleepLib/machine_common.h | 2 + sleepyhead/SleepLib/schema.cpp | 164 ++++++++++++++++++++++++--- sleepyhead/docs/channels.xml | 22 ---- 3 files changed, 149 insertions(+), 39 deletions(-) diff --git a/sleepyhead/SleepLib/machine_common.h b/sleepyhead/SleepLib/machine_common.h index 2d4d88ea..510a8928 100644 --- a/sleepyhead/SleepLib/machine_common.h +++ b/sleepyhead/SleepLib/machine_common.h @@ -174,6 +174,8 @@ extern ChannelID POS_Orientation, POS_Inclination; const QString GRP_CPAP = "CPAP"; const QString GRP_POS = "POS"; const QString GRP_OXI = "OXI"; +const QString GRP_JOURNAL = "JOURNAL"; +const QString GRP_SLEEP = "SLEEP"; #endif // MACHINE_COMMON_H diff --git a/sleepyhead/SleepLib/schema.cpp b/sleepyhead/SleepLib/schema.cpp index 2ce84b86..f72d29ce 100644 --- a/sleepyhead/SleepLib/schema.cpp +++ b/sleepyhead/SleepLib/schema.cpp @@ -473,6 +473,136 @@ void init() ch->addOption(7, QObject::tr("ASV (Variable EPAP)")); ch->addOption(8, QObject::tr("AVAPS")); +// +// +// + + + // + schema::channel.add(GRP_JOURNAL, ch = new Channel(Journal_Weight = 0x0803, DATA, MT_JOURNAL, DAY, + "Weight", QObject::tr("Weight"), + QObject::tr("Weight"), + QObject::tr("Weight"), STR_UNIT_KG, + DOUBLE, Qt::black)); + +// Kids grow... but that adds a whole nother layer of complexity. + // + schema::channel.add(GRP_JOURNAL, ch = new Channel(0x0804, DATA, MT_JOURNAL, DAY, + "Height", QObject::tr("Height"), + QObject::tr("Physical Height"), + QObject::tr("Height"), STR_UNIT_CM, + DOUBLE, Qt::black)); + +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(0x0805, DATA, MT_JOURNAL, DAY, + "BookmarkNotes", QObject::tr("Notes"), + QObject::tr("Bookmark Notes"), + QObject::tr("Notes"), QString(), + STRING, Qt::black)); + +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(Journal_BMI = 0x0806, DATA, MT_JOURNAL, DAY, + "BMI", QObject::tr("BMI"), + QObject::tr("Body Mass Index"), + QObject::tr("BMI"), QString(), + DOUBLE, Qt::black)); + + +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(Journal_ZombieMeter = 0x0807, DATA, MT_JOURNAL, DAY, + "ZombieMeter", QObject::tr("Zombie"), + QObject::tr("How you feel (0 = like crap, 10 = unstoppable)"), + QObject::tr("Zombie"), QString(), + DOUBLE, Qt::black)); + +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(0x0808, DATA, MT_JOURNAL, DAY, + "BookmarkStart", QObject::tr("Start"), + QObject::tr("Bookmark Start"), + QObject::tr("Start"), QString(), + INTEGER, Qt::black)); +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(0x0809, DATA, MT_JOURNAL, DAY, + "BookmarkEnd", QObject::tr("End"), + QObject::tr("Bookmark End"), + QObject::tr("End"), QString(), + DOUBLE, Qt::black)); +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(0x080a, DATA, MT_JOURNAL, DAY, + "LastUpdated", QObject::tr("Last Updated"), + QObject::tr("Last Updated"), + QObject::tr("Last Updated"), QString(), + DATETIME, Qt::black)); +// + schema::channel.add(GRP_JOURNAL, ch = new Channel(Journal_Notes = 0xd000, DATA, MT_JOURNAL, DAY, + "Journal", QObject::tr("Journal Notes"), + QObject::tr("Journal Notes"), + QObject::tr("Journal"), QString(), + RICHTEXT, Qt::black)); + + +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_SleepStage = 0x2000, WAVEFORM, MT_SLEEPSTAGE, SESSION, + "SleepStage", QObject::tr("Sleep Stage"), + QObject::tr("1=Awake 2=REM 3=Light Sleep 4=Deep Sleep"), + QObject::tr("Sleep Stage"), QString(), + INTEGER, Qt::darkGray)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(0x2001, WAVEFORM, MT_SLEEPSTAGE, SESSION, + "ZeoBW", QObject::tr("Brain Wave"), + QObject::tr("Brain Wave"), + QObject::tr("BrainWave"), QString(), + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_Awakenings = 0x2002, DATA, MT_SLEEPSTAGE, SESSION, + "Awakenings", QObject::tr("Awakenings"), + QObject::tr("Number of Awakenings"), + QObject::tr("Awakenings"), QString(), + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_MorningFeel= 0x2003, DATA, MT_SLEEPSTAGE, SESSION, + "MorningFeel", QObject::tr("Morning Feel"), + QObject::tr("How you felt in the morning"), + QObject::tr("Morning Feel"), QString(), + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_TimeInWake = 0x2004, DATA, MT_SLEEPSTAGE, SESSION, + "TimeInWake", QObject::tr("Time Awake"), + QObject::tr("Time spent awake"), + QObject::tr("Time Awake"), STR_UNIT_Minutes, + INTEGER, Qt::black)); + +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_TimeInREM = 0x2005, DATA, MT_SLEEPSTAGE, SESSION, + "TimeInREM", QObject::tr("Time In REM Sleep"), + QObject::tr("Time spent in REM Sleep"), + QObject::tr("Time in REM Sleep"), STR_UNIT_Minutes, + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_TimeInLight = 0x2006, DATA, MT_SLEEPSTAGE, SESSION, + "TimeInLight", QObject::tr("Time In Light Sleep"), + QObject::tr("Time spent in light sleep"), + QObject::tr("Time in Light Sleep"), STR_UNIT_Minutes, + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_TimeInDeep= 0x2007, DATA, MT_SLEEPSTAGE, SESSION, + "TimeInDeep", QObject::tr("Time In Deep Sleep"), + QObject::tr("Time spent in deep sleep"), + QObject::tr("Time in Deep Sleep"), STR_UNIT_Minutes, + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_TimeInDeep= 0x2008, DATA, MT_SLEEPSTAGE, SESSION, + "TimeToZ", QObject::tr("Time to Sleep"), + QObject::tr("Time taken to get to sleep"), + QObject::tr("Time to Sleep"), STR_UNIT_Minutes, + INTEGER, Qt::black)); +// + schema::channel.add(GRP_SLEEP, ch = new Channel(ZEO_ZQ=0x2009, DATA, MT_SLEEPSTAGE, SESSION, + "ZeoZQ", QObject::tr("Zeo ZQ"), + QObject::tr("Zeo sleep quality measurement"), + QObject::tr("ZEO Zq"), QString(), + INTEGER, Qt::black)); + // //