Browse Source

Make it possible to install and use the theme system-wide

tags/1.9.4
falkTX 11 years ago
parent
commit
91ea98f225
3 changed files with 46 additions and 30 deletions
  1. +13
    -23
      source/theme/CarlaStyle.cpp
  2. +11
    -1
      source/theme/CarlaStyle.hpp
  3. +22
    -6
      source/theme/Makefile

+ 13
- 23
source/theme/CarlaStyle.cpp View File

@@ -51,10 +51,6 @@
# include <QtGui/QWizard>
#endif

#ifdef CARLA_EXPORT_STYLE
# include <QtGui/QStylePlugin>
#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

+ 11
- 1
source/theme/CarlaStyle.hpp View File

@@ -19,7 +19,7 @@
#ifndef __CARLA_STYLE_HPP__
#define __CARLA_STYLE_HPP__

#include <QtCore/Qt>
#include <QtGui/QStylePlugin>

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
# include <QtWidgets/QCommonStyle>
@@ -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__

+ 22
- 6
source/theme/Makefile View File

@@ -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 $@



Loading…
Cancel
Save