PythonConsole::PythonConsole( QWidget* parent) : QMainWindow( parent ) { setupUi(this); setWindowIcon(loadIcon("AppIcon.png")); changedLabel = new QLabel(this); cursorTemplate = tr("Col: %1 Row: %2/%3"); cursorLabel = new QLabel(this); statusBar()->addPermanentWidget(changedLabel); statusBar()->addPermanentWidget(cursorLabel); action_Open->setIcon(loadIcon("16/document-open.png")); action_Save->setIcon(loadIcon("16/document-save.png")); actionSave_As->setIcon(loadIcon("16/document-save-as.png")); action_Exit->setIcon(loadIcon("exit.png")); action_Run->setIcon(loadIcon("ok.png")); action_Open->setShortcut(tr("Ctrl+O")); action_Save->setShortcut(tr("Ctrl+S")); action_Run->setShortcut(Qt::Key_F9); actionRun_As_Console->setShortcut(Qt::CTRL + Qt::Key_F9); commandEdit->setTabStopWidth(qRound(commandEdit->fontPointSize() * 4)); // install syntax highlighter. //SyntaxHighlighter *sxHigh = new SyntaxHighlighter(commandEdit); languageChange(); commandEdit_cursorPositionChanged(); // welcome note QString welcomeText("\"\"\""); welcomeText += tr("Scribus Python Console"); welcomeText += "\n\n"; welcomeText += tr( "This is a standard Python console with some \n" "known limitations. Please consult the Scribus \n" "Scripter documentation for futher information. "); welcomeText += "\"\"\"\n"; commandEdit->setText(welcomeText); commandEdit->selectAll(); connect(commandEdit, SIGNAL(cursorPositionChanged()), this, SLOT(commandEdit_cursorPositionChanged())); connect(commandEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(documentChanged(bool))); connect(action_Open, SIGNAL(triggered()), this, SLOT(slot_open())); connect(action_Save, SIGNAL(triggered()), this, SLOT(slot_save())); connect(actionSave_As, SIGNAL(triggered()), this, SLOT(slot_saveAs())); connect(action_Exit, SIGNAL(triggered()), this, SLOT(slot_quit())); connect(action_Run, SIGNAL(triggered()), this, SLOT(slot_runScript())); connect(actionRun_As_Console, SIGNAL(triggered()), this, SLOT(slot_runScriptAsConsole())); connect(action_Save_Output, SIGNAL(triggered()), this, SLOT(slot_saveOutput())); }
void PythonConsole::languageChange() { Ui::PythonConsole::retranslateUi(this); cursorTemplate = tr("Col: %1 Row: %2/%3"); commandEdit_cursorPositionChanged(); commandEdit->setToolTip( "<qt>" + tr("Write your commands here. A selection is processed as script.") + "</qt>"); outputEdit->setToolTip( "<qt>" + tr("Output of your script") + "</qt>"); }