void ColorEditor::keyPressEvent(QKeyEvent *e) { int key = e->key(); if (key == Qt::Key_Return || key == Qt::Key_Enter) { emit colorSelected(d->color, d->outputFormat); } }
void PaletteWidget2::setSelectedColorIndex(const int i) { if (i != selectedItem && i > -1 && i < PALETTE_COLOR_COUNT) { selectedItem = i; update(); emit colorSelected(i); } }
void ColorDialog::indexSelected(QPoint /*p*/) { QPoint hs_pos(m_hsLabel->selectedIndex()); QPoint v_pos(m_vLabel->selectedIndex()); int h = qBound(0, hs_pos.x(), 359); int s = qBound(0, hs_pos.y(), 255); int v = qBound(0, v_pos.y(), 255); setSelectedColor(QColor::fromHsv(h, s, v, m_aSpinBox->value())); emit colorSelected(selectedColor); }
void ColorSelectionControl::setColor(const QColor &color) { if (this->color == color) return; this->color = color; updateColorPoint(); update(); emit colorSelected(this->color); }
ColorWidget ( QWidget* parent = NULL ) : QLineEdit(parent) { setReadOnly(true); connect(&color_dialog,SIGNAL(currentColorChanged(QColor)), SLOT(update_color(QColor)) ); connect(&color_dialog,SIGNAL(colorSelected(QColor)), SLOT(update_color(QColor)) ); //connect(this,SIGNAL(editingFinished()),SLOT(update_from_text())); connect(&color_dialog,SIGNAL(finished(int)),SIGNAL(dialog_closed())); color_dialog.setOptions(QColorDialog::ShowAlphaChannel|QColorDialog::NoButtons); update_color(color()); }
ColorDialog::ColorDialog(QWidget* parent) : QDialog(parent) { setupUi(this); setSelectedColor(QColor(Qt::white)); connect(m_hsLabel, SIGNAL(colorSelected(QPoint)), this, SLOT(indexSelected(QPoint))); connect(m_vLabel, SIGNAL(colorSelected(QPoint)), this, SLOT(indexSelected(QPoint))); connect(m_okButton, SIGNAL(pressed()), this, SLOT(accept())); connect(m_cancelButton, SIGNAL(pressed()), this, SLOT(reject())); connect(m_rSpinBox, SIGNAL(valueChanged(int)), this, SLOT(rgbSpinValueChanged())); connect(m_gSpinBox, SIGNAL(valueChanged(int)), this, SLOT(rgbSpinValueChanged())); connect(m_bSpinBox, SIGNAL(valueChanged(int)), this, SLOT(rgbSpinValueChanged())); connect(m_aSpinBox, SIGNAL(valueChanged(int)), this, SLOT(rgbSpinValueChanged())); connect(m_hSpinBox, SIGNAL(valueChanged(int)), this, SLOT(hsvSpinValueChanged())); connect(m_sSpinBox, SIGNAL(valueChanged(int)), this, SLOT(hsvSpinValueChanged())); connect(m_vSpinBox, SIGNAL(valueChanged(int)), this, SLOT(hsvSpinValueChanged())); }
void Swatch::setSelected(int selected) { if ( selected < 0 || selected >= p->palette.count() ) selected = -1; if ( selected != p->selected ) { selectedChanged( p->selected = selected ); if ( selected != -1 ) colorSelected( p->palette.colorAt(p->selected) ); update(); } }
Color_Selector::Color_Selector(QWidget *parent) : Color_Preview(parent), p(new Private(this)) { setUpdateMode(Continuous); p->old_color = color(); connect(this,SIGNAL(clicked()),this,SLOT(showDialog())); connect(this,SIGNAL(colorChanged(QColor)),this,SLOT(update_old_color(QColor))); connect(p->dialog,SIGNAL(rejected()),this,SLOT(reject_dialog())); connect(p->dialog,SIGNAL(colorSelected(QColor)), this, SLOT(accept_dialog())); setAcceptDrops(true); }
void KColorCells::selectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { QModelIndexList indexList = selected.indexes(); d->selected = -1; foreach (QModelIndex index, indexList) { int row = index.row(); int column = index.column(); int cell = row * columnCount() + column; d->selected = cell; emit colorSelected( cell , color( cell ) ); break; }
void SelectColorDialog::setCurrentColor(int colorIndex) { if (_selectedColor != colorIndex) { if (_selectedColor != -1) _widgets[_selectedColor]->setSelected(false); _selectedColor = colorIndex; _widgets[_selectedColor]->setSelected(true); emit colorSelected(colorIndex); } }
void GenomeColorSelector::mousePressEvent (QMouseEvent* e) { if (e->button() == Qt::LeftButton) { last_y = selected_y; int y = 255 - e->pos().y(); if (last_y != y) emit colorSelected(y / 255.); } else if (e->button() == Qt::RightButton) { popupMenu->exec(e->globalPos()); } }
void Color_Wheel::mouseMoveEvent(QMouseEvent *ev) { if ( mouse_status == Drag_Circle ) { huem = line_to_point(ev->pos()).angle()/360.0; render_rectangle(); emit colorSelected(color()); emit colorChanged(color()); update(); } else if ( mouse_status == Drag_Square ) { QLineF glob_mouse_ln = line_to_point(ev->pos()); QLineF center_mouse_ln ( QPointF(0,0), glob_mouse_ln.p2() - glob_mouse_ln.p1() ); center_mouse_ln.setAngle(center_mouse_ln.angle()-huem*360-45); sat = center_mouse_ln.x2()/square_size()+0.5; val = center_mouse_ln.y2()/square_size()+0.5; if ( sat > 1 ) sat = 1; else if ( sat < 0 ) sat = 0; if ( val > 1 ) val = 1; else if ( val < 0 ) val = 0; emit colorSelected(color()); emit colorChanged(color()); update(); } }
void UBColorPicker::mousePressEvent ( QMouseEvent * event ) { if (event->buttons() & Qt::LeftButton) { mSelectedColorIndex++; if (mSelectedColorIndex >= mColors.size()) mSelectedColorIndex = 0; repaint(); emit colorSelected(mColors.at(mSelectedColorIndex)); } }
int MoodBox::ColorSelectionControl::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = ColorControl::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: colorSelected((*reinterpret_cast< const QColor(*)>(_a[1]))); break; case 1: setColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break; default: ; } _id -= 2; } return _id; }
QPlatformColorDialogHelper *QQuickQColorDialog::helper() { QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); if (parentItem) m_parentWindow = parentItem->window(); if (!m_dlgHelper) { m_dlgHelper = new QColorDialogHelper(); connect(m_dlgHelper, SIGNAL(currentColorChanged(QColor)), this, SLOT(setCurrentColor(QColor))); connect(m_dlgHelper, SIGNAL(colorSelected(QColor)), this, SLOT(setColor(QColor))); connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); } return m_dlgHelper; }
WallpaperChooser::WallpaperChooser(QWidget *parent) : QWidget(parent) // This widget is shown on the bottom of the screen, // it allows to select a wallpaper and some other parameters { mainColor = QColor(Qt::white); // Used to build the gradient with a cool color, TODO: make it changeable m_settings = new QSettings("Desktop", "Desktop"); m_URLList = m_settings->value("WallpaperList").toStringList(); m_settings->value("BackgroundColor", Qt::black).value<QColor>(); layout = new QGridLayout(this); wallpaperList = new QListWidget(); wallpaperList->setStyleSheet("QListWidget{background-color: transparent; border: none;}"); wallpaperList->setViewMode(QListView::IconMode); wallpaperList->setIconSize(QSize(100, 100)); wallpaperList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); wallpaperList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); wallpaperList->setFlow(QListWidget::TopToBottom); wallpaperList->setMovement(QListWidget::Static); wallpaperList->setResizeMode(QListWidget::Adjust); connect(wallpaperList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(wallSelected(QListWidgetItem*))); layout->addWidget(wallpaperList, 0, 0, 2, 4); WallsThread *thread = new WallsThread(); thread->run(wallpaperList, m_URLList); addb = new QPushButton(QIcon::fromTheme("add"), tr("Add")); connect(addb, SIGNAL(clicked()), SLOT(addWall())); layout->addWidget(addb, 0, 4); removeb = new QPushButton(QIcon::fromTheme("remove"), tr("Remove")); connect(removeb, SIGNAL(clicked()), SLOT(removeWall())); layout->addWidget(removeb, 1, 4); colorb = new QPushButton(tr("Background color")); connect(colorb, SIGNAL(clicked()), SLOT(colorSelected())); layout->addWidget(colorb, 2, 0); stylecb = new QComboBox(); stylecb->insertItems(0, QStringList() << tr("Zoomed") << tr("Centered") << tr("Resized") << tr("Enlarged")); stylecb->setCurrentIndex(m_settings->value("Style", Zoomed).toInt()); connect(stylecb, SIGNAL(currentIndexChanged(int)), this, SLOT(styleSelected(int))); layout->addWidget(stylecb, 2, 1); layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding), 2, 2); okb = new QPushButton(QIcon::fromTheme("dialog-apply"), tr("Apply")); connect(okb, SIGNAL(clicked()), this, SLOT(emitHide())); layout->addWidget(okb, 2, 4); }
int MoodBox::PaletteWidget2::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: colorSelected((*reinterpret_cast< qint32(*)>(_a[1]))); break; case 1: colorChanged((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const QColor(*)>(_a[2]))); break; case 2: setPalette((*reinterpret_cast< const Palette(*)>(_a[1]))); break; case 3: updateSelectedColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break; case 4: onColorSelected((*reinterpret_cast< const Color(*)>(_a[1]))); break; default: ; } _id -= 5; } return _id; }
Swatch::Swatch(QWidget* parent) : QWidget(parent), p(new Private(this)) { connect(&p->palette, &ColorPalette::colorsChanged, this, &Swatch::paletteModified); connect(&p->palette, &ColorPalette::columnsChanged, this, (void(QWidget::*)())&QWidget::update); connect(&p->palette, &ColorPalette::colorsUpdated, this, (void(QWidget::*)())&QWidget::update); connect(&p->palette, &ColorPalette::colorChanged, [this](int index){ if ( index == p->selected ) colorSelected( p->palette.colorAt(index) ); }); connect(&p->palette, &ColorPalette::colorRemoved, [this](int index){ if ( index == p->selected ) clearSelection(); }); setFocusPolicy(Qt::StrongFocus); setAcceptDrops(true); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setAttribute(Qt::WA_Hover, true); }
void KColorDialog::_setColor(const KColor &color, const TQString &name) { if (color.isValid()) { if (d->cbDefaultColor && d->cbDefaultColor->isChecked()) d->cbDefaultColor->setChecked(false); d->selColor = color; } else { if (d->cbDefaultColor && d->cbDefaultColor->isChecked()) d->cbDefaultColor->setChecked(true); d->selColor = d->defaultColor; } showColor( d->selColor, name ); emit colorSelected( d->selColor ); }
void QmitkPopupColorChooser::mouseMoveEvent (QMouseEvent* e) { double x(e->pos().x()); double y(e->pos().y()); x /= width(); if ( x >= 0.0 ) { //x = (int)(x / (1.0/m_Steps)) * (1.0/m_Steps); // div stepsize * stepsize x = (int)(x * (float)(m_Steps-1)) / (float)(m_Steps-1); // same as above if (x > 1.0) x = 1.0; if (x < 0.0) x = 0.0; } y /= height(); if (y >= 1.0) y = 0.9; if (y < 0.0) y = 0.0; y = (int)(y * (float)m_Steps) / (float)m_Steps; m_H = static_cast<int>( y * 359.0 ); if ( x >= 0.5 ) { m_S = static_cast<int>( (1.0 - x) * 511.0 ); if ( m_S > 255 ) m_S = 255; m_V = 255; } else { m_S = 255; if ( x < 0.0 ) m_V = 0; else { m_V = static_cast<int>( x * 511.0 + 511.0 / (float)(m_Steps-1) ); if ( m_V > 255 ) m_V = 255; } } QColor color; color.setHsv(m_H, m_S, m_V); emit colorSelected( color ); }
void ColorWheel::setColor(const QColor &color) { if (color == m_currentColor) { return; } if (color.hue() != m_currentColor.hue()) { hueChanged(color.hue()); } if (color.saturation() != m_currentColor.saturation() || color.value() != m_currentColor.value() ) { svChanged(color); } update(); emit colorSelected(color); }
void KColorCells::mouseReleaseEvent( TQMouseEvent *e ) { int cell = posToCell(mPos); int currentCell = posToCell(e->pos()); // If we release the mouse in another cell and we don't have // a drag we should ignore this event. if (currentCell != cell) cell = -1; if ( (cell != -1) && (selected != cell) ) { int prevSel = selected; selected = cell; updateCell( prevSel/numCols(), prevSel%numCols() ); updateCell( cell/numCols(), cell%numCols() ); } inMouse = false; if (cell != -1) emit colorSelected( cell ); }
void FancyPlotterSettings::editSensor() { if ( !mView->selectionModel() ) return; const QModelIndex index = mView->selectionModel()->currentIndex(); if ( !index.isValid() ) return; SensorModelEntry sensor = mModel->sensor( index ); KColorDialog dialog(this, true); connect(&dialog, SIGNAL(colorSelected(QColor)), this, SLOT(setColorForSelectedItem(QColor))); QColor color = sensor.color(); dialog.setColor(color); int result = dialog.exec(); if ( result == KColorDialog::Accepted ) sensor.setColor( dialog.color() ); //If it's not accepted, make sure we set the color back to how it was mModel->setSensor( sensor, index ); }
void PaletteWidget::mousePressEvent(QMouseEvent * event) { event->accept(); auto pos = event->localPos(); int x = pos.x() / PIXEL_SIZE_X; int y = pos.y() / PIXEL_SIZE_Y; int color = 8 * y + x; auto state = State::getInstance(); int pen = state->getSelectedPen(); int oldColor = state->getColorForPen(pen); if (oldColor != color) { state->getUndoStack()->push(new SetColorCommand(state, color, pen)); emit colorSelected(); update(); } }
EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, const QHash<qint64, OsmPlacemarkData> *relations, QWidget *parent ) : QDialog( parent ), d( new Private( placemark ) ) { d->setupUi( this ); // Store initial style so that it can be restored if the 'Cancel' button is pressed. d->m_initialStyle = *placemark->style(); d->m_initialVisualCategory = placemark->visualCategory(); d->m_hadInitialOsmData = placemark->hasOsmData(); if ( d->m_hadInitialOsmData ) { d->m_initialOsmData = placemark->osmData(); } // If the placemark has just been created, assign it a default name. if ( placemark->name().isNull() ) { placemark->setName( tr("Untitled Placemark") ); } // Setup id, name, icon link and latitude/longitude values. d->m_header->setId( placemark->id() ); d->m_initialId = placemark->id(); d->m_header->setName( placemark->name() ); d->m_initialName = placemark->name(); d->m_isPlacemarkVisible->setChecked( placemark->isVisible() ); d->m_initialIsPlacemarkVisible = placemark->isVisible(); d->m_header->setIconLink( placemark->style()->iconStyle().iconPath() ); d->m_header->setTargetId( placemark->targetId() ); d->m_initialTargetId = placemark->targetId(); MarbleWidget* marbleWidget = dynamic_cast<MarbleWidget*>( parent ); if( marbleWidget != 0 ) { const AngleUnit defaultAngleUnit = marbleWidget->defaultAngleUnit(); const GeoDataCoordinates::Notation notation = (defaultAngleUnit == DecimalDegree) ? GeoDataCoordinates::Decimal : (defaultAngleUnit == DMSDegree) ? GeoDataCoordinates::DMS : /* else, UTM */ GeoDataCoordinates::DMS; d->m_header->setNotation( notation ); } connect( d->m_header, SIGNAL(valueChanged()), this, SLOT( updateTextAnnotation()) ); d->m_formattedTextWidget->setText( placemark->description() ); d->m_initialDescription = placemark->description(); d->m_initialDescriptionIsCDATA = placemark->descriptionIsCDATA(); d->m_isBalloonVisible->setChecked( placemark->isBalloonVisible() ); d->m_initialIsBaloonVisible = placemark->isBalloonVisible(); d->m_header->setLatitude( placemark->coordinate().latitude( GeoDataCoordinates::Degree ) ); d->m_header->setLongitude( placemark->coordinate().longitude( GeoDataCoordinates::Degree ) ); d->m_initialCoords = GeoDataCoordinates( d->m_header->longitude(), d->m_header->latitude(), 0, GeoDataCoordinates::Degree ); // There's no point showing Relations and Tags tabs if the editor was not // loaded from the annotate plugin ( loaded from tourWidget.. ) if ( relations ) { // Adding the osm tag editor widget tab d->m_osmTagEditorWidget = new OsmTagEditorWidget( placemark, this ); d->tabWidget->addTab( d->m_osmTagEditorWidget, tr( "Tags" ) ); QObject::connect( d->m_osmTagEditorWidget, SIGNAL( placemarkChanged( GeoDataFeature* ) ), this, SLOT( updateTextAnnotation() ) ); // Adding the osm relation editor widget tab d->m_osmRelationManagerWidget = new OsmRelationManagerWidget( placemark, relations, this ); d->tabWidget->addTab( d->m_osmRelationManagerWidget, tr( "Relations" ) ); QObject::connect( d->m_osmRelationManagerWidget, SIGNAL( relationCreated( const OsmPlacemarkData& ) ), this, SIGNAL( relationCreated( const OsmPlacemarkData& ) ) ); } // Adding the elevation widget tab d->m_elevationWidget = new Ui::ElevationWidget; QWidget *elevationTab = new QWidget; d->m_elevationWidget->setupUi( elevationTab ); d->tabWidget->addTab( elevationTab, tr("Elevation") ); qreal altitude = d->m_placemark->coordinate().altitude(); MarbleLocale *locale = MarbleGlobal::getInstance()->locale(); if ( altitude == 0.0 ) { switch ( locale->measurementSystem() ) { case MarbleLocale::MetricSystem: d->m_elevationUnit = MarbleLocale::Meter; break; case MarbleLocale::ImperialSystem: d->m_elevationUnit = MarbleLocale::Foot; break; case MarbleLocale::NauticalSystem: d->m_elevationUnit = MarbleLocale::NauticalMile; break; } d->m_elevationWidget->elevationSpinBox->setSuffix( locale->unitAbbreviation((d->m_elevationUnit)) ); } else { qreal convertedAltitude; const MarbleLocale::MeasurementSystem currentSystem = locale->measurementSystem(); locale->meterToTargetUnit( altitude, currentSystem, convertedAltitude, d->m_elevationUnit ); d->m_elevationWidget->elevationSpinBox->setValue( convertedAltitude ); d->m_elevationWidget->elevationSpinBox->setSuffix( locale->unitAbbreviation(d->m_elevationUnit) ); } // Adjust icon and label scales. d->m_iconScale->setValue( placemark->style()->iconStyle().scale() ); connect( d->m_iconScale, SIGNAL(valueChanged(double)), this, SLOT(updateTextAnnotation()) ); d->m_labelScale->setValue( placemark->style()->labelStyle().scale() ); connect( d->m_labelScale, SIGNAL(valueChanged(double)), this, SLOT(updateTextAnnotation()) ); // Adjust the current color of the two push buttons' pixmap to resemble the label and icon colors. const GeoDataLabelStyle labelStyle = placemark->style()->labelStyle(); const GeoDataIconStyle iconStyle = placemark->style()->iconStyle(); QPixmap labelPixmap( d->m_labelButton->iconSize().width(), d->m_labelButton->iconSize().height() ); labelPixmap.fill( labelStyle.color() ); d->m_labelButton->setIcon( QIcon( labelPixmap ) ); QPixmap iconPixmap( d->m_iconButton->iconSize().width(), d->m_iconButton->iconSize().height() ); iconPixmap.fill( iconStyle.color() ); d->m_iconButton->setIcon( QIcon( iconPixmap ) ); // Setup the color dialogs. d->m_labelColorDialog = new QColorDialog( this ); d->m_labelColorDialog->setOption( QColorDialog::ShowAlphaChannel ); d->m_labelColorDialog->setCurrentColor( labelStyle.color() ); connect( d->m_labelButton, SIGNAL(clicked()), d->m_labelColorDialog, SLOT(exec()) ); connect( d->m_labelColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateLabelDialog(QColor)) ); connect( d->m_labelColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateTextAnnotation()) ); d->m_iconColorDialog = new QColorDialog( this ); d->m_iconColorDialog->setOption( QColorDialog::ShowAlphaChannel ); d->m_iconColorDialog->setCurrentColor( iconStyle.color() ); connect( d->m_iconButton, SIGNAL(clicked()), d->m_iconColorDialog, SLOT(exec()) ); connect( d->m_iconColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateIconDialog(QColor)) ); connect( d->m_iconColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateTextAnnotation()) ); connect( d->m_isBalloonVisible, SIGNAL(toggled(bool)), this, SLOT(updateTextAnnotation()) ); // Promote "Ok" button to default button. d->buttonBox->button( QDialogButtonBox::Ok )->setDefault( true ); connect( d->buttonBox->button( QDialogButtonBox::Ok ), SIGNAL(pressed()), this, SLOT(checkFields()) ); connect( this, SIGNAL(accepted()), SLOT(updateTextAnnotation()) ); connect( this, SIGNAL(accepted()), SLOT(updatePlacemarkAltitude()) ); connect( this, SIGNAL(finished(int)), SLOT(restoreInitial(int)) ); // Ensure that the dialog gets deleted when closing it (either when clicking OK or // Close). connect( this, SIGNAL(finished(int)), SLOT(deleteLater()) ); }
void QmitkPopupColorChooser::keyReleaseEvent(QKeyEvent*) { emit colorSelected( m_OriginalColor ); close(); }
void QmitkColorPropertyEditor::mouseReleaseEvent(QMouseEvent*) { disconnect( colorChooser, SIGNAL(colorSelected(QColor)), this, SLOT(onColorSelected(QColor)) ); }
void ColorWheel::mouseReleaseEvent(QMouseEvent *) { m_isInWheel = false; m_isInSquare = false; emit colorSelected(m_currentColor); }
void KisScratchPad::pick(KoPointerEvent *event) { emit colorSelected(KisToolUtils::pick(m_paintLayer->projection(), event->point.toPoint())); }
QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& color, Layout widgetLayout ) : QgsPanelWidget( parent ) , mAllowAlpha( true ) , mLastCustomColorIndex( 0 ) , mPickingColor( false ) { setupUi( this ); if ( widgetLayout == LayoutVertical ) { // shuffle stuff around QVBoxLayout* newLayout = new QVBoxLayout(); newLayout->addWidget( mTabWidget ); newLayout->addWidget( mSlidersWidget ); newLayout->addWidget( mPreviewWidget ); newLayout->addWidget( mSwatchesWidget ); delete layout(); setLayout( newLayout ); } QSettings settings; mSchemeList->header()->hide(); mSchemeList->setColumnWidth( 0, 44 ); //get schemes with ShowInColorDialog set refreshSchemeComboBox(); QList<QgsColorScheme *> schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); //choose a reasonable starting scheme int activeScheme = settings.value( "/Windows/ColorDialog/activeScheme", 0 ).toInt(); activeScheme = activeScheme >= mSchemeComboBox->count() ? 0 : activeScheme; mSchemeList->setScheme( schemeList.at( activeScheme ) ); mSchemeComboBox->setCurrentIndex( activeScheme ); updateActionsForCurrentScheme(); //listen out for selection changes in list, so we can enable/disable the copy colors option connect( mSchemeList->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( listSelectionChanged( QItemSelection, QItemSelection ) ) ); //copy action defaults to disabled mActionCopyColors->setEnabled( false ); connect( mActionCopyColors, SIGNAL( triggered() ), mSchemeList, SLOT( copyColors() ) ); connect( mActionPasteColors, SIGNAL( triggered() ), mSchemeList, SLOT( pasteColors() ) ); connect( mActionExportColors, SIGNAL( triggered() ), this, SLOT( exportColors() ) ); connect( mActionImportColors, SIGNAL( triggered() ), this, SLOT( importColors() ) ); connect( mActionImportPalette, SIGNAL( triggered() ), this, SLOT( importPalette() ) ); connect( mActionRemovePalette, SIGNAL( triggered() ), this, SLOT( removePalette() ) ); connect( mActionNewPalette, SIGNAL( triggered() ), this, SLOT( newPalette() ) ); connect( mRemoveColorsFromSchemeButton, SIGNAL( clicked() ), mSchemeList, SLOT( removeSelection() ) ); QMenu* schemeMenu = new QMenu( mSchemeToolButton ); schemeMenu->addAction( mActionCopyColors ); schemeMenu->addAction( mActionPasteColors ); schemeMenu->addSeparator(); schemeMenu->addAction( mActionImportColors ); schemeMenu->addAction( mActionExportColors ); schemeMenu->addSeparator(); schemeMenu->addAction( mActionNewPalette ); schemeMenu->addAction( mActionImportPalette ); schemeMenu->addAction( mActionRemovePalette ); schemeMenu->addAction( mActionShowInButtons ); mSchemeToolButton->setMenu( schemeMenu ); connect( mSchemeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( schemeIndexChanged( int ) ) ); connect( mSchemeList, SIGNAL( colorSelected( QColor ) ), this, SLOT( setColor( QColor ) ) ); mOldColorLabel->hide(); mVerticalRamp->setOrientation( QgsColorRampWidget::Vertical ); mVerticalRamp->setInteriorMargin( 2 ); mVerticalRamp->setShowFrame( true ); mRedSlider->setComponent( QgsColorWidget::Red ); mGreenSlider->setComponent( QgsColorWidget::Green ); mBlueSlider->setComponent( QgsColorWidget::Blue ); mHueSlider->setComponent( QgsColorWidget::Hue ); mSaturationSlider->setComponent( QgsColorWidget::Saturation ); mValueSlider->setComponent( QgsColorWidget::Value ); mAlphaSlider->setComponent( QgsColorWidget::Alpha ); mSwatchButton1->setShowMenu( false ); mSwatchButton1->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton2->setShowMenu( false ); mSwatchButton2->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton3->setShowMenu( false ); mSwatchButton3->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton4->setShowMenu( false ); mSwatchButton4->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton5->setShowMenu( false ); mSwatchButton5->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton6->setShowMenu( false ); mSwatchButton6->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton7->setShowMenu( false ); mSwatchButton7->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton8->setShowMenu( false ); mSwatchButton8->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton9->setShowMenu( false ); mSwatchButton9->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton10->setShowMenu( false ); mSwatchButton10->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton11->setShowMenu( false ); mSwatchButton11->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton12->setShowMenu( false ); mSwatchButton12->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton13->setShowMenu( false ); mSwatchButton13->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton14->setShowMenu( false ); mSwatchButton14->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton15->setShowMenu( false ); mSwatchButton15->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton16->setShowMenu( false ); mSwatchButton16->setBehaviour( QgsColorButton::SignalOnly ); //restore custom colors mSwatchButton1->setColor( settings.value( "/Windows/ColorDialog/customColor1", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton2->setColor( settings.value( "/Windows/ColorDialog/customColor2", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton3->setColor( settings.value( "/Windows/ColorDialog/customColor3", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton4->setColor( settings.value( "/Windows/ColorDialog/customColor4", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton5->setColor( settings.value( "/Windows/ColorDialog/customColor5", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton6->setColor( settings.value( "/Windows/ColorDialog/customColor6", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton7->setColor( settings.value( "/Windows/ColorDialog/customColor7", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton8->setColor( settings.value( "/Windows/ColorDialog/customColor8", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton9->setColor( settings.value( "/Windows/ColorDialog/customColor9", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton10->setColor( settings.value( "/Windows/ColorDialog/customColor10", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton11->setColor( settings.value( "/Windows/ColorDialog/customColor11", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton12->setColor( settings.value( "/Windows/ColorDialog/customColor12", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton13->setColor( settings.value( "/Windows/ColorDialog/customColor13", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton14->setColor( settings.value( "/Windows/ColorDialog/customColor14", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton15->setColor( settings.value( "/Windows/ColorDialog/customColor15", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton16->setColor( settings.value( "/Windows/ColorDialog/customColor16", QVariant( QColor() ) ).value<QColor>() ); //restore sample radius mSpinBoxRadius->setValue( settings.value( "/Windows/ColorDialog/sampleRadius", 1 ).toInt() ); mSamplePreview->setColor( QColor() ); if ( color.isValid() ) { setColor( color ); } //restore active component radio button int activeRadio = settings.value( "/Windows/ColorDialog/activeComponent", 2 ).toInt(); switch ( activeRadio ) { case 0: mHueRadio->setChecked( true ); break; case 1: mSaturationRadio->setChecked( true ); break; case 2: mValueRadio->setChecked( true ); break; case 3: mRedRadio->setChecked( true ); break; case 4: mGreenRadio->setChecked( true ); break; case 5: mBlueRadio->setChecked( true ); break; } int currentTab = settings.value( "/Windows/ColorDialog/activeTab", 0 ).toInt(); mTabWidget->setCurrentIndex( currentTab ); #ifdef Q_OS_MAC //disable color picker tab for OSX, as it is impossible to grab the mouse under OSX //see note for QWidget::grabMouse() re OSX Cocoa //http://qt-project.org/doc/qt-4.8/qwidget.html#grabMouse mTabWidget->removeTab( 3 ); #endif //setup connections connect( mColorBox, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorWheel, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorText, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mVerticalRamp, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mRedSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mGreenSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mBlueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mHueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mValueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSaturationSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mAlphaSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorPreview, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton1, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton2, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton3, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton4, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton5, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton6, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton7, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton8, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton9, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton10, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton11, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton12, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton13, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton14, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton15, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton16, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); }