Sfoglia il codice sorgente

Add ctkPopupWidgetPlugin

Julien Finet 13 anni fa
parent
commit
3ecba8ecc8

+ 3 - 0
Libs/Widgets/Plugins/CMakeLists.txt

@@ -57,6 +57,8 @@ SET(PLUGIN_SRCS
   ctkModalityWidgetPlugin.h
   ctkPathLineEditPlugin.cpp
   ctkPathLineEditPlugin.h
+  ctkPopupWidgetPlugin.cpp
+  ctkPopupWidgetPlugin.h
   ctkRangeSliderPlugin.cpp
   ctkRangeSliderPlugin.h
   ctkRangeWidgetPlugin.cpp
@@ -103,6 +105,7 @@ SET(PLUGIN_MOC_SRCS
   ctkMenuButtonPlugin.h
   ctkModalityWidgetPlugin.h
   ctkPathLineEditPlugin.h
+  ctkPopupWidgetPlugin.h
   ctkRangeSliderPlugin.h
   ctkRangeWidgetPlugin.h
   ctkTransferFunctionViewPlugin.h

+ 67 - 0
Libs/Widgets/Plugins/ctkPopupWidgetPlugin.cpp

@@ -0,0 +1,67 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// CTK includes
+#include "ctkPopupWidgetPlugin.h"
+#include "ctkPopupWidget.h"
+
+//-----------------------------------------------------------------------------
+ctkPopupWidgetPlugin::ctkPopupWidgetPlugin(QObject* pluginParent)
+  : QObject(pluginParent)
+{
+}
+
+//-----------------------------------------------------------------------------
+QWidget *ctkPopupWidgetPlugin::createWidget(QWidget* widgetParent)
+{
+  ctkPopupWidget* newWidget = new ctkPopupWidget(widgetParent);
+  newWidget->setWindowFlags(0);
+  return newWidget;
+}
+
+//-----------------------------------------------------------------------------
+QString ctkPopupWidgetPlugin::domXml() const
+{
+  return "<widget class=\"ctkPopupWidget\" name=\"PopupWidget\">\n</widget>\n";
+}
+
+//-----------------------------------------------------------------------------
+QIcon ctkPopupWidgetPlugin::icon() const
+{
+  return QIcon(":/Icons/widget.png");
+}
+
+//-----------------------------------------------------------------------------
+QString ctkPopupWidgetPlugin::includeFile() const
+{
+  return "ctkPopupWidget.h";
+}
+
+//-----------------------------------------------------------------------------
+bool ctkPopupWidgetPlugin::isContainer() const
+{
+  return true;
+}
+
+//-----------------------------------------------------------------------------
+QString ctkPopupWidgetPlugin::name() const
+{
+  return "ctkPopupWidget";
+}

+ 44 - 0
Libs/Widgets/Plugins/ctkPopupWidgetPlugin.h

@@ -0,0 +1,44 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+#ifndef __ctkPopupWidgetPlugin_h
+#define __ctkPopupWidgetPlugin_h
+
+// CTK includes
+#include "ctkWidgetsAbstractPlugin.h"
+
+class CTK_WIDGETS_PLUGINS_EXPORT ctkPopupWidgetPlugin
+  : public QObject
+  , public ctkWidgetsAbstractPlugin
+{
+  Q_OBJECT
+
+public:
+  ctkPopupWidgetPlugin(QObject* pluginParent = 0);
+  
+  QWidget *createWidget(QWidget* parentWidget);
+  QString  domXml() const;
+  QIcon    icon() const;
+  QString  includeFile() const;
+  bool     isContainer() const;
+  QString  name() const;
+};
+
+#endif

+ 2 - 0
Libs/Widgets/Plugins/ctkWidgetsPlugins.h

@@ -47,6 +47,7 @@
 #include "ctkMenuButtonPlugin.h"
 #include "ctkModalityWidgetPlugin.h"
 #include "ctkPathLineEditPlugin.h"
+#include "ctkPopupWidgetPlugin.h"
 #include "ctkRangeSliderPlugin.h"
 #include "ctkRangeWidgetPlugin.h"
 #include "ctkSettingsPanelPlugin.h"
@@ -89,6 +90,7 @@ public:
             << new ctkMenuButtonPlugin
             << new ctkModalityWidgetPlugin
             << new ctkPathLineEditPlugin
+            << new ctkPopupWidgetPlugin
             << new ctkRangeSliderPlugin
             << new ctkRangeWidgetPlugin
             << new ctkSettingsPanelPlugin

+ 9 - 0
Libs/Widgets/ctkPopupWidget.h

@@ -24,6 +24,7 @@
 // Qt includes
 #include <QEasingCurve>
 #include <QFrame>
+#include <QMetaType>
 
 // CTK includes
 #include "ctkWidgetsExport.h"
@@ -34,6 +35,10 @@ class ctkPopupWidgetPrivate;
 class CTK_WIDGETS_EXPORT ctkPopupWidget : public QFrame
 {
   Q_OBJECT
+  
+  Q_ENUMS(AnimationEffect)
+  Q_ENUMS(VerticalDirection)
+
   /// Control wether the popup automatically opens when the mouse
   /// enter the widget. True by default
   Q_PROPERTY( bool autoShow READ autoShow WRITE setAutoShow)
@@ -149,6 +154,10 @@ private:
   Q_DISABLE_COPY(ctkPopupWidget);
 };
 
+Q_DECLARE_METATYPE(ctkPopupWidget::AnimationEffect)
+Q_DECLARE_METATYPE(ctkPopupWidget::VerticalDirection)
+
+// -------------------------------------------------------------------------
 void ctkPopupWidget::showPopup(bool show)
 {
   if (show)