Example #1
0
MainWindow::MainWindow(KTextEditor::Document* doc)
    : document(0),
      view(0)
{
    if(!doc) {
        KTextEditor::Editor* editor = NULL;
        KService::Ptr serv = KService::serviceByDesktopName("yzispart");

        if(!serv) {
            KMessageBox::error(this, "Could not find yzispart!");
            kapp->exit(-1);
        } else {
            editor = KTextEditor::editor(serv->library().toLatin1());

            if(!editor) {
                KMessageBox::error(this, "Could not create yziskpart editor component");
                kapp->exit(-1);
            }
        }

        document = editor->createDocument(0);
    } else {
        document = doc;
    }

    view = qobject_cast< KTextEditor::View* >(document->createView(this));
    setCentralWidget(view);
    guiFactory()->addClient(view);
    show();
}
Example #2
0
EditorWidgetKate::EditorWidgetKate(QWidget *parent) : EditorWidget(parent)
{
    KTextEditor::Editor *editor = KTextEditor::EditorChooser::editor();
    m_doc = editor->createDocument(parent);
    m_view = m_doc->createView(parent);

    KTextEditor::ConfigInterface *iface = qobject_cast<KTextEditor::ConfigInterface*>(m_doc);
    loadSettings(iface, CFG_VARIANT_KATE_SETTINGS_DOC);

    iface = qobject_cast<KTextEditor::ConfigInterface*>(m_view);
    iface->setConfigValue("line-numbers", true);
    loadSettings(iface, CFG_VARIANT_KATE_SETTINGS_VIEW);

    m_view->installEventFilter(this);

    // FIXME: Two config files. Great.
    KConfig config("lorrisrc");
    m_doc->editor()->readConfig(&config);

    m_readOnly = false;
    m_canUndo = false;
    m_canRedo = false;

    connect(m_doc, SIGNAL(textChanged(KTextEditor::Document*)), SLOT(modified(KTextEditor::Document*)));
}
RKConsole::RKConsole (QWidget *parent, bool tool_window, const char *name) : RKMDIWindow (parent, RKMDIWindow::ConsoleWindow, tool_window, name) {
	RK_TRACE (APP);

	QVBoxLayout *layout = new QVBoxLayout (this);
	layout->setContentsMargins (0, 0, 0, 0);

	// create a Kate-part as command-editor
	KTextEditor::Editor* editor = KTextEditor::editor("katepart");
	RK_ASSERT (editor);

	doc = editor->createDocument (this);
	view = doc->createView (this);
	layout->addWidget (view);

	KTextEditor::ConfigInterface *confint = qobject_cast<KTextEditor::ConfigInterface*> (view);
	RK_ASSERT (view);
	confint->setConfigValue ("dynamic-word-wrap", false);

	setFocusProxy (view);
	setFocusPolicy (Qt::StrongFocus);
	
	/* We need to disable kactions that were plugged to the KateViewInternal in kateview.cpp.
	These actions include Key_Up, Key_Down, etc. */
	kate_edit_actions = view->findChild<KActionCollection*> ("edit_actions");
	if (!kate_edit_actions) {
		kate_edit_actions=view->actionCollection();
	}
	if (kate_edit_actions) {
		// make sure these actions never get triggered by a shortcut

		QList<QKeySequence> noshort;
		noshort.append (QKeySequence ());	// no primary
		noshort.append (QKeySequence ());	// no secondary
		noshort.append (QKeySequence ());	// for good measure

		QList<QAction*> keas = kate_edit_actions->actions ();
		for (int i = 0; i < keas.size (); ++i) {
			keas[i]->setShortcuts (noshort);
		}
	} else {
		RK_DO (qDebug ("Could not retrieve the katepart's edit action collection"), APP, DL_ERROR);
	}

	if (view->focusProxy ()) view->focusProxy()->installEventFilter(this);
	view->installEventFilter(this);

	doc->setModified (false);

	hinter = new RKFunctionArgHinter (this, view);
	
	setCaption (i18n ("R Console"));
	console_part = new RKConsolePart (this);
	setPart (console_part);
	setMetaInfo (shortCaption (), "rkward://page/rkward_console", RKSettings::PageConsole);
	initializeActivationSignals ();
	initializeActions (getPart ()->actionCollection ());

	nprefix = "> ";
	iprefix = "+ ";
	prefix = nprefix;
// KDE4: a way to do this?
//	doc->setUndoSteps (0);
	clear ();
	RKCommandHighlighter::setHighlighting (doc, RKCommandHighlighter::RInteractiveSession);

	commands_history = RKSettingsModuleConsole::loadCommandHistory ();
	commands_history_position = commands_history.constEnd ();

	current_command = 0;
	current_command_displayed_up_to = 0;
	tab_key_pressed_before = false;
	previous_chunk_was_piped = false;

// KDE4 TODO: workaround for KDE 4 pre-release versions. Hope this gets fixed before 4.0
// see http://lists.kde.org/?l=kwrite-devel&m=119721420603507&w=2
	setMinimumHeight (50);
}
Example #4
0
KexiEditor::KexiEditor(QWidget *parent)
        : KexiView(parent)
        , d(new Private())
{
// Q3VBoxLayout *layout = new Q3VBoxLayout(this);
#ifdef KTEXTEDIT_BASED_SQL_EDITOR
    d->view = new KTextEdit("", QString(), this);
    //adjust font
    connect(d->view, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
    QFont f("Courier");
    f.setStyleStrategy(QFont::PreferAntialias);
    f.setPointSize(d->view->font().pointSize());
    d->view->setFont(f);
    d->view->setCheckSpellingEnabled(false);
#else
    KexiUtils::KTextEditorFrame *fr = new KexiUtils::KTextEditorFrame(this);
    QVBoxLayout *layout = new QVBoxLayout(fr);
    layout->setContentsMargins(2, 2, 2, 2);

    KTextEditor::Editor *editor = KTextEditor::EditorChooser::editor();
    if (!editor)
        return;
//! @todo error handling!

    d->doc = editor->createDocument(fr);
    if (!d->doc)
        return;
    d->view = d->doc->createView(fr);
    // set word wrap by default
    KTextEditor::ConfigInterface *configIface
        =
qobject_cast<KTextEditor::ConfigInterface*>( d->view );
    configIface->setConfigValue("dynamic-word-wrap", true);

#ifdef __GNUC__
#warning TODO Q3PopupMenu *pop = qobject_cast<Q3PopupMenu*>( mainWin->factory()->container("edit", mainWin) );
#else
#pragma WARNING( TODO Q3PopupMenu *pop = qobject_cast<Q3PopupMenu*>( mainWin->factory()->container("edit", mainWin) ); )
#endif
#ifdef __GNUC__
#warning TODO d->view->setContextMenu(pop);
#else
#pragma WARNING( TODO d->view->setContextMenu(pop); )
#endif
    d->view->setContextMenu(d->view->defaultContextMenu());

    /* KTextEditor::PopupMenuInterface *popupInt = dynamic_cast<KTextEditor::PopupMenuInterface*>( d->view );
      if(popupInt) {
        Q3PopupMenu *pop = (Q3PopupMenu*) mainWin->factory()->container("edit", mainWin);
        if(pop) {
           //plugSharedAction("edit_undo", pop);
           popupInt->installPopup(pop);
        }
      }*/

    connect(d->doc, SIGNAL(textChanged(KTextEditor::Document*)),
            this, SLOT(slotTextChanged(KTextEditor::Document*)));
#endif
    KexiEditorSharedActionConnector c(this, d->view);
    d->view->installEventFilter(this);

    layout->addWidget(d->view);
    setViewWidget(fr, false/*!focus*/);
    setFocusProxy(d->view);
// d->view->show();
}
Example #5
0
HgCommitDialog::HgCommitDialog(QWidget *parent):
    KDialog(parent, Qt::Dialog)
{
    // dialog properties
    this->setCaption(i18nc("@title:window", 
                "<application>Hg</application> Commit"));
    this->setButtons(KDialog::Ok | KDialog::Cancel);
    this->setDefaultButton(KDialog::Ok);
    this->setButtonText(KDialog::Ok, i18nc("@action:button", "Commit"));
    this->enableButtonOk(false); // since commit message is empty when loaded

    // To show diff between commit
    KTextEditor::Editor *editor = KTextEditor::EditorChooser::editor();
    if (!editor) {
        KMessageBox::error(this, 
                i18n("A KDE text-editor component could not be found;"
                     "\nplease check your KDE installation."));
        return;
    }
    m_fileDiffDoc = editor->createDocument(0);
    m_fileDiffView = qobject_cast<KTextEditor::View*>(m_fileDiffDoc->createView(this));
    m_fileDiffDoc->setReadWrite(false);

    // Setup actions
    m_useCurrentBranch= new KAction(this);
    m_useCurrentBranch->setCheckable(true);
    m_useCurrentBranch->setText(i18nc("@action:inmenu",
                               "Commit to current branch"));

    m_newBranch = new KAction(this);
    m_newBranch->setCheckable(true);
    m_newBranch->setText(i18nc("@action:inmenu",
                               "Create new branch"));

    m_closeBranch = new KAction(this);
    m_closeBranch->setCheckable(true);
    m_closeBranch->setText(i18nc("@action:inmenu",
                                 "Close current branch"));

    m_branchMenu = new KMenu(this);
    m_branchMenu->addAction(m_useCurrentBranch);
    m_branchMenu->addAction(m_newBranch);
    m_branchMenu->addAction(m_closeBranch);

    QActionGroup *branchActionGroup = new QActionGroup(this);
    branchActionGroup->addAction(m_useCurrentBranch);
    branchActionGroup->addAction(m_newBranch);
    branchActionGroup->addAction(m_closeBranch);
    m_useCurrentBranch->setChecked(true);
    connect(branchActionGroup, SIGNAL(triggered(QAction *)),
            this, SLOT(slotBranchActions(QAction *)));


    //////////////
    // Setup UI //
    //////////////

    // Top bar of buttons
    QHBoxLayout *topBarLayout = new QHBoxLayout;
    m_copyMessageButton = new KPushButton(i18n("Copy Message"));
    m_branchButton = new KPushButton(i18n("Branch"));

    m_copyMessageMenu = new KMenu(this);
    createCopyMessageMenu();

    topBarLayout->addWidget(new QLabel(getParentForLabel()));
    topBarLayout->addStretch();
    topBarLayout->addWidget(m_branchButton);
    topBarLayout->addWidget(m_copyMessageButton);
    m_branchButton->setMenu(m_branchMenu);
    m_copyMessageButton->setMenu(m_copyMessageMenu);

    // the commit box itself
    QGroupBox *messageGroupBox = new QGroupBox;
    QVBoxLayout *commitLayout = new QVBoxLayout;
    m_commitMessage = new QPlainTextEdit;
    commitLayout->addWidget(m_commitMessage);
    messageGroupBox->setTitle(i18nc("@title:group", "Commit Message"));
    messageGroupBox->setLayout(commitLayout);

    // Show diff here
    QGroupBox *diffGroupBox = new QGroupBox;
    QVBoxLayout *diffLayout = new QVBoxLayout(diffGroupBox);
    diffLayout->addWidget(m_fileDiffView);
    diffGroupBox->setTitle(i18nc("@title:group", "Diff/Content"));
    diffGroupBox->setLayout(diffLayout);

    // Set up layout for Status, Commit and Diff boxes
    QGridLayout *bodyLayout = new QGridLayout;
    m_statusList = new HgStatusList;
    bodyLayout->addWidget(m_statusList, 0, 0, 0, 1);
    bodyLayout->addWidget(messageGroupBox, 0, 1);
    bodyLayout->addWidget(diffGroupBox, 1, 1);
    bodyLayout->setColumnStretch(0, 1);
    bodyLayout->setColumnStretch(1, 2);
    bodyLayout->setRowStretch(0, 1);
    bodyLayout->setRowStretch(1, 1);

    // Set up layout and container for main dialog
    QFrame *frame = new QFrame;
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topBarLayout);
    mainLayout->addLayout(bodyLayout);
    frame->setLayout(mainLayout);
    setMainWidget(frame);

    slotBranchActions(m_useCurrentBranch);
    slotInitDiffOutput(); // initialise with whole repo diff

    // Load saved settings
    FileViewHgPluginSettings *settings = FileViewHgPluginSettings::self();
    this->setInitialSize(QSize(settings->commitDialogWidth(),
                               settings->commitDialogHeight()));
    //
    connect(m_statusList, SIGNAL(itemSelectionChanged(const char, const QString &)),
        this, SLOT(slotItemSelectionChanged(const char, const QString &)));
    connect(m_commitMessage, SIGNAL(textChanged()),
         this, SLOT(slotMessageChanged()));
    connect(this, SIGNAL(finished()), this, SLOT(saveGeometry()));
}