summaryrefslogtreecommitdiffstats
path: root/sigmodr/corewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/corewidgets')
-rw-r--r--sigmodr/corewidgets/CMakeLists.txt103
-rw-r--r--sigmodr/corewidgets/FractionWidget_p.h62
-rw-r--r--sigmodr/corewidgets/Global.h37
-rw-r--r--sigmodr/corewidgets/ScriptWidget_p.h74
-rw-r--r--sigmodr/corewidgets/widgetsui.qrc7
5 files changed, 283 insertions, 0 deletions
diff --git a/sigmodr/corewidgets/CMakeLists.txt b/sigmodr/corewidgets/CMakeLists.txt
new file mode 100644
index 00000000..330a71d5
--- /dev/null
+++ b/sigmodr/corewidgets/CMakeLists.txt
@@ -0,0 +1,103 @@
+project(sigmodrcorewidgets)
+
+include_directories(
+ ${PROJECT_BINARY_DIR}
+)
+
+### FIXME: makekdewidgest4 is busted for uppercase includes and namespaced widgets
+# Upstream bug report: <https://bugs.kde.org/show_bug.cgi?id=185554>
+# set(sigmodrcorewidgets_WIDGETS
+# sigmodr.widgets
+# )
+# kde4_add_widget_files(sigmodrcorewidgets_WIDGET_SRCS ${sigmodrcorewidgets_WIDGETS})
+set(sigmodrcorewidgets_WIDGET_SRCS
+ sigmodrwidgets.cpp
+)
+###
+set(sigmodrcorewidgets_RESOURCES
+ widgetsui.qrc
+)
+qt4_add_resources(sigmodrcorewidgets_RESOURCE_SRCS ${sigmodrcorewidgets_RESOURCES})
+set(sigmodrcorewidgets_HEADERS
+ FractionWidget.h
+ ScriptWidget.h
+)
+set(sigmodrcorewidgets_SRCS
+ FractionWidget.cpp
+ ScriptWidget.cpp
+)
+
+kde4_add_library(sigmodrcorewidgets
+ SHARED
+ ${sigmodrcorewidgets_RESOURCE_SRCS}
+ ${sigmodrcorewidgets_SRCS}
+)
+set_target_properties(sigmodrcorewidgets
+ PROPERTIES
+ VERSION ${SIGEN_VERSION}
+ SOVERSION ${SIGEN_SOVERSION}
+)
+target_link_libraries(sigmodrcorewidgets
+ ${QT_QTCORE_LIBRARY}
+ ${QT_QTGUI_LIBRARY}
+ ${QT_QTUITOOLS_LIBRARY}
+ ${KDE4_KDEUI_LIBRARY}
+ ${KDE4_KTEXTEDITOR_LIBRARY}
+ sigcore
+)
+target_link_libraries(sigmodrcorewidgets LINK_INTERFACE_LIBRARIES
+ ${QT_QTGUI_LIBRARY}
+ sigcore
+)
+
+kde4_add_plugin(sigmodrcorewidgetsplugin
+ ${sigmodrcorewidgets_WIDGET_SRCS}
+)
+set_target_properties(sigmodrcorewidgetsplugin
+ PROPERTIES
+ VERSION ${SIGEN_VERSION}
+ SOVERSION ${SIGEN_SOVERSION}
+)
+target_link_libraries(sigmodrcorewidgetsplugin
+ ${QT_QTCORE_LIBRARY}
+ ${QT_QTGUI_LIBRARY}
+ ${KDE4_KDEUI_LIBRARY}
+ ${PHONON_LIBRARY}
+ sigmodrcorewidgets
+)
+target_link_libraries(sigmodrcorewidgetsplugin LINK_INTERFACE_LIBRARIES
+ ${QT_QTGUI_LIBRARY}
+ ${PHONON_LIBRARY}
+ sigmodrcorewidgets
+)
+
+install(
+ TARGETS
+ sigmodrcorewidgets
+ EXPORT
+ sigen_EXPORTS
+ DESTINATION
+ ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
+ COMPONENT
+ runtime
+)
+
+install(
+ FILES
+ ${sigmodrcorewidgets_HEADERS}
+ DESTINATION
+ ${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}/sigmodr/corewidgets
+ COMPONENT
+ development
+)
+
+install(
+ TARGETS
+ sigmodrcorewidgetsplugin
+ EXPORT
+ sigen_EXPORTS
+ DESTINATION
+ ${PLUGIN_INSTALL_DIR}/plugins/designer
+ COMPONENT
+ runtime
+)
diff --git a/sigmodr/corewidgets/FractionWidget_p.h b/sigmodr/corewidgets/FractionWidget_p.h
new file mode 100644
index 00000000..ef267c76
--- /dev/null
+++ b/sigmodr/corewidgets/FractionWidget_p.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SIGMODRCOREWIDGETS_FRACTIONWIDGET_P
+#define SIGMODRCOREWIDGETS_FRACTIONWIDGET_P
+
+// Sigcore includes
+#include <sigcore/Fraction.h>
+
+// Qt includes
+#include <QtCore/QObject>
+
+// Forward declarations
+class KIntNumInput;
+class KLineEdit;
+
+namespace Sigmodr
+{
+namespace CoreWidgets
+{
+class FractionWidget::Private : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Private(QObject* parent, const Sigcore::Fraction& value);
+
+ QWidget* makeWidgets(FractionWidget* widget);
+
+ Sigcore::Fraction m_value;
+ FractionWidget::Behavior m_behavior;
+ signals:
+ void valueChanged(const Sigcore::Fraction& value);
+ protected slots:
+ void numeratorChanged(const int numerator);
+ void denominatorChanged(const int denominator);
+
+ void updateValue();
+ void resetRanges();
+ private:
+ KIntNumInput* ui_numerator;
+ KIntNumInput* ui_denominator;
+ KLineEdit* ui_value;
+};
+}
+}
+
+#endif
diff --git a/sigmodr/corewidgets/Global.h b/sigmodr/corewidgets/Global.h
new file mode 100644
index 00000000..4a0dce40
--- /dev/null
+++ b/sigmodr/corewidgets/Global.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SIGMODRCOREWIDGETS_GLOBAL
+#define SIGMODRCOREWIDGETS_GLOBAL
+
+// KDE includes
+#include <kdemacros.h>
+
+#ifndef SIGMODRCOREWIDGETS_EXPORT
+# ifdef MAKE_SIGMODRCOREWIDGETS_LIB
+# define SIGMODRCOREWIDGETS_EXPORT KDE_EXPORT
+# else
+# define SIGMODRCOREWIDGETS_EXPORT KDE_IMPORT
+# endif
+# define SIGMODRCOREWIDGETS_IMPORT KDE_IMPORT
+#endif
+
+#ifndef SIGMODRCOREWIDGETS_EXPORT_DEPRECATED
+# define SIGMODRCOREWIDGETS_EXPORT_DEPRECATED KDE_DEPRECATED SIGMODRCOREWIDGETS_EXPORT
+#endif
+
+#endif
diff --git a/sigmodr/corewidgets/ScriptWidget_p.h b/sigmodr/corewidgets/ScriptWidget_p.h
new file mode 100644
index 00000000..612066fb
--- /dev/null
+++ b/sigmodr/corewidgets/ScriptWidget_p.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SIGMODRCOREWIDGETS_SCRIPTWIDGET_P
+#define SIGMODRCOREWIDGETS_SCRIPTWIDGET_P
+
+// Sigcore includes
+#include <sigcore/Script.h>
+
+// Qt includes
+#include <QtCore/QMap>
+#include <QtCore/QObject>
+
+// Forward declarations
+class KComboBox;
+class KTextEdit;
+namespace KTextEditor
+{
+class Document;
+class Editor;
+class View;
+}
+
+namespace Sigmodr
+{
+namespace CoreWidgets
+{
+class ScriptWidget::Private : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Private(QObject* parent, const Sigcore::Script& value);
+ ~Private();
+
+ QWidget* makeWidgets(ScriptWidget* widget);
+
+ Sigcore::Script m_value;
+ signals:
+ void valueChanged(const Sigcore::Script& value);
+ protected slots:
+ void interpreterChanged(const QString& interpreter);
+ void scriptChanged();
+
+ void focused(KTextEditor::View* view);
+ void unfocused(KTextEditor::View* view);
+ void setGui();
+ private:
+ static QMap<QString, QString> m_languages;
+
+ KComboBox* ui_interpreter;
+ KTextEdit* ui_simpleEdit;
+ KTextEditor::View* ui_kteEdit;
+ KTextEditor::Editor* m_editor;
+ KTextEditor::Document* m_document;
+};
+}
+}
+
+#endif
diff --git a/sigmodr/corewidgets/widgetsui.qrc b/sigmodr/corewidgets/widgetsui.qrc
new file mode 100644
index 00000000..542712ca
--- /dev/null
+++ b/sigmodr/corewidgets/widgetsui.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource prefix="/gui">
+ <file>fraction.ui</file>
+ <file>script.ui</file>
+ </qresource>
+</RCC>