23 #include <QColorDialog> 24 #include <QInputDialog> 27 #include <QTableWidget> 31 :
QDialog( parent ), mRamp( ramp ), mCurrentItem( nullptr )
38 btnColor1->setAllowAlpha(
true );
39 btnColor1->setColorDialogTitle(
tr(
"Select ramp color" ) );
40 btnColor1->setContext(
"symbology" );
41 btnColor1->setShowNoColor(
true );
42 btnColor1->setNoColorString(
tr(
"Transparent" ) );
43 btnColor2->setAllowAlpha(
true );
44 btnColor2->setColorDialogTitle(
tr(
"Select ramp color" ) );
45 btnColor2->setContext(
"symbology" );
46 btnColor2->setShowNoColor(
true );
47 btnColor2->setNoColorString(
tr(
"Transparent" ) );
54 connect( btnAddStop, SIGNAL( clicked() ),
this, SLOT(
addStop() ) );
59 cboType->blockSignals(
true );
60 cboType->addItem(
tr(
"Discrete" ) );
61 cboType->addItem(
tr(
"Continuous" ) );
63 cboType->setCurrentIndex( 0 );
65 cboType->setCurrentIndex( 1 );
66 cboType->blockSignals(
false );
71 btnInformation->setEnabled(
false );
107 if ( it.key().startsWith(
"cpt-city" ) )
125 if ( ! gradientFile.
isNull() )
127 QString fileName = gradientFile;
131 fileName = gradientFile;
132 fileName.
replace(
"<cpt-city>",
"http://soliton.vm.bytemark.co.uk/pub/cpt-city" );
134 label =
new QLabel(
tr(
"Gradient file : %1" ).arg( fileName ), dlg );
142 if ( !licenseFile.
isNull() )
144 QString fileName = licenseFile;
148 fileName = licenseFile;
149 fileName.
replace(
"<cpt-city>",
"http://soliton.vm.bytemark.co.uk/pub/cpt-city" );
151 label =
new QLabel(
tr(
"License file : %1" ).arg( fileName ), dlg );
159 QFile file( fileName );
160 if ( file.
open( QIODevice::ReadOnly | QIODevice::Text ) )
177 groupStops->setChecked( !stops.
isEmpty() );
180 for ( QgsGradientStopsList::iterator it = stops.
begin();
181 it != stops.
end(); ++it )
183 double val = it->offset * 100.0;
194 treeStops->insertTopLevelItems( 0, items );
195 treeStops->resizeColumnToContents( 0 );
196 treeStops->setColumnWidth( 0, treeStops->columnWidth( 0 ) + 20 );
197 treeStops->sortByColumn( 1, Qt::AscendingOrder );
198 treeStops->setSortingEnabled(
true );
205 if ( groupStops->isChecked() )
207 int count = treeStops->topLevelItemCount();
209 for (
int i = 0; i < count; i++ )
223 btnColor1->blockSignals(
true );
225 btnColor1->blockSignals(
false );
226 btnColor2->blockSignals(
true );
228 btnColor2->blockSignals(
false );
245 QSize iconSize( 16, 16 );
253 p.setPen( Qt::NoPen );
254 p.setRenderHint( QPainter::Antialiasing );
256 p.drawRoundedRect(
rect, 2, 2 );
281 bool useNative = settings.
value(
"/qgis/native_color_dialogs",
false ).
toBool();
282 if ( settings.
value(
"/qgis/live_color_dialogs",
false ).
toBool() )
290 this,
tr(
"Edit Stop Color" ), QColorDialog::ShowAlphaChannel );
296 this,
tr(
"Edit Stop Color" ), true );
315 double val = key * 100;
317 tr(
"Please enter offset in percents (%) of the new stop" ),
318 val, 0, 100, 2, &ok );
322 double newkey = val / 100.0;
349 tr(
"Please enter offset in percents (%) of the new stop" ),
350 val, 0, 100, 2, &ok );
355 double key = val / 100.0;
372 treeStops->addTopLevelItem( item );
374 treeStops->resizeColumnToContents( 0 );
375 treeStops->setColumnWidth( 0, treeStops->columnWidth( 0 ) + 20 );
385 int index = treeStops->indexOfTopLevelItem( item );
386 treeStops->takeTopLevelItem( index );
static QPixmap colorRampPreviewPixmap(QgsVectorColorRampV2 *ramp, QSize size)
void fill(const QColor &color)
static QString defaultBaseDir()
void on_btnInformation_pressed()
void resizeColumnToContents(int column)
const_iterator constBegin() const
QTreeWidgetItem * mCurrentItem
A generic dialog with layout and button box.
void setColor2(const QColor &color)
void addSpacing(int size)
void setColor2(const QColor &color)
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsStringMap info() const
void setColor1(const QColor &color)
int rowHeight(int row) const
QString number(int n, int base)
void toggledStops(bool on)
void append(const T &value)
const_iterator constEnd() const
QgsVectorGradientColorRampV2Dialog(QgsVectorGradientColorRampV2 *ramp, QWidget *parent=nullptr)
void setStops(const QgsGradientStopsList &stops)
void setItemStopColor(const QColor &newColor)
QgsVectorGradientColorRampV2 * mRamp
void convertToDiscrete(bool discrete)
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
void setTextInteractionFlags(QFlags< Qt::TextInteractionFlag > flags)
QString & replace(int position, int n, QChar after)
QVariant value(const QString &key, const QVariant &defaultValue) const
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), const bool allowAlpha=false)
Return a color selection from a color dialog.
const QgsGradientStopsList & stops() const
static const int StopOffsetRole
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
void setText(int column, const QString &text)
double toDouble(bool *ok) const
void on_cboType_currentIndexChanged(int index)
void setReadOnly(bool ro)
void resizeRowToContents(int row)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool begin(QPaintDevice *device)
void setColor1(const QColor &color)
void setText(const QString &text)
void stopDoubleClicked(QTreeWidgetItem *item, int column)
static QColor getLiveColor(const QColor &initialColor, QObject *updateObject, const char *updateSlot, QWidget *parent=nullptr, const QString &title="", const QColorDialog::ColorDialogOptions &options=nullptr)
Return a color selection from a QColorDialog, with live updating of interim selections.
int count(const Key &key) const
static QColor getLiveColor(const QColor &initialColor, QObject *updateObject, const char *updateSlot, QWidget *parent=nullptr, const QString &title=QString(), const bool allowAlpha=true)
Return a color selection from a color dialog, with live updating of interim selections.
void setStopColor(QTreeWidgetItem *item, const QColor &color)
static const int StopColorRole
const T value(const Key &key) const