* finish editor font option form
* refactor: remove width property from SynGutter * finish gutter click event process * mouse wheel scroll contents in the SynEdit
This commit is contained in:
parent
229148c309
commit
0f0ca96545
|
@ -231,14 +231,18 @@ void Editor::wheelEvent(QWheelEvent *event) {
|
|||
// oldFont.setPointSize(oldFont.pointSize());
|
||||
// this->setFont(oldFont);
|
||||
this->zoomIn();
|
||||
event->accept();
|
||||
return;
|
||||
} else {
|
||||
// size = std::min(size+1,50);
|
||||
// oldFont.setPointSize(oldFont.pointSize());
|
||||
// this->setFont(oldFont);
|
||||
this->zoomOut();
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
onLinesChanged(0,0);
|
||||
}
|
||||
SynEdit::wheelEvent(event);
|
||||
}
|
||||
|
||||
void Editor::onModificationChanged(bool) {
|
||||
|
@ -259,6 +263,8 @@ void Editor::applySettings()
|
|||
SynEditorOptions options = eoAltSetsColumnMode |
|
||||
eoDragDropEditing | eoDropFiles | eoKeepCaretX | eoTabsToSpaces |
|
||||
eoRightMouseMovesCursor | eoScrollByOneLess | eoTabIndent | eoHideShowScrollbars;
|
||||
|
||||
//options
|
||||
options.setFlag(eoAddIndent,pSettings->editor().addIndent());
|
||||
options.setFlag(eoAutoIndent,pSettings->editor().autoIndent());
|
||||
options.setFlag(eoTabsToSpaces,pSettings->editor().tabToSpaces());
|
||||
|
@ -278,7 +284,34 @@ void Editor::applySettings()
|
|||
setInsertCaret(pSettings->editor().caretForInsert());
|
||||
setOverwriteCaret(pSettings->editor().caretForOverwrite());
|
||||
setCaretColor(pSettings->editor().caretColor());
|
||||
//todo: show indent line
|
||||
|
||||
QFont f=QFont(pSettings->editor().fontName(),pSettings->editor().fontSize());
|
||||
f.setStyleStrategy(QFont::PreferAntialias);
|
||||
setFont(f);
|
||||
|
||||
// Set gutter properties
|
||||
gutter().setLeftOffset(pSettings->editor().gutterLeftOffset());
|
||||
gutter().setRightOffset(pSettings->editor().gutterRightOffset());
|
||||
gutter().setBorderStyle(SynGutterBorderStyle::None);
|
||||
gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont());
|
||||
if (pSettings->editor().gutterUseCustomFont()) {
|
||||
f=QFont(pSettings->editor().gutterFontName(),pSettings->editor().gutterFontSize());
|
||||
} else {
|
||||
f=QFont(pSettings->editor().fontName(),pSettings->editor().fontSize());
|
||||
}
|
||||
f.setStyleStrategy(QFont::PreferAntialias);
|
||||
gutter().setFont(f);
|
||||
gutter().setDigitCount(pSettings->editor().gutterDigitsCount());
|
||||
gutter().setVisible(pSettings->editor().gutterVisible());
|
||||
gutter().setAutoSize(pSettings->editor().gutterAutoSize());
|
||||
gutter().setShowLineNumbers(pSettings->editor().gutterShowLineNumbers());
|
||||
gutter().setLeadingZeros(pSettings->editor().gutterAddLeadingZero());
|
||||
if (pSettings->editor().gutterLineNumbersStartZero())
|
||||
gutter().setLineNumberStart(0);
|
||||
else
|
||||
gutter().setLineNumberStart(1);
|
||||
//font color
|
||||
|
||||
}
|
||||
|
||||
void Editor::updateCaption(const QString& newCaption) {
|
||||
|
|
|
@ -9,7 +9,6 @@ SynGutter::SynGutter(QObject *parent):
|
|||
mColor= QColorConstants::Svg::lightgray;
|
||||
mBorderColor = QColorConstants::Transparent;
|
||||
mTextColor = QColorConstants::Svg::black;
|
||||
mWidth = 30;
|
||||
mShowLineNumbers = true;
|
||||
mDigitCount = 1;
|
||||
mLeadingZeros = false;
|
||||
|
@ -71,19 +70,6 @@ void SynGutter::setTextColor(const QColor &value)
|
|||
}
|
||||
}
|
||||
|
||||
int SynGutter::width() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
void SynGutter::setWidth(int width)
|
||||
{
|
||||
if (mWidth != width ) {
|
||||
mWidth = width;
|
||||
setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void SynGutter::autoSizeDigitCount(int linesCount)
|
||||
{
|
||||
if (mVisible && mAutoSize && mShowLineNumbers) {
|
||||
|
@ -111,7 +97,7 @@ int SynGutter::realGutterWidth(int charWidth)
|
|||
if (mShowLineNumbers) {
|
||||
return mLeftOffset + mRightOffset + mAutoSizeDigitCount * charWidth + 2;
|
||||
}
|
||||
return mWidth;
|
||||
return mLeftOffset + mRightOffset;
|
||||
}
|
||||
|
||||
bool SynGutter::visible() const
|
||||
|
|
|
@ -69,9 +69,6 @@ public:
|
|||
bool visible() const;
|
||||
void setVisible(bool visible);
|
||||
|
||||
int width() const;
|
||||
void setWidth(int width);
|
||||
|
||||
void autoSizeDigitCount(int linesCount);
|
||||
QString formatLineNumber(int line);
|
||||
int realGutterWidth(int charWidth);
|
||||
|
@ -102,7 +99,6 @@ private:
|
|||
SynGutterBorderStyle mBorderStyle;
|
||||
bool mUseFontStyle;
|
||||
bool mVisible;
|
||||
int mWidth;
|
||||
int mAutoSizeDigitCount;
|
||||
};
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
|
||||
mGutter.setRightOffset(21);
|
||||
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
|
||||
mGutterWidth = mGutter.width();
|
||||
mGutterWidth = mGutter.realGutterWidth(charWidth());
|
||||
//ControlStyle := ControlStyle + [csOpaque, csSetCaption, csNeedsBorderPaint];
|
||||
//Height := 150;
|
||||
//Width := 200;
|
||||
|
@ -207,7 +207,6 @@ void SynEdit::setCaretXY(const BufferCoord &value)
|
|||
|
||||
void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value)
|
||||
{
|
||||
qDebug()<<"new Value"<<value.Line<<value.Char;
|
||||
bool vTriggerPaint=true; //how to test it?
|
||||
|
||||
if (vTriggerPaint)
|
||||
|
@ -789,6 +788,40 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord
|
|||
setBlockEnd(ptAfter);
|
||||
}
|
||||
|
||||
void SynEdit::processGutterClick(QMouseEvent *event)
|
||||
{
|
||||
int X = event->pos().x();
|
||||
int Y = event->pos().y();
|
||||
DisplayCoord RowColumn = pixelsToRowColumn(X, Y);
|
||||
int Line = rowToLine(RowColumn.Row);
|
||||
|
||||
// Check if we clicked on a folding thing
|
||||
if (mUseCodeFolding) {
|
||||
PSynEditFoldRange FoldRange = foldStartAtLine(Line);
|
||||
if (FoldRange) {
|
||||
// See if we actually clicked on the rectangle...
|
||||
//rect.Left := Gutter.RealGutterWidth(CharWidth) - Gutter.RightOffset;
|
||||
QRect rect;
|
||||
rect.setLeft(mGutterWidth - mGutter.rightOffset());
|
||||
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
|
||||
rect.setTop((RowColumn.Row - mTopLine) * mTextHeight);
|
||||
rect.setBottom(rect.top() + mTextHeight);
|
||||
if (rect.contains(QPoint(X, Y))) {
|
||||
if (FoldRange->collapsed)
|
||||
uncollapse(FoldRange);
|
||||
else
|
||||
collapse(FoldRange);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If not, check gutter marks
|
||||
if (Line>=1 && Line <= mLines->count()) {
|
||||
emit gutterClicked(event->button(),X,Y,Line);
|
||||
}
|
||||
}
|
||||
|
||||
void SynEdit::clearUndo()
|
||||
{
|
||||
mUndoList->Clear();
|
||||
|
@ -2419,6 +2452,24 @@ void SynEdit::uncollapse(PSynEditFoldRange FoldRange)
|
|||
invalidateGutterLines(FoldRange->fromLine, INT_MAX);
|
||||
}
|
||||
|
||||
void SynEdit::collapse(PSynEditFoldRange FoldRange)
|
||||
{
|
||||
FoldRange->linesCollapsed = FoldRange->toLine - FoldRange->fromLine;
|
||||
FoldRange->collapsed = true;
|
||||
|
||||
// Extract caret from fold
|
||||
if ((mCaretY > FoldRange->fromLine) && (mCaretY <= FoldRange->toLine)) {
|
||||
setCaretXY(BufferCoord{mLines->getString(FoldRange->fromLine - 1).length() + 1,
|
||||
FoldRange->fromLine});
|
||||
}
|
||||
|
||||
// Redraw the collapsed line
|
||||
invalidateLines(FoldRange->fromLine, INT_MAX);
|
||||
|
||||
// Redraw fold mark
|
||||
invalidateGutterLines(FoldRange->fromLine, INT_MAX);
|
||||
}
|
||||
|
||||
void SynEdit::foldOnListInserted(int Line, int Count)
|
||||
{
|
||||
// Delete collapsed inside selection
|
||||
|
@ -2831,6 +2882,11 @@ void SynEdit::doScrolled(int)
|
|||
invalidate();
|
||||
}
|
||||
|
||||
SynGutter& SynEdit::gutter()
|
||||
{
|
||||
return mGutter;
|
||||
}
|
||||
|
||||
SynEditCaretType SynEdit::getInsertCaret() const
|
||||
{
|
||||
return mInsertCaret;
|
||||
|
@ -4563,7 +4619,7 @@ void SynEdit::paintEvent(QPaintEvent *event)
|
|||
nL1 = MinMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount());
|
||||
nL2 = MinMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount());
|
||||
|
||||
qDebug()<<"Paint:"<<nL1<<nL2<<nC1<<nC2;
|
||||
//qDebug()<<"Paint:"<<nL1<<nL2<<nC1<<nC2;
|
||||
|
||||
QPainter cachePainter(mContentImage.get());
|
||||
cachePainter.setFont(font());
|
||||
|
@ -4645,7 +4701,6 @@ void SynEdit::focusOutEvent(QFocusEvent *)
|
|||
|
||||
void SynEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
mMouseMoved = false;
|
||||
SynEditorCommand cmd=TranslateKeyCode(event->key(),event->modifiers());
|
||||
if (cmd!=SynEditorCommand::ecNone) {
|
||||
CommandProcessor(cmd,QChar(),nullptr);
|
||||
|
@ -4666,6 +4721,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
bool bWasSel = false;
|
||||
bool bStartDrag = false;
|
||||
mMouseMoved = false;
|
||||
BufferCoord TmpBegin = mBlockBegin;
|
||||
BufferCoord TmpEnd = mBlockEnd;
|
||||
Qt::MouseButton button = event->button();
|
||||
|
@ -4734,7 +4790,7 @@ void SynEdit::mouseReleaseEvent(QMouseEvent *event)
|
|||
int Y=event->pos().y();
|
||||
|
||||
if (!mMouseMoved && (X < mGutterWidth + 2)) {
|
||||
//doOnGutterClick(event);
|
||||
processGutterClick(event);
|
||||
}
|
||||
|
||||
mScrollTimer->stop();
|
||||
|
@ -4817,6 +4873,19 @@ void SynEdit::leaveEvent(QEvent *event)
|
|||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void SynEdit::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->angleDelta().y()>0) {
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value()-1);
|
||||
return;
|
||||
} else {
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value()+1);
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
QAbstractScrollArea::wheelEvent(event);
|
||||
}
|
||||
|
||||
bool SynEdit::viewportEvent(QEvent * event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
|
|
|
@ -298,6 +298,8 @@ public:
|
|||
SynEditCaretType getInsertCaret() const;
|
||||
void setInsertCaret(const SynEditCaretType &insertCaret);
|
||||
|
||||
SynGutter& gutter();
|
||||
|
||||
signals:
|
||||
void Changed();
|
||||
|
||||
|
@ -312,7 +314,7 @@ signals:
|
|||
void ChainListPutted(int Index, int Count);
|
||||
|
||||
void FilesDropped(int X,int Y, const QStringList& AFiles);
|
||||
void GutterClicked(Qt::MouseButton button, int x, int y, int line, PSynEditMark mark);
|
||||
void gutterClicked(Qt::MouseButton button, int x, int y, int line);
|
||||
void ImeInputed(const QString& s);
|
||||
|
||||
void contextHelp(const QString& word);
|
||||
|
@ -371,6 +373,8 @@ private:
|
|||
int scanFrom(int Index);
|
||||
int scanRanges();
|
||||
void uncollapse(PSynEditFoldRange FoldRange);
|
||||
void collapse(PSynEditFoldRange FoldRange);
|
||||
|
||||
void foldOnListInserted(int Line, int Count);
|
||||
void foldOnListDeleted(int Line, int Count);
|
||||
void foldOnListCleared();
|
||||
|
@ -422,6 +426,8 @@ private:
|
|||
const BufferCoord& ptBefore,
|
||||
const BufferCoord& ptAfter);
|
||||
|
||||
void processGutterClick(QMouseEvent* event);
|
||||
|
||||
void clearUndo();
|
||||
BufferCoord GetPreviousLeftBracket(int x,int y);
|
||||
bool CanDoBlockIndent();
|
||||
|
@ -602,6 +608,7 @@ void mouseMoveEvent(QMouseEvent *event) override;
|
|||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void inputMethodEvent(QInputMethodEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
// QAbstractScrollArea interface
|
||||
protected:
|
||||
|
|
|
@ -308,7 +308,6 @@ void SynEditTextPainter::ComputeSelectionInfo()
|
|||
bAnySelection = (vEnd.Line >= vFirstLine) and (vStart.Line <= vLastLine);
|
||||
if (bAnySelection) {
|
||||
// Transform the selection from text space into screen space
|
||||
qDebug()<<"ComputeSelectionInfo";
|
||||
vSelStart = edit->bufferToDisplayPos(vStart);
|
||||
vSelEnd = edit->bufferToDisplayPos(vEnd);
|
||||
// In the column selection mode sort the begin and end of the selection,
|
||||
|
|
|
@ -209,6 +209,156 @@ void Settings::Editor::setHalfPageScroll(bool halfPageScroll)
|
|||
mHalfPageScroll = halfPageScroll;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterFontOnlyMonospaced() const
|
||||
{
|
||||
return mGutterFontOnlyMonospaced;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterFontOnlyMonospaced(bool gutterFontOnlyMonospaced)
|
||||
{
|
||||
mGutterFontOnlyMonospaced = gutterFontOnlyMonospaced;
|
||||
}
|
||||
|
||||
int Settings::Editor::gutterRightOffset() const
|
||||
{
|
||||
return mGutterRightOffset;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterRightOffset(int gutterRightOffset)
|
||||
{
|
||||
mGutterRightOffset = gutterRightOffset;
|
||||
}
|
||||
|
||||
int Settings::Editor::gutterLeftOffset() const
|
||||
{
|
||||
return mGutterLeftOffset;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterLeftOffset(int gutterLeftOffset)
|
||||
{
|
||||
mGutterLeftOffset = gutterLeftOffset;
|
||||
}
|
||||
|
||||
int Settings::Editor::gutterFontSize() const
|
||||
{
|
||||
return mGutterFontSize;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterFontSize(int gutterFontSize)
|
||||
{
|
||||
mGutterFontSize = gutterFontSize;
|
||||
}
|
||||
|
||||
QString Settings::Editor::gutterFontName() const
|
||||
{
|
||||
return mGutterFontName;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterFontName(const QString &gutterFontName)
|
||||
{
|
||||
mGutterFontName = gutterFontName;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterUseCustomFont() const
|
||||
{
|
||||
return mGutterUseCustomFont;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterUseCustomFont(bool gutterUseCustomFont)
|
||||
{
|
||||
mGutterUseCustomFont = gutterUseCustomFont;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterLineNumbersStartZero() const
|
||||
{
|
||||
return mGutterLineNumbersStartZero;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterLineNumbersStartZero(bool gutterLineNumbersStartZero)
|
||||
{
|
||||
mGutterLineNumbersStartZero = gutterLineNumbersStartZero;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterAddLeadingZero() const
|
||||
{
|
||||
return mGutterAddLeadingZero;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterAddLeadingZero(bool gutterAddLeadingZero)
|
||||
{
|
||||
mGutterAddLeadingZero = gutterAddLeadingZero;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterShowLineNumbers() const
|
||||
{
|
||||
return mGutterShowLineNumbers;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterShowLineNumbers(bool gutterShowLineNumbers)
|
||||
{
|
||||
mGutterShowLineNumbers = gutterShowLineNumbers;
|
||||
}
|
||||
|
||||
int Settings::Editor::gutterDigitsCount() const
|
||||
{
|
||||
return mGutterDigitsCount;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterDigitsCount(int gutterDigitsCount)
|
||||
{
|
||||
mGutterDigitsCount = gutterDigitsCount;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterAutoSize() const
|
||||
{
|
||||
return mGutterAutoSize;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterAutoSize(bool gutterAutoSize)
|
||||
{
|
||||
mGutterAutoSize = gutterAutoSize;
|
||||
}
|
||||
|
||||
bool Settings::Editor::gutterVisible() const
|
||||
{
|
||||
return mGutterVisible;
|
||||
}
|
||||
|
||||
void Settings::Editor::setGutterVisible(bool gutterVisible)
|
||||
{
|
||||
mGutterVisible = gutterVisible;
|
||||
}
|
||||
|
||||
bool Settings::Editor::fontOnlyMonospaced() const
|
||||
{
|
||||
return mFontOnlyMonospaced;
|
||||
}
|
||||
|
||||
void Settings::Editor::setFontOnlyMonospaced(bool fontOnlyMonospaced)
|
||||
{
|
||||
mFontOnlyMonospaced = fontOnlyMonospaced;
|
||||
}
|
||||
|
||||
int Settings::Editor::fontSize() const
|
||||
{
|
||||
return mFontSize;
|
||||
}
|
||||
|
||||
void Settings::Editor::setFontSize(int fontSize)
|
||||
{
|
||||
mFontSize = fontSize;
|
||||
}
|
||||
|
||||
QString Settings::Editor::fontName() const
|
||||
{
|
||||
return mFontName;
|
||||
}
|
||||
|
||||
void Settings::Editor::setFontName(const QString &fontName)
|
||||
{
|
||||
mFontName = fontName;
|
||||
}
|
||||
|
||||
bool Settings::Editor::scrollByOneLess() const
|
||||
{
|
||||
return mScrollByOneLess;
|
||||
|
@ -273,6 +423,24 @@ void Settings::Editor::doSave()
|
|||
saveValue("scroll_past_eol", mScrollPastEol);
|
||||
saveValue("scroll_by_one_less", mScrollByOneLess);
|
||||
saveValue("half_page_scroll", mHalfPageScroll);
|
||||
|
||||
//Font
|
||||
//font
|
||||
saveValue("font_name",mFontName);
|
||||
saveValue("font_size", mFontSize);
|
||||
saveValue("font_only_monospaced",mFontOnlyMonospaced);
|
||||
|
||||
//gutter
|
||||
saveValue("gutter_visible", mGutterVisible);
|
||||
saveValue("gutter_auto_size", mGutterAutoSize);
|
||||
saveValue("gutter_digits_count", mGutterDigitsCount);
|
||||
saveValue("gutter_show_line_numbers",mGutterShowLineNumbers);
|
||||
saveValue("gutter_add_leading_zero",mGutterAddLeadingZero);
|
||||
saveValue("gutter_line_numbers_start_zero",mGutterLineNumbersStartZero);
|
||||
saveValue("gutter_use_custom_font",mGutterUseCustomFont);
|
||||
saveValue("gutter_font_name",mGutterFontName);
|
||||
saveValue("gutter_font_size",mGutterFontSize);
|
||||
saveValue("gutter_font_only_monospaced",mGutterFontOnlyMonospaced);
|
||||
}
|
||||
|
||||
void Settings::Editor::doLoad()
|
||||
|
@ -299,6 +467,26 @@ void Settings::Editor::doLoad()
|
|||
mScrollPastEol = boolValue("scroll_past_eol", true);
|
||||
mScrollByOneLess = boolValue("scroll_by_one_less", false);
|
||||
mHalfPageScroll = boolValue("half_page_scroll",false);
|
||||
|
||||
//Font
|
||||
//font
|
||||
mFontName = stringValue("font_name","consolas");
|
||||
mFontSize = intValue("font_size",QGuiApplication::font().pointSize());
|
||||
mFontOnlyMonospaced = boolValue("font_only_monospaced",true);
|
||||
|
||||
//gutter
|
||||
mGutterVisible = boolValue("gutter_visible",true);
|
||||
mGutterAutoSize = boolValue("gutter_auto_size",true);
|
||||
mGutterLeftOffset = intValue("gutter_left_offset",28);
|
||||
mGutterRightOffset = intValue("gutter_right_offset",24);
|
||||
mGutterDigitsCount = intValue("gutter_digits_count",1);
|
||||
mGutterShowLineNumbers = boolValue("gutter_show_line_numbers",true);
|
||||
mGutterAddLeadingZero = boolValue("gutter_add_leading_zero",true);
|
||||
mGutterLineNumbersStartZero = boolValue("gutter_line_numbers_start_zero",false);
|
||||
mGutterUseCustomFont = boolValue("gutter_use_custom_font",false);
|
||||
mGutterFontName = stringValue("gutter_font_name","consolas");
|
||||
mGutterFontSize = intValue("gutter_font_size",QGuiApplication::font().pointSize());
|
||||
mGutterFontOnlyMonospaced = boolValue("gutter_font_only_monospaced",true);
|
||||
}
|
||||
|
||||
SynEditCaretType Settings::Editor::caretForOverwrite() const
|
||||
|
|
|
@ -133,8 +133,54 @@ public:
|
|||
bool halfPageScroll() const;
|
||||
void setHalfPageScroll(bool halfPageScroll);
|
||||
|
||||
QString fontName() const;
|
||||
void setFontName(const QString &fontName);
|
||||
|
||||
int fontSize() const;
|
||||
void setFontSize(int fontSize);
|
||||
|
||||
bool fontOnlyMonospaced() const;
|
||||
void setFontOnlyMonospaced(bool fontOnlyMonospaced);
|
||||
|
||||
bool gutterVisible() const;
|
||||
void setGutterVisible(bool gutterVisible);
|
||||
|
||||
bool gutterAutoSize() const;
|
||||
void setGutterAutoSize(bool gutterAutoSize);
|
||||
|
||||
int gutterDigitsCount() const;
|
||||
void setGutterDigitsCount(int gutterDigitsCount);
|
||||
|
||||
bool gutterShowLineNumbers() const;
|
||||
void setGutterShowLineNumbers(bool gutterShowLineNumbers);
|
||||
|
||||
bool gutterAddLeadingZero() const;
|
||||
void setGutterAddLeadingZero(bool gutterAddLeadingZero);
|
||||
|
||||
bool gutterLineNumbersStartZero() const;
|
||||
void setGutterLineNumbersStartZero(bool gutterLineNumbersStartZero);
|
||||
|
||||
bool gutterUseCustomFont() const;
|
||||
void setGutterUseCustomFont(bool gutterUseCustomFont);
|
||||
|
||||
QString gutterFontName() const;
|
||||
void setGutterFontName(const QString &gutterFontName);
|
||||
|
||||
int gutterFontSize() const;
|
||||
void setGutterFontSize(int gutterFontSize);
|
||||
|
||||
bool gutterFontOnlyMonospaced() const;
|
||||
void setGutterFontOnlyMonospaced(bool gutterFontOnlyMonospaced);
|
||||
|
||||
int gutterLeftOffset() const;
|
||||
void setGutterLeftOffset(int gutterLeftOffset);
|
||||
|
||||
int gutterRightOffset() const;
|
||||
void setGutterRightOffset(int gutterRightOffset);
|
||||
|
||||
private:
|
||||
QByteArray mDefaultEncoding;
|
||||
//General
|
||||
// indents
|
||||
bool mAutoIndent;
|
||||
bool mAddIndent;
|
||||
|
@ -156,6 +202,26 @@ public:
|
|||
bool mScrollByOneLess;
|
||||
bool mHalfPageScroll;
|
||||
|
||||
//Font
|
||||
//font
|
||||
QString mFontName;
|
||||
int mFontSize;
|
||||
bool mFontOnlyMonospaced;
|
||||
|
||||
//gutter
|
||||
bool mGutterVisible;
|
||||
bool mGutterAutoSize;
|
||||
int mGutterLeftOffset;
|
||||
int mGutterRightOffset;
|
||||
int mGutterDigitsCount;
|
||||
bool mGutterShowLineNumbers;
|
||||
bool mGutterAddLeadingZero;
|
||||
bool mGutterLineNumbersStartZero;
|
||||
bool mGutterUseCustomFont;
|
||||
QString mGutterFontName;
|
||||
int mGutterFontSize;
|
||||
bool mGutterFontOnlyMonospaced;
|
||||
|
||||
// _Base interface
|
||||
protected:
|
||||
void doSave() override;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "editorfontwidget.h"
|
||||
#include "ui_editorfontwidget.h"
|
||||
#include "../settings.h"
|
||||
#include "../mainwindow.h"
|
||||
|
||||
EditorFontWidget::EditorFontWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
|
@ -34,10 +36,48 @@ void EditorFontWidget::on_chkGutterOnlyMonospacedFonts_stateChanged(int)
|
|||
|
||||
void EditorFontWidget::doLoad()
|
||||
{
|
||||
//pSettings->editor().load();
|
||||
//font
|
||||
ui->chkOnlyMonospacedFonts->setChecked(pSettings->editor().fontOnlyMonospaced());
|
||||
ui->cbFont->setCurrentFont(QFont(pSettings->editor().fontName()));
|
||||
ui->spinFontSize->setValue(pSettings->editor().fontSize());
|
||||
|
||||
//gutter
|
||||
ui->chkGutterVisible->setChecked(pSettings->editor().gutterVisible());
|
||||
ui->chkAutoSizeGutter->setChecked(pSettings->editor().gutterAutoSize());
|
||||
ui->spinGutterLeftOffset->setValue(pSettings->editor().gutterLeftOffset());
|
||||
ui->spinGutterRightOffset->setValue(pSettings->editor().gutterRightOffset());
|
||||
ui->spinGutterDigitsCount->setValue(pSettings->editor().gutterDigitsCount());
|
||||
ui->grpGutterShowLineNumbers->setChecked(pSettings->editor().gutterShowLineNumbers());
|
||||
ui->chkAddLeadingZeros->setChecked(pSettings->editor().gutterAddLeadingZero());
|
||||
ui->chkLineNumbersStartsZero->setChecked(pSettings->editor().gutterLineNumbersStartZero());
|
||||
ui->grpUseCustomFont->setChecked(pSettings->editor().gutterUseCustomFont());
|
||||
ui->chkGutterOnlyMonospacedFonts->setChecked(pSettings->editor().gutterFontOnlyMonospaced());
|
||||
ui->cbGutterFont->setCurrentFont(QFont(pSettings->editor().gutterFontName()));
|
||||
ui->spinGutterFontSize->setValue(pSettings->editor().gutterFontSize());
|
||||
}
|
||||
|
||||
void EditorFontWidget::doSave()
|
||||
{
|
||||
//font
|
||||
pSettings->editor().setFontOnlyMonospaced(ui->chkOnlyMonospacedFonts->isChecked());
|
||||
pSettings->editor().setFontName(ui->cbFont->currentFont().family());
|
||||
pSettings->editor().setFontSize(ui->spinFontSize->value());
|
||||
|
||||
//gutter
|
||||
pSettings->editor().setGutterVisible(ui->chkGutterVisible->isChecked());
|
||||
pSettings->editor().setGutterAutoSize(ui->chkAutoSizeGutter->isChecked());
|
||||
pSettings->editor().setGutterLeftOffset(ui->spinGutterLeftOffset->value());
|
||||
pSettings->editor().setGutterRightOffset(ui->spinGutterRightOffset->value());
|
||||
pSettings->editor().setGutterDigitsCount(ui->spinGutterDigitsCount->value());
|
||||
pSettings->editor().setGutterShowLineNumbers(ui->grpGutterShowLineNumbers->isChecked());
|
||||
pSettings->editor().setGutterAddLeadingZero(ui->chkAddLeadingZeros->isChecked());
|
||||
pSettings->editor().setGutterLineNumbersStartZero(ui->chkLineNumbersStartsZero->isChecked());
|
||||
pSettings->editor().setGutterUseCustomFont(ui->grpUseCustomFont->isChecked());
|
||||
pSettings->editor().setGutterFontOnlyMonospaced(ui->chkGutterOnlyMonospacedFonts->isChecked());
|
||||
pSettings->editor().setGutterFontName(ui->cbGutterFont->currentFont().family());
|
||||
pSettings->editor().setGutterFontSize(ui->spinGutterFontSize->value());
|
||||
|
||||
pSettings->editor().save();
|
||||
pMainWindow->updateEditorSettings();
|
||||
}
|
||||
|
|
|
@ -143,15 +143,8 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAutoSizeGutter">
|
||||
<property name="text">
|
||||
<string>Auto size the gutter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<widget class="QWidget" name="widget_8" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -165,16 +158,16 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>base width</string>
|
||||
<string>Left Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinGutterBaseWidth">
|
||||
<widget class="QSpinBox" name="spinGutterLeftOffset">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
|
@ -182,7 +175,24 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Right Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinGutterRightOffset">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -220,6 +230,61 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAutoSizeGutter">
|
||||
<property name="text">
|
||||
<string>Auto calculate the digit count of line number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Digit count</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinGutterDigitsCount">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -82,6 +82,6 @@ void EditorGeneralWidget::doSave()
|
|||
pSettings->editor().setScrollByOneLess(ui->chkScrollByOneLess->isChecked());
|
||||
pSettings->editor().setHalfPageScroll(ui->chkScrollHalfPage->isChecked());
|
||||
|
||||
pSettings->editor().save();
|
||||
//pSettings->editor().save();
|
||||
pMainWindow->updateEditorSettings();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>721</width>
|
||||
<height>691</height>
|
||||
<height>700</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
Loading…
Reference in New Issue