mirror of https://github.com/vitalif/openscad
layout problem of editor is solved
parent
22e884d08f
commit
950ffe9722
|
@ -92,6 +92,7 @@ win* {
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG += qt
|
CONFIG += qt
|
||||||
|
CONFIG += qscintilla2
|
||||||
QT += opengl
|
QT += opengl
|
||||||
|
|
||||||
# see http://fedoraproject.org/wiki/UnderstandingDSOLinkChange
|
# see http://fedoraproject.org/wiki/UnderstandingDSOLinkChange
|
||||||
|
|
|
@ -108,7 +108,7 @@ private:
|
||||||
|
|
||||||
LegacyEditor *legacy;
|
LegacyEditor *legacy;
|
||||||
ScintillaEditor *scintilla;
|
ScintillaEditor *scintilla;
|
||||||
Editor *editor;
|
EditorInterface *editor;
|
||||||
|
|
||||||
class QMessageBox *openglbox;
|
class QMessageBox *openglbox;
|
||||||
class FontListDialog *font_list_dialog;
|
class FontListDialog *font_list_dialog;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "Preferences.h"
|
#include "Preferences.h"
|
||||||
|
|
||||||
Editor::Editor(QWidget *parent) : QWidget(parent)
|
EditorInterface::EditorInterface(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
// This needed to avoid QTextEdit accepting filename drops as we want
|
// This needed to avoid QTextEdit accepting filename drops as we want
|
||||||
// to handle these ourselves in MainWindow
|
// to handle these ourselves in MainWindow
|
||||||
setAcceptDrops(false);
|
setAcceptDrops(false);
|
||||||
this->highlighter = new Highlighter(this->document());
|
this->highlighter = new Highlighter(this->document());
|
||||||
}
|
}
|
||||||
Editor::~Editor()
|
EditorInterface::~EditorInterface()
|
||||||
{
|
{
|
||||||
delete highlighter;
|
delete highlighter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include "highlighter.h"
|
#include "highlighter.h"
|
||||||
|
|
||||||
class Editor : public QWidget
|
class EditorInterface : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Editor(QWidget *parent);
|
EditorInterface(QWidget *parent);
|
||||||
~Editor();
|
~EditorInterface();
|
||||||
virtual QSize sizeHint(){ QSize size; return size;}
|
virtual QSize sizeHint(){ QSize size; return size;}
|
||||||
virtual void setInitialSizeHint(const QSize &size) { }
|
virtual void setInitialSizeHint(const QSize &size) { }
|
||||||
virtual void wheelEvent ( QWheelEvent * event ) { }
|
virtual void wheelEvent ( QWheelEvent * event ) { }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "legacyeditor.h"
|
#include "legacyeditor.h"
|
||||||
#include "Preferences.h"
|
#include "Preferences.h"
|
||||||
|
|
||||||
LegacyEditor::LegacyEditor(QWidget *parent) : Editor(parent)
|
LegacyEditor::LegacyEditor(QWidget *parent) : EditorInterface(parent)
|
||||||
{
|
{
|
||||||
legacyeditorLayout = new QVBoxLayout(this);
|
legacyeditorLayout = new QVBoxLayout(this);
|
||||||
textedit = new QTextEdit(this);
|
textedit = new QTextEdit(this);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "highlighter.h"
|
#include "highlighter.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
|
|
||||||
class LegacyEditor : public Editor
|
class LegacyEditor : public EditorInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -168,12 +168,11 @@ MainWindow::MainWindow(const QString &filename)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
// legacy = new LegacyEditor(editorDockContents);
|
// legacy = new LegacyEditor(editorDockContents);
|
||||||
// editor = legacy;
|
// editor = legacy;
|
||||||
|
|
||||||
scintilla = new ScintillaEditor(editorDockContents);
|
scintilla = new ScintillaEditor(editorDockContents);
|
||||||
editor = scintilla;
|
editor = scintilla;
|
||||||
editorDockContents->layout()->addWidget(editor);
|
verticalLayout_4->addWidget(editor);
|
||||||
editor->setMinimumSize(editorDockContents->sizeHint());
|
|
||||||
|
|
||||||
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
||||||
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||||
|
|
|
@ -1,9 +1,70 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <QTextCursor>
|
||||||
#include "scintillaeditor.h"
|
#include "scintillaeditor.h"
|
||||||
|
|
||||||
ScintillaEditor::ScintillaEditor(QWidget *parent) : Editor(parent)
|
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
|
||||||
{
|
{
|
||||||
layout = new QVBoxLayout(this);
|
scintillaLayout = new QVBoxLayout(this);
|
||||||
qsci = new QsciScintilla(this);;
|
qsci = new QsciScintilla(this);
|
||||||
layout->addWidget(qsci);
|
scintillaLayout->addWidget(qsci);
|
||||||
qsci->setMarginLineNumbers(10,true);
|
qsci->setMarginLineNumbers(1,true);
|
||||||
}
|
}
|
||||||
|
void ScintillaEditor::indentSelection()
|
||||||
|
{
|
||||||
|
int line,index;
|
||||||
|
int currentLine = qsci->positionFromLineIndex(line,index);
|
||||||
|
std::cout << "--------------------------------------"<<line<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
||||||
|
qsci->setIndentation(currentLine, 5);
|
||||||
|
}
|
||||||
|
void ScintillaEditor::unindentSelection()
|
||||||
|
{ }
|
||||||
|
void ScintillaEditor::commentSelection()
|
||||||
|
{}
|
||||||
|
void ScintillaEditor::uncommentSelection()
|
||||||
|
{}
|
||||||
|
void ScintillaEditor::setPlainText(const QString &text)
|
||||||
|
{ }
|
||||||
|
void ScintillaEditor::highlightError(int error_pos)
|
||||||
|
{}
|
||||||
|
void ScintillaEditor::unhighlightLastError()
|
||||||
|
{}
|
||||||
|
void ScintillaEditor::setHighlightScheme(const QString &name)
|
||||||
|
{ }
|
||||||
|
void ScintillaEditor::insertPlainText(const QString &text)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void ScintillaEditor::undo()
|
||||||
|
{
|
||||||
|
qsci->undo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditor::redo()
|
||||||
|
{
|
||||||
|
qsci->redo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditor::cut()
|
||||||
|
{
|
||||||
|
qsci->cut();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditor::copy()
|
||||||
|
{
|
||||||
|
qsci->copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditor::paste()
|
||||||
|
{
|
||||||
|
qsci->paste();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditor::zoomIn()
|
||||||
|
{
|
||||||
|
qsci->zoomIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditor::zoomOut()
|
||||||
|
{
|
||||||
|
qsci->zoomOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,51 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <Qsci/qsciscintilla.h>
|
#include <Qsci/qsciscintilla.h>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
|
|
||||||
class ScintillaEditor : public Editor
|
class ScintillaEditor : public EditorInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScintillaEditor(QWidget *parent);
|
ScintillaEditor(QWidget *parent);
|
||||||
QsciScintilla *qsci;
|
QsciScintilla *qsci;
|
||||||
QVBoxLayout *layout;
|
/* virtual QSize sizeHint(){ QSize size; return size;}
|
||||||
|
virtual void setInitialSizeHint(const QSize &size) { }
|
||||||
|
virtual void wheelEvent ( QWheelEvent * event ) { }
|
||||||
|
virtual void setTabStopWidth(int width) { }
|
||||||
|
virtual QString toPlainText() { QString s; return s;}
|
||||||
|
virtual QTextCursor textCursor() { QTextCursor c; return c;}
|
||||||
|
virtual void setTextCursor (const QTextCursor &cursor) { }
|
||||||
|
virtual QTextDocument *document(){QTextDocument *t = new QTextDocument; return t;}
|
||||||
|
virtual bool find(const QString & exp, QTextDocument::FindFlags options = 0){ return options;}
|
||||||
|
*/
|
||||||
|
public slots:
|
||||||
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
|
// virtual void setLineWrapping(bool on) { }
|
||||||
|
// virtual void setContentModified(bool y){ }
|
||||||
|
// virtual bool isContentModified(){ return true; }
|
||||||
|
void indentSelection();
|
||||||
|
void unindentSelection();
|
||||||
|
void commentSelection();
|
||||||
|
void uncommentSelection();
|
||||||
|
void setPlainText(const QString &text);
|
||||||
|
void highlightError(int error_pos);
|
||||||
|
void unhighlightLastError();
|
||||||
|
void setHighlightScheme(const QString &name);
|
||||||
|
void insertPlainText(const QString &text);
|
||||||
|
void undo();
|
||||||
|
void redo();
|
||||||
|
void cut();
|
||||||
|
void copy();
|
||||||
|
void paste();
|
||||||
|
private:
|
||||||
|
// Highlighter *highlighter;
|
||||||
|
// QSize initialSizeHint;
|
||||||
|
QVBoxLayout *scintillaLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCINTILLAEDITOR_H
|
#endif // SCINTILLAEDITOR_H
|
||||||
|
|
Loading…
Reference in New Issue