Skip to content

Commit

Permalink
Port some more color buttons to QgsColorButtonV2
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 12, 2014
1 parent 766f078 commit cecb3d1
Show file tree
Hide file tree
Showing 10 changed files with 360 additions and 201 deletions.
6 changes: 6 additions & 0 deletions src/app/qgsannotationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
mFrameColorButton->setColor( mItem->frameColor() );
mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mFrameColorButton->setContext( "symbology" );
mFrameColorButton->setNoColorString( tr( "Transparent frame" ) );
mFrameColorButton->setShowNoColor( true );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mBackgroundColorButton->setContext( "symbology" );
mBackgroundColorButton->setNoColorString( tr( "Transparent" ) );
mBackgroundColorButton->setShowNoColor( true );

const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
if ( symbol )
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsdecorationcopyrightdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
cboPlacement->setCurrentIndex( mDeco.mPlacementIndex );
// color
pbnColorChooser->setColor( mDeco.mLabelQColor );
pbnColorChooser->setContext( "gui" );
pbnColorChooser->setColorDialogTitle( tr( "Select text color" ) );

QTextCursor cursor = txtCopyrightText->textCursor();
txtCopyrightText->selectAll();
txtCopyrightText->setTextColor( mDeco.mLabelQColor );
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsdecorationscalebardialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar&
cboStyle->setCurrentIndex( mDeco.mStyleIndex );

pbnChangeColor->setColor( mDeco.mColor );
pbnChangeColor->setContext( "gui" );
pbnChangeColor->setColorDialogTitle( tr( "Select scalebar color" ) );
}

QgsDecorationScaleBarDialog::~QgsDecorationScaleBarDialog()
Expand Down
18 changes: 18 additions & 0 deletions src/app/qgslabelinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ QgsLabelingGui::QgsLabelingGui( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas,

populateFontCapitalsComboBox();

// color buttons
mPreviewBackgroundBtn->setColorDialogTitle( tr( "Select fill color" ) );
mPreviewBackgroundBtn->setContext( "labelling" );
btnTextColor->setColorDialogTitle( tr( "Select text color" ) );
btnTextColor->setContext( "labelling" );
btnTextColor->setDefaultColor( Qt::black );
btnBufferColor->setColorDialogTitle( tr( "Select buffer color" ) );
btnBufferColor->setContext( "labelling" );
btnBufferColor->setDefaultColor( Qt::white );
mShapeBorderColorBtn->setColorDialogTitle( tr( "Select border color" ) );
mShapeBorderColorBtn->setContext( "labelling" );
mShapeFillColorBtn->setColorDialogTitle( tr( "Select fill color" ) );
mShapeFillColorBtn->setContext( "labelling" );
mShadowColorBtn->setColorDialogTitle( tr( "Select shadow color" ) );
mShadowColorBtn->setContext( "labelling" );
mShadowColorBtn->setDefaultColor( Qt::black );

// set up quadrant offset button group
mQuadrantBtnGrp = new QButtonGroup( this );
mQuadrantBtnGrp->addButton( mPointOffsetAboveLeft, ( int )QgsPalLayerSettings::QuadrantAboveLeft );
Expand Down Expand Up @@ -344,6 +361,7 @@ void QgsLabelingGui::init()
chkPreserveRotation->setChecked( lyr.preserveRotation );

mPreviewBackgroundBtn->setColor( lyr.previewBkgrdColor );
mPreviewBackgroundBtn->setDefaultColor( lyr.previewBkgrdColor );
setPreviewBackground( lyr.previewBkgrdColor );

mScaleBasedVisibilityChkBx->setChecked( lyr.scaleVisibility );
Expand Down
16 changes: 15 additions & 1 deletion src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :

mIdentifyHighlightColorButton->setColorDialogTitle( tr( "Identify highlight color" ) );
mIdentifyHighlightColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mIdentifyHighlightColorButton->setContext( "gui" );
mIdentifyHighlightColorButton->setDefaultColor( QGis::DEFAULT_HIGHLIGHT_COLOR );

QSettings settings;

Expand Down Expand Up @@ -616,20 +618,28 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
int myBlue = settings.value( "/qgis/default_selection_color_blue", 0 ).toInt();
int myAlpha = settings.value( "/qgis/default_selection_color_alpha", 255 ).toInt();
pbnSelectionColor->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
pbnSelectionColor->setColorDialogTitle( tr( "Selection color" ) );
pbnSelectionColor->setColorDialogTitle( tr( "Set selection color" ) );
pbnSelectionColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
pbnSelectionColor->setContext( "gui" );
pbnSelectionColor->setDefaultColor( QColor( 255, 255, 0, 255 ) );

//set the default color for canvas background
myRed = settings.value( "/qgis/default_canvas_color_red", 255 ).toInt();
myGreen = settings.value( "/qgis/default_canvas_color_green", 255 ).toInt();
myBlue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
pbnCanvasColor->setColor( QColor( myRed, myGreen, myBlue ) );
pbnCanvasColor->setColorDialogTitle( tr( "Set canvas color" ) );
pbnCanvasColor->setContext( "gui" );
pbnCanvasColor->setDefaultColor( Qt::white );

// set the default color for the measure tool
myRed = settings.value( "/qgis/default_measure_color_red", 222 ).toInt();
myGreen = settings.value( "/qgis/default_measure_color_green", 155 ).toInt();
myBlue = settings.value( "/qgis/default_measure_color_blue", 67 ).toInt();
pbnMeasureColor->setColor( QColor( myRed, myGreen, myBlue ) );
pbnMeasureColor->setColorDialogTitle( tr( "Set measuring tool color" ) );
pbnMeasureColor->setContext( "gui" );
pbnMeasureColor->setDefaultColor( QColor( 222, 155, 67 ) );

capitaliseCheckBox->setChecked( settings.value( "/qgis/capitaliseLayerName", QVariant( false ) ).toBool() );

Expand Down Expand Up @@ -703,6 +713,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
mGridColorButton->setColor( gridColor );
mGridColorButton->setColorDialogTitle( tr( "Select grid color" ) );
mGridColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mGridColorButton->setContext( "gui" );
mGridColorButton->setDefaultColor( QColor( 190, 190, 190, 100 ) );

//default composer grid style
QString gridStyleString;
Expand Down Expand Up @@ -758,6 +770,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
myAlpha = settings.value( "/qgis/digitizing/line_color_alpha", 200 ).toInt();
mLineColorToolButton->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
mLineColorToolButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mLineColorToolButton->setContext( "gui" );
mLineColorToolButton->setDefaultColor( QColor( 255, 0, 0, 200 ) );

//default snap mode
mDefaultSnapModeComboBox->insertItem( 0, tr( "To vertex" ), "to vertex" );
Expand Down
150 changes: 102 additions & 48 deletions src/ui/qgsannotationwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,90 +6,144 @@
<rect>
<x>0</x>
<y>0</y>
<width>221</width>
<width>319</width>
<height>172</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="mMapPositionFixedCheckBox">
<property name="text">
<string>Fixed map position</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QgsColorButton" name="mFrameColorButton">
<property name="text">
<string/>
<widget class="QLabel" name="mMapMarkerLabel">
<property name="text">
<string>Map marker</string>
</property>
<property name="buddy">
<cstring>mMapMarkerButton</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="mMapMarkerButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mFrameWidthLabel">
<property name="text">
<string>Frame width</string>
</property>
<property name="buddy">
<cstring>mFrameWidthSpinBox</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mBackgroundColorLabel">
<property name="text">
<string>Background color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QgsColorButtonV2" name="mBackgroundColorButton">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mBackgroundColorLabel">
<property name="text">
<string>Background color</string>
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mMapMarkerLabel">
<property name="text">
<string>Map marker</string>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="buddy">
<cstring>mMapMarkerButton</cstring>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="2" column="1">
<widget class="QgsColorButton" name="mBackgroundColorButton">
<property name="text">
<string/>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mFrameColorLabel">
<property name="text">
<string>Frame color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QgsColorButtonV2" name="mFrameColorButton">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="mMapMarkerButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mFrameWidthLabel">
<property name="text">
<string>Frame width</string>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="buddy">
<cstring>mFrameWidthSpinBox</cstring>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mFrameColorLabel">
<property name="text">
<string>Frame color</string>
</property>
</widget>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsColorButton</class>
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
<class>QgsColorButtonV2</class>
<extends>QToolButton</extends>
<header>qgscolorbuttonv2.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
Loading

0 comments on commit cecb3d1

Please sign in to comment.