Browse Source

Add initial bits for Qt6 support

pull/1555/merge
falktx@falktx.com 3 months ago
parent
commit
5b1b757933
4 changed files with 112 additions and 7 deletions
  1. +7
    -0
      Makefile
  2. +12
    -0
      source/Makefile.deps.mk
  3. +36
    -6
      source/theme/CarlaStyle.cpp
  4. +57
    -1
      source/theme/Makefile

+ 7
- 0
Makefile View File

@@ -78,6 +78,10 @@ ifeq ($(HAVE_QT5),true)
3RD_LIBS += $(MODULEDIR)/theme.qt5.a 3RD_LIBS += $(MODULEDIR)/theme.qt5.a
endif endif


ifeq ($(HAVE_QT6),true)
3RD_LIBS += $(MODULEDIR)/theme.qt6.a
endif

ifeq ($(HAVE_YSFX),true) ifeq ($(HAVE_YSFX),true)
3RD_LIBS += $(MODULEDIR)/ysfx.a 3RD_LIBS += $(MODULEDIR)/ysfx.a
endif endif
@@ -121,6 +125,9 @@ $(MODULEDIR)/theme.qt4.a: .FORCE
$(MODULEDIR)/theme.qt5.a: .FORCE $(MODULEDIR)/theme.qt5.a: .FORCE
@$(MAKE) -C source/theme qt5 @$(MAKE) -C source/theme qt5


$(MODULEDIR)/theme.qt6.a: .FORCE
@$(MAKE) -C source/theme qt6

$(MODULEDIR)/%.arm32.a: .FORCE $(MODULEDIR)/%.arm32.a: .FORCE
ifneq ($(WINDOWS),true) ifneq ($(WINDOWS),true)
@$(MAKE) -C source/modules/$* arm32 @$(MAKE) -C source/modules/$* arm32


+ 12
- 0
source/Makefile.deps.mk View File

@@ -215,6 +215,7 @@ HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \
$(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true) $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true)
HAVE_QT5PKG = $(shell $(PKG_CONFIG) --silence-errors --variable=prefix Qt5OpenGLExtensions 1>/dev/null && echo true) HAVE_QT5PKG = $(shell $(PKG_CONFIG) --silence-errors --variable=prefix Qt5OpenGLExtensions 1>/dev/null && echo true)
HAVE_QT5BREW = $(shell test -e /usr/local/opt/qt5/bin/uic && echo true) HAVE_QT5BREW = $(shell test -e /usr/local/opt/qt5/bin/uic && echo true)
HAVE_QT6 = $(shell $(PKG_CONFIG) --exists Qt6Core Qt6Gui Qt6Widgets && echo true)
HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true) HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true)


ifeq ($(HAVE_FLUIDSYNTH),true) ifeq ($(HAVE_FLUIDSYNTH),true)
@@ -295,10 +296,20 @@ ifeq (,$(wildcard $(UIC_QT5)))
HAVE_QT5 = false HAVE_QT5 = false
endif endif


ifeq ($(HAVE_QT6),true)
QT6_HOSTBINS = $(shell $(PKG_CONFIG) --variable=libexecdir Qt6Core)
endif

MOC_QT6 ?= $(QT6_HOSTBINS)/moc
RCC_QT6 ?= $(QT6_HOSTBINS)/rcc
UIC_QT6 ?= $(QT6_HOSTBINS)/uic

ifeq ($(HAVE_QT4),true) ifeq ($(HAVE_QT4),true)
HAVE_QT = true HAVE_QT = true
else ifeq ($(HAVE_QT5),true) else ifeq ($(HAVE_QT5),true)
HAVE_QT = true HAVE_QT = true
else ifeq ($(HAVE_QT6),true)
HAVE_QT = true
# FIXME # FIXME
else ifeq ($(WINDOWS),true) else ifeq ($(WINDOWS),true)
HAVE_QT = true HAVE_QT = true
@@ -354,6 +365,7 @@ HAVE_QT4 = false
HAVE_QT5 = false HAVE_QT5 = false
HAVE_QT5PKG = false HAVE_QT5PKG = false
HAVE_QT5BREW = false HAVE_QT5BREW = false
HAVE_QT6 = false
HAVE_SDL = false HAVE_SDL = false
HAVE_SDL1 = false HAVE_SDL1 = false
HAVE_SDL2 = false HAVE_SDL2 = false


+ 36
- 6
source/theme/CarlaStyle.cpp View File

@@ -885,7 +885,11 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
painter->restore(); painter->restore();
} }
break; break;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
case PE_IndicatorItemViewItemCheck:
#else
case PE_IndicatorViewItemCheck: case PE_IndicatorViewItemCheck:
#endif
{ {
QStyleOptionButton button; QStyleOptionButton button;
button.QStyleOption::operator=(*option); button.QStyleOption::operator=(*option);
@@ -1406,7 +1410,13 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
QColor dimHighlight(qMin(highlight.red()/2 + 110, 255), QColor dimHighlight(qMin(highlight.red()/2 + 110, 255),
qMin(highlight.green()/2 + 110, 255), qMin(highlight.green()/2 + 110, 255),
qMin(highlight.blue()/2 + 110, 255)); qMin(highlight.blue()/2 + 110, 255));
dimHighlight.setAlpha(widget && widget->isTopLevel() ? 255 : 80);
dimHighlight.setAlpha(widget &&
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
widget->isWindow()
#else
widget->isTopLevel()
#endif
? 255 : 80);
QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y())); QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()));
gradient.setColorAt(0, dimHighlight.lighter(120)); gradient.setColorAt(0, dimHighlight.lighter(120));
gradient.setColorAt(1, dimHighlight); gradient.setColorAt(1, dimHighlight);
@@ -1689,7 +1699,11 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
bool complete = bar->progress == bar->maximum; bool complete = bar->progress == bar->maximum;


// Get extra style options if version 2 // Get extra style options if version 2
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
vertical = bar->state != QStyle::State_Horizontal;
#else
vertical = (bar->orientation == Qt::Vertical); vertical = (bar->orientation == Qt::Vertical);
#endif
inverted = bar->invertedAppearance; inverted = bar->invertedAppearance;


// If the orientation is vertical, we use a transform to rotate // If the orientation is vertical, we use a transform to rotate
@@ -1771,12 +1785,12 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
highlightedGradientStartColor.setAlpha(120); highlightedGradientStartColor.setAlpha(120);
painter->setPen(QPen(highlightedGradientStartColor, 9.0)); painter->setPen(QPen(highlightedGradientStartColor, 9.0));
painter->setClipRect(progressBar.adjusted(1, 1, -1, -1)); painter->setClipRect(progressBar.adjusted(1, 1, -1, -1));
#ifndef QT_NO_ANIMATION
#ifndef QT_NO_ANIMATION
if (CarlaProgressStyleAnimation *animation = qobject_cast<CarlaProgressStyleAnimation*>(d->animation(widget))) if (CarlaProgressStyleAnimation *animation = qobject_cast<CarlaProgressStyleAnimation*>(d->animation(widget)))
step = animation->animationStep() % 22; step = animation->animationStep() % 22;
else else
d->startAnimation(new CarlaProgressStyleAnimation(d->animationFps(), const_cast<QWidget*>(widget))); d->startAnimation(new CarlaProgressStyleAnimation(d->animationFps(), const_cast<QWidget*>(widget)));
#endif
#endif
for (int x = progressBar.left() - rect.height(); x < rect.right() ; x += 22) for (int x = progressBar.left() - rect.height(); x < rect.right() ; x += 22)
painter->drawLine(x + step, progressBar.bottom() + 1, painter->drawLine(x + step, progressBar.bottom() + 1,
x + rect.height() + step, progressBar.top() - 2); x + rect.height() + step, progressBar.top() - 2);
@@ -1794,7 +1808,11 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,


painter->save(); painter->save();
bool vertical = false, inverted = false; bool vertical = false, inverted = false;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
vertical = bar->state != QStyle::State_Horizontal;
#else
vertical = (bar->orientation == Qt::Vertical); vertical = (bar->orientation == Qt::Vertical);
#endif
inverted = bar->invertedAppearance; inverted = bar->invertedAppearance;
if (vertical) if (vertical)
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
@@ -1962,13 +1980,13 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
else else
pixmap = menuItem->icon.pixmap(iconSize, mode); pixmap = menuItem->icon.pixmap(iconSize, mode);


#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
const int pixw = pixmap.width() / pixmap.devicePixelRatioF(); const int pixw = pixmap.width() / pixmap.devicePixelRatioF();
const int pixh = pixmap.height() / pixmap.devicePixelRatioF(); const int pixh = pixmap.height() / pixmap.devicePixelRatioF();
#else
#else
const int pixw = pixmap.width(); const int pixw = pixmap.width();
const int pixh = pixmap.height(); const int pixh = pixmap.height();
#endif
#endif


QRect pmr(0, 0, pixw, pixh); QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter(vCheckRect.center()); pmr.moveCenter(vCheckRect.center());
@@ -1993,7 +2011,11 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
} }
int x, y, w, h; int x, y, w, h;
menuitem->rect.getRect(&x, &y, &w, &h); menuitem->rect.getRect(&x, &y, &w, &h);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
int tab = menuitem->reservedShortcutWidth;
#else
int tab = menuitem->tabWidth; int tab = menuitem->tabWidth;
#endif
QColor discol; QColor discol;
if (dis) { if (dis) {
discol = menuitem->palette.text().color(); discol = menuitem->palette.text().color();
@@ -2056,7 +2078,11 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
newMI.rect = vSubMenuRect; newMI.rect = vSubMenuRect;
newMI.state = !enabled ? State_None : State_Enabled; newMI.state = !enabled ? State_None : State_Enabled;
if (selected) if (selected)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
newMI.palette.setColor(QPalette::WindowText,
#else
newMI.palette.setColor(QPalette::Foreground, newMI.palette.setColor(QPalette::Foreground,
#endif
newMI.palette.highlightedText().color()); newMI.palette.highlightedText().color());
proxy()->drawPrimitive(arrow, &newMI, painter, widget); proxy()->drawPrimitive(arrow, &newMI, painter, widget);
} }
@@ -3950,7 +3976,11 @@ int CarlaStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWid
case SH_FontDialog_SelectAssociatedText: case SH_FontDialog_SelectAssociatedText:
case SH_MenuBar_AltKeyNavigation: case SH_MenuBar_AltKeyNavigation:
case SH_ComboBox_ListMouseTracking: case SH_ComboBox_ListMouseTracking:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
case SH_Slider_StopMouseOverSlider:
#else
case SH_ScrollBar_StopMouseOverSlider: case SH_ScrollBar_StopMouseOverSlider:
#endif
case SH_ScrollBar_MiddleClickAbsolutePosition: case SH_ScrollBar_MiddleClickAbsolutePosition:
case SH_TitleBar_AutoRaise: case SH_TitleBar_AutoRaise:
case SH_TitleBar_NoBorder: case SH_TitleBar_NoBorder:


+ 57
- 1
source/theme/Makefile View File

@@ -44,6 +44,12 @@ QT5_LINK_FLAGS = $(NON_STATIC_LINK_FLAGS) -F $(QT5_PREFIX)/lib -framework QtCore
QT5_STYLES_DIR = $(QT5_PREFIX)/plugins/styles QT5_STYLES_DIR = $(QT5_PREFIX)/plugins/styles
endif endif


ifeq ($(HAVE_QT6),true)
QT6_CXX_FLAGS = $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags Qt6Core Qt6Gui Qt6Widgets) -std=gnu++17
QT6_LINK_FLAGS = $(NON_STATIC_LINK_FLAGS) $(shell pkg-config --libs Qt6Core Qt6Gui Qt6Widgets)
QT6_STYLES_DIR = $(shell pkg-config --variable=libdir Qt6Core)/qt6/plugins/styles
endif

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


ifeq ($(HAVE_QT4),true) ifeq ($(HAVE_QT4),true)
@@ -64,6 +70,15 @@ FILES_qt5 = \
$(OBJDIR)/resources.qt5.cpp $(OBJDIR)/resources.qt5.cpp
endif endif


ifeq ($(HAVE_QT6),true)
FILES_qt6 = \
$(OBJDIR)/moc_CarlaStyle.qt6.cpp \
$(OBJDIR)/moc_CarlaStyleAnimations.qt6.cpp \
$(OBJDIR)/moc_CarlaStylePlugin.qt6.cpp \
$(OBJDIR)/moc_CarlaStylePrivate.qt6.cpp \
$(OBJDIR)/resources.qt6.cpp
endif

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


ifeq ($(HAVE_QT4),true) ifeq ($(HAVE_QT4),true)
@@ -92,6 +107,19 @@ OBJS_qt5_shared = $(OBJS_qt5) \
$(OBJDIR)/moc_CarlaStylePlugin.qt5.cpp.o $(OBJDIR)/moc_CarlaStylePlugin.qt5.cpp.o
endif endif


ifeq ($(HAVE_QT6),true)
OBJS_qt6 = \
$(OBJDIR)/CarlaStyle.cpp.qt6.o \
$(OBJDIR)/moc_CarlaStyle.qt6.cpp.o \
$(OBJDIR)/moc_CarlaStyleAnimations.qt6.cpp.o \
$(OBJDIR)/moc_CarlaStylePrivate.qt6.cpp.o \
$(OBJDIR)/resources.qt6.cpp.o

OBJS_qt6_shared = $(OBJS_qt6) \
$(OBJDIR)/CarlaStylePlugin.cpp.qt6.o \
$(OBJDIR)/moc_CarlaStylePlugin.qt6.cpp.o
endif

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


ifeq ($(HAVE_QT5),true) ifeq ($(HAVE_QT5),true)
@@ -102,11 +130,13 @@ endif


qt4: $(MODULEDIR)/$(MODULENAME).qt4.a qt4: $(MODULEDIR)/$(MODULENAME).qt4.a
qt5: $(MODULEDIR)/$(MODULENAME).qt5.a qt5: $(MODULEDIR)/$(MODULENAME).qt5.a
qt6: $(MODULEDIR)/$(MODULENAME).qt6.a


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


clean: clean:
rm -f $(OBJDIR)/*.o $(MODULEDIR)/$(MODULENAME)*.a $(BINDIR)/styles/carlastyle$(LIB_EXT) $(FILES_qt4) $(FILES_qt5)
rm -f $(OBJDIR)/*.o $(MODULEDIR)/$(MODULENAME)*.a
rm -f $(BINDIR)/styles/carlastyle$(LIB_EXT) $(FILES_qt4) $(FILES_qt5) $(FILES_qt6)


debug: debug:
$(MAKE) DEBUG=true $(MAKE) DEBUG=true
@@ -129,6 +159,12 @@ $(MODULEDIR)/$(MODULENAME).qt5.a: $(FILES_qt5) $(OBJS_qt5)
$(SILENT)rm -f $@ $(SILENT)rm -f $@
$(SILENT)$(AR) crs $@ $(OBJS_qt5) $(SILENT)$(AR) crs $@ $(OBJS_qt5)


$(MODULEDIR)/$(MODULENAME).qt6.a: $(FILES_qt6) $(OBJS_qt6)
-@mkdir -p $(MODULEDIR)
@echo "Creating $(MODULENAME).qt6.a"
$(SILENT)rm -f $@
$(SILENT)$(AR) crs $@ $(OBJS_qt6)

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


$(BINDIR)/styles/carlastyle.dll: $(FILES_qt5) $(OBJS_qt5_shared) $(BINDIR)/styles/carlastyle.dll: $(FILES_qt5) $(OBJS_qt5_shared)
@@ -162,6 +198,11 @@ $(OBJDIR)/moc_%.qt5.cpp: %.hpp
@echo "Generating moc_$*.qt5.cpp" @echo "Generating moc_$*.qt5.cpp"
$(SILENT)$(MOC_QT5) -Istyles $< -o $@ $(SILENT)$(MOC_QT5) -Istyles $< -o $@


$(OBJDIR)/moc_%.qt6.cpp: %.hpp
-@mkdir -p $(OBJDIR)
@echo "Generating moc_$*.qt6.cpp"
$(SILENT)$(MOC_QT6) -Istyles $< -o $@

$(OBJDIR)/resources.qt4.cpp: $(CWD)/../resources/resources-theme.qrc $(OBJDIR)/resources.qt4.cpp: $(CWD)/../resources/resources-theme.qrc
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Generating resources.qt4.cpp" @echo "Generating resources.qt4.cpp"
@@ -172,6 +213,11 @@ $(OBJDIR)/resources.qt5.cpp: $(CWD)/../resources/resources-theme.qrc
@echo "Generating resources.qt5.cpp" @echo "Generating resources.qt5.cpp"
$(SILENT)$(RCC_QT5) $< -o $@ $(SILENT)$(RCC_QT5) $< -o $@


$(OBJDIR)/resources.qt6.cpp: $(CWD)/../resources/resources-theme.qrc
-@mkdir -p $(OBJDIR)
@echo "Generating resources.qt6.cpp"
$(SILENT)$(RCC_QT6) $< -o $@

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


$(OBJDIR)/%.qt4.cpp.o: $(OBJDIR)/%.qt4.cpp $(OBJDIR)/moc_CarlaStyle.qt4.cpp $(OBJDIR)/%.qt4.cpp.o: $(OBJDIR)/%.qt4.cpp $(OBJDIR)/moc_CarlaStyle.qt4.cpp
@@ -184,6 +230,11 @@ $(OBJDIR)/%.qt5.cpp.o: $(OBJDIR)/%.qt5.cpp $(OBJDIR)/moc_CarlaStyle.qt5.cpp
@echo "Compiling $*.cpp (Qt5)" @echo "Compiling $*.cpp (Qt5)"
$(SILENT)$(CXX) $< $(QT5_CXX_FLAGS) -c -o $@ $(SILENT)$(CXX) $< $(QT5_CXX_FLAGS) -c -o $@


$(OBJDIR)/%.qt6.cpp.o: $(OBJDIR)/%.qt6.cpp $(OBJDIR)/moc_CarlaStyle.qt6.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $*.cpp (Qt6)"
$(SILENT)$(CXX) $< $(QT6_CXX_FLAGS) -c -o $@

$(OBJDIR)/%.cpp.qt4.o: %.cpp $(OBJDIR)/moc_CarlaStyle.qt4.cpp $(OBJDIR)/%.cpp.qt4.o: %.cpp $(OBJDIR)/moc_CarlaStyle.qt4.cpp
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Compiling $< (Qt4)" @echo "Compiling $< (Qt4)"
@@ -194,6 +245,11 @@ $(OBJDIR)/%.cpp.qt5.o: %.cpp $(OBJDIR)/moc_CarlaStyle.qt5.cpp
@echo "Compiling $< (Qt5)" @echo "Compiling $< (Qt5)"
$(SILENT)$(CXX) $< $(QT5_CXX_FLAGS) -c -o $@ $(SILENT)$(CXX) $< $(QT5_CXX_FLAGS) -c -o $@


$(OBJDIR)/%.cpp.qt6.o: %.cpp $(OBJDIR)/moc_CarlaStyle.qt6.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $< (Qt6)"
$(SILENT)$(CXX) $< $(QT6_CXX_FLAGS) -c -o $@

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


-include $(OBJS_qt4_shared:%.o=%.d) -include $(OBJS_qt4_shared:%.o=%.d)


Loading…
Cancel
Save