changeset 280:829163c6efc1 am-2

split MainWindow into a generic one and one specific to these samples
author am@osimis.io
date Mon, 27 Aug 2018 16:22:08 +0200
parents 8f5d7495076d
children 300d8b8c48b3
files Applications/Qt/QCairoWidget.cpp Applications/Qt/QCairoWidget.h Applications/Qt/QStoneMainWindow.cpp Applications/Qt/QStoneMainWindow.h Applications/Samples/Qt/MainWindow.cpp Applications/Samples/Qt/MainWindow.h Platforms/Generic/CMakeLists.txt Resources/CMake/QtConfiguration.cmake
diffstat 8 files changed, 177 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Qt/QCairoWidget.cpp	Mon Aug 27 15:40:13 2018 +0200
+++ b/Applications/Qt/QCairoWidget.cpp	Mon Aug 27 16:22:08 2018 +0200
@@ -1,3 +1,23 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
 #include "QCairoWidget.h"
 
 #include <QPainter>
--- a/Applications/Qt/QCairoWidget.h	Mon Aug 27 15:40:13 2018 +0200
+++ b/Applications/Qt/QCairoWidget.h	Mon Aug 27 16:22:08 2018 +0200
@@ -1,3 +1,23 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
 #pragma once
 
 #include "../../Framework/Widgets/CairoWidget.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Qt/QStoneMainWindow.cpp	Mon Aug 27 16:22:08 2018 +0200
@@ -0,0 +1,39 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "QStoneMainWindow.h"
+
+QStoneMainWindow::QStoneMainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent) :
+  QMainWindow(parent),
+  context_(context)
+{
+}
+
+void QStoneMainWindow::SetCentralStoneWidget(QCairoWidget *centralWidget)
+{
+  cairoCentralWidget_ = centralWidget;
+  cairoCentralWidget_->SetContext(context_);
+}
+
+QStoneMainWindow::~QStoneMainWindow()
+{
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Qt/QStoneMainWindow.h	Mon Aug 27 16:22:08 2018 +0200
@@ -0,0 +1,42 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+#pragma once
+
+#include <QMainWindow>
+
+#include "QCairoWidget.h"
+#include "../Generic/BasicNativeApplicationContext.h"
+
+class QStoneMainWindow : public QMainWindow
+{
+  Q_OBJECT
+
+private:
+  OrthancStone::BasicNativeApplicationContext& context_;
+  QCairoWidget          *cairoCentralWidget_;
+
+protected:  // you must inherit this class
+  QStoneMainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent = 0);
+  void SetCentralStoneWidget(QCairoWidget* centralWidget);
+public:
+  virtual ~QStoneMainWindow();
+
+};
+
--- a/Applications/Samples/Qt/MainWindow.cpp	Mon Aug 27 15:40:13 2018 +0200
+++ b/Applications/Samples/Qt/MainWindow.cpp	Mon Aug 27 16:22:08 2018 +0200
@@ -1,3 +1,23 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
 #include "MainWindow.h"
 
 /**
@@ -7,13 +27,11 @@
 #include <ui_MainWindow.h>
 
 MainWindow::MainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent) :
-  QMainWindow(parent),
-  ui_(new Ui::MainWindow),
-  context_(context)
+  QStoneMainWindow(context, parent),
+  ui_(new Ui::MainWindow)
 {
   ui_->setupUi(this);
-  cairoCentralWidget_ = ui_->cairoCentralWidget;
-  cairoCentralWidget_->SetContext(context_);
+  SetCentralStoneWidget(ui_->cairoCentralWidget);
 }
 
 MainWindow::~MainWindow()
--- a/Applications/Samples/Qt/MainWindow.h	Mon Aug 27 15:40:13 2018 +0200
+++ b/Applications/Samples/Qt/MainWindow.h	Mon Aug 27 16:22:08 2018 +0200
@@ -1,30 +1,41 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+#pragma once
 
 #include "../../Qt/QCairoWidget.h"
-#include "../../Generic/BasicNativeApplicationContext.h"
+#include "../../Qt/QStoneMainWindow.h"
+
 namespace Ui 
 {
   class MainWindow;
 }
 
 
-class MainWindow : public QMainWindow
+class MainWindow : public QStoneMainWindow
 {
   Q_OBJECT
 
-public:
-
 private:
   Ui::MainWindow        *ui_;
-  OrthancStone::BasicNativeApplicationContext& context_;
-  QCairoWidget          *cairoCentralWidget_;
 
 public:
   explicit MainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent = 0);
   ~MainWindow();
 };
-
-#endif // MAINWINDOW_H
--- a/Platforms/Generic/CMakeLists.txt	Mon Aug 27 15:40:13 2018 +0200
+++ b/Platforms/Generic/CMakeLists.txt	Mon Aug 27 16:22:08 2018 +0200
@@ -29,8 +29,8 @@
 
 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options)
 
-SET(ENABLE_SDL ON)
-SET(ENABLE_QT OFF)
+SET(ENABLE_SDL OFF)
+SET(ENABLE_QT ON)
 SET(ORTHANC_SANDBOXED OFF)
 SET(ENABLE_CRYPTO_OPTIONS ON)
 SET(ENABLE_GOOGLE_TEST ON)
@@ -47,6 +47,13 @@
 ## Build all the sample applications
 #####################################################################
 
+if (ENABLE_QT)
+  list(APPEND APPLICATIONS_SOURCES
+    ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/MainWindow.cpp
+    ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/MainWindow.ui
+    )
+endif()
+
 macro(BuildSample Target Header Sample)
   add_executable(${Target}
     ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainNative.cpp
--- a/Resources/CMake/QtConfiguration.cmake	Mon Aug 27 15:40:13 2018 +0200
+++ b/Resources/CMake/QtConfiguration.cmake	Mon Aug 27 16:22:08 2018 +0200
@@ -26,16 +26,10 @@
 find_package(Qt5Widgets)
 find_package(Qt5Core)
 
-#qt5_wrap_ui(UI_HEADERS
-#    ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/MainWindow.ui
-#)
-set_property(SOURCE ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/MainWindow.h PROPERTY SKIP_AUTOMOC ON)
-
 list(APPEND QT_SOURCES
     ${ORTHANC_STONE_ROOT}/Applications/Qt/QCairoWidget.cpp
     ${ORTHANC_STONE_ROOT}/Applications/Qt/BasicQtApplication.cpp
-    ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/MainWindow.cpp
-    ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/MainWindow.ui
+    ${ORTHANC_STONE_ROOT}/Applications/Qt/QStoneMainWindow.cpp
 )
 
 include_directories(${ORTHANC_STONE_ROOT}/Applications/Qt/)