30#include "moc_qgslayouttablebackgroundcolorsdialog.cpp"
32using namespace Qt::StringLiterals;
35 : QDialog( parent, flags )
41 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QgsLayoutTableBackgroundColorsDialog::buttonBox_accepted );
42 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QgsLayoutTableBackgroundColorsDialog::buttonBox_rejected );
43 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutTableBackgroundColorsDialog::showHelp );
65 connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked,
this, &QgsLayoutTableBackgroundColorsDialog::apply );
67 setGuiElementValues();
70void QgsLayoutTableBackgroundColorsDialog::apply()
76 for (
auto checkBoxIt = mCheckBoxMap.constBegin(); checkBoxIt != mCheckBoxMap.constEnd(); ++checkBoxIt )
79 style.
enabled = checkBoxIt.value()->isChecked();
80 if (
QgsColorButton *button = mColorButtonMap.value( checkBoxIt.key() ) )
86 mTable->setBackgroundColor( mDefaultColorButton->color() );
91void QgsLayoutTableBackgroundColorsDialog::buttonBox_accepted()
97void QgsLayoutTableBackgroundColorsDialog::buttonBox_rejected()
102void QgsLayoutTableBackgroundColorsDialog::showHelp()
104 QgsHelp::openHelp( u
"print_composer/composer_items/composer_attribute_table.html#appearance"_s );
107void QgsLayoutTableBackgroundColorsDialog::setGuiElementValues()
112 for (
auto it = mCheckBoxMap.constBegin(); it != mCheckBoxMap.constEnd(); ++it )
114 it.value()->setChecked( mTable->cellStyle( it.key() )->enabled );
115 QgsColorButton *button = mColorButtonMap.value( it.key() );
118 button->setEnabled( mTable->cellStyle( it.key() )->enabled );
119 button->
setColor( mTable->cellStyle( it.key() )->cellBackgroundColor );
124 mDefaultColorButton->setColor( mTable->backgroundColor() );
125 mDefaultColorButton->setAllowOpacity(
true );
126 mDefaultColorButton->setColorDialogTitle( tr(
"Select Background Color" ) );
127 mDefaultColorButton->setShowNoColor(
true );
128 mDefaultColorButton->setNoColorString( tr(
"No Background" ) );
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...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
void beginCommand(const QString &commandText, UndoCommand command=UndoNone)
Starts new undo command for this item.
@ UndoTableCellStyle
Table cell style.
QgsLayoutTableBackgroundColorsDialog(QgsLayoutTable *table, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutTableBackgroundColorsDialog.
Styling option for a layout table cell.
QColor cellBackgroundColor
Cell background color.
bool enabled
Whether the styling option is enabled.
Displays a table in the print layout, and allows the table to span over multiple frames.
@ FirstRow
Style first row only.
@ EvenColumns
Style even numbered columns.
@ EvenRows
Style even numbered rows.
@ HeaderRow
Style header row.
@ OddColumns
Style odd numbered columns.
@ FirstColumn
Style first column only.
@ LastColumn
Style last column only.
@ LastRow
Style last row only.
@ OddRows
Style odd numbered rows.
void setCellStyle(CellStyleGroup group, const QgsLayoutTableStyle &style)
Sets the cell style for a cell group.