- 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/editorcodecompletionwidget.cpp \
settingsdialog/editormiscwidget.cpp \ settingsdialog/editormiscwidget.cpp \
settingsdialog/formattergeneralwidget.cpp \ settingsdialog/formattergeneralwidget.cpp \
settingsdialog/projectcompileparamaterswidget.cpp \
settingsdialog/projectcompilerwidget.cpp \ settingsdialog/projectcompilerwidget.cpp \
settingsdialog/projectfileswidget.cpp \ settingsdialog/projectfileswidget.cpp \
settingsdialog/projectgeneralwidget.cpp \ settingsdialog/projectgeneralwidget.cpp \
@ -128,6 +129,7 @@ HEADERS += \
settingsdialog/editorcodecompletionwidget.h \ settingsdialog/editorcodecompletionwidget.h \
settingsdialog/editormiscwidget.h \ settingsdialog/editormiscwidget.h \
settingsdialog/formattergeneralwidget.h \ settingsdialog/formattergeneralwidget.h \
settingsdialog/projectcompileparamaterswidget.h \
settingsdialog/projectcompilerwidget.h \ settingsdialog/projectcompilerwidget.h \
settingsdialog/projectfileswidget.h \ settingsdialog/projectfileswidget.h \
settingsdialog/projectgeneralwidget.h \ settingsdialog/projectgeneralwidget.h \
@ -189,6 +191,7 @@ FORMS += \
settingsdialog/editorcodecompletionwidget.ui \ settingsdialog/editorcodecompletionwidget.ui \
settingsdialog/editormiscwidget.ui \ settingsdialog/editormiscwidget.ui \
settingsdialog/formattergeneralwidget.ui \ settingsdialog/formattergeneralwidget.ui \
settingsdialog/projectcompileparamaterswidget.ui \
settingsdialog/projectcompilerwidget.ui \ settingsdialog/projectcompilerwidget.ui \
settingsdialog/projectfileswidget.ui \ settingsdialog/projectfileswidget.ui \
settingsdialog/projectgeneralwidget.ui \ settingsdialog/projectgeneralwidget.ui \

View File

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

View File

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

View File

@ -276,7 +276,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="tabIssues"> <widget class="QWidget" name="tabIssues">
<attribute name="icon"> <attribute name="icon">
@ -762,16 +762,6 @@
</item> </item>
</layout> </layout>
</widget> </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>
</widget> </widget>
</item> </item>

View File

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

View File

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

View File

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

View File

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

View File

@ -95,3 +95,17 @@ void EditorGeneralWidget::doSave()
pSettings->editor().save(); pSettings->editor().save();
pMainWindow->updateEditorSettings(); 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: protected:
void doLoad() override; void doLoad() override;
void doSave() override; void doSave() override;
private slots:
void on_chkCaretUseTextColor_stateChanged(int arg1);
void on_chkShowIndentLines_stateChanged(int arg1);
}; };
#endif // EDITORGENERALWIDGET_H #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: private:
PProjectUnit currentUnit(); PProjectUnit currentUnit();
void copyUnits(); void copyUnits();
void disableFileOptions();
private slots: private slots:
void on_treeProject_doubleClicked(const QModelIndex &index); void on_treeProject_doubleClicked(const QModelIndex &index);
void on_spinPriority_valueChanged(int arg1); void on_spinPriority_valueChanged(int arg1);