Merge branch 'master' into material-theme
This commit is contained in:
commit
1ce1188f4b
@ -18,6 +18,7 @@
|
|||||||
#include <QskTextLabel.h>
|
#include <QskTextLabel.h>
|
||||||
#include <QskSwitchButton.h>
|
#include <QskSwitchButton.h>
|
||||||
#include <QskPushButton.h>
|
#include <QskPushButton.h>
|
||||||
|
#include <QskMenu.h>
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
@ -42,6 +43,33 @@ namespace
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MenuButton : public QskPushButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MenuButton( const QString& text, QQuickItem* parent = nullptr )
|
||||||
|
: QskPushButton( text, parent )
|
||||||
|
{
|
||||||
|
setFlat( true ); // until we have the section bit in QskAspect
|
||||||
|
|
||||||
|
connect( this, &QskPushButton::pressed, this, &MenuButton::openMenu );
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void openMenu()
|
||||||
|
{
|
||||||
|
auto menu = new QskMenu( window()->contentItem() );
|
||||||
|
|
||||||
|
menu->addOption( "image://shapes/Rectangle/White", "Print" );
|
||||||
|
menu->addOption( "image://shapes/Diamond/Yellow", "Save As" );
|
||||||
|
menu->addOption( "image://shapes/Ellipse/Red", "Setup" );
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addOption( "image://shapes/Hexagon/PapayaWhip", "Help" );
|
||||||
|
|
||||||
|
menu->setOrigin( geometry().bottomLeft() );
|
||||||
|
menu->open();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Once QskApplicationView and friends are implemented we can replace
|
Once QskApplicationView and friends are implemented we can replace
|
||||||
Header/ApplicationWindow with it. TODO ...
|
Header/ApplicationWindow with it. TODO ...
|
||||||
@ -70,6 +98,10 @@ namespace
|
|||||||
[] { Skinny::changeSkin( 500 ); } );
|
[] { Skinny::changeSkin( 500 ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
new MenuButton( "Menu", this );
|
||||||
|
}
|
||||||
|
|
||||||
addStretch( 10 );
|
addStretch( 10 );
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -20,11 +20,6 @@
|
|||||||
#include <QskTabView.h>
|
#include <QskTabView.h>
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
|
|
||||||
#ifdef CONTEXT_MENU
|
|
||||||
#include <QskMenu.h>
|
|
||||||
#include <QskEvent.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@ -46,10 +41,6 @@ class GraphicLabel : public QskGraphicLabel
|
|||||||
setBoxShapeHint( Panel, 8 );
|
setBoxShapeHint( Panel, 8 );
|
||||||
setAlignment( Qt::AlignCenter );
|
setAlignment( Qt::AlignCenter );
|
||||||
setDarknessMode( false );
|
setDarknessMode( false );
|
||||||
|
|
||||||
#ifdef CONTEXT_MENU
|
|
||||||
setAcceptedMouseButtons( Qt::LeftButton );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDarknessMode( bool on )
|
void setDarknessMode( bool on )
|
||||||
@ -80,27 +71,6 @@ class GraphicLabel : public QskGraphicLabel
|
|||||||
startTransition( QskGraphicLabel::Graphic | QskAspect::GraphicRole,
|
startTransition( QskGraphicLabel::Graphic | QskAspect::GraphicRole,
|
||||||
duration, oldRole, graphicRole() );
|
duration, oldRole, graphicRole() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONTEXT_MENU
|
|
||||||
protected:
|
|
||||||
void mousePressEvent( QMouseEvent* event ) override
|
|
||||||
{
|
|
||||||
QskMenu menu( this );
|
|
||||||
menu.setPopupFlag( QskPopup::DeleteOnClose, false );
|
|
||||||
|
|
||||||
menu.addOption( "image://shapes/Rectangle/White", "Print" );
|
|
||||||
menu.addOption( "image://shapes/Diamond/Yellow", "Save As" );
|
|
||||||
menu.addOption( "image://shapes/Ellipse/Red", "Setup" );
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addOption( "image://shapes/Hexagon/PapayaWhip", "Help" );
|
|
||||||
|
|
||||||
menu.setOrigin( qskMousePosition( event ) );
|
|
||||||
|
|
||||||
const int result = menu.exec();
|
|
||||||
if ( result >= 0 )
|
|
||||||
qDebug() << "Selected:" << result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
|
@ -7,10 +7,6 @@
|
|||||||
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#ifdef CONTEXT_MENU
|
|
||||||
#include <SkinnyShapeProvider.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
#include <QskObjectCounter.h>
|
#include <QskObjectCounter.h>
|
||||||
|
|
||||||
@ -22,10 +18,6 @@ int main( int argc, char* argv[] )
|
|||||||
QskObjectCounter counter( true );
|
QskObjectCounter counter( true );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONTEXT_MENU
|
|
||||||
Qsk::addGraphicProvider( "shapes", new SkinnyShapeProvider() );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
CONFIG += qskexample
|
CONFIG += qskexample
|
||||||
DEFINES += CONTEXT_MENU
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
MainWindow.h
|
MainWindow.h
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
#include <QskInputPanelBox.h>
|
#include <QskInputPanelBox.h>
|
||||||
#include <QskListView.h>
|
#include <QskListView.h>
|
||||||
|
#include <QskMenu.h>
|
||||||
#include <QskPageIndicator.h>
|
#include <QskPageIndicator.h>
|
||||||
#include <QskPushButton.h>
|
#include <QskPushButton.h>
|
||||||
#include <QskProgressBar.h>
|
#include <QskProgressBar.h>
|
||||||
@ -72,6 +73,7 @@ namespace
|
|||||||
void setupInputPanel();
|
void setupInputPanel();
|
||||||
void setupVirtualKeyboard();
|
void setupVirtualKeyboard();
|
||||||
void setupListView();
|
void setupListView();
|
||||||
|
void setupMenu();
|
||||||
void setupPageIndicator();
|
void setupPageIndicator();
|
||||||
void setupPopup();
|
void setupPopup();
|
||||||
void setupProgressBar();
|
void setupProgressBar();
|
||||||
@ -104,6 +106,7 @@ void Editor::setup()
|
|||||||
setupInputPanel();
|
setupInputPanel();
|
||||||
setupVirtualKeyboard();
|
setupVirtualKeyboard();
|
||||||
setupListView();
|
setupListView();
|
||||||
|
setupMenu();
|
||||||
setupPageIndicator();
|
setupPageIndicator();
|
||||||
setupPopup();
|
setupPopup();
|
||||||
setupProgressBar();
|
setupProgressBar();
|
||||||
@ -177,6 +180,45 @@ void Editor::setupPopup()
|
|||||||
setGradient( Q::Overlay, gradient );
|
setGradient( Q::Overlay, gradient );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::setupMenu()
|
||||||
|
{
|
||||||
|
using A = QskAspect;
|
||||||
|
using Q = QskMenu;
|
||||||
|
|
||||||
|
setBoxShape( Q::Panel, qskDpiScaled( 4 ) );
|
||||||
|
setBoxBorderMetrics( Q::Panel, qskDpiScaled( 1 ) );
|
||||||
|
setBoxBorderColors( Q::Panel, m_pal.darker125 );
|
||||||
|
|
||||||
|
setGradient( Q::Panel, m_pal.baseColor );
|
||||||
|
|
||||||
|
const bool isCascading = qskMaybeDesktopPlatform();
|
||||||
|
setFlagHint( Q::Panel | A::Style, isCascading );
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
setPadding( Q::Separator, QMarginsF( 10, 0, 10, 0 ) );
|
||||||
|
#endif
|
||||||
|
setMetric( Q::Separator | A::Size, qskDpiScaled( 1 ) );
|
||||||
|
setBoxShape( Q::Separator, 0 );
|
||||||
|
setBoxBorderMetrics( Q::Separator, 0 );
|
||||||
|
setGradient( Q::Separator, m_pal.darker125 );
|
||||||
|
|
||||||
|
setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) );
|
||||||
|
setSpacing( Q::Cell, 5 );
|
||||||
|
setGradient( Q::Cell, Qt::transparent );
|
||||||
|
|
||||||
|
setGradient( Q::Cursor, m_pal.accentColor );
|
||||||
|
|
||||||
|
setColor( Q::Text, m_pal.textColor );
|
||||||
|
setColor( Q::Text | Q::Selected, m_pal.contrastColor );
|
||||||
|
setFontRole( Q::Text, QskSkin::SmallFont );
|
||||||
|
|
||||||
|
setPosition( Q::Panel, 0 );
|
||||||
|
setPosition( Q::Panel | QskPopup::Closed, 1 );
|
||||||
|
|
||||||
|
setAnimation( Q::Panel | A::Metric, 150 );
|
||||||
|
setAnimation( Q::Cursor | A::Position | A::Metric, 75, QEasingCurve::OutCubic );
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::setupTextLabel()
|
void Editor::setupTextLabel()
|
||||||
{
|
{
|
||||||
using Q = QskTextLabel;
|
using Q = QskTextLabel;
|
||||||
|
@ -331,11 +331,11 @@ void Editor::setupMenu()
|
|||||||
using A = QskAspect;
|
using A = QskAspect;
|
||||||
using Q = QskMenu;
|
using Q = QskMenu;
|
||||||
|
|
||||||
const QColor c1( 78, 158, 38 );
|
setBoxShape( Q::Panel, qskDpiScaled( 4 ) );
|
||||||
const QColor c2( 15, 103, 43 );
|
setBoxBorderMetrics( Q::Panel, qskDpiScaled( 1 ) );
|
||||||
|
setBoxBorderColors( Q::Panel, m_pal.darker125 );
|
||||||
|
|
||||||
setBoxShape( Q::Panel, 4 );
|
setGradient( Q::Panel, m_pal.lighter110 );
|
||||||
setVGradient( Q::Panel, c1, c2 );
|
|
||||||
|
|
||||||
const bool isCascading = qskMaybeDesktopPlatform();
|
const bool isCascading = qskMaybeDesktopPlatform();
|
||||||
setFlagHint( Q::Panel | A::Style, isCascading );
|
setFlagHint( Q::Panel | A::Style, isCascading );
|
||||||
@ -343,16 +343,17 @@ void Editor::setupMenu()
|
|||||||
#if 0
|
#if 0
|
||||||
setPadding( Q::Separator, QMarginsF( 10, 0, 10, 0 ) );
|
setPadding( Q::Separator, QMarginsF( 10, 0, 10, 0 ) );
|
||||||
#endif
|
#endif
|
||||||
setMetric( Q::Separator | A::Size, 2 );
|
setMetric( Q::Separator | A::Size, qskDpiScaled( 2 ) );
|
||||||
setSeparator( Q::Separator | A::Horizontal );
|
setSeparator( Q::Separator | A::Horizontal );
|
||||||
|
|
||||||
setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) );
|
setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) );
|
||||||
setSpacing( Q::Cell, 5 );
|
setSpacing( Q::Cell, 5 );
|
||||||
setGradient( Q::Cell, Qt::transparent );
|
setGradient( Q::Cell, Qt::transparent );
|
||||||
|
|
||||||
setHGradient( Q::Cursor, c2, c2.lighter( 2 ) );
|
setGradient( Q::Cursor, m_pal.highlighted );
|
||||||
|
|
||||||
setColor( Q::Text, QColor( 255, 255, 255 ) );
|
setColor( Q::Text, m_pal.contrastedText );
|
||||||
|
setColor( Q::Text | Q::Selected, m_pal.highlightedText );
|
||||||
setFontRole( Q::Text, QskSkin::SmallFont );
|
setFontRole( Q::Text, QskSkin::SmallFont );
|
||||||
|
|
||||||
setPosition( Q::Panel, 0 );
|
setPosition( Q::Panel, 0 );
|
||||||
|
@ -37,6 +37,11 @@ namespace
|
|||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
QskGraphic graphic;
|
QskGraphic graphic;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// TODO ...
|
||||||
|
bool isEnabled = true;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +80,9 @@ QskMenu::~QskMenu()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
// has no effect as we do not offer submenus yet. TODO ...
|
||||||
bool QskMenu::isCascading() const
|
bool QskMenu::isCascading() const
|
||||||
{
|
{
|
||||||
return flagHint( QskMenu::Panel | QskAspect::Style );
|
return flagHint( QskMenu::Panel | QskAspect::Style );
|
||||||
@ -92,6 +100,8 @@ void QskMenu::resetCascading()
|
|||||||
Q_EMIT cascadingChanged( isCascading() );
|
Q_EMIT cascadingChanged( isCascading() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void QskMenu::setOrigin( const QPointF& origin )
|
void QskMenu::setOrigin( const QPointF& origin )
|
||||||
{
|
{
|
||||||
if ( origin != m_data->origin )
|
if ( origin != m_data->origin )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user