Mon, 19 Jul 2021 19:28:16 +0300
Add connections
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
src/document.cpp | file | annotate | diff | comparison | revisions | |
src/document.h | file | annotate | diff | comparison | revisions | |
src/mainwindow.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.h | file | annotate | diff | comparison | revisions | |
src/tools/basetool.h | file | annotate | diff | comparison | revisions | |
src/tools/drawtool.cpp | file | annotate | diff | comparison | revisions | |
src/tools/drawtool.h | file | annotate | diff | comparison | revisions | |
src/ui/canvas.cpp | file | annotate | diff | comparison | revisions | |
src/ui/canvas.h | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Sun May 16 22:41:00 2021 +0300 +++ b/CMakeLists.txt Mon Jul 19 19:28:16 2021 +0300 @@ -155,8 +155,8 @@ include_directories("${PROJECT_SOURCE_DIR}/src") # Translations -qt5_create_translation(QM_FILES ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} ${LDFORGE_FORMS} ${LDFORGE_LOCALES}) -add_custom_target(translations ALL DEPENDS ${QM_FILES}) +#qt5_create_translation(QM_FILES ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} ${LDFORGE_FORMS} ${LDFORGE_LOCALES}) +#add_custom_target(translations ALL DEPENDS ${QM_FILES}) add_custom_target(resources ALL DEPENDS ${LDFORGE_RESOURCES}) if (NOT MSVC) @@ -183,8 +183,8 @@ ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} ${LDFORGE_RESOURCES} - ${LDFORGE_QRC} - ${LDFORGE_QM_RC_FILE} + #${LDFORGE_QRC} + #${LDFORGE_QM_RC_FILE} ${QM_FILES} ${LDFORGE_FORMS_HEADERS} ${LDFORGE_OTHER_FILES}
--- a/src/document.cpp Sun May 16 22:41:00 2021 +0300 +++ b/src/document.cpp Mon Jul 19 19:28:16 2021 +0300 @@ -71,6 +71,7 @@ this->selectionChanged(resolve(this->ui.listView->selectionModel()->selection())); }); connect(this->model, &Model::dataChanged, this->renderer, qOverload<>(&Canvas::update)); + connect(this->renderer, &Canvas::mouseClick, this, &Document::mouseClick); } Document::~Document()
--- a/src/document.h Sun May 16 22:41:00 2021 +0300 +++ b/src/document.h Mon Jul 19 19:28:16 2021 +0300 @@ -45,6 +45,7 @@ signals: void newStatusText(const QString& newStatusText); void splitterChanged(); + void mouseClick(const Canvas::MouseClickInfo& info); private: void selectionChanged(const QSet<ldraw::id_t>& newSelection); Model* model;
--- a/src/mainwindow.cpp Sun May 16 22:41:00 2021 +0300 +++ b/src/mainwindow.cpp Mon Jul 19 19:28:16 2021 +0300 @@ -212,6 +212,7 @@ this->ui->tabs->setCurrentWidget(document); document->restoreSplitterState(this->documentSplitterState); connect(document, &Document::splitterChanged, this, &MainWindow::handleDocumentSplitterChange); + connect(document, &Document::mouseClick, this, &MainWindow::canvasMouseReleased); } void MainWindow::runSettingsEditor() @@ -411,16 +412,11 @@ } -void MainWindow::canvasMouseReleased(QMouseEvent *event) +void MainWindow::canvasMouseReleased(const Canvas::MouseClickInfo& info) { - BaseTool::MouseEventData eventData; - eventData.ev = event; - // Qt::KeyboardModifiers keymods; - // bool mouseMoved; - // Qt::MouseButtons releasedButtons; if (this->selectedTool != nullptr) { - this->selectedTool->mouseReleased(eventData); + this->selectedTool->mouseClick(info); } }
--- a/src/mainwindow.h Sun May 16 22:41:00 2021 +0300 +++ b/src/mainwindow.h Mon Jul 19 19:28:16 2021 +0300 @@ -25,6 +25,7 @@ #include "documentmanager.h" #include "libraries.h" #include "uiutilities.h" +#include "ui/canvas.h" class MainWindow : public QMainWindow { @@ -75,7 +76,7 @@ void selectTool(BaseTool* tool); private slots: void canvasMousePressed(QMouseEvent* event); - void canvasMouseReleased(QMouseEvent* event); + void canvasMouseReleased(const Canvas::MouseClickInfo& info); void canvasMouseDoubleClicked(QMouseEvent* event); void canvasMouseMoved(QMouseEvent*); void canvasKeyReleased(QKeyEvent*);
--- a/src/tools/basetool.h Sun May 16 22:41:00 2021 +0300 +++ b/src/tools/basetool.h Mon Jul 19 19:28:16 2021 +0300 @@ -1,26 +1,19 @@ #pragma once #include <QMouseEvent> #include "../main.h" +#include "../ui/canvas.h" class BaseTool : public QObject { Q_OBJECT public: - struct MouseEventData - { - QMouseEvent* ev; - Qt::KeyboardModifiers keymods; - bool mouseMoved; - Qt::MouseButtons releasedButtons; - }; - BaseTool(QObject* parent = nullptr); virtual QString name() const = 0; virtual QString toolTip() const = 0; virtual bool mousePressed(QMouseEvent*) { return false; } - virtual bool mouseReleased(MouseEventData const&) { return false; } + virtual bool mouseClick(const Canvas::MouseClickInfo&) { return false; } virtual bool mouseDoubleClicked(QMouseEvent*) { return false; } virtual bool mouseMoved(QMouseEvent*) { return false; } virtual bool keyReleased(QKeyEvent*) { return false; }
--- a/src/tools/drawtool.cpp Sun May 16 22:41:00 2021 +0300 +++ b/src/tools/drawtool.cpp Mon Jul 19 19:28:16 2021 +0300 @@ -16,7 +16,9 @@ return result; } -bool DrawTool::mouseReleased(const BaseTool::MouseEventData &event) +bool DrawTool::mouseClick(const Canvas::MouseClickInfo& info) { + static_cast<void>(info); QMessageBox::information(nullptr, "hleelo", "it works"); + return true; }
--- a/src/tools/drawtool.h Sun May 16 22:41:00 2021 +0300 +++ b/src/tools/drawtool.h Mon Jul 19 19:28:16 2021 +0300 @@ -10,5 +10,5 @@ QString name() const; QString toolTip() const; - bool mouseReleased(MouseEventData const& event) override; + bool mouseClick(const Canvas::MouseClickInfo& info) override; };
--- a/src/ui/canvas.cpp Sun May 16 22:41:00 2021 +0300 +++ b/src/ui/canvas.cpp Mon Jul 19 19:28:16 2021 +0300 @@ -89,6 +89,9 @@ void Canvas::mouseReleaseEvent(QMouseEvent* event) { + MouseClickInfo info; + info.click = this->totalMouseMove < (2.0 / sqrt(2)) * 5.0; + emit mouseClick(info); if (this->totalMouseMove < (2.0 / sqrt(2)) * 5.0) { if (this->highlighted == ldraw::NULL_ID)
--- a/src/ui/canvas.h Sun May 16 22:41:00 2021 +0300 +++ b/src/ui/canvas.h Mon Jul 19 19:28:16 2021 +0300 @@ -7,6 +7,7 @@ { Q_OBJECT public: + struct MouseClickInfo; Canvas( Model* model, DocumentManager* documents, @@ -23,6 +24,7 @@ signals: void newStatusText(const QString& newStatusText); void selectionChanged(const QSet<ldraw::id_t>& newSelection); + void mouseClick(const MouseClickInfo& info); private: void updateGridMatrix(); glm::vec3 cameraVector() const; @@ -35,3 +37,8 @@ int totalMouseMove = 0; QSet<ldraw::id_t> selection; }; + +struct Canvas::MouseClickInfo +{ + bool click; +};