[Kst] branches/work/kst/portto4/kst/src/widgets

Adam Treat treat at kde.org
Thu Sep 27 22:01:42 CEST 2007


SVN commit 717966 by treat:

* Add stubbed version of all the primitive selectors.
* Fix file requester alignment, size and layout.
* Bugfix in kstwidgets with inheritance problem.



 M  +3 -0      filerequester.cpp  
 M  +76 -0     kstwidgets.cpp  
 M  +75 -49    kstwidgets.h  
 A             matrixselector.cpp   [License: GPL (v2+)]
 A             matrixselector.h   [License: GPL (v2+)]
 A             matrixselector.ui  
 A             scalarselector.cpp   [License: GPL (v2+)]
 A             scalarselector.h   [License: GPL (v2+)]
 A             scalarselector.ui  
 A             stringselector.cpp   [License: GPL (v2+)]
 A             stringselector.h   [License: GPL (v2+)]
 A             stringselector.ui  
 A             vectorselector.cpp   [License: GPL (v2+)]
 A             vectorselector.h   [License: GPL (v2+)]
 A             vectorselector.ui  
 M  +14 -2     widgets.pro  


--- branches/work/kst/portto4/kst/src/widgets/filerequester.cpp #717965:717966
@@ -11,6 +11,7 @@
 
 #include "filerequester.h"
 
+#include <QStyle>
 #include <QLineEdit>
 #include <QToolButton>
 #include <QHBoxLayout>
@@ -51,7 +52,9 @@
   layout->addWidget(_fileButton);
   setLayout(layout);
 
+  int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
   _fileButton->setIcon(QPixmap(":kst_changefile.png"));
+  _fileButton->setFixedSize(size + 8, size + 8);
 
   setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
   connect (_fileEdit, SIGNAL(textEdited(const QString &)), this, SLOT(setFile(const QString &)));
--- branches/work/kst/portto4/kst/src/widgets/kstwidgets.cpp #717965:717966
@@ -18,6 +18,82 @@
   _plugins.append(new FileRequesterPlugin(this));
   _plugins.append(new ComboBoxPlugin(this));
   _plugins.append(new DataRangePlugin(this));
+  _plugins.append(new VectorSelectorPlugin(this));
+  _plugins.append(new MatrixSelectorPlugin(this));
+  _plugins.append(new ScalarSelectorPlugin(this));
+  _plugins.append(new StringSelectorPlugin(this));
 }
 
+
+KstWidgets::~KstWidgets() {
+}
+
+
+KstWidgetPlugin::KstWidgetPlugin(QObject *parent)
+  : QObject(parent), _initialized(false) {
+}
+
+
+KstWidgetPlugin::~KstWidgetPlugin() {
+}
+
+
+QString KstWidgetPlugin::group() const {
+  return tr("Kst Widgets");
+}
+
+
+QString KstWidgetPlugin::toolTip() const {
+  return QString::null;
+}
+
+
+QString KstWidgetPlugin::whatsThis() const {
+  return QString::null;
+}
+
+
+QString KstWidgetPlugin::instanceName() const {
+  QString name = static_cast<const QDesignerCustomWidgetInterface*>(this)->name().replace("Kst::", "");
+  QChar camel = name.at(0).toLower();
+  return name.replace(0,1,camel.toLower());
+}
+
+
+QString KstWidgetPlugin::includeFile() const {
+  return instanceName().toLower() + ".h";
+}
+
+
+QString KstWidgetPlugin::domXml() const {
+  QString name = static_cast<const QDesignerCustomWidgetInterface*>(this)->name();
+  return QString::fromUtf8("<widget class=\"%1\" name=\"%2\"/>")
+          .arg(name).arg(instanceName());
+}
+
+
+bool KstWidgetPlugin::isContainer() const {
+  return false;
+}
+
+
+bool KstWidgetPlugin::isInitialized() const {
+  return _initialized;
+}
+
+
+QIcon KstWidgetPlugin::icon() const {
+  return QIcon();
+}
+
+
+void KstWidgetPlugin::initialize(QDesignerFormEditorInterface *) {
+  if (_initialized)
+    return;
+
+  _initialized = true;
+}
+
 Q_EXPORT_PLUGIN2(kstwidgets, KstWidgets)
+
+// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/widgets/kstwidgets.h #717965:717966
@@ -17,56 +17,40 @@
 
 #include <QtPlugin>
 
-class KstWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {
+class KstWidgets : public QObject, public QDesignerCustomWidgetCollectionInterface {
+  Q_OBJECT
+  Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
 public:
-  KstWidgetPlugin(QObject *parent = 0) : QObject(parent), _initialized(false) {}
-
-  QString group() const {
-    return tr("Kst Widgets");
+  KstWidgets(QObject *parent = 0);
+  virtual ~KstWidgets();
+  QList<QDesignerCustomWidgetInterface*> customWidgets() const {
+    return _plugins;
   }
-  QString toolTip() const {
-    return QString::null;
-  }
-  QString whatsThis() const {
-    return QString::null;
-  }
 
-  QString instanceName() const {
-    QChar camel = name().at(0).toLower();
-    return name().replace(0,1,camel.toLower());
-  }
+private:
+  QList<QDesignerCustomWidgetInterface*> _plugins;
+};
 
-  QString includeFile() const {
-    return name().replace("Kst::", "").toLower() + ".h";
-  }
+class KstWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface {
+public:
+  KstWidgetPlugin(QObject *parent = 0);
+  virtual ~KstWidgetPlugin();
 
-  QString domXml() const {
-    return QString::fromUtf8("<widget class=\"%1\" name=\"%2\"/>")
-           .arg(name()).arg(instanceName().toLower());
-  }
+  QString group() const;
+  QString toolTip() const;
+  QString whatsThis() const;
+  QString instanceName() const;
+  QString includeFile() const;
+  QString domXml() const;
+  bool isContainer() const;
+  bool isInitialized() const;
+  QIcon icon() const;
+  void initialize(QDesignerFormEditorInterface *);
 
-  bool isContainer() const {
-    return false;
-  }
-  bool isInitialized() const {
-    return _initialized;
-  }
-  QIcon icon() const {
-    return QIcon();
-  }
-
-  void initialize(QDesignerFormEditorInterface *) {
-    if (_initialized)
-      return;
-
-    _initialized = true;
-  }
-
 private:
   bool _initialized;
 };
 
-
 #include "colorbutton.h"
 class ColorButtonPlugin : public KstWidgetPlugin {
   Q_OBJECT
@@ -81,7 +65,6 @@
   }
 };
 
-
 #include "gradienteditor.h"
 class GradientEditorPlugin : public KstWidgetPlugin {
   Q_OBJECT
@@ -138,19 +121,62 @@
   }
 };
 
-class KstWidgets : public QObject, public QDesignerCustomWidgetCollectionInterface {
+#include "vectorselector.h"
+class VectorSelectorPlugin : public KstWidgetPlugin {
   Q_OBJECT
-  Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
+  Q_INTERFACES(QDesignerCustomWidgetInterface)
 public:
-  KstWidgets(QObject *parent = 0);
-  virtual ~KstWidgets() {}
-  QList<QDesignerCustomWidgetInterface*> customWidgets() const {
-    return _plugins;
+  VectorSelectorPlugin(QObject *parent = 0) : KstWidgetPlugin(parent) {}
+  QString name() const {
+    return QLatin1String("Kst::VectorSelector");
+  } //do not translate
+  QWidget *createWidget(QWidget *parent) {
+    return new Kst::VectorSelector(parent);
   }
+};
 
-private:
-  QList<QDesignerCustomWidgetInterface*> _plugins;
+#include "matrixselector.h"
+class MatrixSelectorPlugin : public KstWidgetPlugin {
+  Q_OBJECT
+  Q_INTERFACES(QDesignerCustomWidgetInterface)
+public:
+  MatrixSelectorPlugin(QObject *parent = 0) : KstWidgetPlugin(parent) {}
+  QString name() const {
+    return QLatin1String("Kst::MatrixSelector");
+  } //do not translate
+  QWidget *createWidget(QWidget *parent) {
+    return new Kst::MatrixSelector(parent);
+  }
 };
 
+#include "scalarselector.h"
+class ScalarSelectorPlugin : public KstWidgetPlugin {
+  Q_OBJECT
+  Q_INTERFACES(QDesignerCustomWidgetInterface)
+public:
+  ScalarSelectorPlugin(QObject *parent = 0) : KstWidgetPlugin(parent) {}
+  QString name() const {
+    return QLatin1String("Kst::ScalarSelector");
+  } //do not translate
+  QWidget *createWidget(QWidget *parent) {
+    return new Kst::ScalarSelector(parent);
+  }
+};
+
+#include "stringselector.h"
+class StringSelectorPlugin : public KstWidgetPlugin {
+  Q_OBJECT
+  Q_INTERFACES(QDesignerCustomWidgetInterface)
+public:
+  StringSelectorPlugin(QObject *parent = 0) : KstWidgetPlugin(parent) {}
+  QString name() const {
+    return QLatin1String("Kst::StringSelector");
+  } //do not translate
+  QWidget *createWidget(QWidget *parent) {
+    return new Kst::StringSelector(parent);
+  }
+};
+
 #endif
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/widgets/widgets.pro #717965:717966
@@ -1,6 +1,6 @@
 include($$PWD/../../kst.pri)
 
-QT += gui xml
+QT += gui xml qt3support
 
 TEMPLATE = lib
 CONFIG += designer plugin
@@ -25,7 +25,11 @@
     combobox.cpp \
     datarange.cpp \
     filerequester.cpp \
-    gradienteditor.cpp
+    gradienteditor.cpp \
+    matrixselector.cpp \
+    scalarselector.cpp \
+    stringselector.cpp \
+    vectorselector.cpp
 
 HEADERS += \
     colorbutton.h \
@@ -33,10 +37,18 @@
     datarange.h \
     filerequester.h \
     gradienteditor.h \
+    matrixselector.h \
+    scalarselector.h \
+    stringselector.h \
+    vectorselector.h \
     kstwidgets.h
 
 FORMS += \
     datarange.ui \
+    matrixselector.ui \
+    scalarselector.ui \
+    stringselector.ui \
+    vectorselector.ui
 
 RESOURCES += \
     $$TOPLEVELDIR/src/images/images.qrc


More information about the Kst mailing list