/
qgsdecorationcopyrightdialog.cpp
93 lines (79 loc) · 3.48 KB
/
qgsdecorationcopyrightdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/***************************************************************************
* Copyright (C) 2003 by Tim Sutton *
* tim@linfiniti.com *
* *
* This is a plugin generated from the QGIS plugin template *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "qgsdecorationcopyrightdialog.h"
#include "qgsdecorationcopyright.h"
#include "qgscontexthelp.h"
//qt includes
#include <QColorDialog>
#include <QColor>
#include <QFont>
#include <QSettings>
QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyright& deco, QWidget* parent )
: QDialog( parent ), mDeco( deco )
{
setupUi( this );
QSettings settings;
restoreGeometry( settings.value( "/Windows/DecorationCopyright/geometry" ).toByteArray() );
//programmatically hide orientation selection for now
cboOrientation->hide();
textLabel15->hide();
grpEnable->setChecked( mDeco.enabled() );
// text
txtCopyrightText->setPlainText( mDeco.mLabelQString );
// placement
cboPlacement->addItem( tr( "Top left" ), QgsDecorationItem::TopLeft );
cboPlacement->addItem( tr( "Top right" ), QgsDecorationItem::TopRight );
cboPlacement->addItem( tr( "Bottom left" ), QgsDecorationItem::BottomLeft );
cboPlacement->addItem( tr( "Bottom right" ), QgsDecorationItem::BottomRight );
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
spnHorizontal->setValue( mDeco.mMarginHorizontal );
spnVertical->setValue( mDeco.mMarginVertical );
// color
pbnColorChooser->setColor( mDeco.mLabelQColor );
pbnColorChooser->setContext( "gui" );
pbnColorChooser->setColorDialogTitle( tr( "Select text color" ) );
QTextCursor cursor = txtCopyrightText->textCursor();
txtCopyrightText->selectAll();
txtCopyrightText->setTextColor( mDeco.mLabelQColor );
txtCopyrightText->setTextCursor( cursor );
}
QgsDecorationCopyrightDialog::~QgsDecorationCopyrightDialog()
{
QSettings settings;
settings.setValue( "/Windows/DecorationCopyright/geometry", saveGeometry() );
}
void QgsDecorationCopyrightDialog::on_buttonBox_accepted()
{
mDeco.mQFont = txtCopyrightText->currentFont();
mDeco.mLabelQString = txtCopyrightText->toPlainText();
mDeco.mLabelQColor = pbnColorChooser->color();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.mMarginHorizontal = spnHorizontal->value();
mDeco.mMarginVertical = spnVertical->value();
mDeco.setEnabled( grpEnable->isChecked() );
accept();
}
void QgsDecorationCopyrightDialog::on_buttonBox_rejected()
{
reject();
}
void QgsDecorationCopyrightDialog::on_pbnColorChooser_colorChanged( const QColor& c )
{
QTextCursor cursor = txtCopyrightText->textCursor();
txtCopyrightText->selectAll();
txtCopyrightText->setTextColor( c );
txtCopyrightText->setTextCursor( cursor );
}
void QgsDecorationCopyrightDialog::on_buttonBox_helpRequested()
{
QgsContextHelp::run( metaObject()->className() );
}