mac_cocoa_native_color.diff

Native color picker for new generation symbology on OSX. - John Tull, 2012-05-30 01:29 PM

Download (16.3 KB)

View differences:

src/app/qgssinglesymboldialog.cpp
252 252

  
253 253
void QgsSingleSymbolDialog::selectOutlineColor()
254 254
{
255
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
256
  // Native Mac dialog works only for Qt Carbon
257
  QColor c = QColorDialog::getColor( btnOutlineColor->color(), this, "", QColorDialog::DontUseNativeDialog );
255
#ifdef QT_MAC_USE_COCOA
256
  QColorDialog colorDialog( this );
257
  colorDialog.setOption( QColorDialog::NoButtons );
258
  colorDialog.exec();
259
  QColor c = colorDialog.currentColor();
258 260
#else
259 261
  QColor c = QColorDialog::getColor( btnOutlineColor->color(), this );
260 262
#endif
......
270 272

  
271 273
void QgsSingleSymbolDialog::selectFillColor()
272 274
{
273
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
274
  // Native Mac dialog works only for Qt Carbon
275
  QColor c = QColorDialog::getColor( btnFillColor->color(), this, "", QColorDialog::DontUseNativeDialog );
275
#ifdef QT_MAC_USE_COCOA
276
  QColorDialog colorDialog( this );
277
  colorDialog.setOption( QColorDialog::NoButtons );
278
  colorDialog.exec();
279
  QColor c = colorDialog.currentColor();
276 280
#else
277 281
  QColor c = QColorDialog::getColor( btnFillColor->color(), this );
278 282
#endif
src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
188 188
{
189 189
  if ( mLayer )
190 190
  {
191
  #ifdef QT_MAC_USE_COCOA
192
    QColorDialog colorDialog( this );
193
    colorDialog.setOption( QColorDialog::NoButtons );
194
    colorDialog.exec();
195
    QColor newColor = colorDialog.currentColor();
196
  #else
191 197
    QColor newColor = QColorDialog::getColor( mLayer->outlineColor() );
198
  #endif
192 199
    if ( newColor.isValid() )
193 200
    {
194 201
      mLayer->setOutlineColor( newColor );
......
201 208
{
202 209
  if ( mLayer )
203 210
  {
211
  #ifdef QT_MAC_USE_COCOA
212
    QColorDialog colorDialog( this );
213
    colorDialog.setOption( QColorDialog::NoButtons );
214
    colorDialog.exec();
215
    QColor newColor = colorDialog.currentColor();
216
  #else
204 217
    QColor newColor = QColorDialog::getColor( mLayer->fillColor() );
218
  #endif
205 219
    if ( newColor.isValid() )
206 220
    {
207 221
      mLayer->setFillColor( newColor );
src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp
231 231
  }
232 232

  
233 233
#if QT_VERSION >= 0x040500
234
  #ifdef QT_MAC_USE_COCOA
235
    QColorDialog colorDialog( this );
236
    colorDialog.setOption( QColorDialog::NoButtons );
237
    colorDialog.exec();
238
    QColor newColor = colorDialog.currentColor();
239
  #else
234 240
  QColor newColor = QColorDialog::getColor( mRenderer->circleColor(), 0, tr( "Circle color" ), QColorDialog::ShowAlphaChannel );
241
  #endif
235 242
#else
236 243
  QColor newColor = QColorDialog::getColor( mRenderer->circleColor() );
237 244
#endif
......
250 257
  }
251 258

  
252 259
#if QT_VERSION >= 0x040500
260
  #ifdef QT_MAC_USE_COCOA
261
    QColorDialog colorDialog( this );
262
    colorDialog.setOption( QColorDialog::NoButtons );
263
    colorDialog.exec();
264
    QColor newColor = colorDialog.currentColor();
265
  #else
253 266
  QColor newColor = QColorDialog::getColor( mRenderer->labelColor(), 0, tr( "Label color" ), QColorDialog::ShowAlphaChannel );
267
  #endif
254 268
#else
255 269
  QColor newColor = QColorDialog::getColor( mRenderer->labelColor() );
256 270
#endif
src/gui/symbology-ng/qgssymbollayerv2widget.cpp
102 102

  
103 103
void QgsSimpleLineSymbolLayerV2Widget::colorChanged()
104 104
{
105
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
106
  // Native Mac dialog works only for Qt Carbon
107
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
108
  // FIXME need to also check max QT_VERSION when Qt bug fixed
109
  QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
105
#ifdef QT_MAC_USE_COCOA
106
  QColorDialog colorDialog( this );
107
  colorDialog.setOption( QColorDialog::NoButtons );
108
  colorDialog.exec();
109
  QColor color = colorDialog.currentColor();
110 110
#else
111 111
  QColor color = QColorDialog::getColor( mLayer->color(), this );
112 112
#endif
......
251 251

  
252 252
void QgsSimpleMarkerSymbolLayerV2Widget::setColorBorder()
253 253
{
254
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
255
  // Native Mac dialog works only for Qt Carbon
256
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
257
  // FIXME need to also check max QT_VERSION when Qt bug fixed
258
  QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::DontUseNativeDialog );
254
#ifdef QT_MAC_USE_COCOA
255
  QColorDialog colorDialog( this );
256
  colorDialog.setOption( QColorDialog::NoButtons );
257
  colorDialog.exec();
258
  QColor borderColor = colorDialog.currentColor();
259 259
#else
260 260
  QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this );
261 261
#endif
......
268 268

  
269 269
void QgsSimpleMarkerSymbolLayerV2Widget::setColorFill()
270 270
{
271
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
272
  // Native Mac dialog works only for Qt Carbon
273
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
274
  // FIXME need to also check max QT_VERSION when Qt bug fixed
275
  QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
271
#ifdef QT_MAC_USE_COCOA
272
  QColorDialog colorDialog( this );
273
  colorDialog.setOption( QColorDialog::NoButtons );
274
  colorDialog.exec();
275
  QColor color = colorDialog.currentColor();
276 276
#else
277 277
  QColor color = QColorDialog::getColor( mLayer->color(), this );
278 278
#endif
......
349 349

  
350 350
void QgsSimpleFillSymbolLayerV2Widget::setColor()
351 351
{
352
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
353
  // Native Mac dialog works only for Qt Carbon
354
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
355
  // FIXME need to also check max QT_VERSION when Qt bug fixed
356
  QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
352
#ifdef QT_MAC_USE_COCOA
353
  QColorDialog colorDialog( this );
354
  colorDialog.setOption( QColorDialog::NoButtons );
355
  colorDialog.exec();
356
  QColor color = colorDialog.currentColor();
357 357
#else
358 358
  QColor color = QColorDialog::getColor( mLayer->color(), this );
359 359
#endif
......
366 366

  
367 367
void QgsSimpleFillSymbolLayerV2Widget::setBorderColor()
368 368
{
369
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
370
  // Native Mac dialog works only for Qt Carbon
371
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
372
  // FIXME need to also check max QT_VERSION when Qt bug fixed
373
  QColor color = QColorDialog::getColor( mLayer->borderColor(), this, "", QColorDialog::DontUseNativeDialog );
369
#ifdef QT_MAC_USE_COCOA
370
  QColorDialog colorDialog( this );
371
  colorDialog.setOption( QColorDialog::NoButtons );
372
  colorDialog.exec();
373
  QColor color = colorDialog.currentColor();
374 374
#else
375 375
  QColor color = QColorDialog::getColor( mLayer->borderColor(), this );
376 376
#endif
......
723 723
  {
724 724
    return;
725 725
  }
726
#ifdef QT_MAC_USE_COCOA
727
  QColorDialog colorDialog( this );
728
  colorDialog.setOption( QColorDialog::NoButtons );
729
  colorDialog.exec();
730
  QColor c = colorDialog.currentColor();
731
#else
726 732
  QColor c = QColorDialog::getColor( mLayer->fillColor() );
733
#endif
727 734
  if ( c.isValid() )
728 735
  {
729 736
    mLayer->setFillColor( c );
......
737 744
  {
738 745
    return;
739 746
  }
747
#ifdef QT_MAC_USE_COCOA
748
  QColorDialog colorDialog( this );
749
  colorDialog.setOption( QColorDialog::NoButtons );
750
  colorDialog.exec();
751
  QColor c = colorDialog.currentColor();
752
#else
740 753
  QColor c = QColorDialog::getColor( mLayer->outlineColor() );
754
#endif
741 755
  if ( c.isValid() )
742 756
  {
743 757
    mLayer->setOutlineColor( c );
......
787 801

  
788 802
void QgsLineDecorationSymbolLayerV2Widget::colorChanged()
789 803
{
790
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
791
  // Native Mac dialog works only for Qt Carbon
792
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
793
  // FIXME need to also check max QT_VERSION when Qt bug fixed
794
  QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
804
#ifdef QT_MAC_USE_COCOA
805
  QColorDialog colorDialog( this );
806
  colorDialog.setOption( QColorDialog::NoButtons );
807
  colorDialog.exec();
808
  QColor color = colorDialog.currentColor();
795 809
#else
796 810
  QColor color = QColorDialog::getColor( mLayer->color(), this );
797 811
#endif
......
947 961
  {
948 962
    return;
949 963
  }
964
#ifdef QT_MAC_USE_COCOA
965
  QColorDialog colorDialog( this );
966
  colorDialog.setOption( QColorDialog::NoButtons );
967
  colorDialog.exec();
968
  QColor c = colorDialog.currentColor();
969
#else
950 970
  QColor c = QColorDialog::getColor( mLayer->svgFillColor() );
971
#endif
951 972
  if ( c.isValid() )
952 973
  {
953 974
    mLayer->setSvgFillColor( c );
......
961 982
  {
962 983
    return;
963 984
  }
985
#ifdef QT_MAC_USE_COCOA
986
  QColorDialog colorDialog( this );
987
  colorDialog.setOption( QColorDialog::NoButtons );
988
  colorDialog.exec();
989
  QColor c = colorDialog.currentColor();
990
#else
964 991
  QColor c = QColorDialog::getColor( mLayer->svgOutlineColor() );
992
#endif
965 993
  if ( c.isValid() )
966 994
  {
967 995
    mLayer->setSvgOutlineColor( c );
......
1049 1077
{
1050 1078
  if ( mLayer )
1051 1079
  {
1080
#ifdef QT_MAC_USE_COCOA
1081
  QColorDialog colorDialog( this );
1082
  colorDialog.setOption( QColorDialog::NoButtons );
1083
  colorDialog.exec();
1084
  QColor c = colorDialog.currentColor();
1085
#else
1052 1086
    QColor c = QColorDialog::getColor( mLayer->color() );
1087
#endif
1053 1088
    if ( c.isValid() )
1054 1089
    {
1055 1090
      mLayer->setColor( c );
......
1224 1259

  
1225 1260
void QgsFontMarkerSymbolLayerV2Widget::setColor()
1226 1261
{
1227
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
1228
  // Native Mac dialog works only for Qt Carbon
1229
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
1230
  // FIXME need to also check max QT_VERSION when Qt bug fixed
1231
  QColor color = QColorDialog::getColor( mLayer->color(), this, "", QColorDialog::DontUseNativeDialog );
1262
#ifdef QT_MAC_USE_COCOA
1263
  QColorDialog colorDialog( this );
1264
  colorDialog.setOption( QColorDialog::NoButtons );
1265
  colorDialog.exec();
1266
  QColor color = colorDialog.currentColor();
1232 1267
#else
1233 1268
  QColor color = QColorDialog::getColor( mLayer->color(), this );
1234 1269
#endif
src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
188 188

  
189 189
void QgsSymbolV2SelectorDialog::setSymbolColor()
190 190
{
191
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
192
  // Native Mac dialog works only for Qt Carbon
193
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
194
  // FIXME need to also check max QT_VERSION when Qt bug fixed
195
  QColor color = QColorDialog::getColor( mSymbol->color(), this, "", QColorDialog::DontUseNativeDialog );
191
#ifdef QT_MAC_USE_COCOA
192
  QColorDialog colorDialog( this );
193
  colorDialog.setOption( QColorDialog::NoButtons );
194
  colorDialog.exec();
195
  QColor color = colorDialog.currentColor();
196 196
#else
197 197
  QColor color = QColorDialog::getColor( mSymbol->color(), this );
198 198
#endif
src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp
87 87

  
88 88
void QgsVectorGradientColorRampV2Dialog::setColor1()
89 89
{
90
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
91
  // Native Mac dialog works only for Qt Carbon
92
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
93
  // FIXME need to also check max QT_VERSION when Qt bug fixed
94
  QColor color = QColorDialog::getColor( mRamp->color1(), this, "", QColorDialog::DontUseNativeDialog );
90
#ifdef QT_MAC_USE_COCOA
91
  QColorDialog colorDialog( this );
92
  colorDialog.setOption( QColorDialog::NoButtons );
93
  colorDialog.exec();
94
  QColor color = colorDialog.currentColor();
95 95
#else
96 96
  QColor color = QColorDialog::getColor( mRamp->color1(), this );
97 97
#endif
......
103 103

  
104 104
void QgsVectorGradientColorRampV2Dialog::setColor2()
105 105
{
106
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
107
  // Native Mac dialog works only for Qt Carbon
108
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
109
  // FIXME need to also check max QT_VERSION when Qt bug fixed
110
  QColor color = QColorDialog::getColor( mRamp->color2(), this, "", QColorDialog::DontUseNativeDialog );
106
#ifdef QT_MAC_USE_COCOA
107
  QColorDialog colorDialog( this );
108
  colorDialog.setOption( QColorDialog::NoButtons );
109
  colorDialog.exec();
110
  QColor color = colorDialog.currentColor();
111 111
#else
112 112
  QColor color = QColorDialog::getColor( mRamp->color2(), this );
113 113
#endif
......
142 142
{
143 143
  if ( column == 0 )
144 144
  {
145
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
146
    // Native Mac dialog works only for Qt Carbon
147
    // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
148
    // FIXME need to also check max QT_VERSION when Qt bug fixed
149
    QColor color = QColorDialog::getColor( item->data( 0, StopColorRole ).value<QColor>(), this, "", QColorDialog::DontUseNativeDialog );
145
#ifdef QT_MAC_USE_COCOA
146
  QColorDialog colorDialog( this );
147
  colorDialog.setOption( QColorDialog::NoButtons );
148
  colorDialog.exec();
149
  QColor color = colorDialog.currentColor();
150 150
#else
151 151
    QColor color = QColorDialog::getColor( item->data( 0, StopColorRole ).value<QColor>(), this );
152 152
#endif
......
188 188

  
189 189
void QgsVectorGradientColorRampV2Dialog::addStop()
190 190
{
191
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
192
  // Native Mac dialog works only for Qt Carbon
193
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
194
  // also Qt 4.7 Mac Cocoa bug: calling QInputDialog::getInt after QColorDialog::getColor will freeze app
195
  // workaround: call QColorDialog::getColor below instead of here,
196
  // but not needed at this time because of the other Qt bug
197
  // FIXME need to also check max QT_VERSION when Qt bug(s) fixed
198
  QColor color = QColorDialog::getColor( QColor(), this, "", QColorDialog::DontUseNativeDialog );
191
#ifdef QT_MAC_USE_COCOA
192
  QColorDialog colorDialog( this );
193
  colorDialog.setOption( QColorDialog::NoButtons );
194
  colorDialog.exec();
195
  QColor color = colorDialog.currentColor();
199 196
#else
200 197
  QColor color = QColorDialog::getColor( QColor(), this );
201 198
#endif