From 676e0d5e9f2fee3614c8247ec60745263b274700 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Wed, 6 Apr 2022 08:41:32 +0200 Subject: [PATCH] colorswitch example removed --- examples/buttons/TestButton.qml | 7 + examples/buttons/buttons.qml | 10 +- examples/colorswitch/Theme.cpp | 117 ----------------- examples/colorswitch/Theme.h | 35 ----- examples/colorswitch/colorswitch.pro | 11 -- examples/colorswitch/colorswitch.qml | 187 --------------------------- examples/colorswitch/colorswitch.qrc | 5 - examples/colorswitch/main.cpp | 36 ------ examples/examples.pro | 1 - src/controls/QskWindow.cpp | 9 +- 10 files changed, 21 insertions(+), 397 deletions(-) delete mode 100644 examples/colorswitch/Theme.cpp delete mode 100644 examples/colorswitch/Theme.h delete mode 100644 examples/colorswitch/colorswitch.pro delete mode 100644 examples/colorswitch/colorswitch.qml delete mode 100644 examples/colorswitch/colorswitch.qrc delete mode 100644 examples/colorswitch/main.cpp diff --git a/examples/buttons/TestButton.qml b/examples/buttons/TestButton.qml index 9d4d5137..cbb76ae5 100644 --- a/examples/buttons/TestButton.qml +++ b/examples/buttons/TestButton.qml @@ -5,10 +5,17 @@ Qsk.PushButton { sizePolicy { + // long texts, should not have an effect horizontalPolicy: Qsk.SizePolicy.Ignored verticalPolicy: Qsk.SizePolicy.Ignored } + minimumSize + { + width: 80 + height: 60 + } + shape { sizeMode: Qt.RelativeSize diff --git a/examples/buttons/buttons.qml b/examples/buttons/buttons.qml index 442f7729..e8296251 100644 --- a/examples/buttons/buttons.qml +++ b/examples/buttons/buttons.qml @@ -6,12 +6,20 @@ Qsk.Window { id: window visible: true - // visibility: QskWindow.Minimized width: 600 height: 600 color: "Beige" + Component.onCompleted: + { + // very much standard: we should find a better way + + var hint = sizeConstraint(); + setMinimumWidth( hint.width ) + setMinimumHeight( hint.height ) + } + Qsk.Shortcut { sequence : "Ctrl+X" diff --git a/examples/colorswitch/Theme.cpp b/examples/colorswitch/Theme.cpp deleted file mode 100644 index a24a66bc..00000000 --- a/examples/colorswitch/Theme.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "Theme.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace -{ - class SkinTransition final : public QskSkinTransition - { - public: - SkinTransition( const QColor& accent ) - : m_accent( accent ) - { - } - - protected: - void updateSkin( QskSkin*, QskSkin* newSkin ) override - { - newSkin->resetColors( m_accent ); - - /* - The current implementation of the skins is not that good - and we don't have support for customizing them by a minimal set - of attributes. So we do some manual extra work here - */ - - QskSkinHintTableEditor ed( &newSkin->hintTable() ); - - ed.setColor( QskListView::Cell | QskListView::Selected, m_accent.darker( 130 ) ); - ed.setBoxBorderColors( QskFocusIndicator::Panel, m_accent.darker( 150 ) ); - } - - private: - const QColor m_accent; - }; -} - -Theme::Theme( QObject* parent ) - : QObject( parent ) - , m_accent( Qt::blue ) -{ - connect( qskSetup, &QskSetup::skinChanged, - this, [ this ]( QskSkin* ) { updateColors(); } ); - - connect( qskSetup, &QskSetup::skinChanged, - this, [ this ]( QskSkin* ) { Q_EMIT skinChanged(); } ); -} - -void Theme::setAccent( QColor color ) -{ - if ( m_accent != color ) - { - m_accent = color; - updateColors(); - - Q_EMIT accentChanged(); - } -} - -QColor Theme::accent() const -{ - return m_accent; -} - -void Theme::setSkin( const QString& skinName ) -{ - if ( skinName == qskSetup->skinName() ) - return; - - auto oldSkin = qskSetup->skin(); - if ( oldSkin->parent() == qskSetup ) - oldSkin->setParent( nullptr ); // otherwise setSkin deletes it - - auto newSkin = qskSetup->setSkin( skinName ); - - SkinTransition transition( m_accent ); - - transition.setSourceSkin( oldSkin ); - transition.setTargetSkin( newSkin ); - transition.setAnimation( 500 ); - - transition.process(); - - if ( oldSkin->parent() == nullptr ) - delete oldSkin; -} - -QString Theme::skin() const -{ - return qskSetup->skinName(); -} - -void Theme::updateColors() -{ - SkinTransition transition( m_accent ); - - transition.setMask( SkinTransition::Color ); - transition.setSourceSkin( qskSetup->skin() ); - transition.setTargetSkin( qskSetup->skin() ); - transition.setAnimation( 500 ); - - transition.process(); -} - -#include "moc_Theme.cpp" diff --git a/examples/colorswitch/Theme.h b/examples/colorswitch/Theme.h deleted file mode 100644 index a01300f3..00000000 --- a/examples/colorswitch/Theme.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#pragma once - -#include -#include - -class Theme : public QObject -{ - Q_OBJECT - - Q_PROPERTY( QColor accent READ accent WRITE setAccent NOTIFY accentChanged ) - Q_PROPERTY( QString skin READ skin WRITE setSkin NOTIFY skinChanged ) - - public: - Theme( QObject* parent = nullptr ); - - void setAccent( QColor color ); - QColor accent() const; - - void setSkin( const QString& ); - QString skin() const; - - Q_SIGNALS: - void accentChanged(); - void skinChanged(); - - private: - void updateColors(); - - QColor m_accent; -}; diff --git a/examples/colorswitch/colorswitch.pro b/examples/colorswitch/colorswitch.pro deleted file mode 100644 index e6da7676..00000000 --- a/examples/colorswitch/colorswitch.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += qskexample qskqmlexport - -RESOURCES += \ - colorswitch.qrc - -HEADERS += \ - Theme.h - -SOURCES += \ - Theme.cpp \ - main.cpp diff --git a/examples/colorswitch/colorswitch.qml b/examples/colorswitch/colorswitch.qml deleted file mode 100644 index 32732703..00000000 --- a/examples/colorswitch/colorswitch.qml +++ /dev/null @@ -1,187 +0,0 @@ -import QtQuick 2.5 -import Skinny 1.0 -import Theme 1.0 // things beyond supersimple are way more convenient with C++ - -Main -{ - id: main - - property var accentColors: [ "red", "lightgreen", "#66336699" ] - - Theme - { - accent: accentColors[ tabBar.currentIndex < 0 ? 0 : tabBar.currentIndex ] - skin: listBox.entries[ listBox.selectedRow ] - } - - Window - { - id: window - - visible: true - color: "Gainsboro" - - width: 600 - height: 600 - - Component.onCompleted: - { - // very much standard: we should find a better way - - var hint = sizeConstraint(); - setMinimumWidth( hint.width ) - setMinimumHeight( hint.height ) - } - - LinearBox - { - orientation: Qt.Horizontal - - spacing: 20 - //margins: 8 // so that we can see the focus frame - margins { left: 8; top: 8; right: 8; bottom: 8 } - - SimpleListBox - { - id: listBox - - preferredWidthFromColumns: true - sizePolicy.horizontalPolicy: SizePolicy.Fixed - - entries: main.skinList - selectedRow: 1 - } - - LinearBox - { - // margins: 10 - margins { left: 10; top: 10; right: 10; bottom: 10 } - orientation: Qt.Vertical - defaultAlignment: Qt.AlignCenter - extraSpacingAt: Qt.BottomEdge - - TabBar - { - id: tabBar - currentIndex: 1 - - Instantiator - { - onObjectAdded: { - tabBar.insertTab( index, object ); - } - - model: accentColors - - delegate: TabButton - { - id: tabButton1 - sizePolicy.horizontalPolicy: SizePolicy.MinimumExpanding - text: modelData - } - } - } - - LinearBox - { - orientation: Qt.Horizontal - dimension: 3 - - spacing: 20 - //margins: 20 - margins { left: 20; top: 20; right: 20; bottom: 20 } - - sizePolicy - { - horizontalPolicy: SizePolicy.Fixed - verticalPolicy: SizePolicy.Fixed - } - - PushButton - { - text: "normal" - focus: true - } - - PushButton - { - text: checked ? "checked" : "unchecked" - checked: true - checkable: true - } - - PushButton - { - text: "disabled" - enabled: false - } - - PushButton - { - text: "flat" - flat: true - } - - PushButton - { - text: ( checked ? "\u2714 " : "" ) + "flat" - flat: true - checkable: true - checked: true - } - - PushButton - { - text: "flat" - flat: true - enabled: false - } - } - - LinearBox - { - spacing: 5 - orientation: Qt.Horizontal - - sizePolicy - { - horizontalPolicy: SizePolicy.MinimumExpanding - verticalPolicy: SizePolicy.Fixed - } - - Slider - { - id: slider - - minimum: 0 - maximum: 100 - value: 42 - - snap: true - stepSize: 1 - } - - TextLabel - { - id: sliderValue - - FontMetrics - { - id: fontMetrics - } - - property rect textRect: fontMetrics.boundingRect("100") - preferredSize: Qt.size( textRect.width, textRect.height ) - sizePolicy: SizePolicy.Fixed - - text: slider.value - } - } - } - } - - FocusIndicator - { - } - } -} diff --git a/examples/colorswitch/colorswitch.qrc b/examples/colorswitch/colorswitch.qrc deleted file mode 100644 index 77f236a9..00000000 --- a/examples/colorswitch/colorswitch.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - colorswitch.qml - - diff --git a/examples/colorswitch/main.cpp b/examples/colorswitch/main.cpp deleted file mode 100644 index 00d69450..00000000 --- a/examples/colorswitch/main.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "Theme.h" - -#include - -#include -#include - -#include -#include -#include - -int main( int argc, char* argv[] ) -{ -#ifdef ITEM_STATISTICS - QskObjectCounter counter( true ); -#endif - - qputenv( "QT_IM_MODULE", "skinny" ); - - QskQml::registerTypes(); - qmlRegisterType< Theme >( "Theme", 1, 0, "Theme" ); - - QGuiApplication app( argc, argv ); - - SkinnyShortcut::enable( SkinnyShortcut::Quit | - SkinnyShortcut::ChangeFonts | SkinnyShortcut::DebugShortcuts ); - - QQmlApplicationEngine engine( QUrl( "qrc:/qml/colorswitch.qml" ) ); - - return app.exec(); -} diff --git a/examples/examples.pro b/examples/examples.pro index 0402f44c..a2698bd4 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -32,7 +32,6 @@ qtHaveModule(svg) { SUBDIRS += \ boxes \ buttons \ - colorswitch \ frames \ gbenchmark \ glabels \ diff --git a/src/controls/QskWindow.cpp b/src/controls/QskWindow.cpp index 7e853324..42f7640c 100644 --- a/src/controls/QskWindow.cpp +++ b/src/controls/QskWindow.cpp @@ -489,15 +489,16 @@ QSize QskWindow::sizeConstraint() const const auto children = contentItem()->childItems(); for ( auto child : children ) { - if ( auto control = qskControlCast( child ) ) + if ( !qskIsTransparentForPositioner( child ) ) { - const QSizeF itemConstraint = control->sizeConstraint(); + const auto size = qskSizeConstraint( child, Qt::PreferredSize ); +qDebug() << child << size; if ( doWidth ) - constraint.setWidth( qMax( constraint.width(), itemConstraint.width() ) ); + constraint.setWidth( qMax( constraint.width(), size.width() ) ); if ( doHeight ) - constraint.setHeight( qMax( constraint.height(), itemConstraint.height() ) ); + constraint.setHeight( qMax( constraint.height(), size.height() ) ); } } }