Changeset c8ed26ddf1 in tspsg for src/settingsdialog.cpp


Ignore:
Timestamp:
Jul 17, 2012, 8:11:11 PM (12 years ago)
Author:
Oleksii Serdiuk
Branches:
appveyor, imgbot, master, readme
Children:
50b614b0ea
Parents:
7e8e1b444d
git-author:
Oleksii Serdiuk <contacts@…> (07/17/12 20:11:11)
git-committer:
Oleksii Serdiuk <contacts@…> (07/17/12 20:24:34)
Message:

Implemented color selection from Settings Dialog.

Changing background color appeared to be much harder than expected, so
this feature was removed for now. It is possible to change background
color of the solution output area. However, this background change
doesn't affect printing and export - there background color always stays
white. Will investigate possible workarounds later...

Closes ticket:13 - All colors should be configurable through Settings Dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/settingsdialog.cpp

    r7e8e1b444d rc8ed26ddf1  
    5252    buttonAlternateColor->setIcon(GET_ICON("format-text-color"));
    5353    buttonBorderColor->setIcon(GET_ICON("format-stroke-color"));
    54     buttonBgColor->setIcon(GET_ICON("format-fill-color"));
     54//    buttonBgColor->setIcon(GET_ICON("format-fill-color"));
    5555    buttonFont->setIcon(GET_ICON("preferences-desktop-font"));
    5656    buttonHelp->setIcon(GET_ICON("help-hint"));
     
    217217    connect(buttonFont, SIGNAL(clicked()), SLOT(buttonFontClicked()));
    218218    connect(buttonTextColor, SIGNAL(clicked()), SLOT(buttonTextColorClicked()));
     219    connect(buttonSelectedColor, SIGNAL(clicked()), SLOT(buttonSelectedColorClicked()));
     220    connect(buttonAlternateColor, SIGNAL(clicked()), SLOT(buttonAlternateColorClicked()));
     221    connect(buttonBorderColor, SIGNAL(clicked()), SLOT(buttonBorderColorClicked()));
     222//    connect(buttonBgColor, SIGNAL(clicked()), SLOT(buttonBgColorClicked()));
    219223    setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
    220224#if !defined(QT_NO_STATUSTIP) && !defined(HANDHELD)
     
    295299    selColor = QColor(settings->value("Colors/Selected", DEF_SELECTED_COLOR).toString());
    296300    altColor = QColor(settings->value("Colors/Alternate", DEF_ALTERNATE_COLOR).toString());
    297     borderColor = QColor(settings->value("Colors/Border", DEF_TABLE_COLOR).toString());
    298     bgColor = QColor(settings->value("Colors/Background", DEF_BACKGROUND_COLOR).toString());
     301    borderColor = QColor(settings->value("Colors/TableBorder", DEF_TABLE_COLOR).toString());
     302//    bgColor = QColor(settings->value("Colors/Background", DEF_BACKGROUND_COLOR).toString());
    299303    settings->endGroup();
    300304
     
    304308    labelFontExample->setText(font.family());
    305309
    306     p = boxTextColor->palette();
    307     p.setColor(QPalette::Window, textColor);
    308     boxTextColor->setPalette(p);
    309 
    310     p = boxSelectedColor->palette();
    311     p.setColor(QPalette::Window, selColor);
    312     boxSelectedColor->setPalette(p);
    313 
    314     p = boxAlternateColor->palette();
    315     p.setColor(QPalette::Window, altColor);
    316     boxAlternateColor->setPalette(p);
    317 
    318     p = boxBorderColor->palette();
    319     p.setColor(QPalette::Window, borderColor);
    320     boxBorderColor->setPalette(p);
    321 
    322     p = boxBgColor->palette();
    323     p.setColor(QPalette::Window, bgColor);
    324     boxBgColor->setPalette(p);
     310    setBgColor(boxTextColor, textColor);
     311    setBgColor(boxSelectedColor, selColor);
     312    setBgColor(boxAlternateColor, altColor);
     313    setBgColor(boxBorderColor, borderColor);
     314//    setBgColor(boxBgColor, bgColor);
    325315
    326316#ifdef HANDHELD
     
    427417    if (_fontChanged)
    428418        settings->setValue("Font", font);
    429     if (_colorChanged)
    430         settings->setValue("Colors/Text", textColor.name());
     419    if (_colorChanged) {
     420        settings->beginGroup("Colors");
     421        if (textColor != DEF_TEXT_COLOR)
     422            settings->setValue("Text", textColor.name());
     423        else
     424            settings->remove("Text");
     425        if (selColor != QColor(DEF_SELECTED_COLOR))
     426            settings->setValue("Selected", selColor.name());
     427        else
     428            settings->remove("Selected");
     429        if (altColor != DEF_ALTERNATE_COLOR)
     430            settings->setValue("Alternate",altColor.name());
     431        else
     432            settings->remove("Alternate");
     433        if (borderColor != DEF_TABLE_COLOR)
     434            settings->setValue("TableBorder", borderColor.name());
     435        else
     436            settings->remove("TableColor");
     437//        if (bgColor != DEF_BACKGROUND_COLOR)
     438//            settings->setValue("Background", bgColor.name());
     439//        else
     440//            settings->remove("Background");
     441        settings->endGroup();
     442    }
    431443    settings->endGroup();
    432444    QDialog::accept();
    433445}
    434446
     447void SettingsDialog::pickColor(QColor &where)
     448{
     449    QColor color = QColorDialog::getColor(where, this);
     450    if (color.isValid() && (where != color)) {
     451        where = color;
     452        _colorChanged = true;
     453    }
     454}
     455
     456void SettingsDialog::setBgColor(QWidget *widget, const QColor &color)
     457{
     458    QPalette p = widget->palette();
     459    p.setColor(QPalette::Window, color);
     460    widget->setPalette(p);
     461}
     462
    435463void SettingsDialog::buttonTextColorClicked()
    436464{
    437 QColor color = QColorDialog::getColor(this->textColor,this);
    438     if (color.isValid() && (this->textColor != color)) {
    439         this->textColor = color;
    440         _colorChanged = true;
    441     }
    442 }
     465    pickColor(textColor);
     466    setBgColor(boxTextColor, textColor);
     467}
     468
     469void SettingsDialog::buttonSelectedColorClicked()
     470{
     471    pickColor(selColor);
     472    setBgColor(boxSelectedColor, selColor);
     473}
     474
     475void SettingsDialog::buttonAlternateColorClicked()
     476{
     477    pickColor(altColor);
     478    setBgColor(boxAlternateColor, altColor);
     479}
     480
     481void SettingsDialog::buttonBorderColorClicked()
     482{
     483    pickColor(borderColor);
     484    setBgColor(boxBorderColor, borderColor);
     485}
     486
     487//void SettingsDialog::buttonBgColorClicked()
     488//{
     489//    pickColor(bgColor);
     490//    setBgColor(boxBgColor, bgColor);
     491//}
    443492
    444493void SettingsDialog::buttonFontClicked()
Note: See TracChangeset for help on using the changeset viewer.