messagebox/messageboxQml examples moved to gallery

This commit is contained in:
Uwe Rathmann 2023-07-03 16:48:37 +02:00
parent 9550ca62fc
commit 2911aaf88a
8 changed files with 84 additions and 411 deletions

View File

@ -6,7 +6,6 @@
add_subdirectory(desktop)
add_subdirectory(gallery)
add_subdirectory(layouts)
add_subdirectory(messagebox)
add_subdirectory(mycontrols)
add_subdirectory(qvgviewer)
add_subdirectory(thumbnails)
@ -18,5 +17,4 @@ if( BUILD_QML_EXPORT )
add_subdirectory(buttons)
add_subdirectory(frames)
add_subdirectory(glabels)
add_subdirectory(messageboxQml)
endif()

View File

@ -15,80 +15,106 @@ namespace
{
class Button : public QskPushButton
{
Q_OBJECT
public:
enum ButtonType
Button( const QString& text, QQuickItem* parent = nullptr )
: QskPushButton( text, parent )
{
Message,
Information,
Warning,
Critical,
}
};
Question,
Selection,
TypeCount
};
Q_ENUM( ButtonType )
Button( ButtonType type, QQuickItem* parent = nullptr )
: QskPushButton( parent )
, m_type( type )
class ButtonBox : public QskLinearBox
{
public:
ButtonBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, 2, parent )
{
setShape( 10 );
initSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Fixed );
setObjectName( "ButtonBox" );
const int index = metaObject()->indexOfEnumerator( "ButtonType" );
setText( metaObject()->enumerator( index ).key( m_type ) );
setMargins( 10 );
setSpacing( 20 );
connect( this, &QskPushButton::clicked, this, &Button::showDialog );
auto messageButton = new Button( "Message", this );
connect( messageButton, &Button::clicked, this, &ButtonBox::execMessage );
auto informationButton = new Button( "Information", this );
connect( informationButton, &Button::clicked, this, &ButtonBox::execInformation );
auto questionButton = new Button( "Question", this );
connect( questionButton, &Button::clicked, this, &ButtonBox::execQuestion );
auto warningButton = new Button( "Warning", this );
connect( warningButton, &Button::clicked, this, &ButtonBox::execWarning );
auto criticalButton = new Button( "Critical", this );
connect( criticalButton, &Button::clicked, this, &ButtonBox::execCritical );
auto selectButton = new Button( "Selection", this );
connect( selectButton, &Button::clicked, this, &ButtonBox::execSelection );
setExtraSpacingAt( Qt::BottomEdge );
}
private:
void showDialog()
void execMessage()
{
switch( static_cast< int >( m_type ) )
{
case Message:
qskDialog->message( text(), text(), QskStandardSymbol::Ok );
break;
case Information:
qskDialog->information( text(), text() );
break;
case Warning:
qskDialog->warning( text(), text() );
break;
case Critical:
qskDialog->critical( text(), text() );
break;
case Question:
qskDialog->question( text(), text() );
break;
case Selection:
qskDialog->select( text(), text(), { "yes", "no", "maybe" } );
break;
}
qskDialog->message( "Message", "Request vector, over.",
QskStandardSymbol::NoSymbol, QskDialog::Close );
}
const ButtonType m_type;
void execInformation()
{
qskDialog->information( "Information",
"We have clearance, Clarence." );
}
void execQuestion()
{
qskDialog->question( "Question",
"Roger, Roger. Do we have a vector, Victor ?" );
}
void execWarning()
{
qskDialog->warning( "Warning", "We have clearance, Clarence." );
}
void execCritical()
{
qskDialog->critical( "Critical", "That's Clarence Oveur. Over." );
}
void execSelection()
{
// of course we all love "The Teens"
const QStringList entries =
{
"Give Me More",
"Gimme Gimme Your Love",
"1-2-3-4 Red Light",
"New York",
"If You Walk Away",
"Eloise",
"On The Radio",
"We Are The Teens",
"Never Gonna Tell No Lie To You",
"Walking On Sunshine ",
"Get Out Of My Mind",
"Cover Girl ",
"Here I Stand",
"Gypsy Caravan",
"It´s Good To Have A Friend",
"We´ll Have A Party Tonite ´nite",
"Automatic World",
"Gimme Gimme Gimme Gimme Gimme Your Love"
};
qskDialog->select( "Here we go ...", "Hot Hot Hot", entries, 7 );
}
};
}
DialogPage::DialogPage( QQuickItem* parent )
: Page( Qt::Horizontal, parent )
{
auto box = new QskLinearBox( Qt::Horizontal, 2, this );
box->setSpacing( 20 );
box->setExtraSpacingAt( Qt::BottomEdge );
for ( int i = 0; i < Button::TypeCount; i++ )
new Button( static_cast< Button::ButtonType >( i ), box );
( void ) new ButtonBox( this );
}
#include "DialogPage.moc"

View File

@ -1,6 +0,0 @@
############################################################################
# QSkinny - Copyright (C) 2016 Uwe Rathmann
# SPDX-License-Identifier: BSD-3-Clause
############################################################################
qsk_add_example(messagebox main.cpp)

View File

@ -1,155 +0,0 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/
#include <SkinnyShortcut.h>
#include <QFontDatabase>
#include <QGuiApplication>
#include <QskAspect.h>
#include <QskDialog.h>
#include <QskFocusIndicator.h>
#include <QskLinearBox.h>
#include <QskObjectCounter.h>
#include <QskPushButton.h>
#include <QskStandardSymbol.h>
#include <QskWindow.h>
class Button : public QskPushButton
{
public:
Button( const QString& text, QQuickItem* parent = nullptr )
: QskPushButton( text, parent )
{
setObjectName( text );
setSizePolicy( QskSizePolicy::MinimumExpanding,
QskSizePolicy::MinimumExpanding );
}
};
class ButtonBox : public QskLinearBox
{
public:
ButtonBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, 2, parent )
{
setObjectName( "ButtonBox" );
setMargins( 10 );
setSpacing( 5 );
Button* messageButton = new Button( "Message", this );
connect( messageButton, &Button::clicked, this, &ButtonBox::execMessage );
Button* informationButton = new Button( "Information", this );
connect( informationButton, &Button::clicked, this, &ButtonBox::execInformation );
Button* questionButton = new Button( "Question", this );
connect( questionButton, &Button::clicked, this, &ButtonBox::execQuestion );
Button* warningButton = new Button( "Warning", this );
connect( warningButton, &Button::clicked, this, &ButtonBox::execWarning );
Button* criticalButton = new Button( "Critical", this );
connect( criticalButton, &Button::clicked, this, &ButtonBox::execCritical );
Button* selectButton = new Button( "Selection", this );
connect( selectButton, &Button::clicked, this, &ButtonBox::execSelection );
}
private:
void execMessage()
{
qDebug() << qskDialog->message( "Message", "Request vector, over.",
QskStandardSymbol::NoSymbol, QskDialog::Close );
}
void execInformation()
{
qDebug() << qskDialog->information( "Information",
"We have clearance, Clarence." );
}
void execQuestion()
{
qDebug() << qskDialog->question( "Question",
"Roger, Roger. Do we have a vector, Victor ?" );
}
void execWarning()
{
qDebug() << qskDialog->warning( "Warning", "We have clearance, Clarence." );
}
void execCritical()
{
qDebug() << qskDialog->critical( "Critical", "That's Clarence Oveur. Over." );
}
void execSelection()
{
// of course we all love "The Teens"
const QStringList entries =
{
"Give Me More",
"Gimme Gimme Your Love",
"1-2-3-4 Red Light",
"New York",
"If You Walk Away",
"Eloise",
"On The Radio",
"We Are The Teens",
"Never Gonna Tell No Lie To You",
"Walking On Sunshine ",
"Get Out Of My Mind",
"Cover Girl ",
"Here I Stand",
"Gypsy Caravan",
"It´s Good To Have A Friend",
"We´ll Have A Party Tonite ´nite",
"Automatic World",
"Gimme Gimme Gimme Gimme Gimme Your Love"
};
qDebug() << qskDialog->select( "Here we go ...", "Hot Hot Hot", entries, 7 );
}
};
int main( int argc, char* argv[] )
{
#ifdef ITEM_STATISTICS
QskObjectCounter counter( true );
#endif
QGuiApplication app( argc, argv );
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
qskDialog->setPolicy( QskDialog::EmbeddedBox );
auto box = new ButtonBox();
/*
To avoid losing the focus, when a message box is executed
we have to define the "main window" ( here a ButtonBox ) to
be a focusScope.
*/
box->setFlag( QQuickItem::ItemIsFocusScope, true );
box->setTabFence( true );
box->setFocusPolicy( Qt::TabFocus );
// setting the initial focus
box->itemAtIndex( 0 )->setFocus( true );
box->setFocus( true );
QskWindow window;
window.addItem( box );
window.addItem( new QskFocusIndicator() );
window.resize( 800, 800 );
window.show();
return app.exec();
}

View File

@ -1,9 +0,0 @@
############################################################################
# QSkinny - Copyright (C) 2016 Uwe Rathmann
# SPDX-License-Identifier: BSD-3-Clause
############################################################################
set(SOURCES main.cpp)
qt_add_resources(SOURCES messagebox.qrc)
qsk_add_example(messageboxQml ${SOURCES})

View File

@ -1,29 +0,0 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/
#include <SkinnyShortcut.h>
#include <QskQml.h>
#include <QskObjectCounter.h>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main( int argc, char* argv[] )
{
#ifdef ITEM_STATISTICS
QskObjectCounter counter( true );
#endif
QskQml::registerTypes();
QGuiApplication app( argc, argv );
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
QQmlApplicationEngine engine( QUrl( "qrc:/qml/messagebox.qml" ) );
return app.exec();
}

View File

@ -1,147 +0,0 @@
import QtQuick 2.0
import Skinny 1.0 as Qsk
import "qrc:/qml"
Qsk.Window
{
id: window
visible: true
width: 600
height: 400
// color: "Beige"
Qsk.LinearBox
{
orientation: Qt.Horizontal
dimension: 2
margins { left: 10; top: 10; right: 10; bottom: 10 }
//margins: 10
Qsk.PushButton
{
id: messageButton
text: "Message"
focus: true
sizePolicy.vertical: Qsk.SizePolicy.MinimumExpanding
onClicked:
{
var answer = Qsk.Dialog.message(
"Message", "Request vector, over.",
Qsk.StandardSymbol.NoSymbol, Qsk.Dialog.Close
);
}
}
Qsk.PushButton
{
id: informationButton
text: "Information"
sizePolicy.vertical: Qsk.SizePolicy.MinimumExpanding
onClicked:
{
var answer = Qsk.Dialog.information(
"Information", "We have clearance, Clarence."
);
}
}
Qsk.PushButton
{
id: questionButton
text: "Question"
sizePolicy.vertical: Qsk.SizePolicy.MinimumExpanding
onClicked:
{
var answer = Qsk.Dialog.question(
"Question", "Roger, Roger. Do we have a vector, Victor ?",
Qsk.Dialog.Yes | Qsk.Dialog.No
)
if ( answer == Qsk.Dialog.Yes )
console.log( "Yes" )
else
console.log( "No" )
}
}
Qsk.PushButton
{
id: warningButton
text: "Warning"
sizePolicy.vertical: Qsk.SizePolicy.MinimumExpanding
onClicked:
{
var answer = Qsk.Dialog.warning(
"Warning", "We have clearance, Clarence."
)
}
}
Qsk.PushButton
{
id: criticalButton
text: "Critical"
sizePolicy.vertical: Qsk.SizePolicy.MinimumExpanding
onClicked:
{
var answer = Qsk.Dialog.critical(
"Critical", "That's Clarence Oveur. Over."
);
}
}
Qsk.PushButton
{
id: selectionButton
text: "Selection"
sizePolicy.vertical: Qsk.SizePolicy.MinimumExpanding
onClicked:
{
var hotTracks = [
"Give Me More",
"Gimme Gimme Your Love",
"1-2-3-4 Red Light",
"New York",
"If You Walk Away",
"Eloise",
"On The Radio",
"We Are The Teens",
"Never Gonna Tell No Lie To You",
"Walking On Sunshine ",
"Get Out Of My Mind",
"Cover Girl ",
"Here I Stand",
"Gypsy Caravan",
"It´s Good To Have A Friend",
"We´ll Have A Party Tonite ´nite",
"Automatic World",
"Gimme Gimme Gimme Gimme Gimme Your Love"
]
var hottestTrackEver = Qsk.Dialog.select(
"Here we go ...", "Hot Hot Hot", hotTracks, 7 )
console.log( hottestTrackEver )
}
}
}
Qsk.FocusIndicator
{
}
}

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/qml">
<file>messagebox.qml</file>
</qresource>
</RCC>