void ScriptConsole::createDialogContent() { ui->setupUi(dialog); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); highlighter = new StelScriptSyntaxHighlighter(ui->scriptEdit->document()); ui->includeEdit->setText(StelFileMgr::getInstallationDir() + "/scripts"); ui->quickrunCombo->addItem(q_("quickrun...")); ui->quickrunCombo->addItem(q_("selected text")); ui->quickrunCombo->addItem(q_("clear text")); ui->quickrunCombo->addItem(q_("clear images")); ui->quickrunCombo->addItem(q_("natural")); ui->quickrunCombo->addItem(q_("starchart")); connect(ui->scriptEdit, SIGNAL(cursorPositionChanged()), this, SLOT(rowColumnChanged())); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(loadScript())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveScript())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearButtonPressed())); connect(ui->preprocessSSCButton, SIGNAL(clicked()), this, SLOT(preprocessScript())); connect(ui->runButton, SIGNAL(clicked()), this, SLOT(runScript())); connect(ui->stopButton, SIGNAL(clicked()), &StelApp::getInstance().getScriptMgr(), SLOT(stopScript())); connect(ui->includeBrowseButton, SIGNAL(clicked()), this, SLOT(includeBrowse())); connect(ui->quickrunCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(quickRun(int))); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptRunning()), this, SLOT(scriptStarted())); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptStopped()), this, SLOT(scriptEnded())); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptDebug(const QString&)), this, SLOT(appendLogLine(const QString&))); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptOutput(const QString&)), this, SLOT(appendOutputLine(const QString&))); ui->tabs->setCurrentIndex(0); ui->scriptEdit->setFocus(); }
void RuleWidget::on_ruleSave_clicked() { QString lastRulesDir=mainWindow.iniSettings->value("UI/LastRulesPath",baseValues.desktopLocation).toString(); if(!QFile::exists(lastRulesDir))lastRulesDir=baseValues.desktopLocation; QString fileName=QFileDialog::getSaveFileName(baseValues.mainWindow_, julyTr("SAVE_GOUP","Save Rules Group"),lastRulesDir+"/"+QString(groupName).replace("/","_").replace("\\","").replace(":","").replace("?","")+".JLR","JL Ruels (*.JLR)"); if(fileName.isEmpty())return; mainWindow.iniSettings->setValue("UI/LastRulesPath",QFileInfo(fileName).dir().path()); mainWindow.iniSettings->sync(); if(QFile::exists(fileName))QFile::remove(fileName); QSettings saveScript(fileName,QSettings::IniFormat); saveScript.beginGroup("JLRuleGroup"); saveScript.setValue("Version",baseValues.jlScriptVersion); saveScript.setValue("Name",groupName); saveScript.endGroup(); for(int n=0;n<rulesModel->holderList.count();n++) RuleScriptParser::writeHolderToSettings(rulesModel->holderList[n],saveScript,"Rule_"+QString::number(n+101)); saveScript.sync(); if(!QFile::exists(fileName)) { QMessageBox::warning(baseValues.mainWindow_,windowTitle(),"Can not write file"); return; } }
/// Save to the current filename, opening a dialog if blank void ScriptEditor::saveToCurrentFile() { QString filename = fileName(); if (filename.isEmpty()) { saveAs(); return; } else { saveScript(filename); } }
void TagEditor::createActions(){ connect(LoadScriptButton,SIGNAL(clicked()),this,SLOT(loadScript())); connect(SaveScriptButton,SIGNAL(clicked()),this,SLOT(saveScript())); connect(RunScriptButton,SIGNAL(clicked()),this, SLOT(runScript())); QAction* searchOnlineAction = new QAction(tr("Search for selected file/album in online musicdatabases..."), this); searchOnlineAction->setShortcut(tr("Ctrl+S")); connect(searchOnlineAction, SIGNAL(triggered()), this, SLOT(searchOnline())); QAction* searchForFilesAction = new QAction(tr("Search for files to add to workspace..."), this); //searchForFilesAction->setShortcut(tr("Ctrl+S")); connect(searchForFilesAction, SIGNAL(triggered()), this, SLOT(searchAndAddFiles())); TreeView->setContextMenuPolicy(Qt::ActionsContextMenu); TreeView->addAction(searchOnlineAction); TreeView->addAction(searchForFilesAction); connect( TreeView, SIGNAL( expanded( const QModelIndex & ) ), this, SLOT( resizeColumn() ) ); connect( TreeView, SIGNAL( collapsed( const QModelIndex & ) ), this, SLOT( resizeColumn() ) ); //connect( TreeWidget_, SIGNAL( currentRowChanged( int ) ), this, SLOT( showTagInfo(int) ) ); connect( TreeWidget_, SIGNAL( itemSelectionChanged() ), this, SLOT( showTagInfo() ) ); connect( AddButton, SIGNAL( clicked() ), this, SLOT(addFiles() ) ); connect( RemoveButton, SIGNAL( clicked() ), this, SLOT(removeFiles() ) ); connect( ClearButton, SIGNAL( clicked() ), this, SLOT(removeAllFiles() ) ); connect( SaveButton, SIGNAL( clicked() ), this, SLOT(saveTag() ) ); connect( ChooseDirButton, SIGNAL( clicked() ), this, SLOT(chooseDir() ) ); connect( actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) ); connect( actionRewriteTag, SIGNAL( triggered() ), this, SLOT( rewriteTag() ) ); connect( actionRenameFiles, SIGNAL( triggered() ), this, SLOT( renameFiles() ) ); connect( actionReplaceTags, SIGNAL( triggered() ), this, SLOT( replaceTags() ) ); connect( actionSerialize, SIGNAL( triggered() ), this, SLOT( serialize() ) ); connect( actionClearTags, SIGNAL( triggered() ), this, SLOT( clearTags() ) ); //connect( actionRemoveFrames, SIGNAL( triggered() ), this, SLOT( removeFrames() ) ); //styles QSignalMapper *styleMapper = new QSignalMapper(this); QStringList styles = QStyleFactory::keys(); for(int i=0;i<styles.size();i++){ QAction *a = new QAction(styles[i],menuStyle); a->setCheckable(true); connect(a, SIGNAL(triggered()), styleMapper, SLOT(map())); styleMapper->setMapping(a, styles[i]); menuStyle->addAction(a); } menuStyle->addSeparator(); QAction *actionCustomStyleSheet = new QAction("Custom...",menuStyle); actionCustomStyleSheet->setCheckable(true); connect(actionCustomStyleSheet, SIGNAL(triggered()), this, SLOT(openStyleSheet())); menuStyle->addAction( actionCustomStyleSheet ); connect(styleMapper, SIGNAL(mapped(const QString &)), this, SLOT(setGUIStyle(const QString &))); }
ScriptDialog::ScriptDialog(const QString &fn, QWidget *parent) : QDialog(parent) { m_fn = fn; QPushButton *okButton = new QPushButton(tr("OK")); QPushButton *applyButton = new QPushButton(tr("Apply")); QPushButton *cancelButton = new QPushButton(tr("Cancel")); cancelButton->setDefault(true); connect(okButton, SIGNAL(clicked()), this, SLOT(saveScript())); connect(applyButton, SIGNAL(clicked()), this, SLOT(applyScript())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(1); buttonsLayout->addWidget(okButton); buttonsLayout->addWidget(applyButton); buttonsLayout->addWidget(cancelButton); m_pSeqEdit = new QLineEdit; m_pStepsEdit = new QComboBox; connect( m_pSeqEdit, SIGNAL(editingFinished()), this, SLOT(onSeqChanged()) ); connect( m_pStepsEdit, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(onStepChanged(const QString &)) ); QHBoxLayout *hbLayout = new QHBoxLayout; hbLayout->addWidget(m_pSeqEdit); hbLayout->addWidget(m_pStepsEdit); m_pEditor = new CodeEditor; m_pEditor->setTabStopWidth(40); m_pCondEditor = new CodeEditor; m_pCondEditor->setTabStopWidth(40); QHBoxLayout *editorLayout = new QHBoxLayout; editorLayout->addWidget(m_pEditor, 2); editorLayout->addWidget(m_pCondEditor, 1); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(hbLayout); mainLayout->addLayout(editorLayout, 1); mainLayout->addStretch(); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); setWindowTitle(tr("Script Dialog")); if(!m_fn.isEmpty()){ setScript(m_fn); } resize(1024, 600); }
FilterScriptDialog::FilterScriptDialog(QWidget * parent) :QDialog(parent) { ui = new Ui::scriptDialog(); FilterScriptDialog::ui->setupUi(this); scriptPtr=0; connect(ui->okButton, SIGNAL(clicked()), this, SLOT(applyScript())); connect(ui->clearScriptButton,SIGNAL(clicked()), this, SLOT(clearScript())); connect(ui->saveScriptButton, SIGNAL(clicked()), this, SLOT(saveScript())); connect(ui->openScriptButton, SIGNAL(clicked()), this, SLOT(openScript())); connect(ui->moveUpButton,SIGNAL(clicked()), this, SLOT(moveSelectedFilterUp())); connect(ui->moveDownButton, SIGNAL(clicked()), this, SLOT(moveSelectedFilterDown())); connect(ui->removeFilterButton, SIGNAL(clicked()), this, SLOT(removeSelectedFilter())); connect(ui->editParameterButton, SIGNAL(clicked()), this, SLOT(editSelectedFilterParameters())); }
void RuleWidget::saveRulesData() { ui.saveFon->setVisible(false); if(QFile::exists(filePath))QFile::remove(filePath); QSettings saveScript(filePath,QSettings::IniFormat); saveScript.beginGroup("JLRuleGroup"); saveScript.setValue("Version",baseValues.jlScriptVersion); saveScript.setValue("Name",groupName); saveScript.setValue("LogRowsCount",ui.limitRowsValue->value()); saveScript.setValue("Notes",ui.notes->toPlainText()); saveScript.setValue("BeepOnDone",ui.ruleBeep->isChecked()); saveScript.endGroup(); for(int n=0;n<rulesModel->holderList.count();n++) RuleScriptParser::writeHolderToSettings(rulesModel->holderList[n],saveScript,"Rule_"+QString::number(n+101)); saveScript.sync(); }
/** * Save the script, opening a dialog to ask for the filename */ void ScriptEditor::saveAs() { QString selectedFilter; QString filter = "Scripts (*.py *.PY);;All Files (*)"; QString filename = MantidQt::API::FileDialogHandler::getSaveFileName( NULL, "MantidPlot - Save", "", filter, &selectedFilter); if (filename.isEmpty()) { throw SaveCancelledException(); } if (QFileInfo(filename).suffix().isEmpty()) { QString ext = selectedFilter.section('(', 1).section(' ', 0, 0); ext.remove(0, 1); if (ext != ")") filename += ext; } saveScript(filename); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_scene(new QGraphicsScene), m_turtleGraphics(new TurtleCanvasGraphicsItem), m_cmds(m_turtleGraphics), m_prefsDialog(new PreferencesDialog(this)), m_aboutDialog(new AboutDialog(this)), m_canvasSaveOptionsDialog(new CanvasSaveOptionsDialog(this)), m_settings("settings.ini") { ui->setupUi(this); m_scene->addItem(m_turtleGraphics); ui->graphicsView->setScene(m_scene); ui->graphicsView->centerOn(0.0, 0.0); // Add the graphics view actions QAction* centerAction = new QAction("&Center View", NULL); QAction* clearAction = new QAction("C&lear Canvas", NULL); ui->graphicsView->addAction(centerAction); ui->graphicsView->addAction(clearAction); connect(centerAction, SIGNAL(triggered()), this, SLOT(centerGraphicsScene())); connect(clearAction, SIGNAL(triggered()), this, SLOT(clearCanvas())); ui->graphicsView->setContextMenuPolicy(Qt::ActionsContextMenu); ui->errorMessagesTextEdit->setTextColor(Qt::red); // These buttons are only enabled while a script is running. ui->haltButton->setEnabled(false); ui->pauseButton->setEnabled(false); ui->resumeButton->setEnabled(false); // Messages dock is hidden by default. ui->messagesDockWidget->hide(); connect(m_turtleGraphics, SIGNAL(canvasResized()), this, SLOT(resizeGraphicsScene())); connect(ui->runButton, SIGNAL(clicked()), this, SLOT(runScript())); connect(ui->haltButton, SIGNAL(clicked()), this, SLOT(haltScript())); connect(ui->pauseButton, SIGNAL(clicked()), this, SLOT(pauseScript())); connect(ui->resumeButton, SIGNAL(clicked()), this, SLOT(resumeScript())); connect(ui->action_Open_Script, SIGNAL(triggered()), this, SLOT(loadScript())); connect(ui->action_Save_Script, SIGNAL(triggered()), this, SLOT(saveScript())); connect(ui->action_Save_Canvas, SIGNAL(triggered()), this, SLOT(saveCanvas())); connect(ui->action_Preferences, SIGNAL(triggered()), m_prefsDialog, SLOT(show())); connect(ui->action_About, SIGNAL(triggered()), m_aboutDialog, SLOT(show())); connect(ui->action_Errors, SIGNAL(triggered(bool)), this, SLOT(showErrors())); connect(ui->action_Script_Output, SIGNAL(triggered(bool)), this, SLOT(showScriptOutputs())); connect(m_prefsDialog, SIGNAL(rejected()), this, SLOT(loadPreferences())); connect(m_prefsDialog, SIGNAL(accepted()), this, SLOT(applyPreferences())); connect(m_prefsDialog, SIGNAL(accepted()), this, SLOT(savePreferences())); connect(&m_cmds, SIGNAL(scriptError(QString)), this, SLOT(showScriptError(QString)), Qt::QueuedConnection); connect(&m_cmds, SIGNAL(scriptMessageReceived()), this, SLOT(showScriptOutput()), Qt::QueuedConnection); loadPreferences(); applyPreferences(); m_cmds.start(); m_cmds.setRequirePaths(""); for (const QString& path : m_settings.requirePaths()) { m_cmds.addRequirePath(path); } for (const QString& filename : m_settings.startupScripts()) { m_cmds.runScriptFile(filename); } // Don't connect this until all the startup scripts have run // to prevent the error messages box from being cleared by successful scripts. connect(&m_cmds, SIGNAL(scriptFinished(bool)), this, SLOT(scriptFinished(bool)), Qt::QueuedConnection); }
InteractiveConsole::InteractiveConsole(QWidget *parent) : QDialog(parent), m_splitter(new QSplitter(Qt::Vertical, this)), m_editorPart(0), m_editor(0), m_output(0), m_loadAction(KStandardAction::open(this, SLOT(openScriptFile()), this)), m_saveAction(KStandardAction::saveAs(this, SLOT(saveScript()), this)), m_clearAction(KStandardAction::clear(this, SLOT(clearEditor()), this)), m_executeAction(new QAction(QIcon::fromTheme(QStringLiteral("system-run")), i18n("&Execute"), this)), m_plasmaAction(new QAction(QIcon::fromTheme(QStringLiteral("plasma")), i18nc("Toolbar Button to switch to Plasma Scripting Mode", "Plasma"), this)), m_kwinAction(new QAction(QIcon::fromTheme(QStringLiteral("kwin")), i18nc("Toolbar Button to switch to KWin Scripting Mode", "KWin"), this)), m_snippetsMenu(new QMenu(i18n("Templates"), this)), m_fileDialog(0), m_closeWhenCompleted(false), m_mode(PlasmaConsole) { addAction(KStandardAction::close(this, SLOT(close()), this)); addAction(m_saveAction); addAction(m_clearAction); setWindowTitle(i18n("Desktop Shell Scripting Console")); setAttribute(Qt::WA_DeleteOnClose); //setButtons(QDialog::None); QWidget *widget = new QWidget(m_splitter); QVBoxLayout *editorLayout = new QVBoxLayout(widget); QLabel *label = new QLabel(i18n("Editor"), widget); QFont f = label->font(); f.setBold(true); label->setFont(f); editorLayout->addWidget(label); connect(m_snippetsMenu, &QMenu::aboutToShow, this, &InteractiveConsole::populateTemplatesMenu); QToolButton *loadTemplateButton = new QToolButton(this); loadTemplateButton->setPopupMode(QToolButton::InstantPopup); loadTemplateButton->setMenu(m_snippetsMenu); loadTemplateButton->setText(i18n("Load")); connect(loadTemplateButton, &QToolButton::triggered, this, &InteractiveConsole::loadTemplate); QToolButton *useTemplateButton = new QToolButton(this); useTemplateButton->setPopupMode(QToolButton::InstantPopup); useTemplateButton->setMenu(m_snippetsMenu); useTemplateButton->setText(i18n("Use")); connect(useTemplateButton, &QToolButton::triggered, this, &InteractiveConsole::useTemplate); QActionGroup *modeGroup = new QActionGroup(this); modeGroup->addAction(m_plasmaAction); modeGroup->addAction(m_kwinAction); m_plasmaAction->setCheckable(true); m_kwinAction->setCheckable(true); m_plasmaAction->setChecked(true); connect(modeGroup, &QActionGroup::triggered, this, &InteractiveConsole::modeSelectionChanged); KToolBar *toolBar = new KToolBar(this, true, false); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolBar->addAction(m_loadAction); toolBar->addAction(m_saveAction); toolBar->addAction(m_clearAction); toolBar->addAction(m_executeAction); toolBar->addAction(m_plasmaAction); toolBar->addAction(m_kwinAction); toolBar->addWidget(loadTemplateButton); toolBar->addWidget(useTemplateButton); editorLayout->addWidget(toolBar); KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KTextEditor/Document")); foreach (const KService::Ptr service, offers) { m_editorPart = service->createInstance<KTextEditor::Document>(widget); if (m_editorPart) { m_editorPart->setHighlightingMode(QStringLiteral("JavaScript/PlasmaDesktop")); KTextEditor::View * view = m_editorPart->createView(widget); view->setContextMenu(view->defaultContextMenu()); KTextEditor::ConfigInterface *config = qobject_cast<KTextEditor::ConfigInterface*>(view); if (config) { config->setConfigValue(QStringLiteral("line-numbers"), true); config->setConfigValue(QStringLiteral("dynamic-word-wrap"), true); } editorLayout->addWidget(view); connect(m_editorPart, &KTextEditor::Document::textChanged, this, &InteractiveConsole::scriptTextChanged); break; } }
void PythonEditor::createWidgets() { runBt_ = new QToolButton(); runBt_->setIcon(QIcon(":/modules/python/python.png")); runBt_->setIconSize(QSize(24, 24)); runBt_->setShortcut(QKeySequence("Ctrl+R")); runBt_->setToolTip("Run Script (Ctrl+R)"); newBt_ = new QToolButton(); newBt_->setIcon(QIcon(":/modules/python/python_2.png")); newBt_->setIconSize(QSize(24, 24)); newBt_->setToolTip("New Script"); openBt_ = new QToolButton(); openBt_->setIcon(QIcon(":/qt/icons/open.png")); openBt_->setIconSize(QSize(24, 24)); openBt_->setToolTip("Load Script"); saveBt_ = new QToolButton(); saveBt_->setIcon(QIcon(":/qt/icons/save.png")); saveBt_->setIconSize(QSize(24, 24)); saveBt_->setToolTip("Save Script"); saveAsBt_ = new QToolButton(); saveAsBt_->setIcon(QIcon(":/qt/icons/saveas.png")); saveAsBt_->setIconSize(QSize(24, 24)); saveAsBt_->setToolTip("Save Script As"); increaseFontSizeBt_ = new QToolButton(); increaseFontSizeBt_->setIcon(QIcon(":/qt/icons/viewmag+.png")); increaseFontSizeBt_->setIconSize(QSize(24, 24)); increaseFontSizeBt_->setToolTip("Increase Font Size"); decreaseFontSizeBt_ = new QToolButton(); decreaseFontSizeBt_->setIcon(QIcon(":/qt/icons/viewmag_.png")); decreaseFontSizeBt_->setIconSize(QSize(24, 24)); decreaseFontSizeBt_->setToolTip("Decrease Font Size"); QHBoxLayout* hbox = new QHBoxLayout(); hbox->setContentsMargins(0,0,0,0); hbox->addWidget(runBt_); QFrame* sep = new QFrame(); sep->setFrameShape(QFrame::VLine); hbox->addWidget(sep); hbox->addWidget(newBt_); hbox->addWidget(openBt_); hbox->addWidget(saveBt_); hbox->addWidget(saveAsBt_); hbox->addStretch(); hbox->addWidget(increaseFontSizeBt_); hbox->addWidget(decreaseFontSizeBt_); QWidget* toolButtonBar = new QWidget(); toolButtonBar->setLayout(hbox); QFont font; font.setFamily("Courier"); font.setFixedPitch(true); font.setPointSize(fontSize_); codeEdit_ = new CodeEdit(); codeEdit_->setFont(font); highlighter_ = new PythonHighlighter(codeEdit_->document()); compilerLogWidget_ = new QTextEdit(); compilerLogWidget_->setFont(font); compilerLogWidget_->setReadOnly(true); compilerLogWidget_->setFixedHeight(150); QVBoxLayout* vbox = new QVBoxLayout(); vbox->addWidget(toolButtonBar); vbox->addWidget(codeEdit_); vbox->addWidget(compilerLogWidget_); setLayout(vbox); connect(runBt_, SIGNAL(clicked()), this, SLOT(runScript())); connect(newBt_, SIGNAL(clicked()), this, SLOT(newScript())); connect(openBt_, SIGNAL(clicked()), this, SLOT(openScript())); connect(saveBt_, SIGNAL(clicked()), this, SLOT(saveScript())); connect(saveAsBt_, SIGNAL(clicked()), this, SLOT(saveScriptAs())); connect(increaseFontSizeBt_, SIGNAL(clicked()), this, SLOT(increaseFontSize())); connect(decreaseFontSizeBt_, SIGNAL(clicked()), this, SLOT(decreaseFontSize())); connect(codeEdit_, SIGNAL(textChanged()), this, SIGNAL(modified())); setMinimumSize(300, 400); }