Changeset a09f31733a in tspsg for src


Ignore:
Timestamp:
Jul 16, 2012, 1:05:35 AM (12 years ago)
Author:
Oleksii Serdiuk
Branches:
appveyor, imgbot, master, readme
Children:
95c1897bf1
Parents:
ff8d0488a0
Message:

Added all configurable colors to Settings Dialog.

Only display ATM. Editing and saving will follow soon...

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/defaults.h

    rff8d0488a0 ra09f31733a  
    107107#   define DEF_FONT_SIZE 10
    108108#endif // Q_WS_S60
    109 //! Default text color
     109//! Default solution text color
    110110#define DEF_TEXT_COLOR QPalette().color(QPalette::Text)
    111111//! Default selected candidate color
     
    114114#define DEF_ALTERNATE_COLOR "#A00000"
    115115//! Default table border color
    116 #define DEF_TABLE_COLOR "#EEEEEE"
     116#define DEF_TABLE_COLOR QPalette().color(QPalette::AlternateBase)
     117//! Default solution background color
     118#define DEF_BACKGROUND_COLOR QPalette().color(QPalette::Base)
    117119
    118120#ifndef QT_NO_PRINTER
  • src/settingsdialog.cpp

    rff8d0488a0 ra09f31733a  
    3131 */
    3232SettingsDialog::SettingsDialog(QWidget *parent)
    33     : QDialog(parent), _newFont(false), _newColor(false), _translucency(0)
     33    : QDialog(parent), _fontChanged(false), _colorChanged(false), _translucency(0)
    3434{
    3535    setupUi(this);
     
    4848    buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
    4949
    50     buttonColor->setIcon(GET_ICON("format-text-color"));
     50    buttonTextColor->setIcon(GET_ICON("format-text-color"));
     51    buttonSelectedColor->setIcon(GET_ICON("format-text-color"));
     52    buttonAlternateColor->setIcon(GET_ICON("format-text-color"));
     53    buttonBorderColor->setIcon(GET_ICON("format-stroke-color"));
     54    buttonBgColor->setIcon(GET_ICON("format-fill-color"));
    5155    buttonFont->setIcon(GET_ICON("preferences-desktop-font"));
    5256    buttonHelp->setIcon(GET_ICON("help-hint"));
     
    212216    connect(spinRandMin, SIGNAL(valueChanged(int)), SLOT(spinRandMinValueChanged(int)));
    213217    connect(buttonFont, SIGNAL(clicked()), SLOT(buttonFontClicked()));
    214     connect(buttonColor, SIGNAL(clicked()), SLOT(buttonColorClicked()));
     218    connect(buttonTextColor, SIGNAL(clicked()), SLOT(buttonTextColorClicked()));
    215219    setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
    216220#if !defined(QT_NO_STATUSTIP) && !defined(HANDHELD)
     
    288292
    289293    font = qvariant_cast<QFont>(settings->value("Font", QFont(DEF_FONT_FACE, DEF_FONT_SIZE)));
    290     color = QColor(settings->value("Colors/Text", DEF_TEXT_COLOR).toString());
     294    textColor = QColor(settings->value("Colors/Text", DEF_TEXT_COLOR).toString());
     295    selColor = QColor(settings->value("Colors/Selected", DEF_SELECTED_COLOR).toString());
     296    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());
    291299    settings->endGroup();
     300
     301    QFont f = font;
     302    f.setPointSize(labelFontExample->font().pointSize());
     303    labelFontExample->setFont(f);
     304    labelFontExample->setText(font.family());
     305
     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);
    292325
    293326#ifdef HANDHELD
     
    304337bool SettingsDialog::colorChanged() const
    305338{
    306     return _newColor;
     339    return _colorChanged;
    307340}
    308341
     
    313346bool SettingsDialog::fontChanged() const
    314347{
    315     return _newFont;
     348    return _fontChanged;
    316349}
    317350
     
    333366    if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
    334367        if (QMessageBox::question(this, tr("Settings Reset"), tr("Do you really want to <b>reset all application settings to their defaults</b>?"), QMessageBox::RestoreDefaults | QMessageBox::Cancel) == QMessageBox::RestoreDefaults) {
    335             _newFont = (font != QFont(DEF_FONT_FACE, DEF_FONT_SIZE));
    336             _newColor = (color != DEF_TEXT_COLOR);
     368            _fontChanged = (font != QFont(DEF_FONT_FACE, DEF_FONT_SIZE));
     369            _colorChanged = (textColor != DEF_TEXT_COLOR);
    337370            settings->remove("");
    338371            settings->setValue("SettingsReset", true);
     
    392425        settings->setValue("ShowMatrixLimit", spinCitiesLimit->value());
    393426    settings->setValue("ScrollToEnd", cbScrollToEnd->isChecked());
    394     if (_newFont)
     427    if (_fontChanged)
    395428        settings->setValue("Font", font);
    396     if (_newColor)
    397         settings->setValue("Colors/Text", color.name());
     429    if (_colorChanged)
     430        settings->setValue("Colors/Text", textColor.name());
    398431    settings->endGroup();
    399432    QDialog::accept();
    400433}
    401434
    402 void SettingsDialog::buttonColorClicked()
    403 {
    404 QColor color = QColorDialog::getColor(this->color,this);
    405     if (color.isValid() && (this->color != color)) {
    406         this->color = color;
    407         _newColor = true;
     435void SettingsDialog::buttonTextColorClicked()
     436{
     437QColor color = QColorDialog::getColor(this->textColor,this);
     438    if (color.isValid() && (this->textColor != color)) {
     439        this->textColor = color;
     440        _colorChanged = true;
    408441    }
    409442}
     
    412445{
    413446bool ok;
    414 QFont font = QFontDialog::getFont(&ok,this->font,this);
     447QFont font = QFontDialog::getFont(&ok, this->font, this);
    415448    if (ok && (this->font != font)) {
    416449        this->font = font;
    417         _newFont = true;
     450        QFont f = font;
     451        f.setPointSize(labelFontExample->font().pointSize());
     452        labelFontExample->setFont(f);
     453        labelFontExample->setText(font.family());
     454        _fontChanged = true;
    418455    }
    419456}
  • src/settingsdialog.h

    rff8d0488a0 ra09f31733a  
    4747
    4848private:
    49     bool _newFont;
    50     bool _newColor;
     49    bool _fontChanged;
     50    bool _colorChanged;
    5151    qint8 _translucency;
    5252
    53     QColor color;
     53    QColor textColor, selColor, altColor, borderColor, bgColor;
    5454    QFont font;
    5555
     
    7979private slots:
    8080    void accept();
    81     void buttonColorClicked();
     81    void buttonTextColorClicked();
    8282    void buttonFontClicked();
    8383#ifdef Q_WS_WINCE_WM
Note: See TracChangeset for help on using the changeset viewer.