merge from master
This commit is contained in:
parent
c4ba1d320f
commit
bf2ad4ee13
|
@ -7,7 +7,6 @@
|
||||||
#include "SkinFactory.h"
|
#include "SkinFactory.h"
|
||||||
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
#include <SkinnyFont.h>
|
|
||||||
|
|
||||||
#include <QskSetup.h>
|
#include <QskSetup.h>
|
||||||
#include <QskSkinManager.h>
|
#include <QskSkinManager.h>
|
||||||
|
@ -33,7 +32,6 @@ int main( int argc, char** argv )
|
||||||
*/
|
*/
|
||||||
qskSetup->setItemUpdateFlag( QskQuickItem::PreferRasterForTextures, true );
|
qskSetup->setItemUpdateFlag( QskQuickItem::PreferRasterForTextures, true );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
MainWindow window;
|
MainWindow window;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "Box.h"
|
#include "Box.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskLinearBox.h>
|
#include <QskLinearBox.h>
|
||||||
|
@ -555,7 +554,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );
|
||||||
|
|
||||||
auto* tabView = new TabView();
|
auto* tabView = new TabView();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShapeProvider.h>
|
#include <SkinnyShapeProvider.h>
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
|
@ -24,7 +23,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
QQmlApplicationEngine engine( QUrl( "qrc:/qml/buttons.qml" ) );
|
QQmlApplicationEngine engine( QUrl( "qrc:/qml/buttons.qml" ) );
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "Theme.h"
|
#include "Theme.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskQml.h>
|
#include <QskQml.h>
|
||||||
|
@ -28,7 +27,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::Quit |
|
SkinnyShortcut::enable( SkinnyShortcut::Quit |
|
||||||
SkinnyShortcut::ChangeFonts | SkinnyShortcut::DebugShortcuts );
|
SkinnyShortcut::ChangeFonts | SkinnyShortcut::DebugShortcuts );
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
#include "ButtonPage.h"
|
#include "ButtonPage.h"
|
||||||
|
|
||||||
#include <QskSwitchButton.h>
|
#include <QskSwitchButton.h>
|
||||||
#include <QskLinearBox.h>
|
#include <QskPushButton.h>
|
||||||
#include <QskTextLabel.h>
|
|
||||||
#include <QskSeparator.h>
|
#include <QskSeparator.h>
|
||||||
|
#include <QskLinearBox.h>
|
||||||
#include <QskRgbValue.h>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -18,10 +16,11 @@ namespace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonBox( QQuickItem* parent = nullptr )
|
ButtonBox( QQuickItem* parent = nullptr )
|
||||||
: QskLinearBox( Qt::Horizontal, parent )
|
: QskLinearBox( Qt::Horizontal, 4, parent )
|
||||||
{
|
{
|
||||||
setDefaultAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
setSpacing( 20 );
|
||||||
setMargins( 30 );
|
setExtraSpacingAt( Qt::BottomEdge );
|
||||||
|
setDefaultAlignment( Qt::AlignCenter );
|
||||||
|
|
||||||
populate();
|
populate();
|
||||||
}
|
}
|
||||||
|
@ -29,20 +28,53 @@ namespace
|
||||||
private:
|
private:
|
||||||
void populate()
|
void populate()
|
||||||
{
|
{
|
||||||
(void) new QskSwitchButton( Qt::Vertical, this );
|
const char* texts[] = { "Press Me", "Check Me" };
|
||||||
(void) new QskSwitchButton( Qt::Horizontal, this );
|
const char* graphics[] = { "diamond/khaki", "ellipse/sandybrown" };
|
||||||
|
|
||||||
auto button3 = new QskSwitchButton( Qt::Vertical, this );
|
for ( int i = 0; i < 6; i++ )
|
||||||
button3->setInverted( true );
|
{
|
||||||
|
const int index = i % 2;
|
||||||
|
|
||||||
auto button4 = new QskSwitchButton( Qt::Horizontal, this );
|
auto button = new QskPushButton( this );
|
||||||
button4->setInverted( true );
|
button->setCheckable( index != 0 );
|
||||||
|
//button->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||||
|
|
||||||
|
if ( i > 1 )
|
||||||
|
{
|
||||||
|
auto src = QStringLiteral( "image://shapes/" ) + graphics[ index ];
|
||||||
|
button->setGraphicSource( src );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( i < 2 || i > 3 )
|
||||||
|
{
|
||||||
|
button->setText( texts[ index ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SwitchButtonBox : public QskLinearBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SwitchButtonBox( QQuickItem* parent = nullptr )
|
||||||
|
: QskLinearBox( Qt::Horizontal, parent )
|
||||||
|
{
|
||||||
|
setSpacing( 20 );
|
||||||
|
setExtraSpacingAt( Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge );
|
||||||
|
|
||||||
|
for ( auto orientation : { Qt::Vertical, Qt::Horizontal } )
|
||||||
|
{
|
||||||
|
(void) new QskSwitchButton( orientation, this );
|
||||||
|
|
||||||
|
auto button = new QskSwitchButton( orientation, this );
|
||||||
|
button->setInverted( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonPage::ButtonPage( QQuickItem* parent )
|
ButtonPage::ButtonPage( QQuickItem* parent )
|
||||||
: Page( Qt::Horizontal, parent )
|
: Page( Qt::Vertical, parent )
|
||||||
{
|
{
|
||||||
setSpacing( 40 );
|
setSpacing( 40 );
|
||||||
populate();
|
populate();
|
||||||
|
@ -50,23 +82,7 @@ ButtonPage::ButtonPage( QQuickItem* parent )
|
||||||
|
|
||||||
void ButtonPage::populate()
|
void ButtonPage::populate()
|
||||||
{
|
{
|
||||||
auto hbox1 = new QskLinearBox();
|
new ButtonBox( this );
|
||||||
hbox1->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );
|
new QskSeparator( Qt::Horizontal, this );
|
||||||
hbox1->setExtraSpacingAt( Qt::LeftEdge );
|
new SwitchButtonBox( this );
|
||||||
|
|
||||||
auto label = new QskTextLabel( "Disable the switches:", hbox1 );
|
|
||||||
label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
|
||||||
|
|
||||||
auto button0 = new QskSwitchButton( hbox1 );
|
|
||||||
|
|
||||||
auto hbox2 = new ButtonBox();
|
|
||||||
|
|
||||||
auto vbox = new QskLinearBox( Qt::Vertical, this );
|
|
||||||
vbox->addItem( hbox1 );
|
|
||||||
vbox->addItem( new QskSeparator() );
|
|
||||||
vbox->addItem( hbox2 );
|
|
||||||
vbox->setExtraSpacingAt( Qt::BottomEdge );
|
|
||||||
|
|
||||||
QObject::connect( button0, &QskSwitchButton::checkedChanged,
|
|
||||||
hbox2, &QskQuickItem::setDisabled );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,29 +8,51 @@
|
||||||
#include <QskGraphicLabel.h>
|
#include <QskGraphicLabel.h>
|
||||||
#include <QskSeparator.h>
|
#include <QskSeparator.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
#include <QskSkin.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
class TextLabel : public QskTextLabel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextLabel( int role, QQuickItem* parent = nullptr )
|
||||||
|
: QskTextLabel( parent )
|
||||||
|
{
|
||||||
|
setText( textFromRole( role ) );
|
||||||
|
setFontRole( role );
|
||||||
|
|
||||||
|
setSizePolicy( Qt::Horizontal, QskSizePolicy::Ignored );
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString textFromRole( int role ) const
|
||||||
|
{
|
||||||
|
static QMetaEnum metaEnum;
|
||||||
|
|
||||||
|
if ( !metaEnum.isValid() )
|
||||||
|
{
|
||||||
|
const auto& mo = QskSkin::staticMetaObject;
|
||||||
|
metaEnum = mo.enumerator( mo.indexOfEnumerator( "SkinFontRole" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString s( metaEnum.valueToKey( role ) );
|
||||||
|
s.remove( QStringLiteral( "Font" ) );
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class TextBox : public QskLinearBox
|
class TextBox : public QskLinearBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextBox( QQuickItem* parent = nullptr )
|
TextBox( QQuickItem* parent = nullptr )
|
||||||
: QskLinearBox( Qt::Vertical, 3, parent )
|
: QskLinearBox( Qt::Horizontal, 3, parent )
|
||||||
{
|
{
|
||||||
setMargins( 10 );
|
setMargins( 10 );
|
||||||
//setDefaultAlignment( Qt::AlignTop );
|
setDefaultAlignment( Qt::AlignCenter );
|
||||||
setExtraSpacingAt( Qt::BottomEdge );
|
|
||||||
|
|
||||||
const QStringList texts =
|
for ( int i = 0; i <= QskSkin::HugeFont; i++ )
|
||||||
{ "Default", "Tiny", "Small", "Medium", "Large", "Huge" };
|
( void ) new TextLabel( i, this );
|
||||||
|
|
||||||
for ( int i = 0; i < texts.size(); i++ )
|
|
||||||
{
|
|
||||||
auto label = new QskTextLabel( texts[ i ] + " Font", this );
|
|
||||||
|
|
||||||
//label->setPanel( true );
|
|
||||||
label->setFontRole( i );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,16 @@
|
||||||
#include "slider/SliderPage.h"
|
#include "slider/SliderPage.h"
|
||||||
#include "button/ButtonPage.h"
|
#include "button/ButtonPage.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
#include <SkinnyShapeProvider.h>
|
#include <SkinnyShapeProvider.h>
|
||||||
|
#include <SkinnyNamespace.h>
|
||||||
|
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
#include <QskObjectCounter.h>
|
#include <QskObjectCounter.h>
|
||||||
#include <QskTabView.h>
|
#include <QskTabView.h>
|
||||||
|
#include <QskTextLabel.h>
|
||||||
|
#include <QskSwitchButton.h>
|
||||||
|
#include <QskPushButton.h>
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
@ -31,6 +34,76 @@ namespace
|
||||||
setTabPosition( Qsk::Left );
|
setTabPosition( Qsk::Left );
|
||||||
setAutoFitTabs( true );
|
setAutoFitTabs( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTabsEnabled( bool on )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < count(); i++ )
|
||||||
|
itemAt( i )->setEnabled( on );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Once QskApplicationView and friends are implemented we can replace
|
||||||
|
Header/ApplicationWindow with it. TODO ...
|
||||||
|
*/
|
||||||
|
class Header : public QskLinearBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Header( QQuickItem* parent = nullptr )
|
||||||
|
: QskLinearBox( Qt::Horizontal, parent )
|
||||||
|
{
|
||||||
|
initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Fixed );
|
||||||
|
|
||||||
|
setMargins( 10 );
|
||||||
|
setBackgroundColor( Qt::lightGray );
|
||||||
|
|
||||||
|
{
|
||||||
|
auto button = new QskPushButton( "Skin", this );
|
||||||
|
#if 1
|
||||||
|
button->setFlat( true ); // until we have the section bit in QskAspect
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// transition leads to errors, when changing the tab before being completed. TODO ...
|
||||||
|
connect( button, &QskSwitchButton::clicked,
|
||||||
|
[] { Skinny::changeSkin( 500 ); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
addStretch( 10 );
|
||||||
|
|
||||||
|
{
|
||||||
|
new QskTextLabel( "Enabled", this );
|
||||||
|
|
||||||
|
auto button = new QskSwitchButton( this );
|
||||||
|
button->setChecked( true );
|
||||||
|
|
||||||
|
connect( button, &QskSwitchButton::toggled,
|
||||||
|
this, &Header::enabledToggled );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void enabledToggled( bool );
|
||||||
|
};
|
||||||
|
|
||||||
|
class ApplicationView : public QskLinearBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ApplicationView( QQuickItem* parent = nullptr )
|
||||||
|
: QskLinearBox( Qt::Vertical, parent )
|
||||||
|
{
|
||||||
|
auto header = new Header( this );
|
||||||
|
|
||||||
|
auto tabView = new TabView( this );
|
||||||
|
tabView->addTab( "Labels", new LabelPage() );
|
||||||
|
tabView->addTab( "Buttons", new ButtonPage() );
|
||||||
|
tabView->addTab( "Sliders", new SliderPage() );
|
||||||
|
tabView->addTab( "Progress\nBars", new ProgressBarPage() );
|
||||||
|
|
||||||
|
connect( header, &Header::enabledToggled,
|
||||||
|
tabView, &TabView::setTabsEnabled );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,21 +117,15 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
auto tabView = new TabView();
|
auto mainView = new ApplicationView();
|
||||||
|
|
||||||
tabView->addTab( "Labels", new LabelPage() );
|
|
||||||
tabView->addTab( "Sliders", new SliderPage() );
|
|
||||||
tabView->addTab( "Progress\nBars", new ProgressBarPage() );
|
|
||||||
tabView->addTab( "Buttons", new ButtonPage() );
|
|
||||||
|
|
||||||
QSize size( 800, 600 );
|
QSize size( 800, 600 );
|
||||||
size = size.expandedTo( tabView->sizeHint().toSize() );
|
size = size.expandedTo( mainView->sizeHint().toSize() );
|
||||||
|
|
||||||
QskWindow window;
|
QskWindow window;
|
||||||
window.addItem( tabView );
|
window.addItem( mainView );
|
||||||
window.addItem( new QskFocusIndicator() );
|
window.addItem( new QskFocusIndicator() );
|
||||||
|
|
||||||
window.resize( size );
|
window.resize( size );
|
||||||
|
@ -66,3 +133,5 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "main.moc"
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "GraphicProvider.h"
|
#include "GraphicProvider.h"
|
||||||
#include "Skin.h"
|
#include "Skin.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskSetup.h>
|
#include <QskSetup.h>
|
||||||
|
@ -61,8 +60,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
|
|
||||||
Qsk::addGraphicProvider( QString(), new GraphicProvider() );
|
Qsk::addGraphicProvider( QString(), new GraphicProvider() );
|
||||||
|
|
||||||
// disable default skins
|
// disable default skins
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "StackLayoutPage.h"
|
#include "StackLayoutPage.h"
|
||||||
#include "TestRectangle.h"
|
#include "TestRectangle.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
|
@ -31,7 +30,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
auto tabView = new QskTabView();
|
auto tabView = new QskTabView();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskAspect.h>
|
#include <QskAspect.h>
|
||||||
|
@ -65,7 +64,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
QskWindow window;
|
QskWindow window;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
@ -126,7 +125,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
qskDialog->setPolicy( QskDialog::EmbeddedBox );
|
qskDialog->setPolicy( QskDialog::EmbeddedBox );
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskQml.h>
|
#include <QskQml.h>
|
||||||
|
@ -22,7 +21,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
QQmlApplicationEngine engine( QUrl( "qrc:/qml/messagebox.qml" ) );
|
QQmlApplicationEngine engine( QUrl( "qrc:/qml/messagebox.qml" ) );
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "MySkin.h"
|
#include "MySkin.h"
|
||||||
#include "MyToggleButton.h"
|
#include "MyToggleButton.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShapeProvider.h>
|
#include <SkinnyShapeProvider.h>
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
|
@ -136,7 +135,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::DebugBackground |
|
SkinnyShortcut::enable( SkinnyShortcut::DebugBackground |
|
||||||
SkinnyShortcut::DebugStatistics | SkinnyShortcut::Quit );
|
SkinnyShortcut::DebugStatistics | SkinnyShortcut::Quit );
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#ifdef CONTEXT_MENU
|
#ifdef CONTEXT_MENU
|
||||||
|
@ -29,7 +28,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
QskFocusIndicator* focusIndicator = new QskFocusIndicator();
|
QskFocusIndicator* focusIndicator = new QskFocusIndicator();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskAspect.h>
|
#include <QskAspect.h>
|
||||||
|
@ -90,7 +89,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
auto tabView = new TabView();
|
auto tabView = new TabView();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "AnchorBox.h"
|
#include "AnchorBox.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskControl.h>
|
#include <QskControl.h>
|
||||||
|
@ -153,7 +152,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );
|
||||||
|
|
||||||
auto box = new MyBox();
|
auto box = new MyBox();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
|
@ -21,7 +20,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
Window window( Qt::Horizontal );
|
Window window( Qt::Horizontal );
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
#include "TestBox.h"
|
#include "TestBox.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
|
|
||||||
#include <QskSizePolicy.h>
|
#include <QskSizePolicy.h>
|
||||||
#include <QskFunctions.h>
|
#include <QskFunctions.h>
|
||||||
|
|
||||||
|
@ -389,15 +387,6 @@ int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
|
||||||
#if 1
|
|
||||||
/*
|
|
||||||
we don't need the fonts, but by calling something from
|
|
||||||
the support library initializations regarding the skins
|
|
||||||
are loaded. TODO ...
|
|
||||||
*/
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int testcase = 0;
|
int testcase = 0;
|
||||||
if ( argc == 2 )
|
if ( argc == 2 )
|
||||||
testcase = atoi( argv[1] );
|
testcase = atoi( argv[1] );
|
||||||
|
|
|
@ -17,7 +17,8 @@ Qsk.Window
|
||||||
orientation: Qt.Horizontal
|
orientation: Qt.Horizontal
|
||||||
dimension: 3
|
dimension: 3
|
||||||
|
|
||||||
margins: 10
|
//margins: 10 // only possible with Qt <= 6.1
|
||||||
|
margins { left: 10; top: 10; right: 10; bottom: 10 }
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
Repeater
|
Repeater
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskDialog.h>
|
#include <QskDialog.h>
|
||||||
|
@ -285,7 +284,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
|
@ -43,7 +42,6 @@ int main( int argc, char* argv[] )
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyFont::init( &app );
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );
|
||||||
|
|
||||||
QskWindow window;
|
QskWindow window;
|
||||||
|
|
|
@ -879,7 +879,7 @@ void Editor::setupSwitchButton()
|
||||||
using A = QskAspect;
|
using A = QskAspect;
|
||||||
using Q = QskSwitchButton;
|
using Q = QskSwitchButton;
|
||||||
|
|
||||||
const qreal radius = qskDpiScaled( 18 );
|
const qreal radius = qskDpiScaled( 12 );
|
||||||
const qreal handleSize = 2 * ( radius - 2 );
|
const qreal handleSize = 2 * ( radius - 2 );
|
||||||
|
|
||||||
setBoxShape( Q::Groove, 100, Qt::RelativeSize );
|
setBoxShape( Q::Groove, 100, Qt::RelativeSize );
|
||||||
|
|
|
@ -144,7 +144,7 @@ QVector< QskAspect::Subcontrol > QskAspect::subControls( const QMetaObject* meta
|
||||||
|
|
||||||
static QByteArray qskEnumString( const char* name, int value )
|
static QByteArray qskEnumString( const char* name, int value )
|
||||||
{
|
{
|
||||||
const QMetaObject& mo = QskAspect::staticMetaObject;
|
const auto& mo = QskAspect::staticMetaObject;
|
||||||
|
|
||||||
const QMetaEnum metaEnum = mo.enumerator( mo.indexOfEnumerator( name ) );
|
const QMetaEnum metaEnum = mo.enumerator( mo.indexOfEnumerator( name ) );
|
||||||
const char* key = metaEnum.valueToKey( value );
|
const char* key = metaEnum.valueToKey( value );
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "QskGraphicProviderMap.h"
|
#include "QskGraphicProviderMap.h"
|
||||||
#include "QskSkinHintTable.h"
|
#include "QskSkinHintTable.h"
|
||||||
#include "QskStandardSymbol.h"
|
#include "QskStandardSymbol.h"
|
||||||
|
#include "QskPlatform.h"
|
||||||
|
|
||||||
#include "QskMargins.h"
|
#include "QskMargins.h"
|
||||||
|
|
||||||
|
@ -216,13 +217,14 @@ void QskSkin::declareSkinlet( const QMetaObject* metaObject,
|
||||||
|
|
||||||
void QskSkin::setupFonts( const QString& family, int weight, bool italic )
|
void QskSkin::setupFonts( const QString& family, int weight, bool italic )
|
||||||
{
|
{
|
||||||
|
const int sizes[] = { 10, 15, 20, 32, 66 };
|
||||||
|
static_assert( sizeof( sizes ) / sizeof( sizes[ 0 ] ) == HugeFont );
|
||||||
|
|
||||||
QFont font( family, -1, weight, italic );
|
QFont font( family, -1, weight, italic );
|
||||||
|
|
||||||
const uint base = TinyFont;
|
|
||||||
for ( int i = TinyFont; i <= HugeFont; i++ )
|
for ( int i = TinyFont; i <= HugeFont; i++ )
|
||||||
{
|
{
|
||||||
// TODO: make the scaling components configurable
|
font.setPixelSize( qskDpiScaled( sizes[i-1] ) );
|
||||||
font.setPixelSize( int( std::pow( uint( i ) - base + 2, 2.5 ) ) );
|
|
||||||
m_data->fonts[ i ] = font;
|
m_data->fonts[ i ] = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "SkinnyFont.h"
|
|
||||||
|
|
||||||
#include <QFontDatabase>
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QElapsedTimer>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
|
||||||
#define STRING(x) STRINGIFY(x)
|
|
||||||
|
|
||||||
void SkinnyFont::init( QGuiApplication* )
|
|
||||||
{
|
|
||||||
#ifdef FONTCONFIG_FILE
|
|
||||||
const char env[] = "FONTCONFIG_FILE";
|
|
||||||
if ( !qEnvironmentVariableIsSet( env ) )
|
|
||||||
qputenv( env, STRING( FONTCONFIG_FILE ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QElapsedTimer timer;
|
|
||||||
timer.start();
|
|
||||||
|
|
||||||
QFontDatabase();
|
|
||||||
|
|
||||||
const auto elapsed = timer.elapsed();
|
|
||||||
|
|
||||||
if ( elapsed > 20 )
|
|
||||||
{
|
|
||||||
qWarning() << "Loading fonts needed" << elapsed << "ms"
|
|
||||||
<< "- usually because of creating a font cache.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
The default initialization in QskSkin sets up its font table
|
|
||||||
with using the application font for the default font role.
|
|
||||||
*/
|
|
||||||
QGuiApplication::setFont( QFont( "DejaVuSans", 12 ) );
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,23 +3,20 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SKINNY_GLOBAL_H
|
#pragma once
|
||||||
#define SKINNY_GLOBAL_H
|
|
||||||
|
|
||||||
#include <QskGlobal.h>
|
#include <QskGlobal.h>
|
||||||
|
|
||||||
#ifdef QSK_DLL
|
#ifdef QSK_DLL
|
||||||
|
|
||||||
#if defined( SKINNY_MAKEDLL ) // create a DLL library
|
#if defined( SKINNY_MAKEDLL ) // create a DLL library
|
||||||
#define SKINNY_EXPORT Q_DECL_EXPORT
|
#define SKINNY_EXPORT Q_DECL_EXPORT
|
||||||
#else // use a DLL library
|
#else // use a DLL library
|
||||||
#define SKINNY_EXPORT Q_DECL_IMPORT
|
#define SKINNY_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // QSK_DLL
|
#endif // QSK_DLL
|
||||||
|
|
||||||
#ifndef SKINNY_EXPORT
|
#ifndef SKINNY_EXPORT
|
||||||
#define SKINNY_EXPORT
|
#define SKINNY_EXPORT
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "SkinnyNamespace.h"
|
||||||
|
|
||||||
|
#include <QskSetup.h>
|
||||||
|
#include <QskSkinManager.h>
|
||||||
|
#include <QskSkin.h>
|
||||||
|
#include <QskSkinTransition.h>
|
||||||
|
#include <QskAnimationHint.h>
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#define STRINGIFY(x) #x
|
||||||
|
#define STRING(x) STRINGIFY(x)
|
||||||
|
|
||||||
|
#if defined( ENSURE_SKINS )
|
||||||
|
|
||||||
|
#include <squiek/QskSquiekSkinFactory.h>
|
||||||
|
#include <material/QskMaterialSkinFactory.h>
|
||||||
|
|
||||||
|
static void initSkins()
|
||||||
|
{
|
||||||
|
if ( qskSkinManager->skinNames().isEmpty() )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
To avoid having problems with not finding the skin plugins
|
||||||
|
we manually add them here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
qskSkinManager->registerFactory( "SquiekFactory", new QskSquiekSkinFactory() );
|
||||||
|
qskSkinManager->registerFactory( "MaterialFactory", new QskMaterialSkinFactory() );
|
||||||
|
|
||||||
|
qWarning() << "Couldn't find skin plugins, adding some manually.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_COREAPP_STARTUP_FUNCTION( initSkins )
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ENSURE_FONTS
|
||||||
|
|
||||||
|
#if defined( ENSURE_FONTS )
|
||||||
|
|
||||||
|
#include <QFontDatabase>
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
|
static void initFonts()
|
||||||
|
{
|
||||||
|
#ifdef FONTCONFIG_FILE
|
||||||
|
const char env[] = "FONTCONFIG_FILE";
|
||||||
|
if ( !qEnvironmentVariableIsSet( env ) )
|
||||||
|
qputenv( env, STRING( FONTCONFIG_FILE ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QElapsedTimer timer;
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
QFontDatabase();
|
||||||
|
|
||||||
|
const auto elapsed = timer.elapsed();
|
||||||
|
|
||||||
|
if ( elapsed > 20 )
|
||||||
|
{
|
||||||
|
qWarning() << "Loading fonts needed" << elapsed << "ms"
|
||||||
|
<< "- usually because of creating a font cache.";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The default initialization in QskSkin sets up its font table
|
||||||
|
with using the application font for the default font role.
|
||||||
|
*/
|
||||||
|
QGuiApplication::setFont( QFont( "DejaVuSans", 12 ) );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_COREAPP_STARTUP_FUNCTION( initFonts )
|
||||||
|
|
||||||
|
void Skinny::changeSkin( QskAnimationHint hint )
|
||||||
|
{
|
||||||
|
const auto names = qskSkinManager->skinNames();
|
||||||
|
if ( names.size() <= 1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int index = names.indexOf( qskSetup->skinName() );
|
||||||
|
index = ( index + 1 ) % names.size();
|
||||||
|
|
||||||
|
auto oldSkin = qskSetup->skin();
|
||||||
|
if ( oldSkin->parent() == qskSetup )
|
||||||
|
oldSkin->setParent( nullptr ); // otherwise setSkin deletes it
|
||||||
|
|
||||||
|
if ( auto newSkin = qskSetup->setSkin( names[ index ] ) )
|
||||||
|
{
|
||||||
|
QskSkinTransition transition;
|
||||||
|
|
||||||
|
//transition.setMask( QskAspect::Color ); // Metrics are flickering -> TODO
|
||||||
|
transition.setSourceSkin( oldSkin );
|
||||||
|
transition.setTargetSkin( newSkin );
|
||||||
|
transition.setAnimation( hint );
|
||||||
|
|
||||||
|
transition.process();
|
||||||
|
|
||||||
|
if ( oldSkin->parent() == nullptr )
|
||||||
|
delete oldSkin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Skinny::changeFonts( int increment )
|
||||||
|
{
|
||||||
|
auto skin = qskSetup->skin();
|
||||||
|
|
||||||
|
const auto fonts = skin->fonts();
|
||||||
|
|
||||||
|
for ( auto it = fonts.begin(); it != fonts.end(); ++it )
|
||||||
|
{
|
||||||
|
auto role = it->first;
|
||||||
|
auto font = it->second;
|
||||||
|
|
||||||
|
if ( font.pixelSize() > 0 )
|
||||||
|
{
|
||||||
|
const auto newSize = font.pixelSize() + increment;
|
||||||
|
if ( newSize > 0 )
|
||||||
|
font.setPixelSize( newSize );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto newSize = font.pointSizeF() + increment;
|
||||||
|
if ( newSize > 0 )
|
||||||
|
font.setPointSizeF( font.pointSizeF() + increment );
|
||||||
|
}
|
||||||
|
|
||||||
|
skin->setFont( role, font );
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EMIT qskSetup->skinChanged( skin );
|
||||||
|
}
|
|
@ -3,16 +3,13 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SKINNY_FONT_H_
|
#pragma once
|
||||||
#define SKINNY_FONT_H_
|
|
||||||
|
|
||||||
#include "SkinnyGlobal.h"
|
#include "SkinnyGlobal.h"
|
||||||
|
#include <QskAnimationHint.h>
|
||||||
|
|
||||||
class QGuiApplication;
|
namespace Skinny
|
||||||
|
|
||||||
namespace SkinnyFont
|
|
||||||
{
|
{
|
||||||
SKINNY_EXPORT void init( QGuiApplication* );
|
SKINNY_EXPORT void changeSkin( QskAnimationHint hint = 500 );
|
||||||
|
SKINNY_EXPORT void changeFonts( int increment );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -3,8 +3,7 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SKINNY_SHAPE_FACTORY_H_
|
#pragma once
|
||||||
#define SKINNY_SHAPE_FACTORY_H_
|
|
||||||
|
|
||||||
#include "SkinnyGlobal.h"
|
#include "SkinnyGlobal.h"
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
@ -32,5 +31,3 @@ namespace SkinnyShapeFactory
|
||||||
|
|
||||||
SKINNY_EXPORT QPainterPath shapePath( Shape, const QSizeF& );
|
SKINNY_EXPORT QPainterPath shapePath( Shape, const QSizeF& );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SKINNY_SHAPE_PROVIDER_H
|
#pragma once
|
||||||
#define SKINNY_SHAPE_PROVIDER_H
|
|
||||||
|
|
||||||
#include "SkinnyGlobal.h"
|
#include "SkinnyGlobal.h"
|
||||||
#include <QskGraphicProvider.h>
|
#include <QskGraphicProvider.h>
|
||||||
|
@ -15,5 +14,3 @@ class SKINNY_EXPORT SkinnyShapeProvider : public QskGraphicProvider
|
||||||
const QskGraphic* loadGraphic( const QString& id ) const override final;
|
const QskGraphic* loadGraphic( const QString& id ) const override final;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#include "SkinnyShortcut.h"
|
#include "SkinnyShortcut.h"
|
||||||
|
#include "SkinnyNamespace.h"
|
||||||
|
|
||||||
#include <QskShortcutMap.h>
|
#include <QskShortcutMap.h>
|
||||||
#include <QskSetup.h>
|
#include <QskSetup.h>
|
||||||
#include <QskSkinManager.h>
|
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
#include <QskAspect.h>
|
|
||||||
#include <QskSkin.h>
|
|
||||||
#include <QskControl.h>
|
#include <QskControl.h>
|
||||||
#include <QskQuick.h>
|
#include <QskQuick.h>
|
||||||
#include <QskAnimationHint.h>
|
|
||||||
#include <QskSkinTransition.h>
|
|
||||||
|
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
@ -17,7 +13,6 @@
|
||||||
#include <QSGNode>
|
#include <QSGNode>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
SkinnyShortcut::SkinnyShortcut( QObject* parent ):
|
SkinnyShortcut::SkinnyShortcut( QObject* parent ):
|
||||||
|
@ -34,17 +29,17 @@ void SkinnyShortcut::enable( Types types )
|
||||||
if ( types & RotateSkin )
|
if ( types & RotateSkin )
|
||||||
{
|
{
|
||||||
QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL | Qt::Key_S ),
|
QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL | Qt::Key_S ),
|
||||||
false, &s_shortcut, &SkinnyShortcut::rotateSkin );
|
false, &s_shortcut, [] { Skinny::changeSkin(); } );
|
||||||
cout << "CTRL-S to change the skin." << endl;
|
cout << "CTRL-S to change the skin." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( types & ChangeFonts )
|
if ( types & ChangeFonts )
|
||||||
{
|
{
|
||||||
QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL | Qt::Key_F ),
|
QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL | Qt::Key_F ),
|
||||||
false, &s_shortcut, [] { s_shortcut.changeFonts( +1 ); } );
|
false, &s_shortcut, [] { Skinny::changeFonts( +1 ); } );
|
||||||
|
|
||||||
QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL | Qt::Key_G ),
|
QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL | Qt::Key_G ),
|
||||||
false, &s_shortcut, [] { s_shortcut.changeFonts( -1 ); } );
|
false, &s_shortcut, [] { Skinny::changeFonts( -1 ); } );
|
||||||
|
|
||||||
cout << "CTRL-F to increase the font size." << endl;
|
cout << "CTRL-F to increase the font size." << endl;
|
||||||
cout << "CTRL-G to decrease the font size." << endl;
|
cout << "CTRL-G to decrease the font size." << endl;
|
||||||
|
@ -75,35 +70,6 @@ void SkinnyShortcut::enable( Types types )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinnyShortcut::rotateSkin()
|
|
||||||
{
|
|
||||||
const auto names = qskSkinManager->skinNames();
|
|
||||||
if ( names.size() <= 1 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
int index = names.indexOf( qskSetup->skinName() );
|
|
||||||
index = ( index + 1 ) % names.size();
|
|
||||||
|
|
||||||
auto oldSkin = qskSetup->skin();
|
|
||||||
if ( oldSkin->parent() == qskSetup )
|
|
||||||
oldSkin->setParent( nullptr ); // otherwise setSkin deletes it
|
|
||||||
|
|
||||||
if ( auto newSkin = qskSetup->setSkin( names[ index ] ) )
|
|
||||||
{
|
|
||||||
QskSkinTransition transition;
|
|
||||||
|
|
||||||
//transition.setMask( QskAspect::Color ); // Metrics are flickering -> TODO
|
|
||||||
transition.setSourceSkin( oldSkin );
|
|
||||||
transition.setTargetSkin( newSkin );
|
|
||||||
transition.setAnimation( 500 );
|
|
||||||
|
|
||||||
transition.process();
|
|
||||||
|
|
||||||
if ( oldSkin->parent() == nullptr )
|
|
||||||
delete oldSkin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkinnyShortcut::showBackground()
|
void SkinnyShortcut::showBackground()
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -149,36 +115,6 @@ void SkinnyShortcut::showBackground()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinnyShortcut::changeFonts( int increment )
|
|
||||||
{
|
|
||||||
auto skin = qskSetup->skin();
|
|
||||||
|
|
||||||
const auto fonts = skin->fonts();
|
|
||||||
|
|
||||||
for ( auto it = fonts.begin(); it != fonts.end(); ++it )
|
|
||||||
{
|
|
||||||
auto role = it->first;
|
|
||||||
auto font = it->second;
|
|
||||||
|
|
||||||
if ( font.pixelSize() > 0 )
|
|
||||||
{
|
|
||||||
const auto newSize = font.pixelSize() + increment;
|
|
||||||
if ( newSize > 0 )
|
|
||||||
font.setPixelSize( newSize );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto newSize = font.pointSizeF() + increment;
|
|
||||||
if ( newSize > 0 )
|
|
||||||
font.setPointSizeF( font.pointSizeF() + increment );
|
|
||||||
}
|
|
||||||
|
|
||||||
skin->setFont( role, font );
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EMIT qskSetup->skinChanged( skin );
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void countNodes( const QSGNode* node, int& counter )
|
static inline void countNodes( const QSGNode* node, int& counter )
|
||||||
{
|
{
|
||||||
if ( node )
|
if ( node )
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SKINNY_SHORTCUT_H_
|
#pragma once
|
||||||
#define SKINNY_SHORTCUT_H_
|
|
||||||
|
|
||||||
#include "SkinnyGlobal.h"
|
#include "SkinnyGlobal.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -34,12 +33,8 @@ class SKINNY_EXPORT SkinnyShortcut : public QObject
|
||||||
private:
|
private:
|
||||||
SkinnyShortcut( QObject* parent = nullptr );
|
SkinnyShortcut( QObject* parent = nullptr );
|
||||||
|
|
||||||
void rotateSkin();
|
|
||||||
void changeFonts( int increment );
|
|
||||||
void showBackground();
|
void showBackground();
|
||||||
void debugStatistics();
|
void debugStatistics();
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS( SkinnyShortcut::Types )
|
Q_DECLARE_OPERATORS_FOR_FLAGS( SkinnyShortcut::Types )
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ contains(QSK_CONFIG, QskDll): DEFINES += SKINNY_MAKEDLL
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
SkinnyGlobal.h \
|
SkinnyGlobal.h \
|
||||||
SkinnyFont.h \
|
SkinnyNamespace.h \
|
||||||
SkinnyShapeFactory.h \
|
SkinnyShapeFactory.h \
|
||||||
SkinnyShapeProvider.h \
|
SkinnyShapeProvider.h \
|
||||||
SkinnyShortcut.h
|
SkinnyShortcut.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
SkinnyFont.cpp \
|
SkinnyNamespace.cpp \
|
||||||
SkinnyPlugin.cpp \
|
SkinnyPlugin.cpp \
|
||||||
SkinnyShapeFactory.cpp \
|
SkinnyShapeFactory.cpp \
|
||||||
SkinnyShapeProvider.cpp \
|
SkinnyShapeProvider.cpp \
|
||||||
|
|
Loading…
Reference in New Issue