Beispiel #1
0
void ServiceManager::startSlot()
{
    QTreeWidgetItem *item = listServices->currentItem();
      if (!item)
	return;
	  
    workingTreeWidgetItem = item;	 
	  
    // Disable the buttons until we are done
    setButtonsAllEnabled(false);

    // Start the process
    QString prog;
    QStringList args;

    if ( wDir.isEmpty() ) {
      prog = item->text(0);
      args << "start";
    } else {
      prog = "warden";
      args << "chroot" << wIP << item->text(0) + " start";
    }


    // Show the progress GUI
    progressUI *servAction = new progressUI;
    servAction->startServ(prog, args);
    servAction->show();

    // Set item staus to pending
    item->setText(3, tr("Checking...") );

    listSelectionChanged();

}
RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
	RK_TRACE (PLUGIN);

	XMLHelper *xml = XMLHelper::getStaticHelper ();

	// basic layout
	QGridLayout *g_layout = new QGridLayout (this, 4, 3, RKGlobals::spacingHint ());

	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Variable:"), DL_INFO), this);
	g_layout->addWidget (label, 0, 2);

	select = new QPushButton (QString::null, this);
	setSelectButton (false);
	connect (select, SIGNAL (clicked ()), this, SLOT (selectPressed ()));
	g_layout->addWidget (select, 1, 0);
	g_layout->addColSpacing (1, 5);

	list = new QListView (this);
	list->setSelectionMode (QListView::Extended);
	list->addColumn (" ");		// for counter
	list->addColumn (i18n ("Name"));
	list->setSorting (2);
	g_layout->addWidget (list, 1, 2);

	// initialize properties
	addChild ("source", source = new RKComponentPropertyRObjects (this, false));
	addChild ("available", available = new RKComponentPropertyRObjects (this, true));
	addChild ("selected", selected = new RKComponentPropertyRObjects (this, false));

	// find out about options
	if (multi = xml->getBoolAttribute (element, "multi", false, DL_INFO)) {
		available->setListLength (xml->getIntAttribute (element, "min_vars", 1, DL_INFO), xml->getIntAttribute (element, "min_vars_if_any", 1, DL_INFO), xml->getIntAttribute (element, "max_vars", 0, DL_INFO));
		connect (list, SIGNAL (selectionChanged ()), this, SLOT (listSelectionChanged ()));
	} else {
		available->setListLength (1, 1, 1);

		// make it look like a line-edit
		list->header ()->hide ();
		list->setFixedHeight (list->fontMetrics ().height () + 2*list->itemMargin () + 4);	// the height of a single line including margins
		list->setColumnWidthMode (0, QListView::Manual);
		list->setColumnWidth (0, 0);
		list->setHScrollBarMode (QScrollView::AlwaysOff);
		list->setVScrollBarMode (QScrollView::AlwaysOff);
		g_layout->setRowStretch (3, 1);		// so the label does not get separated from the view
	}

	// initialize filters
	available->setClassFilter (QStringList::split (" ", xml->getStringAttribute (element, "classes", QString::null, DL_INFO)));
	setRequired (xml->getBoolAttribute (element, "required", false, DL_INFO));
	available->setTypeFilter (QStringList::split (" ", xml->getStringAttribute (element, "types", QString::null, DL_INFO)));
	available->setDimensionFilter (xml->getIntAttribute (element, "num_dimensions", 0, DL_INFO), xml->getIntAttribute (element, "min_length", 0, DL_INFO), xml->getIntAttribute (element, "max_length", INT_MAX, DL_INFO));

	connect (available, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (availablePropertyChanged (RKComponentPropertyBase *)));
	availablePropertyChanged (available);		// initialize
}
Beispiel #3
0
KornSubjectsDlg::KornSubjectsDlg(QWidget *parent)
    : KDialogBase(parent, "urldialog", true, "test", Close, Close, true), _mailDrop(new QPtrList< KMailDrop >),
      _subjects(0), _delete(0), mailDlg(0), _canDeleteMaildrop(true)
{
    _loadSubjectsCanceled = false;
    setModal(true);

    // The dialog contains a list view and several buttons.
    // Two box layouts hol dthem.
    QWidget *page = new QWidget(this);
    setMainWidget(page);
    invertSelButton = new KPushButton(i18n("&Invert Selection"), page);
    clearSelButton = new KPushButton(i18n("&Remove Selection"), page);
    deleteButton = new KPushButton(i18n("&Delete"), page);
    showButton = new KPushButton(i18n("&Show"), page);
    deleteButton->setEnabled(false);
    showButton->setEnabled(false);
    QVBoxLayout *topLayout = new QVBoxLayout(page, 0, spacingHint());
    QHBoxLayout *buttons = new QHBoxLayout();
    _list = new KListView(page);
    topLayout->addWidget(_list, 10);
    topLayout->addLayout(buttons, 0);
    buttons->addWidget(invertSelButton, 0);
    buttons->addWidget(clearSelButton, 0);
    buttons->addWidget(deleteButton, 0);
    buttons->addWidget(showButton, 0);
    buttons->addStretch(10);

    // feed the list view with its colums
    _list->setSelectionMode(QListView::Multi);
    _list->addColumn(i18n("From"));
    _list->addColumn(i18n("Subject"));
    _list->addColumn(i18n("Date"));
    _list->addColumn(i18n("Size (Bytes)"));

    // column 3 contains a number (change alignment)
    _list->setColumnAlignment(3, Qt::AlignRight);
    _list->setItemMargin(3);

    // connect the selection changed and double click events of the list view
    connect(_list, SIGNAL(selectionChanged()), this, SLOT(listSelectionChanged()));
    connect(_list, SIGNAL(executed(QListViewItem *)), this, SLOT(doubleClicked(QListViewItem *)));

    // connect the buttons
    connect(invertSelButton, SIGNAL(clicked()), this, SLOT(invertSelection()));
    connect(clearSelButton, SIGNAL(clicked()), this, SLOT(removeSelection()));
    connect(showButton, SIGNAL(clicked()), this, SLOT(showMessage()));
    connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteMessage()));
    setInitialSize(QSize(QApplication::desktop()->width(), QApplication::desktop()->height()));
}
Beispiel #4
0
void ServiceManager::enableSlot()
{
    QTreeWidgetItem *item = listServices->currentItem();
    if (!item)
      return;
	  
    workingTreeWidgetItem = item;	 
    QStringList rcList;
    QString tag = item->text(1);

    // Disable the buttons until we are done
    setButtonsAllEnabled(false);

    pcbsd::Utils::setConfFileValue( wDir + "/etc/rc.conf", tag, tag + "=\"YES\"", -1);

    // Set the service as enabled
    item->setText(4, tr("Enabled"));
    listSelectionChanged();
}
void RKVarSlot::availablePropertyChanged (RKComponentPropertyBase *) {
	RK_TRACE (PLUGIN);

	list->clear ();
	item_map.clear ();

	RK_DO (qDebug ("contained in varslot: %s", available->value ().latin1 ()), PLUGIN, DL_DEBUG);

	ObjectList objlist = available->objectList ();
	ObjectList::const_iterator it = objlist.begin ();
	int i = 1;
	while (it != objlist.end ()) {
		QListViewItem *new_item = new QListViewItem (list, QString::number (i++), (*it)->getShortName ());
		list->insertItem (new_item);
		item_map.insert (new_item, *it);
		++it;
	}

	listSelectionChanged ();		// takes care of updating the select button

	changed ();
}
Beispiel #6
0
RKValueSelector::RKValueSelector (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
	RK_TRACE (PLUGIN);

	updating = false;
	XMLHelper *xml = parent_component->xmlHelper ();
	standalone = element.tagName () == "select";

	addChild ("selected", selected = new RKComponentPropertyStringList (this, false));
	connect (selected, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (selectionPropertyChanged()));
	selected->setInternal (!standalone);
	addChild ("available", available = new RKComponentPropertyStringList (this, false));
	connect (available, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (availablePropertyChanged()));
	available->setInternal (true);
	addChild ("labels", labels = new RKComponentPropertyStringList (this, false));
	connect (labels, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (labelsPropertyChanged()));
	labels->setInternal (true);

	QVBoxLayout *vbox = new QVBoxLayout (this);
	vbox->setContentsMargins (0, 0, 0, 0);

	label_string = xml->i18nStringAttribute (element, "label", QString (), DL_INFO);
	if (!label_string.isNull ()) {
		QLabel *label = new QLabel (label_string, this);
		vbox->addWidget (label);
	}

	list_view = new QTreeView (this);
	list_view->setHeaderHidden (true);
	list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
	list_view->setRootIsDecorated (false);
	model = new QStringListModel (this);
	list_view->setModel (model);
	connect (list_view->selectionModel (), SIGNAL (selectionChanged(QItemSelection,QItemSelection)), this, SLOT (listSelectionChanged()));

	vbox->addWidget (list_view);

	XMLChildList options = xml->getChildElements (element, "option", DL_INFO);
	if (!options.isEmpty ()) {
		QStringList values_list;
		QStringList labels_list;
		QStringList selected_list;

		for (int i = 0; i < options.size (); ++i) {
			const QDomElement &child = options[i];
			QString v = xml->getStringAttribute (child, "value", QString (), DL_WARNING);
			QString l = xml->i18nStringAttribute (child, "label", v, DL_INFO);
			if (xml->getBoolAttribute (child, "checked", false, DL_INFO)) selected_list.append (v);
			labels_list.append (l);
			values_list.append (v);
		}
		available->setValueList (values_list);
		labels->setValueList (labels_list);
		selected->setValueList (selected_list);
	}
}
Beispiel #7
0
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 ) ) );
}
Beispiel #8
0
QgsColorDialogV2::QgsColorDialogV2( QWidget *parent, Qt::WindowFlags fl, const QColor& color )
    : QDialog( parent, fl )
    , mPreviousColor( color )
    , mAllowAlpha( true )
    , mLastCustomColorIndex( 0 )
    , mPickingColor( false )
{
  setupUi( this );

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/ColorDialog/geometry" ).toByteArray() );

  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 );
  mActionImportColors->setEnabled( schemeList.at( activeScheme )->isEditable() );
  mActionPasteColors->setEnabled( schemeList.at( activeScheme )->isEditable() );
  mAddColorToSchemeButton->setEnabled( schemeList.at( activeScheme )->isEditable() );
  mRemoveColorsFromSchemeButton->setEnabled( schemeList.at( activeScheme )->isEditable() );
  QgsUserColorScheme* userScheme = dynamic_cast<QgsUserColorScheme*>( schemeList.at( activeScheme ) );
  mActionRemovePalette->setEnabled( userScheme ? true : false );

  //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 );
  mSchemeToolButton->setMenu( schemeMenu );

  connect( mSchemeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( schemeIndexChanged( int ) ) );
  connect( mSchemeList, SIGNAL( colorSelected( QColor ) ), this, SLOT( setColor( QColor ) ) );

  if ( mPreviousColor.isValid() )
  {
    QPushButton* resetButton = new QPushButton( tr( "Reset" ) );
    mButtonBox->addButton( resetButton, QDialogButtonBox::ResetRole );
  }
  else
  {
    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( QgsColorButtonV2::SignalOnly );
  mSwatchButton2->setShowMenu( false );
  mSwatchButton2->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton3->setShowMenu( false );
  mSwatchButton3->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton4->setShowMenu( false );
  mSwatchButton4->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton5->setShowMenu( false );
  mSwatchButton5->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton6->setShowMenu( false );
  mSwatchButton6->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton7->setShowMenu( false );
  mSwatchButton7->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton8->setShowMenu( false );
  mSwatchButton8->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton9->setShowMenu( false );
  mSwatchButton9->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton10->setShowMenu( false );
  mSwatchButton10->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton11->setShowMenu( false );
  mSwatchButton11->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton12->setShowMenu( false );
  mSwatchButton12->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton13->setShowMenu( false );
  mSwatchButton13->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton14->setShowMenu( false );
  mSwatchButton14->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton15->setShowMenu( false );
  mSwatchButton15->setBehaviour( QgsColorButtonV2::SignalOnly );
  mSwatchButton16->setShowMenu( false );
  mSwatchButton16->setBehaviour( QgsColorButtonV2::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 );
    mColorPreview->setColor2( 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 );

  //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 ) ) );
}
void DCompleterListView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
    Q_UNUSED(deselected);
    emit listSelectionChanged(selected);
    QListView::selectionChanged(selected, deselected);
}