From 8f6ad2faabf0317a1bd1bab3cfb580b1b11f182b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 28 May 2014 15:27:50 -0700 Subject: [PATCH] Add 'Load default scripts' button to preferences --- interface/src/Application.cpp | 10 +++- interface/src/Application.h | 1 + interface/src/ui/PreferencesDialog.cpp | 2 + interface/ui/preferencesDialog.ui | 82 ++++++++++++++++++++++++-- 4 files changed, 89 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fac0ef154f..d2b05f2cc4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -105,6 +105,8 @@ const int STARTUP_JITTER_SAMPLES = NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL / 2 const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml"; const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion"; +const QString DEFAULT_SCRIPTS_JS_URL = "http://public.highfidelity.io/scripts/defaultScripts.js"; + void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { if (message.size() > 0) { QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate); @@ -362,7 +364,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : qDebug() << "This is a first run..."; // clear the scripts, and set out script to our default scripts clearScriptsBeforeRunning(); - loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); + loadScript(DEFAULT_SCRIPTS_JS_URL); QMutexLocker locker(&_settingsMutex); _settings->setValue("firstRun",QVariant(false)); @@ -3362,6 +3364,12 @@ void Application::reloadAllScripts() { stopAllScripts(true); } +void Application::loadDefaultScripts() { + if (!_scriptEnginesHash.contains(DEFAULT_SCRIPTS_JS_URL)) { + loadScript(DEFAULT_SCRIPTS_JS_URL); + } +} + void Application::manageRunningScriptsWidgetVisibility(bool shown) { if (_runningScriptsWidgetWasVisible && shown) { _runningScriptsWidget->show(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 0065944611..0d4f1c89d6 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -328,6 +328,7 @@ public slots: void stopAllScripts(bool restart = false); void stopScript(const QString& scriptName); void reloadAllScripts(); + void loadDefaultScripts(); void toggleRunningScriptsWidget(); void uploadHead(); diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index ed2d7097db..d5c6079d4b 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -29,6 +29,8 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags flags) : F connect(ui.buttonBrowseHead, &QPushButton::clicked, this, &PreferencesDialog::openHeadModelBrowser); connect(ui.buttonBrowseBody, &QPushButton::clicked, this, &PreferencesDialog::openBodyModelBrowser); connect(ui.buttonBrowseLocation, &QPushButton::clicked, this, &PreferencesDialog::openSnapshotLocationBrowser); + connect(ui.buttonReloadDefaultScripts, &QPushButton::clicked, + Application::getInstance(), &Application::loadDefaultScripts); } void PreferencesDialog::accept() { diff --git a/interface/ui/preferencesDialog.ui b/interface/ui/preferencesDialog.ui index bab431160d..a1c2073ab6 100644 --- a/interface/ui/preferencesDialog.ui +++ b/interface/ui/preferencesDialog.ui @@ -134,8 +134,8 @@ color: #0e7077 0 30 - 615 - 491 + 494 + 384 @@ -154,9 +154,9 @@ color: #0e7077 0 - -271 - 598 - 1018 + -204 + 494 + 1091 @@ -612,6 +612,78 @@ color: #0e7077 + + + + + 0 + 0 + + + + + 0 + 40 + + + + + Arial + 20 + 50 + false + + + + color: #0e7077 + + + Scripts + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + + 0 + 0 + + + + background: #0e7077; +color: #fff; +border-radius: 4px; +font: bold 14pt; +padding: 10px;margin-top:10px + + + Load Default Scripts + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + +