20 #include <boost/archive/text_iarchive.hpp> 21 #include <boost/archive/text_oarchive.hpp> 22 #include <boost/serialization/serialization.hpp> 24 #include <QApplication> 28 #include <QFontMetrics> 29 #include <QPixmapCache> 40 using std::stringstream;
45 const vector< pair<QString, QString> >
Themes {
47 {
"QDarkStyleSheet",
":/themes/qdarkstyle/style.qss"},
48 {
"DarkStyle",
":/themes/darkstyle/darkstyle.qss"}
92 beginGroup(
"Settings");
108 QString language = QLocale().uiLanguages().first();
109 language = language.split(
"-").first();
147 3 * QFontMetrics(QApplication::font()).height());
151 2 * QFontMetrics(QApplication::font()).height());
189 QColor(0, 0, 0, 5 * 256 / 100).rgba());
192 QColor(220, 231, 243).rgba());
198 QColor(188, 188, 188, 9 * 256 / 100).rgba());
201 QColor(60, 60, 60).rgba());
214 if (!resource_name.isEmpty()) {
215 QFile
file(resource_name);
216 file.open(QFile::ReadOnly | QFile::Text);
217 qApp->setStyleSheet(file.readAll());
219 qApp->setStyleSheet(
"");
227 qApp->setStyle(style);
231 if (theme_name.compare(
"QDarkStyleSheet") == 0) {
232 QPalette dark_palette;
233 dark_palette.setColor(QPalette::Window, QColor(53, 53, 53));
234 dark_palette.setColor(QPalette::WindowText, Qt::white);
235 dark_palette.setColor(QPalette::Base, QColor(42, 42, 42));
236 dark_palette.setColor(QPalette::Dark, QColor(35, 35, 35));
237 dark_palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
238 qApp->setPalette(dark_palette);
240 }
else if (theme_name.compare(
"DarkStyle") == 0) {
241 QPalette dark_palette;
242 dark_palette.setColor(QPalette::Window, QColor(53, 53, 53));
243 dark_palette.setColor(QPalette::WindowText, Qt::white);
244 dark_palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(127, 127, 127));
245 dark_palette.setColor(QPalette::Base, QColor(42, 42, 42));
246 dark_palette.setColor(QPalette::AlternateBase, QColor(66, 66, 66));
247 dark_palette.setColor(QPalette::ToolTipBase, Qt::white);
248 dark_palette.setColor(QPalette::ToolTipText, QColor(53, 53, 53));
249 dark_palette.setColor(QPalette::Text, Qt::white);
250 dark_palette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
251 dark_palette.setColor(QPalette::Dark, QColor(35, 35, 35));
252 dark_palette.setColor(QPalette::Shadow, QColor(20, 20, 20));
253 dark_palette.setColor(QPalette::Button, QColor(53, 53, 53));
254 dark_palette.setColor(QPalette::ButtonText, Qt::white);
255 dark_palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(127, 127, 127));
256 dark_palette.setColor(QPalette::BrightText, Qt::red);
257 dark_palette.setColor(QPalette::Link, QColor(42, 130, 218));
258 dark_palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
259 dark_palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
260 dark_palette.setColor(QPalette::HighlightedText, Qt::white);
261 dark_palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(127, 127, 127));
262 qApp->setPalette(dark_palette);
266 QPixmapCache::clear();
296 QSettings::setValue(key, value);
299 qDebug() <<
"Setting" << key <<
"changed to" <<
value;
303 cb->on_setting_changed(key, value);
323 setValue(entry.first, entry.second);
325 tracked_changes_.clear();
330 const GVariantType *var_type = g_variant_get_type(v);
331 char *var_type_str = g_variant_type_dup_string(var_type);
333 QByteArray var_data = QByteArray((
const char*)g_variant_get_data(v),
334 g_variant_get_size(v));
336 settings.setValue(
"value", var_data);
337 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 338 settings.setValue(
"type", (
const char *)var_type_str);
340 settings.setValue(
"type", var_type_str);
343 g_free(var_type_str);
348 QString raw_type = settings.value(
"type").toString();
349 GVariantType *var_type = g_variant_type_new(raw_type.toUtf8());
351 QByteArray
data = settings.value(
"value").toByteArray();
353 #if GLIB_CHECK_VERSION(2, 67, 3) // See https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538 354 gpointer var_data = g_memdup2((gconstpointer)data.constData(), (gsize)data.size());
356 gpointer var_data = g_memdup((gconstpointer)data.constData(), (guint)data.size());
359 GVariant *
value = g_variant_new_from_data(var_type, var_data,
360 data.size(),
false, g_free, var_data);
362 g_variant_type_free(var_type);
369 const QByteArray var_data = QByteArray((
const char*)v.get_data(), v.get_size());
371 settings.setValue(
"value", var_data);
372 settings.setValue(
"type", QString::fromStdString(v.get_type_string()));
377 QString raw_type = settings.value(
"type").toString();
378 GVariantType *var_type = g_variant_type_new(raw_type.toUtf8());
380 QByteArray
data = settings.value(
"value").toByteArray();
382 #if GLIB_CHECK_VERSION(2, 67, 3) // See https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538 383 gpointer var_data = g_memdup2((gconstpointer)data.constData(), (gsize)data.size());
385 gpointer var_data = g_memdup((gconstpointer)data.constData(), (guint)data.size());
388 GVariant *
value = g_variant_new_from_data(var_type, var_data,
389 data.size(),
false, g_free, var_data);
391 Glib::VariantBase ret_val = Glib::VariantBase(value,
true);
393 g_variant_type_free(var_type);
394 g_variant_unref(value);
402 boost::archive::text_oarchive oa(ss);
403 oa << boost::serialization::make_nvp(name, ts);
404 settings.setValue(name, QString::fromStdString(ss.str()));
411 ss << settings.value(name).toString().toStdString();
414 boost::archive::text_iarchive ia(ss);
415 ia >> boost::serialization::make_nvp(name, result);
416 }
catch (boost::archive::archive_exception&) {
417 qDebug() <<
"Could not restore setting" << name;
static void store_gvariant(QSettings &settings, GVariant *v)
void save_internal_defaults()
static const QString Key_General_SaveWithSetup
const vector< pair< QString, QString > > Themes
static bool is_dark_theme_
static map< QString, QVariant > tracked_changes_
static const QString Key_View_KeepRulerItemSelected
static vector< GlobalSettingsInterface * > callbacks_
static QPalette default_palette_
static const QString Key_Log_BufferSize
static const QString Key_View_ShowAnalogMinorGrid
static const QString Key_View_FillSignalHighAreaColor
static const QString Key_View_DefaultDivHeight
static pv::util::Timestamp restore_timestamp(QSettings &settings, const char *name)
T value(details::expression_node< T > *n)
static const QString Key_General_Style
static const QString Key_Log_NotifyOfStacktrace
static const QString Key_Dec_AlwaysShowAllRows
static const QString Key_View_SnapDistance
static const QString Key_View_TriggerIsZeroTime
static const QString Key_View_CursorShowSamples
static const QString Key_General_StartAllSessions
static const QString Key_General_Language
void set_defaults_where_needed()
static bool current_theme_is_dark()
static const QString Key_View_DefaultLogicHeight
static const QString Key_View_CursorFillColor
libsigrok allows users to import and export data from files in various formats some of them as generic as others very specific For a list and make sure to check not so common and outright exotic ways to represent data and sigrok tries to suit as many needs as it can To see which formats your version of PulseView just click on the small arrow next to the _Open_ PulseView will ask for the file name to open Once you picked the file
static QString default_style_
static const QString Key_View_StickyScrolling
static void remove_change_handler(GlobalSettingsInterface *cb)
static void store_timestamp(QSettings &settings, const char *name, const pv::util::Timestamp &ts)
static Glib::VariantBase restore_variantbase(QSettings &settings)
void setValue(const QString &key, const QVariant &value)
static const QString Key_General_Theme
static const QString Key_View_CursorShowFrequency
static const QString Key_View_ShowHoverMarker
void undo_tracked_changes()
static const QString Key_View_AllowVerticalDragging
static const QString Key_Dec_InitialStateConfigurable
static const QString Key_View_ConversionThresholdDispMode
static const QString Key_View_ZoomToFitAfterAcq
static void store_variantbase(QSettings &settings, Glib::VariantBase v)
static const QString Key_View_ShowSamplingPoints
static const QString Key_View_ZoomToFitDuringAcq
static const QString Key_View_FillSignalHighAreas
void switch_language(const QString &language)
static const QString Key_View_CursorShowInterval
static GVariant * restore_gvariant(QSettings &settings)
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
void set_dark_theme_default_colors()
void set_bright_theme_default_colors()
static const QString Key_Dec_ExportFormat
static void add_change_handler(GlobalSettingsInterface *cb)
static const QString Key_View_ColoredBG