diff --git a/interface/src/ui/RunningScriptsWidget.cpp b/interface/src/ui/RunningScriptsWidget.cpp index 86db1c71fe..5eac34731f 100644 --- a/interface/src/ui/RunningScriptsWidget.cpp +++ b/interface/src/ui/RunningScriptsWidget.cpp @@ -3,6 +3,7 @@ // interface/src/ui // // Created by Mohammed Nafees on 03/28/2014. +// Updated by Ryan Huffman on 05/13/2014. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -18,17 +19,17 @@ #include #include #include -#include -#include "ScriptListModel.h" #include "Application.h" +#include "Menu.h" +#include "ScriptsModel.h" RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) : FramelessDialog(parent, 0, POSITION_LEFT), ui(new Ui::RunningScriptsWidget), - _fsm(this), - _spm(this) { + _scriptsModel(this), + _proxyModel(this) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, false); @@ -42,17 +43,13 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) : ui->recentlyLoadedScriptsArea->hide(); - _fsm.setReadOnly(true); - _fsm.setRootPath(QDir("/Users/huffman/dev/hifi-19644/examples").absolutePath()); - _fsm.setFilter(QDir::NoDotAndDotDot | QDir::Files); - _fsm.setNameFilterDisables(false); - _fsm.setNameFilters(QStringList("*.js")); - _spm.setSourceModel(&_fsm); - _spm.sort(0, Qt::AscendingOrder); - _spm.setDynamicSortFilter(true); - ui->scriptListView->setModel(&_spm); + QString scriptPath = "/Users/huffman/dev/hifi-19644/examples";//Application::getInstance()->getPreviousScriptLocation(); + + _proxyModel.setSourceModel(&_scriptsModel); + _proxyModel.sort(0, Qt::AscendingOrder); + _proxyModel.setDynamicSortFilter(true); + ui->scriptListView->setModel(&_proxyModel); ui->scriptListView->setAttribute(Qt::WA_MacShowFocusRect, false); - ui->scriptListView->setRootIndex(_spm.mapFromSource(_fsm.index("/Users/huffman/dev/hifi-19644/examples"))); connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &RunningScriptsWidget::updateFileFilter); connect(ui->scriptListView, &QListView::doubleClicked, this, &RunningScriptsWidget::scriptFileSelected); @@ -88,6 +85,17 @@ RunningScriptsWidget::~RunningScriptsWidget() { delete ui; } +void RunningScriptsWidget::updateFileFilter(const QString& filter) { + QRegExp regex("^.*" + QRegExp::escape(filter) + ".*$", Qt::CaseInsensitive); + _proxyModel.setFilterRegExp(regex); +} + +void RunningScriptsWidget::scriptFileSelected(const QModelIndex& index) { + QVariant scriptFile = _proxyModel.data(index, ScriptsModel::ScriptPath); + qDebug() << "Loading: " << scriptFile.toString(); + Application::getInstance()->loadScript(scriptFile.toString()); +} + void RunningScriptsWidget::setBoundary(const QRect& rect) { _boundary = rect; } @@ -126,8 +134,6 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) { ui->runningScriptsTableWidget->resize(ui->runningScriptsTableWidget->width(), y - RUNNING_SCRIPTS_TABLE_LEFT_MARGIN); _runningScriptsTable->resize(_runningScriptsTable->width(), y - RUNNING_SCRIPTS_TABLE_LEFT_MARGIN); - ui->reloadAllButton->move(ui->reloadAllButton->x(), y); - ui->stopAllButton->move(ui->stopAllButton->x(), y); ui->recentlyLoadedLabel->move(ui->recentlyLoadedLabel->x(), ui->stopAllButton->y() + ui->stopAllButton->height() + RECENTLY_LOADED_TOP_MARGIN); ui->recentlyLoadedScriptsTableWidget->move(ui->recentlyLoadedScriptsTableWidget->x(), @@ -173,10 +179,12 @@ void RunningScriptsWidget::paintEvent(QPaintEvent* event) { QPainter painter(this); painter.setPen(QColor::fromRgb(225, 225, 225)); // #e1e1e1 + const QPoint& labelPos = ui->runningScriptsArea->mapToParent(ui->currentlyRunningLabel->pos()); + if (ui->currentlyRunningLabel->isVisible()) { // line below the 'Currently Running' label - painter.drawLine(36, ui->currentlyRunningLabel->y() + ui->currentlyRunningLabel->height(), - 300, ui->currentlyRunningLabel->y() + ui->currentlyRunningLabel->height()); + painter.drawLine(36, labelPos.y() + ui->currentlyRunningLabel->height(), + 300, labelPos.y() + ui->currentlyRunningLabel->height()); } if (ui->recentlyLoadedLabel->isVisible()) { diff --git a/interface/src/ui/RunningScriptsWidget.h b/interface/src/ui/RunningScriptsWidget.h index ad310c4ed4..6b45ac2202 100644 --- a/interface/src/ui/RunningScriptsWidget.h +++ b/interface/src/ui/RunningScriptsWidget.h @@ -3,6 +3,7 @@ // interface/src/ui // // Created by Mohammed Nafees on 03/28/2014. +// Updated by Ryan Huffman on 05/13/2014. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -12,6 +13,10 @@ #ifndef hifi_RunningScriptsWidget_h #define hifi_RunningScriptsWidget_h +#include +#include + +#include "ScriptsModel.h" #include "FramelessDialog.h" #include "ScriptsTableWidget.h" @@ -42,9 +47,13 @@ private slots: void stopScript(int row, int column); void loadScript(int row, int column); void allScriptsStopped(); + void updateFileFilter(const QString& filter); + void scriptFileSelected(const QModelIndex& index); private: Ui::RunningScriptsWidget* ui; + QSortFilterProxyModel _proxyModel; + ScriptsModel _scriptsModel; ScriptsTableWidget* _runningScriptsTable; ScriptsTableWidget* _recentlyLoadedScriptsTable; QStringList _recentlyLoadedScripts; diff --git a/interface/ui/runningScriptsWidget.ui b/interface/ui/runningScriptsWidget.ui index 6abd0f2d5a..324a460d1b 100644 --- a/interface/ui/runningScriptsWidget.ui +++ b/interface/ui/runningScriptsWidget.ui @@ -6,8 +6,8 @@ 0 0 - 323 - 894 + 324 + 971 @@ -21,252 +21,586 @@ QWidget { background: #f7f7f7; } - - - - 37 - 29 - 251 - 20 - + + + 20 - - color: #0e7077; + + 20 + + + 20 + + + 20 + + + + + + 0 + + + 0 + + + 0 + + + + + color: #0e7077; font-size: 20pt; background: transparent; - - - <html><head/><body><p><span style=" font-size:18pt;">Running Scripts</span></p></body></html> - - - 0 - - - -1 - - - - - - 36 - 110 - 270 - 20 - - - - color: #0e7077; -font: bold 14pt; + + + <html><head/><body><p><span style=" font-size:18pt;">Running Scripts</span></p></body></html> + + + 0 + + + -1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PointingHandCursor + + + border: 0 + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + 0 + 1 + + + + + 0 + 141 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Helvetica,Arial,sans-serif + 16 + 75 + false + true + + + + color: #0e7077; +font: bold 16pt; background: transparent; - - - <html><head/><body><p><span style=" font-weight:600;">Currently running</span></p></body></html> - - - - - - 36 - 270 - 111 - 35 - - - - PointingHandCursor - - - false - - - background: #0e7077; + + + <html><head/><body><p><span style=" font-weight:600;">Currently running</span></p></body></html> + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 0 + 8 + + + + + + + + + 0 + 0 + + + + + 24 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 111 + 35 + + + + PointingHandCursor + + + false + + + background: #0e7077; color: #fff; border-radius: 4px; font: bold 14pt; padding-top: 3px; - - - Reload all - - - - ../resources/images/reload.svg../resources/images/reload.svg - - - - - - 160 - 270 - 93 - 35 - - - - PointingHandCursor - - - background: #0e7077; + + + Reload all + + + + ../../../../../../../../.designer/resources/images/reload.svg../../../../../../../../.designer/resources/images/reload.svg + + + + + + + + 0 + 0 + + + + + 111 + 35 + + + + PointingHandCursor + + + background: #0e7077; color: #fff; border-radius: 4px; font: bold 14pt; padding-top: 3px; - - - Stop all - - - - ../resources/images/stop.svg../resources/images/stop.svg - - - - - - 36 - 320 - 265 - 20 - - - - color: #0e7077; -font: bold 14pt; - - - <html><head/><body><p><span style=" font-weight:600;">Recently loaded</span></p></body></html> - - - - - - 36 - 630 - 211 - 41 - - - - color: #95a5a6; + + + Stop all + + + + ../../../../../../../../.designer/resources/images/stop.svg../../../../../../../../.designer/resources/images/stop.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + font: 14pt; + + + There are no scripts currently running. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 20 + 10 + + + + + + + + + 0 + 1 + + + + + 284 + 0 + + + + 0 + + + background: transparent; font-size: 14pt; - - - (click a script or use the 1-9 keys to load and run it) - - - true - - - - - - 285 - 29 - 16 - 16 - - - - PointingHandCursor - - - - - - - 16 - 16 - - - - true - - - - - - 36 - 110 - 271 - 51 - - - - font: 14pt; - - - There are no scripts currently running. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 30 - 340 - 272 - 280 - - - - background: transparent; + + + + + + + + + + true + + + + 0 + 100 + + + + + 16777215 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + color: #0e7077; +font: bold 16pt; + + + <html><head/><body><p><span style=" font-weight:600;">Recently loaded</span></p></body></html> + + + + + + + font: 14pt; + + + There are no recently loaded scripts. + + + + + + + + 0 + 1 + + + + + 284 + 0 + + + + background: transparent; font-size: 14pt; - - - - - - 30 - 128 - 272 - 161 - - - - background: transparent; + + + + + + + color: #95a5a6; font-size: 14pt; - - - - - - 36 - 70 - 111 - 35 - - - - PointingHandCursor - - - background: #0e7077; + + + (click a script or use the 1-9 keys to load and run it) + + + true + + + + + + + + + + + 0 + 1 + + + + + 0 + 300 + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 15 + + + + + color: #0e7077; +font: bold 16pt; + + + Scripts + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 111 + 35 + + + + PointingHandCursor + + + background: #0e7077; color: #fff; border-radius: 4px; font: bold 14pt; padding-top: 3px; - - - Load script - - - - ../resources/images/plus.svg../resources/images/plus.svg - - - widgetTitle - currentlyRunningLabel - recentlyLoadedLabel - recentlyLoadedInstruction - hideWidgetButton - recentlyLoadedScriptsTableWidget - runningScriptsTableWidget - noRunningScriptsLabel - reloadAllButton - stopAllButton - loadScriptButton + + + Load script + + + + ../../../../../../../../.designer/resources/images/plus.svg../../../../../../../../.designer/resources/images/plus.svg + + + + + + + + + + border: 1px solid rgb(128, 128, 128); +border-radius: 2px; +padding: 4px; +background-color: white; + + + filter + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 6 + + + + + + + + border: 1px solid rgb(128, 128, 128); +border-radius: 2px; + + + QFrame::Box + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAsNeeded + + + + + + +