LV2 Toolkit  1.2.0
qt4ui.hpp
1 /*
2  qt4ui.hpp - This file is part of LVTK
3  Copyright (C) 2013 Michael Fisher <mfisher@bketech.com>
4 
5  LVTK is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3 of the License, or
8  (at your option) any later version.
9 
10  LVTK is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with LVTK; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
21 #ifndef LVTK_QT4UI_HPP
22 #define LVTK_QT4UI_HPP
23 
24 #include <lvtk/ui.hpp>
25 
26 #include <QWidget>
27 
28 namespace lvtk {
29 
37  template <bool Required = true>
38  struct Qt4UI
39  {
41  template <class Derived>
42  struct I : Extension<Required>
43  {
44  I() : p_widget (0) { }
45 
46  ~I()
47  {
48  if (p_widget && ! p_widget->parent())
49  {
50  delete p_widget;
51  }
52  }
53 
55  static void
57  {
59  }
60 
61 
64  bool
66  {
67  return (p_widget != 0);
68  }
69 
70  protected:
71 
78  void
79  set_widget (QWidget* plugin_gui)
80  {
81  if (p_widget == plugin_gui)
82  return;
83 
84  if (0 != p_widget) {
85  delete p_widget;
86  p_widget = 0;
87  }
88 
89  p_widget = plugin_gui;
90  }
91 
94  LV2UI_Widget*
96  {
97  return widget_cast (p_widget);
98  }
99 
100  private:
102  QWidget *p_widget;
103 
104  };
105  };
106 
107 
108 } /* namespace lvtk */
109 
110 
111 #endif /* LVTK_QT4UI_HPP */
LV2UI_Widget * widget()
Definition: qt4ui.hpp:95
static void map_feature_handlers(FeatureHandlerMap &hmap)
Definition: qt4ui.hpp:56
bool check_ok()
Definition: qt4ui.hpp:65
void set_widget(QWidget *plugin_gui)
Definition: qt4ui.hpp:79
Definition: feature.hpp:34
Definition: qt4ui.hpp:38
map< string, FeatureHandler > FeatureHandlerMap
Definition: feature.hpp:57
Definition: qt4ui.hpp:42