Changeset c8ed26ddf1 in tspsg for src


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

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/defaults.h

    r7e8e1b444d rc8ed26ddf1  
    115115//! Default table border color
    116116#define DEF_TABLE_COLOR QPalette().color(QPalette::AlternateBase)
    117 //! Default solution background color
    118 #define DEF_BACKGROUND_COLOR QPalette().color(QPalette::Base)
     117////! Default solution background color
     118//#define DEF_BACKGROUND_COLOR QPalette().color(QPalette::Base)
    119119
    120120#ifndef QT_NO_PRINTER
  • src/mainwindow.cpp

    r7e8e1b444d rc8ed26ddf1  
    303303
    304304        html.replace(QRegExp("font-family:([^;]*);"), "font-family:\\1, 'DejaVu Sans Mono', 'Courier New', Courier, monospace;");
     305        html.replace(QRegExp("<style ([^>]*)>"), QString("<style \\1>\n"
     306                                                         "body { color: %1 }\n"
     307                                                         "td { border-style: solid; border-width: 1px; border-color: %2; }")
     308                     .arg(settings->value("Output/Colors/Font", DEF_TEXT_COLOR).toString(),
     309                          settings->value("Output/Colors/TableBorder", DEF_TABLE_COLOR).toString()));
    305310
    306311        if (!graph.isNull()) {
     
    10021007        pic.end();
    10031008
    1004 QImage i(graph.width() + 2, graph.height() + 2, QImage::Format_RGB32);
    1005         i.fill(0xFFFFFF);
     1009        QImage i(graph.width() + 2, graph.height() + 2, QImage::Format_ARGB32);
     1010        i.fill(QColor(255, 255, 255, 0));
    10061011        pic.begin(&i);
    10071012        pic.drawPicture(1, 1, graph);
     
    13191324
    13201325    settings->endGroup();
    1321 
    1322     solutionText->setTextColor(color);
    13231326}
    13241327
  • 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()
  • src/settingsdialog.h

    r7e8e1b444d rc8ed26ddf1  
    7272    QLabel *labelHint;
    7373
     74    void pickColor(QColor &where);
     75    void setBgColor(QWidget *widget, const QColor &color);
     76
    7477#ifndef QT_NO_STATUSTIP
    7578    bool event(QEvent *ev);
     
    8083    void accept();
    8184    void buttonTextColorClicked();
     85    void buttonSelectedColorClicked();
     86    void buttonAlternateColorClicked();
     87    void buttonBorderColorClicked();
     88//    void buttonBgColorClicked();
    8289    void buttonFontClicked();
    8390#ifdef Q_WS_WINCE_WM
Note: See TracChangeset for help on using the changeset viewer.