//! [8] void MainWindow::createActions() { //! [8] brushColorAction = new QAction(tr("&Brush Color..."), this); brushColorAction->setShortcut(tr("Ctrl+C")); connect(brushColorAction, SIGNAL(triggered()), this, SLOT(brushColorAct())); //! [9] alphaChannelPressureAction = new QAction(tr("&Pressure"), this); alphaChannelPressureAction->setCheckable(true); alphaChannelTiltAction = new QAction(tr("&Tilt"), this); alphaChannelTiltAction->setCheckable(true); noAlphaChannelAction = new QAction(tr("No Alpha Channel"), this); noAlphaChannelAction->setCheckable(true); noAlphaChannelAction->setChecked(true); alphaChannelGroup = new QActionGroup(this); alphaChannelGroup->addAction(alphaChannelPressureAction); alphaChannelGroup->addAction(alphaChannelTiltAction); alphaChannelGroup->addAction(noAlphaChannelAction); connect(alphaChannelGroup, SIGNAL(triggered(QAction*)), this, SLOT(alphaActionTriggered(QAction*))); //! [9] colorSaturationVTiltAction = new QAction(tr("&Vertical Tilt"), this); colorSaturationVTiltAction->setCheckable(true); colorSaturationHTiltAction = new QAction(tr("&Horizontal Tilt"), this); colorSaturationHTiltAction->setCheckable(true); colorSaturationPressureAction = new QAction(tr("&Pressure"), this); colorSaturationPressureAction->setCheckable(true); noColorSaturationAction = new QAction(tr("&No Color Saturation"), this); noColorSaturationAction->setCheckable(true); noColorSaturationAction->setChecked(true); colorSaturationGroup = new QActionGroup(this); colorSaturationGroup->addAction(colorSaturationVTiltAction); colorSaturationGroup->addAction(colorSaturationHTiltAction); colorSaturationGroup->addAction(colorSaturationPressureAction); colorSaturationGroup->addAction(noColorSaturationAction); connect(colorSaturationGroup, SIGNAL(triggered(QAction*)), this, SLOT(saturationActionTriggered(QAction*))); lineWidthPressureAction = new QAction(tr("&Pressure"), this); lineWidthPressureAction->setCheckable(true); lineWidthPressureAction->setChecked(true); lineWidthTiltAction = new QAction(tr("&Tilt"), this); lineWidthTiltAction->setCheckable(true); lineWidthFixedAction = new QAction(tr("&Fixed"), this); lineWidthFixedAction->setCheckable(true); lineWidthGroup = new QActionGroup(this); lineWidthGroup->addAction(lineWidthPressureAction); lineWidthGroup->addAction(lineWidthTiltAction); lineWidthGroup->addAction(lineWidthFixedAction); connect(lineWidthGroup, SIGNAL(triggered(QAction*)), this, SLOT(lineWidthActionTriggered(QAction*))); exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcuts(QKeySequence::Quit); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); loadAction = new QAction(tr("&Open..."), this); loadAction->setShortcuts(QKeySequence::Open); connect(loadAction, SIGNAL(triggered()), this, SLOT(loadAct())); saveAction = new QAction(tr("&Save As..."), this); saveAction->setShortcuts(QKeySequence::SaveAs); connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAct())); aboutAction = new QAction(tr("A&bout"), this); aboutAction->setShortcut(tr("Ctrl+B")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutAct())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setShortcut(tr("Ctrl+Q")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); //! [10] }
ScriptEditor::ScriptEditor(const QString& source, const QString& filename, int type) : ChildTab(NULL), ui(new Ui::ScriptEditor), m_language(ENGINE_QTSCRIPT), m_editor(NULL) { ui->setupUi(this); m_exampleBtn = new QPushButton(this); m_exampleBtn->setToolTip(tr("Examples")); m_exampleBtn->setCheckable(true); m_exampleBtn->setIconSize(QSize(24, 24)); m_exampleBtn->setIcon(QIcon(":/actions/info")); m_exampleBtn->setFlat(true); m_exampleBtn->setStyleSheet("padding: 3px;"); m_settingsBtn = new QPushButton(this); m_settingsBtn->setToolTip(tr("Settings")); m_settingsBtn->setCheckable(true); m_settingsBtn->setIconSize(QSize(24, 24)); m_settingsBtn->setIcon(QIcon(":/actions/system")); m_settingsBtn->setFlat(true); m_settingsBtn->setStyleSheet("padding: 3px;"); QLabel *docLabel = new QLabel(this); docLabel->setTextFormat(Qt::RichText); docLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); docLabel->setOpenExternalLinks(true); docLabel->setText(tr("<a href=\"http://technika.junior.cz/docs/Lorris/index.html\">Documentation</a>")); docLabel->setToolTip("http://technika.junior.cz/docs/Lorris/index.html"); QToolBar *bar = new QToolBar(this); bar->setIconSize(QSize(24, 24)); QAction *load = bar->addAction(QIcon(":/actions/open"), tr("Load"), this, SLOT(loadAct())); QAction *save = bar->addAction(QIcon(":/actions/save"), tr("Save"), this, SLOT(saveAct())); QAction *saveAs = bar->addAction(QIcon(":/actions/save-as"), tr("Save as..."), this, SLOT(saveAs())); bar->addSeparator(); QAction *undo = bar->addAction(QIcon(":/actions/undo"), tr("Undo"), this, SIGNAL(undo())); QAction *redo = bar->addAction(QIcon(":/actions/redo"), tr("Redo"), this, SIGNAL(redo())); bar->addSeparator(); QAction *apply = bar->addAction(QIcon(":/icons/start"), tr("Apply"), this, SLOT(applyAct())); bar->addSeparator(); bar->addWidget(m_exampleBtn); bar->addWidget(m_settingsBtn); bar->addSeparator(); bar->addWidget(docLabel); load->setShortcut(QKeySequence("Ctrl+O")); load->setToolTip(tr("Load (Ctrl+O)")); save->setShortcut(QKeySequence("Ctrl+S")); save->setToolTip(tr("Save (Ctrl+S)")); saveAs->setShortcut(QKeySequence("Ctrl+Shift+S")); saveAs->setToolTip(tr("Save as... (Ctrl+Shift+S)")); apply->setShortcut(QKeySequence("F5")); apply->setToolTip(tr("Apply (F5)")); connect(this, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool))); connect(this, SIGNAL(redoAvailable(bool)), redo, SLOT(setEnabled(bool))); ui->mainLayout->insertWidget(0, bar); quint32 editor_cfg = sConfig.get(CFG_QUINT32_SCRIPTEDITOR_TYPE); #ifdef USE_KATE setEditor(EDITOR_KATE); #elif defined(USE_QSCI) setEditor(EDITOR_QSCINTILLA); #else setEditor(EDITOR_INTERNAL); #endif if(editor_cfg != UINT_MAX) setEditor(editor_cfg); undo->setToolTip(tr("Undo (%1)").arg(m_editor->getUndoShortcut())); redo->setToolTip(tr("Redo (%1)").arg(m_editor->getRedoShortcut())); ui->resizeLine->setOrientation(false); ui->resizeLine->setResizeLayout(ui->mainLayout); ui->mainLayout->setStretch(ui->mainLayout->indexOf(ui->errorEdit), sConfig.get(CFG_QUINT32_SCRIPTEDITOR_STR)); ui->mainLayout->setStretch(ui->mainLayout->indexOf(ui->errorEdit)-2, 100 - sConfig.get(CFG_QUINT32_SCRIPTEDITOR_STR)); ui->resizeLine->updateStretch(); m_errors = 0; m_ignoreFocus = false; m_editor->setText(source); m_changed = !source.isEmpty(); setLanguage(type); connect(&m_status_timer, SIGNAL(timeout()), SLOT(clearStatus())); connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), SLOT(focusChanged(QWidget*,QWidget*))); ui->errorBtn->setChecked(sConfig.get(CFG_BOOL_SHOW_SCRIPT_ERROR)); on_errorBtn_toggled(ui->errorBtn->isChecked()); setFilename(filename); m_contentChanged = false; m_fileChanged = false; checkChange(); connect(m_exampleBtn, SIGNAL(clicked()), SLOT(exampleBtn())); connect(m_settingsBtn, SIGNAL(clicked()), SLOT(settingsBtn())); }