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

« back to all changes in this revision

Viewing changes to scribus/plugins/scriptplugin/pconsole.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:
49
49
        commandEdit->setTabStopWidth(qRound(commandEdit->fontPointSize() * 4));
50
50
 
51
51
        // install syntax highlighter.
52
 
        //SyntaxHighlighter *sxHigh =
53
52
        new SyntaxHighlighter(commandEdit);
54
53
 
55
54
        languageChange();
83
82
{
84
83
}
85
84
 
 
85
void PythonConsole::updateSyntaxHighlighter()
 
86
{
 
87
        new SyntaxHighlighter(commandEdit);
 
88
}
 
89
 
86
90
void PythonConsole::setFonts()
87
91
{
88
92
        QFont font = QFont("Fixed");
191
195
void PythonConsole::slot_saveAs()
192
196
{
193
197
        QString oldFname = filename;
 
198
        QString dirName  = QDir::homePath();
 
199
        if (!filename.isEmpty())
 
200
        {
 
201
                QFileInfo fInfo(filename);
 
202
                QDir fileDir = fInfo.absoluteDir();
 
203
                if (fileDir.exists())
 
204
                        dirName = fileDir.absolutePath();
 
205
        }
194
206
        filename = QFileDialog::getSaveFileName(this,
195
207
                        tr("Save the Python Commands in File"),
196
 
                        ".",
 
208
                        dirName,
197
209
                        tr("Python Scripts (*.py *.PY)"));
198
 
        if (filename.isNull())
 
210
        if (filename.isEmpty())
 
211
        {
 
212
                filename = oldFname;
199
213
                return;
200
 
        QFile f(filename);
201
 
        if (f.exists())
 
214
        }
 
215
        // #10070 : not needed QFileDialog::getSaveFileName() will ask overwrite confirmation by itself
 
216
        /*if (QFile::exists(filename))
202
217
        {
203
 
                QString fn = QDir::convertSeparators(filename);
 
218
                QString fn = QDir::toNativeSeparators(filename);
204
219
                if (ScMessageBox::warning(this, CommonStrings::trWarning,
205
220
                        "<qt>" + tr(QString("File %1 already exists. Do you want to replace it?").arg(fn).toLocal8Bit().constData()) + "</qt>",
206
221
                        QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
208
223
                        filename = oldFname;
209
224
                        return;
210
225
                }
211
 
        }
 
226
        }*/
212
227
        slot_save();
213
228
}
214
229
 
215
230
void PythonConsole::slot_saveOutput()
216
231
{
 
232
        QString dname = QDir::homePath();
217
233
        QString fname = QFileDialog::getSaveFileName(this,
218
234
                        tr("Save Current Output"),
219
 
                        ".",
 
235
                        dname,
220
236
                        tr("Text Files (*.txt)"));
221
 
        if (fname == QString::null)
 
237
        if (fname.isEmpty())
222
238
                return;
223
239
        QFile f(fname);
224
 
        if (!f.exists())
 
240
        // #10070 : not needed QFileDialog::getSaveFileName() will ask overwrite confirmation by itself
 
241
        /*if (f.exists())
225
242
        {
226
 
                QString fn = QDir::convertSeparators(filename);
 
243
                QString fn = QDir::toNativeSeparators(filename);
227
244
                if (QMessageBox::warning(this, CommonStrings::trWarning,
228
245
                        "<qt>" + tr(QString("File %1 already exists. Do you want to replace it?").arg(fn).toLocal8Bit().constData()) + "</qt>",
229
246
                        QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
230
247
                        return;
231
 
        }
 
248
        }*/
232
249
        // save
233
250
        if (f.open(QIODevice::WriteOnly))
234
251
        {
300
317
 
301
318
void SyntaxHighlighter::highlightBlock(const QString &text)
302
319
{
 
320
        // Apply default text color
 
321
        setFormat(0, text.length(), colors.textColor);
 
322
 
303
323
        foreach (HighlightingRule rule, highlightingRules)
304
324
        {
305
325
                QRegExp expression(rule.pattern);
349
369
        textColor.setNamedColor(prefs->get("syntaxtext", "#000000"));
350
370
}
351
371
 
352
 
SyntaxColors::~SyntaxColors()
 
372
void SyntaxColors::saveToPrefs()
353
373
{
354
374
        PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("scriptplugin");
355
 
        prefs->set("syntaxerror", qcolor2named(errorColor));
356
 
        prefs->set("syntaxcomment", qcolor2named(commentColor));
357
 
        prefs->set("syntaxkeyword", qcolor2named(keywordColor));
358
 
        prefs->set("syntaxsign", qcolor2named(signColor));
359
 
        prefs->set("syntaxnumber", qcolor2named(numberColor));
360
 
        prefs->set("syntaxstring", qcolor2named(stringColor));
361
 
        prefs->set("syntaxtext", qcolor2named(textColor));
 
375
        if (prefs)
 
376
        {
 
377
                prefs->set("syntaxerror", qcolor2named(errorColor));
 
378
                prefs->set("syntaxcomment", qcolor2named(commentColor));
 
379
                prefs->set("syntaxkeyword", qcolor2named(keywordColor));
 
380
                prefs->set("syntaxsign", qcolor2named(signColor));
 
381
                prefs->set("syntaxnumber", qcolor2named(numberColor));
 
382
                prefs->set("syntaxstring", qcolor2named(stringColor));
 
383
                prefs->set("syntaxtext", qcolor2named(textColor));
 
384
        }
362
385
}
363
386
 
364
387
QString SyntaxColors::qcolor2named(QColor color)