diff --git a/examples/gallery/main.cpp b/examples/gallery/main.cpp index 7123fe62..5a466641 100644 --- a/examples/gallery/main.cpp +++ b/examples/gallery/main.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -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 Header/ApplicationWindow with it. TODO ... @@ -70,6 +98,10 @@ namespace [] { Skinny::changeSkin( 500 ); } ); } + { + new MenuButton( "Menu", this ); + } + addStretch( 10 ); { diff --git a/examples/qvgviewer/MainWindow.cpp b/examples/qvgviewer/MainWindow.cpp index e78a1a79..bc379584 100644 --- a/examples/qvgviewer/MainWindow.cpp +++ b/examples/qvgviewer/MainWindow.cpp @@ -20,11 +20,6 @@ #include #include -#ifdef CONTEXT_MENU - #include - #include -#endif - #include #include @@ -46,10 +41,6 @@ class GraphicLabel : public QskGraphicLabel setBoxShapeHint( Panel, 8 ); setAlignment( Qt::AlignCenter ); setDarknessMode( false ); - -#ifdef CONTEXT_MENU - setAcceptedMouseButtons( Qt::LeftButton ); -#endif } void setDarknessMode( bool on ) @@ -80,27 +71,6 @@ class GraphicLabel : public QskGraphicLabel startTransition( QskGraphicLabel::Graphic | QskAspect::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() diff --git a/examples/qvgviewer/main.cpp b/examples/qvgviewer/main.cpp index 31d62caa..458709e1 100644 --- a/examples/qvgviewer/main.cpp +++ b/examples/qvgviewer/main.cpp @@ -7,10 +7,6 @@ #include -#ifdef CONTEXT_MENU - #include -#endif - #include #include @@ -22,10 +18,6 @@ int main( int argc, char* argv[] ) QskObjectCounter counter( true ); #endif -#ifdef CONTEXT_MENU - Qsk::addGraphicProvider( "shapes", new SkinnyShapeProvider() ); -#endif - QGuiApplication app( argc, argv ); SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts ); diff --git a/examples/qvgviewer/qvgviewer.pro b/examples/qvgviewer/qvgviewer.pro index ece321d1..d2c05ec5 100644 --- a/examples/qvgviewer/qvgviewer.pro +++ b/examples/qvgviewer/qvgviewer.pro @@ -1,5 +1,4 @@ CONFIG += qskexample -DEFINES += CONTEXT_MENU HEADERS += \ MainWindow.h diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index e48e5907..704db760 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ namespace void setupInputPanel(); void setupVirtualKeyboard(); void setupListView(); + void setupMenu(); void setupPageIndicator(); void setupPopup(); void setupProgressBar(); @@ -104,6 +106,7 @@ void Editor::setup() setupInputPanel(); setupVirtualKeyboard(); setupListView(); + setupMenu(); setupPageIndicator(); setupPopup(); setupProgressBar(); @@ -177,6 +180,45 @@ void Editor::setupPopup() 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() { using Q = QskTextLabel; diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 035ddb31..e1643987 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -331,11 +331,11 @@ void Editor::setupMenu() using A = QskAspect; using Q = QskMenu; - const QColor c1( 78, 158, 38 ); - const QColor c2( 15, 103, 43 ); + setBoxShape( Q::Panel, qskDpiScaled( 4 ) ); + setBoxBorderMetrics( Q::Panel, qskDpiScaled( 1 ) ); + setBoxBorderColors( Q::Panel, m_pal.darker125 ); - setBoxShape( Q::Panel, 4 ); - setVGradient( Q::Panel, c1, c2 ); + setGradient( Q::Panel, m_pal.lighter110 ); const bool isCascading = qskMaybeDesktopPlatform(); setFlagHint( Q::Panel | A::Style, isCascading ); @@ -343,16 +343,17 @@ void Editor::setupMenu() #if 0 setPadding( Q::Separator, QMarginsF( 10, 0, 10, 0 ) ); #endif - setMetric( Q::Separator | A::Size, 2 ); + setMetric( Q::Separator | A::Size, qskDpiScaled( 2 ) ); setSeparator( Q::Separator | A::Horizontal ); setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) ); setSpacing( Q::Cell, 5 ); 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 ); setPosition( Q::Panel, 0 ); diff --git a/src/controls/QskMenu.cpp b/src/controls/QskMenu.cpp index 0cff4321..9c1389f9 100644 --- a/src/controls/QskMenu.cpp +++ b/src/controls/QskMenu.cpp @@ -37,6 +37,11 @@ namespace QString text; 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 { return flagHint( QskMenu::Panel | QskAspect::Style ); @@ -92,6 +100,8 @@ void QskMenu::resetCascading() Q_EMIT cascadingChanged( isCascading() ); } +#endif + void QskMenu::setOrigin( const QPointF& origin ) { if ( origin != m_data->origin )