Browse Source

Fixes for theme code

tags/1.9.4
falkTX 12 years ago
parent
commit
2bdf032c24
6 changed files with 239 additions and 230 deletions
  1. +24
    -28
      source/backend/standalone/CarlaStandalone.cpp
  2. +150
    -122
      source/modules/theme/CarlaStyle.cpp
  3. +26
    -42
      source/modules/theme/CarlaStyle.hpp
  4. +6
    -7
      source/modules/theme/CarlaStyleAnimations.hpp
  5. +9
    -11
      source/modules/theme/CarlaStylePrivate.hpp
  6. +24
    -20
      source/modules/theme/Makefile

+ 24
- 28
source/backend/standalone/CarlaStandalone.cpp View File

@@ -25,11 +25,8 @@
#include "CarlaNative.h"

#include "CarlaLogThread.hpp"

#ifndef BUILD_BRIDGE
# include "CarlaStyle.hpp"
# include <QtCore/QSettings>
#endif
#include "CarlaStyle.hpp"
#include <QtCore/QSettings>

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
# include <QtWidgets/QApplication>
@@ -58,6 +55,7 @@ struct CarlaBackendStandalone {
EngineOptions options;

QApplication* app;
CarlaStyle* style;
bool needsInit;

LogThread logThread;
@@ -69,26 +67,7 @@ struct CarlaBackendStandalone {
app(qApp),
needsInit(app == nullptr)
{
#ifndef BUILD_BRIDGE
if (app != nullptr)
{
QSettings settings;

if (settings.value("Main/UseProTheme", true).toBool())
{
CarlaStyle* const style(new CarlaStyle());
app->setStyle(style);
style->ready(app);

QString color(settings.value("Main/ProThemeColor", "Black").toString());

if (color == "System")
pass(); //style->setColorScheme(CarlaStyle::COLOR_SYSTEM);
else
style->setColorScheme(CarlaStyle::COLOR_BLACK);
}
}
#endif
checkTheme();
}

~CarlaBackendStandalone()
@@ -109,14 +88,12 @@ struct CarlaBackendStandalone {
app = qApp;

if (app != nullptr)
{
needsInit = false;
return;
}

static int argc = 0;
static char** argv = nullptr;
app = new QApplication(argc, argv, true);
checkTheme();
}

void close()
@@ -128,10 +105,29 @@ struct CarlaBackendStandalone {

app->quit();
app->processEvents();

if (style != nullptr)
{
delete style;
style = nullptr;
}

delete app;
app = nullptr;
}

void checkTheme()
{
if (app == nullptr || style != nullptr)
return;

if (QSettings().value("Main/UseProTheme", true).toBool())
{
style = new CarlaStyle();
app->setStyle(style);
}
}

CARLA_DECLARE_NON_COPY_STRUCT(CarlaBackendStandalone)

} standalone;


+ 150
- 122
source/modules/theme/CarlaStyle.cpp View File

@@ -1,24 +1,24 @@
/*
* Carla Style, based on Qt5 fusion style
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.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 any later version.
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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.
* GNU Lesser General Public License for more details.
*
* For a full copy of the GNU General Public License see the GPL3.txt file
* For a full copy of the license see the doc/LGPL.txt file
*/

#include "CarlaStylePrivate.hpp"

#include <QtCore/qmath.h>
#include <QtCore/QSettings>
#include <QtCore/QStringBuilder>

#include <QtGui/QPainter>
@@ -524,67 +524,12 @@ CarlaStyle::CarlaStyle()
d(new CarlaStylePrivate(this))
{
setObjectName(QLatin1String("Carla"));
}

CarlaStyle::~CarlaStyle()
{
}

void CarlaStyle::setColorScheme(ColorScheme color)
{
switch (color)
{
case COLOR_BLACK:
qApp->setPalette(fPalBlack);
break;
case COLOR_BLUE:
qApp->setPalette(fPalBlue);
break;
case COLOR_SYSTEM:
qApp->setPalette(fPalSystem);
break;
}
}

void printPalette(const QPalette& pal)
{
#define PAL "fPalBlue"
QApplication* const app(qApp);

#define PAL_PRINT(ROLE) \
{ \
QColor color1(pal.color(QPalette::Disabled, ROLE)); \
QColor color2(pal.color(QPalette::Active, ROLE)); \
QColor color3(pal.color(QPalette::Inactive, ROLE)); \
printf(PAL ".setColor(QPalette::Disabled, " #ROLE ", QColor(%i, %i, %i));\n", color1.red(), color1.green(), color1.blue()); \
printf(PAL ".setColor(QPalette::Active, " #ROLE ", QColor(%i, %i, %i));\n", color2.red(), color2.green(), color2.blue()); \
printf(PAL ".setColor(QPalette::Inactive, " #ROLE ", QColor(%i, %i, %i));\n", color3.red(), color3.green(), color3.blue()); \
}

PAL_PRINT(QPalette::Window)
PAL_PRINT(QPalette::WindowText)
PAL_PRINT(QPalette::Base)
PAL_PRINT(QPalette::AlternateBase)
PAL_PRINT(QPalette::ToolTipBase)
PAL_PRINT(QPalette::ToolTipText)
PAL_PRINT(QPalette::Text)
PAL_PRINT(QPalette::Button)
PAL_PRINT(QPalette::ButtonText)
PAL_PRINT(QPalette::BrightText)
PAL_PRINT(QPalette::Light)
PAL_PRINT(QPalette::Midlight)
PAL_PRINT(QPalette::Dark)
PAL_PRINT(QPalette::Mid)
PAL_PRINT(QPalette::Shadow)
PAL_PRINT(QPalette::Highlight)
PAL_PRINT(QPalette::HighlightedText)
PAL_PRINT(QPalette::Link)
PAL_PRINT(QPalette::LinkVisited)

#undef PAL
}
if (app == nullptr)
return;

void CarlaStyle::ready(QApplication* app)
{
fPalSystem = app->palette();

fPalBlack.setColor(QPalette::Disabled, QPalette::Window, QColor(14, 14, 14));
@@ -702,6 +647,83 @@ void CarlaStyle::ready(QApplication* app)
fPalBlue.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(51, 74, 118));
fPalBlue.setColor(QPalette::Active, QPalette::LinkVisited, QColor(64, 128, 255));
fPalBlue.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(64, 128, 255));

setColorSchemeAsNeeded();
}

CarlaStyle::~CarlaStyle()
{
delete d;
}

void CarlaStyle::setColorSchemeAsNeeded()
{
QSettings settings("falkTX", "Carla");

if (! settings.value("Main/UseProTheme", true).toBool())
return;

QString color(settings.value("Main/ProThemeColor", "Black").toString());

if (color == "System")
setColorScheme(CarlaStyle::COLOR_SYSTEM);
else if (color == "Blue")
setColorScheme(CarlaStyle::COLOR_BLUE);
else
setColorScheme(CarlaStyle::COLOR_BLACK);
}

void CarlaStyle::setColorScheme(ColorScheme color)
{
switch (color)
{
case COLOR_BLACK:
qApp->setPalette(fPalBlack);
break;
case COLOR_BLUE:
qApp->setPalette(fPalBlue);
break;
case COLOR_SYSTEM:
qApp->setPalette(fPalSystem);
break;
}
}

void printPalette(const QPalette& pal)
{
#define PAL "fPalBlue"

#define PAL_PRINT(ROLE) \
{ \
QColor color1(pal.color(QPalette::Disabled, ROLE)); \
QColor color2(pal.color(QPalette::Active, ROLE)); \
QColor color3(pal.color(QPalette::Inactive, ROLE)); \
printf(PAL ".setColor(QPalette::Disabled, " #ROLE ", QColor(%i, %i, %i));\n", color1.red(), color1.green(), color1.blue()); \
printf(PAL ".setColor(QPalette::Active, " #ROLE ", QColor(%i, %i, %i));\n", color2.red(), color2.green(), color2.blue()); \
printf(PAL ".setColor(QPalette::Inactive, " #ROLE ", QColor(%i, %i, %i));\n", color3.red(), color3.green(), color3.blue()); \
}

PAL_PRINT(QPalette::Window)
PAL_PRINT(QPalette::WindowText)
PAL_PRINT(QPalette::Base)
PAL_PRINT(QPalette::AlternateBase)
PAL_PRINT(QPalette::ToolTipBase)
PAL_PRINT(QPalette::ToolTipText)
PAL_PRINT(QPalette::Text)
PAL_PRINT(QPalette::Button)
PAL_PRINT(QPalette::ButtonText)
PAL_PRINT(QPalette::BrightText)
PAL_PRINT(QPalette::Light)
PAL_PRINT(QPalette::Midlight)
PAL_PRINT(QPalette::Dark)
PAL_PRINT(QPalette::Mid)
PAL_PRINT(QPalette::Shadow)
PAL_PRINT(QPalette::Highlight)
PAL_PRINT(QPalette::HighlightedText)
PAL_PRINT(QPalette::Link)
PAL_PRINT(QPalette::LinkVisited)

#undef PAL
}

/*!
@@ -1213,15 +1235,13 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
r = rect.adjusted(0, 1, -1, 0);

bool isEnabled = option->state & State_Enabled;
bool hasFocus = (option->state & State_HasFocus && option->state & State_KeyboardFocusChange);
QColor buttonColor = d->buttonColor(option->palette);
QColor darkOutline = outline;

#if 0
bool hasFocus = (option->state & State_HasFocus && option->state & State_KeyboardFocusChange);
if (hasFocus | isDefault) {
QColor darkOutline = outline;
if (hasFocus || isDefault) {
darkOutline = highlightedOutline;
}
#endif

if (isDefault)
buttonColor = mergedColors(buttonColor, highlightedOutline.lighter(130), 90);
@@ -1408,7 +1428,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
case CE_ToolBar:
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
// Reserve the beveled appearance only for mainwindow toolbars
if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
if (widget && !(qobject_cast<const QMainWindow*> (widget->parentWidget())))
break;

// Draws the light line above and the dark line below menu bars and
@@ -1541,6 +1561,10 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
- titleRect.bottom(),
r.top() + titleRect.left() - rect.left(),
titleRect.height(), titleRect.width());

painter->translate(r.left(), r.top() + r.width());
painter->rotate(-90);
painter->translate(-r.left(), -r.top());
}

if (!dwOpt->title.isEmpty()) {
@@ -2004,7 +2028,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
int dim = (menuItem->rect.height() - 4) / 2;
PrimitiveElement arrow;
arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
arrow = option->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim;
QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
@@ -3113,53 +3137,6 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
painter->restore();
}

// draw handle
if ((option->subControls & SC_SliderHandle) ) {
QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());
if (!QPixmapCache::find(handlePixmapName, cache)) {
cache = styleCachePixmap(handle.size());
cache.fill(Qt::transparent);
QRect pixmapRect(0, 0, handle.width(), handle.height());
QPainter handlePainter(&cache);
QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2);

// gradient fill
QRect r = pixmapRect.adjusted(1, 1, -2, -2);
QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft);

handlePainter.setRenderHint(QPainter::Antialiasing, true);
handlePainter.translate(0.5, 0.5);

handlePainter.setPen(Qt::NoPen);
handlePainter.setBrush(QColor(0, 0, 0, 40));
handlePainter.drawRect(r.adjusted(-1, 2, 1, -2));

handlePainter.setPen(QPen(d->outline(option->palette), 1));
if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
handlePainter.setPen(QPen(d->highlightedOutline(option->palette), 1));

handlePainter.setBrush(gradient);
handlePainter.drawRoundedRect(r, 2, 2);
handlePainter.setBrush(Qt::NoBrush);
handlePainter.setPen(d->innerContrastLine());
handlePainter.drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2);

QColor cornerAlpha = outline.darker(120);
cornerAlpha.setAlpha(80);

//handle shadow
handlePainter.setPen(shadowAlpha);
handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1));
handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4));
handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2));

handlePainter.end();
QPixmapCache::insert(handlePixmapName, cache);
}

painter->drawPixmap(handle.topLeft(), cache);

}
if (option->subControls & SC_SliderTickmarks) {
painter->setPen(outline);
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
@@ -3215,6 +3192,54 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
v = nextInterval;
}
}

// draw handle
if ((option->subControls & SC_SliderHandle) ) {
QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());
if (!QPixmapCache::find(handlePixmapName, cache)) {
cache = styleCachePixmap(handle.size());
cache.fill(Qt::transparent);
QRect pixmapRect(0, 0, handle.width(), handle.height());
QPainter handlePainter(&cache);
QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2);

// gradient fill
QRect r = pixmapRect.adjusted(1, 1, -2, -2);
QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft);

handlePainter.setRenderHint(QPainter::Antialiasing, true);
handlePainter.translate(0.5, 0.5);

handlePainter.setPen(Qt::NoPen);
handlePainter.setBrush(QColor(0, 0, 0, 40));
handlePainter.drawRect(r.adjusted(-1, 2, 1, -2));

handlePainter.setPen(QPen(d->outline(option->palette), 1));
if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
handlePainter.setPen(QPen(d->highlightedOutline(option->palette), 1));

handlePainter.setBrush(gradient);
handlePainter.drawRoundedRect(r, 2, 2);
handlePainter.setBrush(Qt::NoBrush);
handlePainter.setPen(d->innerContrastLine());
handlePainter.drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2);

QColor cornerAlpha = outline.darker(120);
cornerAlpha.setAlpha(80);

//handle shadow
handlePainter.setPen(shadowAlpha);
handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1));
handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4));
handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2));

handlePainter.end();
QPixmapCache::insert(handlePixmapName, cache);
}

painter->drawPixmap(handle.topLeft(), cache);
}

painter->setBrush(oldBrush);
painter->setPen(oldPen);
}
@@ -3236,6 +3261,8 @@ int CarlaStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, cons
{
switch (metric)
{
case PM_SliderTickmarkOffset:
return 4;
case PM_HeaderMargin:
return 2;
case PM_ToolTipLabelFrameWidth:
@@ -3335,9 +3362,9 @@ QSize CarlaStyle::sizeFromContents(ContentsType type, const QStyleOption* option
case CT_PushButton:
if (const QStyleOptionButton* btn = qstyleoption_cast<const QStyleOptionButton *>(option))
{
if (newSize.width() < 80 && ! btn->text.isEmpty())
if (!btn->text.isEmpty() && newSize.width() < 80)
newSize.setWidth(80);
if (btn->iconSize.height() > 16 && ! btn->icon.isNull())
if (!btn->icon.isNull() && btn->iconSize.height() > 16)
newSize -= QSize(0, 2);
}
break;
@@ -3834,6 +3861,9 @@ QRect CarlaStyle::subElementRect(SubElement sr, const QStyleOption *opt, const Q
return r;
}

#ifdef CARLA_EXPORT_STYLE
# include "resources.cpp"

CarlaStylePlugin::CarlaStylePlugin(QObject* parent)
: QStylePlugin(parent)
{
@@ -3849,7 +3879,5 @@ QStringList CarlaStylePlugin::keys() const
return QStringList() << "Carla";
}

#ifdef CARLA_EXPORT_STYLE
# include "resources.cpp"
Q_EXPORT_PLUGIN2(Carla, CarlaStylePlugin)
#endif

+ 26
- 42
source/modules/theme/CarlaStyle.hpp View File

@@ -1,19 +1,18 @@
/*
* Carla Style, based on Qt5 fusion style
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.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 any later version.
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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.
* GNU Lesser General Public License for more details.
*
* For a full copy of the GNU General Public License see the GPL3.txt file
* For a full copy of the license see the doc/LGPL.txt file
*/

#ifndef CARLA_STYLE_HPP_INCLUDED
@@ -21,7 +20,7 @@

#include "CarlaDefines.hpp"

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

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
# include <QtWidgets/QCommonStyle>
@@ -36,39 +35,34 @@ class CarlaStyle : public QCommonStyle
Q_OBJECT

public:
CarlaStyle();
~CarlaStyle();

enum ColorScheme {
COLOR_BLACK = 0,
COLOR_BLUE = 1,
COLOR_SYSTEM = 2
};

void ready(QApplication* app);
CarlaStyle();
~CarlaStyle();

void setColorSchemeAsNeeded();
void setColorScheme(ColorScheme color);

QPalette standardPalette() const;
void drawPrimitive(PrimitiveElement elem,
const QStyleOption *option,
QPainter *painter, const QWidget *widget = 0) const;
void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter,
const QWidget *widget) const;
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
QPainter *painter, const QWidget *widget) const;
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
const QSize &size, const QWidget *widget) const;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
SubControl sc, const QWidget *widget) const;
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
QStyleHintReturn *returnData = 0) const;
void drawItemText(QPainter *painter, const QRect &rect,
int flags, const QPalette &pal, bool enabled,
const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
void polish(QWidget *widget);
void unpolish(QWidget *widget);
QPalette standardPalette() const override;
void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter,
const QWidget* widget = nullptr) const override;
void drawControl(ControlElement ce, const QStyleOption* option, QPainter* painter, const QWidget* widget) const override;
int pixelMetric(PixelMetric metric, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter,
const QWidget* widget) const override;
QRect subElementRect(SubElement r, const QStyleOption* opt, const QWidget* widget = nullptr) const override;
QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget) const override;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const override;
int styleHint(StyleHint hint, const QStyleOption* option = nullptr, const QWidget* widget = nullptr,
QStyleHintReturn* returnData = nullptr) const override;
void drawItemText(QPainter *painter, const QRect& rect, int flags, const QPalette& pal, bool enabled, const QString& text,
QPalette::ColorRole textRole = QPalette::NoRole) const override;
void polish(QWidget* widget) override;
void unpolish(QWidget* widget) override;

private:
QPalette fPalBlack;
@@ -79,14 +73,4 @@ 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_INCLUDED

+ 6
- 7
source/modules/theme/CarlaStyleAnimations.hpp View File

@@ -1,19 +1,18 @@
/*
* Carla Style, based on Qt5 fusion style
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.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 any later version.
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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.
* GNU Lesser General Public License for more details.
*
* For a full copy of the GNU General Public License see the GPL3.txt file
* For a full copy of the license see the doc/LGPL.txt file
*/

#ifndef CARLA_STYLE_ANIMATIONS_HPP_INCLUDED
@@ -162,7 +161,7 @@ public:
}

protected:
bool isUpdateNeeded() const
bool isUpdateNeeded() const override
{
if (CarlaStyleAnimation::isUpdateNeeded())
{


+ 9
- 11
source/modules/theme/CarlaStylePrivate.hpp View File

@@ -1,19 +1,18 @@
/*
* Carla Style, based on Qt5 fusion style
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.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 any later version.
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation.
*
* 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.
* GNU Lesser General Public License for more details.
*
* For a full copy of the GNU General Public License see the GPL3.txt file
* For a full copy of the license see the doc/LGPL.txt file
*/

#ifndef CARLA_STYLE_PRIVATE_HPP_INCLUDED
@@ -39,7 +38,7 @@ public:
};

CarlaStylePrivate(CarlaStyle* const style)
: kStyle(style),
: fStyle(style),
fAnimationFps(60)
{
}
@@ -131,7 +130,7 @@ public:
void startAnimation(CarlaStyleAnimation* animation) const
{
stopAnimation(animation->target());
kStyle->connect(animation, SIGNAL(destroyed()), SLOT(_removeAnimation()), Qt::UniqueConnection);
fStyle->connect(animation, SIGNAL(destroyed()), SLOT(_removeAnimation()), Qt::UniqueConnection);
fAnimations.insert(animation->target(), animation);
animation->start();
}
@@ -144,15 +143,14 @@ public:
}

private:
CarlaStyle* const kStyle;
CarlaStyle* const fStyle;
int fAnimationFps;
mutable QHash<const QObject*, CarlaStyleAnimation*> fAnimations;

private slots:
void _removeAnimation()
{
QObject* animation = kStyle->sender();
if (animation != nullptr)
if (QObject* animation = fStyle->sender())
fAnimations.remove(animation->parent());
}
};


+ 24
- 20
source/modules/theme/Makefile View File

@@ -14,9 +14,11 @@ QT5_CXX_FLAGS = $(BUILD_CXX_FLAGS) # FIXME: use copy instead of reference
ifeq ($(HAVE_QT4),true)
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore QtGui)
LINK_FLAGS += $(shell pkg-config --libs QtCore QtGui)
QT_STYLES_DIR = $(shell pkg-config --variable=libdir QtCore)/qt4/plugins/styles
else
BUILD_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)
LINK_FLAGS += $(shell pkg-config --libs Qt5Core Qt5Gui Qt5Widgets)
QT_STYLES_DIR = $(shell pkg-config --variable=libdir Qt5Core)/qt5/plugins/styles
endif

ifeq ($(HAVE_QT5),true)
@@ -27,50 +29,51 @@ endif

FILES = \
moc_CarlaStyle.cpp \
moc_CarlaStylePrivate.cpp \
moc_CarlaStyleAnimations.cpp \
moc_CarlaStylePlugin.cpp \
moc_CarlaStylePrivate.cpp \
resources.cpp

OBJS = \
CarlaStyle.cpp.o \
moc_CarlaStyle.cpp.o \
moc_CarlaStyleAnimations.cpp.o \
moc_CarlaStylePlugin.cpp.o \
moc_CarlaStylePrivate.cpp.o

OBJS_static = $(OBJS) \
CarlaStyle.cpp.o

OBJS_shared = $(OBJS) \
CarlaStyle.cpp.export.o
CarlaStylePlugin.cpp.o \
resources.cpp.o

OBJS_qt5 = \
CarlaStyle.cpp.qt5.o \
moc_CarlaStyle.cpp.qt5.o \
moc_CarlaStyleAnimations.cpp.qt5.o \
moc_CarlaStylePrivate.cpp.qt5.o \
CarlaStyle.cpp.qt5.o
moc_CarlaStylePrivate.cpp.qt5.o

OBJS_posix32 = \
CarlaStyle.cpp.posix32.o \
moc_CarlaStyle.cpp.posix32.o \
moc_CarlaStyleAnimations.cpp.posix32.o \
moc_CarlaStylePrivate.cpp.posix32.o \
CarlaStyle.cpp.posix32.o
moc_CarlaStylePrivate.cpp.posix32.o

OBJS_posix64 = \
CarlaStyle.cpp.posix64.o \
moc_CarlaStyle.cpp.posix64.o \
moc_CarlaStyleAnimations.cpp.posix64.o \
moc_CarlaStylePrivate.cpp.posix64.o \
CarlaStyle.cpp.posix64.o
moc_CarlaStylePrivate.cpp.posix64.o

OBJS_win32 = \
CarlaStyle.cpp.win32.o \
moc_CarlaStyle.cpp.win32.o \
moc_CarlaStyleAnimations.cpp.win32.o \
moc_CarlaStylePrivate.cpp.win32.o \
CarlaStyle.cpp.win32.o
moc_CarlaStylePrivate.cpp.win32.o

OBJS_win64 = \
CarlaStyle.cpp.win64.o \
moc_CarlaStyle.cpp.win64.o \
moc_CarlaStyleAnimations.cpp.win64.o \
moc_CarlaStylePrivate.cpp.win64.o \
CarlaStyle.cpp.win64.o
moc_CarlaStylePrivate.cpp.win64.o

# --------------------------------------------------------------

@@ -84,8 +87,8 @@ win64: ../theme.win64.a

# --------------------------------------------------------------

../theme.a: $(FILES) $(OBJS_static)
$(AR) rs $@ $(OBJS_static)
../theme.a: $(FILES) $(OBJS)
$(AR) rs $@ $(OBJS)

../theme.qt5.a: $(FILES) $(OBJS_qt5)
$(AR) rs $@ $(OBJS_qt5)
@@ -119,9 +122,6 @@ win64: ../theme.win64.a
%.cpp.qt5.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(QT5_CXX_FLAGS) -c -o $@

%.cpp.export.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_EXPORT_STYLE -c -o $@

%.cpp.posix32.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@

@@ -142,6 +142,10 @@ resources.cpp: ../../../resources/resources-theme.qrc

# --------------------------------------------------------------

install: ../carlastyle.so
install -d $(QT_STYLES_DIR)
install -m 644 $< $(QT_STYLES_DIR)

clean:
rm -f *.o ../theme.* $(FILES)



Loading…
Cancel
Save