Browse Source

Update the style/theme code to work with Qt5

tags/1.9.4
falkTX 11 years ago
parent
commit
df299c7cbd
14 changed files with 319 additions and 118 deletions
  1. +3
    -0
      Makefile
  2. +6
    -10
      source/Makefile.mk
  3. +1
    -5
      source/carla-mini
  4. +1
    -5
      source/carla-plugin
  5. +7
    -7
      source/carla_host.py
  6. +212
    -0
      source/carla_style.py
  7. +1
    -1
      source/carla_widgets.py
  8. +3
    -0
      source/modules/carla_native/vex.cpp
  9. +3
    -41
      source/modules/theme/CarlaStyle.cpp
  10. +0
    -7
      source/modules/theme/CarlaStyle.hpp
  11. +8
    -5
      source/modules/theme/CarlaStylePlugin.cpp
  12. +7
    -2
      source/modules/theme/CarlaStylePlugin.hpp
  13. +66
    -35
      source/modules/theme/Makefile
  14. +1
    -0
      source/modules/theme/styles/carlastyle.json

+ 3
- 0
Makefile View File

@@ -44,6 +44,9 @@ discovery:
plugin: plugin:
$(MAKE) -C source/plugin $(MAKE) -C source/plugin


theme:
$(MAKE) -C source/modules/theme

posix32: posix32:
$(MAKE) -C source/bridges posix32 $(MAKE) -C source/bridges posix32
$(MAKE) -C source/discovery posix32 $(MAKE) -C source/discovery posix32


+ 6
- 10
source/Makefile.mk View File

@@ -25,6 +25,9 @@ CARLA_VESTIGE_HEADER = true
AR ?= ar AR ?= ar
CC ?= gcc CC ?= gcc
CXX ?= g++ CXX ?= g++
MOC ?= moc
RCC ?= rcc
UIC ?= uic


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


@@ -82,17 +85,10 @@ HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true) HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
endif endif


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

# TODO - move this to theme
ifeq ($(HAVE_QT4),true) ifeq ($(HAVE_QT4),true)
MOC ?= $(shell pkg-config --variable=moc_location QtCore)
RCC ?= $(shell pkg-config --variable=rcc_location QtCore)
UIC ?= $(shell pkg-config --variable=uic_location QtCore)
else
MOC ?= moc
RCC ?= rcc
UIC ?= uic
MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
endif endif


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

+ 1
- 5
source/carla-mini View File

@@ -41,11 +41,7 @@ if __name__ == '__main__':
# ------------------------------------------------------------- # -------------------------------------------------------------
# App initialization # App initialization


app = QApplication(sys.argv)
app.setApplicationName("Carla")
app.setApplicationVersion(VERSION)
app.setOrganizationName("falkTX")
app.setWindowIcon(QIcon(":/scalable/carla.svg"))
app = CarlaApplication()


# ------------------------------------------------------------- # -------------------------------------------------------------
# Set-up custom signal handling # Set-up custom signal handling


+ 1
- 5
source/carla-plugin View File

@@ -331,11 +331,7 @@ if __name__ == '__main__':
# ------------------------------------------------------------- # -------------------------------------------------------------
# App initialization # App initialization


app = QApplication(sys.argv)
app.setApplicationName("Carla")
app.setApplicationVersion(VERSION)
app.setOrganizationName("falkTX")
app.setWindowIcon(QIcon(":/scalable/carla.svg"))
app = CarlaApplication()


# ------------------------------------------------------------- # -------------------------------------------------------------
# Set-up custom signal handling # Set-up custom signal handling


+ 7
- 7
source/carla_host.py View File

@@ -21,10 +21,11 @@


try: try:
from PyQt5.QtCore import QTimer from PyQt5.QtCore import QTimer
from PyQt5.QtGui import QPalette
from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtWidgets import QApplication, QMainWindow
except: except:
from PyQt4.QtCore import QTimer from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QApplication, QMainWindow
from PyQt4.QtGui import QApplication, QMainWindow, QPalette


# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# Imports (Custom) # Imports (Custom)
@@ -33,6 +34,7 @@ import ui_carla_host


from carla_database import * from carla_database import *
from carla_settings import * from carla_settings import *
from carla_style import *
from carla_widgets import * from carla_widgets import *


# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
@@ -507,10 +509,10 @@ class HostWindow(QMainWindow):
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# Internal stuff (settings) # Internal stuff (settings)


def loadSettings(self, doGeometry):
def loadSettings(self, firstTime):
settings = QSettings() settings = QSettings()


if doGeometry:
if firstTime:
self.restoreGeometry(settings.value("Geometry", "")) self.restoreGeometry(settings.value("Geometry", ""))


showToolbar = settings.value("ShowToolbar", True, type=bool) showToolbar = settings.value("ShowToolbar", True, type=bool)
@@ -572,9 +574,6 @@ class HostWindow(QMainWindow):


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


useCustomMiniCanvasPaint = bool(settings.value("Main/UseProTheme", True, type=bool) and
settings.value("Main/ProThemeColor", "Black", type=str) == "Black")

self.fSavedSettings = { self.fSavedSettings = {
"Main/DefaultProjectFolder": settings.value("Main/DefaultProjectFolder", HOME, type=str), "Main/DefaultProjectFolder": settings.value("Main/DefaultProjectFolder", HOME, type=str),
"Main/RefreshInterval": settings.value("Main/RefreshInterval", 50, type=int), "Main/RefreshInterval": settings.value("Main/RefreshInterval", 50, type=int),
@@ -585,7 +584,8 @@ class HostWindow(QMainWindow):
"Canvas/UseOpenGL": settings.value("Canvas/UseOpenGL", False, type=bool), "Canvas/UseOpenGL": settings.value("Canvas/UseOpenGL", False, type=bool),
"Canvas/Antialiasing": settings.value("Canvas/Antialiasing", CANVAS_ANTIALIASING_SMALL, type=int), "Canvas/Antialiasing": settings.value("Canvas/Antialiasing", CANVAS_ANTIALIASING_SMALL, type=int),
"Canvas/HighQualityAntialiasing": settings.value("Canvas/HighQualityAntialiasing", False, type=bool), "Canvas/HighQualityAntialiasing": settings.value("Canvas/HighQualityAntialiasing", False, type=bool),
"UseCustomMiniCanvasPaint": useCustomMiniCanvasPaint
"UseCustomMiniCanvasPaint": (settings.value("Main/UseProTheme", True, type=bool) and
settings.value("Main/ProThemeColor", "Black", type=str).lower() == "black")
} }


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


+ 212
- 0
source/carla_style.py View File

@@ -0,0 +1,212 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Carla style
# 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 2 of the License, or
# 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.
#
# For a full copy of the GNU General Public License see the GPL.txt file

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

try:
from PyQt5.QtCore import QSettings
from PyQt5.QtGui import QColor, QPalette
from PyQt5.QtWidgets import QApplication
except:
from PyQt4.QtCore import QSettings
from PyQt4.QtGui import QApplication, QColor, QPalette

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)

from carla_shared import *

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

class CarlaApplication(object):
# Colors
COLOR_SYSTEM = 0
COLOR_BLACK = 1
COLOR_BLUE = 1

def __init__(self, appName = "Carla"):
object.__init__(self)

if os.path.exists(os.path.join(CWD, "modules", "theme")):
libdir = os.path.join(os.path.join(CWD, "modules", "theme"))
else:
libdir = CWD

QApplication.addLibraryPath(libdir)

self.fApp = QApplication(sys.argv)
self.fApp.setApplicationName(appName)
self.fApp.setApplicationVersion(VERSION)
self.fApp.setOrganizationName("falkTX")

if appName.lower() == "carla-control":
self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg"))
else:
self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg"))

self.fPalSystem = self.fApp.palette()

self.fPalBlack = QPalette()
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Window, QColor(14, 14, 14))
self.fPalBlack.setColor(QPalette.Active, QPalette.Window, QColor(17, 17, 17))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Window, QColor(17, 17, 17))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.WindowText, QColor(83, 83, 83))
self.fPalBlack.setColor(QPalette.Active, QPalette.WindowText, QColor(240, 240, 240))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.WindowText, QColor(240, 240, 240))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Base, QColor(6, 6, 6))
self.fPalBlack.setColor(QPalette.Active, QPalette.Base, QColor(7, 7, 7))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Base, QColor(7, 7, 7))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(12, 12, 12))
self.fPalBlack.setColor(QPalette.Active, QPalette.AlternateBase, QColor(14, 14, 14))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(14, 14, 14))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(4, 4, 4))
self.fPalBlack.setColor(QPalette.Active, QPalette.ToolTipBase, QColor(4, 4, 4))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(4, 4, 4))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(230, 230, 230))
self.fPalBlack.setColor(QPalette.Active, QPalette.ToolTipText, QColor(230, 230, 230))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(230, 230, 230))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Text, QColor(74, 74, 74))
self.fPalBlack.setColor(QPalette.Active, QPalette.Text, QColor(230, 230, 230))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Text, QColor(230, 230, 230))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Button, QColor(24, 24, 24))
self.fPalBlack.setColor(QPalette.Active, QPalette.Button, QColor(28, 28, 28))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Button, QColor(28, 28, 28))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90))
self.fPalBlack.setColor(QPalette.Active, QPalette.ButtonText, QColor(240, 240, 240))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(240, 240, 240))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
self.fPalBlack.setColor(QPalette.Active, QPalette.BrightText, QColor(255, 255, 255))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Light, QColor(191, 191, 191))
self.fPalBlack.setColor(QPalette.Active, QPalette.Light, QColor(191, 191, 191))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Light, QColor(191, 191, 191))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Midlight, QColor(155, 155, 155))
self.fPalBlack.setColor(QPalette.Active, QPalette.Midlight, QColor(155, 155, 155))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Midlight, QColor(155, 155, 155))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Dark, QColor(129, 129, 129))
self.fPalBlack.setColor(QPalette.Active, QPalette.Dark, QColor(129, 129, 129))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Dark, QColor(129, 129, 129))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Mid, QColor(94, 94, 94))
self.fPalBlack.setColor(QPalette.Active, QPalette.Mid, QColor(94, 94, 94))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Mid, QColor(94, 94, 94))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Shadow, QColor(155, 155, 155))
self.fPalBlack.setColor(QPalette.Active, QPalette.Shadow, QColor(155, 155, 155))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Shadow, QColor(155, 155, 155))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Highlight, QColor(14, 14, 14))
self.fPalBlack.setColor(QPalette.Active, QPalette.Highlight, QColor(60, 60, 60))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Highlight, QColor(34, 34, 34))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(83, 83, 83))
self.fPalBlack.setColor(QPalette.Active, QPalette.HighlightedText, QColor(255, 255, 255))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(240, 240, 240))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.Link, QColor(34, 34, 74))
self.fPalBlack.setColor(QPalette.Active, QPalette.Link, QColor(100, 100, 230))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.Link, QColor(100, 100, 230))
self.fPalBlack.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(74, 34, 74))
self.fPalBlack.setColor(QPalette.Active, QPalette.LinkVisited, QColor(230, 100, 230))
self.fPalBlack.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(230, 100, 230))

self.fPalBlue = QPalette()
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Window, QColor(32, 35, 39))
self.fPalBlue.setColor(QPalette.Active, QPalette.Window, QColor(37, 40, 45))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Window, QColor(37, 40, 45))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.WindowText, QColor(89, 95, 104))
self.fPalBlue.setColor(QPalette.Active, QPalette.WindowText, QColor(223, 237, 255))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.WindowText, QColor(223, 237, 255))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Base, QColor(48, 53, 60))
self.fPalBlue.setColor(QPalette.Active, QPalette.Base, QColor(55, 61, 69))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Base, QColor(55, 61, 69))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(60, 64, 67))
self.fPalBlue.setColor(QPalette.Active, QPalette.AlternateBase, QColor(69, 73, 77))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(69, 73, 77))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(182, 193, 208))
self.fPalBlue.setColor(QPalette.Active, QPalette.ToolTipBase, QColor(182, 193, 208))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(182, 193, 208))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(42, 44, 48))
self.fPalBlue.setColor(QPalette.Active, QPalette.ToolTipText, QColor(42, 44, 48))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(42, 44, 48))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Text, QColor(96, 103, 113))
self.fPalBlue.setColor(QPalette.Active, QPalette.Text, QColor(210, 222, 240))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Text, QColor(210, 222, 240))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Button, QColor(51, 55, 62))
self.fPalBlue.setColor(QPalette.Active, QPalette.Button, QColor(59, 63, 71))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Button, QColor(59, 63, 71))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(98, 104, 114))
self.fPalBlue.setColor(QPalette.Active, QPalette.ButtonText, QColor(210, 222, 240))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(210, 222, 240))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
self.fPalBlue.setColor(QPalette.Active, QPalette.BrightText, QColor(255, 255, 255))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Light, QColor(59, 64, 72))
self.fPalBlue.setColor(QPalette.Active, QPalette.Light, QColor(63, 68, 76))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Light, QColor(63, 68, 76))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Midlight, QColor(48, 52, 59))
self.fPalBlue.setColor(QPalette.Active, QPalette.Midlight, QColor(51, 56, 63))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Midlight, QColor(51, 56, 63))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Dark, QColor(18, 19, 22))
self.fPalBlue.setColor(QPalette.Active, QPalette.Dark, QColor(20, 22, 25))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Dark, QColor(20, 22, 25))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Mid, QColor(28, 30, 34))
self.fPalBlue.setColor(QPalette.Active, QPalette.Mid, QColor(32, 35, 39))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Mid, QColor(32, 35, 39))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Shadow, QColor(13, 14, 16))
self.fPalBlue.setColor(QPalette.Active, QPalette.Shadow, QColor(15, 16, 18))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Shadow, QColor(15, 16, 18))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Highlight, QColor(32, 35, 39))
self.fPalBlue.setColor(QPalette.Active, QPalette.Highlight, QColor(14, 14, 17))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Highlight, QColor(27, 28, 33))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(89, 95, 104))
self.fPalBlue.setColor(QPalette.Active, QPalette.HighlightedText, QColor(217, 234, 253))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(223, 237, 255))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.Link, QColor(79, 100, 118))
self.fPalBlue.setColor(QPalette.Active, QPalette.Link, QColor(156, 212, 255))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.Link, QColor(156, 212, 255))
self.fPalBlue.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(51, 74, 118))
self.fPalBlue.setColor(QPalette.Active, QPalette.LinkVisited, QColor(64, 128, 255))
self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255))

self.loadSettings()
print("TESTING", self.fApp.style().objectName())

def loadSettings(self):
settings = QSettings()

useProTheme = settings.value("Main/UseProTheme", True, type=bool)

if useProTheme:
print("USING PRO THEME")
self.fApp.setStyle("carla")

proThemeColor = settings.value("Main/ProThemeColor", "Black", type=str)

if proThemeColor.lower() == "black":
print("USING PRO AND BLACK THEME")
self.fApp.setPalette(self.fPalBlack)

elif proThemeColor.lower() == "blue":
print("USING PRO AND BLUE THEME")
self.fApp.setPalette(self.fPalBlue)

def arguments(self):
return self.fApp.arguments()

def exec_(self):
return self.fApp.exec_()

def getApp(self):
return self.fApp

+ 1
- 1
source/carla_widgets.py View File

@@ -1040,7 +1040,7 @@ class PluginEdit(QDialog):
sender = self.sender() sender = self.sender()


if sender == self.ui.ch_fixed_buffer: if sender == self.ui.ch_fixed_buffer:
option = PLUGIN_OPTION_FIXED_BUFFER
option = PLUGIN_OPTION_FIXED_BUFFERS
elif sender == self.ui.ch_force_stereo: elif sender == self.ui.ch_force_stereo:
option = PLUGIN_OPTION_FORCE_STEREO option = PLUGIN_OPTION_FORCE_STEREO
elif sender == self.ui.ch_map_program_changes: elif sender == self.ui.ch_map_program_changes:


+ 3
- 0
source/modules/carla_native/vex.cpp View File

@@ -683,6 +683,9 @@ public:
fParameters[offset + 24] = 0.5f; fParameters[offset + 24] = 0.5f;
} }


fParameters[76] = 0.3f; // Chorus Rate
fParameters[77] = 0.6f; // Chorus Depth

fParameters[89] = 1.0f; fParameters[89] = 1.0f;


fSynth.setSampleRate(getSampleRate()); fSynth.setSampleRate(getSampleRate());


+ 3
- 41
source/modules/theme/CarlaStyle.cpp View File

@@ -523,13 +523,9 @@ CarlaStyle::CarlaStyle()
: QCommonStyle(), : QCommonStyle(),
d(new CarlaStylePrivate(this)) d(new CarlaStylePrivate(this))
{ {
setObjectName(QLatin1String("Carla"));

QApplication* const app(qApp);

if (app == nullptr)
return;
setObjectName(QLatin1String("CarlaStyle"));


#if 0
fPalSystem = app->palette(); fPalSystem = app->palette();


fPalBlack.setColor(QPalette::Disabled, QPalette::Window, QColor(14, 14, 14)); fPalBlack.setColor(QPalette::Disabled, QPalette::Window, QColor(14, 14, 14));
@@ -647,8 +643,7 @@ CarlaStyle::CarlaStyle()
fPalBlue.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(51, 74, 118)); fPalBlue.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(51, 74, 118));
fPalBlue.setColor(QPalette::Active, QPalette::LinkVisited, QColor(64, 128, 255)); fPalBlue.setColor(QPalette::Active, QPalette::LinkVisited, QColor(64, 128, 255));
fPalBlue.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(64, 128, 255)); fPalBlue.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(64, 128, 255));

setColorSchemeAsNeeded();
#endif
} }


CarlaStyle::~CarlaStyle() CarlaStyle::~CarlaStyle()
@@ -656,39 +651,6 @@ CarlaStyle::~CarlaStyle()
delete d; 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) void printPalette(const QPalette& pal)
{ {
#define PAL "fPalBlue" #define PAL "fPalBlue"


+ 0
- 7
source/modules/theme/CarlaStyle.hpp View File

@@ -44,9 +44,6 @@ public:
CarlaStyle(); CarlaStyle();
~CarlaStyle(); ~CarlaStyle();


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

QPalette standardPalette() const override; QPalette standardPalette() const override;
void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter, void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter,
const QWidget* widget = nullptr) const override; const QWidget* widget = nullptr) const override;
@@ -65,10 +62,6 @@ public:
void unpolish(QWidget* widget) override; void unpolish(QWidget* widget) override;


private: private:
QPalette fPalBlack;
QPalette fPalBlue;
QPalette fPalSystem;

CarlaStylePrivate* const d; CarlaStylePrivate* const d;
friend class CarlaStylePrivate; friend class CarlaStylePrivate;
}; };


+ 8
- 5
source/modules/theme/CarlaStylePlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaStylePlugin.hpp" #include "CarlaStylePlugin.hpp"
#include "CarlaStyle.hpp"


CarlaStylePlugin::CarlaStylePlugin(QObject* parent) CarlaStylePlugin::CarlaStylePlugin(QObject* parent)
: QStylePlugin(parent) : QStylePlugin(parent)
@@ -24,12 +25,14 @@ CarlaStylePlugin::CarlaStylePlugin(QObject* parent)


QStyle* CarlaStylePlugin::create(const QString& key) QStyle* CarlaStylePlugin::create(const QString& key)
{ {
return (key.toLower() == "carla") ? new CarlaStyle() : nullptr;
return (key.toLower() == "carla") ? new CarlaStyle : nullptr;
} }


// QStringList CarlaStylePlugin::keys() const
// {
// return QStringList() << "Carla";
// }
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QStringList CarlaStylePlugin::keys() const
{
return QStringList() << "Carla";
}


Q_EXPORT_PLUGIN2(Carla, CarlaStylePlugin) Q_EXPORT_PLUGIN2(Carla, CarlaStylePlugin)
#endif

+ 7
- 2
source/modules/theme/CarlaStylePlugin.hpp View File

@@ -18,7 +18,7 @@
#ifndef CARLA_STYLE_PLUGIN_HPP_INCLUDED #ifndef CARLA_STYLE_PLUGIN_HPP_INCLUDED
#define CARLA_STYLE_PLUGIN_HPP_INCLUDED #define CARLA_STYLE_PLUGIN_HPP_INCLUDED


#include "CarlaStyle.hpp"
#include <QtCore/Qt>


#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
# include <QtWidgets/QStylePlugin> # include <QtWidgets/QStylePlugin>
@@ -29,11 +29,16 @@
class CarlaStylePlugin : public QStylePlugin class CarlaStylePlugin : public QStylePlugin
{ {
Q_OBJECT Q_OBJECT
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "carlastyle.json")
#endif


public: public:
CarlaStylePlugin(QObject* parent = nullptr); CarlaStylePlugin(QObject* parent = nullptr);
QStyle* create(const QString& key) override; QStyle* create(const QString& key) override;
//QStringList keys() const override;
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QStringList keys() const override;
#endif
}; };


#endif // CARLA_STYLE_PLUGIN_HPP_INCLUDED #endif // CARLA_STYLE_PLUGIN_HPP_INCLUDED

+ 66
- 35
source/modules/theme/Makefile View File

@@ -9,20 +9,14 @@ include ../../Makefile.mk
# -------------------------------------------------------------- # --------------------------------------------------------------


BUILD_CXX_FLAGS += -I. -I../../includes -I../../utils BUILD_CXX_FLAGS += -I. -I../../includes -I../../utils
QT5_CXX_FLAGS = $(BUILD_CXX_FLAGS) # FIXME: use copy instead of reference
QT4_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) BUILD_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)
LINK_FLAGS += $(shell pkg-config --libs Qt5Core Qt5Gui Qt5Widgets) LINK_FLAGS += $(shell pkg-config --libs Qt5Core Qt5Gui Qt5Widgets)
QT_STYLES_DIR = $(shell pkg-config --variable=libdir Qt5Core)/qt5/plugins/styles QT_STYLES_DIR = $(shell pkg-config --variable=libdir Qt5Core)/qt5/plugins/styles
endif


ifeq ($(HAVE_QT5),true)
QT5_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)
ifeq ($(HAVE_QT4),true)
QT4_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)
endif endif


# -------------------------------------------------------------- # --------------------------------------------------------------
@@ -34,22 +28,33 @@ FILES = \
moc_CarlaStylePrivate.cpp \ moc_CarlaStylePrivate.cpp \
resources.cpp resources.cpp


OBJS = \
FILES_qt4 = \
moc_CarlaStyle.qt4.cpp \
moc_CarlaStyleAnimations.qt4.cpp \
moc_CarlaStylePlugin.qt4.cpp \
moc_CarlaStylePrivate.qt4.cpp \
resources.qt4.cpp

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

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


OBJS_shared = $(OBJS) \ OBJS_shared = $(OBJS) \
CarlaStylePlugin.cpp.o \ CarlaStylePlugin.cpp.o \
moc_CarlaStylePlugin.cpp.o \
resources.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
# --------------------------------------------------------------

OBJS_qt4 = \
CarlaStyle.cpp.qt4.o \
moc_CarlaStyle.cpp.qt4.o \
moc_CarlaStyleAnimations.cpp.qt4.o \
moc_CarlaStylePrivate.cpp.qt4.o


OBJS_posix32 = \ OBJS_posix32 = \
CarlaStyle.cpp.posix32.o \ CarlaStyle.cpp.posix32.o \
@@ -77,9 +82,21 @@ OBJS_win64 = \


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


all: ../theme.a


qt5: ../theme.qt5.a

ifeq ($(WIN32),true)
CARLASTYLE = styles/carlastyle.dll
else
ifeq ($(MACOS),true)
CARLASTYLE = styles/carlastyle.dylib
else
CARLASTYLE = styles/carlastyle.so
endif
endif

all: ../theme.a $(CARLASTYLE)

qt4: ../theme.qt4.a
posix32: ../theme.posix32.a posix32: ../theme.posix32.a
posix64: ../theme.posix64.a posix64: ../theme.posix64.a
win32: ../theme.win32.a win32: ../theme.win32.a
@@ -88,30 +105,38 @@ win64: ../theme.win64.a
# -------------------------------------------------------------- # --------------------------------------------------------------


../theme.a: $(FILES) $(OBJS) ../theme.a: $(FILES) $(OBJS)
$(AR) rs $@ $(OBJS)
rm -f $@
$(AR) crs $@ $(OBJS)


../theme.qt5.a: $(FILES) $(OBJS_qt5)
$(AR) rs $@ $(OBJS_qt5)
../theme.qt4.a: $(FILES_qt4) $(OBJS_qt4)
rm -f $@
$(AR) crs $@ $(OBJS_qt4)


../theme.posix32.a: $(FILES) $(OBJS_posix32) ../theme.posix32.a: $(FILES) $(OBJS_posix32)
$(AR) rs $@ $(OBJS_posix32)
rm -f $@
$(AR) crs $@ $(OBJS_posix32)


../theme.posix64.a: $(FILES) $(OBJS_posix64) ../theme.posix64.a: $(FILES) $(OBJS_posix64)
$(AR) rs $@ $(OBJS_posix64)
rm -f $@
$(AR) crs $@ $(OBJS_posix64)


../theme.win32.a: $(FILES) $(OBJS_win32) ../theme.win32.a: $(FILES) $(OBJS_win32)
$(AR) rs $@ $(OBJS_win32)
rm -f $@
$(AR) crs $@ $(OBJS_win32)


../theme.win64.a: $(FILES) $(OBJS_win64) ../theme.win64.a: $(FILES) $(OBJS_win64)
$(AR) rs $@ $(OBJS_win64)
rm -f $@
$(AR) crs $@ $(OBJS_win64)

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


../carlastyle.dll: $(FILES) $(OBJS_shared)
styles/carlastyle.dll: $(FILES) $(OBJS_shared)
$(CXX) $(OBJS_shared) -shared $(LINK_FLAGS) -o $@ $(CXX) $(OBJS_shared) -shared $(LINK_FLAGS) -o $@


../carlastyle.dynlib: $(FILES) $(OBJS_shared)
styles/carlastyle.dynlib: $(FILES) $(OBJS_shared)
$(CXX) $(OBJS_shared) -dynamiclib $(LINK_FLAGS) -o $@ $(CXX) $(OBJS_shared) -dynamiclib $(LINK_FLAGS) -o $@


../carlastyle.so: $(FILES) $(OBJS_shared)
styles/carlastyle.so: $(FILES) $(OBJS_shared)
$(CXX) $(OBJS_shared) -shared $(LINK_FLAGS) -o $@ $(CXX) $(OBJS_shared) -shared $(LINK_FLAGS) -o $@


# -------------------------------------------------------------- # --------------------------------------------------------------
@@ -119,8 +144,8 @@ win64: ../theme.win64.a
%.cpp.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp %.cpp.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@


%.cpp.qt5.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(QT5_CXX_FLAGS) -c -o $@
%.cpp.qt4.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(QT4_CXX_FLAGS) -c -o $@


%.cpp.posix32.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp %.cpp.posix32.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@ $(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@
@@ -134,20 +159,26 @@ win64: ../theme.win64.a
%.cpp.win64.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp %.cpp.win64.o: %.cpp CarlaStyle.hpp moc_CarlaStyle.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@ $(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@


moc_%.qt4.cpp: %.hpp
$(MOC_QT4) $< -o $@

moc_%.cpp: %.hpp moc_%.cpp: %.hpp
$(MOC) $< -o $@ $(MOC) $< -o $@


resources.cpp: ../../../resources/resources-theme.qrc resources.cpp: ../../../resources/resources-theme.qrc
$(RCC) $< -o $@ $(RCC) $< -o $@


# --------------------------------------------------------------
resources.qt4.cpp: ../../../resources/resources-theme.qrc
$(RCC_QT4) $< -o $@


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


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


debug: debug:
$(MAKE) DEBUG=true $(MAKE) DEBUG=true

install: $(THEMESTYLE)
install -d $(QT_STYLES_DIR)
install -m 644 $< styles/carlastyle.json $(QT_STYLES_DIR)

+ 1
- 0
source/modules/theme/styles/carlastyle.json View File

@@ -0,0 +1 @@
{ "Keys": [ "Carla" ] }

Loading…
Cancel
Save