Пример #1
0
/** Shows a color dialog and hides this dialog temporarily.
 * Also, reorder the mainWindow and the color dialog to avoid overlapping, if possible. */
void CustomizeThemeDialog::showColorDialog()
{
	_targetedColor = findChild<Reflector*>(sender()->objectName().replace("ToolButton", "Widget"));
	if (_targetedColor) {
		QPalette::ColorRole cr = _targetedColor->colorRole();
		_targetedColor->setColor(QApplication::palette().color(cr));

		this->setAttribute(Qt::WA_DeleteOnClose, false);
		ColorDialog *colorDialog = new ColorDialog(this);
		colorDialog->setCurrentColor(_targetedColor->color());
		this->hide();
		int i = colorDialog->exec();
		if (i >= 0) {
			// Automatically adjusts Reflector Widgets for Text colors if one hasn't check the option
			if (!SettingsPrivate::instance()->isCustomTextColorOverriden()) {
				QPalette palette = QApplication::palette();
				if (cr == QPalette::Base) {
					fontColorWidget->setColor(palette.color(QPalette::Text));
				} else if (cr == QPalette::Highlight) {
					selectedFontColorWidget->setColor(palette.color(QPalette::HighlightedText));
				}
			}
			this->show();
			this->setAttribute(Qt::WA_DeleteOnClose);
		}
	}
}
/** Shows a color dialog and hides this dialog temporarily.
 * Also, reorder the mainWindow and the color dialog to avoid overlapping, if possible. */
void CustomizeThemeDialog::showColorDialog()
{
	_targetedColor = findChild<Reflector*>(sender()->objectName().replace("ToolButton", "Widget"));
	if (_targetedColor) {
		qDebug() << _targetedColor->objectName() << _targetedColor->color();
		_targetedColor->setColor(SettingsPrivate::instance()->customColors(_targetedColor->colorRole()));
		qDebug() << _targetedColor->objectName() << _targetedColor->color();
		ColorDialog *colorDialog = new ColorDialog(this);
		colorDialog->setCurrentColor(_targetedColor->color());
		//qDebug() << colorDialog->currentColor() << _targetedColor->color();
		this->hide();
		colorDialog->exec();
	}
}