Added message source and arm example
This commit is contained in:
1 parent
eaa115d115
commit
d2fc849cc2
38 files changed
+2261
-174
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "application.h"
|
||||
#include "error_dialog.h"
|
||||
#include "warning_dialog.h"
|
||||
#include "message_source.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
@@ -140,11 +141,11 @@ namespace display {
|
||||
auto *radioLayout = new QHBoxLayout(group);
|
||||
group->setLayout(radioLayout);
|
||||
|
||||
auto isTrue = new QRadioButton("da", group);
|
||||
auto isTrue = new QRadioButton(QMESSAGE("msg_boolean_true"), group);
|
||||
connect(isTrue, &QRadioButton::clicked, [this]() {
|
||||
this->value = domain::Value::fromBool(true);
|
||||
});
|
||||
auto isFalse = new QRadioButton("ne", group);
|
||||
auto isFalse = new QRadioButton(QMESSAGE("msg_boolean_false"), group);
|
||||
connect(isFalse, &QRadioButton::clicked, [this]() {
|
||||
this->value = domain::Value::fromBool(false);
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace display {
|
||||
|
||||
ErrorDialog::ErrorDialog(std::vector<domain::ValidationError> errors)
|
||||
: GenericDialog("Greške", "") {
|
||||
: GenericDialog("msg_dialog_error_title", std::nullopt, "msg_dialog_error_close") {
|
||||
|
||||
auto contentLayout = new QVBoxLayout();
|
||||
content->setLayout(contentLayout);
|
||||
@@ -17,7 +17,7 @@ namespace display {
|
||||
}
|
||||
|
||||
ErrorDialog::ErrorDialog(std::ostringstream& errorStream)
|
||||
: GenericDialog("Greške", "") {
|
||||
: GenericDialog("msg_dialog_error_title", std::nullopt, "msg_dialog_error_close") {
|
||||
|
||||
auto contentLayout = new QVBoxLayout();
|
||||
content->setLayout(contentLayout);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include <QVBoxLayout>
|
||||
#include "generic_dialog.h"
|
||||
|
||||
display::GenericDialog::GenericDialog(std::string title, std::string action) {
|
||||
#include "message_source.h"
|
||||
|
||||
display::GenericDialog::GenericDialog(std::string title, std::optional<std::string> action, std::string cancel) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(QString::fromStdString(title));
|
||||
setWindowTitle(QMESSAGE(title));
|
||||
|
||||
setLayout(new QVBoxLayout());
|
||||
content = new QWidget(this);
|
||||
@@ -14,12 +16,16 @@ display::GenericDialog::GenericDialog(std::string title, std::string action) {
|
||||
layout()->addWidget(actionWidget);
|
||||
|
||||
// if action isn't defined only close button is offered
|
||||
if(!action.empty()) {
|
||||
okButton = new QPushButton(QString::fromStdString(action), this);
|
||||
connect(okButton, &QPushButton::clicked, this, [this](){if(this->onUpdate()) this->accept();});
|
||||
if(action.has_value()) {
|
||||
okButton = new QPushButton(QMESSAGE(*action), this);
|
||||
connect(okButton, &QPushButton::clicked, this, [this](){
|
||||
if(this->onUpdate()) {
|
||||
this->accept();
|
||||
}
|
||||
});
|
||||
actionBar->addWidget(okButton);
|
||||
}
|
||||
cancelButton = new QPushButton("Odustani", this);
|
||||
cancelButton = new QPushButton(QMESSAGE(cancel), this);
|
||||
connect(cancelButton, &QPushButton::clicked, [this]() { reject(); });
|
||||
actionBar->addWidget(cancelButton);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace display {
|
||||
|
||||
class GenericDialog: public QDialog {
|
||||
public:
|
||||
|
||||
GenericDialog(std::string title, std::string action = "Ažuriraj");
|
||||
explicit GenericDialog(std::string title,
|
||||
std::optional<std::string> action = "msg_dialog_actions_update",
|
||||
std::string cancel = "msg_dialog_actions_cancel");
|
||||
|
||||
protected:
|
||||
void setOkButtonDisabled(bool disabled);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include "memory_dialog.h"
|
||||
#include "message_source.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
@@ -35,7 +36,7 @@ namespace display {
|
||||
for (const auto& entry: memoryInstances) {
|
||||
combo->addItem(QString::fromStdString(entry));
|
||||
}
|
||||
combo->addItem("null");
|
||||
combo->addItem(QMESSAGE("msg_dialog_memory_default"));
|
||||
|
||||
connect(combo, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
if(index == memoryInstances.size()) {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include <set>
|
||||
#include "name_dialog.h"
|
||||
#include "message_source.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
NameDialog::NameDialog(std::string currentName, std::set<std::string> &names)
|
||||
: GenericDialog("Izmjeni ime", "Izmjeni"), currentName(currentName), usedNames(names) {
|
||||
: GenericDialog("msg_dialog_name_update"), currentName(currentName), usedNames(names) {
|
||||
|
||||
usedNames.erase(currentName);
|
||||
|
||||
auto *contentLayout = new QVBoxLayout();
|
||||
contentLayout->addWidget(new QLabel("Izmjeni ime", this));
|
||||
contentLayout->addWidget(new QLabel(QMESSAGE("msg_dialog_name_update"), this));
|
||||
|
||||
edit = new QLineEdit(this);
|
||||
edit->insert(currentName.c_str());
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include "success_dialog.h"
|
||||
#include "message_source.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
SuccessDialog::SuccessDialog(std::string message, std::string action) {
|
||||
SuccessDialog::SuccessDialog(std::string message) {
|
||||
setLayout(new QVBoxLayout());
|
||||
setWindowTitle(QMESSAGE("msg_dialog_success_title"));
|
||||
layout()->addWidget(new QLabel(QString::fromStdString(message)));
|
||||
|
||||
auto button = new QPushButton(QString::fromStdString(action));
|
||||
auto button = new QPushButton(QMESSAGE("msg_dialog_actions_ok"));
|
||||
connect(button, &QPushButton::clicked, [this]() {accept();});
|
||||
layout()->addWidget(button);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace display {
|
||||
|
||||
class SuccessDialog: public QDialog {
|
||||
public:
|
||||
explicit SuccessDialog(std::string message, std::string action = "Ok");
|
||||
explicit SuccessDialog(std::string message);
|
||||
};
|
||||
|
||||
} // display
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace display {
|
||||
|
||||
WarningDialog::WarningDialog(domain::ValidationError error)
|
||||
: GenericDialog("Upozorenje", "U redu") {
|
||||
: GenericDialog("msg_dialog_warning_title", "msg_dialog_actions_ok") {
|
||||
|
||||
auto contentLayout = new QVBoxLayout();
|
||||
content->setLayout(contentLayout);
|
||||
|
||||
Reference in new issue
Block a user