diff --git a/source/theme/CarlaStyle.cpp b/source/theme/CarlaStyle.cpp index e635ba200..9f27f6c0f 100644 --- a/source/theme/CarlaStyle.cpp +++ b/source/theme/CarlaStyle.cpp @@ -51,10 +51,6 @@ # include #endif -#ifdef CARLA_EXPORT_STYLE -# include -#endif - #define BEGIN_STYLE_PIXMAPCACHE(a) \ QRect rect = option->rect; \ QPixmap internalPixmapCache; \ @@ -3838,28 +3834,22 @@ QRect CarlaStyle::subElementRect(SubElement sr, const QStyleOption *opt, const Q return r; } -#ifdef CARLA_EXPORT_STYLE -# include "resources.cpp" - -class CarlaStylePlugin : public QStylePlugin +CarlaStylePlugin::CarlaStylePlugin(QObject* parent) + : QStylePlugin(parent) { - Q_OBJECT - -public: - CarlaStylePlugin(QObject* parent = nullptr) - : QStylePlugin(parent) {} +} - QStyle* create(const QString& key) - { - return (key.toLower() == "Carla") ? new CarlaStyle() : nullptr; - } +QStyle* CarlaStylePlugin::create(const QString& key) +{ + return (key.toLower() == "carla") ? new CarlaStyle() : nullptr; +} - QStringList keys() const - { - return QStringList() << "Carla"; - } -}; +QStringList CarlaStylePlugin::keys() const +{ + return QStringList() << "Carla"; +} +#ifdef CARLA_EXPORT_STYLE +# include "resources.cpp" Q_EXPORT_PLUGIN2(Carla, CarlaStylePlugin) - #endif diff --git a/source/theme/CarlaStyle.hpp b/source/theme/CarlaStyle.hpp index bb58245f7..3e85dc7c0 100644 --- a/source/theme/CarlaStyle.hpp +++ b/source/theme/CarlaStyle.hpp @@ -19,7 +19,7 @@ #ifndef __CARLA_STYLE_HPP__ #define __CARLA_STYLE_HPP__ -#include +#include #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) # include @@ -77,4 +77,14 @@ private: friend class CarlaStylePrivate; }; +class CarlaStylePlugin : public QStylePlugin +{ + Q_OBJECT + +public: + CarlaStylePlugin(QObject* parent = nullptr); + QStyle* create(const QString& key); + QStringList keys() const; +}; + #endif // __CARLA_STYLE_HPP__ diff --git a/source/theme/Makefile b/source/theme/Makefile index 550fcc118..c6002eb01 100644 --- a/source/theme/Makefile +++ b/source/theme/Makefile @@ -25,33 +25,49 @@ FILES = \ resources.cpp OBJS = \ - CarlaStyle.cpp.o \ moc_CarlaStyle.cpp.o \ moc_CarlaStyleAnimations.cpp.o \ moc_CarlaStylePrivate.cpp.o -TARGET = ../libs/theme.a +OBJS_shared = $(OBJS) \ + CarlaStyle.export.cpp.o + +OBJS_static = $(OBJS) \ + CarlaStyle.cpp.o + +SHARED = carlastyle.so +STATIC = ../libs/theme.a # -------------------------------------------------------------- -all: $(TARGET) +all: $(STATIC) clean: - rm -f $(FILES) $(OBJS) $(TARGET) + rm -f $(FILES) $(OBJS_shared) $(OBJS_static) $(SHARED) $(STATIC) debug: $(MAKE) DEBUG=true +install: $(SHARED) + # FIXME - find a way to get a proper install path + install -m 644 $(SHARED) /usr/lib/x86_64-linux-gnu/qt4/plugins/styles/ + # -------------------------------------------------------------- -$(TARGET): $(FILES) $(OBJS) - $(AR) rs $@ $(OBJS) +$(SHARED): $(FILES) $(OBJS_shared) + $(CXX) $(OBJS_shared) $(LINK_FLAGS) -shared -o $@ && $(STRIP) $@ + +$(STATIC): $(FILES) $(OBJS_static) + $(AR) rs $@ $(OBJS_static) # -------------------------------------------------------------- %.cpp.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ +%.export.cpp.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp + $(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_EXPORT_STYLE -c -o $@ + moc_%.cpp: %.hpp $(MOC) $< -o $@