Permalink
Browse files

BLARGH technic things, rebased. FML.

  • Loading branch information...
peterix committed Oct 1, 2015
1 parent 2973b11 commit 608e10820578697ffb7e30bdc83843b427baf3d3
Showing with 2,727 additions and 0 deletions.
  1. +56 −0 application/dialogs/QMLDialog.cpp
  2. +26 −0 application/dialogs/QMLDialog.h
  3. +61 −0 application/dialogs/TechnicDialog.cpp
  4. +21 −0 application/dialogs/TechnicDialog.h
  5. +100 −0 application/resources/multimc/scalable/technic.svg
  6. +48 −0 application/resources/qml/ScrollBar.qml
  7. +11 −0 application/resources/qml/qml.qrc
  8. +101 −0 application/resources/qml/technic/close.svg
  9. BIN application/resources/qml/technic/default_background.jpg
  10. BIN application/resources/qml/technic/default_logo.png
  11. +88 −0 application/resources/qml/technic/install.svg
  12. +367 −0 application/resources/qml/technic/technic.qml
  13. +80 −0 application/technic/ImageProvider.cpp
  14. +16 −0 application/technic/ImageProvider.h
  15. +38 −0 logic/technic/LegacyPackInfo.h
  16. +293 −0 logic/technic/PackModel.cpp
  17. +101 −0 logic/technic/PackModel.h
  18. +57 −0 logic/technic/SolderInstance.cpp
  19. +22 −0 logic/technic/SolderInstance.h
  20. +193 −0 logic/technic/SolderProfileStrategy.cpp
  21. +20 −0 logic/technic/SolderProfileStrategy.h
  22. +147 −0 logic/technic/SolderUpdate.cpp
  23. +38 −0 logic/technic/SolderUpdate.h
  24. +95 −0 logic/technic/SolderVersion.cpp
  25. +33 −0 logic/technic/SolderVersion.h
  26. +100 −0 resources/multimc/scalable/technic.svg
  27. +48 −0 resources/qml/ScrollBar.qml
  28. +11 −0 resources/qml/qml.qrc
  29. +101 −0 resources/qml/technic/close.svg
  30. BIN resources/qml/technic/default_background.jpg
  31. BIN resources/qml/technic/default_logo.png
  32. +88 −0 resources/qml/technic/install.svg
  33. +367 −0 resources/qml/technic/technic.qml
@@ -0,0 +1,56 @@
+#include "QMLDialog.h"
+#include <QQuickView>
+#include <QHBoxLayout>
+#include <QQmlContext>
+#include <QQuickItem>
+
+QMLDialog::QMLDialog(QWidget * parent)
+ : QDialog(parent)
+{
+ m_view = new QQuickView(this->windowHandle());
+ m_view->rootContext()->setContextProperty("dialog",this);
+
+ auto layout = new QHBoxLayout();
+ layout->setMargin(0);
+ QWidget *container = QWidget::createWindowContainer(m_view);
+ container->setParent(this);
+ layout->addWidget(container);
+ setLayout(layout);
+ m_view->setResizeMode(QQuickView::SizeRootObjectToView);
+}
+
+void QMLDialog::setUrl(QUrl sourceUrl)
+{
+ m_view->setSource(sourceUrl);
+ int minWidth = getPropertyValue("minWidth", -1).toInt();
+ int minHeight = getPropertyValue("minHeight", -1).toInt();
+ setMinimumSize(QSize(minWidth, minHeight));
+}
+
+
+QVariant QMLDialog::getPropertyValue(const char* name, QVariant defVal)
+{
+ auto rootobj = m_view->rootObject();
+ auto propertyObj = rootobj->property(name);
+ if(!propertyObj.isValid())
+ {
+ return defVal;
+ }
+ if(defVal.type() != propertyObj.type())
+ {
+ return defVal;
+ }
+ return propertyObj;
+}
+
+void QMLDialog::startDragging()
+{
+ m_dragPoint = mapFromGlobal(QCursor::pos());
+}
+
+void QMLDialog::updateDragging()
+{
+ QPoint draggingNow = QCursor::pos();
+ QPoint pos = draggingNow - m_dragPoint;
+ move(pos);
+}
@@ -0,0 +1,26 @@
+#pragma once
+#include <QDialog>
+#include <QUrl>
+#include <QVariant>
+
+class QQuickView;
+
+class QMLDialog: public QDialog
+{
+ Q_OBJECT
+public:
+ explicit QMLDialog(QWidget * parent = 0);
+ virtual ~QMLDialog() {};
+
+public slots:
+ void startDragging();
+ void updateDragging();
+
+public:
+ QVariant getPropertyValue (const char * name, QVariant defVal);
+ void setUrl(QUrl sourceUrl);
+
+protected: /* variables */
+ QPoint m_dragPoint;
+ QQuickView *m_view = nullptr;
+};
@@ -0,0 +1,61 @@
+#include "TechnicDialog.h"
+#include <QQmlContext>
+#include <QQuickView>
+#include "technic/PackModel.h"
+#include "technic/ImageProvider.h"
+
+TechnicDialog::TechnicDialog(QWidget *parent)
+ : QMLDialog(parent)
+{
+ m_model = new PackModel(this);
+ m_versionModel = new VersionModel(nullptr, this);
+ setWindowTitle(tr("Install Technic Pack"));
+ setWindowIcon(QIcon::fromTheme("technic"));
+ QQmlContext *ctxt = m_view->rootContext();
+ ctxt->setContextProperty("packModel", m_model);
+ ctxt->setContextProperty("versionModel", m_versionModel);
+ m_view->engine()->addImageProvider(QLatin1String("url"), new ImageProvider());
+ setUrl(QUrl(QStringLiteral("qrc:///qml/technic/technic.qml")));
+}
+
+void TechnicDialog::setCurrent(int i)
+{
+ if(m_currentPack == i)
+ {
+ return;
+ }
+ m_currentPack = -1;
+ auto pack = m_model->packByIndex(i);
+ if(pack)
+ {
+ m_versionModel->reset(pack);
+ }
+ else
+ {
+ m_versionModel->reset(nullptr);
+ }
+}
+
+
+SolderPackInfoPtr TechnicDialog::getPack()
+{
+ auto index = getPropertyValue("currentPack", -1).toInt();
+ return m_model->packByIndex(index);
+}
+
+SolderVersionPtr TechnicDialog::getVersion()
+{
+ auto versionId = getPropertyValue("currentVersion", QString("invalid")).toString();
+ return m_versionModel->versionById(versionId);
+}
+
+QString TechnicDialog::getInstanceName()
+{
+ auto pack = getPack();
+ if(!pack)
+ {
+ return "invalid";
+ }
+ auto name = getPropertyValue("instanceName", pack->display_name).toString();
+ return name;
+}
@@ -0,0 +1,21 @@
+#pragma once
+#include "QMLDialog.h"
+#include "technic/PackModel.h"
+
+class TechnicDialog : public QMLDialog
+{
+ Q_OBJECT
+public:
+ explicit TechnicDialog(QWidget * parent = 0);
+
+public:
+ Q_INVOKABLE void setCurrent(int i);
+ SolderPackInfoPtr getPack();
+ QString getInstanceName();
+ SolderVersionPtr getVersion();
+
+private:
+ int m_currentPack = -1;
+ PackModel * m_model;
+ VersionModel * m_versionModel;
+};
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.5 r10040"
+ width="400"
+ height="400"
+ sodipodi:docname="technic.svg">
+ <metadata
+ id="metadata8">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs6" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1614"
+ inkscape:window-height="1030"
+ id="namedview4"
+ showgrid="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ inkscape:zoom="1.18"
+ inkscape:cx="256.86078"
+ inkscape:cy="142.34294"
+ inkscape:window-x="1676"
+ inkscape:window-y="-3"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g3007">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2992"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true"
+ originx="0px"
+ originy="0px" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="95.5,-27.5"
+ id="guide3003" />
+ </sodipodi:namedview>
+ <path
+ style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 200 0 C 89.54305 -3.7895613e-14 0 89.54305 0 200 C 1.8947806e-14 310.45695 89.54305 400 200 400 C 310.45695 400 400 310.45695 400 200 C 400 89.54305 310.45695 -5.1958438e-14 200 0 z M 200 55 C 280.08129 55 345 119.91871 345 200 C 345 280.08129 280.08129 345 200 345 C 119.91871 345 55 280.08129 55 200 C 55 119.91871 119.91871 55 200 55 z "
+ id="path2986" />
+ <g
+ id="g3007"
+ transform="matrix(0.94999999,0,0,0.94999999,466,-42.249997)">
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="9.4699421"
+ inkscape:original="M -285.125 115.25 C -316.56723 113.95902 -334.63676 125.56457 -338.0625 149.25 C -338.55901 152.6829 -338.95765 170.00245 -338.96875 187.71875 L -339 219.9375 L -343 221 C -349.18848 222.66638 -353.72687 227.25192 -355.625 233.78125 C -357.72237 240.99597 -356.983 248.2657 -353.03125 259.09375 C -350.34647 266.45024 -350.001 268.62492 -350 278.4375 C -349.99815 291.57286 -348.57135 295.49927 -342.75 298.34375 C -339.1036 300.12548 -339 300.32578 -339 305.59375 L -339 311 L -343 311 L -347 311 L -347 325.5 L -347 340 L -343.125 340 L -339.25 340 L -338.84375 359.25 C -338.47771 376.80266 -338.24255 378.92196 -336.15625 383.21875 C -333.07907 389.55628 -328.67834 392.1313 -320.03125 392.75 C -305.21331 393.81022 -299.15733 388.64168 -298.0625 374 C -297.51735 366.7096 -297.43014 366.51437 -295 366.8125 C -291.51291 367.2403 -284.95059 371.9301 -282.25 375.9375 C -280.1013 379.12596 -280 380.24485 -280 397.65625 L -280 420 L -225.28125 412.21875 C -225.47892 411.82299 -225.30591 378.275 -224.90625 345 C -224.50659 311.725 -224.14465 273.31652 -224.09375 259.65625 L -224 234.8125 L -221.125 233.75 C -219.17498 233.01395 -217.89958 231.59335 -217.21875 229.375 L -216.21875 226.09375 L -277.96875 210.25 L -280.5625 219.5 L -296.28125 220.09375 L -295.8125 194.09375 C -295.46724 174.9177 -294.98317 167.70949 -294.03125 166.5625 C -292.90427 165.20457 -287.77161 165 -253.375 165 L -214 165 L -214 149.3125 L -220.25 143.1875 C -238.48153 125.3822 -259.57546 116.29903 -285.125 115.25 z M -280 300.9375 L -280 325.46875 L -280 350 L -288.53125 350 C -297.91043 350 -298.3723 349.68736 -297.8125 343.84375 C -297.50965 340.68239 -297.26643 340.4781 -293.25 340.1875 L -289 339.875 L -289 325.5 L -289 311.125 L -293.25 310.8125 L -297.5 310.5 L -297.5 306 L -297.5 301.5 L -288.75 301.21875 L -280 300.9375 z "
+ style="fill:#000000;fill-opacity:1"
+ id="path3034"
+ d="m -284.75,105.78125 c -16.95761,-0.69626 -31.31705,1.96262 -42.46875,9.125 -11.1517,7.16238 -18.19959,19.0396 -20.21875,33 -0.51982,3.59406 -0.55347,7.9338 -0.71875,15 -0.16528,7.0662 -0.27566,15.88525 -0.28125,24.8125 l -0.0312,25.40625 c -7.77587,3.19257 -13.86383,9.79188 -16.25,18 -2.73991,9.425 -1.50808,19.46571 2.78125,31.21875 2.56841,7.03764 2.46777,6.5033 2.46875,16.09375 9.7e-4,6.91043 0.14994,11.98093 2,17.0625 1.06112,2.9146 3.03193,5.48908 5.28125,7.59375 A 9.4708891,9.4708891 0 0 0 -356.46875,311 l 0,14.5 0,14.5 a 9.4708891,9.4708891 0 0 0 7.9375,9.34375 l 0.21875,10.09375 c 0.18374,8.81065 0.29938,13.79018 0.75,17.8125 0.45062,4.02232 1.62571,7.52081 2.875,10.09375 2.09323,4.31105 5.352,8.38038 9.6875,10.9375 4.3355,2.55712 9.13893,3.53832 14.28125,3.90625 8.59322,0.61484 16.74787,-0.40936 22.96875,-5.71875 4.40609,-3.76051 6.76366,-8.86191 8.03125,-14.53125 -0.0311,0.0727 -0.0883,-0.0541 -0.0312,0.5 0.19269,1.87158 0.28125,6.53142 0.28125,15.21875 l 0,22.34375 a 9.4708891,9.4708891 0 0 0 10.8125,9.375 l 54.71875,-7.78125 a 9.4708891,9.4708891 0 0 0 8.09375,-10.15625 c 0.003,0.0738 0.01,0.10722 0,-0.0312 -0.004,-0.10923 -0.0265,-0.38557 -0.0312,-0.65625 -0.0257,0.0426 -0.0393,0.12579 -0.0312,0.1875 a 9.4708891,9.4708891 0 0 0 -0.25,-1.25 c 0.051,0.16005 0.26572,0.55775 0.28125,0.65625 -0.0119,-0.95001 -0.0287,-2.33842 -0.0312,-4.125 -0.005,-3.68144 0.0283,-8.93394 0.0625,-15.21875 0.0684,-12.56962 0.20668,-29.25931 0.40625,-45.875 0.39989,-33.29385 0.76122,-71.6761 0.8125,-85.4375 l 0.0625,-18.84375 c 3.00234,-2.16793 5.4191,-5.47106 6.40625,-8.6875 a 9.4708891,9.4708891 0 0 0 0,-0.0312 l 1,-3.28125 a 9.4708891,9.4708891 0 0 0 -6.71875,-11.9375 l -61.75,-15.84375 a 9.4708891,9.4708891 0 0 0 -10.9375,5.25 l 0.21875,-12.0625 c 0.16677,-9.26234 0.37297,-15.45496 0.625,-19.5 5.37086,-0.2054 15.21387,-0.28125 32.34375,-0.28125 l 39.375,0 A 9.4708891,9.4708891 0 0 0 -204.53125,165 l 0,-15.6875 a 9.4708891,9.4708891 0 0 0 -2.84375,-6.75 l -6.25,-6.125 a 9.4708891,9.4708891 0 0 0 0,-0.0312 c -19.69195,-19.23158 -43.55014,-29.49281 -71.125,-30.625 z m -0.25,64.1875 c -0.008,0.0577 -0.30394,0.43362 -0.34375,0.53125 0.009,-0.0627 0.0229,-0.29266 0.0312,-0.34375 0.0487,-0.29961 0.35399,-0.47743 0.3125,-0.1875 z" />
+ <path
+ sodipodi:nodetypes="ssssssscccccccsscssscssssccsssccccsscssccsccccccccccssscc"
+ inkscape:connector-curvature="0"
+ id="path2989"
+ d="m -280,397.64788 c 0,-17.4114 -0.11609,-18.52438 -2.26479,-21.71284 -2.70059,-4.0074 -9.24812,-8.70054 -12.73521,-9.12834 -2.43014,-0.29813 -2.51567,-0.0971 -3.06082,7.1933 -1.09483,14.64168 -7.16764,19.82479 -21.98558,18.76457 -8.64709,-0.6187 -13.02256,-3.21475 -16.09974,-9.55228 -2.0863,-4.29679 -2.32344,-6.40963 -2.68948,-23.96229 l -0.40143,-19.25 -3.88148,0 -3.88147,0 0,-14.5 0,-14.5 4,0 4,0 0,-5.41764 c 0,-5.26797 -0.1036,-5.46827 -3.75,-7.25 -5.82135,-2.84448 -7.2466,-6.7556 -7.24845,-19.89096 -0.001,-9.81258 -0.34247,-11.99273 -3.02725,-19.34922 -3.95175,-10.82805 -4.69815,-18.09039 -2.60078,-25.30511 1.89813,-6.52933 6.42487,-11.11715 12.61335,-12.78353 l 4.01313,-1.08063 0.0201,-32.21145 c 0.0111,-17.7163 0.42635,-35.0202 0.92286,-38.4531 3.42574,-23.68543 21.48989,-35.2874 52.93212,-33.99642 25.54954,1.04903 46.64338,10.13309 64.87491,27.93839 l 6.25,6.10389 0,15.69578 -39.37756,0 c -34.39661,0 -39.54075,0.19664 -40.66773,1.55457 -0.95192,1.14699 -1.41286,8.36845 -1.75812,27.5445 l -0.46796,25.98994 15.7104,-0.58901 2.60443,-9.24229 61.74469,15.82262 -1.00774,3.2835 c -0.68083,2.21835 -1.94405,3.63692 -3.89407,4.37297 l -2.88633,1.08947 -0.0925,24.83687 c -0.0509,13.66027 -0.41954,52.06186 -0.8192,85.33686 -0.39966,33.275 -0.56493,66.8238 -0.36726,67.21956 L -280,420 z m 0,-72.18681 0,-24.53894 -8.75,0.28894 -8.75,0.28893 0,4.5 0,4.5 4.25,0.3075 4.25,0.3075 0,14.385 0,14.385 -4.25,0.3075 c -4.01643,0.2906 -4.26761,0.49134 -4.57046,3.6527 -0.5598,5.84361 -0.0901,6.1548 9.28908,6.1548 L -280,350 z"
+ style="fill:#138ad3;fill-opacity:1" />
+ <path
+ id="path2996"
+ d="m -280,55 c -110.45695,0 -200,89.54305 -200,200 0,110.45695 89.54305,200 200,200 110.45695,0 200,-89.54305 200,-200 0,-110.45695 -89.54305,-200 -200,-200 z m 0,37.5 c 89.74627,0 162.5,72.75373 162.5,162.5 0,89.74627 -72.75373,162.5 -162.5,162.5 -89.74627,0 -162.5,-72.75373 -162.5,-162.5 0,-89.74627 72.75373,-162.5 162.5,-162.5 z"
+ style="color:#000000;fill:#138ad3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
@@ -0,0 +1,48 @@
+import QtQuick 2.0
+
+Item {
+ id: scrollbar;
+
+ property Flickable flickable : undefined
+
+ width: 7
+ anchors.right: flickable.right;
+ anchors.top: flickable.top
+ anchors.bottom: flickable.bottom
+ z:1
+
+ Rectangle {
+ id: scrollHandle
+ clip: true
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: flickable.visibleArea.heightRatio * flickable.height
+ visible: flickable.visibleArea.heightRatio < 1.0
+ color: "#808080"
+
+ Binding {
+ target: scrollHandle
+ property: "y"
+ value: (mouseArea.drag.maximumY * flickable.contentY) / (flickable.contentHeight * (1 - flickable.visibleArea.heightRatio))
+ when: !mouseArea.drag.active
+ }
+
+ Binding {
+ target: flickable
+ property: "contentY"
+ value: ((flickable.contentHeight * (1 - flickable.visibleArea.heightRatio)) * scrollHandle.y) / mouseArea.drag.maximumY
+ when: mouseArea.drag.active
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ drag.target: parent
+ drag.axis: Drag.YAxis
+ drag.minimumY: 0
+ drag.maximumY: flickable.height - scrollHandle.height
+ preventStealing: true
+ }
+ }
+}
@@ -0,0 +1,11 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource prefix="/qml">
+ <file>technic/technic.qml</file>
+ <file>technic/close.svg</file>
+ <file>technic/install.svg</file>
+ <file>technic/default_logo.png</file>
+ <file>technic/default_background.jpg</file>
+ <file>ScrollBar.qml</file>
+ </qresource>
+</RCC>
Oops, something went wrong.

0 comments on commit 608e108

Please sign in to comment.