mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 19:23:04 +02:00
Add a reload script button after each script in list of running scripts
This commit is contained in:
parent
f220d40bb8
commit
5dab977c28
5 changed files with 84 additions and 6 deletions
50
interface/resources/images/reload-script.svg
Normal file
50
interface/resources/images/reload-script.svg
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 100 100"
|
||||
enable-background="new 0 0 100 100"
|
||||
xml:space="preserve"
|
||||
id="svg2"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="reload-script-43339.svg"><metadata
|
||||
id="metadata14"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs12" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1184"
|
||||
inkscape:window-height="655"
|
||||
id="namedview10"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.36"
|
||||
inkscape:cx="-12.5"
|
||||
inkscape:cy="56.355932"
|
||||
inkscape:window-x="424"
|
||||
inkscape:window-y="79"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg2" /><g
|
||||
id="g4"
|
||||
style="fill:#c4c4c4;fill-opacity:1"
|
||||
transform="matrix(1.0520186,0,0,1.0809642,-4.9561957,-7.0141066)"><g
|
||||
id="g6"
|
||||
style="fill:#c4c4c4;fill-opacity:1"><path
|
||||
d="m 8.139,47.902 14.505,0 c 1.51,0 2.838,-0.987 3.28,-2.429 1.222,-4.042 3.425,-7.649 6.357,-10.583 4.643,-4.627 10.918,-7.442 17.982,-7.45 7.056,0.008 13.331,2.823 17.979,7.45 0.144,0.147 0.271,0.31 0.411,0.457 L 59.46,46.155 c -0.257,0.299 -0.313,0.724 -0.157,1.078 0.173,0.365 0.53,0.59 0.923,0.584 l 38.526,0.111 c 0.294,0.005 0.581,-0.129 0.771,-0.352 0.197,-0.231 0.278,-0.527 0.23,-0.818 L 93.483,8.741 C 93.421,8.353 93.137,8.038 92.753,7.933 92.375,7.828 91.968,7.952 91.714,8.248 L 82.256,19.366 C 73.983,11.441 62.706,6.512 50.337,6.491 50.279,6.488 50.206,6.488 50.122,6.491 37.396,6.527 25.801,11.73 17.469,20.08 11.119,26.417 6.604,34.634 4.776,43.81 c -0.198,1.013 0.062,2.046 0.715,2.843 0.655,0.793 1.617,1.249 2.648,1.249 z m 90.845,10.939 c -0.652,-0.798 -1.618,-1.259 -2.646,-1.259 l -14.506,0 c -1.507,0 -2.836,0.991 -3.279,2.435 -1.223,4.039 -3.427,7.649 -6.357,10.587 -4.64,4.622 -10.915,7.439 -17.982,7.45 -7.056,-0.011 -13.331,-2.828 -17.979,-7.45 -0.144,-0.146 -0.269,-0.32 -0.41,-0.464 l 9.196,-10.811 c 0.256,-0.294 0.311,-0.717 0.154,-1.076 -0.173,-0.356 -0.527,-0.587 -0.923,-0.585 L 5.727,57.561 c -0.294,0 -0.581,0.126 -0.773,0.352 -0.195,0.229 -0.277,0.524 -0.229,0.824 l 6.271,38.012 c 0.062,0.388 0.345,0.701 0.729,0.812 0.378,0.104 0.784,-0.025 1.039,-0.322 L 22.22,86.125 c 8.278,7.922 19.553,12.859 31.921,12.87 0.06,0.005 0.131,0.005 0.215,0 12.729,-0.032 24.323,-5.237 32.655,-13.583 6.348,-6.338 10.865,-14.561 12.69,-23.728 0.199,-1.012 -0.062,-2.045 -0.717,-2.843 z"
|
||||
id="path8"
|
||||
style="fill:#c4c4c4;fill-opacity:1"
|
||||
inkscape:connector-curvature="0" /></g></g></svg>
|
After Width: | Height: | Size: 3.2 KiB |
|
@ -4317,6 +4317,19 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
|||
return scriptEngine;
|
||||
}
|
||||
|
||||
void Application::reloadScript(const QString& scriptFilename) {
|
||||
DependencyManager::get<ScriptCache>()->deleteScript(scriptFilename);
|
||||
|
||||
ScriptEngine* scriptEngine = _scriptEnginesHash.value(scriptFilename);
|
||||
connect(scriptEngine, SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&)));
|
||||
scriptEngine->stop();
|
||||
|
||||
// HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities
|
||||
// whenever a script stops in case it happened to have been setting joint rotations.
|
||||
// TODO: expose animation priorities and provide a layered animation control system.
|
||||
_myAvatar->clearScriptableSettings();
|
||||
}
|
||||
|
||||
void Application::handleScriptEngineLoaded(const QString& scriptFilename) {
|
||||
ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender());
|
||||
|
||||
|
|
|
@ -400,6 +400,7 @@ public slots:
|
|||
bool askToLoadScript(const QString& scriptFilenameOrURL);
|
||||
ScriptEngine* loadScript(const QString& scriptFilename = QString(), bool isUserLoaded = true,
|
||||
bool loadScriptFromEditor = false, bool activateMainWindow = false);
|
||||
void reloadScript(const QString& scriptFilename);
|
||||
void scriptFinished(const QString& scriptName);
|
||||
void stopAllScripts(bool restart = false);
|
||||
void stopScript(const QString& scriptName);
|
||||
|
|
|
@ -32,7 +32,8 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
|||
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
||||
Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::RunningScriptsWidget),
|
||||
_signalMapper(this),
|
||||
_reloadSignalMapper(this),
|
||||
_stopSignalMapper(this),
|
||||
_scriptsModelFilter(this),
|
||||
_scriptsModel(this) {
|
||||
ui->setupUi(this);
|
||||
|
@ -64,7 +65,8 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
|||
Application::getInstance(), &Application::loadDialog);
|
||||
connect(ui->loadScriptFromURLButton, &QPushButton::clicked,
|
||||
Application::getInstance(), &Application::loadScriptURLDialog);
|
||||
connect(&_signalMapper, SIGNAL(mapped(QString)), Application::getInstance(), SLOT(stopScript(const QString&)));
|
||||
connect(&_reloadSignalMapper, SIGNAL(mapped(QString)), Application::getInstance(), SLOT(reloadScript(const QString&)));
|
||||
connect(&_stopSignalMapper, SIGNAL(mapped(QString)), Application::getInstance(), SLOT(stopScript(const QString&)));
|
||||
|
||||
UIUtil::scaleWidgetFontSizes(this);
|
||||
}
|
||||
|
@ -115,6 +117,17 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
|||
name->setText(name->text() + "(" + QString::number(hash.find(list.at(i)).value()) + ")");
|
||||
}
|
||||
++hash[list.at(i)];
|
||||
|
||||
QPushButton* reloadButton = new QPushButton(row);
|
||||
reloadButton->setFlat(true);
|
||||
reloadButton->setIcon(
|
||||
QIcon(QPixmap(PathUtils::resourcesPath() + "images/reload-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT)));
|
||||
reloadButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
|
||||
reloadButton->setStyleSheet("border: 0;");
|
||||
reloadButton->setCursor(Qt::PointingHandCursor);
|
||||
connect(reloadButton, SIGNAL(clicked()), &_reloadSignalMapper, SLOT(map()));
|
||||
_reloadSignalMapper.setMapping(reloadButton, url.toString());
|
||||
|
||||
QPushButton* closeButton = new QPushButton(row);
|
||||
closeButton->setFlat(true);
|
||||
closeButton->setIcon(
|
||||
|
@ -122,9 +135,8 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
|||
closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
|
||||
closeButton->setStyleSheet("border: 0;");
|
||||
closeButton->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
connect(closeButton, SIGNAL(clicked()), &_signalMapper, SLOT(map()));
|
||||
_signalMapper.setMapping(closeButton, url.toString());
|
||||
connect(closeButton, SIGNAL(clicked()), &_stopSignalMapper, SLOT(map()));
|
||||
_stopSignalMapper.setMapping(closeButton, url.toString());
|
||||
|
||||
row->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
|
||||
|
@ -132,6 +144,7 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
|||
row->layout()->setSpacing(0);
|
||||
|
||||
row->layout()->addWidget(name);
|
||||
row->layout()->addWidget(reloadButton);
|
||||
row->layout()->addWidget(closeButton);
|
||||
|
||||
row->setToolTip(url.toString());
|
||||
|
|
|
@ -59,7 +59,8 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::RunningScriptsWidget* ui;
|
||||
QSignalMapper _signalMapper;
|
||||
QSignalMapper _reloadSignalMapper;
|
||||
QSignalMapper _stopSignalMapper;
|
||||
ScriptsModelFilter _scriptsModelFilter;
|
||||
ScriptsModel _scriptsModel;
|
||||
ScriptsTableWidget* _recentlyLoadedScriptsTable;
|
||||
|
|
Loading…
Reference in a new issue