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 += qscintilla2
|
||||
QT += opengl
|
||||
|
||||
# see http://fedoraproject.org/wiki/UnderstandingDSOLinkChange
|
||||
|
|
|
@ -108,7 +108,7 @@ private:
|
|||
|
||||
LegacyEditor *legacy;
|
||||
ScintillaEditor *scintilla;
|
||||
Editor *editor;
|
||||
EditorInterface *editor;
|
||||
|
||||
class QMessageBox *openglbox;
|
||||
class FontListDialog *font_list_dialog;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "editor.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
|
||||
// to handle these ourselves in MainWindow
|
||||
setAcceptDrops(false);
|
||||
this->highlighter = new Highlighter(this->document());
|
||||
}
|
||||
Editor::~Editor()
|
||||
EditorInterface::~EditorInterface()
|
||||
{
|
||||
delete highlighter;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
#include <QTextEdit>
|
||||
#include "highlighter.h"
|
||||
|
||||
class Editor : public QWidget
|
||||
class EditorInterface : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Editor(QWidget *parent);
|
||||
~Editor();
|
||||
EditorInterface(QWidget *parent);
|
||||
~EditorInterface();
|
||||
virtual QSize sizeHint(){ QSize size; return size;}
|
||||
virtual void setInitialSizeHint(const QSize &size) { }
|
||||
virtual void wheelEvent ( QWheelEvent * event ) { }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "legacyeditor.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
LegacyEditor::LegacyEditor(QWidget *parent) : Editor(parent)
|
||||
LegacyEditor::LegacyEditor(QWidget *parent) : EditorInterface(parent)
|
||||
{
|
||||
legacyeditorLayout = new QVBoxLayout(this);
|
||||
textedit = new QTextEdit(this);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "highlighter.h"
|
||||
#include "editor.h"
|
||||
|
||||
class LegacyEditor : public Editor
|
||||
class LegacyEditor : public EditorInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -168,12 +168,11 @@ MainWindow::MainWindow(const QString &filename)
|
|||
{
|
||||
setupUi(this);
|
||||
// legacy = new LegacyEditor(editorDockContents);
|
||||
// editor = legacy;
|
||||
// editor = legacy;
|
||||
|
||||
scintilla = new ScintillaEditor(editorDockContents);
|
||||
editor = scintilla;
|
||||
editorDockContents->layout()->addWidget(editor);
|
||||
editor->setMinimumSize(editorDockContents->sizeHint());
|
||||
verticalLayout_4->addWidget(editor);
|
||||
|
||||
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
||||
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||
|
|
|
@ -1,9 +1,70 @@
|
|||
#include <iostream>
|
||||
#include <QTextCursor>
|
||||
#include "scintillaeditor.h"
|
||||
|
||||
ScintillaEditor::ScintillaEditor(QWidget *parent) : Editor(parent)
|
||||
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
|
||||
{
|
||||
layout = new QVBoxLayout(this);
|
||||
qsci = new QsciScintilla(this);;
|
||||
layout->addWidget(qsci);
|
||||
qsci->setMarginLineNumbers(10,true);
|
||||
scintillaLayout = new QVBoxLayout(this);
|
||||
qsci = new QsciScintilla(this);
|
||||
scintillaLayout->addWidget(qsci);
|
||||
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 <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <Qsci/qsciscintilla.h>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "editor.h"
|
||||
|
||||
class ScintillaEditor : public Editor
|
||||
class ScintillaEditor : public EditorInterface
|
||||
{
|
||||
public:
|
||||
ScintillaEditor(QWidget *parent);
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue