Code formatting, enable c++17 for qmlfrontend
authorunC0Rr
Tue, 15 Nov 2022 15:25:37 +0100
changeset 15894 ebc50f21e849
parent 15893 5b3beb90e1a6
child 15895 9b8d4f34e0f3
Code formatting, enable c++17 for qmlfrontend
qmlfrontend/CMakeLists.txt
qmlfrontend/game_view.cpp
--- a/qmlfrontend/CMakeLists.txt	Tue Nov 15 14:27:22 2022 +0100
+++ b/qmlfrontend/CMakeLists.txt	Tue Nov 15 15:25:37 2022 +0100
@@ -1,7 +1,10 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.8)
 
 project(qmlfrontend LANGUAGES CXX)
 
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
--- a/qmlfrontend/game_view.cpp	Tue Nov 15 14:27:22 2022 +0100
+++ b/qmlfrontend/game_view.cpp	Tue Nov 15 15:25:37 2022 +0100
@@ -42,7 +42,9 @@
 void GameView::cleanup() { m_renderer.reset(); }
 
 void GameView::setEngineInstance(EngineInstance* engineInstance) {
-  if (m_engineInstance == engineInstance) return;
+  if (m_engineInstance == engineInstance) {
+    return;
+  }
 
   cleanup();
   m_engineInstance = engineInstance;
@@ -59,13 +61,13 @@
             &GameViewRenderer::paint, Qt::DirectConnection);
   }
 
-  if (m_windowChanged || (m_viewportSize != window()->size())) {
+  if (m_windowChanged || (m_viewportSize != size())) {
     m_windowChanged = false;
 
     if (m_engineInstance)
       m_engineInstance->setOpenGLContext(window()->openglContext());
 
-    m_viewportSize = window()->size();
+    m_viewportSize = size().toSize();
     m_centerPoint = QPoint(m_viewportSize.width(), m_viewportSize.height()) / 2;
   }
 
@@ -75,7 +77,9 @@
     QCursor::setPos(mapToGlobal(m_centerPoint).toPoint());
   }
 
-  if (m_renderer) m_renderer->tick(m_delta);
+  if (m_renderer) {
+    m_renderer->tick(m_delta);
+  }
 }
 
 GameViewRenderer::GameViewRenderer()
@@ -90,7 +94,9 @@
 }
 
 void GameViewRenderer::paint() {
-  if (m_delta == 0) return;
+  if (m_delta == 0) {
+    return;
+  }
 
   if (m_engineInstance) {
     m_engineInstance->advance(m_delta);