Allow passing --profile someuser as argument

It either opens an existing profile or opens the profile create wizard.
This commit is contained in:
François Revol 2017-09-02 14:01:01 +02:00
parent 0e04bd991b
commit dc44c63b9a
3 changed files with 24 additions and 3 deletions

View File

@ -189,6 +189,7 @@ int main(int argc, char *argv[])
bool force_login_screen = false; bool force_login_screen = false;
bool force_data_dir = false; bool force_data_dir = false;
bool changing_language = false; bool changing_language = false;
QString load_profile = "";
QApplication a(argc, argv); QApplication a(argc, argv);
QStringList args = QCoreApplication::arguments(); QStringList args = QCoreApplication::arguments();
@ -212,6 +213,13 @@ int main(int argc, char *argv[])
settings.setValue(LangSetting,""); settings.setValue(LangSetting,"");
} else if (args[i] == "-p") { } else if (args[i] == "-p") {
sDelay(1); sDelay(1);
} else if (args[i] == "--profile") {
if ((i+1) < args.size()) {
load_profile = args[++i];
} else {
fprintf(stderr, "Missing argument to --profile\n");
exit(1);
}
} }
} }
@ -455,7 +463,18 @@ retry_directory:
ProfileSelect profsel(0); ProfileSelect profsel(0);
if (skip_login) { if (load_profile.size()) {
profsel.QuickLogin();
p_profile = Profiles::Get(load_profile);
if (!p_profile) {
NewProfile newprof(0, &load_profile);
if (newprof.exec() == NewProfile::Rejected) {
return 0;
}
}
} else if (skip_login) {
profsel.QuickLogin(); profsel.QuickLogin();
if (profsel.result() == ProfileSelect::Rejected) { if (profsel.result() == ProfileSelect::Rejected) {

View File

@ -23,11 +23,13 @@
extern MainWindow *mainwin; extern MainWindow *mainwin;
NewProfile::NewProfile(QWidget *parent) : NewProfile::NewProfile(QWidget *parent, const QString *user) :
QDialog(parent), QDialog(parent),
ui(new Ui::NewProfile) ui(new Ui::NewProfile)
{ {
ui->setupUi(this); ui->setupUi(this);
if (user)
ui->userNameEdit->setText(*user);
// ui->userNameEdit->setText(getUserName()); // ui->userNameEdit->setText(getUserName());
QLocale locale = QLocale::system(); QLocale locale = QLocale::system();
QString shortformat = locale.dateFormat(QLocale::ShortFormat); QString shortformat = locale.dateFormat(QLocale::ShortFormat);

View File

@ -25,7 +25,7 @@ class NewProfile : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit NewProfile(QWidget *parent = 0); explicit NewProfile(QWidget *parent = 0, const QString *user = 0);
~NewProfile(); ~NewProfile();
//! \brief When used in edit mode, this skips the first page //! \brief When used in edit mode, this skips the first page