SemanticMarkupEdition::SemanticMarkupEdition( QTextEdit* textEdit): //krazy:exclude=qclasses QObject(textEdit), mTextEdit(textEdit) { Q_ASSERT(textEdit); connect(mTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(updateActionStates())); //TODO Needed to update the action states when the user deletes a character; //look how to do that without updating twice in any other text change. connect(mTextEdit, SIGNAL(textChanged()), this, SLOT(updateActionStates())); }
void AppEditMenu::focusWidgetChanged(QWidget * /*old*/, QWidget *now) { if(now==0){ return; } if(dynamic_cast<QMenu*>(now)){ return; } currentAppWidget=now; ConnectionPage *cnPage=getConnectionsPane()->currentConnectionPage(); ConnectionPageTab *cnPageTab=cnPage ? cnPage->currentConnectionPageTab() : 0; updateActionStates(cnPage, cnPageTab); CodeEditor *editor = qobject_cast<CodeEditor*>(currentAppWidget); bool isCodeEditor=(editor!=0); if(isCodeEditor){ updateActionStatesForCodeEditor(editor); return; } bool canUndo=now->metaObject()->indexOfSlot("undo()")>-1; bool canRedo=now->metaObject()->indexOfSlot("redo()")>-1; editUndoAction->setEnabled(canUndo); editRedoAction->setEnabled(canRedo); bool canCut=now->metaObject()->indexOfSlot("cut()")>-1; bool canCopy=now->metaObject()->indexOfSlot("copy()")>-1; bool canPaste=now->metaObject()->indexOfSlot("paste()")>-1; bool canSelectAll=now->metaObject()->indexOfSlot("selectAll()")>-1; editCutAction->setEnabled(canCut); editCopyAction->setEnabled(canCopy); //editCopyAsAction->setEnabled(false); editPasteAction->setEnabled(canPaste); editSelectAllAction->setEnabled(canSelectAll); editCommentAction->setEnabled(false); editMoveUpAction->setEnabled(false); editMoveDownAction->setEnabled(false); editSelectBlockAction->setEnabled(false); editToUpperCaseAction->setEnabled(false); editToLowerCaseAction->setEnabled(false); editCreateDuplicateAction->setEnabled(false); editRemoveEmptyLinesAction->setEnabled(false); editApplyCaseFoldingAction->setEnabled(false); editFormatCodeAction->setEnabled(false); editDescribeAction->setEnabled(false); editResolveAction->setEnabled(false); editIncreaseFontSize->setEnabled(false); editDecreaseFontSize->setEnabled(false); editResetFontSize->setEnabled(false); editGoToLineAction->setEnabled(false); }
void SoundMuteAction::actionTriggered(QAction *sender, bool toggled) { Q_UNUSED(sender); m_soundManager->setMute(!toggled); updateActionStates(); configuration()->deprecatedApi()->writeEntry("Sounds", "PlaySound", toggled); }
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) , m_editor(0) , m_hooqPlayInjector(new PlatformInjector(this)) , m_hooqRecordInjector(new PlatformInjector(this)) , m_hooqLogger(0) , m_hooqPlayer(0) , m_interpreter(new Interpreter(this)) , m_server(new QTcpServer(this)) , m_testModel(new TestModel(this)) , m_testRunning(false) , m_testResultsWindow(new TestResultsDialog(this)) , m_xmlDump(0) { if(!m_interpreter->haveRequiredQtScriptExtensions()) { QMessageBox::critical(0, tr("Couldn't load required QtScript extensions"), tr("Please install qtscriptgenerator for the version of Qt you are currently using. While recording in Hooq may work, playback will not be possible.")); } if(!m_server->listen(QHostAddress::LocalHost, Hooq::Communication::serverPort())) { QMessageBox::critical(0, tr("Couldn't listen for applications"), tr("Hooq couldn't start listening for applications; you're probably running two copies of Hooq. Hooq will not work.")); } m_editor = new ScriptEditor(m_interpreter->engine()); setupUi(this); setStatusBar(0); populateTestSets(); m_testList->setModel(m_testModel); PushButtonDelegate* delegate = new PushButtonDelegate(m_testList, this); delegate->addButton(1, QApplication::style()->standardIcon(QStyle::SP_MediaPlay)); delegate->addButton(2, QApplication::style()->standardIcon(QStyle::SP_FileIcon)); m_testList->setItemDelegate(delegate); m_testList->header()->setResizeMode(0, QHeaderView::Stretch); m_testList->header()->setResizeMode(1, QHeaderView::Fixed); m_testList->header()->setResizeMode(2, QHeaderView::Fixed); m_testList->header()->setStretchLastSection(false); m_contextMenu = new QMenu(this); m_contextMenu->addAction(tr("Run"), this, SLOT(runCurrentTest())); m_contextMenu->addAction(tr("Edit"), this, SLOT(editCurrentTest())); m_contextMenu->addSeparator(); m_contextMenu->addAction(tr("Delete"), this, SLOT(deleteCurrentTest())); setTestSet(m_testSetEdit->currentText()); m_testList->setContextMenuPolicy(Qt::CustomContextMenu); QObject* deleteObserver = new ModelIndexKeyEventObserver(QKeySequence::Delete, m_testList); connect( deleteObserver, SIGNAL(released(QModelIndex)), SLOT(deleteCurrentTest()) ); connect( m_testList, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showTestContextMenu(QPoint)) ); connect( m_testSetEdit, SIGNAL(activated(QString)), SLOT(setTestSet(QString)) ); connect( m_runAllButton, SIGNAL(clicked()), SLOT(runAllTests()) ); connect( m_addTestButton, SIGNAL(clicked()), SLOT(startRecording()) ); connect( m_hooqRecordInjector, SIGNAL(finished(int)), SLOT(finishRecording()) ); connect( m_testNameEdit, SIGNAL(textChanged(QString)), SLOT(updateActionStates()) ); connect( m_addTestSetButton, SIGNAL(clicked()), SLOT(addTestSet()) ); connect( m_newTestSet, SIGNAL(triggered()), SLOT(addTestSet()) ); connect( m_editTestSet, SIGNAL(triggered()), SLOT(editTestSet()) ); connect( m_removeTestSet, SIGNAL(triggered()), SLOT(removeTestSet()) ); connect( m_exportSet, SIGNAL(triggered()), SLOT(exportCurrentSet()) ); connect( m_importSet, SIGNAL(triggered()), SLOT(importTestSet()) ); connect( m_editor, SIGNAL(pickRequested()), m_interpreter, SLOT(pickObject()) ); connect( m_editor, SIGNAL(startRequested()), SLOT(runEditorTest()) ); connect( m_editor, SIGNAL(exceptionThrown(QString, QStringList)), SLOT(logException(QString, QStringList)) ); connect( m_interpreter, SIGNAL(objectPicked(ObjectInformation)), m_editor, SLOT(objectPicked(ObjectInformation)) ); connect( m_interpreter, SIGNAL(objectNotFound(QString)), m_editor, SLOT(objectNotFound(QString)) ); connect( m_interpreter, SIGNAL(executionFailed(int)), m_editor, SLOT(handleApplicationExit(int)) ); connect( m_interpreter, SIGNAL(finished()), SLOT(testFinished()) ); connect( m_interpreter, SIGNAL(startApplicationAndAttach()), SLOT(startApplication()) ); connect( m_quit, SIGNAL(triggered()), qApp, SLOT(quit()) ); connect( m_aboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()) ); connect( m_about, SIGNAL(triggered()), SLOT(about()) ); ColumnClickMapper* mapper = new ColumnClickMapper(m_testList); mapper->addMapping(1, this, SLOT(runTestScript(QModelIndex))); mapper->addMapping(2, this, SLOT(editTestScript(QModelIndex))); updateActionStates(); }
void MainWindow::setBuildAvailable() { _build_available = true; updateActionStates(); }
void MainWindow::setBuildAvailable(bool enabled) { _build_available = enabled; updateActionStates(); }
void MainWindow::setCloseAvailable(bool enabled) { _close_available = enabled; updateActionStates(); }
void MainWindow::setSaveAvailable(bool enabled) { _save_available = enabled; updateActionStates(); }
void SemanticMarkupEdition::createActions(KActionCollection* actionCollection) { Q_ASSERT(actionCollection); mEmphasisAction = new KAction("emphasis", actionCollection); mEmphasisAction->setCheckable(true); mEmphasisAction->setToolTip(i18nc("@info:tooltip", "Emphasized text")); mEmphasisAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag to emphasize a word or phrase in the text.<nl/>" "Example: <emphasis>emphasized text</emphasis>")); actionCollection->addAction("kuit-edition-phrase-emphasis", mEmphasisAction); connect(mEmphasisAction, SIGNAL(triggered()), this, SLOT(emphasis())); mActions.append(mEmphasisAction); mEmphasisStrongAction = new KAction("emphasis (strong)", actionCollection); mEmphasisStrongAction->setCheckable(true); mEmphasisStrongAction->setToolTip(i18nc("@info:tooltip", "Strongly emphasized text")); mEmphasisStrongAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag to strongly emphasize a word or phrase in the text.<nl/>" "Example: <emphasis strong=\"1\">strongly emphasized text</emphasis>")); actionCollection->addAction("kuit-edition-phrase-emphasis-strong", mEmphasisStrongAction); connect(mEmphasisStrongAction, SIGNAL(triggered()), this, SLOT(emphasisStrong())); mActions.append(mEmphasisStrongAction); mFilenameAction = new KAction("filename", actionCollection); mFilenameAction->setCheckable(true); mFilenameAction->setToolTip(i18nc("@info:tooltip", "Filename or path")); mFilenameAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag for file or folder name or path.<nl/>" "The path separators will be transformed into what is native to the " "platform.<nl/>" "Example: <filename>/home/user/Music/song.ogg</filename>")); actionCollection->addAction("kuit-edition-phrase-filename", mFilenameAction); connect(mFilenameAction, SIGNAL(triggered()), this, SLOT(filename())); mActions.append(mFilenameAction); mInterfaceAction = new KAction("interface", actionCollection); mInterfaceAction->setCheckable(true); mInterfaceAction->setToolTip(i18nc("@info:tooltip", "GUI interface element")); mInterfaceAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag for paths to GUI interface elements.<nl/>" "If there is more than one element in the path, use \"|\" to delimit " "elements, which will be converted into canonical delimiter.<nl/>" "Example: <interface>File|Open</interface>")); actionCollection->addAction("kuit-edition-phrase-interface", mInterfaceAction); connect(mInterfaceAction, SIGNAL(triggered()), this, SLOT(interface())); mActions.append(mInterfaceAction); mLinkAction = new KAction("link", actionCollection); mLinkAction->setCheckable(true); mLinkAction->setToolTip(i18nc("@info:tooltip", "Link to URL or widget")); mLinkAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag to link to a URL-addressable resource.<nl/>" "Widgets in the target application interface can be linked using " "<emphasis>widget:theObjectNameOfTheWidget</emphasis><nl/>" "Example: <link url=\"http://www.kde.org\">a link</link>")); actionCollection->addAction("kuit-edition-phrase-link", mLinkAction); connect(mLinkAction, SIGNAL(triggered()), this, SLOT(link())); mActions.append(mLinkAction); mNlAction = new KAction("nl", actionCollection); mNlAction->setToolTip(i18nc("@info:tooltip", "Line break")); mNlAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag for line breaks.<nl/>" "Example: line<nl/>break")); actionCollection->addAction("kuit-edition-phrase-nl", mNlAction); connect(mNlAction, SIGNAL(triggered()), this, SLOT(nl())); mActions.append(mNlAction); mShortcutAction = new KAction("shortcut", actionCollection); mShortcutAction->setCheckable(true); mShortcutAction->setToolTip(i18nc("@info:tooltip", "Combination of keys to press")); mShortcutAction->setWhatsThis(i18nc("@info:whatsthis", "Phrase tag for combinations of keys to press.<nl/>" "Separate the keys by \"+\" or \"-\", and the shortcut will be " "converted into canonical form.<nl/>" "Example: <shortcut>Ctrl+N</shortcut>")); actionCollection->addAction("kuit-edition-phrase-shortcut", mShortcutAction); connect(mShortcutAction, SIGNAL(triggered()), this, SLOT(shortcut())); mActions.append(mShortcutAction); mParaAction = new KAction("para", actionCollection); mParaAction->setCheckable(true); mParaAction->setToolTip(i18nc("@info:tooltip", "Paragraph")); mParaAction->setWhatsThis(i18nc("@info:whatsthis", "<para>Structure tag for text paragraphs.<nl/>" "Example: one paragraph</para><para>Other paragraph</para>")); actionCollection->addAction("kuit-edition-structure-para", mParaAction); connect(mParaAction, SIGNAL(triggered()), this, SLOT(para())); mActions.append(mParaAction); mListAction = new KAction("list", actionCollection); mListAction->setCheckable(true); mListAction->setToolTip(i18nc("@info:tooltip", "List of items")); mListAction->setWhatsThis(i18nc("@info:whatsthis", "<para>Structure tag for lists of items.<nl/>" "Can contain only <item> as subtags. List is considered an " "element of the paragraph, so the <list> must be found inside " "<para>.<nl/>" "Example: <list>" " <item>One item</item>" " <item>Other item</item>" " </list></para>")); actionCollection->addAction("kuit-edition-structure-list", mListAction); connect(mListAction, SIGNAL(triggered()), this, SLOT(list())); mActions.append(mListAction); mItemAction = new KAction("item", actionCollection); mItemAction->setCheckable(true); mItemAction->setToolTip(i18nc("@info:tooltip", "List items")); mItemAction->setWhatsThis(i18nc("@info:whatsthis", "<para>Structure tag for list items.<nl/>" "Example: <list>" " <item>One item</item>" " <item>Other item</item>" " </list></para>")); actionCollection->addAction("kuit-edition-structure-item", mItemAction); connect(mItemAction, SIGNAL(triggered()), this, SLOT(item())); mActions.append(mItemAction); updateActionStates(); }