Ejemplo n.º 1
0
PythonScriptViewWidget::PythonScriptViewWidget(PythonScriptView *view, QWidget *parent) : QWidget(parent), fontZoom(0) , pythonScriptView(view) {
    setupUi(this);
    consoleOutputWidget->installEventFilter(&keyboardFocusEventFilter);
    mainScriptToolBar = new QToolBar(mainScriptToolBarWidget);
    newMainScriptAction = mainScriptToolBar->addAction(QIcon(":/icons/doc_new.png"), "New main script");
    loadMainScriptAction = mainScriptToolBar->addAction(QIcon(":/icons/doc_import.png"), "Load main script from file");
    saveMainScriptAction = mainScriptToolBar->addAction(QIcon(":/icons/doc_export.png"), "Save main script to file");

    modulesToolBar = new QToolBar(modulesToolBarWidget);
    modulesToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    newStringModuleAction = modulesToolBar->addAction(QIcon(":/icons/doc_plus.png"), "New string module");
    newFileModuleAction = modulesToolBar->addAction(QIcon(":/icons/doc_new.png"), "New file module");
    loadModuleAction = modulesToolBar->addAction(QIcon(":/icons/doc_import.png"), "Import module from file");
    saveModuleAction = modulesToolBar->addAction(QIcon(":/icons/doc_export.png"), "Save module to file");

    pluginsToolBar = new QToolBar(pluginsToolBarWidget);
    pluginsToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    newPluginAction = pluginsToolBar->addAction(QIcon(":/icons/doc_plus.png"), "New Tulip plugin");
    loadPluginAction = pluginsToolBar->addAction(QIcon(":/icons/doc_import.png"), "Import Tulip plugin from file");
    savePluginAction = pluginsToolBar->addAction(QIcon(":/icons/doc_export.png"), "Save Tulip plugin to file");


    modulesTabWidget->clear();
    mainScriptsTabWidget->clear();
    pluginsTabWidget->clear();
    QList<int> sizes;
    sizes.push_back(550);
    sizes.push_back(150);
    splitter->setSizes(sizes);
    splitter->setCollapsible(0, false);
    pluginControlFrame->hide();

    pluginsInfosWidget->appendHtml(QString("When the plugin development is finished, you can copy the associated Python file ")
                                   + "to <b>" + pythonPluginsPath.c_str() + "</b> or <b> "
                                   + pythonPluginsPathHome.c_str() +"</b> and it will be automatically loaded at Tulip startup");

    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(resizeToolBars()));
    connect(decreaseFontSizeButton, SIGNAL(clicked()), this, SLOT(decreaseFontSize()));
    connect(increaseFontSizeButton, SIGNAL(clicked()), this, SLOT(increaseFontSize()));
    connect(decreaseFontSizeButton2, SIGNAL(clicked()), this, SLOT(decreaseFontSize()));
    connect(increaseFontSizeButton2, SIGNAL(clicked()), this, SLOT(increaseFontSize()));
    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
    connect(consoleOutputWidget, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(scrollToEditorLine(const QUrl &)));

    QString docRootPath = QString(tlp::TulipShareDir.c_str()) + "../doc/tulip-python/html/index.html";

    QFile docRoot(docRootPath);

    if (docRoot.exists()) {
        QWebView *webView = new QWebView();
#ifdef WIN32
        webView->load(QUrl("file:///"+docRootPath));
#else
        webView->load(QUrl("file://"+docRootPath));
#endif
        tabWidget->addTab(webView, "Documentation");
    }

}
Ejemplo n.º 2
0
DocumentBrowser::DocumentBrowser(LiteApi::IApplication *app, QObject *parent) :
    LiteApi::IDocumentBrowser(parent),
    m_liteApp(app),
    m_extension(new Extension)
{
    m_widget = new QWidget;

    m_htmlWidget = app->htmlWidgetManager()->createByName(this,"QTextBrowser");

    m_toolBar = new QToolBar;
    m_toolBar->setIconSize(LiteApi::getToolBarIconSize());

    m_backwardAct = new QAction(QIcon("icon:images/backward.png"),tr("Back"),this);
    m_forwardAct = new QAction(QIcon("icon:images/forward.png"),tr("Forward"),this);
    m_reloadUrlAct = new QAction(QIcon("icon:images/reload.png"),tr("Reload"),this);
    m_toolBar->addAction(m_backwardAct);
    m_toolBar->addAction(m_forwardAct);

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Document");

    m_increaseFontSize = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSize,"IncreaseFontSize","Ctrl++;Ctrl+=");

    m_decreaseFontSize = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSize,"DecreaseFontSize","Ctrl+-");

    m_resetFontSize = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSize,"ResizeFontSize","Ctrl+0");

    m_urlComboBox = new QComboBox;
    m_urlComboBox->setEditable(true);
    m_urlComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);

    m_toolBar->addSeparator();
    m_toolBar->addWidget(m_urlComboBox);
    m_toolBar->addAction(m_reloadUrlAct);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);

    mainLayout->addWidget(m_toolBar);
    mainLayout->addWidget(m_htmlWidget->widget());
    m_widget->setLayout(mainLayout);

    m_widget->addAction(m_increaseFontSize);
    m_widget->addAction(m_decreaseFontSize);
    m_widget->addAction(m_resetFontSize);

    connect(m_increaseFontSize,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSize,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSize,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_htmlWidget,SIGNAL(linkHovered(QUrl)),this,SIGNAL(linkHovered(QUrl)));
    connect(m_htmlWidget,SIGNAL(linkClicked(QUrl)),this,SLOT(linkClicked(QUrl)));
    connect(m_htmlWidget,SIGNAL(loadFinished(bool)),this,SIGNAL(documentLoaded()));
    connect(m_backwardAct,SIGNAL(triggered()),this,SLOT(backward()));
    connect(m_forwardAct,SIGNAL(triggered()),this,SLOT(forward()));
    connect(m_reloadUrlAct,SIGNAL(triggered()),this,SLOT(reloadUrl()));
    connect(m_urlComboBox,SIGNAL(activated(QString)),this,SLOT(activatedUrl(QString)));
    connect(this,SIGNAL(backwardAvailable(bool)),m_backwardAct,SLOT(setEnabled(bool)));
    connect(this,SIGNAL(forwardAvailable(bool)),m_forwardAct,SLOT(setEnabled(bool)));

    m_extension->addObject("LiteApi.IDocumentBrowser",this);
    m_extension->addObject("LiteApi.IHtmlWidget",m_htmlWidget);
    m_extension->addObject("LiteApi.QTextBrowser",m_htmlWidget->widget());
    m_htmlWidget->installEventFilter(m_liteApp->editorManager());

    requestFontZoom(0);

    QPalette p = m_htmlWidget->widget()->palette();
    p.setBrush(QPalette::Highlight,Qt::yellow);
    p.setColor(QPalette::HighlightedText,Qt::black);
    m_htmlWidget->widget()->setPalette(p);

    emit backwardAvailable(false);
    emit forwardAvailable(false);
}
Ejemplo n.º 3
0
void LiteEditor::createActions()
{
    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor");

    m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this);
    actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo);

    m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this);
    actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y");

    m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this);
    actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut);

    m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this);
    actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy);

    m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this);
    actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste);

    m_selectAllAct = new QAction(tr("Select All"),this);
    actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll);

    m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this);
#ifndef QT_NO_PRINTER
    m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this);
    m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this);
    m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this);
#endif
    m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this);
    actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+[");

    m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this);
    actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]");


    m_selectBlockAct = new QAction(tr("Select Block"),this);
    actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U");

    m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this);
    actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E");

    m_foldAct = new QAction(tr("Fold"),this);   
    actionContext->regAction(m_foldAct,"Fold","Ctrl+<");

    m_unfoldAct = new QAction(tr("Unfold"),this);
    actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>");

    m_foldAllAct = new QAction(tr("Fold All"),this);
    actionContext->regAction(m_foldAllAct,"FoldAll","");

    m_unfoldAllAct = new QAction(tr("Unfold All"),this);
    actionContext->regAction(m_unfoldAllAct,"UnfoldAll","");

    connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold()));
    connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold()));
    connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll()));
    connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll()));

    m_gotoLineAct = new QAction(tr("Go To Line"),this);
    actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L");

    m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this);
    m_lockAct->setEnabled(false);

    m_duplicateAct = new QAction(tr("Duplicate"),this);
    actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+D");

    connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate()));

    m_deleteLineAct = new QAction(tr("Delete Line"),this);
    actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K");

    connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine()));

    m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this);
    actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return");
    connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore()));

    m_insertLineAfterAct = new QAction(tr("Insert Line After"),this);
    actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return");
    connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter()));

    m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++;Ctrl+=");

    m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-");

    m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0");

    m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this);
    actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace","");

    m_wordWrapAct = new QAction(tr("Word Wrap"),this);
    m_wordWrapAct->setCheckable(true);
    actionContext->regAction(m_wordWrapAct,"WordWrap","");

//    m_widget->addAction(m_foldAct);
//    m_widget->addAction(m_unfoldAct);
//    m_widget->addAction(m_gotoLineAct);

//    m_widget->addAction(m_gotoPrevBlockAct);
//    m_widget->addAction(m_gotoNextBlockAct);
//    m_widget->addAction(m_selectBlockAct);
//    m_widget->addAction(m_gotoMatchBraceAct);

    connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool)));

    connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo()));
    connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo()));
    connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut()));
    connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy()));
    connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste()));
    connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll()));
    connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock()));

    connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml()));
#ifndef QT_NO_PRINTER
    connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf()));
    connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint()));
    connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview()));
#endif
    connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock()));
    connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock()));
    connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace()));
    connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine()));
    connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace()));
    connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool)));

    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged()));
    clipbordDataChanged();
}
Ejemplo n.º 4
0
void LiteEditor::createActions()
{
    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor");

    m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this);
    actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo);

    m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this);
    actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y");

    m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this);
    actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut);

    m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this);
    actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy);

    m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this);
    actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste);

    m_selectAllAct = new QAction(tr("Select All"),this);
    actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll);

    m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this);
#ifndef QT_NO_PRINTER
    m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this);
    m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this);
    m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this);
#endif
    m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this);
    actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+[");

    m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this);
    actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]");


    m_selectBlockAct = new QAction(tr("Select Block"),this);
    actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U");

    m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this);
    actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E");

    m_foldAct = new QAction(tr("Fold"),this);   
    actionContext->regAction(m_foldAct,"Fold","Ctrl+<");

    m_unfoldAct = new QAction(tr("Unfold"),this);
    actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>");

    m_foldAllAct = new QAction(tr("Fold All"),this);
    actionContext->regAction(m_foldAllAct,"FoldAll","");

    m_unfoldAllAct = new QAction(tr("Unfold All"),this);
    actionContext->regAction(m_unfoldAllAct,"UnfoldAll","");

    connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold()));
    connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold()));
    connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll()));
    connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll()));

    m_gotoLineAct = new QAction(tr("Go To Line"),this);
    actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L");

    m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this);
    m_lockAct->setEnabled(false);

    m_duplicateAct = new QAction(tr("Duplicate"),this);
    actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+Shift+D");
    connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate()));

    m_deleteLineAct = new QAction(tr("Delete Line"),this);
    actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K");
    connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine()));

    m_copyLineAct = new QAction(tr("Copy Line"),this);
    actionContext->regAction(m_copyLineAct,"CopyLine","Ctrl+Ins");
    connect(m_copyLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(copyLine()));

    m_cutLineAct = new QAction(tr("Cut Line"),this);
    actionContext->regAction(m_cutLineAct,"CutLine","Shift+Del");
    connect(m_cutLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(cutLine()));

    m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this);
    actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return");
    connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore()));

    m_insertLineAfterAct = new QAction(tr("Insert Line After"),this);
    actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return");
    connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter()));

    m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++");

    m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-");

    m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0");

    m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this);
    actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace","");

    m_wordWrapAct = new QAction(tr("Word Wrap (MimeType)"),this);
    m_wordWrapAct->setCheckable(true);
    actionContext->regAction(m_wordWrapAct,"WordWrap","");

    m_codeCompleteAct = new QAction(tr("Code Complete"),this);
#ifdef Q_OS_MAC
    actionContext->regAction(m_codeCompleteAct,"CodeComplete","Meta+Space");
#else
    actionContext->regAction(m_codeCompleteAct,"CodeComplete","Ctrl+Space");
#endif

    m_commentAct = new QAction(tr("Toggle Comment"),this);
    actionContext->regAction(m_commentAct,"Comment","Ctrl+/");

    m_blockCommentAct = new QAction(tr("Toggle Block Commnet"),this);
    actionContext->regAction(m_blockCommentAct,"BlockComment","Ctrl+Shift+/");

    m_autoIndentAct = new QAction(tr("Auto-indent Selection"),this);
    actionContext->regAction(m_autoIndentAct,"AutoIndent","Ctrl+I");
    m_autoIndentAct->setVisible(false);

    m_tabToSpacesAct = new QAction(tr("Tab To Spaces (MimeType)"),this);
    actionContext->regAction(m_tabToSpacesAct,"TabToSpaces","");
    m_tabToSpacesAct->setCheckable(true);

    m_lineEndingWindowAct = new QAction(tr("Line End Windows (\\r\\n)"),this);
    actionContext->regAction(m_lineEndingWindowAct,"LineEndingWindow","");
    m_lineEndingWindowAct->setCheckable(true);

    m_lineEndingUnixAct = new QAction(tr("Line End Unix (\\n)"),this);
    actionContext->regAction(m_lineEndingUnixAct,"LineEndingUnix","");
    m_lineEndingUnixAct->setCheckable(true);

    m_visualizeWhitespaceAct = new QAction(tr("Visualize Whitespace (Global)"),this);
    actionContext->regAction(m_visualizeWhitespaceAct,"VisualizeWhitespace","");
    m_visualizeWhitespaceAct->setCheckable(true);

    m_commentAct->setVisible(false);
    m_blockCommentAct->setVisible(false);

    m_moveLineUpAction = new QAction(tr("Move Line Up"),this);
    actionContext->regAction(m_moveLineUpAction,"MoveLineUp","Ctrl+Shift+Up");

    m_moveLineDownAction = new QAction(tr("Move Line Down"),this);
    actionContext->regAction(m_moveLineDownAction,"MoveLineDown","Ctrl+Shift+Down");

    m_copyLineUpAction = new QAction(tr("Copy Line Up"),this);
    actionContext->regAction(m_copyLineUpAction,"CopyLineUp","Ctrl+Alt+Up");

    m_copyLineDownAction = new QAction(tr("Copy Line Down"),this);
    actionContext->regAction(m_copyLineDownAction,"CopyLineDown","Ctrl+Alt+Down");

    m_joinLinesAction = new QAction(tr("Join Lines"),this);
    actionContext->regAction(m_joinLinesAction,"JoinLines","Ctrl+J");

    connect(m_codeCompleteAct,SIGNAL(triggered()),m_editorWidget,SLOT(codeCompleter()));
//    m_widget->addAction(m_foldAct);
//    m_widget->addAction(m_unfoldAct);
//    m_widget->addAction(m_gotoLineAct);

//    m_widget->addAction(m_gotoPrevBlockAct);
//    m_widget->addAction(m_gotoNextBlockAct);
//    m_widget->addAction(m_selectBlockAct);
//    m_widget->addAction(m_gotoMatchBraceAct);

    connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool)));

    connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo()));
    connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo()));
    connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut()));
    connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy()));
    connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste()));
    connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll()));
    connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock()));

    connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml()));
#ifndef QT_NO_PRINTER
    connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf()));
    connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint()));
    connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview()));
#endif
    connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock()));
    connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock()));
    connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace()));
    connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine()));
    connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace()));
    connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool)));
    connect(m_commentAct,SIGNAL(triggered()),this,SLOT(comment()));
    connect(m_blockCommentAct,SIGNAL(triggered()),this,SLOT(blockComment()));
    connect(m_autoIndentAct,SIGNAL(triggered()),this,SLOT(autoIndent()));
    connect(m_tabToSpacesAct,SIGNAL(toggled(bool)),this,SLOT(tabToSpacesToggled(bool)));
    connect(m_visualizeWhitespaceAct,SIGNAL(toggled(bool)),this,SLOT(toggledVisualizeWhitespace(bool)));
    connect(m_moveLineUpAction,SIGNAL(triggered()),m_editorWidget,SLOT(moveLineUp()));
    connect(m_moveLineDownAction,SIGNAL(triggered()),m_editorWidget,SLOT(moveLineDown()));
    connect(m_copyLineUpAction,SIGNAL(triggered()),m_editorWidget,SLOT(copyLineUp()));
    connect(m_copyLineDownAction,SIGNAL(triggered()),m_editorWidget,SLOT(copyLineDown()));
    connect(m_joinLinesAction,SIGNAL(triggered()),m_editorWidget,SLOT(joinLines()));
    //connect(m_lineEndingWindowAct,SIGNAL(triggered()),this,SLOT(lineEndingWindow()));
    //connect(m_lineEndingUnixAct,SIGNAL(triggered()),this,SLOT(lineEndingUnixAct()));
    QActionGroup *group = new QActionGroup(this);
    group->addAction(m_lineEndingWindowAct);
    group->addAction(m_lineEndingUnixAct);
    connect(group,SIGNAL(triggered(QAction*)),this,SLOT(triggeredLineEnding(QAction*)));

#ifdef Q_OS_WIN
    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged()));
    clipbordDataChanged();
#endif
}
Ejemplo n.º 5
0
void PythonEditor::createWidgets() {
    runBt_ = new QToolButton();
    runBt_->setIcon(QIcon(":/modules/python/python.png"));
    runBt_->setIconSize(QSize(24, 24));
    runBt_->setShortcut(QKeySequence("Ctrl+R"));
    runBt_->setToolTip("Run Script (Ctrl+R)");
    newBt_ = new QToolButton();
    newBt_->setIcon(QIcon(":/modules/python/python_2.png"));
    newBt_->setIconSize(QSize(24, 24));
    newBt_->setToolTip("New Script");
    openBt_ = new QToolButton();
    openBt_->setIcon(QIcon(":/qt/icons/open.png"));
    openBt_->setIconSize(QSize(24, 24));
    openBt_->setToolTip("Load Script");
    saveBt_ = new QToolButton();
    saveBt_->setIcon(QIcon(":/qt/icons/save.png"));
    saveBt_->setIconSize(QSize(24, 24));
    saveBt_->setToolTip("Save Script");
    saveAsBt_ = new QToolButton();
    saveAsBt_->setIcon(QIcon(":/qt/icons/saveas.png"));
    saveAsBt_->setIconSize(QSize(24, 24));
    saveAsBt_->setToolTip("Save Script As");

    increaseFontSizeBt_ = new QToolButton();
    increaseFontSizeBt_->setIcon(QIcon(":/qt/icons/viewmag+.png"));
    increaseFontSizeBt_->setIconSize(QSize(24, 24));
    increaseFontSizeBt_->setToolTip("Increase Font Size");
    decreaseFontSizeBt_ = new QToolButton();
    decreaseFontSizeBt_->setIcon(QIcon(":/qt/icons/viewmag_.png"));
    decreaseFontSizeBt_->setIconSize(QSize(24, 24));
    decreaseFontSizeBt_->setToolTip("Decrease Font Size");

    QHBoxLayout* hbox = new QHBoxLayout();
    hbox->setContentsMargins(0,0,0,0);
    hbox->addWidget(runBt_);
    QFrame* sep = new QFrame();
    sep->setFrameShape(QFrame::VLine);
    hbox->addWidget(sep);
    hbox->addWidget(newBt_);
    hbox->addWidget(openBt_);
    hbox->addWidget(saveBt_);
    hbox->addWidget(saveAsBt_);
    hbox->addStretch();
    hbox->addWidget(increaseFontSizeBt_);
    hbox->addWidget(decreaseFontSizeBt_);
    QWidget* toolButtonBar = new QWidget();
    toolButtonBar->setLayout(hbox);

    QFont font;
    font.setFamily("Courier");
    font.setFixedPitch(true);
    font.setPointSize(fontSize_);

    codeEdit_ = new CodeEdit();
    codeEdit_->setFont(font);
    highlighter_ = new PythonHighlighter(codeEdit_->document());

    compilerLogWidget_ = new QTextEdit();
    compilerLogWidget_->setFont(font);
    compilerLogWidget_->setReadOnly(true);
    compilerLogWidget_->setFixedHeight(150);
    QVBoxLayout* vbox = new QVBoxLayout();
    vbox->addWidget(toolButtonBar);
    vbox->addWidget(codeEdit_);
    vbox->addWidget(compilerLogWidget_);
    setLayout(vbox);

    connect(runBt_, SIGNAL(clicked()), this, SLOT(runScript()));
    connect(newBt_, SIGNAL(clicked()), this, SLOT(newScript()));
    connect(openBt_, SIGNAL(clicked()), this, SLOT(openScript()));
    connect(saveBt_, SIGNAL(clicked()), this, SLOT(saveScript()));
    connect(saveAsBt_, SIGNAL(clicked()), this, SLOT(saveScriptAs()));
    connect(increaseFontSizeBt_, SIGNAL(clicked()), this, SLOT(increaseFontSize()));
    connect(decreaseFontSizeBt_, SIGNAL(clicked()), this, SLOT(decreaseFontSize()));
    connect(codeEdit_, SIGNAL(textChanged()), this, SIGNAL(modified()));

    setMinimumSize(300, 400);
}