Updated translations + bugfixes
This commit is contained in:
1 parent
1759adf25a
commit
f66fc1db26
20 files changed
+157
-158
No files matched your search
@@ -59,14 +59,16 @@ namespace display {
|
||||
|
||||
}
|
||||
|
||||
AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute) {
|
||||
AttributeDialog::AttributeDialog(domain::InstanceAttribute *attribute, bool updating) {
|
||||
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
attributeValue = attribute;
|
||||
|
||||
this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName()));
|
||||
auto actionType = updating ? "Izmjeni " : "Postavi ";
|
||||
|
||||
this->setWindowTitle(QString::fromStdString(actionType + attribute->attribute.getName()));
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
this->setLayout(layout);
|
||||
@@ -120,11 +122,11 @@ namespace display {
|
||||
auto *radioLayout = new QHBoxLayout(group);
|
||||
group->setLayout(radioLayout);
|
||||
|
||||
auto isTrue = new QRadioButton("true", group);
|
||||
auto isTrue = new QRadioButton("da", group);
|
||||
connect(isTrue, &QRadioButton::clicked, [this]() {
|
||||
this->value = domain::Value::fromBool(true);
|
||||
});
|
||||
auto isFalse = new QRadioButton("false", group);
|
||||
auto isFalse = new QRadioButton("ne", group);
|
||||
connect(isFalse, &QRadioButton::clicked, [this]() {
|
||||
this->value = domain::Value::fromBool(false);
|
||||
});
|
||||
@@ -140,7 +142,7 @@ namespace display {
|
||||
layout->addWidget(group);
|
||||
}
|
||||
|
||||
auto button = new QPushButton("Ažuriraj");
|
||||
auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
connect(button, &QPushButton::clicked, this, &AttributeDialog::onUpdate);
|
||||
|
||||
layout->addWidget(button);
|
||||
@@ -170,14 +172,16 @@ namespace display {
|
||||
}
|
||||
|
||||
MemoryDialog::MemoryDialog(domain::InstanceAttribute *attribute,
|
||||
std::vector<std::shared_ptr<domain::ComponentInstance>> instances) {
|
||||
std::vector<std::shared_ptr<domain::ComponentInstance>> instances, bool updating) {
|
||||
memoryInstances = std::vector<std::string>();
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
attributeValue = attribute;
|
||||
|
||||
this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName()));
|
||||
auto actionType = updating ? "Izmjeni memoriju" : "Postavi memoriju";
|
||||
|
||||
this->setWindowTitle(QString::fromStdString(actionType));
|
||||
|
||||
for (auto &instance: instances) {
|
||||
if (instance->component.getType() == domain::Component::MEMORY) {
|
||||
@@ -212,7 +216,7 @@ namespace display {
|
||||
}
|
||||
}
|
||||
|
||||
auto button = new QPushButton("Ažuriraj");
|
||||
auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
connect(button, &QPushButton::clicked, this, &MemoryDialog::onUpdate);
|
||||
|
||||
layout->addWidget(button);
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace display {
|
||||
domain::InstanceAttribute *attributeValue;
|
||||
|
||||
public:
|
||||
AttributeDialog(domain::InstanceAttribute *attribute);
|
||||
AttributeDialog(domain::InstanceAttribute *attribute, bool updating = true);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace display {
|
||||
|
||||
public:
|
||||
MemoryDialog(domain::InstanceAttribute *attribute,
|
||||
std::vector<std::shared_ptr<domain::ComponentInstance>> instances);
|
||||
std::vector<std::shared_ptr<domain::ComponentInstance>> instances, bool updating = true);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -7,11 +7,15 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QLine>
|
||||
#include <QPen>
|
||||
#include <QGraphicsSceneContextMenuEvent>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace display {
|
||||
|
||||
QPen connectionPen(QColor::fromRgb(150, 150, 250));
|
||||
|
||||
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
menu.addAction("Izmjeni ime", [this]() {
|
||||
@@ -32,18 +36,20 @@ namespace display {
|
||||
auto *attr = &this->instance->attributes[i];
|
||||
bool enabled = attr->attribute.getPopup().has_value();
|
||||
|
||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
||||
[attr]() {
|
||||
if (attr->value.getType() == domain::Value::MEMORY_REFERENCE) {
|
||||
auto dialog = new MemoryDialog(attr,
|
||||
Application::instance()->getSchema()->componentInstances);
|
||||
dialog->exec();
|
||||
} else {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
}
|
||||
});
|
||||
action->setEnabled(enabled);
|
||||
if(attr->value.getType() == domain::Value::MEMORY_REFERENCE) {
|
||||
menu.addAction("Izmjeni memoriju", [attr]() {
|
||||
auto dialog = new MemoryDialog(attr,
|
||||
Application::instance()->getSchema()->componentInstances);
|
||||
dialog->exec();
|
||||
});
|
||||
} else {
|
||||
auto action = menu.addAction(QString::fromStdString("Izmjeni '" + attr->name + "'"),
|
||||
[attr]() {
|
||||
auto dialog = new AttributeDialog(attr);
|
||||
dialog->exec();
|
||||
});
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
menu.addSeparator();
|
||||
menu.addAction(QString::fromStdString("Ukloni " + this->instance->name), [this]() {
|
||||
@@ -62,7 +68,7 @@ namespace display {
|
||||
|
||||
void Pin::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||
QMenu menu;
|
||||
menu.addAction("Connect pin", [&]() {});
|
||||
menu.addAction("Poveži pin", [&]() {});
|
||||
menu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
@@ -75,6 +81,8 @@ namespace display {
|
||||
QPointF(pin.getDisplayPin().getConnectionX(),
|
||||
pin.getDisplayPin().getConnectionY());
|
||||
view->context.line = new QGraphicsLineItem(QLineF(view->context.startingPoint, event->scenePos()));
|
||||
view->context.line->setPen(QPen(QColor::fromRgb(100, 100, 250), 1, Qt::PenStyle::DashLine));
|
||||
view->context.line->setZValue(1000);
|
||||
this->scene()->addItem(view->context.line);
|
||||
|
||||
view->showConnectable(this);
|
||||
@@ -225,9 +233,8 @@ namespace display {
|
||||
BusConnection::BusConnection(domain::BusConnectionInstance *connection, ComponentGroup *component, BusGroup *bus): connection(
|
||||
connection), component(component), bus(bus) {
|
||||
updateConnection();
|
||||
|
||||
setCursor(Qt::CrossCursor);
|
||||
|
||||
setPen(connectionPen);
|
||||
setZValue(-1);
|
||||
setHandlesChildEvents(false);
|
||||
}
|
||||
|
||||
@@ -280,7 +287,8 @@ namespace display {
|
||||
DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first,
|
||||
ComponentGroup *second): connection(connection), first(first), second(second) {
|
||||
updateConnection();
|
||||
setCursor(Qt::CrossCursor);
|
||||
setPen(connectionPen);
|
||||
setZValue(-1);
|
||||
setHandlesChildEvents(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace display {
|
||||
componentList = new LibraryList(this);
|
||||
busList = new LibraryList(this);
|
||||
|
||||
layout->setMargin(4);
|
||||
layout->addWidget(new QLabel("Components:"));
|
||||
layout->setContentsMargins(4, 4, 4, 4);
|
||||
layout->addWidget(new QLabel("Komponente:"));
|
||||
layout->addWidget(componentList, 1);
|
||||
layout->addSpacing(8);
|
||||
layout->addWidget(new QLabel("Buses:"));
|
||||
layout->addWidget(new QLabel("Sabirnice:"));
|
||||
layout->addWidget(busList, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ namespace display {
|
||||
: QListWidgetItem(parent), mimeType(mimeType), value(value) {
|
||||
setText(QString::fromStdString(title));
|
||||
}
|
||||
} // display
|
||||
} // display
|
||||
@@ -11,8 +11,6 @@
|
||||
namespace display {
|
||||
|
||||
Schema::Schema() {
|
||||
this->selectedBrush.setColor(QColor::fromRgb(20, 20, 125));
|
||||
this->selectedPen.setColor(QColor::fromRgb(20, 20, 125));
|
||||
schema = nullptr;
|
||||
library = std::nullopt;
|
||||
this->setScene(&scene);
|
||||
@@ -27,7 +25,9 @@ namespace display {
|
||||
components.clear();
|
||||
buses.clear();
|
||||
scene.clear();
|
||||
pins.clear();
|
||||
busConnections.clear();
|
||||
directConnections.clear();
|
||||
|
||||
if (schema != nullptr) {
|
||||
for (auto &instance: schema->componentInstances) {
|
||||
@@ -150,6 +150,7 @@ namespace display {
|
||||
if (con.has_value()) {
|
||||
auto attributes = populateAttributes(con->getAttributes());
|
||||
if(attributes.size() != con->getAttributes().size()) {
|
||||
clearSelectable();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -190,6 +191,7 @@ namespace display {
|
||||
attributes = populateAttributes(con->getAttributes());
|
||||
}
|
||||
if(attributes.size() != con->getAttributes().size()) {
|
||||
clearSelectable();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,14 +213,7 @@ namespace display {
|
||||
}
|
||||
}
|
||||
|
||||
updateConnections();
|
||||
|
||||
|
||||
for (auto &item: this->context.selectable) {
|
||||
this->scene.removeItem(item);
|
||||
delete item;
|
||||
}
|
||||
this->context.selectable.clear();
|
||||
clearSelectable();
|
||||
}
|
||||
|
||||
void Schema::showConnectable(Pin *domainPin) {
|
||||
@@ -236,7 +231,7 @@ namespace display {
|
||||
continue;
|
||||
}
|
||||
auto rect = new QGraphicsRectItem(group->boundingRect());
|
||||
rect->setPen(selectedPen);
|
||||
rect->setBrush(selectedBrush);
|
||||
rect->setPos(group->scenePos());
|
||||
|
||||
auto _rect = rect->rect();
|
||||
@@ -255,6 +250,7 @@ namespace display {
|
||||
auto pinInstance = domain::ConnectionComponent{connection.componentInstance.value()->name, connection.pin.value().getName()};
|
||||
auto &instance = pins[pinInstance];
|
||||
auto rect = new QGraphicsRectItem(instance->boundingRect());
|
||||
rect->setBrush(selectedBrush);
|
||||
rect->setPen(selectedPen);
|
||||
rect->setPos(instance->scenePos());
|
||||
|
||||
@@ -276,13 +272,13 @@ namespace display {
|
||||
domain::InstanceAttribute attribute(attr.getName(), attr.getDefault(), attr);
|
||||
if(attr.getPopup().has_value() && attr.getPopup()->getType() == domain::Popup::AUTOMATIC) {
|
||||
if(attr.getDefault().isType(domain::Value::MEMORY_REFERENCE)) {
|
||||
auto dialog = new MemoryDialog(&attribute, schema->componentInstances);
|
||||
auto dialog = new MemoryDialog(&attribute, schema->componentInstances, false);
|
||||
if(dialog->exec() == QDialog::Rejected) {
|
||||
// if any dialog isn't set, whole creation is rejected
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
auto dialog = new AttributeDialog(&attribute);
|
||||
auto dialog = new AttributeDialog(&attribute, false);
|
||||
if(dialog->exec() == QDialog::Rejected) {
|
||||
// if any dialog isn't set, whole creation is rejected
|
||||
return {};
|
||||
@@ -301,7 +297,7 @@ namespace display {
|
||||
instanceAttributes.emplace_back(attr.getName(), attr.getDefault(), attr);
|
||||
}
|
||||
|
||||
auto dialog = new display::SingleAutomaticDialog(instanceAttributes);
|
||||
auto dialog = new display::SingleAutomaticDialog(instanceAttributes, false);
|
||||
if(dialog->exec() == QDialog::Rejected) {
|
||||
// if dialog is rejected, whole creation is rejected
|
||||
return {};
|
||||
@@ -311,4 +307,14 @@ namespace display {
|
||||
|
||||
}
|
||||
|
||||
void Schema::clearSelectable() {
|
||||
updateConnections();
|
||||
|
||||
for (auto &item: this->context.selectable) {
|
||||
this->scene.removeItem(item);
|
||||
delete item;
|
||||
}
|
||||
this->context.selectable.clear();
|
||||
}
|
||||
|
||||
} // namespace display
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QWidget>
|
||||
#include <QColor>
|
||||
#include <QGraphicsLineItem>
|
||||
|
||||
#include <comdel/domain/schema.h>
|
||||
@@ -19,8 +20,9 @@ namespace display {
|
||||
|
||||
public:
|
||||
|
||||
QBrush selectedBrush;
|
||||
QPen selectedPen;
|
||||
QBrush selectedBrush = QBrush(QColor::fromRgb(50, 50, 150, 100), Qt::BrushStyle::SolidPattern);
|
||||
QPen selectedPen = QPen(QColor::fromRgb(50, 50, 150), 1, Qt::PenStyle::SolidLine);
|
||||
QPen activeLinePen = QPen(QColor::fromRgb(250, 100, 100));
|
||||
|
||||
enum State {
|
||||
DEFAULT,
|
||||
@@ -68,15 +70,11 @@ namespace display {
|
||||
domain::Schema *schema{};
|
||||
std::optional<domain::Library> library;
|
||||
|
||||
std::vector<domain::BusInstance *>
|
||||
getAvailableConnectionBusses(domain::ComponentInstance *instance, domain::Pin &pin);
|
||||
|
||||
std::vector<domain::ConnectionComponent>
|
||||
getAvailableConnectionPins(domain::ComponentInstance *instance, domain::Pin &pin);
|
||||
|
||||
std::vector<domain::InstanceAttribute> populateAttributes(std::vector<domain::Attribute>& attributes);
|
||||
|
||||
std::vector<domain::InstanceAttribute> populateSingleAutomaticConnection(domain::Connection connection);
|
||||
|
||||
void clearSelectable();
|
||||
};
|
||||
|
||||
} // namespace display
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <QPushButton>
|
||||
|
||||
namespace display {
|
||||
SingleAutomaticDialog::SingleAutomaticDialog(std::vector<domain::InstanceAttribute> &values): attributes(values) {
|
||||
SingleAutomaticDialog::SingleAutomaticDialog(std::vector<domain::InstanceAttribute> &values, bool updating): attributes(values) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(QString::fromStdString("Postavi poveznicu"));
|
||||
setWindowTitle(QString::fromStdString(updating ? "Ažuriraj poveznicu" : "Postavi poveznicu"));
|
||||
|
||||
firstValue = values[0].value;
|
||||
secondValue = values[1].value;
|
||||
@@ -29,7 +29,7 @@ namespace display {
|
||||
setupValues(firstLayout, values[0], &SingleAutomaticDialog::onFirstEnumerationChanged);
|
||||
setupValues(secondLayout, values[1], &SingleAutomaticDialog::onSecondEnumerationChanged);
|
||||
|
||||
auto button = new QPushButton("Ažuriraj");
|
||||
auto button = new QPushButton(updating ? "Ažuriraj" : "Postavi");
|
||||
connect(button, &QPushButton::clicked, this, &SingleAutomaticDialog::onUpdate);
|
||||
parentLayout->addWidget(button);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace display {
|
||||
std::vector<domain::InstanceAttribute> &attributes;
|
||||
|
||||
public:
|
||||
explicit SingleAutomaticDialog(std::vector<domain::InstanceAttribute>& values);
|
||||
explicit SingleAutomaticDialog(std::vector<domain::InstanceAttribute>& values, bool updating = true);
|
||||
|
||||
void setupValues(QVBoxLayout *layout, domain::InstanceAttribute &attribute, void (display::SingleAutomaticDialog::* handler)(int));
|
||||
|
||||
|
||||
Reference in new issue
Block a user