void Selection_Flipz (void) { UndoableCommand undo("mirrorSelected -axis z"); Select_FlipAxis(2); }
QFEHelpEditorWidget::QFEHelpEditorWidget(QWidget* parent) : QWidget(parent), ui(new Ui::QFEHelpEditorWidget) { modified=false; newScript=true; ui->setupUi(this); ui->edtScript->getEditor()->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); ui->edtScript->getEditor()->setLineWrapMode(QTextEdit::WidgetWidth); connect(ui->edtScript->getEditor()->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); highlighter=new QFHTMLHighlighter("", ui->edtScript->getEditor()->document()); highlighter->setUseSpecial2("$(", ")$"); highlighter->setUseSpecial1("$$", "$$"); completer = new QCompleter(ui->edtScript->getEditor()); completermodel=modelFromFile(ProgramOptions::getInstance()->getAssetsDirectory()+"/qtscript/completer.txt"); completer->setModel(completermodel); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setWrapAround(false); ui->edtScript->getEditor()->setCompleter(completer); recentHelpFiles=new QRecentFilesMenu(this); recentHelpFiles->setUseSystemFileIcons(false); recentHelpFiles->setAlwaysEnabled(true); connect(recentHelpFiles, SIGNAL(openRecentFile(QString)), this, SLOT(openScriptNoAsk(QString))); ui->btnOpen->setMenu(recentHelpFiles); connect(ui->edtScript->getEditor(), SIGNAL(cursorPositionChanged()), this, SLOT(edtScript_cursorPositionChanged())); actLoadAutosave=new QFActionWithNoMenuRole(tr("load last autosaved file ..."), this); connect(actLoadAutosave, SIGNAL(triggered()), this, SLOT(reloadLastAutosave())); cutAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_cut.png"), tr("Cu&t"), this); cutAct->setShortcut(tr("Ctrl+X")); cutAct->setToolTip(tr("Cut the current selection's contents to the " "clipboard")); connect(cutAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(cut())); copyAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_copy.png"), tr("&Copy"), this); copyAct->setShortcut(tr("Ctrl+C")); copyAct->setToolTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(copy())); pasteAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_paste.png"), tr("&Paste"), this); pasteAct->setShortcut(tr("Ctrl+V")); pasteAct->setToolTip(tr("Paste the clipboard's contents into the current " "selection")); connect(pasteAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(paste())); undoAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_undo.png"), tr("&Undo"), this); undoAct->setShortcut(tr("Ctrl+Z")); undoAct->setToolTip(tr("Undo the last change ")); connect(undoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(undo())); redoAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_redo.png"), tr("&Redo"), this); redoAct->setShortcut(tr("Ctrl+Shift+Z")); redoAct->setToolTip(tr("Redo the last undone change ")); connect(redoAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(redo())); findAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find.png"), tr("&Find ..."), this); findAct->setShortcut(tr("Ctrl+F")); findAct->setToolTip(tr("Find a string in sequence ")); connect(findAct, SIGNAL(triggered()), this, SLOT(findFirst())); findNextAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find_next.png"), tr("Find &next"), this); findNextAct->setShortcut(tr("F3")); findNextAct->setToolTip(tr("Find the next occurence ")); connect(findNextAct, SIGNAL(triggered()), this, SLOT(findNext())); findNextAct->setEnabled(false); replaceAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_find_replace.png"), tr("Find && &replace ..."), this); replaceAct->setShortcut(tr("Ctrl+R")); replaceAct->setToolTip(tr("Find a string in sequence and replace it with another string ")); connect(replaceAct, SIGNAL(triggered()), this, SLOT(replaceFirst())); commentAct = new QFActionWithNoMenuRole(tr("&Comment text"), this); commentAct->setShortcut(tr("Ctrl+B")); commentAct->setToolTip(tr("add (single line) comment at the beginning of each line ")); connect(commentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(comment())); unCommentAct = new QFActionWithNoMenuRole(tr("&Uncomment text"), this); unCommentAct->setShortcut(tr("Ctrl+Shift+B")); unCommentAct->setToolTip(tr("remove (single line) comment at the beginning of each line ")); connect(unCommentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(uncomment())); indentAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_indent.png"), tr("&Increase indention"), this); commentAct->setShortcut(tr("Ctrl+I")); indentAct->setToolTip(tr("increase indention ")); connect(indentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentInc())); unindentAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_unindent.png"), tr("&Decrease indention"), this); unindentAct->setShortcut(tr("Ctrl+Shift+I")); unindentAct->setToolTip(tr("decrease indention ")); connect(unindentAct, SIGNAL(triggered()), ui->edtScript->getEditor(), SLOT(indentDec())); gotoLineAct = new QFActionWithNoMenuRole(tr("&Goto line ..."), this); gotoLineAct->setShortcut(tr("Alt+G")); gotoLineAct->setToolTip(tr("goto a line in the opened file ")); connect(gotoLineAct, SIGNAL(triggered()), this, SLOT(gotoLine())); printAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/script_print.png"), tr("&Print ..."), this); printAct->setToolTip(tr("print the current SDFF file ")); connect(printAct, SIGNAL(triggered()), this, SLOT(print())); actInsertIcon = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/insert_image.png"), tr("&Insert icon ..."), this); actInsertIcon->setToolTip(tr("print the current SDFF file ")); connect(actInsertIcon, SIGNAL(triggered()), this, SLOT(insertIcon())); toEntityAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/toentity.png"), tr("&Convert characters to entities ..."), this); toEntityAct->setToolTip(tr("convert characters in the selected text to HTML entities")); connect(toEntityAct, SIGNAL(triggered()), this, SLOT(toEntity())); toCharAct = new QFActionWithNoMenuRole(QIcon(":/qfe_helpeditor/tochars.png"), tr("&Convert entities to characters ..."), this); toCharAct->setToolTip(tr("convert HTML entities in the selected text to characters")); connect(toCharAct, SIGNAL(triggered()), this, SLOT(toChars())); cutAct->setEnabled(false); copyAct->setEnabled(false); undoAct->setEnabled(false); redoAct->setEnabled(false); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), cutAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(undoAvailable(bool)), undoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(redoAvailable(bool)), redoAct, SLOT(setEnabled(bool))); connect(ui->edtScript->getEditor(), SIGNAL(findNextAvailable(bool)), findNextAct, SLOT(setEnabled(bool))); QMenu* menuMore=new QMenu(ui->tbMoreOptions); menuMore->addAction(indentAct); menuMore->addAction(unindentAct); menuMore->addAction(commentAct); menuMore->addAction(unCommentAct); menuMore->addSeparator(); menuMore->addAction(toEntityAct); menuMore->addAction(toCharAct); menuMore->addSeparator(); menuMore->addAction(actInsertIcon); menuMore->addSeparator(); menuMore->addAction(gotoLineAct); menuMore->addAction(findAct); menuMore->addAction(replaceAct); menuMore->addAction(findNextAct); menuMore->addSeparator(); menuMore->addAction(actLoadAutosave); ui->tbMoreOptions->setMenu(menuMore); ui->tbFind->setDefaultAction(findAct); ui->tbFindNext->setDefaultAction(findNextAct); ui->tbReplace->setDefaultAction(replaceAct); ui->tbPrint->setDefaultAction(printAct); ui->tbCopy->setDefaultAction(copyAct); ui->tbCut->setDefaultAction(cutAct); ui->tbPaste->setDefaultAction(pasteAct); ui->tbRedo->setDefaultAction(redoAct); ui->tbUndo->setDefaultAction(undoAct); ui->tbEntity->setDefaultAction(toEntityAct); ui->tbChars->setDefaultAction(toCharAct); setScriptFilename(""); QMenu* menu; menu=new QMenu(tr("directories"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$mainhelpdir$$"); addInsertAction(menu, "$$mainhelppicdir$$"); addInsertAction(menu, "$$assetsdir$$"); addInsertAction(menu, "$$examplesdir$$"); addInsertAction(menu, "$$configdir$$"); addInsertAction(menu, "$$maindir$$"); addInsertAction(menu, "$$sourcedir$$"); menu=new QMenu(tr("version/copyright info"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$version.svnrevision$$"); addInsertAction(menu, "$$version.status$$"); addInsertAction(menu, "$$version.date$$"); addInsertAction(menu, "$$version$$"); addInsertAction(menu, "$$version_full$$"); menu->addSeparator(); addInsertAction(menu, "$$thanksto$$"); addInsertAction(menu, "$$copyright$$"); addInsertAction(menu, "$$author$$"); addInsertAction(menu, "$$weblink$$"); addInsertAction(menu, "$$license$$"); addInsertAction(menu, "$$maillist$$"); addInsertAction(menu, "$$maillistrequest$$"); menu->addSeparator(); addInsertAction(menu, "$$qfcitation$$"); addInsertAction(menu, "$$qfcitation_bibtex$$"); addInsertAction(menu, "$$jankrieger_phdthesis$$"); addInsertAction(menu, "$$jankrieger_phdthesis_ref$$"); menu=new QMenu(tr("general help links"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("Link: RDR general help"), "<a href=\"$qf_ui_rdr_helpfile$$\">$$qf_ui_rdr_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Evaluation general help"), "<a href=\"$$qf_ui_eval_helpfile$$\">$$qf_ui_eval_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Plotter Widget general help"), "<a href=\"$$qf_ui_jkqtplotter_helpfile$$\">$$qf_ui_jkqtplotter_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: LaTeX parser general help"), "<a href=\"$$qf_ui_latex_helpfile$$\">$$qf_ui_latex_helpfiletitle$$</a>" ); addInsertAction(menu, tr("Link: Expression parser help"), "<a href=\"$$qf_mathparser_helpfile$$\">$$qf_mathparser_helpfiletitle$$</a>" ); //addInsertAction(menu, tr("Link: help"), "<a href=\"$$aa$$\">$$aa$$</a>" ); //addInsertAction(menu, tr("Link: help"), QString("<a href=\"$$mainhelpdir$$aa\">aa</a>") ); addInsertAction(menu, tr("Link: Custom color palettes help"), QString("<a href=\"$$mainhelpdir$$colorpalettes.html\">custom color paletes</a>") ); addInsertAction(menu, tr("Link: Available color palettes"), QString("<a href=\"$$mainhelpdir$$installedcolorpalettes.html\">available color paletes</a>") ); addInsertAction(menu, tr("Link: Regular Expressions"), QString("<a href=\"$$mainhelpdir$$qf3_qtregexp.html\">regular expressions</a>") ); addInsertAction(menu, tr("Link: Fit Functions"), QString("<a href=\"$$mainhelpdir$$qf3_fitfunc.html\">fit functions</a>") ); addInsertAction(menu, tr("Link: Fit Algorithms"), QString("<a href=\"$$mainhelpdir$$qf3_fitalg.html\">fit algorithms</a>") ); addInsertAction(menu, tr("Link: File Formats"), QString("<a href=\"$$mainhelpdir$$qf3_fileformats.html\">file formats</a>") ); addInsertAction(menu, tr("Link: GPL 3.0"), QString("<a href=\"$$mainhelpdir$$gpl3_0.html\">GPL 3.0</a>") ); addInsertAction(menu, tr("Link: FAQs"), QString("<a href=\"$$qf_faqfile$$\">Frequently asked questions</a>") ); menu->addSeparator(); addInsertAction(menu, "$$qf_ui_rdr_helpfile$$"); addInsertAction(menu, "$$qf_ui_rdr_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_eval_helpfile$$"); addInsertAction(menu, "$$qf_ui_eval_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_jkqtplotter_helpfile$$"); addInsertAction(menu, "$$qf_ui_jkqtplotter_helpfiletitle$$"); addInsertAction(menu, "$$qf_ui_latex_helpfile$$"); addInsertAction(menu, "$$qf_ui_latex_helpfiletitle$$"); addInsertAction(menu, "$$qf_mathparser_helpfile$$"); addInsertAction(menu, "$$qf_mathparser_helpfiletitle$$"); addInsertAction(menu, "$$qf_faqfile$$"); menu=new QMenu(tr("page header/footer"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$qf_commondoc_backtop$$"); menu->addSeparator(); addInsertAction(menu, "$$qf_commondoc_footer.start$$"); addInsertAction(menu, "$$qf_commondoc_footer.end$$"); menu->addSeparator(); addInsertAction(menu, "$$qf_commondoc_header.start$$"); addInsertAction(menu, "$$qf_commondoc_header.end$$"); addInsertAction(menu, "$$qf_commondoc_header.end_notitle$$"); addInsertAction(menu, "$$qf_commondoc_header.rdr$$"); addInsertAction(menu, "$$qf_commondoc_header.eval$$"); addInsertAction(menu, "$$qf_commondoc_header.extension$$"); addInsertAction(menu, "$$qf_commondoc_header.fitfunc$$"); addInsertAction(menu, "$$qf_commondoc_header.fitalg$$"); addInsertAction(menu, "$$qf_commondoc_header.separator$$"); menu=new QMenu(tr("plugin info"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$local_plugin_icon$$"); addInsertAction(menu, "$$local_plugin_iconfilename$$"); addInsertAction(menu, "$$local_plugin_name$$"); addInsertAction(menu, "$$local_plugin_author$$"); addInsertAction(menu, "$$local_plugin_copyright$$"); addInsertAction(menu, "$$local_plugin_weblink_url$$"); addInsertAction(menu, "$$local_plugin_weblink$$"); addInsertAction(menu, "$$local_plugin_id$$"); addInsertAction(menu, "$$local_plugin_subid$$"); addInsertAction(menu, "$$local_plugin_subname$$"); addInsertAction(menu, "$$local_plugin_subshortname$$"); addInsertAction(menu, "$$local_plugin_tutorial_file$$"); addInsertAction(menu, "$$local_plugin_tutorial_link$$"); addInsertAction(menu, "$$local_plugin_mainhelp_file$$"); addInsertAction(menu, "$$local_plugin_mainhelp_link$$"); addInsertAction(menu, "$$local_plugin_version$$"); addInsertAction(menu, "$$local_plugin_typehelp_link$$"); addInsertAction(menu, "$$local_plugin_typehelp_file$$"); addInsertAction(menu, "$$local_plugin_assets$$"); addInsertAction(menu, "$$local_plugin_examples$$"); addInsertAction(menu, "$$local_plugin_help$$"); addInsertAction(menu, "$$local_plugin_config$$"); addInsertAction(menu, "$$local_plugin_tutorials$$"); menu->addSeparator(); addInsertAction(menu, "$$plugin_info:help:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:tutorial:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:helpdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:assetsdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:examplesdir:PLUGINID$$"); addInsertAction(menu, "$$plugin_info:configdir:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$fitfunction:help:PLUGINID$$"); addInsertAction(menu, "$$fitfunction:name:PLUGINID$$"); addInsertAction(menu, "$$fitfunction:short_name:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$fitalgorithm:help:PLUGINID$$"); addInsertAction(menu, "$$fitalgorithm:name:PLUGINID$$"); addInsertAction(menu, "$$fitalgorithm:short_name:PLUGINID$$"); menu->addSeparator(); addInsertAction(menu, "$$importer:help:PLUGINID$$"); addInsertAction(menu, "$$importer:name:PLUGINID$$"); addInsertAction(menu, "$$exporter:help:PLUGINID$$"); addInsertAction(menu, "$$exporter:name:PLUGINID$$"); menu=new QMenu(tr("plugin lists"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$list:extension:INTERFACENAME$$"); addInsertAction(menu, "$$list:fitfunc:$$"); addInsertAction(menu, "$$list:fitfunc:STARTSWITH$$"); addInsertAction(menu, "$$list:fitfunc_inplugin:PLUGIN_ID|STARTSWITH$$"); addInsertAction(menu, "$$list:fitfunc_inplugin:PLUGIN_ID$$"); addInsertAction(menu, "$$list:fitalg:$$"); addInsertAction(menu, "$$list:fitalg:STARTSWITH$$"); addInsertAction(menu, "$$list:importers:STARTSWITH$$"); addInsertAction(menu, "$$list:exporters:STARTSWITH$$"); addInsertAction(menu, "$$list:plugin_tutorials:PLUGIN_ID$$"); menu=new QMenu(tr("help lists"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tutorials_contents$$"); addInsertAction(menu, "$$help_contents$$"); addInsertAction(menu, "$$settings_contents$$"); menu=new QMenu(tr("insert files"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$insert:FILENAME$$"); addInsertAction(menu, "$$insertglobal:FILENAME$$"); menu=new QMenu(tr("insert Equations (LaTeX)"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$math:LATEX$$"); addInsertAction(menu, "$(LATEX)$"); addInsertAction(menu, "$$bmath:LATEX$$"); addInsertAction(menu, "$[LATEX]$"); menu=new QMenu(tr("insert Literature References"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$ref:<ID>:Text$$"); addInsertAction(menu, "$$ref:<ID>:$$"); addInsertAction(menu, "$$invisibleref:<ID>:Text$$"); addInsertAction(menu, "$$references$$"); menu=new QMenu(tr("insert Figures"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$fig:FILENAME:CAPTION$$"); menu=new QMenu(tr("insert Info boxes"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$see:Text$$"); addInsertAction(menu, "$$note:Text$$"); addInsertAction(menu, "$$info:Text$$"); addInsertAction(menu, "$$warning:Text$$"); addInsertAction(menu, "$$example:Text$$"); addInsertAction(menu, "$$codeexample:Text$$"); addInsertAction(menu, "$$bqtt:Text$$"); addInsertAction(menu, "$$bqcode:Text$$"); menu->addSeparator(); addInsertAction(menu, "$$startbox$$"); addInsertAction(menu, "$$startbox_info$$"); addInsertAction(menu, "$$startbox_note$$"); addInsertAction(menu, "$$startbox_see$$"); addInsertAction(menu, "$$startbox_warning$$"); addInsertAction(menu, "$$startbox_example$$"); addInsertAction(menu, "$$startbox:backgroundcolor:bordercolor$$"); addInsertAction(menu, "$$startbox:lightgrey:midnightblue$$"); addInsertAction(menu, "$$endbox$$"); menu=new QMenu(tr("insert Tooltips"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tooltip:PHRASE$$"); menu=new QMenu(tr("FAQs"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("FAQ entry"), "$$faq_start$$\n <a name=\"FAQ1\"><b>Question?</b>\n$$faq_answer$$\n Answer ...\n$$faq_end$$"); menu->addSeparator(); addInsertAction(menu, "$$faq_start"); addInsertAction(menu, "$$faq_answer"); addInsertAction(menu, "$$faq_end"); menu=new QMenu(tr("Function References"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, tr("Function reference entry"), "$$funcref_start$$<a name=\"NAME\"/><!-- func:NAME -->\n <b><tt><!-- template -->NAME<!-- /template --></tt> - <i> DESCRIPTION </i>:</b>\n$$funcref_description$$\n DESCRIPTION\n <!-- /func:NAME -->\n$$funcref_end$$"); menu->addSeparator(); addInsertAction(menu, "$$funcref_start"); addInsertAction(menu, "$$funcref_description"); addInsertAction(menu, "$$funcref_end"); menu=new QMenu(tr("insert other markups"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$$tt:Text$$"); menu=new QMenu(tr("LaTeX"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "\\left(%1#\\right)"); addInsertAction(menu, "\\left[%1#\\right]"); addInsertAction(menu, "\\left\\{%1#\\right\\}"); addInsertAction(menu, "\\left\\langle%1#\\right\\rangle"); menu->addSeparator(); addInsertAction(menu, "\\sqrt{%1#}"); menu->addSeparator(); addInsertAction(menu, "\\sum_{#}^{}%1"); addInsertAction(menu, "\\prod_{#}^{}%1"); addInsertAction(menu, "\\int_{#}^{}%1\\;\\mathrm{d}x"); addInsertAction(menu, "\\iint_{#}^{}%1\\;\\mathrm{d}^2x"); addInsertAction(menu, "\\iiint_{#}^{}%1\\;\\mathrm{d}^3x"); addInsertAction(menu, "\\oint_{#}^{}%1\\;\\mathrm{d}x"); addInsertAction(menu, "\\lim_{%1#}"); addInsertAction(menu, "\\argmin_{%1#}"); addInsertAction(menu, "\\argmax_{%1#}"); menu->addSeparator(); addInsertAction(menu, "\\vec{%1#}"); addInsertAction(menu, "\\hat{%1#}"); addInsertAction(menu, "\\tilde{%1#}"); addInsertAction(menu, "\\mathbf{%1#}"); addInsertAction(menu, "\\mathrm{%1#}"); addInsertAction(menu, "\\mathit{%1#}"); addInsertAction(menu, "\\mathsf{%1#}"); addInsertAction(menu, "\\mathbb{%1#}"); addInsertAction(menu, "\\mathscript{%1#}"); addInsertAction(menu, "\\underline{%1#}"); //addInsertAction(menu, "$$$$"); menu=new QMenu(tr("Special Characters"), this); ui->edtScript->getEditor()->addAction(menu->menuAction()); addInsertAction(menu, "$" "$"); addInsertAction(menu, "$$" "$$"); QTimer::singleShot(AUTOSAVE_INTERVAL_MSEC, this, SLOT(autosave())); }
void MainWindow::createActions() { m_newAction = new QAction(this); m_newAction->setText(tr("&New")); m_newAction->setShortcut(QKeySequence::New); m_newAction->setIcon(QIcon(":/images/document-new.png")); m_newAction->setStatusTip(tr("Create a new, in memory, SQLite database")); connect(m_newAction, SIGNAL(triggered()), this, SLOT(openMemoryDatabase())); m_openAction = new QAction(this); m_openAction->setText(tr("&Open")); m_openAction->setShortcut(QKeySequence::Open); m_openAction->setIcon(QIcon(":/images/document-open.png")); m_openAction->setStatusTip(tr("Open an existing SQLite database")); connect(m_openAction, SIGNAL(triggered()), this, SLOT(openDatabase())); m_saveAction = new QAction(this); m_saveAction->setText(tr("&Save")); m_saveAction->setShortcut(QKeySequence::Save); m_saveAction->setStatusTip(tr("Save the database")); connect(m_saveAction, SIGNAL(triggered()), m_dbWidget, SIGNAL(commit())); m_saveAsAction = new QAction(this); m_saveAsAction->setText(tr("Save &As...")); m_saveAsAction->setShortcut(QKeySequence::SaveAs); m_saveAsAction->setStatusTip(tr("Save this database under a new name")); connect(m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAsDatabase())); m_closeAction = new QAction(this); m_closeAction->setText(tr("Close")); m_closeAction->setShortcut(QKeySequence::Close); m_closeAction->setStatusTip(tr("Close the currently opened database")); connect(m_closeAction, SIGNAL(triggered()), this, SLOT(closeDatabase())); for (int i = 0; i < MaxRecentFiles; ++i) { m_recentFileActions[i] = new QAction(this); m_recentFileActions[i]->setVisible(false); connect(m_recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } m_exitAction = new QAction(this); m_exitAction->setText(tr("E&xit")); m_exitAction->setShortcut(QKeySequence::Quit); m_exitAction->setStatusTip(tr("Quits sbuilder")); connect(m_exitAction, SIGNAL(triggered()), this, SLOT(close())); m_undoAction = new QAction(this); m_undoAction->setText(tr("&Undo")); m_undoAction->setShortcut(QKeySequence::Undo); connect(m_undoAction, SIGNAL(triggered()), m_dbWidget, SLOT(undo())); m_redoAction = new QAction(this); m_redoAction->setText(tr("&Redo")); m_redoAction->setShortcut(QKeySequence::Redo); connect(m_redoAction, SIGNAL(triggered()), m_dbWidget, SLOT(redo())); m_cutAction = new QAction(this); m_cutAction->setText(tr("Cu&t")); m_cutAction->setShortcut(QKeySequence::Cut); m_cutAction->setIcon(QIcon(":/images/edit-cut.png")); connect(m_cutAction, SIGNAL(triggered()), m_dbWidget, SLOT(cut())); m_copyAction = new QAction(this); m_copyAction->setText(tr("&Copy")); m_copyAction->setShortcut(QKeySequence::Copy); m_copyAction->setIcon(QIcon(":/images/edit-copy.png")); connect(m_copyAction, SIGNAL(triggered()), m_dbWidget, SLOT(copy())); m_pasteAction = new QAction(this); m_pasteAction->setText(tr("&Paste")); m_pasteAction->setShortcut(QKeySequence::Paste); m_pasteAction->setIcon(QIcon(":/images/edit-paste.png")); connect(m_pasteAction, SIGNAL(triggered()), m_dbWidget, SLOT(paste())); m_selectAllAction = new QAction(this); m_selectAllAction->setText(tr("&Select All")); m_selectAllAction->setShortcut(QKeySequence::SelectAll); connect(m_selectAllAction, SIGNAL(triggered()), m_dbWidget, SLOT(selectAll())); m_runAction = new QAction(this); m_runAction->setText(tr("&Run")); // TODO: a better name m_runAction->setIcon(QIcon(":/images/media-playback-start.png")); m_runAction->setShortcut(QKeySequence(tr("F5"))); connect(m_runAction, SIGNAL(triggered()), m_dbWidget, SLOT(execute())); m_commitAction = new QAction(this); m_commitAction->setText(tr("&Commit")); connect(m_commitAction, SIGNAL(triggered()), m_dbWidget, SIGNAL(commit())); m_rollbackAction = new QAction(this); m_rollbackAction->setText(tr("Roll&back")); connect(m_rollbackAction, SIGNAL(triggered()), m_dbWidget, SIGNAL(rollback())); m_logAction = new QAction(this); m_logAction->setText(tr("Show Log")); connect(m_logAction, SIGNAL(triggered()), m_log, SLOT(show())); m_pragmaAction = new QAction(this); m_pragmaAction->setText(tr("Show &Pragmas")); connect(m_pragmaAction, SIGNAL(triggered()), m_pragmaDialog, SLOT(show())); m_memoryAction = new QAction(this); m_memoryAction->setText(tr("Show &Memory Stats")); connect(m_memoryAction, SIGNAL(triggered()), m_memoryDialog, SLOT(show())); m_aboutAction = new QAction(this); m_aboutAction->setText(tr("&About")); m_aboutAction->setStatusTip(tr("About the wonderful maker of sbuilder")); connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(about())); }
TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setupFileActions(); setupEditActions(); setupTextActions(); { QMenu *helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); } textEdit = new QTextEdit(this); connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); setCentralWidget(textEdit); textEdit->setFocus(); setCurrentFileName(QString()); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); QString initialFile = ":/example.html"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
EditorMainWindow::EditorMainWindow(QWidget *parent) : QMainWindow(parent) { camera_ = 0; ui.setupUi(this); QApplication::connect(ui.action_Open, SIGNAL(triggered()), this, SLOT(openRequested())); QApplication::connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(saveRequested())); QApplication::connect(ui.actionDerive_map, SIGNAL(triggered()), this, SLOT(deriveMap())); QApplication::connect(ui.action_Quit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); QApplication::connect(ui.actionZoom_In, SIGNAL(triggered()), this, SLOT(zoominRequested())); QApplication::connect(ui.actionZoom_Out, SIGNAL(triggered()), this, SLOT(zoomoutRequested())); QApplication::connect(ui.horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScroll(int))); QApplication::connect(ui.verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vertScroll(int))); QApplication::connect(ui.actionRotate_Left, SIGNAL(triggered()), this, SLOT(rotateLeft())); QApplication::connect(ui.actionRotate_Right, SIGNAL(triggered()), this, SLOT(rotateRight())); QApplication::connect(ui.actionTilt_Up, SIGNAL(triggered()), this, SLOT(tiltUp())); QApplication::connect(ui.actionTilt_Down, SIGNAL(triggered()), this, SLOT(tiltDown())); QApplication::connect(ui.actionUndo, SIGNAL(triggered()), this, SLOT(undo())); QApplication::connect(ui.actionRedo, SIGNAL(triggered()), this, SLOT(redo())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S),this), SIGNAL(activated()), this, SLOT(saveRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O),this), SIGNAL(activated()), this, SLOT(openRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Z),this), SIGNAL(activated()), this, SLOT(zoominRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_X),this), SIGNAL(activated()), this, SLOT(zoomoutRequested())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left),this), SIGNAL(activated()), this, SLOT(rotateLeft())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right),this), SIGNAL(activated()), this, SLOT(rotateRight())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up),this), SIGNAL(activated()), this, SLOT(tiltUp())); QApplication::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down),this), SIGNAL(activated()), this, SLOT(tiltDown())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Left),this), SIGNAL(activated()), this, SLOT(panLeft())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Right),this), SIGNAL(activated()), this, SLOT(panRight())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Up),this), SIGNAL(activated()), this, SLOT(panUp())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_Down),this), SIGNAL(activated()), this, SLOT(panDown())); ui.action_Save->setEnabled(false); ui.editorGLWidget->setEnabled(false); QToolButton* party_button = new QToolButton(); party_button->setText("Parties"); party_button->setCheckable(true); party_button->setChecked(false); handlers_.push_back(new TerrainHandler(*this, "party", false, tool_buttons_.size())); QApplication::connect(party_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_P),this), SIGNAL(activated()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(party_button); tool_buttons_.push_back(party_button); QToolButton* height_button = new QToolButton(); height_button->setText("Height"); height_button->setCheckable(true); height_button->setChecked(true); handlers_.push_back(new TerrainHandler(*this, "", false, tool_buttons_.size())); QApplication::connect(height_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); QApplication::connect(new QShortcut(QKeySequence(Qt::Key_H),this), SIGNAL(activated()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(height_button); tool_buttons_.push_back(height_button); QToolButton* picker_button = new QToolButton(); picker_button->setText("Picker"); picker_button->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, "", true, tool_buttons_.size())); QApplication::connect(picker_button, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(picker_button); tool_buttons_.push_back(picker_button); std::vector<std::string> terrain_ids; hex::base_terrain::get_terrain_ids(terrain_ids); for(int n = 0; n != terrain_ids.size(); ++n) { QToolButton* b = new QToolButton(); b->setText(hex::base_terrain::get(terrain_ids[n])->name().c_str()); b->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, terrain_ids[n], false, tool_buttons_.size())); QApplication::connect(b, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(b); tool_buttons_.push_back(b); } terrain_ids.clear(); hex::terrain_feature::get_feature_ids(terrain_ids); for(int n = 0; n != terrain_ids.size(); ++n) { QToolButton* b = new QToolButton(); b->setText(hex::terrain_feature::get(terrain_ids[n])->name().c_str()); b->setCheckable(true); handlers_.push_back(new TerrainHandler(*this, terrain_ids[n], true, tool_buttons_.size())); QApplication::connect(b, SIGNAL(pressed()), handlers_.back(), SLOT(terrainSelected())); ui.tilesToolBar->addWidget(b); tool_buttons_.push_back(b); } }
//! [0] QPushButton p("&Exit", parent); // automatic shortcut Alt+E Q3PopupMenu *fileMenu = new fileMenu(parent); fileMenu->insertItem("Undo", parent, SLOT(undo()), Qt::CTRL + Qt::Key_Z); //! [0] //! [1] accelerator->insertItem(QKeySequence("M")); //! [1] //! [2] Q3Accel *a = new Q3Accel(myWindow); a->connectItem(a->insertItem(Qt::CTRL + Qt::Key_P), myWindow, SLOT(printDoc())); //! [2] //! [3] Q3Accel *a = new Q3Accel(myWindow); // create accels for myWindow a->insertItem(CTRL + Key_P, 200); // Ctrl+P, e.g. to print document a->insertItem(ALT + Key_X, 201); // Alt+X, e.g. to quit a->insertItem(UNICODE_ACCEL + 'q', 202); // Unicode 'q', e.g. to quit a->insertItem(Key_D); // gets a unique negative id < -1 a->insertItem(CTRL + SHIFT + Key_P); // gets a unique negative id < -1 //! [3] //! [4]
void main() { clrscr(); char choice; int loop; cout << "Sentence : "; cin.get(array,39); cin.ignore(100,'\n'); do { clrscr(); cout << endl << "The Sentence is : " << endl << array << endl; cout << "1=Reverse Words" << endl << "2=Reverse Letters in Words" << endl << "3=Back word to Front" << endl << "4=Front Word to Back" << endl; if(pro[0]!=null) cout << "5=Undo" << endl; if(con[0]!=null) cout << "6=Redo" << endl; cout << "7=Quit" << endl; choice=getch(); if(choice=='1') { rev_words(); con[0]=null; for(loop=29; loop>0; loop--) { pro[loop]=pro[loop-1]; } pro[0]=rw; } else if(choice=='2') { rev_letters(); con[0]=null; for(loop=29; loop>0; loop--) { pro[loop]=pro[loop-1]; } pro[0]=rl; } else if(choice=='3') { back_to_front(); con[0]=null; for(loop=29; loop>0; loop--) { pro[loop]=pro[loop-1]; } pro[0]=btf; } else if(choice=='4') { front_to_back(); con[0]=null; for(loop=29; loop>0; loop--) { pro[loop]=pro[loop-1]; } pro[0]=ftb; } else if(choice=='5' && pro[0]!=null) undo(); else if(choice=='6' && con[0]!=null) redo(); } while(choice!='7'); }
void MainWindow2::createMenus() { // ---------- File Menu ------------- connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newDocument())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openDocument())); connect(ui->actionSave_as, SIGNAL(triggered()), this, SLOT(saveAsNewDocument())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveDocument())); connect(ui->actionPrint, SIGNAL(triggered()), editor, SLOT(print())); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); /// --- Export Menu --- connect(ui->actionExport_X_sheet , SIGNAL(triggered()), editor, SLOT(exportX())); connect(ui->actionExport_Image_Sequence, SIGNAL(triggered()), editor, SLOT(exportSeq())); connect(ui->actionExport_Image, SIGNAL(triggered()), editor, SLOT(exportImage())); connect(ui->actionExport_Movie, SIGNAL(triggered()), editor, SLOT(exportMov())); //exportFlashAct = new QAction(tr("&Flash/SWF..."), this); //exportFlashAct->setShortcut(tr("Ctrl+Alt+F")); //connect(exportFlashAct, SIGNAL(triggered()), editor, SLOT(exportFlash())); connect(ui->actionExport_Palette, SIGNAL(triggered()), this, SLOT(exportPalette())); /// --- Import Menu --- connect(ui->actionExport_Svg_Image, SIGNAL(triggered()), editor, SLOT(saveSvg())); connect(ui->actionImport_Image, SIGNAL(triggered()), editor, SLOT(importImage())); connect(ui->actionImport_Image_Sequence, SIGNAL(triggered()), editor, SLOT(importImageSequence())); connect(ui->actionImport_Movie, SIGNAL(triggered()), editor, SLOT(importMov())); connect(ui->actionImport_Sound, SIGNAL(triggered()), editor, SLOT(importSound())); connect(ui->actionImport_Palette, SIGNAL(triggered()), this, SLOT(importPalette())); /// --- Edit Menu --- connect(ui->actionUndo, SIGNAL(triggered()), editor, SLOT(undo())); connect(ui->actionRedo, SIGNAL(triggered()), editor, SLOT(redo())); connect(ui->actionCut, SIGNAL(triggered()), editor, SLOT(cut())); connect(ui->actionCopy, SIGNAL(triggered()), editor, SLOT(copy())); connect(ui->actionPaste, SIGNAL(triggered()), editor, SLOT(paste())); connect(ui->actionDelete, SIGNAL(triggered()), editor, SLOT(clearCurrentFrame())); connect(ui->actionCrop, SIGNAL(triggered()), editor, SLOT(crop())); connect(ui->actionCrop_To_Selection, SIGNAL(triggered()), editor, SLOT(croptoselect())); connect(ui->actionSelect_All, SIGNAL(triggered()), editor, SIGNAL(selectAll())); connect(ui->actionDeselect_All, SIGNAL(triggered()), editor, SLOT(deselectAll())); connect(ui->actionPreference, SIGNAL(triggered()), this, SLOT(showPreferences())); ui->actionRedo->setEnabled(false); /// --- Layer Menu --- connect(ui->actionNew_Bitmap_Layer, SIGNAL(triggered()), editor, SLOT(newBitmapLayer())); connect(ui->actionNew_Vector_Layer, SIGNAL(triggered()), editor, SLOT(newVectorLayer())); connect(ui->actionNew_Sound_Layer, SIGNAL(triggered()), editor, SLOT(newSoundLayer())); connect(ui->actionNew_Camera_Layer, SIGNAL(triggered()), editor, SLOT(newCameraLayer())); connect(ui->actionDelete_Current_Layer, SIGNAL(triggered()), editor, SLOT(deleteCurrentLayer())); /// --- View Menu --- connect(ui->actionZoom_In, SIGNAL(triggered()), editor, SLOT(setzoom())); connect(ui->actionZoom_Out, SIGNAL(triggered()), editor, SLOT(setzoom1())); connect(ui->actionRotate_Clockwise, SIGNAL(triggered()), editor, SLOT(rotatecw())); connect(ui->actionRotate_Anticlosewise, SIGNAL(triggered()), editor, SLOT(rotateacw())); connect(ui->actionReset_Windows, SIGNAL(triggered()), this, SLOT(dockAllPalettes())); connect(ui->actionReset_View, SIGNAL(triggered()), editor, SLOT(resetView())); connect(ui->actionHorizontal_Flip, SIGNAL(triggered()), editor, SLOT(toggleMirror())); connect(ui->actionVertical_Flip, SIGNAL(triggered()), editor, SLOT(toggleMirrorV())); ui->actionPreview->setEnabled(false); //# connect(previewAct, SIGNAL(triggered()), editor, SLOT(getCameraLayer()));//TODO: Preview view ui->actionGrid->setEnabled(false); connect(ui->actionGrid, SIGNAL(triggered()), editor, SLOT(gridview())); //TODO: Grid view connect(ui->actionOnionPrevious, SIGNAL(triggered(bool)), editor, SIGNAL(toggleOnionPrev(bool))); connect(editor, SIGNAL(onionPrevChanged(bool)), ui->actionOnionPrevious, SLOT(setChecked(bool))); connect(ui->actionOnionNext, SIGNAL(triggered(bool)), editor, SIGNAL(toggleOnionNext(bool))); connect(editor, SIGNAL(onionNextChanged(bool)), ui->actionOnionNext, SLOT(setChecked(bool))); /// --- Animation Menu --- connect(ui->actionPlay, SIGNAL(triggered()), editor, SLOT(play())); connect(ui->actionLoop, SIGNAL(triggered(bool)), editor, SLOT(setLoop(bool))); connect(ui->actionLoop, SIGNAL(toggled(bool)), editor, SIGNAL(toggleLoop(bool))); //TODO: WTF? connect(editor, SIGNAL(loopToggled(bool)), ui->actionLoop, SLOT(setChecked(bool))); connect(ui->actionAdd_Frame, SIGNAL(triggered()), editor, SLOT(addKey())); connect(ui->actionRemove_Frame, SIGNAL(triggered()), editor, SLOT(removeKey())); connect(ui->actionNext_Frame, SIGNAL(triggered()), editor, SLOT(playNextFrame())); connect(ui->actionPrevious_Frame, SIGNAL(triggered()), editor, SLOT(playPrevFrame())); connect(ui->actionNext_Keyframe, SIGNAL(triggered()), editor, SLOT(scrubNextKeyframe())); connect(ui->actionPrev_Keyframe, SIGNAL(triggered()), editor, SLOT(scrubPreviousKeyframe())); connect(ui->actionDuplicate_Frame, SIGNAL(triggered()), editor, SLOT(duplicateKey())); /// --- Tool Menu --- connect(ui->actionClear, SIGNAL(triggered()), editor, SLOT(clearCurrentFrame())); connect(ui->actionMove, SIGNAL(triggered()), m_toolSet, SLOT(moveOn())); connect(ui->actionSelect, SIGNAL(triggered()), m_toolSet, SLOT(selectOn())); connect(ui->actionBrush, SIGNAL(triggered()), m_toolSet, SLOT(brushOn())); connect(ui->actionPolyline, SIGNAL(triggered()), m_toolSet, SLOT(polylineOn())); connect(ui->actionSmudge, SIGNAL(triggered()), m_toolSet, SLOT(smudgeOn())); connect(ui->actionPen, SIGNAL(triggered()), m_toolSet, SLOT(penOn())); connect(ui->actionHand, SIGNAL(triggered()), m_toolSet, SLOT(handOn())); connect(ui->actionPencil, SIGNAL(triggered()), m_toolSet, SLOT(pencilOn())); connect(ui->actionBucket, SIGNAL(triggered()), m_toolSet, SLOT(bucketOn())); connect(ui->actionEyedropper, SIGNAL(triggered()), m_toolSet, SLOT(eyedropperOn())); connect(ui->actionEraser, SIGNAL(triggered()), m_toolSet, SLOT(eraserOn())); connect(ui->actionResetToolsDefault, SIGNAL(triggered()), this, SLOT(resetToolsSettings())); /// --- Help Menu --- connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(helpBox())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPencil())); // --------------- Menus ------------------ openRecentMenu = new QMenu(tr("Open recent"), this); connect(ui->menuEdit, SIGNAL(aboutToShow()), this, SLOT(undoActSetText())); connect(ui->menuEdit, SIGNAL(aboutToHide()), this, SLOT(undoActSetEnabled())); }
editor_action* editor_action_unit_facing::perform(map_context& mc) const { std::unique_ptr<editor_action> undo(new editor_action_unit_facing(loc_, old_direction_, new_direction_)); perform_without_undo(mc); return undo.release(); }
void Score::write(Xml& xml, bool selectionOnly) { // if we have multi measure rests and some parts are hidden, // then some layout information is missing: // relayout with all parts set visible QList<Part*> hiddenParts; bool unhide = false; if (styleB(StyleIdx::createMultiMeasureRests)) { for (Part* part : _parts) { if (!part->show()) { if (!unhide) { startCmd(); unhide = true; } part->undoChangeProperty(P_ID::VISIBLE, true); hiddenParts.append(part); } } } if (unhide) { doLayout(); for (Part* p : hiddenParts) p->setShow(false); } xml.stag("Score"); switch(_layoutMode) { case LayoutMode::PAGE: case LayoutMode::FLOAT: case LayoutMode::SYSTEM: break; case LayoutMode::LINE: xml.tag("layoutMode", "line"); break; } #ifdef OMR if (_omr && xml.writeOmr) _omr->write(xml); #endif if (_showOmr && xml.writeOmr) xml.tag("showOmr", _showOmr); if (_audio && xml.writeOmr) { xml.tag("playMode", int(_playMode)); _audio->write(xml); } for (int i = 0; i < 32; ++i) { if (!_layerTags[i].isEmpty()) { xml.tag(QString("LayerTag id=\"%1\" tag=\"%2\"").arg(i).arg(_layerTags[i]), _layerTagComments[i]); } } int n = _layer.size(); for (int i = 1; i < n; ++i) { // dont save default variant const Layer& l = _layer[i]; xml.tagE(QString("Layer name=\"%1\" mask=\"%2\"").arg(l.name).arg(l.tags)); } xml.tag("currentLayer", _currentLayer); if (!MScore::testMode) _synthesizerState.write(xml); if (pageNumberOffset()) xml.tag("page-offset", pageNumberOffset()); xml.tag("Division", MScore::division); xml.curTrack = -1; _style.save(xml, true); // save only differences to buildin style xml.tag("showInvisible", _showInvisible); xml.tag("showUnprintable", _showUnprintable); xml.tag("showFrames", _showFrames); xml.tag("showMargins", _showPageborders); QMapIterator<QString, QString> i(_metaTags); while (i.hasNext()) { i.next(); if ((!MScore::testMode && !MScore::saveTemplateMode) || (i.key() != "platform" && i.key() != "creationDate")) xml.tag(QString("metaTag name=\"%1\"").arg(i.key().toHtmlEscaped()), i.value()); } if (!selectionOnly) { xml.stag("PageList"); foreach(Page* page, _pages) page->write(xml); xml.etag(); } xml.curTrack = 0; int staffStart; int staffEnd; MeasureBase* measureStart; MeasureBase* measureEnd; if (selectionOnly) { staffStart = _selection.staffStart(); staffEnd = _selection.staffEnd(); // make sure we select full parts Staff* sStaff = staff(staffStart); Part* sPart = sStaff->part(); Staff* eStaff = staff(staffEnd - 1); Part* ePart = eStaff->part(); staffStart = staffIdx(sPart); staffEnd = staffIdx(ePart) + ePart->nstaves(); measureStart = _selection.startSegment()->measure(); if (_selection.endSegment()) measureEnd = _selection.endSegment()->measure()->next(); else measureEnd = 0; } else { staffStart = 0; staffEnd = nstaves(); measureStart = first(); measureEnd = 0; } foreach(const Part* part, _parts) { if (!selectionOnly || ((staffIdx(part) >= staffStart) && (staffEnd >= staffIdx(part) + part->nstaves()))) part->write(xml); } xml.curTrack = 0; xml.trackDiff = -staffStart * VOICES; if (measureStart) { for (int staffIdx = staffStart; staffIdx < staffEnd; ++staffIdx) { xml.stag(QString("Staff id=\"%1\"").arg(staffIdx + 1 - staffStart)); xml.curTick = measureStart->tick(); xml.tickDiff = xml.curTick; xml.curTrack = staffIdx * VOICES; bool writeSystemElements = staffIdx == staffStart; for (MeasureBase* m = measureStart; m != measureEnd; m = m->next()) writeMeasure(xml, m, staffIdx, writeSystemElements); xml.etag(); } } xml.curTrack = -1; if (!selectionOnly) { for (const Excerpt* excerpt : _excerpts) { if (excerpt->partScore() != this) excerpt->partScore()->write(xml, false); // recursion } } if (parentScore()) xml.tag("name", name()); xml.etag(); if (unhide) { endCmd(); undo()->undo(); endUndoRedo(); } }
QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent ) : QWidget( parent ) , mMapCanvas( canvas ) , mBlockAutoApply( false ) , mCurrentLayer( nullptr ) , mVectorStyleWidget( nullptr ) { QBoxLayout* layout = new QVBoxLayout(); layout->setContentsMargins( 0, 0, 0, 0 ); this->setLayout( layout ); mAutoApplyTimer = new QTimer( this ); mAutoApplyTimer->setSingleShot( true ); connect( mAutoApplyTimer, SIGNAL( timeout() ), this, SLOT( apply() ) ); mStackedWidget = new QStackedWidget( this ); mMapStyleTabs = new QTabWidget( this ); mMapStyleTabs->setDocumentMode( true ); mNotSupportedPage = mStackedWidget->addWidget( new QLabel( "Not supported currently" ) ); mVectorPage = mStackedWidget->addWidget( mMapStyleTabs ); // create undo widget mUndoWidget = new QgsUndoWidget( this->mMapStyleTabs, mMapCanvas ); mUndoWidget->setObjectName( "Undo Styles" ); mLayerTitleLabel = new QLabel(); mLayerTitleLabel->setAlignment( Qt::AlignHCenter ); layout->addWidget( mLayerTitleLabel ); layout->addWidget( mStackedWidget ); mButtonBox = new QDialogButtonBox( QDialogButtonBox::Apply ); mLiveApplyCheck = new QCheckBox( "Live update" ); mLiveApplyCheck->setChecked( true ); mUndoButton = new QToolButton( this ); mUndoButton->setIcon( QgsApplication::getThemeIcon( "mActionUndo.png" ) ); mRedoButton = new QToolButton( this ); mRedoButton->setIcon( QgsApplication::getThemeIcon( "mActionRedo.png" ) ); connect( mUndoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( undo() ) ); connect( mRedoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( redo() ) ); QHBoxLayout* bottomLayout = new QHBoxLayout( ); bottomLayout->addWidget( mUndoButton ); bottomLayout->addWidget( mRedoButton ); bottomLayout->addWidget( mButtonBox ); bottomLayout->addWidget( mLiveApplyCheck ); layout->addLayout( bottomLayout ); mLabelingWidget = new QgsLabelingWidget( 0, mMapCanvas, this ); mLabelingWidget->setDockMode( true ); connect( mLabelingWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) ); // Only labels for now but styles and diagrams will come later QScrollArea* stylescroll = new QScrollArea; stylescroll->setWidgetResizable( true ); stylescroll->setFrameStyle( QFrame::NoFrame ); QScrollArea* labelscroll = new QScrollArea; labelscroll->setWidgetResizable( true ); labelscroll->setFrameStyle( QFrame::NoFrame ); labelscroll->setWidget( mLabelingWidget ); mStyleTabIndex = mMapStyleTabs->addTab( stylescroll, QgsApplication::getThemeIcon( "propertyicons/symbology.png" ), "Styles" ); mLabelTabIndex = mMapStyleTabs->addTab( labelscroll, QgsApplication::getThemeIcon( "labelingSingle.svg" ), "Labeling" ); mMapStyleTabs->addTab( mUndoWidget, QgsApplication::getThemeIcon( "labelingSingle.svg" ), "History" ); // int diagramTabIndex = mMapStyleTabs->addTab( new QWidget(), QgsApplication::getThemeIcon( "propertyicons/diagram.png" ), "Diagrams" ); // mMapStyleTabs->setTabEnabled( styleTabIndex, false ); // mMapStyleTabs->setTabEnabled( diagramTabIndex, false ); mMapStyleTabs->setCurrentIndex( mStyleTabIndex ); connect( mMapStyleTabs, SIGNAL( currentChanged( int ) ), this, SLOT( updateCurrentWidgetLayer( int ) ) ); connect( mLiveApplyCheck, SIGNAL( toggled( bool ) ), mButtonBox->button( QDialogButtonBox::Apply ), SLOT( setDisabled( bool ) ) ); connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); mButtonBox->button( QDialogButtonBox::Apply )->setEnabled( false ); }
bool Score::saveFile() { QString suffix = info.suffix(); if (info.exists() && !info.isWritable()) { MScore::lastError = tr("The following file is locked: \n%1 \n\nTry saving to a different location.").arg(info.filePath()); return false; } // if file was already saved in this session // save but don't overwrite backup again if (saved()) { try { if (suffix == "mscx") saveFile(info); else saveCompressedFile(info, false); } catch (QString s) { MScore::lastError = s; return false; } undo()->setClean(); info.refresh(); update(); return true; } // // step 1 // save into temporary file to prevent partially overwriting // the original file in case of "disc full" // QString tempName = info.filePath() + QString(".temp"); QFile temp(tempName); if (!temp.open(QIODevice::WriteOnly)) { MScore::lastError = tr("Open Temp File\n%1\nfailed: %2").arg(tempName).arg(QString(strerror(errno))); return false; } try { if (suffix == "mscx") saveFile(&temp, false); else saveCompressedFile(&temp, info, false); } catch (QString s) { MScore::lastError = s; return false; } if (temp.error() != QFile::NoError) { MScore::lastError = tr("MuseScore: Save File failed: %1").arg(temp.errorString()); temp.close(); return false; } temp.close(); // // step 2 // remove old backup file if exists // QDir dir(info.path()); QString backupName = QString(".") + info.fileName() + QString(","); if (dir.exists(backupName)) { if (!dir.remove(backupName)) { // if (!MScore::noGui) // QMessageBox::critical(0, tr("MuseScore: Save File"), // tr("Removing old backup file ") + backupName + tr(" failed")); } } // // step 3 // rename old file into backup // QString name(info.filePath()); if (dir.exists(name)) { if (!dir.rename(name, backupName)) { // if (!MScore::noGui) // QMessageBox::critical(0, tr("MuseScore: Save File"), // tr("Renaming old file <") // + name + tr("> to backup <") + backupName + tr("> failed")); } } #ifdef Q_OS_WIN QFileInfo fileBackup(dir, backupName); QString backupNativePath = QDir::toNativeSeparators(fileBackup.absoluteFilePath()); SetFileAttributes((LPCTSTR)backupNativePath.toLocal8Bit(), FILE_ATTRIBUTE_HIDDEN); #endif // // step 4 // rename temp name into file name // if (!QFile::rename(tempName, name)) { MScore::lastError = tr("Renaming temp. file <%1> to <%2> failed:\n%3").arg(tempName).arg(name).arg(QString(strerror(errno))); return false; } // make file readable by all QFile::setPermissions(name, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther); undo()->setClean(); setSaved(true); info.refresh(); update(); return true; }
Fenetre::Fenetre(QWidget *parent) : courant(0), QMainWindow(parent) { //************************* courant = NULL; folder = NULL; resize(1200, 512); //*************************** Menu *************************** QMenu* mFile = menuBar()->addMenu("&File"); QMenu* mEdit = menuBar()->addMenu("&Edit"); QMenu* mView = menuBar()->addMenu("&View"); QMenu* mNouveau = mFile->addMenu("New"); QAction* mactionAnnuler = mEdit->addAction("Annuler"); QAction* mactionRefaire = mEdit->addAction("Refaire"); QAction* mactionSupprimer = mEdit->addAction("Supprimer"); QMenu* mTag = mEdit->addMenu("Tags"); QAction* mactionSupprimerTag = mTag->addAction("Supprimer"); QMenu* mDocument = mEdit->addMenu("Documents"); QAction* mactionUp = mDocument->addAction("Monter"); QAction* mactionDown = mDocument->addAction("Descendre"); QMenu* mExport = mEdit->addMenu("Exporter"); QAction* mactionOuvrir = mFile->addAction("Ouvrir un espace de travail"); QAction* mactionNew = mFile->addAction("Nouvel espace de travail"); QAction* mactionSaveAs = mFile->addAction("Enregistrer sous..."); QAction* mactionNewArticle = mNouveau->addAction("Article"); QAction* mactionNewImage = mNouveau->addAction("Image"); QAction* mactionNewAudio = mNouveau->addAction("Audio"); QAction* mactionNewVideo = mNouveau->addAction("Video"); QAction* mactionNewDocument = mNouveau->addAction("Document"); QAction* mactionExportHTML = mExport->addAction("Html"); QAction* mactionExportTex = mExport->addAction("Tex"); QAction* mactionExportTexte = mExport->addAction("Texte"); QAction* mactionOption=mEdit->addAction("Setting"); QAction* mactionAddTag = mNouveau->addAction("Tag"); QAction* mactionSave = mFile->addAction("Sauvegarder"); mFile->addSeparator(); QMenu* ouvrirCorbeille = mFile->addMenu("Corbeille"); QAction* mactionRestaurer = ouvrirCorbeille->addAction("Restaurer"); QAction* mactionVider = ouvrirCorbeille->addAction("Vider la Corbeille"); mactionViewEdit = mView->addAction("Onglet Editeur"); mactionViewHTML = mView->addAction("Onglet Html"); mactionViewTex = mView->addAction("Onglet Tex"); mactionViewTexte = mView->addAction("Onglet Texte"); mFile->addSeparator(); QAction* actionQuitter = mFile->addAction("&Quitter"); actionQuitter->setIcon(QIcon("icon/quitter.png")); mactionNewArticle->setIcon(QIcon("icon/article.png")); mactionNewImage->setIcon(QIcon("icon/image.png")); mactionNewAudio->setIcon(QIcon("icon/audio.png")); mactionNewVideo->setIcon(QIcon("icon/video.png")); mNouveau->setIcon(QIcon("icon/plus.png")); mactionDown->setIcon(QIcon("icon/down.png")); mactionUp->setIcon(QIcon("icon/up.png")); mactionAddTag->setIcon(QIcon("icon/tag.png")); mactionSave->setIcon(QIcon("icon/save.png")); mactionExportHTML->setIcon(QIcon("icon/html.png")); mactionExportTex->setIcon(QIcon("icon/tex.png")); mactionExportTexte->setIcon(QIcon("icon/texte.png")); mactionAnnuler->setIcon(QIcon("icon/undo.png")); mactionRefaire->setIcon(QIcon("icon/redo.png")); mactionSupprimer->setIcon(QIcon("icon/cross.png")); mactionRestaurer->setIcon(QIcon("icon/corbeille.png")); mactionNewDocument->setIcon(QIcon("icon/document.png")); mactionOption->setIcon(QIcon("icon/setting.png")); mactionOuvrir->setShortcut(QKeySequence("Ctrl+O")); actionQuitter->setShortcut(QKeySequence("Ctrl+Q")); mactionSave->setShortcut(QKeySequence("Ctrl+S")); mactionAnnuler->setShortcut(QKeySequence("Ctrl+Z")); mactionRefaire->setShortcut(QKeySequence("Ctrl+Y")); mactionSupprimer->setShortcut(tr("Delete")); //** VIEW **// mactionViewEdit->setCheckable(true); mactionViewEdit->setChecked(true); mactionViewHTML->setCheckable(true); mactionViewTex->setCheckable(true); mactionViewTexte->setCheckable(true); //Bar de statue QStatusBar* statusBar = new QStatusBar; statusBar->addWidget(new QLabel("Projet Lo21 - Pauline Crouillère / Emilien Notarianni")); this->setStatusBar(statusBar); // Création de la barre d'outils QToolBar *toolBarFichier = addToolBar("Fichier"); toolBarFichier->addAction(mactionNewArticle); toolBarFichier->addAction(mactionNewImage); toolBarFichier->addAction(mactionNewAudio); toolBarFichier->addAction(mactionNewVideo); toolBarFichier->addAction(mactionNewDocument); toolBarFichier->addSeparator(); toolBarFichier->addAction(mactionAddTag); toolBarFichier->addSeparator(); toolBarFichier->addAction(mactionUp); toolBarFichier->addAction(mactionDown); toolBarFichier->addSeparator(); toolBarFichier->addAction(mactionExportHTML); toolBarFichier->addAction(mactionExportTex); toolBarFichier->addAction(mactionExportTexte); toolBarFichier->addSeparator(); toolBarFichier->addAction(mactionRestaurer); toolBarFichier->addSeparator(); toolBarFichier->addAction(mactionSupprimer); toolBarFichier->addSeparator(); toolBarFichier->addAction(actionQuitter); /*************************************************************/ couche = new QHBoxLayout(); lw = new LeftWindows(); ow = new OngletWindows(); couche->addWidget(lw); couche->addWidget(ow); couche->setMargin(0); couche->setAlignment(Qt::AlignTop); centerWindows = new QWidget(); centerWindows->setLayout(couche); setCentralWidget(centerWindows); //************************** CONNECT **************************/ QObject::connect(mactionNewArticle, SIGNAL(triggered()), this, SLOT(newArticle())); QObject::connect(mactionNewDocument, SIGNAL(triggered()), this, SLOT(newDocument())); QObject::connect(mactionNewImage, SIGNAL(triggered()), this, SLOT(newImage())); QObject::connect(mactionNewAudio, SIGNAL(triggered()), this, SLOT(newAudio())); QObject::connect(mactionNewVideo, SIGNAL(triggered()), this, SLOT(newVideo())); QObject::connect(mactionAddTag, SIGNAL(triggered()), this, SLOT(newTag())); QObject::connect(mactionOuvrir,SIGNAL(triggered()),this, SLOT(ouvrirDialogue())); QObject::connect(actionQuitter,SIGNAL(triggered()),qApp, SLOT(quit())); QObject::connect(mactionUp,SIGNAL(triggered()),this, SLOT(docUp())); QObject::connect(mactionDown,SIGNAL(triggered()),this, SLOT(docDown())); QObject::connect(mactionRestaurer, SIGNAL(triggered()), this, SLOT(ouvrirCorbeille())); QObject::connect(mactionSave, SIGNAL(triggered()), this, SLOT(asave())); QObject::connect(mactionExportHTML, SIGNAL(triggered()), this, SLOT(exportHTML())); QObject::connect(mactionExportTex, SIGNAL(triggered()), this, SLOT(exportTex())); QObject::connect(mactionExportTexte, SIGNAL(triggered()), this, SLOT(exportTexte())); QObject::connect(mactionSupprimer, SIGNAL(triggered()), this, SLOT(deleteInCorbeille())); QObject::connect(mactionVider, SIGNAL(triggered()), this, SLOT(viderLaCorbeille())); //TODO QObject::connect(mactionAnnuler, SIGNAL(triggered()), qApp, SLOT(undo())); QObject::connect(mactionRefaire, SIGNAL(triggered()), qApp, SLOT(redo())); // QObject::connect(mactionSaveAs, SIGNAL(triggered()), this, SLOT(copieWorkSpace())); QObject::connect(mactionNew, SIGNAL(triggered()), this, SLOT(newWorkSpace())); QObject::connect(mactionOption, SIGNAL(triggered()), this, SLOT(setting())); QObject::connect(mactionViewEdit, SIGNAL(triggered()), this, SLOT(changeEdit())); QObject::connect(mactionViewHTML, SIGNAL(triggered()), this, SLOT(changeHtml())); QObject::connect(mactionViewTex,SIGNAL(triggered()),this, SLOT(changeTex())); QObject::connect(mactionViewTexte,SIGNAL(triggered()),this, SLOT(changeTexte())); QObject::connect(ow, SIGNAL(currentChanged(int)), this, SLOT(changeOnglet(int))); QObject::connect(mactionSupprimerTag, SIGNAL(triggered()), this, SLOT(supprimeTag())); }
FITSViewer::FITSViewer (QWidget *parent) : KXmlGuiWindow (parent) { #ifdef Q_OS_OSX if(Options::independentWindowFITS()) setWindowFlags(Qt::Window); else{ setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(changeAlwaysOnTop(Qt::ApplicationState))); } #endif fitsTab = new QTabWidget(this); undoGroup = new QUndoGroup(this); fitsID = 0; debayerDialog= NULL; markStars = false; lastURL = QUrl(QDir::homePath()); fitsTab->setTabsClosable(true); setWindowIcon(QIcon::fromTheme("kstars_fitsviewer", QIcon(":/icons/breeze/default/kstars_fitsviewer.svg"))); setCentralWidget(fitsTab); connect(fitsTab, SIGNAL(currentChanged(int)), this, SLOT(tabFocusUpdated(int))); connect(fitsTab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); //These two connections will enable or disable the scope button if a scope is available or not. //Of course this is also dependent on the presence of WCS data in the image. #ifdef HAVE_INDI connect(INDIListener::Instance(), SIGNAL(newTelescope(ISD::GDInterface *)), this, SLOT(updateWCSFunctions())); connect(INDIListener::Instance(), SIGNAL(deviceRemoved(ISD::GDInterface *)), this, SLOT(updateWCSFunctions())); #endif led.setColor(Qt::green); fitsPosition.setAlignment(Qt::AlignCenter); fitsValue.setAlignment(Qt::AlignCenter); //fitsPosition.setFixedWidth(100); //fitsValue.setFixedWidth(100); fitsWCS.setVisible(false); statusBar()->insertPermanentWidget(FITS_WCS, &fitsWCS); statusBar()->insertPermanentWidget(FITS_VALUE, &fitsValue); statusBar()->insertPermanentWidget(FITS_POSITION, &fitsPosition); statusBar()->insertPermanentWidget(FITS_ZOOM, &fitsZoom); statusBar()->insertPermanentWidget(FITS_RESOLUTION, &fitsResolution); statusBar()->insertPermanentWidget(FITS_LED, &led); QAction *action; action = actionCollection()->addAction("rotate_right", this, SLOT(rotateCW())); action->setText(i18n("Rotate Right")); action->setIcon(QIcon::fromTheme("object-rotate-right", QIcon(":/icons/breeze/default/object-rotate-right.svg"))); action = actionCollection()->addAction("rotate_left", this, SLOT(rotateCCW())); action->setText(i18n("Rotate Left")); action->setIcon(QIcon::fromTheme("object-rotate-left", QIcon(":/icons/breeze/default/object-rotate-left.svg"))); action = actionCollection()->addAction("flip_horizontal", this, SLOT(flipHorizontal())); action->setText(i18n("Flip Horizontal")); action->setIcon(QIcon::fromTheme("object-flip-horizontal", QIcon(":/icons/breeze/default/object-flip-horizontal.svg"))); action = actionCollection()->addAction("flip_vertical", this, SLOT(flipVertical())); action->setText(i18n("Flip Vertical")); action->setIcon(QIcon::fromTheme("object-flip-vertical", QIcon(":/icons/breeze/default/object-flip-vertical.svg"))); action = actionCollection()->addAction("image_histogram"); action->setText(i18n("Histogram")); connect(action, SIGNAL(triggered(bool)), SLOT (histoFITS())); actionCollection()->setDefaultShortcut(action, QKeySequence::Replace); action->setIcon(QIcon(":/icons/histogram.png")); action = KStandardAction::open(this, SLOT(openFile()), actionCollection()); action->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/breeze/default/document-open.svg"))); saveFileAction = KStandardAction::save(this, SLOT(saveFile()), actionCollection()); saveFileAction->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/breeze/default/document-save.svg"))); action=saveFileAsAction = KStandardAction::saveAs(this, SLOT(saveFileAs()), actionCollection()); saveFileAsAction->setIcon(QIcon::fromTheme("document-save_as", QIcon(":/icons/breeze/default/document-save-as.svg"))); action = actionCollection()->addAction("fits_header"); actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_H)); action->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/breeze/default/document-properties.svg"))); action->setText(i18n( "FITS Header")); connect(action, SIGNAL(triggered(bool) ), SLOT(headerFITS())); action = actionCollection()->addAction("fits_debayer"); actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_D)); action->setIcon(QIcon::fromTheme("view-preview", QIcon(":/icons/breeze/default/view-preview.svg"))); action->setText(i18n( "Debayer...")); connect(action, SIGNAL(triggered(bool) ), SLOT(debayerFITS())); action = actionCollection()->addAction("image_stretch"); action->setText(i18n("Auto stretch")); connect(action, SIGNAL(triggered(bool)), SLOT (stretchFITS())); actionCollection()->setDefaultShortcut(action, QKeySequence::SelectAll); action->setIcon(QIcon::fromTheme("transform-move", QIcon(":/icons/breeze/default/transform-move.svg"))); action = KStandardAction::close(this, SLOT(close()), actionCollection()); action->setIcon(QIcon::fromTheme("window-close", QIcon(":/icons/breeze/default/window-close.svg"))); action = KStandardAction::copy(this, SLOT(copyFITS()), actionCollection()); action->setIcon(QIcon::fromTheme("edit-copy", QIcon(":/icons/breeze/default/edit-copy.svg"))); action=KStandardAction::zoomIn(this, SLOT(ZoomIn()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/icons/breeze/default/zoom-in.svg"))); action=KStandardAction::zoomOut(this, SLOT(ZoomOut()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/icons/breeze/default/zoom-out.svg"))); action=KStandardAction::actualSize(this, SLOT(ZoomDefault()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-fit-best", QIcon(":/icons/breeze/default/zoom-fit-best.svg"))); QAction *kundo = KStandardAction::undo(undoGroup, SLOT(undo()), actionCollection()); kundo->setIcon(QIcon::fromTheme("edit-undo", QIcon(":/icons/breeze/default/edit-undo.svg"))); QAction *kredo = KStandardAction::redo(undoGroup, SLOT(redo()), actionCollection()); kredo->setIcon(QIcon::fromTheme("edit-redo", QIcon(":/icons/breeze/default/edit-redo.svg"))); connect(undoGroup, SIGNAL(canUndoChanged(bool)), kundo, SLOT(setEnabled(bool))); connect(undoGroup, SIGNAL(canRedoChanged(bool)), kredo, SLOT(setEnabled(bool))); action = actionCollection()->addAction("image_stats"); action->setIcon(QIcon::fromTheme("view-statistics", QIcon(":/icons/breeze/default/view-statistics.svg"))); action->setText(i18n( "Statistics")); connect(action, SIGNAL(triggered(bool)), SLOT(statFITS())); action = actionCollection()->addAction("view_crosshair"); action->setIcon(QIcon::fromTheme("crosshairs", QIcon(":/icons/breeze/default/crosshairs.svg"))); action->setText(i18n( "Show Cross Hairs")); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleCrossHair())); action = actionCollection()->addAction("view_pixel_grid"); action->setIcon(QIcon::fromTheme("map-flat", QIcon(":/icons/breeze/default/map-flat.svg"))); action->setText(i18n( "Show Pixel Gridlines")); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(togglePixelGrid())); action = actionCollection()->addAction("view_eq_grid"); action->setIcon(QIcon::fromTheme("kstars_grid", QIcon(":/icons/breeze/default/kstars_grid.svg"))); action->setText(i18n( "Show Equatorial Gridlines")); action->setCheckable(true); action->setDisabled(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleEQGrid())); action = actionCollection()->addAction("view_objects"); action->setIcon(QIcon::fromTheme("help-hint", QIcon(":/icons/breeze/default/help-hint.svg"))); action->setText(i18n( "Show Objects in Image")); action->setCheckable(true); action->setDisabled(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleObjects())); action = actionCollection()->addAction("center_telescope"); action->setIcon(QIcon(":/icons/center_telescope.svg")); action->setText(i18n( "Center Telescope\n*No Telescopes Detected*")); action->setDisabled(true); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(centerTelescope())); action = actionCollection()->addAction("view_zoom_fit"); action->setIcon(QIcon::fromTheme("zoom-fit-width", QIcon(":/icons/breeze/default/zoom-fit-width.svg"))); action->setText(i18n( "Zoom To Fit")); connect(action, SIGNAL(triggered(bool)), SLOT(ZoomToFit())); action = actionCollection()->addAction("mark_stars"); action->setText(i18n( "Mark Stars")); connect(action, SIGNAL(triggered(bool)), SLOT(toggleStars())); QSignalMapper *filterMapper = new QSignalMapper(this); int filterCounter=1; foreach(QString filter, FITSViewer::filterTypes) { action = actionCollection()->addAction(QString("filter%1").arg(filterCounter)); action->setText(i18n(filter.toUtf8().constData())); filterMapper->setMapping(action, filterCounter++); connect(action, SIGNAL(triggered()), filterMapper, SLOT(map())); }
int main(int argc, char **argv) { struct level2_data *data; vmwSVMWGraphState *graph_state; vmwVisual *virtual_1; int ch,i,j,y_offset=0; int x=0,y=0; char tempst[10]; int sprite_array[16]; int sprite_offset=0; int doublesize=1,fullscreen=0; int argsfound=0; char filename[255],spritefile[255]; /* Parse command line arguments */ i=1; while(i<argc) { if (argv[i][0]=='-') { if (argv[i][1]=='d') doublesize=2; if (argv[i][1]=='f') fullscreen=1; } else { argsfound++; if (argsfound==1) strncpy(filename,argv[i],254); if (argsfound==2) strncpy(spritefile,argv[i],254); } i++; } if (argsfound<2) { printf("\nUSAGE: %s [-f] [-d] data_file sprite_file\n\n",argv[0]); return -1; } printf("Editing datafile=%s spritefile=%s\n",filename,spritefile); data=parse_data_file(filename); graph_state=vmwSetupSVMWGraph(VMW_SDLTARGET,doublesize*320,doublesize*200,0,doublesize,fullscreen,1); graph_state->default_font=vmwLoadFont("../data/tbfont.tb1",8,16,256); virtual_1=vmwSetupVisual(320,200); if (vmwLoadPicPacked(0,0,virtual_1,1,1,spritefile,graph_state)!=0) { printf("ERROR LOADING %s\n",spritefile); return -1; } for(j=0;j<data->rows;j++) for(i=0;i<data->cols;i++) data->sprites[j*10+i]->data=vmwGetSprite(1+i*21,1+j*11,20,10,virtual_1); vmwDrawBox(0,0,319,199,0,virtual_1); draw_all_sprites(0,data,virtual_1); vmwBlitMemToDisplay(graph_state,virtual_1); ch=' '; while(1) { switch(ch) { case 'A'...'P' : if (sprite_array[ch-0x41]!=-1) modify_level(data,x,y+y_offset,CHANGE_SPRITE, sprite_array[ch-0x41]); break; case 'a'...'p' : if (sprite_array[ch-0x61]!=-1) modify_level(data,x,y+y_offset,CHANGE_SPRITE, sprite_array[ch-0x61]); break; case 's': case 'S': save_data(filename,data); modified_since_save=0; break; case 'u': case 'U': undo(data); break; case 'q': case 'Q': if (modified_since_save) { if (vmwAreYouSure(graph_state, graph_state->default_font, virtual_1, "FILE HAS CHANGED", "QUIT W/O SAVING?", "YES-QUIT ANYWAY", "NO!-LET ME SAVE")) return 0; } else return 0; break; case '>': case '.': i=0; j=sprite_offset; while ( (i<16) && (j<data->numsprites)) { if ((data->sprites[j]->initialized) && (belongs_on_map(data->sprites[j]->type))) { i++; } j++; } if (j<data->numsprites) sprite_offset=j; break; case '<': case ',': i=0; j=sprite_offset; while ( (i<16) && (j>0)) { if ((data->sprites[j]->initialized) && (belongs_on_map(data->sprites[j]->type))) { i++; } j--; } if (j>=0) sprite_offset=j; break; case VMW_UP: if (y>0) y--; else if (y_offset>0) y_offset--; break; case VMW_DOWN: if (y>=19) { if (y_offset<data->level_length-21) y_offset++; } else y++; break; case VMW_RIGHT: if (x<11) x++; break; case VMW_LEFT: if (x>0) x--; break; case VMW_PGUP: if (y_offset>20) y_offset-=20; else (y_offset=0); break; case VMW_PGDN: if (y_offset<data->level_length-41) y_offset+=20; else y_offset=data->level_length-20; break; case VMW_HOME: y_offset=0; break; case VMW_END: y_offset=data->level_length-20; break; case VMW_INS: modify_level(data,0,y+y_offset,INSERT_LINE,0); break; case VMW_DEL: modify_level(data,0,y+y_offset,DELETE_LINE,0); break; } /* Make sure if we delete a line it doesn't make us */ /* try to display off the end of the screen */ if (y_offset>=data->level_length-20) y_offset=data->level_length-20; draw_all_sprites(y_offset,data,virtual_1); /* Draw cursor box */ vmwDrawHLine(x*20,y*10,20,15,virtual_1); vmwDrawHLine(x*20,(y*10)+9,20,15,virtual_1); vmwDrawVLine(x*20,y*10,10,15,virtual_1); vmwDrawVLine((x*20)+19,y*10,10,15,virtual_1); vmwDrawBox(240,0,79,199,0,virtual_1); sprintf(tempst,"X: %4d",x); vmwTextXY(tempst,245,5,9,0,0,graph_state->default_font,virtual_1); sprintf(tempst,"Y: %4d",y+y_offset); vmwTextXY(tempst,245,15,9,0,0,graph_state->default_font,virtual_1); sprintf(tempst,"L: %4d",data->level_length); vmwTextXY(tempst,245,25,9,0,0,graph_state->default_font,virtual_1); vmwDrawHLine(243,38,74,12,virtual_1); vmwDrawHLine(243,150,74,12,virtual_1); sprintf(tempst,"%c",'<'); vmwTextXY(tempst,275,40,11,0,0,graph_state->default_font,virtual_1); sprintf(tempst,"%c",'>'); vmwTextXY(tempst,275,140,11,0,0,graph_state->default_font,virtual_1); if (sprite_offset>=data->numsprites) sprite_offset=0; if (sprite_offset<0) sprite_offset=0; j=sprite_offset; for(i=0;i<16;i++) { sprintf(tempst,"%c",0x41+i); while ((j<data->numsprites) && ((!data->sprites[j]->initialized) || (!belongs_on_map(data->sprites[j]->type)))) { j++; } if (j<data->numsprites) { sprite_array[i]=j; vmwTextXY(tempst,((i/8)*61)+245,((i%8)*11)+50,11,0,0,graph_state->default_font,virtual_1); vmwPutSpriteNonTransparent(data->sprites[j]->data, ((i/8)*21)+260, ((i%8)*11)+50,virtual_1); j++; } else sprite_array[i]=-1; } vmwTextXY("INS DEL",245,155,11,0,0,graph_state->default_font,virtual_1); vmwTextXY(" , ",245,155,9,0,0,graph_state->default_font,virtual_1); vmwTextXY(" ndo",245,165,9,0,0,graph_state->default_font,virtual_1); vmwTextXY("U",245,165,11,0,0,graph_state->default_font,virtual_1); vmwTextXY(" ave",245,175,9,0,0,graph_state->default_font,virtual_1); vmwTextXY("S",245,175,11,0,0,graph_state->default_font,virtual_1); if (modified_since_save) vmwTextXY(" *",245,175,12,0,0,graph_state->default_font,virtual_1); vmwTextXY(" uit",245,185,9,0,0,graph_state->default_font,virtual_1); vmwTextXY("Q",245,185,11,0,0,graph_state->default_font,virtual_1); vmwBlitMemToDisplay(graph_state,virtual_1); while( ((ch=vmwGetInput())==0)) { usleep(30); } } return 0; }
editor_action* editor_action_unit::perform(map_context& mc) const { std::unique_ptr<editor_action> undo(new editor_action_unit_delete(loc_)); perform_without_undo(mc); return undo.release(); }
void ExecutionEnv::workingCanceled( const int /*resp*/) { cancel(); undo(); return; }
void PlayField::keyPressEvent(QKeyEvent * e) { int x=levelMap_->xpos(); int y=levelMap_->ypos(); switch (e->key()) { case Qt::Key_Up: if (e->state() & Qt::ControlModifier) step(x, 0); else if (e->state() & Qt::ShiftModifier) push(x, 0); else push(x, y-1); break; case Qt::Key_Down: if (e->state() & Qt::ControlModifier) step(x, MAX_Y); else if (e->state() & Qt::ShiftModifier) push(x, MAX_Y); else push(x, y+1); break; case Qt::Key_Left: if (e->state() & Qt::ControlModifier) step(0, y); else if (e->state() & Qt::ShiftModifier) push(0, y); else push(x-1, y); break; case Qt::Key_Right: if (e->state() & Qt::ControlModifier) step(MAX_X, y); else if (e->state() & Qt::ShiftModifier) push(MAX_X, y); else push(x+1, y); break; case Qt::Key_Q: KApplication::kApplication()->closeAllWindows(); break; case Qt::Key_Backspace: case Qt::Key_Delete: if (e->state() & Qt::ControlModifier) redo(); else undo(); break; #if 0 case Qt::Key_X: levelMap_->random(); levelChange(); repaint(false); break; case Qt::Key_R: level(levelMap_->level()); return; break; case Qt::Key_N: nextLevel(); return; break; case Qt::Key_P: previousLevel(); return; break; case Qt::Key_U: undo(); return; break; case Qt::Key_I: history_->redo(levelMap_); repaint(false); return; break; case Qt::Key_S: { QString buf; history_->save(buf); printf("%s\n", (char *) buf); } return; break; case Qt::Key_L: stopMoving(); history_->clear(); level(levelMap_->level()); { char buf[4096]="r1*D1*D1*r1*@r1*D1*"; //scanf("%s", buf); history_->load(levelMap_, buf); } updateStepsXpm(); updatePushesXpm(); repaint(false); return; break; #endif case Qt::Key_Print: HtmlPrinter::printHtml(levelMap_); break; default: e->ignore(); return; break; } }
/** Constructor */ CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags) : mBlogId(cId), QMainWindow (parent, flags) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); setAttribute ( Qt::WA_DeleteOnClose, true ); setupFileActions(); setupEditActions(); setupViewActions(); setupInsertActions(); setupParagraphActions(); setAcceptDrops(true); setStartupText(); newBlogMsg(); ui.toolBar_2->addAction(ui.actionIncreasefontsize); ui.toolBar_2->addAction(ui.actionDecreasefontsize); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionOrderedlist); ui.toolBar_2->addAction(ui.actionUnorderedlist); ui.toolBar_2->addAction(ui.actionBlockquoute); ui.toolBar_2->addAction(ui.actionCode); ui.toolBar_2->addAction(ui.actionsplitPost); setupTextActions(); connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg())); connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew())); connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease())); connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease())); connect(ui.actionBlockquoute, SIGNAL (triggered()), this, SLOT (blockQuote())); connect(ui.actionCode, SIGNAL (triggered()), this, SLOT (toggleCode())); connect(ui.actionsplitPost, SIGNAL (triggered()), this, SLOT (addPostSplitter())); connect(ui.actionOrderedlist, SIGNAL (triggered()), this, SLOT (addOrderedList())); connect(ui.actionUnorderedlist, SIGNAL (triggered()), this, SLOT (addUnorderedList())); //connect(webView, SIGNAL(loadFinished(bool)),this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL( textChanged(const QString &)), this, SLOT(updateTextEdit())); connect( ui.msgEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect( ui.msgEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); QPalette palette = QApplication::palette(); codeBackground = palette.color( QPalette::Active, QPalette::Midlight ); fontChanged(ui.msgEdit->font()); colorChanged(ui.msgEdit->textColor()); alignmentChanged(ui.msgEdit->alignment()); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)), ui.actionUndo, SLOT(setEnabled(bool))); connect( ui.msgEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified( ui.msgEdit->document()->isModified()); actionSave->setEnabled( ui.msgEdit->document()->isModified()); actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); ui.actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable()); actionRedo->setEnabled( ui.msgEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(ui.actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), ui.msgEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), ui.msgEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), ui.msgEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), ui.msgEdit, SLOT(paste())); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif //defaultCharFormat defaultCharFormat = ui.msgEdit->currentCharFormat(); const QFont defaultFont = ui.msgEdit->document()->defaultFont(); defaultCharFormat.setFont( defaultFont ); defaultCharFormat.setForeground( ui.msgEdit->currentCharFormat().foreground() ); defaultCharFormat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) ); defaultCharFormat.setBackground( palette.color( QPalette::Active, QPalette::Base ) ); defaultCharFormat.setProperty( TextFormat::HasCodeStyle, QVariant( false ) ); //defaultBlockFormat defaultBlockFormat = ui.msgEdit->textCursor().blockFormat(); }
PluginCreator::PluginCreator(QWidget* parent) : QMainWindow(parent) { state = S_INIT; item = 0; view = 0; dock = 0; manualDock = 0; helpBrowser = 0; setupUi(this); QToolBar* fileTools = addToolBar(tr("File Operations")); fileTools->setObjectName("FileOperations"); actionNew->setIcon(*icons[fileNew_ICON]); actionNew->setShortcut(QKeySequence(QKeySequence::New)); fileTools->addAction(actionNew); actionOpen->setIcon(*icons[fileOpen_ICON]); actionOpen->setShortcut(QKeySequence(QKeySequence::Open)); fileTools->addAction(actionOpen); actionSave->setIcon(*icons[fileSave_ICON]); actionSave->setShortcut(QKeySequence(QKeySequence::Save)); fileTools->addAction(actionSave); actionQuit->setShortcut(QKeySequence(QKeySequence::Quit)); actionManual->setIcon(QIcon(":/data/help.png")); actionManual->setShortcut(QKeySequence(QKeySequence::HelpContents)); fileTools->addAction(actionManual); QToolBar* editTools = addToolBar(tr("Edit Operations")); editTools->setObjectName("EditOperations"); actionUndo->setIcon(*icons[undo_ICON]); actionUndo->setShortcut(QKeySequence(QKeySequence::Undo)); editTools->addAction(actionUndo); actionRedo->setIcon(*icons[redo_ICON]); actionRedo->setShortcut(QKeySequence(QKeySequence::Redo)); editTools->addAction(actionRedo); actionUndo->setEnabled(false); actionRedo->setEnabled(false); log->setReadOnly(true); log->setMaximumBlockCount(1000); readSettings(); setState(S_EMPTY); connect(run, SIGNAL(clicked()), SLOT(runClicked())); connect(stop, SIGNAL(clicked()), SLOT(stopClicked())); connect(actionOpen, SIGNAL(triggered()), SLOT(loadPlugin())); connect(actionSave, SIGNAL(triggered()), SLOT(savePlugin())); connect(actionNew, SIGNAL(triggered()), SLOT(newPlugin())); connect(actionQuit, SIGNAL(triggered()), SLOT(close())); connect(actionManual, SIGNAL(triggered()), SLOT(showManual())); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); connect(textEdit, SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(textChanged()), SLOT(textChanged())); }
void maskImageWidget::init(const QImage& image) { setWindowTitle(tr("Mask Editor")); QPixmap load("coral_open32x32.png"); QPixmap save("coral_save32x32.png"); QPixmap undo("coral_undo32x32.png"); QPixmap redo("coral_redo32x32.png"); QPixmap pen("coral_pencil32x32.png"); QPixmap eraser("coral_eraser32x32.png"); QAction *canvasloadmask = new QAction(this); canvasloadmask->setIcon(load); canvasloadmask->setText(tr("&Load Mask")); QAction *canvassavemask = new QAction(this); canvassavemask->setIcon(QIcon(save)); canvassavemask->setText(tr("&Save Mask")); QAction *canvasundo = new QAction(this); canvasundo->setIcon(QIcon(undo)); canvasundo->setText(tr("&Undo")); canvasundo->setShortcut(QKeySequence("Ctrl+Z")); QAction *canvasredo = new QAction(this); canvasredo->setIcon(QIcon(redo)); canvasredo->setText(tr("&Redo")); canvasredo->setShortcut(QKeySequence("Ctrl+Shift+Z")); QAction *canvasclear = new QAction(tr("&Clear"), this); canvasclear->setShortcut(QKeySequence("Ctrl+C")); QAction *canvaspen = new QAction(this); canvaspen->setIcon(QIcon(pen)); canvaspen->setText(tr("&Pen")); QAction *canvaseraser = new QAction(this); canvaseraser->setIcon(QIcon(eraser)); canvaseraser->setText(tr("&Eraser")); QActionGroup *actions(new QActionGroup(this)); actions->addAction(canvaspen); actions->addAction(canvaseraser); canvaspen->setCheckable(true); canvaseraser->setCheckable(true); canvaspen->setChecked(true); actions->setExclusive(true); QAction *canvasOK = new QAction(this); canvasOK->setText("OK"); QAction *canvasCancel = new QAction(this); canvasCancel->setText("Cancel"); QBoxLayout *layout(new QVBoxLayout(this)); // We don't want a real-size image. We will downscale it! QImage image_to_use = image; pimpl_->realwidth_ = image.width(); pimpl_->realheight_ = image.height(); qDebug("maskImageWidget::Init real wxh %i x%i",pimpl_->realwidth_,pimpl_->realheight_); QDesktopWidget *desktop(QApplication::desktop()); if (image.width() > (desktop->width() * .8) || image.height() > (desktop->height() * .8)) { int width(desktop->width()), height(desktop->height()); image_to_use = image.scaled((int)std::floor(width * .75), (int)std::floor(height * .75), Qt::KeepAspectRatio); } pimpl_->render_area_ = new maskRenderWidget(image_to_use, this); QToolBar *canvas_toolbar(new QToolBar(this)); canvas_toolbar->addSeparator(); canvas_toolbar->addAction(canvasloadmask); canvas_toolbar->addAction(canvassavemask); canvas_toolbar->addSeparator(); canvas_toolbar->addAction(canvasundo); canvas_toolbar->addAction(canvasredo); canvas_toolbar->addSeparator(); QSpinBox *pen_width(new QSpinBox(canvas_toolbar)); pen_width->setToolTip(tr("Pen Width")); pen_width->setRange(0, 80); pen_width->setSingleStep(2); pen_width->setValue(16); connect(pen_width, SIGNAL(valueChanged(int)), SLOT(setCanvasPenWidth(int))); canvas_toolbar->addWidget(pen_width); canvas_toolbar->addAction(canvaspen); canvas_toolbar->addAction(canvaseraser); canvas_toolbar->addSeparator(); QSpinBox *gradient(new QSpinBox(canvas_toolbar)); gradient->setToolTip("Gradient Threshold"); gradient->setRange(0, 255); gradient->setValue(pimpl_->threshold_gradient_); connect(gradient, SIGNAL(valueChanged(int)), SLOT(setGradientThreshold(int))); QSpinBox *fixed(new QSpinBox(canvas_toolbar)); fixed->setToolTip("Fixed Threshold"); fixed->setRange(0, 255); fixed->setValue(pimpl_->threshold_fixed_); connect(fixed, SIGNAL(valueChanged(int)), SLOT(setFixedThreshold(int))); canvas_toolbar->addWidget(gradient); canvas_toolbar->addWidget(fixed); canvas_toolbar->addSeparator(); canvas_toolbar->addAction(canvasOK); canvas_toolbar->addAction(canvasCancel); layout->addWidget(canvas_toolbar); layout->addWidget(pimpl_->render_area_); layout->setSizeConstraint(QLayout::SetFixedSize); connect(canvasloadmask, SIGNAL(activated()), SLOT(loadMask())); connect(canvassavemask, SIGNAL(activated()), SLOT(saveMask())); connect(canvasundo, SIGNAL(activated()), pimpl_->render_area_, SLOT(undo())); connect(canvasredo, SIGNAL(activated()), pimpl_->render_area_, SLOT(redo())); connect(canvasclear, SIGNAL(activated()), pimpl_->render_area_, SLOT(clear())); connect(canvaspen, SIGNAL(activated()), SLOT(setCanvasPen())); connect(canvaseraser, SIGNAL(activated()), SLOT(setCanvasEraser())); connect(pimpl_->render_area_, SIGNAL(pointSelected(const QPoint &)), SLOT(automaticMask(const QPoint &))); connect(canvasOK, SIGNAL(activated()), SLOT(accept())); connect(canvasCancel, SIGNAL(activated()), SLOT(reject())); }
void PaintMainWindow::CreateMenuBar() { //Create File Menu //File Menu Begin QPopupMenu* file = new QPopupMenu(this); //Create Image Section file->insertItem("&New image", this, SLOT(OnNewImage()), CTRL+Key_N); file->insertItem("&Load image", this, SLOT(OnLoadImage()), CTRL+Key_O); file->insertItem("&Save image", this, SLOT(OnSaveImage()), CTRL+Key_S); file->insertSeparator(); //Create Color Section file->insertItem("&Foreground color", this, SLOT(ChangeFGColor())); file->insertItem("&Background color", this, SLOT(ChangeBGColor())); file->insertSeparator(); //Create Exit Section file->insertItem("&Exit", this, SLOT(OnExit()), CTRL+Key_X); //Insert File Menu menuBar()->insertItem("&File", file); //File Menu End //Create Edit Menu //Edit Menu Begin QPopupMenu* edit = new QPopupMenu(this); //Create Edit items edit->insertItem("&Undo", canvas, SLOT(undo()), CTRL+Key_Z); edit->insertItem("&Redo", canvas, SLOT(redo()), CTRL+Key_Y); edit->insertItem("&Clear All", canvas, SLOT(clearAll())); edit->insertItem("Re&size", this, SLOT(OnResizeImage()), CTRL+Key_R); //Insert Edit Menu menuBar()->insertItem("&Edit", edit); //Edit Menu End //Create View Menu //View Menu Begin QPopupMenu* view = new QPopupMenu(this); //Create ToolBar toggler QAction *ToolBar_t = new QAction("&Tool Bar", 0, this); QObject::connect(ToolBar_t, SIGNAL(activated()), this, SLOT(ToggleToolBar())); //Set ToolBar toggler to be checkable ToolBar_t->setToggleAction(true); ToolBar_t->setOn(true); ToolBar_t->addTo(view); //Connect ToolBar state to ToolBar toggler QObject::connect(tools, SIGNAL(visibilityChanged(bool)), ToolBar_t, SLOT(toggle())); //Insert View Menu menuBar()->insertItem("&View", view); //View Menu End //Create Help Menu //Help Menu Begin QPopupMenu* help = new QPopupMenu(this); //Create Help items help->insertItem("&About", this, SLOT(ShowAbout())); //Insert Help Menu menuBar()->insertItem("&Help", help); //Help Menu End }
SimpleRichTextEdit::SimpleRichTextEdit(QWidget *parent) : KTextEdit(parent) { enableFindReplace(false); setCheckSpellingEnabled(true); setAutoFormatting(KTextEdit::AutoNone); setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); QTextDocument *textDocument = document(); QTextOption textOption; textOption.setAlignment(Qt::AlignCenter); textOption.setWrapMode(QTextOption::NoWrap); textDocument->setDefaultTextOption(textOption); QFont defaultFont = font(); defaultFont.setPointSize(defaultFont.pointSize() + 2); textDocument->setDefaultFont(defaultFont); QString styleSheet("p {" " display: block;" " white-space: pre;" " margin-top: 0px;" " margin-bottom: 0px;" "}"); textDocument->setDefaultStyleSheet(styleSheet); setTextInteractionFlags(Qt::TextEditorInteraction); m_actions[Undo] = new QAction(this); m_actions[Undo]->setIcon(QIcon::fromTheme("edit-undo")); m_actions[Undo]->setText(i18n("Undo")); m_actions[Undo]->setShortcuts(KStandardShortcut::undo()); connect(m_actions[Undo], SIGNAL(triggered()), this, SLOT(undo())); m_actions[Redo] = new QAction(this); m_actions[Redo]->setIcon(QIcon::fromTheme("edit-redo")); m_actions[Redo]->setText(i18n("Redo")); m_actions[Redo]->setShortcuts(KStandardShortcut::redo()); connect(m_actions[Redo], SIGNAL(triggered()), this, SLOT(redo())); m_actions[Cut] = new QAction(this); m_actions[Cut]->setIcon(QIcon::fromTheme("edit-cut")); m_actions[Cut]->setText(i18n("Cut")); m_actions[Cut]->setShortcuts(KStandardShortcut::cut()); connect(m_actions[Cut], SIGNAL(triggered()), this, SLOT(cut())); m_actions[Copy] = new QAction(this); m_actions[Copy]->setIcon(QIcon::fromTheme("edit-copy")); m_actions[Copy]->setText(i18n("Copy")); m_actions[Copy]->setShortcuts(KStandardShortcut::copy()); connect(m_actions[Copy], SIGNAL(triggered()), this, SLOT(copy())); #if !defined(QT_NO_CLIPBOARD) m_actions[Paste] = new QAction(this); m_actions[Paste]->setIcon(QIcon::fromTheme("edit-paste")); m_actions[Paste]->setText(i18n("Paste")); m_actions[Paste]->setShortcuts(KStandardShortcut::paste()); connect(m_actions[Paste], SIGNAL(triggered()), this, SLOT(paste())); #endif m_actions[Delete] = new QAction(this); m_actions[Delete]->setIcon(QIcon::fromTheme("edit-delete")); m_actions[Delete]->setText(i18n("Delete")); m_actions[Delete]->setShortcut(QKeySequence::Delete); connect(m_actions[Delete], SIGNAL(triggered()), this, SLOT(deleteText())); m_actions[Clear] = new QAction(this); m_actions[Clear]->setIcon(QIcon::fromTheme("edit-clear")); m_actions[Clear]->setText(i18nc("@action:inmenu Clear all text", "Clear")); connect(m_actions[Clear], SIGNAL(triggered()), this, SLOT(undoableClear())); m_actions[SelectAll] = new QAction(this); m_actions[SelectAll]->setIcon(QIcon::fromTheme("edit-select-all")); m_actions[SelectAll]->setText(i18n("Select All")); m_actions[SelectAll]->setShortcut(QKeySequence::SelectAll); connect(m_actions[SelectAll], SIGNAL(triggered()), this, SLOT(selectAll())); m_actions[ToggleBold] = new QAction(this); m_actions[ToggleBold]->setIcon(QIcon::fromTheme("format-text-bold")); m_actions[ToggleBold]->setText(i18nc("@action:inmenu Toggle bold style", "Bold")); m_actions[ToggleBold]->setShortcut(QKeySequence("Ctrl+B")); connect(m_actions[ToggleBold], SIGNAL(triggered()), this, SLOT(toggleFontBold())); m_actions[ToggleItalic] = new QAction(this); m_actions[ToggleItalic]->setIcon(QIcon::fromTheme("format-text-italic")); m_actions[ToggleItalic]->setText(i18nc("@action:inmenu Toggle italic style", "Italic")); m_actions[ToggleItalic]->setShortcut(QKeySequence("Ctrl+I")); connect(m_actions[ToggleItalic], SIGNAL(triggered()), this, SLOT(toggleFontItalic())); m_actions[ToggleUnderline] = new QAction(this); m_actions[ToggleUnderline]->setIcon(QIcon::fromTheme("format-text-underline")); m_actions[ToggleUnderline]->setText(i18nc("@action:inmenu Toggle underline style", "Underline")); m_actions[ToggleUnderline]->setShortcut(QKeySequence("Ctrl+U")); connect(m_actions[ToggleUnderline], SIGNAL(triggered()), this, SLOT(toggleFontUnderline())); m_actions[ToggleStrikeOut] = new QAction(this); m_actions[ToggleStrikeOut]->setIcon(QIcon::fromTheme("format-text-strikethrough")); m_actions[ToggleStrikeOut]->setText(i18nc("@action:inmenu Toggle strike through style", "Strike Through")); m_actions[ToggleStrikeOut]->setShortcut(QKeySequence("Ctrl+T")); connect(m_actions[ToggleStrikeOut], SIGNAL(triggered()), this, SLOT(toggleFontStrikeOut())); m_actions[ChangeTextColor] = new QAction(this); m_actions[ChangeTextColor]->setIcon(QIcon::fromTheme("format-text-color")); m_actions[ChangeTextColor]->setText(i18nc("@action:inmenu Change Text Color", "Text Color")); m_actions[ChangeTextColor]->setShortcut(QKeySequence("Ctrl+Shift+C")); connect(m_actions[ChangeTextColor], SIGNAL(triggered()), this, SLOT(changeTextColor())); m_actions[CheckSpelling] = new QAction(this); m_actions[CheckSpelling]->setIcon(QIcon::fromTheme("tools-check-spelling")); m_actions[CheckSpelling]->setText(i18n("Check Spelling...")); connect(m_actions[CheckSpelling], SIGNAL(triggered()), this, SLOT(checkSpelling())); m_actions[ToggleAutoSpellChecking] = new QAction(this); m_actions[ToggleAutoSpellChecking]->setText(i18n("Auto Spell Check")); m_actions[ToggleAutoSpellChecking]->setCheckable(true); connect(m_actions[ToggleAutoSpellChecking], SIGNAL(triggered()), this, SLOT(toggleAutoSpellChecking())); m_actions[AllowTabulations] = new QAction(this); m_actions[AllowTabulations]->setText(i18n("Allow Tabulations")); connect(m_actions[AllowTabulations], SIGNAL(triggered()), this, SLOT(toggleTabChangesFocus())); QMenu *menu = createStandardContextMenu(); menu->setParent(this); QList<QAction *> actions = menu->actions(); m_insertUnicodeControlCharMenu = 0; for(QList<QAction *>::ConstIterator it = actions.constBegin(), end = actions.constEnd(); it != end; ++it) { if((*it)->menu()) { // this depends on Qt private implementation but at least is guaranteed // to behave reasonably if that implementation changes in the future. if(!strcmp((*it)->menu()->metaObject()->className(), "QUnicodeControlCharacterMenu")) { m_insertUnicodeControlCharMenu = (*it)->menu(); break; } } } }
qmdiEditor::qmdiEditor( QString fName, QWidget* p ): QsvEditor(p) { setupActions(); actionSave = new QAction( QIcon(":images/save.png"), tr("&Save"), this ); actionUndo = new QAction( QIcon(":images/redo.png"), tr("&Redo"), this ); actionRedo = new QAction( QIcon(":images/undo.png"), tr("&Undo"), this ); actionCopy = new QAction( QIcon(":images/copy.png"), tr("&Copy"), this ); actionCut = new QAction( QIcon(":images/cut.png"), tr("&Cut"), this ); actionPaste = new QAction( QIcon(":images/paste.png"), tr("&Paste"), this ); actionSave->setObjectName( "qmdiEditor::actionSave" ); actionUndo->setObjectName( "qmdiEditor::actionUndo" ); actionRedo->setObjectName( "qmdiEditor::actionRedo" ); actionCopy->setObjectName( "qmdiEditor::actionCopy" ); actionCut->setObjectName( "qmdiEditor::actionCut" ); actionPaste->setObjectName( "qmdiEditor::actionPaste" ); connect( this, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)) ); connect( this, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)) ); connect( this, SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)) ); connect( this, SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool)) ); connect( actionUndo, SIGNAL(triggered()), this, SLOT(undo()) ); connect( actionRedo, SIGNAL(triggered()), this, SLOT(redo()) ); connect( actionCopy, SIGNAL(triggered()), this, SLOT(copy()) ); connect( actionCut, SIGNAL(triggered()), this, SLOT(cut()) ); connect( actionPaste, SIGNAL(triggered()), this, SLOT(paste()) ); // connect( actiohAskHelp, SIGNAL(triggered()), this, SLOT(helpShowHelp())); textOperationsMenu = new QMenu( tr("Text actions"), this ); textOperationsMenu->setObjectName("qmdiEditor::textOperationsMenu"); textOperationsMenu->addAction( actionCapitalize ); textOperationsMenu->addAction( actionLowerCase ); textOperationsMenu->addAction( actionChangeCase ); bookmarksMenu = new QMenu( tr("Bookmarks"), this ); bookmarksMenu ->setObjectName("qmdiEditor::bookmarksMenu "); bookmarksMenu->addAction( actionToggleBookmark ); bookmarksMenu->addSeparator(); bookmarksMenu->addAction( actionNextBookmark ); bookmarksMenu->addAction( actionPrevBookmark ); menus["&File"]->addAction( actionSave ); menus["&Edit"]->addAction( actionUndo ); menus["&Edit"]->addAction( actionRedo ); menus["&Edit"]->addSeparator(); menus["&Edit"]->addAction( actionCopy ); menus["&Edit"]->addAction( actionCut ); menus["&Edit"]->addAction( actionPaste ); menus["&Edit"]->addSeparator(); menus["&Edit"]->addMenu( textOperationsMenu ); menus["&Edit"]->addMenu( bookmarksMenu ); // menus["&Edit"]->addAction( actionTogglebreakpoint ); menus["&Edit"]->addAction( actionFindMatchingBracket ); menus["&Search"]->addAction( actionFind ); menus["&Search"]->addAction( actionFindNext ); menus["&Search"]->addAction( actionFindPrev ); menus["&Search"]->addAction( actionClearSearchHighlight ); menus["&Search"]->addSeparator(); menus["&Search"]->addAction( actionReplace ); menus["&Search"]->addSeparator(); menus["&Search"]->addAction( actionGotoLine ); loadFile( fName ); mdiClientName = getShortFileName(); }
void MainWindow::createMenus() { QAction* action; QString name; QMenu* menu; QMenu* subMenu; // ----- File Menu ----- menu = menuBar()->addMenu("File"); name = "About"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showAbout())); name = "New Molecule"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(newMoleculeMenu())); action->setShortcut(QKeySequence::New); name = "New Viewer"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(newViewer())); name = "Open"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(openFile())); action->setShortcut(QKeySequence::Open); name = "Open Recent"; m_recentFilesMenu = menu->addMenu(name); updateRecentFilesMenu(); menu->addSeparator(); /* name = "Parse Test File"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(parseFile())); menu->addSeparator(); */ name = "Close Viewer"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(close())); action->setShortcut(QKeySequence::Close); name = "Save"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAll())); action->setShortcut(QKeySequence::Save); name = "Save As"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAs())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S); menu->addSeparator(); name = "Save Picture"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewer, SLOT(saveSnapshot())); action->setShortcut(Qt::CTRL + Qt::Key_P); name = "Record Animation"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), this, SLOT(toggleRecordingActive())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_P); m_recordAnimationAction = action; name = "Show Message Log"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showLogMessages())); action->setShortcut(Qt::CTRL + Qt::Key_L); name = "Quit"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(quit())); action->setShortcut(Qt::CTRL + Qt::Key_Q); // ----- Edit Menu ----- menu = menuBar()->addMenu("Edit"); name = "Undo"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(undo())); action->setShortcut(QKeySequence::Undo); connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool))); name = "Redo"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(redo())); action->setShortcut(QKeySequence::Redo); connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool))); menu->addSeparator(); name = "Cut"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(cutSelection())); action->setShortcut(Qt::CTRL + Qt::Key_X); name = "Copy"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(copySelectionToClipboard())); action->setShortcut(Qt::CTRL + Qt::Key_C); name = "Paste"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(pasteSelectionFromClipboard())); action->setShortcut(Qt::CTRL + Qt::Key_V); menu->addSeparator(); name = "Select All"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(selectAll())); action->setShortcut(Qt::CTRL + Qt::Key_A); name = "Select None"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SIGNAL(clearSelection())); action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_A); name = "Invert Selection"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(invertSelection())); action->setShortcut(Qt::CTRL + Qt::Key_I); menu->addSeparator(); name = "Reindex Atoms"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(reindexAtoms())); menu->addSeparator(); name = "Preferences"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showPreferences())); // ----- Display Menu ----- menu = menuBar()->addMenu("Display"); name = "Full Screen"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), this, SLOT(fullScreen())); action->setShortcut(Qt::CTRL + Qt::Key_0); m_fullScreenAction = action; name = "Reset View"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewer, SLOT(resetView())); action->setShortcut(Qt::CTRL + Qt::Key_R); name = "Show Axes"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAxes())); connect(&m_viewerModel, SIGNAL(axesOn(bool)), action, SLOT(setChecked(bool))); action->setShortcut(Qt::Key_A); menu->addSeparator(); name = "Atom Labels"; subMenu = menu->addMenu(name); name = "Element"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Element); action->setShortcut(Qt::Key_E); action->setCheckable(true); m_labelActions << action; name = "Index"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Index); action->setShortcut(Qt::Key_I); action->setCheckable(true); m_labelActions << action; name = "Mass"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Mass); action->setShortcut(Qt::Key_M); action->setCheckable(true); m_labelActions << action; /* name = "NMR Shifts"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::NmrShifts); action->setShortcut(Qt::Key_N); action->setCheckable(true); m_labelActions << action; */ name = "Partial Charge"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Charge); action->setShortcut(Qt::Key_Q); action->setCheckable(true); m_labelActions << action; name = "Spin Densities"; action = subMenu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setLabel())); action->setData(Layer::Atom::Spin); action->setShortcut(Qt::Key_S); action->setCheckable(true); m_labelActions << action; menu->addSeparator(); name = "Configure Appearance"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(configureAppearance())); // These are not working correctly at the moment. /* name = "Partial Charge Type"; QActionGroup* partialChargeGroup = new QActionGroup(this); subMenu = menu->addMenu(name); QString pc("Gasteiger"); action = subMenu->addAction(pc); action->setCheckable(true); action->setChecked(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); pc = "Sanderson"; action = subMenu->addAction(pc); action->setCheckable(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); pc = "Mulliken"; action = subMenu->addAction(pc); action->setCheckable(true); action->setData(pc); partialChargeGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType())); */ // ----- Build Menu ----- menu = menuBar()->addMenu("Build"); name = "Fill Valencies With Hydrogens"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(addHydrogens())); action->setShortcut(Qt::CTRL + Qt::Key_F); name = "Reperceive Bonds"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(reperceiveBonds())); menu->addSeparator(); name = "Set Constraint"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(setConstraint())); action->setShortcut(Qt::CTRL + Qt::Key_K); name = "Minimize Structure"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(minimizeEnergy())); action->setShortcut(Qt::CTRL + Qt::Key_M); name = "Select Force Field"; QActionGroup* forceFieldGroup = new QActionGroup(this); subMenu = menu->addMenu(name); QString ff("MMFF94"); action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "MMFF94s"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "UFF"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "Ghemical"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); ff = "Gaff"; action = subMenu->addAction(ff); action->setCheckable(true); action->setData(ff); forceFieldGroup->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(setForceField())); if (Preferences::DefaultForceField() == ff) action->setChecked(true); menu->addSeparator(); name = "Translate To Center"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(translateToCenter())); action->setShortcut(Qt::CTRL + Qt::Key_T ); name = "Symmetrize Molecule"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(symmetrize())); action->setShortcut(Qt::CTRL + Qt::Key_Y ); name = "Set Symmetry Tolerance"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(adjustSymmetryTolerance())); name = "Auto-detect Symmetry"; action = menu->addAction(name); action->setCheckable(true); action->setChecked(false); connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAutoDetectSymmetry())); // ----- Calculation Menu ----- menu = menuBar()->addMenu("Calculation"); name = "Q-Chem Setup"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(openQChemUI())); action->setShortcut(Qt::CTRL + Qt::Key_U ); m_qchemSetupAction = action; name = "Job Monitor"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showProcessMonitor())); action->setShortcut(Qt::CTRL + Qt::Key_J ); menu->addSeparator(); name = "Edit Servers"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(editServers())); name = "Remove All Processes"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), &(ProcessMonitor::instance()), SLOT(clearProcessList())); name = "Reset Password Vault Key"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(setVaultPassword())); // ----- Help Menu ----- menu = menuBar()->addMenu("Help"); name = "Show Help"; action = menu->addAction(name); connect(action, SIGNAL(triggered()), this, SLOT(showHelp())); }
/* ======================== createActions ======================== */ void CBaseEditWindow::createActions( IShader* ) { // // files // m_actNew = new QAction( QIcon(":/images/new.png"), tr( "&New" ), this ); m_actNew->setShortcut( tr( "Ctrl+N" ) ); connect( m_actNew, SIGNAL(triggered() ), this, SLOT(newFile()) ); m_actOpen = new QAction( QIcon(":/images/open.png"), tr( "&Open..." ), this ); m_actOpen->setShortcut( tr( "Ctrl+O" ) ); connect( m_actOpen, SIGNAL(triggered()), this, SLOT(open()) ); m_actSave = new QAction( QIcon(":/images/save.png"), tr( "&Save" ), this ); m_actSave->setShortcut( tr( "Ctrl+S" ) ); connect( m_actSave, SIGNAL(triggered()), this, SLOT(save()) ); m_actSaveAs = new QAction( tr( "Save &As" ), this ); connect( m_actSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()) ); m_actQuit = new QAction( QIcon(":/images/exit.png"), tr( "E&xit" ), this ); m_actQuit->setShortcut( tr( "Ctrl+Q" ) ); connect( m_actQuit, SIGNAL(triggered()), this, SLOT(close()) ); // // edit // m_actUndo = new QAction( QIcon(":/images/undo.png"), tr( "&Undo" ), this ); m_actUndo->setShortcut( tr( "Ctrl+Z" ) ); connect( m_actUndo, SIGNAL(triggered()), this, SLOT(undo()) ); m_actRedo = new QAction( QIcon(":/images/redo.png"), tr( "&Redo" ), this ); m_actRedo->setShortcut( tr( "Ctrl+Shift+Z" ) ); connect( m_actRedo, SIGNAL(triggered()), this, SLOT(redo()) ); m_actCopy = new QAction( QIcon(":/images/copy.png"), tr( "&Copy" ), this ); m_actCopy->setShortcut( tr( "Ctrl+C" ) ); connect( m_actCopy, SIGNAL(triggered()), this, SLOT(copy()) ); m_actCut = new QAction( QIcon(":/images/cut.png"), tr( "Cu&t" ), this ); m_actCut->setShortcut( tr( "Ctrl+X" ) ); connect( m_actCut, SIGNAL(triggered()), this, SLOT(cut()) ); m_actPaste = new QAction( QIcon(":/images/paste.png"), tr( "&Paste" ), this ); m_actPaste->setShortcut( tr( "Ctrl+V" ) ); connect( m_actPaste, SIGNAL(triggered()), this, SLOT(paste()) ); // // shaders // m_actLink = new QAction( tr( "&Link" ), this ); m_actLink->setShortcut( tr( "F5" ) ); connect( m_actLink, SIGNAL(triggered()), this, SLOT(link()) ); // // help // m_actAbout = new QAction( tr( "&About" ), this ); connect( m_actAbout, SIGNAL(triggered()), this, SLOT(about()) ); m_actAboutQt = new QAction( QIcon(":/images/qt.png"), tr( "About &Qt" ), this ); connect( m_actAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()) ); }
void PixelShaderEditor::onInitialize() { m_resourceMgr = &ResourcesManager::getInstance(); ASSERT( m_resourceMgr != NULL ); // setup ui m_ui.setupUi( this ); // create a toolbar QString iconsDir = m_resourceMgr->getFilesystem().getShortcut( "editorIcons" ).c_str(); QToolBar* toolbar = new QToolBar( m_ui.toolbarFrame ); m_ui.toolbarFrame->layout()->addWidget( toolbar ); // load some common icons m_linkActiveIcon = QIcon( iconsDir + "linkActive.png" ); m_linkInactiveIcon = QIcon( iconsDir + "linkInactive.png" ); // set the editor up m_scriptEditor = new TextEditWidget( m_ui.editorFrame, toolbar ); m_ui.editorFrame->layout()->addWidget( m_scriptEditor ); QFont font( "Courier", 12 ); m_scriptEditor->setFont( font ); m_scriptEditor->setSyntaxHighlighter( new ShaderSyntaxHighlighter() ); m_scriptEditor->setPlainText( m_shader.getScript().c_str() ); connect( m_scriptEditor, SIGNAL( textChanged() ), this, SLOT( onScriptModified() ) ); m_docModified = false; // set the properties { const PixelShaderParams& params = m_shader.getParams(); // geometry group box { m_ui.cullingMode->setCurrentIndex( params.m_cullingMode - 1 ); connect( m_ui.cullingMode, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); } // depth group box { m_ui.zBufferEnabled->setChecked( params.m_useZBuffer ); connect( m_ui.zBufferEnabled, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) ); m_ui.zBufferWriteEnabled->setChecked( params.m_writeToZBuffer ); connect( m_ui.zBufferWriteEnabled, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) ); m_ui.depthTestFuncCombo->setCurrentIndex( params.m_depthTestFunc - 1 ); connect( m_ui.depthTestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); } // alpha test group box { m_ui.alphaTest->setChecked( params.m_useAlphaTest ); connect( m_ui.alphaTest, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) ); m_ui.alphaTestFuncCombo->setCurrentIndex( params.m_alphaTestFunc - 1 ); connect( m_ui.alphaTestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); // create the reference color picker { QLayout* layout = m_ui.alphaTestRefColor->layout(); Color color; color.setFromLong( params.m_alphaTestRefVal ); m_alphaTestRefColor = new ColorFrame( m_ui.alphaTestRefColor, color ); layout->addWidget( m_alphaTestRefColor ); connect( m_alphaTestRefColor, SIGNAL( changed( const QColor& ) ), this, SLOT( onParamChange() ) ); } } // blending group box { m_ui.useAlphaBlend->setChecked( params.m_useBlending ); connect( m_ui.useAlphaBlend, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) ); m_ui.blendSrcFuncCombo->setCurrentIndex( params.m_blendSourceFunc - 1 ); connect( m_ui.blendSrcFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); m_ui.blendDestFuncCombo->setCurrentIndex( params.m_blendDestFunc - 1 ); connect( m_ui.blendDestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); } // separate alpha blending group box { m_ui.useSeparatedAlphaBlending->setChecked( params.m_useSeparateAlphaBlend ); connect( m_ui.useSeparatedAlphaBlending, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) ); m_ui.alphaBlendSrcFuncCombo->setCurrentIndex( params.m_alphaBlendSourceFunc - 1 ); connect( m_ui.alphaBlendSrcFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); m_ui.alphaBlendDestFuncCombo->setCurrentIndex( params.m_alphaBlendDestFunc - 1 ); connect( m_ui.alphaBlendDestFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); } // stencil operations group box { m_ui.useStencil->setChecked( params.m_stencilEnable ); connect( m_ui.useStencil, SIGNAL( toggled( bool ) ), this, SLOT( onParamChange() ) ); m_ui.stencilFailCombo->setCurrentIndex( params.m_stencilFail - 1 ); connect( m_ui.stencilFailCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); m_ui.stencilZFailCombo->setCurrentIndex( params.m_stencilZFail - 1 ); connect( m_ui.stencilZFailCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); m_ui.stencilPassCombo->setCurrentIndex( params.m_stencilPass - 1 ); connect( m_ui.stencilPassCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); m_ui.stencilFuncCombo->setCurrentIndex( params.m_stencilFunc - 1 ); connect( m_ui.stencilFuncCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onParamChange() ) ); m_stencilRef = new HexEditor( m_ui.stencilRefFrame, params.m_stencilRef ); m_ui.stencilRefFrame->layout()->addWidget( m_stencilRef ); m_stencilMask = new HexEditor( m_ui.stencilMaskFrame, params.m_stencilMask ); m_ui.stencilMaskFrame->layout()->addWidget( m_stencilMask ); m_stencilWriteMask = new HexEditor( m_ui.stencilWriteMaskFrame, params.m_stencilWriteMask ); m_ui.stencilWriteMaskFrame->layout()->addWidget( m_stencilWriteMask ); } refreshRenderingParamsUI(); } // set texture stages tabs { initializeTextureStagesTab(); } // initialize the toolbar // file management { QAction* actionSave = new QAction( QIcon( iconsDir + tr( "/saveFile.png" ) ), tr( "Save" ), toolbar ); actionSave->setShortcut( QKeySequence( tr( "Ctrl+S" ) ) ); toolbar->addAction( actionSave ); connect( actionSave, SIGNAL( triggered() ), this, SLOT( save() ) ); QAction* actionImportFrom = new QAction( QIcon( iconsDir + tr( "/import.png" ) ), tr( "Import" ), toolbar ); toolbar->addAction( actionImportFrom ); connect( actionImportFrom, SIGNAL( triggered() ), this, SLOT( importFrom() ) ); QAction* actionExportTo = new QAction( QIcon( iconsDir + tr( "/export.png" ) ), tr( "Export" ), toolbar ); toolbar->addAction( actionExportTo ); connect( actionExportTo, SIGNAL( triggered() ), this, SLOT( exportTo() ) ); toolbar->addSeparator(); } // script edition commands { QAction* actionUndo = new QAction( QIcon( iconsDir + tr( "/undo.png" ) ), tr( "Undo" ), toolbar ); actionUndo->setShortcut( QKeySequence( tr( "Ctrl+Z" ) ) ); toolbar->addAction( actionUndo ); connect( actionUndo, SIGNAL( triggered() ), m_scriptEditor, SLOT( undo() ) ); QAction* actionRedo = new QAction( QIcon( iconsDir + tr( "/redo.png" ) ), tr( "Redo" ), toolbar ); actionRedo->setShortcut( QKeySequence( tr( "Ctrl+Y" ) ) ); toolbar->addAction( actionRedo ); connect( actionRedo, SIGNAL( triggered() ), m_scriptEditor, SLOT( redo() ) ); toolbar->addSeparator(); } // building commands { QAction* actionCompile = new QAction( QIcon( iconsDir + tr( "/play.png" ) ), tr( "Compile" ), toolbar ); actionCompile->setShortcut( QKeySequence( tr( "F5" ) ) ); toolbar->addAction( actionCompile ); connect( actionCompile, SIGNAL( triggered() ), this, SLOT( compile() ) ); } show(); }
void AnnotWindow::slotUpdateUndoAndRedoInContextMenu(QMenu* menu) { if (!menu) return; QList<QAction *> actionList = menu->actions(); enum { UndoAct, RedoAct, CutAct, CopyAct, PasteAct, ClearAct, SelectAllAct, NCountActs }; KAction *kundo = KStandardAction::create( KStandardAction::Undo, m_document, SLOT(undo()), menu); KAction *kredo = KStandardAction::create( KStandardAction::Redo, m_document, SLOT(redo()), menu); connect(m_document, SIGNAL(canUndoChanged(bool)), kundo, SLOT(setEnabled(bool))); connect(m_document, SIGNAL(canRedoChanged(bool)), kredo, SLOT(setEnabled(bool))); kundo->setEnabled(m_document->canUndo()); kredo->setEnabled(m_document->canRedo()); QAction *oldUndo, *oldRedo; oldUndo = actionList[UndoAct]; oldRedo = actionList[RedoAct]; menu->insertAction(oldUndo, kundo); menu->insertAction(oldRedo, kredo); menu->removeAction(oldUndo); menu->removeAction(oldRedo); }
bool MineBrush::MineAction::redo() { return undo(); }
void Selection_Flipy (void) { UndoableCommand undo("mirrorSelected -axis y"); Select_FlipAxis(1); }