diff --git a/guidededitor.cpp b/guidededitor.cpp new file mode 100644 index 0000000..472ac56 --- /dev/null +++ b/guidededitor.cpp @@ -0,0 +1,31 @@ +#include "guidededitor.h" + +GuidedEditor::GuidedEditor(QWidget *parent) : QWidget(parent) +{ + editorLayout = new FlowLayout(this); + this->setLayout(editorLayout); + //tests + this->editorLayout->addWidget(new EditorElement(this)); + this->editorLayout->addWidget(new EditorElement(this)); + QString style = QString( + "QWidget {" + "border-radius: 5px;" + "background: white }" + "QLabel {border: 2px dashed black; background: gray; " + "border-radius: 5px;}" + "QLineEdit {border: 2px dashed black;background: dark-gray;" + "border-radius: 5px;}" + ); + this->setStyleSheet(style); + +} + +void GuidedEditor::addElement() { + this->editorLayout->addWidget(new EditorElement(this)); +} + +GuidedEditor::~GuidedEditor() +{ + +} + diff --git a/guidededitor.h b/guidededitor.h new file mode 100644 index 0000000..72d088e --- /dev/null +++ b/guidededitor.h @@ -0,0 +1,26 @@ +#ifndef GUIDEDEDITOR_H +#define GUIDEDEDITOR_H + +#include +#include "flowlayout.h" +#include "guidededitorelement.h" + +class GuidedEditor : public QWidget +{ + Q_OBJECT +public: + explicit GuidedEditor(QWidget *parent = 0); + ~GuidedEditor(); + +signals: + +public slots: + void addElement(); + +private: + FlowLayout* editorLayout; + QList* list; + +}; + +#endif // GUIDEDEDITOR_H diff --git a/editorelement.cpp b/guidededitorelement.cpp similarity index 94% rename from editorelement.cpp rename to guidededitorelement.cpp index 6824985..ae72f32 100644 --- a/editorelement.cpp +++ b/guidededitorelement.cpp @@ -1,4 +1,4 @@ -#include "editorelement.h" +#include "guidededitorelement.h" #include EditorElement::EditorElement(QWidget *parent) : QWidget(parent) diff --git a/editorelement.h b/guidededitorelement.h similarity index 100% rename from editorelement.h rename to guidededitorelement.h diff --git a/mainwindow.cpp b/mainwindow.cpp index 679efc0..50a056e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,27 +1,22 @@ #include "mainwindow.h" -#include "../QtGuidedEditor/qgewidget.h" -#include "flowlayout.h" +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - list = new QList(); - editor = new QWidget(this); - centralLayout = new FlowLayout(editor); - editor->setLayout(centralLayout); - centralLayout->addWidget(new EditorElement(this)); - centralLayout->addWidget(new EditorElement(this)); + editor = new GuidedEditor(this); this->setCentralWidget(editor); - QString style = QString( - "QWidget {" - "border-radius: 5px;" - "background: white }" - "QLabel {border: 2px dashed black; background: gray; " - "border-radius: 5px;}" - "QLineEdit {border: 2px dashed black;background: dark-gray;" - "border-radius: 5px;}" - ); - editor->setStyleSheet(style); + dockWidget = new QDockWidget(this); + this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); + + // dockwidget + QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget); + dockWidget->setLayout(dockLayout); + QPushButton* button = new QPushButton(dockWidget); + button->setText("add"); + dockLayout->addWidget(button); + this->connect(button, &QPushButton::pressed,editor, &GuidedEditor::addElement); + } diff --git a/mainwindow.h b/mainwindow.h index 11ed6cc..774d41d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,17 +3,17 @@ #include #include -#include "editorelement.h" #include "flowlayout.h" +#include "guidededitor.h" +#include +#include class MainWindow : public QMainWindow { Q_OBJECT private: - FlowLayout* centralLayout; - QWidget* editor; - QList* list; - + GuidedEditor* editor; + QDockWidget* dockWidget; public: MainWindow(QWidget *parent = 0); diff --git a/networkpacketcomposer.pro b/networkpacketcomposer.pro index bb118d2..396b071 100644 --- a/networkpacketcomposer.pro +++ b/networkpacketcomposer.pro @@ -14,12 +14,14 @@ TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ - editorelement.cpp \ - flowlayout.cpp + flowlayout.cpp \ + guidededitorelement.cpp \ + guidededitor.cpp HEADERS += mainwindow.h \ - editorelement.h \ - flowlayout.h + flowlayout.h \ + guidededitorelement.h \ + guidededitor.h INCLUDEPATH += $$PWD/../QtGuidedEditor DEPENDPATH += $$PWD/../QtGuidedEditor