- fix: caret color error when turn on option "caret use text color"

- show / hide some options depends on other options state
This commit is contained in:
royqh1979@gmail.com 2021-09-15 14:35:37 +08:00
parent 0cebe9a6a5
commit 14c83ab829
14 changed files with 199 additions and 26 deletions

View File

@ -43,6 +43,7 @@ SOURCES += \
settingsdialog/editorcodecompletionwidget.cpp \
settingsdialog/editormiscwidget.cpp \
settingsdialog/formattergeneralwidget.cpp \
settingsdialog/projectcompileparamaterswidget.cpp \
settingsdialog/projectcompilerwidget.cpp \
settingsdialog/projectfileswidget.cpp \
settingsdialog/projectgeneralwidget.cpp \
@ -128,6 +129,7 @@ HEADERS += \
settingsdialog/editorcodecompletionwidget.h \
settingsdialog/editormiscwidget.h \
settingsdialog/formattergeneralwidget.h \
settingsdialog/projectcompileparamaterswidget.h \
settingsdialog/projectcompilerwidget.h \
settingsdialog/projectfileswidget.h \
settingsdialog/projectgeneralwidget.h \
@ -189,6 +191,7 @@ FORMS += \
settingsdialog/editorcodecompletionwidget.ui \
settingsdialog/editormiscwidget.ui \
settingsdialog/formattergeneralwidget.ui \
settingsdialog/projectcompileparamaterswidget.ui \
settingsdialog/projectcompilerwidget.ui \
settingsdialog/projectfileswidget.ui \
settingsdialog/projectgeneralwidget.ui \

View File

@ -2677,11 +2677,8 @@ void Editor::applySettings()
setTabWidth(pSettings->editor().tabWidth());
setInsertCaret(pSettings->editor().caretForInsert());
setOverwriteCaret(pSettings->editor().caretForOverwrite());
if (pSettings->editor().caretUseTextColor()) {
setCaretColor(palette().color(QPalette::Text));
} else {
setCaretColor(pSettings->editor().caretColor());
}
setCaretUseTextColor(pSettings->editor().caretUseTextColor());
setCaretColor(pSettings->editor().caretColor());
QFont f=QFont(pSettings->editor().fontName(),pSettings->editor().fontSize());
f.setStyleStrategy(QFont::PreferAntialias);

View File

@ -1190,8 +1190,6 @@ void MainWindow::openCloseBottomPanel(bool open)
mBottomPanelOpenned = open;
QSplitterHandle* handle = ui->splitterMessages->handle(1);
handle->setEnabled(open);
int idxClose = ui->tabMessages->indexOf(ui->tabClose);
ui->tabMessages->setTabVisible(idxClose,open);
}
void MainWindow::openCloseLeftPanel(bool open)
@ -2244,12 +2242,7 @@ void MainWindow::on_tabMessages_tabBarClicked(int index)
void MainWindow::on_tabMessages_currentChanged(int index)
{
int idxClose = ui->tabMessages->indexOf(ui->tabClose);
if (index == idxClose) {
openCloseBottomPanel(false);
} else {
openCloseBottomPanel(true);
}
openCloseBottomPanel(true);
}
void MainWindow::on_tabMessages_tabBarDoubleClicked(int index)

View File

@ -276,7 +276,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<widget class="QWidget" name="tabIssues">
<attribute name="icon">
@ -762,16 +762,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabClose">
<attribute name="icon">
<iconset>
<normalon>:/icons/images/newlook24/008-close.png</normalon>
</iconset>
</attribute>
<attribute name="title">
<string>Close</string>
</attribute>
</widget>
</widget>
</widget>
</item>

View File

@ -266,6 +266,7 @@ Editor *Project::openUnit(int index)
Editor * editor = pMainWindow->editorList()->getOpenedEditorByFilename(fullPath);
if (editor) {//already opened in the editors
editor->setInProject(true);
editor->activate();
return editor;
}
QByteArray encoding;
@ -274,6 +275,7 @@ Editor *Project::openUnit(int index)
editor->setInProject(true);
unit->setEditor(editor);
unit->setEncoding(encoding);
editor->activate();
loadUnitLayout(editor,index);
return editor;
}

View File

@ -53,6 +53,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mOrigRedoList = mRedoList;
mCaretColor = QColorConstants::Red;
mCaretUseTextColor = false;
mActiveLineColor = QColorConstants::Svg::lightblue;
mSelectedBackground = palette().color(QPalette::Highlight);
mSelectedForeground = palette().color(QPalette::HighlightedText);
@ -3163,7 +3164,11 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
} else {
ct =mOverwriteCaret;
}
painter.setPen(mCaretColor);
if (mCaretUseTextColor) {
painter.setPen(palette().color(QPalette::Text));
} else {
painter.setPen(mCaretColor);
}
switch(ct) {
case SynEditCaretType::ctVerticalLine:
painter.drawLine(rcClip.left()+1,rcClip.top(),rcClip.left()+1,rcClip.bottom());
@ -3244,6 +3249,16 @@ void SynEdit::onScrolled(int)
invalidate();
}
bool SynEdit::caretUseTextColor() const
{
return mCaretUseTextColor;
}
void SynEdit::setCaretUseTextColor(bool newCaretUseTextColor)
{
mCaretUseTextColor = newCaretUseTextColor;
}
const QColor &SynEdit::rightEdgeColor() const
{
return mRightEdgeColor;

View File

@ -348,6 +348,9 @@ public:
const QColor &rightEdgeColor() const;
void setRightEdgeColor(const QColor &newRightEdgeColor);
bool caretUseTextColor() const;
void setCaretUseTextColor(bool newCaretUseTextColor);
signals:
void linesDeleted(int FirstLine, int Count);
void linesInserted(int FirstLine, int Count);
@ -573,6 +576,7 @@ private:
QColor mSelectedForeground;
QColor mSelectedBackground;
QColor mCaretColor;
bool mCaretUseTextColor;
QColor mActiveLineColor;
PSynEditUndoList mUndoList;
PSynEditUndoList mRedoList;

View File

@ -802,7 +802,7 @@ void SynEditTextPainter::PaintLines()
rcToken.setLeft(std::max(rcLine.left(), ColumnToXValue(nLineSelEnd)));
rcToken.setRight(std::min(rcLine.right(), ColumnToXValue(LastCol)));
PaintToken(sToken, nTokenColumnLen, 0, nLineSelEnd, LastCol,true);
setDrawingColors(false);
setDrawingColors(true);
rcToken.setLeft(std::max(rcLine.left(), ColumnToXValue(nLineSelStart)));
rcToken.setRight(std::min(rcLine.right(), ColumnToXValue(nLineSelEnd)));
PaintToken(sToken, nTokenColumnLen, 0, nLineSelStart, nLineSelEnd - 1,false);

View File

@ -95,3 +95,17 @@ void EditorGeneralWidget::doSave()
pSettings->editor().save();
pMainWindow->updateEditorSettings();
}
void EditorGeneralWidget::on_chkCaretUseTextColor_stateChanged(int )
{
ui->lbCaretColor->setVisible(!ui->chkCaretUseTextColor->isChecked());
ui->colorCaret->setVisible(!ui->chkCaretUseTextColor->isChecked());
}
void EditorGeneralWidget::on_chkShowIndentLines_stateChanged(int)
{
ui->lbIndentLineColor->setVisible(ui->chkShowIndentLines->isChecked());
ui->colorIndentLine->setVisible(ui->chkShowIndentLines->isChecked());
}

View File

@ -23,6 +23,9 @@ private:
protected:
void doLoad() override;
void doSave() override;
private slots:
void on_chkCaretUseTextColor_stateChanged(int arg1);
void on_chkShowIndentLines_stateChanged(int arg1);
};
#endif // EDITORGENERALWIDGET_H

View File

@ -0,0 +1,14 @@
#include "projectcompileparamaterswidget.h"
#include "ui_projectcompileparamaterswidget.h"
ProjectCompileParamatersWidget::ProjectCompileParamatersWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ProjectCompileParamatersWidget)
{
ui->setupUi(this);
}
ProjectCompileParamatersWidget::~ProjectCompileParamatersWidget()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef PROJECTCOMPILEPARAMATERSWIDGET_H
#define PROJECTCOMPILEPARAMATERSWIDGET_H
#include <QWidget>
namespace Ui {
class ProjectCompileParamatersWidget;
}
class ProjectCompileParamatersWidget : public QWidget
{
Q_OBJECT
public:
explicit ProjectCompileParamatersWidget(QWidget *parent = nullptr);
~ProjectCompileParamatersWidget();
private:
Ui::ProjectCompileParamatersWidget *ui;
};
#endif // PROJECTCOMPILEPARAMATERSWIDGET_H

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectCompileParamatersWidget</class>
<widget class="QWidget" name="ProjectCompileParamatersWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>675</width>
<height>447</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chkAddCharset">
<property name="text">
<string>Add encoding options to compiler</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkStaticLink">
<property name="text">
<string>Statically link libraries</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Additional build options:</string>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="txtLinker">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>C Compiler</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QPlainTextEdit" name="txtCCompiler"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>C++ Compiler</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QPlainTextEdit" name="txtCPPCompiler"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Linker</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QPlainTextEdit" name="txtCCompiler_3"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -29,6 +29,7 @@ protected:
private:
PProjectUnit currentUnit();
void copyUnits();
void disableFileOptions();
private slots:
void on_treeProject_doubleClicked(const QModelIndex &index);
void on_spinPriority_valueChanged(int arg1);