From 2f567778f71a1c6dcfdaa7831d7642e4c45c5c7b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 19 Jan 2017 12:22:44 +0100 Subject: Add "admin mode" (edit vm) --- src/command_line_options.cpp | 4 ++ src/dialog.cpp | 20 +++++++--- src/globals.cpp | 1 + src/globals.h | 1 + src/i18n/de.ts | 64 ++++++++++++++++-------------- src/i18n/pt.ts | 93 ++++++++++++++++++++++++-------------------- src/main.cpp | 69 +++++++++++++++++--------------- src/ui/dialog.ui | 19 ++++++--- 8 files changed, 156 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp index f020f0d..22c5475 100644 --- a/src/command_line_options.cpp +++ b/src/command_line_options.cpp @@ -6,6 +6,7 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { // parse command line arguments (please sort by short option for easier handling) static const struct option longOptions[] = { + {"allow-vm-edit", no_argument, NULL, 'vmed'}, {"autoquit", required_argument, NULL, 'aqit'}, {"base", required_argument, NULL, 'b'}, {"path", required_argument, NULL, 'b'}, // Compatibility to v1.0 @@ -108,6 +109,9 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { case 'uuid': options.insert("uuid", optarg); break; + case 'vmed': + options.insert("allow-vm-edit", ""); + break; default: options.insert("error", "error"); break; diff --git a/src/dialog.cpp b/src/dialog.cpp index 105d476..6d245bb 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -81,6 +81,7 @@ Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent) //activeTab_ = 2; //ui->tabButtonAllClasses->setChecked(true); + ui->chkAdminMode->setVisible(g_allowVmEdit); // TODO: Implement bug report dialog :) ui->buttonBugReport->setEnabled(false); @@ -119,15 +120,24 @@ void Dialog::on_treeView_doubleClicked(const QModelIndex& index) if (s == NULL) // no valid session has been selected, do nothing return; + // These two are up here in case run-virt cares... + if (ui->PVS_checkbox->isChecked()) { + setenv("PVS_AUTO_CONNECT", "TRUE", 1); + } else { + setenv("PVS_AUTO_CONNECT", "FALSE", 1); + } + if (g_allowVmEdit && ui->chkAdminMode->isChecked()) { + setenv("VMCHOOSER_ADMIN_MODE", "TRUE", 1); + } else { + setenv("VMCHOOSER_ADMIN_MODE", "FALSE", 1); + } + + // Run session if (s->run()) { - // Run session start script + // Run session start script if the session could be initialized successfully if (QFile::exists(sessionStartScript)) { // Use the current environment variables and add the necessary // information for the startUpScipt. - if (ui->PVS_checkbox->isChecked()) - setenv("PVS_AUTO_CONNECT", "TRUE", 1); - else - setenv("PVS_AUTO_CONNECT", "FALSE", 1); // export session information to the environment of the process to be exec'ed setenv("SESSION_NAME", s->shortDescription().toUtf8(), 1); setenv("SESSION_UUID", s->uuid().toUtf8(), 1); diff --git a/src/globals.cpp b/src/globals.cpp index 50bb19a..1531e67 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -21,6 +21,7 @@ const QString previousSessionFile(userPath + "/vmchooser2.ini"); bool debugMode = false; bool pvsEnabled = false; int g_autoQuitSeconds = 0; +bool g_allowVmEdit = false; QString pool; QString theme; diff --git a/src/globals.h b/src/globals.h index a2a8805..8b592ac 100644 --- a/src/globals.h +++ b/src/globals.h @@ -25,6 +25,7 @@ class Session; extern bool debugMode; extern bool pvsEnabled; extern int g_autoQuitSeconds; +extern bool g_allowVmEdit; extern QString binPath; extern QString etcPath; diff --git a/src/i18n/de.ts b/src/i18n/de.ts index a28d83c..704791d 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -23,35 +23,6 @@ vmchooser: invalid size argument Ungültige Größe - - Usage: vmchooser [ OPTIONS ] - - -b --base base directory where VM images are accessible - -d, --default name of default session - -c, --config alternative config file - -l, --locations location id(s), space separated - --location-mode how to treat entries for this location (IGNORE, BUMP or EXCLUSIVE) - --exam-mode enable exam mode - -P, --pool one or more pool names to display (comma separated) - -f, --file direct boot .desktop file - -x, --xpath path of X Session .desktop files - -u, --url url of vmware .xml file - -s, --size window size <width>x<height> - -t, --theme theme - --template-mode how to treat template entries (IGNORE or BUMP) - -p, --pvs show pvs options - -D, --debug print debug information - -v, --version print version and exit - -h, --help print usage information and exit - -S, --runscript change path to run-virt.sh - -T --tab default tab (0=xsession, 1=my vms, 2=all vms) - --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests) - --start-uuid start lecture with the given uuid - -FILE can be a vmware .xml or an X .desktop file - - - Requested --config not found: Gewünschte --config nicht gefunden: @@ -68,6 +39,37 @@ FILE can be a vmware .xml or an X .desktop file No config file found or given Keine Konfiguration angegeben und/oder gefunden + + Usage: vmchooser [ OPTIONS ] + + --allow-vm-edit show the 'edit this vm' checkbox + --autoquit [secs] automatically exit if no selection is made after secs seconds + -b --base base directory where VM images are accessible + -d, --default name of default session + -c, --config alternative config file + -l, --locations location id(s), space separated + --location-mode how to treat entries for this location (IGNORE, BUMP or EXCLUSIVE) + --exam-mode enable exam mode + -P, --pool one or more pool names to display (comma separated) + -f, --file direct boot .desktop file + -x, --xpath path of X Session .desktop files + -u, --url url of vmware .xml file + -s, --size window size <width>x<height> + -t, --theme theme + --template-mode how to treat template entries (IGNORE or BUMP) + -p, --pvs show pvs options + -D, --debug print debug information + -v, --version print version and exit + -h, --help print usage information and exit + -S, --runscript change path to run-virt.sh + -T --tab default tab (0=xsession, 1=my vms, 2=all vms) + --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests) + --start-uuid start lecture with the given uuid + +FILE can be a vmware .xml or an X .desktop file + + + Dialog @@ -203,6 +205,10 @@ FILE can be a vmware .xml or an X .desktop file Could not get help (XML has no //news/info) Konnte Hilfe nicht abrufen (//news/info nicht gefunden) + + Edit VM + Adminmodus (VM Bearbeiten) + QObject diff --git a/src/i18n/pt.ts b/src/i18n/pt.ts index c331c47..f873fe8 100755 --- a/src/i18n/pt.ts +++ b/src/i18n/pt.ts @@ -7,74 +7,76 @@ Usage: vmchooser [ OPTIONS ] - -b --base base directory where VM images are accessible - -d, --default name of default session - -c, --config alternative config file - -l, --locations location id(s), space separated - --location-mode how to treat entries for this location (IGNORE, BUMP or EXCLUSIVE) - --exam-mode enable exam mode - -P, --pool one or more pool names to display (comma separated) - -f, --file direct boot .desktop file - -x, --xpath path of X Session .desktop files - -u, --url url of vmware .xml file - -s, --size window size <width>x<height> - -t, --theme theme - --template-mode how to treat template entries (IGNORE or BUMP) - -p, --pvs show pvs options - -D, --debug print debug information - -v, --version print version and exit - -h, --help print usage information and exit - -S, --runscript change path to run-virt.sh - -T --tab default tab (0=xsession, 1=my vms, 2=all vms) - --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests) - --start-uuid start lecture with the given uuid + --allow-vm-edit show the 'edit this vm' checkbox + --autoquit [secs] automatically exit if no selection is made after secs seconds + -b --base base directory where VM images are accessible + -d, --default name of default session + -c, --config alternative config file + -l, --locations location id(s), space separated + --location-mode how to treat entries for this location (IGNORE, BUMP or EXCLUSIVE) + --exam-mode enable exam mode + -P, --pool one or more pool names to display (comma separated) + -f, --file direct boot .desktop file + -x, --xpath path of X Session .desktop files + -u, --url url of vmware .xml file + -s, --size window size <width>x<height> + -t, --theme theme + --template-mode how to treat template entries (IGNORE or BUMP) + -p, --pvs show pvs options + -D, --debug print debug information + -v, --version print version and exit + -h, --help print usage information and exit + -S, --runscript change path to run-virt.sh + -T --tab default tab (0=xsession, 1=my vms, 2=all vms) + --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests) + --start-uuid start lecture with the given uuid FILE can be a vmware .xml or an X .desktop file - + vmchooser: failed to run session vmchooser: falhou ao executar a sessão - + vmchooser: invalid session file vmchooser: arquivo de sessão inválido - + Requested --config not found: - + Using user specific config: - + Using global config: - + No config file found or given - + vmchooser: no URL given - + vmchooser: invalid URL - + vmchooser: invalid size argument @@ -83,7 +85,7 @@ FILE can be a vmware .xml or an X .desktop file Dialog - + vmchooser seletor @@ -148,27 +150,32 @@ FILE can be a vmware .xml or an X .desktop file - + + Edit VM + + + + Join PVS - + Report Bug - + Help/News - + Abort Interromper - + Start Iniciar @@ -193,37 +200,37 @@ FILE can be a vmware .xml or an X .desktop file - + Auto logout in %1 - + Native Linux - + Could not get news. - + Could not get news. (//news/date or //news/info missing) - + Could not get help. - + Could not get help (XML has no //news/info) - + Vmchooser failed to run the selected session! O seletor da VM falhou ao executar a sessão selecionada! diff --git a/src/main.cpp b/src/main.cpp index 74cee75..2f1dfab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,27 +34,29 @@ int main(int argc, char *argv[]) { std::string usage( a.translate("Console", "Usage: vmchooser [ OPTIONS ]\n\n" - " -b --base base directory where VM images are accessible\n" - " -d, --default name of default session\n" - " -c, --config alternative config file\n" - " -l, --locations location id(s), space separated\n" - " --location-mode how to treat entries for this location (IGNORE, BUMP or EXCLUSIVE)\n" - " --exam-mode enable exam mode\n" - " -P, --pool one or more pool names to display (comma separated)\n" - " -f, --file direct boot .desktop file\n" - " -x, --xpath path of X Session .desktop files\n" - " -u, --url url of vmware .xml file\n" - " -s, --size window size x\n" - " -t, --theme theme\n" - " --template-mode how to treat template entries (IGNORE or BUMP)\n" - " -p, --pvs show pvs options\n" - " -D, --debug print debug information\n" - " -v, --version print version and exit\n" - " -h, --help print usage information and exit\n" - " -S, --runscript change path to run-virt.sh\n" - " -T --tab default tab (0=xsession, 1=my vms, 2=all vms)\n" - " --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests)\n" - " --start-uuid start lecture with the given uuid\n" + " --allow-vm-edit show the 'edit this vm' checkbox\n" + " --autoquit [secs] automatically exit if no selection is made after secs seconds\n" + " -b --base base directory where VM images are accessible\n" + " -d, --default name of default session\n" + " -c, --config alternative config file\n" + " -l, --locations location id(s), space separated\n" + " --location-mode how to treat entries for this location (IGNORE, BUMP or EXCLUSIVE)\n" + " --exam-mode enable exam mode\n" + " -P, --pool one or more pool names to display (comma separated)\n" + " -f, --file direct boot .desktop file\n" + " -x, --xpath path of X Session .desktop files\n" + " -u, --url url of vmware .xml file\n" + " -s, --size window size x\n" + " -t, --theme theme\n" + " --template-mode how to treat template entries (IGNORE or BUMP)\n" + " -p, --pvs show pvs options\n" + " -D, --debug print debug information\n" + " -v, --version print version and exit\n" + " -h, --help print usage information and exit\n" + " -S, --runscript change path to run-virt.sh\n" + " -T --tab default tab (0=xsession, 1=my vms, 2=all vms)\n" + " --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests)\n" + " --start-uuid start lecture with the given uuid\n" "\nFILE can be a vmware .xml or an X .desktop file\n").toUtf8().data()); if (cmdOptions.contains("error")) { @@ -266,6 +268,20 @@ int main(int argc, char *argv[]) { g_noVtx = true; } + if (cmdOptions.contains("pvs")) { + pvsEnabled = true; + } + + if (cmdOptions.contains("autoquit")) { + bool ok = false; + g_autoQuitSeconds = cmdOptions.value("autoquit").toInt(&ok, 10); + if (!ok) { + g_autoQuitSeconds = 0; + } + } + + g_allowVmEdit = cmdOptions.contains("allow-vm-edit"); + /* read session files */ QList xsessions(XSession::readSessions(xSessionPath)); @@ -296,17 +312,6 @@ int main(int argc, char *argv[]) { w.setTheme(); w.setWindowFlags(Qt::FramelessWindowHint); - if (cmdOptions.contains("pvs")) { - pvsEnabled = true; - } - - if (cmdOptions.contains("autoquit")) { - bool ok = false; - g_autoQuitSeconds = cmdOptions.value("autoquit").toInt(&ok, 10); - if (!ok) { - g_autoQuitSeconds = 0; - } - } QRect desktopRect = QApplication::desktop()->availableGeometry(&w); if (size == "fullscreen") { diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui index cde9282..6516207 100644 --- a/src/ui/dialog.ui +++ b/src/ui/dialog.ui @@ -132,8 +132,8 @@ margin-bottom:0px;} <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Loading...</p></body></html> +</style></head><body style=" font-family:'DejaVuSans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans';">Loading...</span></p></body></html> @@ -164,8 +164,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Loading...</p></body></html> +</style></head><body style=" font-family:'DejaVuSans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans';">Loading...</span></p></body></html> @@ -492,8 +492,8 @@ border:1px solid #999; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Click on an item on the left side for more information</p></body></html> +</style></head><body style=" font-family:'DejaVuSans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans';">Click on an item on the left side for more information</span></p></body></html> @@ -527,6 +527,13 @@ p, li { white-space: pre-wrap; } + + + + Edit VM + + + -- cgit v1.2.3-55-g7522