Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
OpenSpace
Commits
3dea3ef5
Commit
3dea3ef5
authored
3 years ago
by
Alexander Bock
Browse files
Options
Download
Email Patches
Plain Diff
Add ability to select profile properties from a ScriptLog (closes #1780)
parent
94d9a5a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/OpenSpace/ext/launcher/include/profile/propertiesdialog.h
+4
-0
...OpenSpace/ext/launcher/include/profile/propertiesdialog.h
apps/OpenSpace/ext/launcher/src/profile/propertiesdialog.cpp
+96
-0
apps/OpenSpace/ext/launcher/src/profile/propertiesdialog.cpp
with
100 additions
and
0 deletions
+100
-0
apps/OpenSpace/ext/launcher/include/profile/propertiesdialog.h
+
4
-
0
View file @
3dea3ef5
...
...
@@ -65,6 +65,8 @@ private slots:
void
transitionToEditMode
();
void
parseSelections
();
void
selectLineFromScriptLog
();
private:
void
createWidgets
();
...
...
@@ -81,6 +83,8 @@ private:
QListWidget
*
_list
=
nullptr
;
QPushButton
*
_addButton
=
nullptr
;
QPushButton
*
_removeButton
=
nullptr
;
QPushButton
*
_fillFromScriptLog
=
nullptr
;
QLabel
*
_commandLabel
=
nullptr
;
QComboBox
*
_commandCombo
=
nullptr
;
QLabel
*
_propertyLabel
=
nullptr
;
...
...
This diff is collapsed.
Click to expand it.
apps/OpenSpace/ext/launcher/src/profile/propertiesdialog.cpp
+
96
-
0
View file @
3dea3ef5
...
...
@@ -25,6 +25,7 @@
#include
"profile/propertiesdialog.h"
#include
"profile/line.h"
#include
<ghoul/filesystem/filesystem.h>
#include
<QComboBox>
#include
<QDialogButtonBox>
#include
<QEvent>
...
...
@@ -33,6 +34,7 @@
#include
<QLineEdit>
#include
<QListWidget>
#include
<QPushButton>
#include
<QTextStream>
#include
<QVBoxLayout>
#include
<iostream>
...
...
@@ -93,6 +95,13 @@ void PropertiesDialog::createWidgets() {
}
layout
->
addWidget
(
new
Line
);
{
_fillFromScriptLog
=
new
QPushButton
(
"Fill from ScriptLog"
);
connect
(
_fillFromScriptLog
,
&
QPushButton
::
clicked
,
this
,
&
PropertiesDialog
::
selectLineFromScriptLog
);
layout
->
addWidget
(
_fillFromScriptLog
);
_commandLabel
=
new
QLabel
(
"Property Set Command"
);
layout
->
addWidget
(
_commandLabel
);
...
...
@@ -333,6 +342,7 @@ void PropertiesDialog::transitionFromEditMode() {
}
void
PropertiesDialog
::
editBoxDisabled
(
bool
disabled
)
{
_fillFromScriptLog
->
setDisabled
(
disabled
);
_commandLabel
->
setDisabled
(
disabled
);
_commandCombo
->
setDisabled
(
disabled
);
_propertyLabel
->
setDisabled
(
disabled
);
...
...
@@ -368,3 +378,89 @@ void PropertiesDialog::keyPressEvent(QKeyEvent* evt) {
QDialog
::
keyPressEvent
(
evt
);
}
void
PropertiesDialog
::
selectLineFromScriptLog
()
{
QComboBox
*
comboBox
=
new
QComboBox
;
QFile
file
(
QString
::
fromStdString
(
absPath
(
"${LOGS}/scriptLog.txt"
).
string
()));
if
(
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
QTextStream
in
(
&
file
);
while
(
!
in
.
atEnd
())
{
QString
line
=
in
.
readLine
();
// removing return from a few statments
// these are usually generated by gui panels
line
.
remove
(
QRegularExpression
(
"^return "
));
if
(
line
.
isEmpty
())
{
continue
;
}
if
(
!
line
.
startsWith
(
"openspace.setPropertyValue"
))
{
continue
;
}
comboBox
->
addItem
(
line
);
}
}
QDialog
dialog
;
connect
(
&
dialog
,
&
QDialog
::
finished
,
[
this
,
comboBox
](
int
result
)
{
if
(
result
==
QDialog
::
Rejected
)
{
return
;
}
QString
text
=
comboBox
->
currentText
();
if
(
!
text
.
startsWith
(
"openspace.setPropertyValue"
))
{
return
;
}
// We have a string that is of the form:
// openspace.setPropertyValue('prop', value);
if
(
text
.
startsWith
(
"openspace.setPropertyValueSingle"
))
{
using
namespace
std
::
string_view_literals
;
_commandCombo
->
setCurrentIndex
(
0
);
text
=
text
.
mid
(
"openspace.setPropertyValueSingle"
sv
.
size
()
+
1
);
// +1 for (
}
else
{
// command == "openspace.setPropertyValue"
using
namespace
std
::
string_view_literals
;
_commandCombo
->
setCurrentIndex
(
1
);
text
=
text
.
mid
(
"openspace.setPropertyValue"
sv
.
size
()
+
1
);
// +1 for (
}
// Remove everything past the closing brace
text
=
text
.
left
(
text
.
indexOf
(
")"
));
QStringList
textList
=
text
.
split
(
","
);
if
(
textList
.
size
()
<
2
)
{
return
;
}
// Remove the string markers around the property
QString
property
=
textList
[
0
].
mid
(
1
,
textList
[
0
].
size
()
-
2
);
textList
.
removeFirst
();
QString
value
=
textList
.
join
(
","
);
_propertyEdit
->
setText
(
property
.
trimmed
());
_valueEdit
->
setText
(
value
.
trimmed
());
});
QLayout
*
layout
=
new
QVBoxLayout
;
QLabel
*
label
=
new
QLabel
(
"Select a line from the Script Log to add"
);
layout
->
addWidget
(
label
);
layout
->
addWidget
(
comboBox
);
QDialogButtonBox
*
bb
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
connect
(
bb
,
&
QDialogButtonBox
::
accepted
,
&
dialog
,
&
QDialog
::
accept
);
connect
(
bb
,
&
QDialogButtonBox
::
rejected
,
&
dialog
,
&
QDialog
::
reject
);
layout
->
addWidget
(
bb
);
dialog
.
setLayout
(
layout
);
dialog
.
exec
();
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment