diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-11 20:34:40 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-11 21:30:22 +0200 |
commit | 8c9ce776ec7d9061304cc462a2de4b76d12fa7ad (patch) | |
tree | 6589db8ba19c7310096efd388bfc39317760abe7 /gui | |
parent | f1cf449c099f30482f05d9a7c6209321050159d5 (diff) | |
download | nextpnr-8c9ce776ec7d9061304cc462a2de4b76d12fa7ad.tar.gz nextpnr-8c9ce776ec7d9061304cc462a2de4b76d12fa7ad.tar.bz2 nextpnr-8c9ce776ec7d9061304cc462a2de4b76d12fa7ad.zip |
Added property editor for example
Diffstat (limited to 'gui')
-rw-r--r-- | gui/gui.cmake | 9 | ||||
-rw-r--r-- | gui/mainwindow.cc | 136 | ||||
-rw-r--r-- | gui/mainwindow.ui | 7 |
3 files changed, 144 insertions, 8 deletions
diff --git a/gui/gui.cmake b/gui/gui.cmake index 95a4a397..23f955f9 100644 --- a/gui/gui.cmake +++ b/gui/gui.cmake @@ -22,7 +22,7 @@ qt5_wrap_ui_custom(GENERATED_UI_HEADERS ${UI_SOURCES}) qt5_add_resources_custom(GUI_RESOURCE_FILES gui/nextpnr.qrc) set(GUI_SOURCE_FILES gui/mainwindow.cc gui/fpgaviewwidget.cc gui/emb.cc ${GENERATED_MOC_FILES} ${GENERATED_UI_HEADERS} ${GUI_RESOURCE_FILES}) -set(GUI_LIBRARY_FILES Qt5::Widgets Qt5::OpenGL ${OPENGL_LIBRARIES}) +set(GUI_LIBRARY_FILES Qt5::Widgets Qt5::OpenGL ${OPENGL_LIBRARIES} QtPropertyBrowser) add_library(QtPropertyBrowser STATIC "") @@ -33,6 +33,7 @@ qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qtpropertymanager.h ${CMAKE_CURR qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qtbuttonpropertybrowser.h ${CMAKE_CURRENT_BINARY_DIR}/generated/moc_qtbuttonpropertybrowser.hpp) qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qteditorfactory.h ${CMAKE_CURRENT_BINARY_DIR}/generated/moc_qteditorfactory.hpp) qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.h ${CMAKE_CURRENT_BINARY_DIR}/generated/moc_qttreepropertybrowser.hpp) +qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qtpropertybrowserutils_p.h ${CMAKE_CURRENT_BINARY_DIR}/generated/moc_qtpropertybrowserutils_p.cpp) qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qtpropertymanager.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated/qtpropertymanager.moc) qt5_generate_moc(3rdparty/QtPropertyBrowser/src/qttreepropertybrowser.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated/qttreepropertybrowser.moc) @@ -49,10 +50,12 @@ set(QTPB_GENERATED_MOC_FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/qtpropertymanager.moc ${CMAKE_CURRENT_BINARY_DIR}/generated/qttreepropertybrowser.moc ${CMAKE_CURRENT_BINARY_DIR}/generated/qteditorfactory.moc + ${CMAKE_CURRENT_BINARY_DIR}/generated/moc_qtpropertybrowserutils_p.cpp ) +qt5_add_resources_custom(QTPB_RESOURCE_FILES 3rdparty/QtPropertyBrowser/src/qtpropertybrowser.qrc) aux_source_directory(3rdparty/QtPropertyBrowser/src/ QTPROPBROWSER_SRC_ALL) -target_sources(QtPropertyBrowser PRIVATE ${QTPROPBROWSER_SRC_ALL} ${QTPB_GENERATED_MOC_FILES} ) +target_sources(QtPropertyBrowser PRIVATE ${QTPROPBROWSER_SRC_ALL} ${QTPB_GENERATED_MOC_FILES} ${QTPB_RESOURCE_FILES}) target_include_directories(QtPropertyBrowser PRIVATE 3rdparty/QtPropertyBrowser/src generated) -target_link_libraries(QtPropertyBrowser PRIVATE Qt5::Widgets) +target_link_libraries(QtPropertyBrowser PRIVATE Qt5::Core Qt5::Widgets) diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index 52174139..b24fb58b 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -5,6 +5,12 @@ #include "emb.h" #include "pybindings.h" #include "ui_mainwindow.h" +#include "qtpropertymanager.h" +#include "qtvariantproperty.h" +#include "qttreepropertybrowser.h" + +#include <QDate> +#include <QLocale> MainWindow::MainWindow(Design *_design, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), design(_design) @@ -20,9 +26,137 @@ MainWindow::MainWindow(Design *_design, QWidget *parent) emb::set_stdout(write); std::string title = "nextpnr-ice40 - " + design->chip.getChipName(); setWindowTitle(title.c_str()); + QtVariantPropertyManager *variantManager = new QtVariantPropertyManager(); + + int i = 0; + QtProperty *topItem = variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), + QString::number(i++) + QLatin1String(" Group Property")); + + QtVariantProperty *item = variantManager->addProperty(QVariant::Bool, QString::number(i++) + QLatin1String(" Bool Property")); + item->setValue(true); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Int, QString::number(i++) + QLatin1String(" Int Property")); + item->setValue(20); + item->setAttribute(QLatin1String("minimum"), 0); + item->setAttribute(QLatin1String("maximum"), 100); + item->setAttribute(QLatin1String("singleStep"), 10); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Double, QString::number(i++) + QLatin1String(" Double Property")); + item->setValue(1.2345); + item->setAttribute(QLatin1String("singleStep"), 0.1); + item->setAttribute(QLatin1String("decimals"), 3); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::String, QString::number(i++) + QLatin1String(" String Property")); + item->setValue("Value"); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Date, QString::number(i++) + QLatin1String(" Date Property")); + item->setValue(QDate::currentDate().addDays(2)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Time, QString::number(i++) + QLatin1String(" Time Property")); + item->setValue(QTime::currentTime()); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::DateTime, QString::number(i++) + QLatin1String(" DateTime Property")); + item->setValue(QDateTime::currentDateTime()); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::KeySequence, QString::number(i++) + QLatin1String(" KeySequence Property")); + item->setValue(QKeySequence(Qt::ControlModifier | Qt::Key_Q)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Char, QString::number(i++) + QLatin1String(" Char Property")); + item->setValue(QChar(386)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Locale, QString::number(i++) + QLatin1String(" Locale Property")); + item->setValue(QLocale(QLocale::Polish, QLocale::Poland)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Point, QString::number(i++) + QLatin1String(" Point Property")); + item->setValue(QPoint(10, 10)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::PointF, QString::number(i++) + QLatin1String(" PointF Property")); + item->setValue(QPointF(1.2345, -1.23451)); + item->setAttribute(QLatin1String("decimals"), 3); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Size, QString::number(i++) + QLatin1String(" Size Property")); + item->setValue(QSize(20, 20)); + item->setAttribute(QLatin1String("minimum"), QSize(10, 10)); + item->setAttribute(QLatin1String("maximum"), QSize(30, 30)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::SizeF, QString::number(i++) + QLatin1String(" SizeF Property")); + item->setValue(QSizeF(1.2345, 1.2345)); + item->setAttribute(QLatin1String("decimals"), 3); + item->setAttribute(QLatin1String("minimum"), QSizeF(0.12, 0.34)); + item->setAttribute(QLatin1String("maximum"), QSizeF(20.56, 20.78)); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Rect, QString::number(i++) + QLatin1String(" Rect Property")); + item->setValue(QRect(10, 10, 20, 20)); + topItem->addSubProperty(item); + item->setAttribute(QLatin1String("constraint"), QRect(0, 0, 50, 50)); + + item = variantManager->addProperty(QVariant::RectF, QString::number(i++) + QLatin1String(" RectF Property")); + item->setValue(QRectF(1.2345, 1.2345, 1.2345, 1.2345)); + topItem->addSubProperty(item); + item->setAttribute(QLatin1String("constraint"), QRectF(0, 0, 50, 50)); + item->setAttribute(QLatin1String("decimals"), 3); + + item = variantManager->addProperty(QtVariantPropertyManager::enumTypeId(), + QString::number(i++) + QLatin1String(" Enum Property")); + QStringList enumNames; + enumNames << "Enum0" << "Enum1" << "Enum2"; + item->setAttribute(QLatin1String("enumNames"), enumNames); + item->setValue(1); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QtVariantPropertyManager::flagTypeId(), + QString::number(i++) + QLatin1String(" Flag Property")); + QStringList flagNames; + flagNames << "Flag0" << "Flag1" << "Flag2"; + item->setAttribute(QLatin1String("flagNames"), flagNames); + item->setValue(5); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::SizePolicy, QString::number(i++) + QLatin1String(" SizePolicy Property")); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Font, QString::number(i++) + QLatin1String(" Font Property")); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Cursor, QString::number(i++) + QLatin1String(" Cursor Property")); + topItem->addSubProperty(item); + + item = variantManager->addProperty(QVariant::Color, QString::number(i++) + QLatin1String(" Color Property")); + topItem->addSubProperty(item); + + QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(); + + QtTreePropertyBrowser *variantEditor = new QtTreePropertyBrowser(); + variantEditor->setFactoryForManager(variantManager, variantFactory); + variantEditor->addProperty(topItem); + variantEditor->setPropertiesWithoutValueMarked(true); + variantEditor->setRootIsDecorated(false); + variantEditor->show(); + ui->splitter_2->addWidget(variantEditor); } -MainWindow::~MainWindow() { delete ui; } +MainWindow::~MainWindow() +{ + + //delete variantManager; + //delete variantFactory; + //delete variantEditor; +delete ui; +} void handle_system_exit() { exit(-1); } diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 4e236f3c..3fe0f400 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -63,22 +63,21 @@ <widget class="QSplitter" name="splitter_2"> <property name="orientation"> <enum>Qt::Vertical</enum> - </property> + </property> <widget class="QTreeView" name="treeView"> <property name="minimumSize"> <size> - <width>200</width> + <width>300</width> <height>0</height> </size> </property> <property name="maximumSize"> <size> - <width>200</width> + <width>300</width> <height>16777215</height> </size> </property> </widget> - <widget class="QTableView" name="tableView"/> </widget> </widget> </item> |