parent
b0e56f873f
commit
b1e2b9d61b
|
@ -164,8 +164,7 @@ void Highlighter::highlightBlock(const QString &text)
|
|||
|
||||
void Highlighter::applyFormat(HighlightingRule &rule)
|
||||
{
|
||||
switch( rule.ruleRole )
|
||||
{
|
||||
switch (rule.ruleRole) {
|
||||
case RuleRole::Keyword:
|
||||
rule.format = mKeywordFormat;
|
||||
break;
|
||||
|
|
|
@ -87,19 +87,16 @@ CodeEditorStyle CodeEditorStyle::loadSettings( QSettings *settings )
|
|||
SETTINGS_STYLE_TYPE,
|
||||
QVariant(SETTINGS_STYLE_TYPE_LIGHT)
|
||||
).toString();
|
||||
if( type == SETTINGS_STYLE_TYPE_LIGHT )
|
||||
{
|
||||
if (type == SETTINGS_STYLE_TYPE_LIGHT) {
|
||||
settings->endGroup();
|
||||
return theStyle;
|
||||
}
|
||||
if( type == SETTINGS_STYLE_TYPE_DARK )
|
||||
{
|
||||
if (type == SETTINGS_STYLE_TYPE_DARK) {
|
||||
theStyle = defaultStyleDark;
|
||||
settings->endGroup();
|
||||
return theStyle;
|
||||
}
|
||||
if( type == SETTINGS_STYLE_TYPE_CUSTOM )
|
||||
{
|
||||
if (type == SETTINGS_STYLE_TYPE_CUSTOM) {
|
||||
theStyle.widgetFGColor = settings->value(
|
||||
SETTINGS_STYLE_WIDGETFG,
|
||||
QVariant(defaultStyleLight.widgetFGColor)).value<QColor>();
|
||||
|
@ -158,8 +155,7 @@ void CodeEditorStyle::saveSettings( QSettings *settings,
|
|||
{
|
||||
if (!settings) return;
|
||||
|
||||
if( settings->childGroups().contains( SETTINGS_STYLE_GROUP ))
|
||||
{
|
||||
if (settings->childGroups().contains(SETTINGS_STYLE_GROUP)) {
|
||||
settings->remove(SETTINGS_STYLE_GROUP);
|
||||
}
|
||||
|
||||
|
@ -169,12 +165,10 @@ void CodeEditorStyle::saveSettings( QSettings *settings,
|
|||
if (isDefaultLight && !isDefaultDark) {
|
||||
settings->setValue(SETTINGS_STYLE_TYPE,
|
||||
SETTINGS_STYLE_TYPE_LIGHT);
|
||||
}
|
||||
else if( !isDefaultLight && isDefaultDark ) {
|
||||
} else if (!isDefaultLight && isDefaultDark) {
|
||||
settings->setValue(SETTINGS_STYLE_TYPE,
|
||||
SETTINGS_STYLE_TYPE_DARK);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
settings->setValue(SETTINGS_STYLE_TYPE,
|
||||
SETTINGS_STYLE_TYPE_CUSTOM);
|
||||
settings->setValue(SETTINGS_STYLE_WIDGETFG,
|
||||
|
|
|
@ -27,7 +27,8 @@ SelectColorButton::SelectColorButton( QWidget* parent ) :
|
|||
connect(this, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
}
|
||||
|
||||
void SelectColorButton::updateColor() {
|
||||
void SelectColorButton::updateColor()
|
||||
{
|
||||
QString btnColorStyle = QString(
|
||||
"background-color:rgb(%1,%2,%3);"
|
||||
"border-style:outset;"
|
||||
|
@ -39,23 +40,25 @@ void SelectColorButton::updateColor() {
|
|||
setStyleSheet(btnColorStyle);
|
||||
}
|
||||
|
||||
void SelectColorButton::changeColor() {
|
||||
void SelectColorButton::changeColor()
|
||||
{
|
||||
QColorDialog pDlg(mColor);
|
||||
pDlg.setModal(true);
|
||||
int nResult = pDlg.exec();
|
||||
if (nResult == QDialog::Accepted )
|
||||
{
|
||||
if (nResult == QDialog::Accepted) {
|
||||
setColor(pDlg.selectedColor());
|
||||
emit colorChanged(mColor);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectColorButton::setColor( const QColor& color ) {
|
||||
void SelectColorButton::setColor(const QColor& color)
|
||||
{
|
||||
mColor = color;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
const QColor& SelectColorButton::getColor() {
|
||||
const QColor& SelectColorButton::getColor()
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
|
@ -86,29 +89,32 @@ SelectFontWeightCombo::SelectFontWeightCombo( QWidget* parent ) :
|
|||
this, SLOT(changeWeight(int)));
|
||||
}
|
||||
|
||||
void SelectFontWeightCombo::updateWeight() {
|
||||
void SelectFontWeightCombo::updateWeight()
|
||||
{
|
||||
int nResult = findData(QVariant(static_cast<int>(mWeight)));
|
||||
|
||||
if (nResult != -1) {
|
||||
setCurrentIndex(nResult);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setCurrentIndex(findData(static_cast<int>(QFont::Normal)));
|
||||
}
|
||||
}
|
||||
|
||||
void SelectFontWeightCombo::changeWeight( int index ) {
|
||||
void SelectFontWeightCombo::changeWeight(int index)
|
||||
{
|
||||
if (index != -1) {
|
||||
setWeight(static_cast<QFont::Weight>(itemData(index).toInt()));
|
||||
emit weightChanged(mWeight);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectFontWeightCombo::setWeight( const QFont::Weight& weight ) {
|
||||
void SelectFontWeightCombo::setWeight(const QFont::Weight& weight)
|
||||
{
|
||||
mWeight = weight;
|
||||
updateWeight();
|
||||
}
|
||||
|
||||
const QFont::Weight& SelectFontWeightCombo::getWeight() {
|
||||
const QFont::Weight& SelectFontWeightCombo::getWeight()
|
||||
{
|
||||
return mWeight;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
class SelectColorButton : public QPushButton
|
||||
{
|
||||
class SelectColorButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SelectColorButton(QWidget* parent);
|
||||
|
@ -49,8 +48,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class SelectFontWeightCombo : public QComboBox
|
||||
{
|
||||
class SelectFontWeightCombo : public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SelectFontWeightCombo(QWidget* parent);
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
#include "codeeditor.h"
|
||||
#include "codeeditorstyle.h"
|
||||
|
||||
class StyleEditDialog : public QDialog
|
||||
{
|
||||
class StyleEditDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StyleEditDialog(const CodeEditorStyle& newStyle,
|
||||
|
|
|
@ -340,8 +340,7 @@ void SettingsDialog::editCodeEditorStyle()
|
|||
{
|
||||
StyleEditDialog pDlg(*mCurrentStyle, this);
|
||||
int nResult = pDlg.exec();
|
||||
if( nResult == QDialog::Accepted )
|
||||
{
|
||||
if (nResult == QDialog::Accepted) {
|
||||
*mCurrentStyle = pDlg.getStyle();
|
||||
manageStyleControls();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue