~ubuntu-branches/ubuntu/wily/scribus/wily-proposed

« back to all changes in this revision

Viewing changes to scribus/plugins/scriptplugin/scripterprefsgui.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
        : PrefsPanel(parent)
21
21
{
22
22
        setupUi(this);
 
23
 
 
24
        // Create SyntaxColors with save to prefs
 
25
        // disabled by defaults, only save when apply()
 
26
        syntaxColors = new SyntaxColors();
23
27
        
24
28
        languageChange();
25
29
        setupSyntaxColors();
34
38
        // signals and slots connections
35
39
        connect(extensionScriptsChk, SIGNAL(toggled(bool)), startupScriptEdit, SLOT(setEnabled(bool)));
36
40
        // colors
37
 
        connect(textButton, SIGNAL(clicked()), this, SLOT(setColor()));
 
41
        connect(textButton   , SIGNAL(clicked()), this, SLOT(setColor()));
38
42
        connect(commentButton, SIGNAL(clicked()), this, SLOT(setColor()));
39
43
        connect(keywordButton, SIGNAL(clicked()), this, SLOT(setColor()));
40
 
        connect(errorButton, SIGNAL(clicked()), this, SLOT(setColor()));
41
 
        connect(signButton, SIGNAL(clicked()), this, SLOT(setColor()));
42
 
        connect(stringButton, SIGNAL(clicked()), this, SLOT(setColor()));
43
 
        connect(numberButton, SIGNAL(clicked()), this, SLOT(setColor()));
 
44
        connect(errorButton  , SIGNAL(clicked()), this, SLOT(setColor()));
 
45
        connect(signButton   , SIGNAL(clicked()), this, SLOT(setColor()));
 
46
        connect(stringButton , SIGNAL(clicked()), this, SLOT(setColor()));
 
47
        connect(numberButton , SIGNAL(clicked()), this, SLOT(setColor()));
44
48
        connect(startupScriptChangeButton, SIGNAL(clicked()), this, SLOT(changeStartupScript()));
45
49
}
46
50
 
49
53
 */
50
54
ScripterPrefsGui::~ScripterPrefsGui()
51
55
{
 
56
        delete syntaxColors;
52
57
}
53
58
 
54
59
/*
74
79
{
75
80
        scripterCore->setExtensionsEnabled(extensionScriptsChk->isChecked());
76
81
        scripterCore->setStartupScript(startupScriptEdit->text());
77
 
        // colors
78
 
        SyntaxColors *syntax = new SyntaxColors();
79
 
        syntax->textColor = textButton->palette().color(QPalette::Window);
80
 
        syntax->commentColor = commentButton->palette().color(QPalette::Window);
81
 
        syntax->keywordColor = keywordButton->palette().color(QPalette::Window);
82
 
        syntax->errorColor = errorButton->palette().color(QPalette::Window);
83
 
        syntax->signColor = signButton->palette().color(QPalette::Window);
84
 
        syntax->stringColor = stringButton->palette().color(QPalette::Window);
85
 
        syntax->numberColor = numberButton->palette().color(QPalette::Window);
86
 
        delete(syntax);
 
82
        syntaxColors->saveToPrefs();
 
83
 
 
84
        // Necessary to update console syntax highlighter
 
85
        emit prefsChanged();
87
86
}
88
87
 
89
88
void ScripterPrefsGui::setColor()
90
89
{
91
 
        QPalette palette;
92
 
        QPushButton* button = (QPushButton*)sender();
93
 
        QColor color = QColorDialog::getColor(button->palette().color(QPalette::Window), this);
 
90
        QPushButton* button = (QPushButton*) sender();
 
91
 
 
92
        QColor oldColor;
 
93
        if (button == textButton)    oldColor = syntaxColors->textColor;
 
94
        if (button == commentButton) oldColor = syntaxColors->commentColor;
 
95
        if (button == keywordButton) oldColor = syntaxColors->keywordColor;
 
96
        if (button == errorButton)   oldColor = syntaxColors->errorColor;
 
97
        if (button == signButton)    oldColor = syntaxColors->signColor;
 
98
        if (button == stringButton)  oldColor = syntaxColors->stringColor;
 
99
        if (button == numberButton)  oldColor = syntaxColors->numberColor;
 
100
 
 
101
        QColor color = QColorDialog::getColor(oldColor, this);
94
102
        if (color.isValid())
95
103
        {
96
 
                palette.setColor(button->backgroundRole(), color);
97
 
                button->setPalette(palette);
 
104
                setButtonIcon(button, color);
 
105
 
 
106
                if (button == textButton)    syntaxColors->textColor = color;
 
107
                if (button == commentButton) syntaxColors->commentColor = color;
 
108
                if (button == keywordButton) syntaxColors->keywordColor = color;
 
109
                if (button == errorButton)   syntaxColors->errorColor = color;
 
110
                if (button == signButton)    syntaxColors->signColor = color;
 
111
                if (button == stringButton)  syntaxColors->stringColor = color;
 
112
                if (button == numberButton)  syntaxColors->numberColor = color;
98
113
        }
99
114
}
100
115
 
 
116
void ScripterPrefsGui::setButtonIcon(QPushButton* button, QColor color)
 
117
{
 
118
        QSize  iconSize   = button->iconSize();
 
119
        double iconWidth  = qMax(iconSize.width() , button->width() / 3);
 
120
        double iconHeight = qMin(iconSize.height(), button->height() / 3);
 
121
        QSize  newIconSize(iconWidth, iconHeight);
 
122
        if (iconSize != newIconSize)
 
123
                button->setIconSize(newIconSize);
 
124
        QPixmap icon(button->iconSize());
 
125
        icon.fill(color);
 
126
        button->setIcon(icon);
 
127
}
 
128
 
101
129
void ScripterPrefsGui::setupSyntaxColors()
102
130
{
103
 
        QPalette palette;
104
 
        SyntaxColors *syntax = new SyntaxColors();
105
 
        palette.setColor(textButton->backgroundRole(), syntax->textColor);
106
 
        textButton->setPalette(palette);
107
 
        palette.setColor(commentButton->backgroundRole(), syntax->commentColor);
108
 
        commentButton->setPalette(palette);
109
 
        palette.setColor(keywordButton->backgroundRole(), syntax->keywordColor);
110
 
        keywordButton->setPalette(palette);
111
 
        palette.setColor(errorButton->backgroundRole(), syntax->errorColor);
112
 
        errorButton->setPalette(palette);
113
 
        palette.setColor(signButton->backgroundRole(), syntax->signColor);
114
 
        signButton->setPalette(palette);
115
 
        palette.setColor(stringButton->backgroundRole(), syntax->stringColor);
116
 
        stringButton->setPalette(palette);
117
 
        palette.setColor(numberButton->backgroundRole(), syntax->numberColor);
118
 
        numberButton->setPalette(palette);
119
 
        delete(syntax);
 
131
        SyntaxColors syntax;
 
132
        setButtonIcon(textButton   , syntax.textColor);
 
133
        setButtonIcon(commentButton, syntax.commentColor);
 
134
        setButtonIcon(keywordButton, syntax.keywordColor);
 
135
        setButtonIcon(errorButton  , syntax.errorColor);
 
136
        setButtonIcon(signButton   , syntax.signColor);
 
137
        setButtonIcon(stringButton , syntax.stringColor);
 
138
        setButtonIcon(numberButton , syntax.numberColor);
120
139
}
121
140
 
122
141
void ScripterPrefsGui::changeStartupScript()