mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Preferences: hook up default file behavior in the dialog
This now sets the preference variable / config entry and keeps them in sync. Doesn't actually change the behavior at program start, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bfd3782b81
commit
10b9202757
3 changed files with 50 additions and 0 deletions
8
pref.h
8
pref.h
|
@ -89,6 +89,7 @@ struct preferences {
|
||||||
int defaultsetpoint; // default setpoint in mbar
|
int defaultsetpoint; // default setpoint in mbar
|
||||||
bool show_pictures_in_profile;
|
bool show_pictures_in_profile;
|
||||||
bool use_default_file;
|
bool use_default_file;
|
||||||
|
short default_file_behavior;
|
||||||
facebook_prefs_t facebook;
|
facebook_prefs_t facebook;
|
||||||
char *cloud_storage_password;
|
char *cloud_storage_password;
|
||||||
char *cloud_storage_email;
|
char *cloud_storage_email;
|
||||||
|
@ -103,6 +104,13 @@ enum unit_system_values {
|
||||||
PERSONALIZE
|
PERSONALIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum def_file_behavior {
|
||||||
|
UNDEFINED_DEFAULT_FILE,
|
||||||
|
LOCAL_DEFAULT_FILE,
|
||||||
|
NO_DEFAULT_FILE,
|
||||||
|
CLOUD_DEFAULT_FILE
|
||||||
|
};
|
||||||
|
|
||||||
extern struct preferences prefs, default_prefs;
|
extern struct preferences prefs, default_prefs;
|
||||||
|
|
||||||
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
|
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
|
||||||
|
|
|
@ -172,6 +172,9 @@ void PreferencesDialog::setUiFromPrefs()
|
||||||
ui.font->setCurrentFont(QString(prefs.divelist_font));
|
ui.font->setCurrentFont(QString(prefs.divelist_font));
|
||||||
ui.fontsize->setValue(prefs.font_size);
|
ui.fontsize->setValue(prefs.font_size);
|
||||||
ui.defaultfilename->setText(prefs.default_filename);
|
ui.defaultfilename->setText(prefs.default_filename);
|
||||||
|
ui.noDefaultFile->setChecked(prefs.default_file_behavior == NO_DEFAULT_FILE);
|
||||||
|
ui.cloudDefaultFile->setChecked(prefs.default_file_behavior == CLOUD_DEFAULT_FILE);
|
||||||
|
ui.localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
|
||||||
ui.default_cylinder->clear();
|
ui.default_cylinder->clear();
|
||||||
for (int i = 0; tank_info[i].name != NULL; i++) {
|
for (int i = 0; tank_info[i].name != NULL; i++) {
|
||||||
ui.default_cylinder->addItem(tank_info[i].name);
|
ui.default_cylinder->addItem(tank_info[i].name);
|
||||||
|
@ -332,6 +335,12 @@ void PreferencesDialog::syncSettings()
|
||||||
s.setValue("default_filename", ui.defaultfilename->text());
|
s.setValue("default_filename", ui.defaultfilename->text());
|
||||||
s.setValue("default_cylinder", ui.default_cylinder->currentText());
|
s.setValue("default_cylinder", ui.default_cylinder->currentText());
|
||||||
s.setValue("use_default_file", ui.btnUseDefaultFile->isChecked());
|
s.setValue("use_default_file", ui.btnUseDefaultFile->isChecked());
|
||||||
|
if (ui.noDefaultFile->isChecked())
|
||||||
|
s.setValue("default_file_behavior", NO_DEFAULT_FILE);
|
||||||
|
else if (ui.localDefaultFile->isChecked())
|
||||||
|
s.setValue("default_file_behavior", LOCAL_DEFAULT_FILE);
|
||||||
|
else if (ui.cloudDefaultFile->isChecked())
|
||||||
|
s.setValue("default_file_behavior", CLOUD_DEFAULT_FILE);
|
||||||
s.setValue("defaultsetpoint", rint(ui.defaultSetpoint->value() * 1000.0));
|
s.setValue("defaultsetpoint", rint(ui.defaultSetpoint->value() * 1000.0));
|
||||||
s.setValue("o2consumption", rint(ui.psro2rate->value() *1000.0));
|
s.setValue("o2consumption", rint(ui.psro2rate->value() *1000.0));
|
||||||
s.setValue("pscr_ratio", rint(1000.0 / ui.pscrfactor->value()));
|
s.setValue("pscr_ratio", rint(1000.0 / ui.pscrfactor->value()));
|
||||||
|
@ -475,6 +484,18 @@ void PreferencesDialog::loadSettings()
|
||||||
|
|
||||||
s.beginGroup("GeneralSettings");
|
s.beginGroup("GeneralSettings");
|
||||||
GET_TXT("default_filename", default_filename);
|
GET_TXT("default_filename", default_filename);
|
||||||
|
GET_INT("default_file_behavior", default_file_behavior);
|
||||||
|
if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE) {
|
||||||
|
// undefined, so check if there's a filename set and
|
||||||
|
// use that, otherwise go with no default file
|
||||||
|
if (QString(prefs.default_filename).isEmpty())
|
||||||
|
prefs.default_file_behavior = NO_DEFAULT_FILE;
|
||||||
|
else
|
||||||
|
prefs.default_file_behavior = LOCAL_DEFAULT_FILE;
|
||||||
|
}
|
||||||
|
ui.defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
|
||||||
|
ui.btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
|
||||||
|
ui.chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
|
||||||
GET_TXT("default_cylinder", default_cylinder);
|
GET_TXT("default_cylinder", default_cylinder);
|
||||||
GET_BOOL("use_default_file", use_default_file);
|
GET_BOOL("use_default_file", use_default_file);
|
||||||
GET_INT("defaultsetpoint", defaultsetpoint);
|
GET_INT("defaultsetpoint", defaultsetpoint);
|
||||||
|
@ -613,3 +634,21 @@ void PreferencesDialog::on_btnUseDefaultFile_toggled(bool toggle)
|
||||||
ui.defaultfilename->setEnabled(true);
|
ui.defaultfilename->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::on_noDefaultFile_toggled(bool toggle)
|
||||||
|
{
|
||||||
|
prefs.default_file_behavior = NO_DEFAULT_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::on_localDefaultFile_toggled(bool toggle)
|
||||||
|
{
|
||||||
|
ui.defaultfilename->setEnabled(toggle);
|
||||||
|
ui.btnUseDefaultFile->setEnabled(toggle);
|
||||||
|
ui.chooseFile->setEnabled(toggle);
|
||||||
|
prefs.default_file_behavior = LOCAL_DEFAULT_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::on_cloudDefaultFile_toggled(bool toggle)
|
||||||
|
{
|
||||||
|
prefs.default_file_behavior = CLOUD_DEFAULT_FILE;
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ slots:
|
||||||
void gfhighChanged(int gf);
|
void gfhighChanged(int gf);
|
||||||
void proxyType_changed(int idx);
|
void proxyType_changed(int idx);
|
||||||
void on_btnUseDefaultFile_toggled(bool toggle);
|
void on_btnUseDefaultFile_toggled(bool toggle);
|
||||||
|
void on_noDefaultFile_toggled(bool toggle);
|
||||||
|
void on_localDefaultFile_toggled(bool toggle);
|
||||||
|
void on_cloudDefaultFile_toggled(bool toggle);
|
||||||
void facebookLoggedIn();
|
void facebookLoggedIn();
|
||||||
void facebookDisconnect();
|
void facebookDisconnect();
|
||||||
void cloudPinNeeded(bool toggle);
|
void cloudPinNeeded(bool toggle);
|
||||||
|
|
Loading…
Add table
Reference in a new issue