mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core/tests: merge Animations and add vars. to qPrefDisplay
Add class variable tooltip_position to qPrefDisplay Add class variable lastDir to qPrefDisplay qPrefDisplay is updated to use new qPrefPrivate functions Adjust test cases incl. qml tests qPrefAnimations only has 1 variable, that really is a display variable Merge the variable into qPrefDisplay, to simplify setup (and avoid loading extra page in qml). correct theme to save in correct place, and make it a static class variable Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
82b626b3fd
commit
ebc0e6d3f3
22 changed files with 257 additions and 220 deletions
|
@ -103,7 +103,6 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
||||||
|
|
||||||
# classes to manage struct preferences for QWidget and QML
|
# classes to manage struct preferences for QWidget and QML
|
||||||
settings/qPref.cpp
|
settings/qPref.cpp
|
||||||
settings/qPrefAnimations.cpp
|
|
||||||
settings/qPrefCloudStorage.cpp
|
settings/qPrefCloudStorage.cpp
|
||||||
settings/qPrefDisplay.cpp
|
settings/qPrefDisplay.cpp
|
||||||
settings/qPrefDiveComputer.cpp
|
settings/qPrefDiveComputer.cpp
|
||||||
|
|
|
@ -109,7 +109,6 @@ struct preferences {
|
||||||
const char *divelist_font;
|
const char *divelist_font;
|
||||||
double font_size;
|
double font_size;
|
||||||
bool show_developer;
|
bool show_developer;
|
||||||
const char *theme;
|
|
||||||
|
|
||||||
// ********** Facebook **********
|
// ********** Facebook **********
|
||||||
facebook_prefs_t facebook;
|
facebook_prefs_t facebook;
|
||||||
|
|
|
@ -16,7 +16,6 @@ void qPref::loadSync(bool doSync)
|
||||||
if (!doSync)
|
if (!doSync)
|
||||||
uiLanguage(NULL);
|
uiLanguage(NULL);
|
||||||
|
|
||||||
qPrefAnimations::instance()->loadSync(doSync);
|
|
||||||
qPrefCloudStorage::instance()->loadSync(doSync);
|
qPrefCloudStorage::instance()->loadSync(doSync);
|
||||||
qPrefDisplay::instance()->loadSync(doSync);
|
qPrefDisplay::instance()->loadSync(doSync);
|
||||||
qPrefDiveComputer::instance()->loadSync(doSync);
|
qPrefDiveComputer::instance()->loadSync(doSync);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "qPrefAnimations.h"
|
|
||||||
#include "qPrefCloudStorage.h"
|
#include "qPrefCloudStorage.h"
|
||||||
#include "qPrefDisplay.h"
|
#include "qPrefDisplay.h"
|
||||||
#include "qPrefDiveComputer.h"
|
#include "qPrefDiveComputer.h"
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#include "qPrefAnimations.h"
|
|
||||||
#include "qPrefPrivate.h"
|
|
||||||
|
|
||||||
static const QString group = QStringLiteral("Animations");
|
|
||||||
|
|
||||||
qPrefAnimations::qPrefAnimations(QObject *parent) : QObject(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
qPrefAnimations *qPrefAnimations::instance()
|
|
||||||
{
|
|
||||||
static qPrefAnimations *self = new qPrefAnimations;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qPrefAnimations::loadSync(bool doSync)
|
|
||||||
{
|
|
||||||
disk_animation_speed(doSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE_PREFERENCE_INT(Animations, "/animation_speed", animation_speed);
|
|
|
@ -1,35 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#ifndef QPREFANIMATIONS_H
|
|
||||||
#define QPREFANIMATIONS_H
|
|
||||||
#include "core/pref.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class qPrefAnimations : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(int animation_speed READ animation_speed WRITE set_animation_speed NOTIFY animation_speed_changed);
|
|
||||||
|
|
||||||
public:
|
|
||||||
qPrefAnimations(QObject *parent = NULL);
|
|
||||||
static qPrefAnimations *instance();
|
|
||||||
|
|
||||||
// Load/Sync local settings (disk) and struct preference
|
|
||||||
static void loadSync(bool doSync);
|
|
||||||
static void load() { loadSync(false); }
|
|
||||||
static void sync() { loadSync(true); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
static int animation_speed() { return prefs.animation_speed; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
static void set_animation_speed(int value);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void animation_speed_changed(int value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// functions to load/sync variable with disk
|
|
||||||
static void disk_animation_speed(bool doSync);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -8,6 +8,39 @@
|
||||||
|
|
||||||
static const QString group = QStringLiteral("Display");
|
static const QString group = QStringLiteral("Display");
|
||||||
|
|
||||||
|
QPointF qPrefDisplay::st_tooltip_position;
|
||||||
|
static const QPointF st_tooltip_position_default = QPointF(0,0);
|
||||||
|
|
||||||
|
QString qPrefDisplay::st_lastDir;
|
||||||
|
static const QString st_lastDir_default = "";
|
||||||
|
|
||||||
|
QString qPrefDisplay::st_theme;
|
||||||
|
static const QString st_theme_default = "Blue";
|
||||||
|
|
||||||
|
QString qPrefDisplay::st_UserSurvey;
|
||||||
|
static const QString st_UserSurvey_default = "";
|
||||||
|
|
||||||
|
QByteArray qPrefDisplay::st_mainSplitter;
|
||||||
|
static const QByteArray st_mainSplitter_default = "";
|
||||||
|
|
||||||
|
QByteArray qPrefDisplay::st_topSplitter;
|
||||||
|
static const QByteArray st_topSplitter_default = "";
|
||||||
|
|
||||||
|
QByteArray qPrefDisplay::st_bottomSplitter;
|
||||||
|
static const QByteArray st_bottomSplitter_default = "";
|
||||||
|
|
||||||
|
bool qPrefDisplay::st_maximized;
|
||||||
|
static bool st_maximized_default = false;
|
||||||
|
|
||||||
|
QByteArray qPrefDisplay::st_geometry;
|
||||||
|
static const QByteArray st_geometry_default = 0;
|
||||||
|
|
||||||
|
QByteArray qPrefDisplay::st_windowState;
|
||||||
|
static const QByteArray st_windowState_default = 0;
|
||||||
|
|
||||||
|
int qPrefDisplay::st_lastState;
|
||||||
|
static int st_lastState_default = false;
|
||||||
|
|
||||||
qPrefDisplay::qPrefDisplay(QObject *parent) : QObject(parent)
|
qPrefDisplay::qPrefDisplay(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -19,11 +52,16 @@ qPrefDisplay *qPrefDisplay::instance()
|
||||||
|
|
||||||
void qPrefDisplay::loadSync(bool doSync)
|
void qPrefDisplay::loadSync(bool doSync)
|
||||||
{
|
{
|
||||||
|
disk_animation_speed(doSync);
|
||||||
disk_divelist_font(doSync);
|
disk_divelist_font(doSync);
|
||||||
disk_font_size(doSync);
|
disk_font_size(doSync);
|
||||||
disk_display_invalid_dives(doSync);
|
disk_display_invalid_dives(doSync);
|
||||||
disk_show_developer(doSync);
|
disk_show_developer(doSync);
|
||||||
disk_theme(doSync);
|
if (!doSync) {
|
||||||
|
load_tooltip_position();
|
||||||
|
load_theme();
|
||||||
|
load_UserSurvey();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qPrefDisplay::set_divelist_font(const QString &value)
|
void qPrefDisplay::set_divelist_font(const QString &value)
|
||||||
|
@ -69,13 +107,13 @@ void qPrefDisplay::disk_font_size(bool doSync)
|
||||||
setCorrectFont();
|
setCorrectFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//JAN static const QString group = QStringLiteral("Animations");
|
||||||
|
HANDLE_PREFERENCE_INT(Display, "/animation_speed", animation_speed);
|
||||||
|
|
||||||
HANDLE_PREFERENCE_BOOL(Display, "/displayinvalid", display_invalid_dives);
|
HANDLE_PREFERENCE_BOOL(Display, "/displayinvalid", display_invalid_dives);
|
||||||
|
|
||||||
HANDLE_PREFERENCE_BOOL(Display, "/show_developer", show_developer);
|
HANDLE_PREFERENCE_BOOL(Display, "/show_developer", show_developer);
|
||||||
|
|
||||||
HANDLE_PREFERENCE_TXT(Display, "/theme", theme);
|
|
||||||
|
|
||||||
|
|
||||||
void qPrefDisplay::setCorrectFont()
|
void qPrefDisplay::setCorrectFont()
|
||||||
{
|
{
|
||||||
// get the font from the settings or our defaults
|
// get the font from the settings or our defaults
|
||||||
|
@ -102,3 +140,25 @@ void qPrefDisplay::setCorrectFont()
|
||||||
|
|
||||||
prefs.display_invalid_dives = qPrefPrivate::propValue(group + "/displayinvalid", default_prefs.display_invalid_dives).toBool();
|
prefs.display_invalid_dives = qPrefPrivate::propValue(group + "/displayinvalid", default_prefs.display_invalid_dives).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HANDLE_PROP_QSTRING(Display, "FileDialog/LastDir", lastDir);
|
||||||
|
|
||||||
|
HANDLE_PROP_QSTRING(Display, "Theme/currentTheme", theme);
|
||||||
|
|
||||||
|
HANDLE_PROP_QPOINTF(Display, "ProfileMap/tooltip_position", tooltip_position);
|
||||||
|
|
||||||
|
HANDLE_PROP_QSTRING(Display, "UserSurvey/SurveyDone", UserSurvey);
|
||||||
|
|
||||||
|
HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/mainSplitter", mainSplitter);
|
||||||
|
|
||||||
|
HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/topSplitter", topSplitter);
|
||||||
|
|
||||||
|
HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/bottomSplitter", bottomSplitter);
|
||||||
|
|
||||||
|
HANDLE_PROP_BOOL(Display, "MainWindow/maximized", maximized);
|
||||||
|
|
||||||
|
HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/geometry", geometry);
|
||||||
|
|
||||||
|
HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/windowState", windowState);
|
||||||
|
|
||||||
|
HANDLE_PROP_INT(Display, "MainWindow/lastState", lastState);
|
||||||
|
|
|
@ -4,14 +4,26 @@
|
||||||
#include "core/pref.h"
|
#include "core/pref.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPointF>
|
||||||
|
|
||||||
class qPrefDisplay : public QObject {
|
class qPrefDisplay : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int animation_speed READ animation_speed WRITE set_animation_speed NOTIFY animation_speed_changed);
|
||||||
Q_PROPERTY(QString divelist_font READ divelist_font WRITE set_divelist_font NOTIFY divelist_font_changed);
|
Q_PROPERTY(QString divelist_font READ divelist_font WRITE set_divelist_font NOTIFY divelist_font_changed);
|
||||||
Q_PROPERTY(double font_size READ font_size WRITE set_font_size NOTIFY font_size_changed);
|
Q_PROPERTY(double font_size READ font_size WRITE set_font_size NOTIFY font_size_changed);
|
||||||
Q_PROPERTY(bool display_invalid_dives READ display_invalid_dives WRITE set_display_invalid_dives NOTIFY display_invalid_dives_changed);
|
Q_PROPERTY(bool display_invalid_dives READ display_invalid_dives WRITE set_display_invalid_dives NOTIFY display_invalid_dives_changed);
|
||||||
|
Q_PROPERTY(QString lastDir READ lastDir WRITE set_lastDir NOTIFY lastDir_changed);
|
||||||
Q_PROPERTY(bool show_developer READ show_developer WRITE set_show_developer NOTIFY show_developer_changed);
|
Q_PROPERTY(bool show_developer READ show_developer WRITE set_show_developer NOTIFY show_developer_changed);
|
||||||
Q_PROPERTY(QString theme READ theme WRITE set_theme NOTIFY theme_changed);
|
Q_PROPERTY(QString theme READ theme WRITE set_theme NOTIFY theme_changed);
|
||||||
|
Q_PROPERTY(QPointF tooltip_position READ tooltip_position WRITE set_tooltip_position NOTIFY tooltip_position_changed);
|
||||||
|
Q_PROPERTY(QString UserSurvey READ UserSurvey WRITE set_UserSurvey NOTIFY UserSurvey_changed);
|
||||||
|
Q_PROPERTY(QByteArray mainSplitter READ mainSplitter WRITE set_mainSplitter NOTIFY mainSplitter_changed);
|
||||||
|
Q_PROPERTY(QByteArray topSplitter READ topSplitter WRITE set_topSplitter NOTIFY topSplitter_changed);
|
||||||
|
Q_PROPERTY(QByteArray bottomSplitter READ bottomSplitter WRITE set_bottomSplitter NOTIFY bottomSplitter_changed);
|
||||||
|
Q_PROPERTY(bool maximized READ maximized WRITE set_maximized NOTIFY maximized_changed);
|
||||||
|
Q_PROPERTY(QByteArray geometry READ geometry WRITE set_geometry NOTIFY geometry_changed);
|
||||||
|
Q_PROPERTY(QByteArray windowState READ windowState WRITE set_windowState NOTIFY windowState_changed);
|
||||||
|
Q_PROPERTY(int lastState READ lastState WRITE set_lastState NOTIFY lastState_changed);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qPrefDisplay(QObject *parent = NULL);
|
qPrefDisplay(QObject *parent = NULL);
|
||||||
|
@ -23,35 +35,94 @@ public:
|
||||||
static void sync() { loadSync(true); }
|
static void sync() { loadSync(true); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static int animation_speed() { return prefs.animation_speed; }
|
||||||
static QString divelist_font() { return prefs.divelist_font; }
|
static QString divelist_font() { return prefs.divelist_font; }
|
||||||
static double font_size() { return prefs.font_size; }
|
static double font_size() { return prefs.font_size; }
|
||||||
static bool display_invalid_dives() { return prefs.display_invalid_dives; }
|
static bool display_invalid_dives() { return prefs.display_invalid_dives; }
|
||||||
|
static QString lastDir() { return st_lastDir; ; }
|
||||||
static bool show_developer() { return prefs.show_developer; }
|
static bool show_developer() { return prefs.show_developer; }
|
||||||
static QString theme() { return prefs.theme; }
|
static QString theme() { return st_theme; }
|
||||||
|
static QPointF tooltip_position() { return st_tooltip_position; }
|
||||||
|
static QString UserSurvey() { return st_UserSurvey; }
|
||||||
|
static QByteArray mainSplitter() { return st_mainSplitter; }
|
||||||
|
static QByteArray topSplitter() { return st_topSplitter; }
|
||||||
|
static QByteArray bottomSplitter() { return st_bottomSplitter; }
|
||||||
|
static bool maximized() { return st_maximized; }
|
||||||
|
static QByteArray geometry() { return st_geometry; }
|
||||||
|
static QByteArray windowState() { return st_windowState; }
|
||||||
|
static int lastState() { return st_lastState; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
static void set_animation_speed(int value);
|
||||||
static void set_divelist_font(const QString &value);
|
static void set_divelist_font(const QString &value);
|
||||||
static void set_font_size(double value);
|
static void set_font_size(double value);
|
||||||
static void set_display_invalid_dives(bool value);
|
static void set_display_invalid_dives(bool value);
|
||||||
|
static void set_lastDir(const QString &value);
|
||||||
static void set_show_developer(bool value);
|
static void set_show_developer(bool value);
|
||||||
static void set_theme(const QString &value);
|
static void set_theme(const QString &value);
|
||||||
|
static void set_tooltip_position(const QPointF &value);
|
||||||
|
static void set_UserSurvey(const QString &value);
|
||||||
|
static void set_mainSplitter(const QByteArray &value);
|
||||||
|
static void set_topSplitter(const QByteArray &value);
|
||||||
|
static void set_bottomSplitter(const QByteArray &value);
|
||||||
|
static void set_maximized(bool value);
|
||||||
|
static void set_geometry(const QByteArray& value);
|
||||||
|
static void set_windowState(const QByteArray& value);
|
||||||
|
static void set_lastState(int value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void animation_speed_changed(int value);
|
||||||
void divelist_font_changed(const QString &value);
|
void divelist_font_changed(const QString &value);
|
||||||
void font_size_changed(double value);
|
void font_size_changed(double value);
|
||||||
void display_invalid_dives_changed(bool value);
|
void display_invalid_dives_changed(bool value);
|
||||||
|
void lastDir_changed(const QString &value);
|
||||||
void show_developer_changed(bool value);
|
void show_developer_changed(bool value);
|
||||||
void theme_changed(const QString &value);
|
void theme_changed(const QString &value);
|
||||||
|
void tooltip_position_changed(const QPointF &value);
|
||||||
|
void UserSurvey_changed(const QString &value);
|
||||||
|
void mainSplitter_changed(const QByteArray &value);
|
||||||
|
void topSplitter_changed(const QByteArray &value);
|
||||||
|
void bottomSplitter_changed(const QByteArray &value);
|
||||||
|
void maximized_changed(bool value);
|
||||||
|
void geometry_changed(const QByteArray& value);
|
||||||
|
void windowState_changed(const QByteArray& value);
|
||||||
|
void lastState_changed(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// functions to load/sync variable with disk
|
// functions to load/sync variable with disk
|
||||||
|
static void disk_animation_speed(bool doSync);
|
||||||
static void disk_divelist_font(bool doSync);
|
static void disk_divelist_font(bool doSync);
|
||||||
static void disk_font_size(bool doSync);
|
static void disk_font_size(bool doSync);
|
||||||
static void disk_display_invalid_dives(bool doSync);
|
static void disk_display_invalid_dives(bool doSync);
|
||||||
static void disk_show_developer(bool doSync);
|
static void disk_show_developer(bool doSync);
|
||||||
static void disk_theme(bool doSync);
|
|
||||||
|
// functions to handle class variables
|
||||||
|
static void load_lastDir();
|
||||||
|
static void load_theme();
|
||||||
|
static void load_tooltip_position();
|
||||||
|
static void load_UserSurvey();
|
||||||
|
static void load_mainSplitter();
|
||||||
|
static void load_topSplitter();
|
||||||
|
static void load_bottomSplitter();
|
||||||
|
static void load_maximized();
|
||||||
|
static void load_geometry();
|
||||||
|
static void load_windowState();
|
||||||
|
static void load_lastState();
|
||||||
|
|
||||||
// font helper function
|
// font helper function
|
||||||
static void setCorrectFont();
|
static void setCorrectFont();
|
||||||
|
|
||||||
|
// Class variables not present in structure preferences
|
||||||
|
static QString st_lastDir;
|
||||||
|
static QString st_theme;
|
||||||
|
static QPointF st_tooltip_position;
|
||||||
|
static QString st_UserSurvey;
|
||||||
|
static QByteArray st_mainSplitter;
|
||||||
|
static QByteArray st_topSplitter;
|
||||||
|
static QByteArray st_bottomSplitter;
|
||||||
|
static bool st_maximized;
|
||||||
|
static QByteArray st_geometry;
|
||||||
|
static QByteArray st_windowState;
|
||||||
|
static int st_lastState;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,7 +74,7 @@ void PreferencesDefaults::refreshSettings()
|
||||||
ui->default_cylinder->setCurrentIndex(i);
|
ui->default_cylinder->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
ui->displayinvalid->setChecked(qPrefDisplay::display_invalid_dives());
|
ui->displayinvalid->setChecked(qPrefDisplay::display_invalid_dives());
|
||||||
ui->velocitySlider->setValue(qPrefAnimations::animation_speed());
|
ui->velocitySlider->setValue(qPrefDisplay::animation_speed());
|
||||||
ui->btnUseDefaultFile->setChecked(qPrefGeneral::use_default_file());
|
ui->btnUseDefaultFile->setChecked(qPrefGeneral::use_default_file());
|
||||||
|
|
||||||
if (qPrefCloudStorage::cloud_verification_status() == qPref::CS_VERIFIED) {
|
if (qPrefCloudStorage::cloud_verification_status() == qPref::CS_VERIFIED) {
|
||||||
|
@ -117,5 +117,5 @@ void PreferencesDefaults::syncSettings()
|
||||||
qPrefDisplay::set_divelist_font(ui->font->currentFont().toString());
|
qPrefDisplay::set_divelist_font(ui->font->currentFont().toString());
|
||||||
qPrefDisplay::set_font_size(ui->fontsize->value());
|
qPrefDisplay::set_font_size(ui->fontsize->value());
|
||||||
qPrefDisplay::set_display_invalid_dives(ui->displayinvalid->isChecked());
|
qPrefDisplay::set_display_invalid_dives(ui->displayinvalid->isChecked());
|
||||||
qPrefAnimations::set_animation_speed(ui->velocitySlider->value());
|
qPrefDisplay::set_animation_speed(ui->velocitySlider->value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "templatelayout.h"
|
#include "templatelayout.h"
|
||||||
#include "core/statistics.h"
|
#include "core/statistics.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/settings/qPrefAnimations.h"
|
#include "core/settings/qPrefDisplay.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -136,7 +136,7 @@ void Printer::render(int Pages = 0)
|
||||||
// keep original preferences
|
// keep original preferences
|
||||||
QPointer<ProfileWidget2> profile = MainWindow::instance()->graphics();
|
QPointer<ProfileWidget2> profile = MainWindow::instance()->graphics();
|
||||||
int profileFrameStyle = profile->frameStyle();
|
int profileFrameStyle = profile->frameStyle();
|
||||||
int animationOriginal = qPrefAnimations::animation_speed();
|
int animationOriginal = qPrefDisplay::animation_speed();
|
||||||
double fontScale = profile->getFontPrintScale();
|
double fontScale = profile->getFontPrintScale();
|
||||||
double printFontScale = 1.0;
|
double printFontScale = 1.0;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void Printer::render(int Pages = 0)
|
||||||
profile->setFrameStyle(QFrame::NoFrame);
|
profile->setFrameStyle(QFrame::NoFrame);
|
||||||
profile->setPrintMode(true, !printOptions->color_selected);
|
profile->setPrintMode(true, !printOptions->color_selected);
|
||||||
profile->setToolTipVisibile(false);
|
profile->setToolTipVisibile(false);
|
||||||
qPrefAnimations::set_animation_speed(0);
|
qPrefDisplay::set_animation_speed(0);
|
||||||
|
|
||||||
// render the Qwebview
|
// render the Qwebview
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
|
@ -202,7 +202,7 @@ void Printer::render(int Pages = 0)
|
||||||
#else
|
#else
|
||||||
profile->resize(originalSize);
|
profile->resize(originalSize);
|
||||||
#endif
|
#endif
|
||||||
qPrefAnimations::set_animation_speed(animationOriginal);
|
qPrefDisplay::set_animation_speed(animationOriginal);
|
||||||
|
|
||||||
//replot the dive after returning the settings
|
//replot the dive after returning the settings
|
||||||
profile->plotDive(0, true, true);
|
profile->plotDive(0, true, true);
|
||||||
|
|
|
@ -78,7 +78,6 @@ SOURCES += ../../subsurface-mobile-main.cpp \
|
||||||
../../core/connectionlistmodel.cpp \
|
../../core/connectionlistmodel.cpp \
|
||||||
../../core/qt-ble.cpp \
|
../../core/qt-ble.cpp \
|
||||||
../../core/settings/qPref.cpp \
|
../../core/settings/qPref.cpp \
|
||||||
../../core/settings/qPrefAnimations.cpp \
|
|
||||||
../../core/settings/qPrefCloudStorage.cpp \
|
../../core/settings/qPrefCloudStorage.cpp \
|
||||||
../../core/settings/qPrefDisplay.cpp \
|
../../core/settings/qPrefDisplay.cpp \
|
||||||
../../core/settings/qPrefDiveComputer.cpp \
|
../../core/settings/qPrefDiveComputer.cpp \
|
||||||
|
@ -200,7 +199,6 @@ HEADERS += \
|
||||||
../../core/connectionlistmodel.h \
|
../../core/connectionlistmodel.h \
|
||||||
../../core/qt-ble.h \
|
../../core/qt-ble.h \
|
||||||
../../core/settings/qPref.h \
|
../../core/settings/qPref.h \
|
||||||
../../core/settings/qPrefAnimations.h \
|
|
||||||
../../core/settings/qPrefCloudStorage.h \
|
../../core/settings/qPrefCloudStorage.h \
|
||||||
../../core/settings/qPrefDisplay.h \
|
../../core/settings/qPrefDisplay.h \
|
||||||
../../core/settings/qPrefDiveComputer.h \
|
../../core/settings/qPrefDiveComputer.h \
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "profile-widget/animationfunctions.h"
|
#include "profile-widget/animationfunctions.h"
|
||||||
#include "core/pref.h"
|
#include "core/pref.h"
|
||||||
#include "core/settings/qPrefAnimations.h"
|
#include "core/settings/qPrefDisplay.h"
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
namespace Animations {
|
namespace Animations {
|
||||||
|
|
||||||
void hide(QObject *obj)
|
void hide(QObject *obj)
|
||||||
{
|
{
|
||||||
if (qPrefAnimations::animation_speed() != 0) {
|
if (qPrefDisplay::animation_speed() != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
animation->setStartValue(1);
|
animation->setStartValue(1);
|
||||||
animation->setEndValue(0);
|
animation->setEndValue(0);
|
||||||
|
@ -20,7 +20,7 @@ namespace Animations {
|
||||||
|
|
||||||
void show(QObject *obj)
|
void show(QObject *obj)
|
||||||
{
|
{
|
||||||
if (qPrefAnimations::animation_speed() != 0) {
|
if (qPrefDisplay::animation_speed() != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
animation->setStartValue(0);
|
animation->setStartValue(0);
|
||||||
animation->setEndValue(1);
|
animation->setEndValue(1);
|
||||||
|
@ -32,7 +32,7 @@ namespace Animations {
|
||||||
|
|
||||||
void animDelete(QObject *obj)
|
void animDelete(QObject *obj)
|
||||||
{
|
{
|
||||||
if (qPrefAnimations::animation_speed() != 0) {
|
if (qPrefDisplay::animation_speed() != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
|
||||||
obj->connect(animation, &QPropertyAnimation::finished, &QObject::deleteLater);
|
obj->connect(animation, &QPropertyAnimation::finished, &QObject::deleteLater);
|
||||||
animation->setStartValue(1);
|
animation->setStartValue(1);
|
||||||
|
@ -45,7 +45,7 @@ namespace Animations {
|
||||||
|
|
||||||
void moveTo(QObject *obj, qreal x, qreal y)
|
void moveTo(QObject *obj, qreal x, qreal y)
|
||||||
{
|
{
|
||||||
if (qPrefAnimations::animation_speed() != 0) {
|
if (qPrefDisplay::animation_speed() != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
|
||||||
animation->setDuration(prefs.animation_speed);
|
animation->setDuration(prefs.animation_speed);
|
||||||
animation->setStartValue(obj->property("pos").toPointF());
|
animation->setStartValue(obj->property("pos").toPointF());
|
||||||
|
@ -58,7 +58,7 @@ namespace Animations {
|
||||||
|
|
||||||
void scaleTo(QObject *obj, qreal scale)
|
void scaleTo(QObject *obj, qreal scale)
|
||||||
{
|
{
|
||||||
if (qPrefAnimations::animation_speed() != 0) {
|
if (qPrefDisplay::animation_speed() != 0) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale");
|
||||||
animation->setDuration(prefs.animation_speed);
|
animation->setDuration(prefs.animation_speed);
|
||||||
animation->setStartValue(obj->property("scale").toReal());
|
animation->setStartValue(obj->property("scale").toReal());
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "core/profile.h"
|
#include "core/profile.h"
|
||||||
#include "core/membuffer.h"
|
#include "core/membuffer.h"
|
||||||
#include "core/metrics.h"
|
#include "core/metrics.h"
|
||||||
#include "core/settings/qPrefAnimations.h"
|
#include "core/settings/qPrefDisplay.h"
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
@ -62,7 +62,7 @@ void ToolTipItem::collapse()
|
||||||
{
|
{
|
||||||
int dim = defaultIconMetrics().sz_small;
|
int dim = defaultIconMetrics().sz_small;
|
||||||
|
|
||||||
if (qPrefAnimations::animation_speed()) {
|
if (qPrefDisplay::animation_speed()) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "rect");
|
QPropertyAnimation *animation = new QPropertyAnimation(this, "rect");
|
||||||
animation->setDuration(100);
|
animation->setDuration(100);
|
||||||
animation->setStartValue(nextRectangle);
|
animation->setStartValue(nextRectangle);
|
||||||
|
@ -120,7 +120,7 @@ void ToolTipItem::expand()
|
||||||
nextRectangle.setHeight(height);
|
nextRectangle.setHeight(height);
|
||||||
|
|
||||||
if (nextRectangle != rect()) {
|
if (nextRectangle != rect()) {
|
||||||
if (qPrefAnimations::animation_speed()) {
|
if (qPrefDisplay::animation_speed()) {
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "rect", this);
|
QPropertyAnimation *animation = new QPropertyAnimation(this, "rect", this);
|
||||||
animation->setDuration(prefs.animation_speed);
|
animation->setDuration(prefs.animation_speed);
|
||||||
animation->setStartValue(rect());
|
animation->setStartValue(rect());
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-string.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/profile.h"
|
#include "core/profile.h"
|
||||||
#include "core/settings/qPrefAnimations.h"
|
#include "core/settings/qPrefDisplay.h"
|
||||||
#include "core/settings/qPrefTechnicalDetails.h"
|
#include "core/settings/qPrefTechnicalDetails.h"
|
||||||
#include "core/settings/qPrefPartialPressureGas.h"
|
#include "core/settings/qPrefPartialPressureGas.h"
|
||||||
#include "profile-widget/diveeventitem.h"
|
#include "profile-widget/diveeventitem.h"
|
||||||
|
@ -596,8 +596,8 @@ void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
|
||||||
// special handling for the first time we display things
|
// special handling for the first time we display things
|
||||||
int animSpeedBackup = 0;
|
int animSpeedBackup = 0;
|
||||||
if (firstCall && haveFilesOnCommandLine()) {
|
if (firstCall && haveFilesOnCommandLine()) {
|
||||||
animSpeedBackup = qPrefAnimations::animation_speed();
|
animSpeedBackup = qPrefDisplay::animation_speed();
|
||||||
qPrefAnimations::set_animation_speed(0);
|
qPrefDisplay::set_animation_speed(0);
|
||||||
firstCall = false;
|
firstCall = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,7 +806,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
|
||||||
#endif
|
#endif
|
||||||
diveComputerText->setText(dcText);
|
diveComputerText->setText(dcText);
|
||||||
if (haveFilesOnCommandLine() && animSpeedBackup != 0) {
|
if (haveFilesOnCommandLine() && animSpeedBackup != 0) {
|
||||||
qPrefAnimations::set_animation_speed(animSpeedBackup);
|
qPrefDisplay::set_animation_speed(animSpeedBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
|
|
@ -156,7 +156,6 @@ void register_qml_types()
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
REGISTER_TYPE(qPref, "SsrfPrefs");
|
REGISTER_TYPE(qPref, "SsrfPrefs");
|
||||||
REGISTER_TYPE(qPrefAnimations, "SsrfAnimationsPrefs");
|
|
||||||
REGISTER_TYPE(qPrefCloudStorage, "SsrfCloudStoragePrefs");
|
REGISTER_TYPE(qPrefCloudStorage, "SsrfCloudStoragePrefs");
|
||||||
REGISTER_TYPE(qPrefDisplay, "SsrfDisplayPrefs");
|
REGISTER_TYPE(qPrefDisplay, "SsrfDisplayPrefs");
|
||||||
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
|
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
|
||||||
|
|
|
@ -98,7 +98,7 @@ int main(int argc, char **argv)
|
||||||
set_filename(NULL);
|
set_filename(NULL);
|
||||||
|
|
||||||
// some hard coded settings
|
// some hard coded settings
|
||||||
qPrefAnimations::set_animation_speed(0); // we render the profile to pixmap, no animations
|
qPrefDisplay::set_animation_speed(0); // we render the profile to pixmap, no animations
|
||||||
|
|
||||||
// always show the divecomputer reported ceiling in red
|
// always show the divecomputer reported ceiling in red
|
||||||
prefs.redceiling = 1;
|
prefs.redceiling = 1;
|
||||||
|
|
|
@ -100,7 +100,6 @@ TEST(TestPicture testpicture.cpp)
|
||||||
TEST(TestMerge testmerge.cpp)
|
TEST(TestMerge testmerge.cpp)
|
||||||
TEST(TestTagList testtaglist.cpp)
|
TEST(TestTagList testtaglist.cpp)
|
||||||
|
|
||||||
TEST(TestQPrefAnimations testqPrefAnimations.cpp)
|
|
||||||
TEST(TestQPrefCloudStorage testqPrefCloudStorage.cpp)
|
TEST(TestQPrefCloudStorage testqPrefCloudStorage.cpp)
|
||||||
TEST(TestQPrefDisplay testqPrefDisplay.cpp)
|
TEST(TestQPrefDisplay testqPrefDisplay.cpp)
|
||||||
TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp)
|
TEST(TestQPrefDiveComputer testqPrefDiveComputer.cpp)
|
||||||
|
@ -132,7 +131,6 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
TestMerge
|
TestMerge
|
||||||
TestTagList
|
TestTagList
|
||||||
|
|
||||||
TestQPrefAnimations
|
|
||||||
TestQPrefCloudStorage
|
TestQPrefCloudStorage
|
||||||
TestQPrefDisplay
|
TestQPrefDisplay
|
||||||
TestQPrefDiveComputer
|
TestQPrefDiveComputer
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#include "testqPrefAnimations.h"
|
|
||||||
|
|
||||||
#include "core/pref.h"
|
|
||||||
#include "core/qthelper.h"
|
|
||||||
#include "core/settings/qPref.h"
|
|
||||||
|
|
||||||
#include <QDate>
|
|
||||||
#include <QTest>
|
|
||||||
|
|
||||||
void TestQPrefAnimations::initTestCase()
|
|
||||||
{
|
|
||||||
QCoreApplication::setOrganizationName("Subsurface");
|
|
||||||
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
|
||||||
QCoreApplication::setApplicationName("SubsurfaceTestQPrefAnimations");
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefAnimations::test_struct_get()
|
|
||||||
{
|
|
||||||
// Test struct pref -> get func.
|
|
||||||
|
|
||||||
auto tst = qPrefAnimations::instance();
|
|
||||||
|
|
||||||
prefs.animation_speed = 17;
|
|
||||||
|
|
||||||
QCOMPARE(tst->animation_speed(), prefs.animation_speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefAnimations::test_set_struct()
|
|
||||||
{
|
|
||||||
// Test set func -> struct pref
|
|
||||||
|
|
||||||
auto tst = qPrefAnimations::instance();
|
|
||||||
|
|
||||||
tst->set_animation_speed(27);
|
|
||||||
|
|
||||||
QCOMPARE(prefs.animation_speed, 27);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefAnimations::test_set_load_struct()
|
|
||||||
{
|
|
||||||
// test set func -> load -> struct pref
|
|
||||||
|
|
||||||
auto tst = qPrefAnimations::instance();
|
|
||||||
|
|
||||||
tst->set_animation_speed(33);
|
|
||||||
|
|
||||||
prefs.animation_speed = 17;
|
|
||||||
|
|
||||||
tst->load();
|
|
||||||
QCOMPARE(prefs.animation_speed, 33);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefAnimations::test_struct_disk()
|
|
||||||
{
|
|
||||||
// test struct prefs -> disk
|
|
||||||
|
|
||||||
auto tst = qPrefAnimations::instance();
|
|
||||||
|
|
||||||
prefs.animation_speed = 27;
|
|
||||||
|
|
||||||
tst->sync();
|
|
||||||
prefs.animation_speed = 35;
|
|
||||||
|
|
||||||
tst->load();
|
|
||||||
QCOMPARE(prefs.animation_speed, 27);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefAnimations::test_multiple()
|
|
||||||
{
|
|
||||||
// test multiple instances have the same information
|
|
||||||
|
|
||||||
prefs.animation_speed = 37;
|
|
||||||
auto tst_direct = new qPrefAnimations;
|
|
||||||
|
|
||||||
prefs.animation_speed = 25;
|
|
||||||
auto tst = qPrefAnimations::instance();
|
|
||||||
|
|
||||||
QCOMPARE(tst->animation_speed(), tst_direct->animation_speed());
|
|
||||||
QCOMPARE(tst_direct->animation_speed(), 25);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTEST_MAIN(TestQPrefAnimations)
|
|
|
@ -1,18 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#ifndef TESTQPREFANIMATIONS_H
|
|
||||||
#define TESTQPREFANIMATIONS_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class TestQPrefAnimations : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
private slots:
|
|
||||||
void initTestCase();
|
|
||||||
void test_struct_get();
|
|
||||||
void test_set_struct();
|
|
||||||
void test_set_load_struct();
|
|
||||||
void test_struct_disk();
|
|
||||||
void test_multiple();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TESTQPREFANIMATIONS_H
|
|
|
@ -21,17 +21,17 @@ void TestQPrefDisplay::test_struct_get()
|
||||||
|
|
||||||
auto display = qPrefDisplay::instance();
|
auto display = qPrefDisplay::instance();
|
||||||
|
|
||||||
|
prefs.animation_speed = 17;
|
||||||
prefs.display_invalid_dives = true;
|
prefs.display_invalid_dives = true;
|
||||||
prefs.divelist_font = copy_qstring("comic");
|
prefs.divelist_font = copy_qstring("comic");
|
||||||
prefs.font_size = 12.0;
|
prefs.font_size = 12.0;
|
||||||
prefs.show_developer = false;
|
prefs.show_developer = false;
|
||||||
prefs.theme = copy_qstring("myTheme");
|
|
||||||
|
|
||||||
|
QCOMPARE(display->animation_speed(), prefs.animation_speed);
|
||||||
QCOMPARE(display->display_invalid_dives(), prefs.display_invalid_dives);
|
QCOMPARE(display->display_invalid_dives(), prefs.display_invalid_dives);
|
||||||
QCOMPARE(display->divelist_font(), QString(prefs.divelist_font));
|
QCOMPARE(display->divelist_font(), QString(prefs.divelist_font));
|
||||||
QCOMPARE(display->font_size(), prefs.font_size);
|
QCOMPARE(display->font_size(), prefs.font_size);
|
||||||
QCOMPARE(display->show_developer(), prefs.show_developer);
|
QCOMPARE(display->show_developer(), prefs.show_developer);
|
||||||
QCOMPARE(display->theme(), QString(prefs.theme));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQPrefDisplay::test_set_struct()
|
void TestQPrefDisplay::test_set_struct()
|
||||||
|
@ -40,17 +40,39 @@ void TestQPrefDisplay::test_set_struct()
|
||||||
|
|
||||||
auto display = qPrefDisplay::instance();
|
auto display = qPrefDisplay::instance();
|
||||||
|
|
||||||
|
display->set_animation_speed(27);
|
||||||
display->set_display_invalid_dives(true);
|
display->set_display_invalid_dives(true);
|
||||||
display->set_divelist_font("doNotCareAtAll");
|
display->set_divelist_font("doNotCareAtAll");
|
||||||
display->set_font_size(12.0);
|
display->set_font_size(12.0);
|
||||||
display->set_show_developer(false);
|
display->set_show_developer(false);
|
||||||
display->set_theme("myTheme");
|
display->set_theme("myTheme");
|
||||||
|
display->set_lastDir("test1");
|
||||||
|
display->set_tooltip_position(QPointF(512, 3));
|
||||||
|
display->set_UserSurvey("my1");
|
||||||
|
display->set_mainSplitter("main1");
|
||||||
|
display->set_topSplitter("top1");
|
||||||
|
display->set_bottomSplitter("bottom1");
|
||||||
|
display->set_maximized(false);
|
||||||
|
display->set_geometry("geo1");
|
||||||
|
display->set_windowState("win1");
|
||||||
|
display->set_lastState(17);
|
||||||
|
|
||||||
|
QCOMPARE(prefs.animation_speed, 27);
|
||||||
QCOMPARE(prefs.display_invalid_dives, true);
|
QCOMPARE(prefs.display_invalid_dives, true);
|
||||||
QCOMPARE(prefs.divelist_font, "doNotCareAtAll");
|
QCOMPARE(prefs.divelist_font, "doNotCareAtAll");
|
||||||
QCOMPARE(prefs.font_size, 12.0);
|
QCOMPARE(prefs.font_size, 12.0);
|
||||||
QCOMPARE(prefs.show_developer, false);
|
QCOMPARE(prefs.show_developer, false);
|
||||||
QCOMPARE(prefs.theme, "myTheme");
|
QCOMPARE(display->theme(), QString("myTheme"));
|
||||||
|
QCOMPARE(display->lastDir(), QString("test1"));
|
||||||
|
QCOMPARE(display->tooltip_position(), QPointF(512, 3));
|
||||||
|
QCOMPARE(display->UserSurvey(), QString("my1"));
|
||||||
|
QCOMPARE(display->mainSplitter(), QByteArray("main1"));
|
||||||
|
QCOMPARE(display->topSplitter(), QByteArray("top1"));
|
||||||
|
QCOMPARE(display->bottomSplitter(), QByteArray("bottom1"));
|
||||||
|
QCOMPARE(display->maximized(), false);
|
||||||
|
QCOMPARE(display->geometry(), QByteArray("geo1"));
|
||||||
|
QCOMPARE(display->windowState(), QByteArray("win1"));
|
||||||
|
QCOMPARE(display->lastState(), 17);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQPrefDisplay::test_set_load_struct()
|
void TestQPrefDisplay::test_set_load_struct()
|
||||||
|
@ -59,24 +81,46 @@ void TestQPrefDisplay::test_set_load_struct()
|
||||||
|
|
||||||
auto display = qPrefDisplay::instance();
|
auto display = qPrefDisplay::instance();
|
||||||
|
|
||||||
|
display->set_animation_speed(33);
|
||||||
display->set_display_invalid_dives(false);
|
display->set_display_invalid_dives(false);
|
||||||
display->set_divelist_font("doNotCareString");
|
display->set_divelist_font("doNotCareString");
|
||||||
display->set_font_size(15.0);
|
display->set_font_size(15.0);
|
||||||
display->set_show_developer(true);
|
display->set_show_developer(true);
|
||||||
display->set_theme("myTheme2");
|
display->set_theme("myTheme2");
|
||||||
|
display->set_lastDir("test2");
|
||||||
|
display->set_tooltip_position(QPointF(612, 3));
|
||||||
|
display->set_UserSurvey("my2");
|
||||||
|
display->set_mainSplitter("main2");
|
||||||
|
display->set_topSplitter("top2");
|
||||||
|
display->set_bottomSplitter("bottom2");
|
||||||
|
display->set_maximized(true);
|
||||||
|
display->set_geometry("geo2");
|
||||||
|
display->set_windowState("win2");
|
||||||
|
display->set_lastState(27);
|
||||||
|
|
||||||
|
prefs.animation_speed = 17;
|
||||||
prefs.display_invalid_dives = true;
|
prefs.display_invalid_dives = true;
|
||||||
prefs.divelist_font = copy_qstring("doNotCareAtAll");
|
prefs.divelist_font = copy_qstring("doNotCareAtAll");
|
||||||
prefs.font_size = 12.0;
|
prefs.font_size = 12.0;
|
||||||
prefs.show_developer = false;
|
prefs.show_developer = false;
|
||||||
prefs.theme = copy_qstring("myTheme");
|
|
||||||
|
|
||||||
display->load();
|
display->load();
|
||||||
|
QCOMPARE(prefs.animation_speed, 33);
|
||||||
QCOMPARE(prefs.display_invalid_dives, false);
|
QCOMPARE(prefs.display_invalid_dives, false);
|
||||||
QCOMPARE(prefs.divelist_font, "doNotCareString");
|
QCOMPARE(prefs.divelist_font, "doNotCareString");
|
||||||
QCOMPARE(prefs.font_size, 15.0);
|
QCOMPARE(prefs.font_size, 15.0);
|
||||||
QCOMPARE(prefs.show_developer, true);
|
QCOMPARE(prefs.show_developer, true);
|
||||||
QCOMPARE(prefs.theme, "myTheme2");
|
QCOMPARE(display->theme(), QString("myTheme2"));
|
||||||
|
QCOMPARE(display->lastDir(), QString("test2"));
|
||||||
|
QCOMPARE(display->tooltip_position(), QPointF(612, 3));
|
||||||
|
QCOMPARE(display->UserSurvey(), QString("my2"));
|
||||||
|
QCOMPARE(display->mainSplitter(), QByteArray("main2"));
|
||||||
|
QCOMPARE(display->topSplitter(), QByteArray("top2"));
|
||||||
|
QCOMPARE(display->bottomSplitter(), QByteArray("bottom2"));
|
||||||
|
QCOMPARE(display->maximized(), true);
|
||||||
|
QCOMPARE(display->geometry(), QByteArray("geo2"));
|
||||||
|
QCOMPARE(display->windowState(), QByteArray("win2"));
|
||||||
|
QCOMPARE(display->lastState(), 27);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQPrefDisplay::test_struct_disk()
|
void TestQPrefDisplay::test_struct_disk()
|
||||||
|
@ -85,25 +129,25 @@ void TestQPrefDisplay::test_struct_disk()
|
||||||
|
|
||||||
auto display = qPrefDisplay::instance();
|
auto display = qPrefDisplay::instance();
|
||||||
|
|
||||||
|
prefs.animation_speed = 27;
|
||||||
prefs.display_invalid_dives = true;
|
prefs.display_invalid_dives = true;
|
||||||
prefs.divelist_font = copy_qstring("doNotCareAtAll");
|
prefs.divelist_font = copy_qstring("doNotCareAtAll");
|
||||||
prefs.font_size = 17.0;
|
prefs.font_size = 17.0;
|
||||||
prefs.show_developer = false;
|
prefs.show_developer = false;
|
||||||
prefs.theme = copy_qstring("myTheme3");
|
|
||||||
|
|
||||||
display->sync();
|
display->sync();
|
||||||
|
prefs.animation_speed = 35;
|
||||||
prefs.display_invalid_dives = false;
|
prefs.display_invalid_dives = false;
|
||||||
prefs.divelist_font = copy_qstring("noString");
|
prefs.divelist_font = copy_qstring("noString");
|
||||||
prefs.font_size = 11.0;
|
prefs.font_size = 11.0;
|
||||||
prefs.show_developer = true;
|
prefs.show_developer = true;
|
||||||
prefs.theme = copy_qstring("myTheme");
|
|
||||||
|
|
||||||
display->load();
|
display->load();
|
||||||
|
QCOMPARE(prefs.animation_speed, 27);
|
||||||
QCOMPARE(prefs.display_invalid_dives, true);
|
QCOMPARE(prefs.display_invalid_dives, true);
|
||||||
QCOMPARE(prefs.divelist_font, "doNotCareAtAll");
|
QCOMPARE(prefs.divelist_font, "doNotCareAtAll");
|
||||||
QCOMPARE(prefs.font_size, 17.0);
|
QCOMPARE(prefs.font_size, 17.0);
|
||||||
QCOMPARE(prefs.show_developer, false);
|
QCOMPARE(prefs.show_developer, false);
|
||||||
QCOMPARE(prefs.theme, "myTheme3");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQPrefDisplay::test_multiple()
|
void TestQPrefDisplay::test_multiple()
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
import QtQuick 2.6
|
|
||||||
import QtTest 1.2
|
|
||||||
import org.subsurfacedivelog.mobile 1.0
|
|
||||||
|
|
||||||
TestCase {
|
|
||||||
name: "qPrefAnimations"
|
|
||||||
|
|
||||||
SsrfAnimationsPrefs {
|
|
||||||
id: tst
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_variables() {
|
|
||||||
var x1 = tst.animation_speed;
|
|
||||||
tst.animation_speed = 37
|
|
||||||
compare(tst.animation_speed, 37)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,21 +11,68 @@ TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_variables() {
|
function test_variables() {
|
||||||
|
var x0 = display.animation_speed
|
||||||
|
display.animation_speed = 37
|
||||||
|
compare(display.animation_speed, 37)
|
||||||
|
|
||||||
var x1 = display.divelist_font
|
var x1 = display.divelist_font
|
||||||
display.divelist_font = "helvitica"
|
display.divelist_font = "helvitica"
|
||||||
compare(display.divelist_font, "helvitica")
|
compare(display.divelist_font, "helvitica")
|
||||||
|
|
||||||
var x2 = display.font_size
|
var x2 = display.font_size
|
||||||
display.font_size = 12.0
|
display.font_size = 12.0
|
||||||
compare(display.font_size, 12.0)
|
compare(display.font_size, 12.0)
|
||||||
|
|
||||||
var x3 = display.display_invalid_dives
|
var x3 = display.display_invalid_dives
|
||||||
display.display_invalid_dives = !x3
|
display.display_invalid_dives = !x3
|
||||||
compare(display.display_invalid_dives, !x3)
|
compare(display.display_invalid_dives, !x3)
|
||||||
|
|
||||||
var x4 = display.show_developer
|
var x4 = display.show_developer
|
||||||
display.show_developer = !x4
|
display.show_developer = !x4
|
||||||
compare(display.show_developer, !x4)
|
compare(display.show_developer, !x4)
|
||||||
|
|
||||||
var x5 = display.theme
|
var x5 = display.theme
|
||||||
display.theme = "myColor"
|
display.theme = "myColor"
|
||||||
compare(display.theme, "myColor")
|
compare(display.theme, "myColor")
|
||||||
}
|
|
||||||
|
|
||||||
|
//TBD var x6 = display.tooltip_position
|
||||||
|
//TBD display.tooltip_position = ??
|
||||||
|
//TBD compare(display.tooltip_position, ??)
|
||||||
|
|
||||||
|
var x7 = display.lastDir
|
||||||
|
display.lastDir = "myDir"
|
||||||
|
compare(display.lastDir, "myDir")
|
||||||
|
|
||||||
|
var x8 = display.UserSurvey
|
||||||
|
display.UserSurvey = "yes"
|
||||||
|
compare(display.UserSurvey, "yes")
|
||||||
|
|
||||||
|
//TBD var x9 = display.mainSplitter
|
||||||
|
//TBD display.mainSplitter = ???
|
||||||
|
//TBD compare(display.mainSplitter, ???)
|
||||||
|
|
||||||
|
//TBD var x10 = display.topSplitter
|
||||||
|
//TBD display.topSplitter = ???
|
||||||
|
//TBD compare(display.topSplitter, ???)
|
||||||
|
|
||||||
|
//TBD var x11 = display.bottomSplitter
|
||||||
|
//TBD display.bottomSplitter = ???
|
||||||
|
//TBD compare(display.bottomSplitter, ???)
|
||||||
|
|
||||||
|
var x12 = display.maximized
|
||||||
|
display.maximized = true
|
||||||
|
compare(display.maximized, true)
|
||||||
|
|
||||||
|
//TBD var x13 = display.geometry
|
||||||
|
//TBD display.geometry = ???
|
||||||
|
//TBD compare(display.geometry, ???)
|
||||||
|
|
||||||
|
//TBD var x14 = display.windowState
|
||||||
|
//TBD display.windowState = ???
|
||||||
|
//TBD compare(display.windowState, ???)
|
||||||
|
|
||||||
|
var x15 = display.lastState
|
||||||
|
display.lastState = 17
|
||||||
|
compare(display.lastState, 17)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue