mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allow switching the user from the command line
This is a feature that many people have asked for. This implementation is somewhat simplistic because we simply use a different name for the program settings - but interestingly enough this appears to be enough to capture a lot of the core functionality that people are looking for in multi-user support. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f536da0ee3
commit
3f63660267
3 changed files with 20 additions and 2 deletions
|
@ -4,6 +4,8 @@
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
char *settings_suffix = NULL;
|
||||||
|
|
||||||
void init_qt_late()
|
void init_qt_late()
|
||||||
{
|
{
|
||||||
QApplication *application = qApp;
|
QApplication *application = qApp;
|
||||||
|
@ -19,7 +21,14 @@ void init_qt_late()
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("Subsurface");
|
QCoreApplication::setOrganizationName("Subsurface");
|
||||||
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
||||||
QCoreApplication::setApplicationName("Subsurface");
|
// enable user specific settings (based on command line argument)
|
||||||
|
if (settings_suffix) {
|
||||||
|
if (verbose)
|
||||||
|
qDebug() << "using custom config for" << QString("Subsurface-%1").arg(settings_suffix);
|
||||||
|
QCoreApplication::setApplicationName(QString("Subsurface-%1").arg(settings_suffix));
|
||||||
|
} else {
|
||||||
|
QCoreApplication::setApplicationName("Subsurface");
|
||||||
|
}
|
||||||
// find plugins installed in the application directory (without this SVGs don't work on Windows)
|
// find plugins installed in the application directory (without this SVGs don't work on Windows)
|
||||||
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
|
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
|
||||||
QLocale loc;
|
QLocale loc;
|
||||||
|
|
|
@ -197,6 +197,11 @@ void parse_argument(const char *arg)
|
||||||
continue;
|
continue;
|
||||||
case '-':
|
case '-':
|
||||||
/* long options with -- */
|
/* long options with -- */
|
||||||
|
/* first test for --user=bla which allows the use of user specific settings */
|
||||||
|
if (strncmp(arg, "--user=", sizeof("--user=") - 1) == 0) {
|
||||||
|
settings_suffix = strdup(arg + sizeof("--user=") - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (strcmp(arg, "--help") == 0) {
|
if (strcmp(arg, "--help") == 0) {
|
||||||
print_help();
|
print_help();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -254,8 +259,10 @@ void setup_system_prefs(void)
|
||||||
subsurface_OS_pref_setup();
|
subsurface_OS_pref_setup();
|
||||||
default_prefs.divelist_font = strdup(system_divelist_default_font);
|
default_prefs.divelist_font = strdup(system_divelist_default_font);
|
||||||
default_prefs.font_size = system_divelist_default_font_size;
|
default_prefs.font_size = system_divelist_default_font_size;
|
||||||
default_prefs.default_filename = system_default_filename();
|
|
||||||
|
|
||||||
|
#if !defined(SUBSURFACE_MOBILE)
|
||||||
|
default_prefs.default_filename = system_default_filename();
|
||||||
|
#endif
|
||||||
env = getenv("LC_MEASUREMENT");
|
env = getenv("LC_MEASUREMENT");
|
||||||
if (!env)
|
if (!env)
|
||||||
env = getenv("LC_ALL");
|
env = getenv("LC_ALL");
|
||||||
|
|
|
@ -19,6 +19,8 @@ void free_prefs(void);
|
||||||
void copy_prefs(struct preferences *src, struct preferences *dest);
|
void copy_prefs(struct preferences *src, struct preferences *dest);
|
||||||
void print_files(void);
|
void print_files(void);
|
||||||
|
|
||||||
|
extern char *settings_suffix;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue