]> sigrok.org Git - pulseview.git/blobdiff - pv/globalsettings.cpp
Add "start acquisition for all devices" option
[pulseview.git] / pv / globalsettings.cpp
index 614b983c40a45418fb6b986c367fd2fad2227ee9..4fa9bc334d27e4e470ca30afe0ae0d52715da9e9 100644 (file)
@@ -17,8 +17,9 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "globalsettings.hpp"
-#include "application.hpp"
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/serialization/serialization.hpp>
 
 #include <QApplication>
 #include <QColor>
 #include <QStyle>
 #include <QtGlobal>
 
+#include "globalsettings.hpp"
+#include "application.hpp"
+
 using std::map;
 using std::pair;
 using std::string;
+using std::stringstream;
 using std::vector;
 
 namespace pv {
@@ -47,6 +52,7 @@ const QString GlobalSettings::Key_General_Language = "General_Language";
 const QString GlobalSettings::Key_General_Theme = "General_Theme";
 const QString GlobalSettings::Key_General_Style = "General_Style";
 const QString GlobalSettings::Key_General_SaveWithSetup = "General_SaveWithSetup";
+const QString GlobalSettings::Key_General_StartAllSessions = "General_StartAllSessions";
 const QString GlobalSettings::Key_View_ZoomToFitDuringAcq = "View_ZoomToFitDuringAcq";
 const QString GlobalSettings::Key_View_ZoomToFitAfterAcq = "View_ZoomToFitAfterAcq";
 const QString GlobalSettings::Key_View_TriggerIsZeroTime = "View_TriggerIsZeroTime";
@@ -97,10 +103,11 @@ void GlobalSettings::set_defaults_where_needed()
 {
        if (!contains(Key_General_Language)) {
                // Determine and set default UI language
-               QString language = QLocale().uiLanguages().first();  // May return e.g. en-Latn-US
+               QString language = QLocale().uiLanguages().first();  // May return e.g. en-Latn-US  // clazy:exclude=detaching-temporary
                language = language.split("-").first();
 
                setValue(Key_General_Language, language);
+               apply_language();
        }
 
        // Use no theme by default
@@ -370,4 +377,28 @@ Glib::VariantBase GlobalSettings::restore_variantbase(QSettings &settings)
        return ret_val;
 }
 
+void GlobalSettings::store_timestamp(QSettings &settings, const char *name, const pv::util::Timestamp &ts)
+{
+       stringstream ss;
+       boost::archive::text_oarchive oa(ss);
+       oa << boost::serialization::make_nvp(name, ts);
+       settings.setValue(name, QString::fromStdString(ss.str()));
+}
+
+pv::util::Timestamp GlobalSettings::restore_timestamp(QSettings &settings, const char *name)
+{
+       util::Timestamp result;
+       stringstream ss;
+       ss << settings.value(name).toString().toStdString();
+
+       try {
+               boost::archive::text_iarchive ia(ss);
+               ia >> boost::serialization::make_nvp(name, result);
+       } catch (boost::archive::archive_exception&) {
+               qDebug() << "Could not restore setting" << name;
+       }
+
+       return result;
+}
+
 } // namespace pv