MarkNodes and Meta support in profiles

This commit is contained in:
GPayne
2020-09-11 12:40:22 -06:00
parent cd084d12be
commit 66aa8bc4be
9 changed files with 831 additions and 0 deletions
@@ -30,6 +30,8 @@ set(HEADER_FILES
include/filesystemaccess.h
include/keybindings.h
include/launcherwindow.h
include/marknodes.h
include/meta.h
include/profileedit.h
include/ui_addedscripts.h
include/ui_assets.h
@@ -37,6 +39,8 @@ set(HEADER_FILES
include/ui_deltatimes.h
include/ui_keybindings.h
include/ui_launcherwindow.h
include/ui_marknodes.h
include/ui_meta.h
include/ui_profileedit.h
)
@@ -50,6 +54,8 @@ set(SOURCE_FILES
src/filesystemaccess.cpp
src/keybindings.cpp
src/launcherwindow.cpp
src/marknodes.cpp
src/meta.cpp
src/profileedit.cpp
)
@@ -0,0 +1,36 @@
#ifndef MARKNODES_H
#define MARKNODES_H
#include <QDialog>
#include <QWidget>
#include <QListWidgetItem>
QT_BEGIN_NAMESPACE
namespace Ui {
class markNodes;
}
QT_END_NAMESPACE
class markNodes : public QDialog
{
Q_OBJECT
public slots:
void listItemSelected();
void listItemAdded();
void listItemRemove();
void parseSelections();
public:
explicit markNodes(std::vector<std::string>& imported, QWidget *parent = nullptr);
~markNodes();
private:
Ui::markNodes *ui;
QWidget* _parent;
std::vector<QListWidgetItem*> _markedNodesListItems;
std::vector<std::string>& _imported;
std::vector<std::string> _data;
};
#endif // MARKNODES_H
@@ -0,0 +1,39 @@
#ifndef META_H
#define META_H
#include <QDialog>
#include <QWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
class meta;
}
QT_END_NAMESPACE
struct Meta {
std::string name;
std::string version;
std::string description;
std::string author;
std::string url;
std::string license;
};
class meta : public QDialog
{
Q_OBJECT
public slots:
void save();
public:
explicit meta(Meta& imported, QWidget *parent = nullptr);
~meta();
private:
Ui::meta *ui;
QWidget* _parent;
Meta& _imported;
};
#endif // META_H
@@ -0,0 +1,102 @@
/********************************************************************************
** Form generated from reading UI file 'markNodes.ui'
**
** Created by: Qt User Interface Compiler version 5.15.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MARKNODES_H
#define UI_MARKNODES_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QPushButton>
QT_BEGIN_NAMESPACE
class Ui_markNodes
{
public:
QDialogButtonBox *buttonBox;
QListWidget *list;
QPushButton *button_remove;
QLabel *label_node;
QLineEdit *line_node;
QPushButton *button_add;
void setupUi(QDialog *markNodes)
{
if (markNodes->objectName().isEmpty())
markNodes->setObjectName(QString::fromUtf8("markNodes"));
markNodes->resize(295, 335);
buttonBox = new QDialogButtonBox(markNodes);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(30, 290, 251, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
list = new QListWidget(markNodes);
list->setObjectName(QString::fromUtf8("list"));
list->setGeometry(QRect(10, 10, 271, 120));
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(list->sizePolicy().hasHeightForWidth());
list->setSizePolicy(sizePolicy);
list->setMinimumSize(QSize(0, 50));
list->setMaximumSize(QSize(16777215, 120));
QFont font;
font.setFamily(QString::fromUtf8("Arial"));
list->setFont(font);
list->setAlternatingRowColors(true);
list->setMovement(QListView::Free);
list->setResizeMode(QListView::Adjust);
button_remove = new QPushButton(markNodes);
button_remove->setObjectName(QString::fromUtf8("button_remove"));
button_remove->setGeometry(QRect(10, 140, 111, 25));
label_node = new QLabel(markNodes);
label_node->setObjectName(QString::fromUtf8("label_node"));
label_node->setGeometry(QRect(10, 190, 131, 20));
QFont font1;
font1.setFamily(QString::fromUtf8("Arial"));
font1.setPointSize(12);
label_node->setFont(font1);
line_node = new QLineEdit(markNodes);
line_node->setObjectName(QString::fromUtf8("line_node"));
line_node->setGeometry(QRect(10, 210, 271, 25));
button_add = new QPushButton(markNodes);
button_add->setObjectName(QString::fromUtf8("button_add"));
button_add->setGeometry(QRect(10, 240, 111, 25));
retranslateUi(markNodes);
QObject::connect(buttonBox, SIGNAL(accepted()), markNodes, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), markNodes, SLOT(reject()));
QMetaObject::connectSlotsByName(markNodes);
} // setupUi
void retranslateUi(QDialog *markNodes)
{
markNodes->setWindowTitle(QCoreApplication::translate("markNodes", "Mark Interesting Nodes", nullptr));
button_remove->setText(QCoreApplication::translate("markNodes", "Remove", nullptr));
label_node->setText(QCoreApplication::translate("markNodes", "Node to add:", nullptr));
#if QT_CONFIG(tooltip)
line_node->setToolTip(QCoreApplication::translate("markNodes", "<html><head/><body><p>Name of scenegraph node to add to list of &quot;interesting&quot; nodes</p></body></html>", nullptr));
#endif // QT_CONFIG(tooltip)
button_add->setText(QCoreApplication::translate("markNodes", "Add New", nullptr));
} // retranslateUi
};
namespace Ui {
class markNodes: public Ui_markNodes {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MARKNODES_H
@@ -0,0 +1,122 @@
/********************************************************************************
** Form generated from reading UI file 'meta.ui'
**
** Created by: Qt User Interface Compiler version 5.15.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_META_H
#define UI_META_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QTextEdit>
QT_BEGIN_NAMESPACE
class Ui_meta
{
public:
QDialogButtonBox *buttonBox;
QLabel *label_name;
QLineEdit *line_name;
QLabel *label_version;
QLineEdit *line_version;
QLabel *label_description;
QTextEdit *text_description;
QLabel *label_author;
QLineEdit *line_author;
QLineEdit *line_url;
QLabel *label_url;
QLineEdit *line_license;
QLabel *label_license;
void setupUi(QDialog *meta)
{
if (meta->objectName().isEmpty())
meta->setObjectName(QString::fromUtf8("meta"));
meta->resize(400, 443);
buttonBox = new QDialogButtonBox(meta);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(40, 390, 341, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
label_name = new QLabel(meta);
label_name->setObjectName(QString::fromUtf8("label_name"));
label_name->setGeometry(QRect(20, 20, 67, 17));
QFont font;
font.setFamily(QString::fromUtf8("Arial"));
font.setPointSize(12);
label_name->setFont(font);
line_name = new QLineEdit(meta);
line_name->setObjectName(QString::fromUtf8("line_name"));
line_name->setGeometry(QRect(20, 40, 331, 25));
label_version = new QLabel(meta);
label_version->setObjectName(QString::fromUtf8("label_version"));
label_version->setGeometry(QRect(20, 70, 67, 17));
label_version->setFont(font);
line_version = new QLineEdit(meta);
line_version->setObjectName(QString::fromUtf8("line_version"));
line_version->setGeometry(QRect(20, 90, 331, 25));
label_description = new QLabel(meta);
label_description->setObjectName(QString::fromUtf8("label_description"));
label_description->setGeometry(QRect(20, 120, 91, 17));
label_description->setFont(font);
text_description = new QTextEdit(meta);
text_description->setObjectName(QString::fromUtf8("text_description"));
text_description->setGeometry(QRect(20, 140, 331, 75));
label_author = new QLabel(meta);
label_author->setObjectName(QString::fromUtf8("label_author"));
label_author->setGeometry(QRect(20, 220, 67, 17));
label_author->setFont(font);
line_author = new QLineEdit(meta);
line_author->setObjectName(QString::fromUtf8("line_author"));
line_author->setGeometry(QRect(20, 240, 331, 25));
line_url = new QLineEdit(meta);
line_url->setObjectName(QString::fromUtf8("line_url"));
line_url->setGeometry(QRect(20, 290, 331, 25));
label_url = new QLabel(meta);
label_url->setObjectName(QString::fromUtf8("label_url"));
label_url->setGeometry(QRect(20, 270, 67, 17));
label_url->setFont(font);
line_license = new QLineEdit(meta);
line_license->setObjectName(QString::fromUtf8("line_license"));
line_license->setGeometry(QRect(20, 340, 331, 25));
label_license = new QLabel(meta);
label_license->setObjectName(QString::fromUtf8("label_license"));
label_license->setGeometry(QRect(20, 320, 67, 17));
label_license->setFont(font);
retranslateUi(meta);
//QObject::connect(buttonBox, SIGNAL(accepted()), meta, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), meta, SLOT(reject()));
QMetaObject::connectSlotsByName(meta);
} // setupUi
void retranslateUi(QDialog *meta)
{
meta->setWindowTitle(QCoreApplication::translate("meta", "Meta", nullptr));
label_name->setText(QCoreApplication::translate("meta", "Name", nullptr));
label_version->setText(QCoreApplication::translate("meta", "Version", nullptr));
label_description->setText(QCoreApplication::translate("meta", "Description", nullptr));
label_author->setText(QCoreApplication::translate("meta", "Author", nullptr));
label_url->setText(QCoreApplication::translate("meta", "URL", nullptr));
line_license->setText(QString());
label_license->setText(QCoreApplication::translate("meta", "License", nullptr));
} // retranslateUi
};
namespace Ui {
class meta: public Ui_meta {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_META_H
@@ -0,0 +1,79 @@
#include "marknodes.h"
#include "./ui_marknodes.h"
#include <qevent.h>
#include <iterator>
markNodes::markNodes(std::vector<std::string>& imported, QWidget *parent)
: QDialog(parent)
, ui(new Ui::markNodes)
, _imported(imported)
, _data(imported)
{
ui->setupUi(this);
for (size_t i = 0; i < _data.size(); ++i) {
_markedNodesListItems.push_back(
new QListWidgetItem(QString(_data[i].c_str()))
);
ui->list->addItem(_markedNodesListItems[i]);
}
ui->line_node->setText("");
connect(ui->list, SIGNAL(itemSelectionChanged()), this, SLOT(listItemSelected()));
connect(ui->button_add, SIGNAL(clicked()), this, SLOT(listItemAdded()));
connect(ui->button_remove, SIGNAL(clicked()), this, SLOT(listItemRemove()));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(parseSelections()));
}
void markNodes::listItemSelected(void) {
ui->button_remove->setDisabled(false);
}
void markNodes::listItemAdded(void) {
if (ui->line_node->text().length() == 0) {
return;
}
std::string itemToAdd = ui->line_node->text().toUtf8().constData();
auto idx = std::find(_data.begin(), _data.end(), itemToAdd);
if (idx != _data.end()) {
ui->list->setCurrentRow(std::distance(_data.begin(), idx));
}
else {
_data.push_back(itemToAdd);
_markedNodesListItems.push_back(new QListWidgetItem(ui->line_node->text()));
ui->list->addItem(_markedNodesListItems.back());
//Scroll down to that blank line highlighted
ui->list->setCurrentItem(_markedNodesListItems.back());
}
//Blank-out entry again
ui->line_node->setText("");
}
void markNodes::listItemRemove(void) {
QListWidgetItem *item = ui->list->currentItem();
int index = ui->list->row(item);
if (index < 0 || index >= _markedNodesListItems.size()) {
return;
}
ui->list->takeItem(index);
_data.erase(_data.begin() + index);
_markedNodesListItems.erase(_markedNodesListItems.begin() + index);
}
void markNodes::parseSelections() {
_imported = _data;
accept();
}
markNodes::~markNodes() {
for (auto n : _markedNodesListItems) {
delete n;
}
delete ui;
}
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>markNodes</class>
<widget class="QDialog" name="markNodes">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>295</width>
<height>335</height>
</rect>
</property>
<property name="windowTitle">
<string>Mark Interesting Nodes</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>290</y>
<width>251</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QListWidget" name="list">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>271</width>
<height>120</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>120</height>
</size>
</property>
<property name="font">
<font>
<family>Arial</family>
</font>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="movement">
<enum>QListView::Free</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
</widget>
<widget class="QPushButton" name="button_remove">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>111</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
<widget class="QLabel" name="label_node">
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<width>131</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Node to add:</string>
</property>
</widget>
<widget class="QLineEdit" name="line_node">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>271</width>
<height>25</height>
</rect>
</property>
<property name="toolTip">
<string extracomment="Module name is required">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Name of scenegraph node to add to list of &amp;quot;interesting&amp;quot; nodes&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QPushButton" name="button_add">
<property name="geometry">
<rect>
<x>10</x>
<y>240</y>
<width>111</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Add New</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>markNodes</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>markNodes</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+34
View File
@@ -0,0 +1,34 @@
#include "meta.h"
#include "./ui_meta.h"
meta::meta(Meta& imported, QWidget *parent)
: QDialog(parent)
, ui(new Ui::meta)
, _imported(imported)
{
ui->setupUi(this);
ui->line_name->setText(QString(_imported.name.c_str()));
ui->line_version->setText(QString(_imported.version.c_str()));
ui->text_description->setText(QString(_imported.description.c_str()));
ui->line_author->setText(QString(_imported.author.c_str()));
ui->line_url->setText(QString(_imported.url.c_str()));
ui->line_license->setText(QString(_imported.license.c_str()));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(save()));
}
void meta::save() {
_imported.name = ui->line_name->text().toUtf8().constData();
_imported.version = ui->line_version->text().toUtf8().constData();
_imported.description = ui->text_description->toPlainText().toUtf8().constData();
_imported.author = ui->line_author->text().toUtf8().constData();
_imported.url = ui->line_url->text().toUtf8().constData();
_imported.license = ui->line_license->text().toUtf8().constData();
accept();
}
meta::~meta() {
delete ui;
}
+245
View File
@@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>meta</class>
<widget class="QDialog" name="meta">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>443</height>
</rect>
</property>
<property name="windowTitle">
<string>Meta</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>40</x>
<y>390</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label_name">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
<widget class="QLineEdit" name="line_name">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>331</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_version">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Version</string>
</property>
</widget>
<widget class="QLineEdit" name="line_version">
<property name="geometry">
<rect>
<x>20</x>
<y>90</y>
<width>331</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_description">
<property name="geometry">
<rect>
<x>20</x>
<y>120</y>
<width>91</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Description</string>
</property>
</widget>
<widget class="QTextEdit" name="text_description">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>331</width>
<height>75</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_author">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Author</string>
</property>
</widget>
<widget class="QLineEdit" name="line_author">
<property name="geometry">
<rect>
<x>20</x>
<y>240</y>
<width>331</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="line_url">
<property name="geometry">
<rect>
<x>20</x>
<y>290</y>
<width>331</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_url">
<property name="geometry">
<rect>
<x>20</x>
<y>270</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>URL</string>
</property>
</widget>
<widget class="QLineEdit" name="line_license">
<property name="geometry">
<rect>
<x>20</x>
<y>340</y>
<width>331</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="label_license">
<property name="geometry">
<rect>
<x>20</x>
<y>320</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>License</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>meta</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>meta</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>