diff --git a/common/lc_global.h b/common/lc_global.h index efa3f762..399035b0 100644 --- a/common/lc_global.h +++ b/common/lc_global.h @@ -75,6 +75,7 @@ class lcVector4; class lcMatrix33; class lcMatrix44; +class lcViewWidget; class lcGLWidget; class lcContext; class lcMesh; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 93260170..1217cec1 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -4,7 +4,7 @@ #include #include "lc_partselectionwidget.h" #include "lc_timelinewidget.h" -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" #include "lc_qcolorlist.h" #include "lc_qpropertiestree.h" #include "lc_qutils.h" @@ -63,7 +63,7 @@ void lcModelTabWidget::ResetLayout() QLayout* TabLayout = layout(); QWidget* TopWidget = TabLayout->itemAt(0)->widget(); - if (TopWidget->metaObject() == &lcQGLWidget::staticMetaObject) + if (TopWidget->metaObject() == &lcViewWidget::staticMetaObject) return; QWidget* Widget = GetAnyViewWidget(); @@ -83,7 +83,7 @@ void lcModelTabWidget::Clear() View->Clear(); mViews.RemoveAll(); mActiveView = nullptr; - lcQGLWidget* Widget = (lcQGLWidget*)layout()->itemAt(0)->widget(); + lcViewWidget* Widget = (lcViewWidget*)layout()->itemAt(0)->widget(); delete Widget->GetView(); Widget->SetView(nullptr); } @@ -1371,9 +1371,9 @@ QByteArray lcMainWindow::GetTabLayout() std::function SaveWidget = [&DataStream, &SaveWidget, &TabWidget](QWidget* Widget) { - if (Widget->metaObject() == &lcQGLWidget::staticMetaObject) + if (Widget->metaObject() == &lcViewWidget::staticMetaObject) { - View* CurrentView = (View*)((lcQGLWidget*)Widget)->GetView(); + View* CurrentView = (View*)((lcViewWidget*)Widget)->GetView(); DataStream << (qint32)0; DataStream << (qint32)(TabWidget->GetActiveView() == CurrentView ? 1 : 0); @@ -1472,7 +1472,7 @@ void lcMainWindow::RestoreTabLayout(const QByteArray& TabLayout) View* CurrentView = nullptr; if (ParentWidget) - CurrentView = (View*)((lcQGLWidget*)ParentWidget)->GetView(); + CurrentView = (View*)((lcViewWidget*)ParentWidget)->GetView(); if (CameraType == 0) { @@ -1595,7 +1595,7 @@ void lcMainWindow::SetCurrentModelTab(lcModel* Model) } lcModelTabWidget* TabWidget; - lcQGLWidget* ViewWidget; + lcViewWidget* ViewWidget; View* NewView; if (!EmptyWidget) @@ -1607,7 +1607,7 @@ void lcMainWindow::SetCurrentModelTab(lcModel* Model) CentralLayout->setContentsMargins(0, 0, 0, 0); NewView = CreateView(Model); - ViewWidget = new lcQGLWidget(TabWidget, NewView); + ViewWidget = new lcViewWidget(TabWidget, NewView); CentralLayout->addWidget(ViewWidget, 0, 0, 1, 1); mModelTabWidget->setCurrentWidget(TabWidget); @@ -1618,7 +1618,7 @@ void lcMainWindow::SetCurrentModelTab(lcModel* Model) TabWidget->SetModel(Model); NewView = CreateView(Model); - ViewWidget = (lcQGLWidget*)TabWidget->layout()->itemAt(0)->widget(); + ViewWidget = (lcViewWidget*)TabWidget->layout()->itemAt(0)->widget(); ViewWidget->SetView(NewView); AddView(NewView); @@ -1802,7 +1802,7 @@ void lcMainWindow::SplitView(Qt::Orientation Orientation) { QWidget* Focus = focusWidget(); - if (Focus->metaObject() != &lcQGLWidget::staticMetaObject) + if (Focus->metaObject() != &lcViewWidget::staticMetaObject) return; QWidget* Parent = Focus->parentWidget(); @@ -1814,7 +1814,7 @@ void lcMainWindow::SplitView(Qt::Orientation Orientation) Splitter = new QSplitter(Orientation, Parent); Parent->layout()->addWidget(Splitter); Splitter->addWidget(Focus); - Splitter->addWidget(new lcQGLWidget(mModelTabWidget->currentWidget(), CreateView(GetCurrentTabModel()))); + Splitter->addWidget(new lcViewWidget(mModelTabWidget->currentWidget(), CreateView(GetCurrentTabModel()))); } else { @@ -1825,7 +1825,7 @@ void lcMainWindow::SplitView(Qt::Orientation Orientation) Splitter = new QSplitter(Orientation, Parent); ParentSplitter->insertWidget(FocusIndex, Splitter); Splitter->addWidget(Focus); - Splitter->addWidget(new lcQGLWidget(mModelTabWidget->currentWidget(), CreateView(GetCurrentTabModel()))); + Splitter->addWidget(new lcViewWidget(mModelTabWidget->currentWidget(), CreateView(GetCurrentTabModel()))); ParentSplitter->setSizes(Sizes); } @@ -1851,7 +1851,7 @@ void lcMainWindow::RemoveActiveView() { QWidget* Focus = focusWidget(); - if (Focus->metaObject() != &lcQGLWidget::staticMetaObject) + if (Focus->metaObject() != &lcViewWidget::staticMetaObject) return; QWidget* Parent = Focus->parentWidget(); @@ -1885,7 +1885,7 @@ void lcMainWindow::RemoveActiveView() Parent->deleteLater(); - if (OtherWidget->metaObject() != &lcQGLWidget::staticMetaObject) + if (OtherWidget->metaObject() != &lcViewWidget::staticMetaObject) { lcModelTabWidget* TabWidget = (lcModelTabWidget*)mModelTabWidget->currentWidget(); diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index d4d9acd1..1ff8c307 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -9,7 +9,6 @@ class View; class lcPartSelectionWidget; class lcPreviewDockWidget; class PiecePreview; -class lcQGLWidget; class lcQPartsTree; class lcQColorList; class lcQPropertiesTree; diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index b90a0a88..e5dec8fc 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -10,8 +10,7 @@ #include "pieceinf.h" #include "view.h" #include "lc_glextensions.h" - -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" #include "lc_previewwidget.h" Q_DECLARE_METATYPE(QList) @@ -712,7 +711,7 @@ void lcPartSelectionListView::PreviewSelection(int InfoIndex) lcPreviewWidget* Preview = new lcPreviewWidget(); - lcQGLWidget* ViewWidget = new lcQGLWidget(nullptr, Preview); + lcViewWidget* ViewWidget = new lcViewWidget(nullptr, Preview); if (Preview && ViewWidget) { diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index fad59687..e67ab87f 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -7,14 +7,13 @@ #include "camera.h" #include "lc_library.h" #include "lc_viewsphere.h" - -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" lcPreviewDockWidget::lcPreviewDockWidget(QMainWindow* Parent) : QMainWindow(Parent) { mPreview = new lcPreviewWidget(); - mViewWidget = new lcQGLWidget(nullptr, mPreview); + mViewWidget = new lcViewWidget(nullptr, mPreview); setCentralWidget(mViewWidget); setMinimumSize(200, 200); diff --git a/common/lc_previewwidget.h b/common/lc_previewwidget.h index 4e3b0b3f..0ffcf282 100644 --- a/common/lc_previewwidget.h +++ b/common/lc_previewwidget.h @@ -4,7 +4,6 @@ #include "lc_scene.h" #include "lc_commands.h" -class lcQGLWidget; class lcPreviewWidget; class lcPreviewDockWidget : public QMainWindow @@ -25,7 +24,7 @@ protected: QToolBar* mToolBar; QLabel* mLabel; lcPreviewWidget* mPreview; - lcQGLWidget* mViewWidget; + lcViewWidget* mViewWidget; }; class lcPreviewWidget : public lcGLWidget diff --git a/common/lc_timelinewidget.cpp b/common/lc_timelinewidget.cpp index d733601a..4765892b 100644 --- a/common/lc_timelinewidget.cpp +++ b/common/lc_timelinewidget.cpp @@ -4,8 +4,7 @@ #include "piece.h" #include "pieceinf.h" #include "lc_mainwindow.h" - -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" #include "lc_previewwidget.h" lcTimelineWidget::lcTimelineWidget(QWidget* Parent) @@ -534,9 +533,9 @@ void lcTimelineWidget::PreviewSelection(QTreeWidgetItem* Current) if (!Info) return; - lcPreviewWidget *Preview = new lcPreviewWidget(); + lcPreviewWidget* Preview = new lcPreviewWidget(); - lcQGLWidget *ViewWidget = new lcQGLWidget(nullptr, Preview); + lcViewWidget* ViewWidget = new lcViewWidget(nullptr, Preview); if (Preview && ViewWidget) { diff --git a/qt/lc_qglwidget.cpp b/common/lc_viewwidget.cpp similarity index 87% rename from qt/lc_qglwidget.cpp rename to common/lc_viewwidget.cpp index 5ed72a78..69fae72f 100644 --- a/qt/lc_qglwidget.cpp +++ b/common/lc_viewwidget.cpp @@ -1,5 +1,5 @@ #include "lc_global.h" -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" #include "lc_glwidget.h" #include "lc_glextensions.h" #include "project.h" @@ -17,9 +17,9 @@ #include "lc_profile.h" #include "lc_previewwidget.h" -static QList gWidgetList; +static QList gWidgetList; -lcQGLWidget::lcQGLWidget(QWidget* Parent, lcGLWidget* Owner) +lcViewWidget::lcViewWidget(QWidget* Parent, lcGLWidget* Owner) : QGLWidget(Parent, gWidgetList.isEmpty() ? nullptr : gWidgetList.first()) { mWheelAccumulator = 0; @@ -62,7 +62,7 @@ lcQGLWidget::lcQGLWidget(QWidget* Parent, lcGLWidget* Owner) } } -lcQGLWidget::~lcQGLWidget() +lcViewWidget::~lcViewWidget() { gWidgetList.removeOne(this); @@ -83,12 +83,12 @@ lcQGLWidget::~lcQGLWidget() delete mView; } -QSize lcQGLWidget::sizeHint() const +QSize lcViewWidget::sizeHint() const { return mPreferredSize.isNull() ? QGLWidget::sizeHint() : mPreferredSize; } -void lcQGLWidget::SetView(lcGLWidget* View) +void lcViewWidget::SetView(lcGLWidget* View) { mView = View; @@ -103,7 +103,7 @@ void lcQGLWidget::SetView(lcGLWidget* View) } } -void lcQGLWidget::SetPreviewPosition(const QRect& ParentRect) +void lcViewWidget::SetPreviewPosition(const QRect& ParentRect) { lcPreferences& Preferences = lcGetPreferences(); lcPreviewWidget* Preview = reinterpret_cast(mView); @@ -150,17 +150,17 @@ void lcQGLWidget::SetPreviewPosition(const QRect& ParentRect) show(); } -void lcQGLWidget::resizeGL(int Width, int Height) +void lcViewWidget::resizeGL(int Width, int Height) { mView->SetSize(Width, Height); } -void lcQGLWidget::paintGL() +void lcViewWidget::paintGL() { mView->OnDraw(); } -void lcQGLWidget::focusInEvent(QFocusEvent* FocusEvent) +void lcViewWidget::focusInEvent(QFocusEvent* FocusEvent) { if (mView) mView->SetFocus(true); @@ -168,7 +168,7 @@ void lcQGLWidget::focusInEvent(QFocusEvent* FocusEvent) QGLWidget::focusInEvent(FocusEvent); } -void lcQGLWidget::focusOutEvent(QFocusEvent* FocusEvent) +void lcViewWidget::focusOutEvent(QFocusEvent* FocusEvent) { if (mView) mView->SetFocus(false); @@ -176,7 +176,7 @@ void lcQGLWidget::focusOutEvent(QFocusEvent* FocusEvent) QGLWidget::focusOutEvent(FocusEvent); } -void lcQGLWidget::keyPressEvent(QKeyEvent* KeyEvent) +void lcViewWidget::keyPressEvent(QKeyEvent* KeyEvent) { if (KeyEvent->key() == Qt::Key_Control || KeyEvent->key() == Qt::Key_Shift) { @@ -187,7 +187,7 @@ void lcQGLWidget::keyPressEvent(QKeyEvent* KeyEvent) QGLWidget::keyPressEvent(KeyEvent); } -void lcQGLWidget::keyReleaseEvent(QKeyEvent* KeyEvent) +void lcViewWidget::keyReleaseEvent(QKeyEvent* KeyEvent) { if (KeyEvent->key() == Qt::Key_Control || KeyEvent->key() == Qt::Key_Shift) { @@ -198,7 +198,7 @@ void lcQGLWidget::keyReleaseEvent(QKeyEvent* KeyEvent) QGLWidget::keyReleaseEvent(KeyEvent); } -void lcQGLWidget::mousePressEvent(QMouseEvent* MouseEvent) +void lcViewWidget::mousePressEvent(QMouseEvent* MouseEvent) { float DeviceScale = GetDeviceScale(); @@ -234,7 +234,7 @@ void lcQGLWidget::mousePressEvent(QMouseEvent* MouseEvent) } } -void lcQGLWidget::mouseReleaseEvent(QMouseEvent* MouseEvent) +void lcViewWidget::mouseReleaseEvent(QMouseEvent* MouseEvent) { float DeviceScale = GetDeviceScale(); @@ -270,7 +270,7 @@ void lcQGLWidget::mouseReleaseEvent(QMouseEvent* MouseEvent) } } -void lcQGLWidget::mouseDoubleClickEvent(QMouseEvent* MouseEvent) +void lcViewWidget::mouseDoubleClickEvent(QMouseEvent* MouseEvent) { float DeviceScale = GetDeviceScale(); @@ -287,7 +287,7 @@ void lcQGLWidget::mouseDoubleClickEvent(QMouseEvent* MouseEvent) } } -void lcQGLWidget::mouseMoveEvent(QMouseEvent* MouseEvent) +void lcViewWidget::mouseMoveEvent(QMouseEvent* MouseEvent) { float DeviceScale = GetDeviceScale(); @@ -297,7 +297,7 @@ void lcQGLWidget::mouseMoveEvent(QMouseEvent* MouseEvent) mView->OnMouseMove(); } -void lcQGLWidget::wheelEvent(QWheelEvent* WheelEvent) +void lcViewWidget::wheelEvent(QWheelEvent* WheelEvent) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) if (WheelEvent->angleDelta().y() == 0) @@ -334,7 +334,7 @@ void lcQGLWidget::wheelEvent(QWheelEvent* WheelEvent) WheelEvent->accept(); } -void lcQGLWidget::dragEnterEvent(QDragEnterEvent* DragEnterEvent) +void lcViewWidget::dragEnterEvent(QDragEnterEvent* DragEnterEvent) { const QMimeData* MimeData = DragEnterEvent->mimeData(); @@ -354,13 +354,13 @@ void lcQGLWidget::dragEnterEvent(QDragEnterEvent* DragEnterEvent) DragEnterEvent->ignore(); } -void lcQGLWidget::dragLeaveEvent(QDragLeaveEvent* DragLeaveEvent) +void lcViewWidget::dragLeaveEvent(QDragLeaveEvent* DragLeaveEvent) { mView->EndDrag(false); DragLeaveEvent->accept(); } -void lcQGLWidget::dragMoveEvent(QDragMoveEvent* DragMoveEvent) +void lcViewWidget::dragMoveEvent(QDragMoveEvent* DragMoveEvent) { const QMimeData* MimeData = DragMoveEvent->mimeData(); @@ -380,7 +380,7 @@ void lcQGLWidget::dragMoveEvent(QDragMoveEvent* DragMoveEvent) QGLWidget::dragMoveEvent(DragMoveEvent); } -void lcQGLWidget::dropEvent(QDropEvent* DropEvent) +void lcViewWidget::dropEvent(QDropEvent* DropEvent) { const QMimeData* MimeData = DropEvent->mimeData(); diff --git a/qt/lc_qglwidget.h b/common/lc_viewwidget.h similarity index 92% rename from qt/lc_qglwidget.h rename to common/lc_viewwidget.h index ee8595b4..352ca6a6 100644 --- a/qt/lc_qglwidget.h +++ b/common/lc_viewwidget.h @@ -2,11 +2,11 @@ #include -class lcQGLWidget : public QGLWidget +class lcViewWidget : public QGLWidget { public: - lcQGLWidget(QWidget* Parent, lcGLWidget* View); - ~lcQGLWidget(); + lcViewWidget(QWidget* Parent, lcGLWidget* View); + ~lcViewWidget(); lcGLWidget* GetView() const { @@ -26,7 +26,7 @@ protected: #else return 1.0f; #endif -} + } void resizeGL(int Width, int Height) override; void paintGL() override; @@ -48,4 +48,3 @@ protected: QSize mPreferredSize; int mWheelAccumulator; }; - diff --git a/leocad.pro b/leocad.pro index 7dcc83c6..76c64dc2 100644 --- a/leocad.pro +++ b/leocad.pro @@ -195,19 +195,22 @@ SOURCES += common/view.cpp \ common/lc_mesh.cpp \ common/lc_meshloader.cpp \ common/lc_model.cpp \ - common/lc_profile.cpp \ + common/lc_partselectionwidget.cpp \ + common/lc_profile.cpp \ common/lc_scene.cpp \ common/lc_selectbycolordialog.cpp \ common/lc_shortcuts.cpp \ common/lc_stringcache.cpp \ common/lc_synth.cpp \ common/lc_texture.cpp \ - common/lc_viewsphere.cpp \ - common/lc_zipfile.cpp \ + common/lc_timelinewidget.cpp \ + common/lc_viewsphere.cpp \ + common/lc_viewwidget.cpp \ + common/lc_zipfile.cpp \ common/image.cpp \ common/group.cpp \ common/camera.cpp \ - qt/system.cpp \ + qt/system.cpp \ qt/qtmain.cpp \ qt/lc_qarraydialog.cpp \ qt/lc_qgroupdialog.cpp \ @@ -224,12 +227,9 @@ SOURCES += common/view.cpp \ qt/lc_qutils.cpp \ qt/lc_qpropertiestree.cpp \ qt/lc_qcolorpicker.cpp \ - qt/lc_qglwidget.cpp \ qt/lc_qcolorlist.cpp \ qt/lc_qfinddialog.cpp \ qt/lc_qmodellistdialog.cpp \ - common/lc_partselectionwidget.cpp \ - common/lc_timelinewidget.cpp \ qt/lc_renderdialog.cpp \ qt/lc_setsdatabasedialog.cpp \ common/lc_partpalettedialog.cpp @@ -272,8 +272,11 @@ HEADERS += \ common/lc_synth.h \ common/lc_texture.h \ common/lc_viewsphere.h \ + common/lc_viewwidget.h \ common/lc_zipfile.h \ - common/image.h \ + common/lc_partselectionwidget.h \ + common/lc_timelinewidget.h \ + common/image.h \ common/group.h \ common/camera.h \ qt/lc_qarraydialog.h \ @@ -291,12 +294,9 @@ HEADERS += \ qt/lc_qutils.h \ qt/lc_qpropertiestree.h \ qt/lc_qcolorpicker.h \ - qt/lc_qglwidget.h \ qt/lc_qcolorlist.h \ qt/lc_qfinddialog.h \ qt/lc_qmodellistdialog.h \ - common/lc_partselectionwidget.h \ - common/lc_timelinewidget.h \ qt/lc_renderdialog.h \ qt/lc_setsdatabasedialog.h \ common/lc_partpalettedialog.h diff --git a/qt/lc_qminifigdialog.cpp b/qt/lc_qminifigdialog.cpp index f868099e..78ede2a9 100644 --- a/qt/lc_qminifigdialog.cpp +++ b/qt/lc_qminifigdialog.cpp @@ -1,7 +1,7 @@ #include "lc_global.h" #include "lc_qminifigdialog.h" #include "ui_lc_qminifigdialog.h" -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" #include "lc_qcolorpicker.h" #include "minifig.h" #include "lc_mainwindow.h" @@ -19,7 +19,7 @@ lcQMinifigDialog::lcQMinifigDialog(QWidget *parent) : mMinifigWidget = new MinifigWizard(); - lcQGLWidget *minifigWidget = new lcQGLWidget(nullptr, mMinifigWidget); + lcViewWidget* minifigWidget = new lcViewWidget(nullptr, mMinifigWidget); minifigWidget->setMinimumWidth(100); previewLayout->addWidget(minifigWidget); diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index ad76beb1..23b53dbd 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -11,8 +11,7 @@ #include "pieceinf.h" #include "lc_library.h" #include "lc_qutils.h" - -#include "lc_qglwidget.h" +#include "lc_viewwidget.h" #include "lc_previewwidget.h" // Draw an icon indicating opened/closing branches @@ -1140,7 +1139,7 @@ bool lcQPropertiesTree::lastColumn(int column) const return header()->visualIndex(column) == columnCount() - 1; } -void lcQPropertiesTree::PreviewSelection(const QString &PartType, int ColorCode) +void lcQPropertiesTree::PreviewSelection(const QString& PartType, int ColorCode) { lcPreferences& Preferences = lcGetPreferences(); if (Preferences.mPreviewPosition != lcPreviewPosition::Floating) @@ -1149,9 +1148,9 @@ void lcQPropertiesTree::PreviewSelection(const QString &PartType, int ColorCode) return; } - lcPreviewWidget *Preview = new lcPreviewWidget(); + lcPreviewWidget* Preview = new lcPreviewWidget(); - lcQGLWidget *ViewWidget = new lcQGLWidget(nullptr, Preview); + lcViewWidget* ViewWidget = new lcViewWidget(nullptr, Preview); if (Preview && ViewWidget) {