QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsmodelgroupboxdefinitionwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelgroupboxdefinitionwidget.cpp
3 ------------------------------------------
4 begin : March 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
20
21#include "qgscolorbutton.h"
22#include "qgsgui.h"
23
24#include <QDialogButtonBox>
25#include <QLabel>
26#include <QTextEdit>
27#include <QVBoxLayout>
28
29#include "moc_qgsmodelgroupboxdefinitionwidget.cpp"
30
31QgsModelGroupBoxDefinitionDialog::QgsModelGroupBoxDefinitionDialog( const QgsProcessingModelGroupBox &box, QWidget *parent )
32 : QDialog( parent )
33 , mBox( box )
34{
35 QVBoxLayout *commentLayout = new QVBoxLayout();
36 commentLayout->addWidget( new QLabel( tr( "Title" ) ) );
37 mCommentEdit = new QTextEdit();
38 mCommentEdit->setAcceptRichText( false );
39 mCommentEdit->setText( box.description() );
40 commentLayout->addWidget( mCommentEdit, 1 );
41
42 QHBoxLayout *hl = new QHBoxLayout();
43 hl->setContentsMargins( 0, 0, 0, 0 );
44 hl->addWidget( new QLabel( tr( "Color" ) ) );
45 mCommentColorButton = new QgsColorButton();
46 mCommentColorButton->setAllowOpacity( true );
47 mCommentColorButton->setWindowTitle( tr( "Comment Color" ) );
48 mCommentColorButton->setShowNull( true, tr( "Default" ) );
49
50 if ( box.color().isValid() )
51 mCommentColorButton->setColor( box.color() );
52 else
53 mCommentColorButton->setToNull();
54
55 hl->addWidget( mCommentColorButton );
56 commentLayout->addLayout( hl );
57
58 QDialogButtonBox *bbox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
59 connect( bbox, &QDialogButtonBox::accepted, this, &QgsModelGroupBoxDefinitionDialog::accept );
60 connect( bbox, &QDialogButtonBox::rejected, this, &QgsModelGroupBoxDefinitionDialog::reject );
61
62 commentLayout->addWidget( bbox );
63 setLayout( commentLayout );
64 setWindowTitle( tr( "Group Box Properties" ) );
65 setObjectName( QStringLiteral( "QgsModelGroupBoxDefinitionWidget" ) );
67
68 mCommentEdit->setFocus();
69 mCommentEdit->selectAll();
70}
71
72QgsProcessingModelGroupBox QgsModelGroupBoxDefinitionDialog::groupBox() const
73{
74 QgsProcessingModelGroupBox box = mBox;
75 box.setColor( mCommentColorButton->isNull() ? QColor() : mCommentColorButton->color() );
76 box.setDescription( mCommentEdit->toPlainText() );
77 return box;
78}
A cross platform button subclass for selecting colors.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition qgsgui.cpp:221
QgsModelGroupBoxDefinitionDialog(const QgsProcessingModelGroupBox &box, QWidget *parent SIP_TRANSFERTHIS=nullptr)
Constructor for QgsModelGroupBoxDefinitionWidget, for the specified group box.
QgsProcessingModelGroupBox groupBox() const
Returns a new instance of the group box, using the current settings defined in the dialog.