astyle formatting

[ci skip]
This commit is contained in:
versat 2019-06-25 15:29:15 +02:00
parent b0e56f873f
commit b1e2b9d61b
12 changed files with 471 additions and 476 deletions

View File

@ -164,8 +164,7 @@ void Highlighter::highlightBlock(const QString &text)
void Highlighter::applyFormat(HighlightingRule &rule) void Highlighter::applyFormat(HighlightingRule &rule)
{ {
switch( rule.ruleRole ) switch (rule.ruleRole) {
{
case RuleRole::Keyword: case RuleRole::Keyword:
rule.format = mKeywordFormat; rule.format = mKeywordFormat;
break; break;

View File

@ -87,19 +87,16 @@ CodeEditorStyle CodeEditorStyle::loadSettings( QSettings *settings )
SETTINGS_STYLE_TYPE, SETTINGS_STYLE_TYPE,
QVariant(SETTINGS_STYLE_TYPE_LIGHT) QVariant(SETTINGS_STYLE_TYPE_LIGHT)
).toString(); ).toString();
if( type == SETTINGS_STYLE_TYPE_LIGHT ) if (type == SETTINGS_STYLE_TYPE_LIGHT) {
{
settings->endGroup(); settings->endGroup();
return theStyle; return theStyle;
} }
if( type == SETTINGS_STYLE_TYPE_DARK ) if (type == SETTINGS_STYLE_TYPE_DARK) {
{
theStyle = defaultStyleDark; theStyle = defaultStyleDark;
settings->endGroup(); settings->endGroup();
return theStyle; return theStyle;
} }
if( type == SETTINGS_STYLE_TYPE_CUSTOM ) if (type == SETTINGS_STYLE_TYPE_CUSTOM) {
{
theStyle.widgetFGColor = settings->value( theStyle.widgetFGColor = settings->value(
SETTINGS_STYLE_WIDGETFG, SETTINGS_STYLE_WIDGETFG,
QVariant(defaultStyleLight.widgetFGColor)).value<QColor>(); QVariant(defaultStyleLight.widgetFGColor)).value<QColor>();
@ -158,8 +155,7 @@ void CodeEditorStyle::saveSettings( QSettings *settings,
{ {
if (!settings) return; if (!settings) return;
if( settings->childGroups().contains( SETTINGS_STYLE_GROUP )) if (settings->childGroups().contains(SETTINGS_STYLE_GROUP)) {
{
settings->remove(SETTINGS_STYLE_GROUP); settings->remove(SETTINGS_STYLE_GROUP);
} }
@ -169,12 +165,10 @@ void CodeEditorStyle::saveSettings( QSettings *settings,
if (isDefaultLight && !isDefaultDark) { if (isDefaultLight && !isDefaultDark) {
settings->setValue(SETTINGS_STYLE_TYPE, settings->setValue(SETTINGS_STYLE_TYPE,
SETTINGS_STYLE_TYPE_LIGHT); SETTINGS_STYLE_TYPE_LIGHT);
} } else if (!isDefaultLight && isDefaultDark) {
else if( !isDefaultLight && isDefaultDark ) {
settings->setValue(SETTINGS_STYLE_TYPE, settings->setValue(SETTINGS_STYLE_TYPE,
SETTINGS_STYLE_TYPE_DARK); SETTINGS_STYLE_TYPE_DARK);
} } else {
else {
settings->setValue(SETTINGS_STYLE_TYPE, settings->setValue(SETTINGS_STYLE_TYPE,
SETTINGS_STYLE_TYPE_CUSTOM); SETTINGS_STYLE_TYPE_CUSTOM);
settings->setValue(SETTINGS_STYLE_WIDGETFG, settings->setValue(SETTINGS_STYLE_WIDGETFG,

View File

@ -27,7 +27,8 @@ SelectColorButton::SelectColorButton( QWidget* parent ) :
connect(this, SIGNAL(clicked()), this, SLOT(changeColor())); connect(this, SIGNAL(clicked()), this, SLOT(changeColor()));
} }
void SelectColorButton::updateColor() { void SelectColorButton::updateColor()
{
QString btnColorStyle = QString( QString btnColorStyle = QString(
"background-color:rgb(%1,%2,%3);" "background-color:rgb(%1,%2,%3);"
"border-style:outset;" "border-style:outset;"
@ -39,23 +40,25 @@ void SelectColorButton::updateColor() {
setStyleSheet(btnColorStyle); setStyleSheet(btnColorStyle);
} }
void SelectColorButton::changeColor() { void SelectColorButton::changeColor()
{
QColorDialog pDlg(mColor); QColorDialog pDlg(mColor);
pDlg.setModal(true); pDlg.setModal(true);
int nResult = pDlg.exec(); int nResult = pDlg.exec();
if (nResult == QDialog::Accepted ) if (nResult == QDialog::Accepted) {
{
setColor(pDlg.selectedColor()); setColor(pDlg.selectedColor());
emit colorChanged(mColor); emit colorChanged(mColor);
} }
} }
void SelectColorButton::setColor( const QColor& color ) { void SelectColorButton::setColor(const QColor& color)
{
mColor = color; mColor = color;
updateColor(); updateColor();
} }
const QColor& SelectColorButton::getColor() { const QColor& SelectColorButton::getColor()
{
return mColor; return mColor;
} }
@ -86,29 +89,32 @@ SelectFontWeightCombo::SelectFontWeightCombo( QWidget* parent ) :
this, SLOT(changeWeight(int))); this, SLOT(changeWeight(int)));
} }
void SelectFontWeightCombo::updateWeight() { void SelectFontWeightCombo::updateWeight()
{
int nResult = findData(QVariant(static_cast<int>(mWeight))); int nResult = findData(QVariant(static_cast<int>(mWeight)));
if (nResult != -1) { if (nResult != -1) {
setCurrentIndex(nResult); setCurrentIndex(nResult);
} } else {
else {
setCurrentIndex(findData(static_cast<int>(QFont::Normal))); setCurrentIndex(findData(static_cast<int>(QFont::Normal)));
} }
} }
void SelectFontWeightCombo::changeWeight( int index ) { void SelectFontWeightCombo::changeWeight(int index)
{
if (index != -1) { if (index != -1) {
setWeight(static_cast<QFont::Weight>(itemData(index).toInt())); setWeight(static_cast<QFont::Weight>(itemData(index).toInt()));
emit weightChanged(mWeight); emit weightChanged(mWeight);
} }
} }
void SelectFontWeightCombo::setWeight( const QFont::Weight& weight ) { void SelectFontWeightCombo::setWeight(const QFont::Weight& weight)
{
mWeight = weight; mWeight = weight;
updateWeight(); updateWeight();
} }
const QFont::Weight& SelectFontWeightCombo::getWeight() { const QFont::Weight& SelectFontWeightCombo::getWeight()
{
return mWeight; return mWeight;
} }

View File

@ -27,8 +27,7 @@
#include <QColor> #include <QColor>
#include <QFont> #include <QFont>
class SelectColorButton : public QPushButton class SelectColorButton : public QPushButton {
{
Q_OBJECT Q_OBJECT
public: public:
explicit SelectColorButton(QWidget* parent); explicit SelectColorButton(QWidget* parent);
@ -49,8 +48,7 @@ private:
}; };
class SelectFontWeightCombo : public QComboBox class SelectFontWeightCombo : public QComboBox {
{
Q_OBJECT Q_OBJECT
public: public:
explicit SelectFontWeightCombo(QWidget* parent); explicit SelectFontWeightCombo(QWidget* parent);

View File

@ -25,8 +25,7 @@
#include "codeeditor.h" #include "codeeditor.h"
#include "codeeditorstyle.h" #include "codeeditorstyle.h"
class StyleEditDialog : public QDialog class StyleEditDialog : public QDialog {
{
Q_OBJECT Q_OBJECT
public: public:
explicit StyleEditDialog(const CodeEditorStyle& newStyle, explicit StyleEditDialog(const CodeEditorStyle& newStyle,

View File

@ -340,8 +340,7 @@ void SettingsDialog::editCodeEditorStyle()
{ {
StyleEditDialog pDlg(*mCurrentStyle, this); StyleEditDialog pDlg(*mCurrentStyle, this);
int nResult = pDlg.exec(); int nResult = pDlg.exec();
if( nResult == QDialog::Accepted ) if (nResult == QDialog::Accepted) {
{
*mCurrentStyle = pDlg.getStyle(); *mCurrentStyle = pDlg.getStyle();
manageStyleControls(); manageStyleControls();
} }