/** 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(); } }
void Editor::editColor() { if (!activeStack() || selection_->empty()) return; KMenu menu(i18n("Select Color")); menu.addTitle(i18n("Shortcuts")); ColorManager *cm = Application::self()->colorManager(); foreach (const ldraw::color &it, cm->colorList()) { QAction *action = menu.addAction(QIcon(ColorManager::colorPixmap(it)), it.get_entity()->name.c_str()); action->setData(it.get_id()); } menu.addTitle(i18n("Recently Used")); foreach (const ColorManager::RecentColorPair &it, cm->recentlyUsed()) { QAction *action = menu.addAction(QIcon(ColorManager::colorPixmap(it.first)), it.first.get_entity()->name.c_str()); action->setData(it.first.get_id()); } menu.addSeparator(); QAction *customize = menu.addAction(i18n("&More...")); QAction *result = menu.exec(QCursor::pos()); if (result) { if (result == customize) { ColorDialog *colordialog = new ColorDialog(Application::self()->rootWindow()); if (colordialog->exec() == QDialog::Accepted) { activeStack()->push(new CommandColor(colordialog->getSelected(), *selection_, model_)); cm->hit(colordialog->getSelected()); emit modified(); } delete colordialog; } else { ldraw::color selected(result->data().toInt()); activeStack()->push(new CommandColor(selected, *selection_, model_)); cm->hit(selected); emit modified(); } } }