diff --git a/sleepyhead/SleepLib/machine.cpp b/sleepyhead/SleepLib/machine.cpp index 69468068..4fbd309d 100644 --- a/sleepyhead/SleepLib/machine.cpp +++ b/sleepyhead/SleepLib/machine.cpp @@ -955,7 +955,7 @@ bool Machine::LoadSummary(ProgressDialog * progress) QDomDocument doc; QFile file(filename); qDebug() << "Opening " << filename; - progress->setMessage(QObject::tr("Opening Summaries.xml.gz")); + progress->setMessage(QObject::tr("Loading Summaries.xml.gz")); QApplication::processEvents(); if (!file.open(QIODevice::ReadOnly)) { @@ -1059,8 +1059,8 @@ bool Machine::LoadSummary(ProgressDialog * progress) int cnt = 0; bool loadSummaries = profile->session->preloadSummaries(); - progress->setMessage(QObject::tr("Queueing Open Tasks")); - QApplication::processEvents(); + //progress->setMessage(QObject::tr("Queueing Open Tasks")); + //QApplication::processEvents(); // progress->setMaximum(sess_order.size()); for (it = sess_order.begin(); it != it_end; ++it, ++cnt) { @@ -1083,7 +1083,7 @@ bool Machine::LoadSummary(ProgressDialog * progress) } } } - progress->setMessage(QObject::tr("Loading Sessions")); + progress->setMessage(QObject::tr("Loading Summary Data")); QApplication::processEvents(); if (loader()) { diff --git a/sleepyhead/SleepLib/profiles.cpp b/sleepyhead/SleepLib/profiles.cpp index 376d75c6..a5017b99 100644 --- a/sleepyhead/SleepLib/profiles.cpp +++ b/sleepyhead/SleepLib/profiles.cpp @@ -963,8 +963,9 @@ void Done() Profile *Get(QString name) { - if (profiles.find(name) != profiles.end()) { - return profiles[name]; + auto it = profiles.find(name); + if (it != profiles.end()) { + return it.value(); } return nullptr; @@ -987,7 +988,7 @@ Profile *Create(QString name) //if (!password.isEmpty()) p_profile.user->setPassword(password); p_profile->Set(STR_GEN_DataFolder, QString("{home}/Profiles/{") + QString(STR_UI_UserName) + QString("}")); - Machine *m = new Machine(0); + Machine *m = new Machine(p_profile, 0); m->setType(MT_JOURNAL); MachineInfo info(MT_JOURNAL, 0, STR_MACH_Journal, "SleepyHead", STR_MACH_Journal, QString(), m->hexid(), QString(), QDateTime::currentDateTime(), 0); diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index eae114e0..d5ccc30e 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -822,9 +822,9 @@ QString Daily::getSessionInformation(Day * day) html+=QString(""+tr("Session Information")+""); html+=" "; QFontMetrics FM(*defaultfont); - QRect r=FM.boundingRect('@'); +// QRect r=FM.boundingRect('@'); - Machine * cpap = day->machine(MT_CPAP); + // Machine * cpap = day->machine(MT_CPAP); QDateTime fd,ld; bool corrupted_waveform=false; @@ -1834,7 +1834,7 @@ Session * Daily::CreateJournalSession(QDate date) { Machine *m = p_profile->GetMachine(MT_JOURNAL); if (!m) { - m=new Machine(0); + m=new Machine(p_profile, 0); MachineInfo info; info.loadername = "Journal"; info.serial = m->hexid(); diff --git a/sleepyhead/mainwindow.cpp b/sleepyhead/mainwindow.cpp index b70606f3..74ac723d 100644 --- a/sleepyhead/mainwindow.cpp +++ b/sleepyhead/mainwindow.cpp @@ -390,7 +390,7 @@ void MainWindow::firstRunMessage() QString GenerateWelcomeHTML(); -bool MainWindow::OpenProfile(QString profileName) +bool MainWindow::OpenProfile(QString profileName, bool skippassword) { auto pit = Profiles::profiles.find(profileName); if (pit == Profiles::profiles.end()) return false; @@ -404,7 +404,7 @@ bool MainWindow::OpenProfile(QString profileName) return false; } } - prof = profileSelector->SelectProfile(profileName); // asks for the password and updates stuff in profileSelector tab + prof = profileSelector->SelectProfile(profileName, skippassword); // asks for the password and updates stuff in profileSelector tab if (!prof) { return false; } @@ -475,7 +475,7 @@ bool MainWindow::OpenProfile(QString profileName) } p_profile->LoadMachineData(progress); - progress->setMessage(tr("Setting up profile \"%1\"").arg(profileName)); + progress->setMessage(tr("Loading profile \"%1\"").arg(profileName)); // Show the sheep? // QPixmap sheep=QPixmap(":/docs/sheep.png").scaled(64,64); diff --git a/sleepyhead/mainwindow.h b/sleepyhead/mainwindow.h index 06233aaa..4ce8856d 100644 --- a/sleepyhead/mainwindow.h +++ b/sleepyhead/mainwindow.h @@ -93,7 +93,7 @@ class MainWindow : public QMainWindow void CheckForUpdates(); void CloseProfile(); - bool OpenProfile(QString name); + bool OpenProfile(QString name, bool skippassword = false); /*! \fn Notify(QString s,int ms=5000, QString title="SleepyHead v"+VersionString()); \brief Pops up a message box near the system tray diff --git a/sleepyhead/profileselector.cpp b/sleepyhead/profileselector.cpp index d5ada8b6..678e8a07 100644 --- a/sleepyhead/profileselector.cpp +++ b/sleepyhead/profileselector.cpp @@ -210,7 +210,7 @@ void ProfileSelector::updateProfileHighlight(QString name) } } -Profile *ProfileSelector::SelectProfile(QString profname) +Profile *ProfileSelector::SelectProfile(QString profname, bool skippassword=false) { qDebug() << "Selecting new profile" << profname; @@ -220,7 +220,7 @@ Profile *ProfileSelector::SelectProfile(QString profname) Profile * prof = pit.value(); if (prof != p_profile) { - if (prof->user->hasPassword()) { + if (prof->user->hasPassword() && !skippassword) { QDialog dialog(this, Qt::Dialog); QLineEdit *e = new QLineEdit(&dialog); e->setEchoMode(QLineEdit::Password); @@ -333,7 +333,7 @@ void ProfileSelector::on_buttonNewProfile_clicked() if (p_profile != nullptr) { QString name = p_profile->user->userName(); p_profile = nullptr; - SelectProfile(name); + mainwin->OpenProfile(name, true); // open profile, skipping the already entered password } else { qWarning() << AppSetting->profileName() << "yielded a null profile"; p_profile=nullptr; diff --git a/sleepyhead/profileselector.h b/sleepyhead/profileselector.h index 9f52d692..cb57b0f5 100644 --- a/sleepyhead/profileselector.h +++ b/sleepyhead/profileselector.h @@ -37,7 +37,7 @@ public: ~ProfileSelector(); void updateProfileList(); - Profile *SelectProfile(QString profname); + Profile *SelectProfile(QString profname, bool skippassword); void updateProfileHighlight(QString name); private slots: