Example #1
0
/*! \~russian
 * \brief Метод инициализирует элементы настройки цвета в соответствии с переданной палитрой.
 * \param palette - палитра для инициализации
 */
void Settings::initColorPickers(QPalette palette)
{
    ui->Frame_Style_Window->setColor( palette.window().color() );
    ui->Frame_Style_WindowText->setColor( palette.windowText().color() );
    ui->Frame_Style_Base->setColor( palette.base().color() );
    ui->Frame_Style_AlternateBase->setColor( palette.alternateBase().color() );
    ui->Frame_Style_ToolTipBase->setColor( palette.toolTipBase().color() );
    ui->Frame_Style_ToolTipText->setColor( palette.toolTipText().color() );
    ui->Frame_Style_Text->setColor( palette.text().color() );
    ui->Frame_Style_Button->setColor( palette.button().color() );
    ui->Frame_Style_ButtonText->setColor( palette.buttonText().color() );
    ui->Frame_Style_BrightText->setColor( palette.brightText().color() );
    ui->Frame_Style_Link->setColor( palette.link().color() );
    ui->Frame_Style_Highlight->setColor( palette.highlight().color() );
    ui->Frame_Style_HighlightedText->setColor( palette.highlightedText().color() );
}
Example #2
0
QVariantMap Bridge::get_palette()
{
    QVariantMap colors;
    QPalette palette = qApp->palette();
    colors.insert("window", palette.window().color().name());
    colors.insert("window_text", palette.windowText().color().name());
    colors.insert("base", palette.base().color().name());
    colors.insert("alternate_base", palette.alternateBase().color().name());
    colors.insert("text", palette.text().color().name());
    colors.insert("button", palette.buttonText().color().name());
    colors.insert("bright_text", palette.brightText().color().name());
    colors.insert("light", palette.light().color().name());
    colors.insert("midlight", palette.midlight().color().name());
    colors.insert("dark", palette.dark().color().name());
    colors.insert("mid", palette.mid().color().name());
    colors.insert("shadow", palette.shadow().color().name());
    colors.insert("highlight", palette.highlight().color().name());
    colors.insert("highlight_text", palette.highlightedText().color().name());
    colors.insert("link", palette.link().color().name());
    colors.insert("link_visited", palette.linkVisited().color().name());
    return colors;
}
void KTThemeSelector::setupChooseColor()
{
	DVHBox *hbox = new DVHBox(this, Qt::Horizontal);
	DVHBox *box1 = new DVHBox(hbox, Qt::Vertical);
	box1->boxLayout()->setMargin(10);
	m_general = new QGroupBox(tr("General"), box1);
	
	QGridLayout *layout1 = new QGridLayout(m_general);
	
	QStringList labels1 = QStringList() << tr("Text") << tr("Base") << tr("Foreground") << tr("Background") << tr("Button") << tr("Button Text");
	
	QStringList names = QStringList() << "Text" << "Base" << "Foreground" << "Background" << "Button" << "ButtonText";
	
	QPalette colorGroup = QApplication::palette();
	
	
	QList<QColor> colors = QList<QColor>() << colorGroup.text ().color() << colorGroup.base().color() << colorGroup.foreground().color() << colorGroup.background().color() << colorGroup.button().color() << colorGroup.buttonText().color();
	
	for(int i = 0; i < labels1.count(); i++)
	{
		layout1->addWidget(new QLabel(labels1[i], m_general), i, 0 );
		DColorButton *button = new DColorButton(m_general);
		button->setObjectName(names[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		
		m_generalButtonGroup.addButton(button);
		layout1->addWidget(button, i, 1);
		m_generalSection.insert(names[i], colors[i].name());
	}
	
	m_effects = new QGroupBox(tr("Effects"), box1);
	
	QGridLayout *layout2 = new QGridLayout(m_effects);
	
	QStringList labels2 = QStringList() << tr("Light") << tr("Midlight") << tr("Dark") << tr("Mid");
	QStringList names2 = QStringList() << "Light" << "Midlight" << "Dark" << "Mid";
	
	colors.clear();
	colors << colorGroup.light().color() << colorGroup.midlight().color() << colorGroup.dark().color() << colorGroup.mid().color();
	
	for(int i = 0; i < labels2.count(); i++)
	{
		layout2->addWidget(new QLabel(labels2[i], m_effects), i, 0 );
		DColorButton *button = new DColorButton(m_effects);
		button->setObjectName(names2[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		m_effectsButtonGroup.addButton(button);
		layout2->addWidget(button, i, 1);
		m_effectsSection.insert(names2[i], colors[i].name());
	}
	////////////
	
	DVHBox *box2 = new DVHBox(hbox, Qt::Vertical);
	box2->boxLayout()->setMargin(10);
	m_selections = new QGroupBox(tr("Selections"), box2);
	
	QGridLayout *layout3 = new QGridLayout(m_selections);
	
	QStringList labels3 = QStringList() << tr("Highlight") << tr("Highlighted Text");
	QStringList names3 = QStringList() << "Highlight" << "HighlightedText";
	colors.clear();
	colors << colorGroup.highlight().color() << colorGroup.highlightedText().color();
	
	for(int i = 0; i < labels3.count(); i++)
	{
		layout3->addWidget(new QLabel(labels3[i], m_selections), i, 0 );
		DColorButton *button = new DColorButton(m_selections);
		button->setObjectName(names3[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		m_selectionsButtonGroup.addButton(button);
		layout3->addWidget(button, i, 1);
		m_selectionsSection.insert(names3[i], colors[i].name());
	}
	
	m_textEffects = new QGroupBox(tr("Text effects"), box2);
	
	QGridLayout *layout4 = new QGridLayout(m_textEffects);
	QStringList labels4 = QStringList() << tr("Bright Text") << tr("Link") << tr("Link Visited");
	QStringList names4 = QStringList() << "BrightText" << "Link" << "LinkVisited";
	
	colors.clear();
	colors << colorGroup.brightText().color() << colorGroup.link().color() << colorGroup.linkVisited().color();
	
	for(int i = 0; i < labels4.count(); i++)
	{
		layout4->addWidget(new QLabel(labels4[i], m_textEffects), i, 0 );
		DColorButton *button = new DColorButton(m_textEffects);
		button->setObjectName(names4[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		m_textEffectsButtonGroup.addButton(button);
		layout4->addWidget(button, i, 1);
		m_textEffectsSection.insert(names4[i], colors[i].name());
	}
	
	QGroupBox *schemeWidget = new QGroupBox(tr("Schema"), box2); // FIXME: add vertical layout
	QVBoxLayout *schemaLayout = new QVBoxLayout;
	
	m_allSchemes = new QTreeWidget;
	m_allSchemes->setHeaderLabels ( QStringList() << tr("Schema") << tr( "Owner" ) << tr( "Date" ) );
	m_allSchemes->header()->setResizeMode(QHeaderView::Stretch);
	
	schemaLayout->addWidget(m_allSchemes);
	
	connect(m_allSchemes, SIGNAL(itemDoubleClicked (QTreeWidgetItem *, int )), this, SLOT(loadSchemaFromListView( QTreeWidgetItem *, int )));
	
	QPushButton *saveSchemeButton = new QPushButton(tr("Save schema"));
	connect(saveSchemeButton, SIGNAL(clicked()), SLOT(saveSchema()));
	
	schemaLayout->addWidget(saveSchemeButton);
	
	schemeWidget->setLayout(schemaLayout);
	
	new DSeparator(this);
	new QLabel(tr("Style"), this);
	DStyleComboBox *styleComboBox = new DStyleComboBox(this);
	Q_UNUSED(styleComboBox);
	new DSeparator(this);
	m_useColors = new QCheckBox(tr("Use this colors"), this);
	
	connect(&m_generalButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseGeneralColor(QAbstractButton * )));
	connect(&m_effectsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseEffectsColor(QAbstractButton * )));
	connect(&m_selectionsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseSelectionsColor(QAbstractButton * )));
	connect(&m_textEffectsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseTextEffectsColor(QAbstractButton * )));
}
Example #4
0
//------------------------------------------------------------
//.-
//.F ScaleDraw::drawLabel
//	Draws the number label for a major scale tick
//
//.u Parameters
//.p  QPainter *p,  double val
//
//------------------------------------------------------------
void ScaleDraw::drawLabel(QPainter *p, const QPalette& palette, double curValue, double val, bool isSpecialText) const
{

    static QString label;
    static double pi_4 = M_PI * 0.25;
    static double pi_75 = M_PI * 0.75;

    double arc;
    int xpos, ypos, x0, y0;
    int tval;

    QFontMetrics fm = p->fontMetrics();

    tval = transform(val);

    // correct rounding errors if val = 0
    if ((!d_scldiv.logScale()) && (MusECore::qwtAbs(val) < MusECore::qwtAbs(step_eps * d_scldiv.majStep())))
       val = 0.0;

    if(isSpecialText && !_specialText.isEmpty())
      label = _specialText;
    else
      label = composeLabelText(val, d_fmt, d_prec);

    switch(d_orient)
    {
    case Right:
// REMOVE Tim. Trackinfo. Changed.      
// 	p->drawText(d_xorg + d_majLen + d_hpad,
// 		    tval + (fm.ascent()-1) / 2,
// 		    label);
        x0 = d_xorg + d_majLen + d_hpad;
        y0 = tval + (fm.ascent()-1) / 2;
	break;
    case Left:
    case InsideVertical:
// 	p->drawText(d_xorg - d_majLen - d_hpad - fm.width(label),
// 		    tval + (fm.ascent() -1) / 2,
// 		    label);
        x0 = d_xorg - d_majLen - d_hpad - fm.width(label);
        y0 = tval + (fm.ascent() -1) / 2;
	break;
    case Bottom:
// 	p->drawText(tval - (fm.width(label)-1) / 2, d_yorg + d_majLen + d_vpad + fm.ascent(), label);
        x0 = tval - (fm.width(label)-1) / 2;
        y0 = d_yorg + d_majLen + d_vpad + fm.ascent();
	break;
        
    case InsideHorizontal:
        x0 = tval - (fm.width(label)-1) / 2;
        //y0 = d_yorg + d_majLen + d_vpad + fm.ascent();
        y0 = d_majLen + d_vpad + fm.ascent();
        break;
        
    case Round:

	if ((tval > d_minAngle + 359 * 16) || (tval < d_minAngle - 359 * 16))
// 	   break;
          return;
	
	arc = double(tval) / 16.0 * M_PI / 180.0;
	
	// Map arc into the interval -pi <= arc <= pi
	if ((arc < -M_PI) || (arc > M_PI))
	   arc -= floor((arc + M_PI) / M_PI * 0.5) * 2.0 * M_PI;
	
	xpos = 1 + MusECore::qwtInt(d_xCenter + (d_radius + double(d_majLen + d_vpad)) * sin(arc));
	ypos = MusECore::qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc));
	
	if (arc < -pi_75)
	{
// 	    p->drawText(xpos - MusECore::qwtInt(double(fm.width(label))
// 				      * (1.0 + (arc + pi_75) * M_2_PI) ),
// 			ypos + fm.ascent() - 1,
// 			label);
         x0 = xpos - MusECore::qwtInt(double(fm.width(label))
                                   * (1.0 + (arc + pi_75) * M_2_PI));
         y0 = ypos + fm.ascent() - 1;
	}
	else if (arc < -M_PI_4)
	{
// // 	    p->drawText(xpos - fm.width(label),
// 			
// 			
// 			ypos - MusECore::qwtInt(double(fm.ascent() - 1)
// 				      * (arc + M_PI_4) * M_2_PI),
// 			label);
            x0 = xpos - fm.width(label);
            y0 = ypos - MusECore::qwtInt(double(fm.ascent() - 1)
                                      * (arc + M_PI_4) * M_2_PI);
	}
	else if (arc < pi_4)
	{
// 	    p->drawText(xpos + MusECore::qwtInt(double(fm.width(label))
// 				      * ( arc - M_PI_4 ) * M_2_PI ),
// 			ypos,
// 			label);
            x0 = xpos + MusECore::qwtInt(double(fm.width(label))
                                      * ( arc - M_PI_4 ) * M_2_PI );
            y0 = ypos;
	}
	else if (arc < pi_75)
	{
// 	    p->drawText(xpos,
// 			ypos + MusECore::qwtInt(double(fm.ascent() - 1)
// 				      * (arc - M_PI_4) * M_2_PI),
// 			label);
            x0 = xpos;
            y0 = ypos + MusECore::qwtInt(double(fm.ascent() - 1)
                                      * (arc - M_PI_4) * M_2_PI);
	}
	else
	{
// 	    p->drawText(xpos - MusECore::qwtInt(double(fm.width(label))
// 				      * ( arc - pi_75) * M_2_PI ),
// 			ypos + fm.ascent() - 1,
// 			label);
            x0 = xpos - MusECore::qwtInt(double(fm.width(label))
                                      * ( arc - pi_75) * M_2_PI );
            y0 = ypos + fm.ascent() - 1;
	}
	break;
    case Top:
    default:
// 	p->drawText(tval - (fm.width(label)-1) / 2, d_yorg - d_majLen - d_vpad, label);
        x0 = tval - (fm.width(label)-1) / 2;
        y0 = d_yorg - d_majLen - d_vpad;
	break;
    }

// REMOVE Tim. Trackinfo. Added.
  switch(d_textHighlightMode)
  {
    case TextHighlightNone:
      p->setPen(palette.text().color());
      p->drawText(x0, y0, label);
    break;

    case TextHighlightAlways:
      p->setPen(palette.brightText().color());
      p->drawText(x0, y0, label);
    break;

    case TextHighlightSplit:
      if(val > curValue)
      {
        p->setPen(palette.text().color());
        p->drawText(x0, y0, label);
      }
      else
      {
        p->setPen(palette.brightText().color());
        p->drawText(x0, y0, label);
      }
    break;

    case TextHighlightShadow:
      // Text shadow:
      //p->setPen(palette.shadow().color());
      p->setPen(Qt::black);
      p->drawText(x0 + 1, y0 + 1, label);
      // Text:
      //p->setPen(palette.brightText().color().darker(120));  // Meh, not quite so bright,
      p->setPen(QColor(Qt::white).darker(120));  // Meh, not quite so bright,
      p->drawText(x0, y0, label);
    break;
    
    case TextHighlightSplitAndShadow:
      //fprintf(stderr, "ScaleDraw::drawLabel val:%.20f curValue:%.20f\n", val, curValue); // REMOVE Tim. Trackinfo.
      if(val > curValue)
      {
        //fprintf(stderr, "   drawing normal\n"); // REMOVE Tim. Trackinfo.
        p->setPen(palette.text().color());
        p->drawText(x0, y0, label);
      }
      else
      {
        // Text shadow:
        //p->setPen(palette.text().color());
        //p->setPen(palette.shadow().color());
        p->setPen(Qt::black);
        p->drawText(x0 + 1, y0 + 1, label);
        // Text:
        //p->setPen(palette.brightText().color().darker(120)); // Meh, not quite so bright,
        p->setPen(QColor(Qt::white).darker(120)); // Meh, not quite so bright,
        p->drawText(x0, y0, label);
      }
    break;
  }

}