diff --git a/sleepyhead/main.cpp b/sleepyhead/main.cpp index 348f8d96..ef01a5a9 100644 --- a/sleepyhead/main.cpp +++ b/sleepyhead/main.cpp @@ -189,6 +189,7 @@ int main(int argc, char *argv[]) bool force_login_screen = false; bool force_data_dir = false; bool changing_language = false; + QString load_profile = ""; QApplication a(argc, argv); QStringList args = QCoreApplication::arguments(); @@ -212,6 +213,13 @@ int main(int argc, char *argv[]) settings.setValue(LangSetting,""); } else if (args[i] == "-p") { 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); - 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(); if (profsel.result() == ProfileSelect::Rejected) { diff --git a/sleepyhead/newprofile.cpp b/sleepyhead/newprofile.cpp index 9acac994..f3830e0f 100644 --- a/sleepyhead/newprofile.cpp +++ b/sleepyhead/newprofile.cpp @@ -23,11 +23,13 @@ extern MainWindow *mainwin; -NewProfile::NewProfile(QWidget *parent) : +NewProfile::NewProfile(QWidget *parent, const QString *user) : QDialog(parent), ui(new Ui::NewProfile) { ui->setupUi(this); + if (user) + ui->userNameEdit->setText(*user); // ui->userNameEdit->setText(getUserName()); QLocale locale = QLocale::system(); QString shortformat = locale.dateFormat(QLocale::ShortFormat); diff --git a/sleepyhead/newprofile.h b/sleepyhead/newprofile.h index 434646e7..8ea0b107 100644 --- a/sleepyhead/newprofile.h +++ b/sleepyhead/newprofile.h @@ -25,7 +25,7 @@ class NewProfile : public QDialog Q_OBJECT public: - explicit NewProfile(QWidget *parent = 0); + explicit NewProfile(QWidget *parent = 0, const QString *user = 0); ~NewProfile(); //! \brief When used in edit mode, this skips the first page