Skip to content

Commit

Permalink
Added a configuration option of custom tab width in GeneralConfigWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
rkhaotix committed Sep 1, 2015
1 parent f47ce5a commit c557690
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 12 deletions.
1 change: 1 addition & 0 deletions conf/defaults/pgmodeler.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
hide-ext-attribs="false"
code-font="DejaVu Sans Mono"
code-font-size="10"
code-tab-width="4"
canvas-corner-move="true"
invert-panning-rangesel="false"
check-update="true"
Expand Down
1 change: 1 addition & 0 deletions conf/dtd/pgmodeler.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<!ATTLIST configuration line-numbers-color CDATA #IMPLIED>
<!ATTLIST configuration line-numbers-bg-color CDATA #IMPLIED>
<!ATTLIST configuration line-highlight-color CDATA #IMPLIED>
<!ATTLIST configuration code-tab-width CDATA #IMPLIED>

<!ELEMENT session (file+)>
<!ELEMENT recent-models (file+)>
Expand Down
1 change: 1 addition & 0 deletions conf/pgmodeler.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
hide-ext-attribs="false"
code-font="DejaVu Sans Mono"
code-font-size="10"
code-tab-width="4"
canvas-corner-move="true"
invert-panning-rangesel="false"
check-update="true"
Expand Down
1 change: 1 addition & 0 deletions conf/schemas/pgmodeler.sch
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $sp [<configuration op-list-size="] {op-list-size} ["] $br
[ hide-table-tags="] %if {hide-table-tags} %then true %else false %end ["] $br
[ code-font="] {code-font} ["] $br
[ code-font-size="] {code-font-size} ["] $br
[ code-tab-width="] {code-tab-width} ["] $br
[ canvas-corner-move="] %if {canvas-corner-move} %then true %else false %end ["] $br
[ invert-panning-rangesel="] %if {invert-panning-rangesel} %then true %else false %end ["] $br
[ check-update="] %if {check-update} %then true %else false %end ["] $br
Expand Down
1 change: 1 addition & 0 deletions libparsers/src/parsersattributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace ParsersAttributes {
CODE_COMPLETION=QString("code-completion"),
CODE_FONT_SIZE=QString("code-font-size"),
CODE_FONT=QString("code-font"),
CODE_TAB_WIDTH=QString("code-tab-width"),
COL_INDEXES=QString("col-indexes"),
COLLATABLE=QString("collatable"),
COLLATION=QString("collation"),
Expand Down
1 change: 1 addition & 0 deletions libparsers/src/parsersattributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace ParsersAttributes {
CODE_COMPLETION,
CODE_FONT_SIZE,
CODE_FONT,
CODE_TAB_WIDTH,
COL_INDEXES,
COLLATABLE,
COLLATION,
Expand Down
25 changes: 17 additions & 8 deletions libpgmodeler_ui/src/generalconfigwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ GeneralConfigWidget::GeneralConfigWidget(QWidget * parent) : BaseConfigWidget(pa

connect(disp_line_numbers_chk, SIGNAL(toggled(bool)), this, SLOT(updateFontPreview()));
connect(hightlight_lines_chk, SIGNAL(toggled(bool)), this, SLOT(updateFontPreview()));
connect(tab_size_spb, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
connect(tab_size_chk, SIGNAL(toggled(bool)), this, SLOT(updateFontPreview()));
connect(tab_size_chk, SIGNAL(toggled(bool)), tab_size_spb, SLOT(setEnabled(bool)));
connect(tab_width_spb, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
connect(tab_width_chk, SIGNAL(toggled(bool)), tab_width_spb, SLOT(setEnabled(bool)));
connect(tab_width_chk, SIGNAL(toggled(bool)), this, SLOT(updateFontPreview()));

config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::GRID_SIZE]=QString();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::OP_LIST_SIZE]=QString();
Expand Down Expand Up @@ -200,6 +200,7 @@ void GeneralConfigWidget::loadConfiguration(void)
QStringList margin, custom_size;
vector<QString> key_attribs;
unsigned interv=0;
int tab_width=0;

for(QWidget *wgt : child_wgts)
wgt->blockSignals(true);
Expand All @@ -211,9 +212,16 @@ void GeneralConfigWidget::loadConfiguration(void)
oplist_size_spb->setValue((config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::OP_LIST_SIZE]).toUInt());

interv=(config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::AUTOSAVE_INTERVAL]).toUInt();
tab_width=(config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CODE_TAB_WIDTH]).toInt();

autosave_interv_chk->setChecked(interv > 0);
autosave_interv_spb->setValue(interv);
autosave_interv_spb->setEnabled(autosave_interv_chk->isChecked());

tab_width_chk->setChecked(tab_width > 0);
tab_width_spb->setEnabled(tab_width_chk->isChecked());
tab_width_spb->setValue(tab_width);

corner_move_chk->setChecked(config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CANVAS_CORNER_MOVE]==ParsersAttributes::_TRUE_);
invert_pan_range_chk->setChecked(config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::INVERT_PANNING_RANGESEL]==ParsersAttributes::_TRUE_);
check_upd_chk->setChecked(config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CHECK_UPDATE]==ParsersAttributes::_TRUE_);
Expand Down Expand Up @@ -326,10 +334,10 @@ void GeneralConfigWidget::saveConfiguration(void)
ParsersAttributes::WIDGET +
GlobalAttributes::SCHEMA_EXT;

config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::GRID_SIZE]=QString("%1").arg(grid_size_spb->value());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::OP_LIST_SIZE]=QString("%1").arg(oplist_size_spb->value());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::AUTOSAVE_INTERVAL]=QString("%1").arg(autosave_interv_chk->isChecked() ? autosave_interv_spb->value() : 0);
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::PAPER_TYPE]=QString("%1").arg(paper_cmb->currentIndex());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::GRID_SIZE]=QString::number(grid_size_spb->value());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::OP_LIST_SIZE]=QString::number(oplist_size_spb->value());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::AUTOSAVE_INTERVAL]=QString::number(autosave_interv_chk->isChecked() ? autosave_interv_spb->value() : 0);
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::PAPER_TYPE]=QString::number(paper_cmb->currentIndex());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::PAPER_ORIENTATION]=(portrait_rb->isChecked() ? ParsersAttributes::PORTRAIT : ParsersAttributes::LANDSCAPE);
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CANVAS_CORNER_MOVE]=(corner_move_chk->isChecked() ? ParsersAttributes::_TRUE_ : QString());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::INVERT_PANNING_RANGESEL]=(invert_pan_range_chk->isChecked() ? ParsersAttributes::_TRUE_ : QString());
Expand All @@ -339,6 +347,7 @@ void GeneralConfigWidget::saveConfiguration(void)
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::SIMPLIFIED_OBJ_CREATION]=(simple_obj_creation_chk->isChecked() ? ParsersAttributes::_TRUE_ : QString());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CONFIRM_VALIDATION]=(confirm_validation_chk->isChecked() ? ParsersAttributes::_TRUE_ : QString());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CODE_COMPLETION]=(code_completion_chk->isChecked() ? ParsersAttributes::_TRUE_ : QString());
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::CODE_TAB_WIDTH]=QString::number(tab_width_chk->isChecked() ? tab_width_spb->value() : 0);

unity_cmb->setCurrentIndex(UNIT_MILIMETERS);
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::PAPER_MARGIN]=QString("%1,%2,%3,%4").arg(left_marg->value())
Expand Down Expand Up @@ -497,7 +506,7 @@ void GeneralConfigWidget::updateFontPreview(void)
NumberedTextEditor::setLineNumbersVisible(disp_line_numbers_chk->isChecked());
NumberedTextEditor::setLineHighlightColor(line_highlight_cp->getColor(0));
NumberedTextEditor::setHighlightLines(hightlight_lines_chk->isChecked());
NumberedTextEditor::setTabWidth(tab_size_chk->isChecked() ? tab_size_spb->value() : 0);
NumberedTextEditor::setTabWidth(tab_width_chk->isChecked() ? tab_width_spb->value() : 0);
LineNumbersWidget::setColors(line_numbers_cp->getColor(0), line_numbers_bg_cp->getColor(0));

font_preview_txt->updateLineNumbersSize();
Expand Down
56 changes: 52 additions & 4 deletions libpgmodeler_ui/ui/generalconfigwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
Expand Down Expand Up @@ -892,7 +892,7 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="4">
<item row="3" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QCheckBox" name="disp_line_numbers_chk">
Expand Down Expand Up @@ -922,7 +922,7 @@
</item>
</layout>
</item>
<item row="0" column="1" colspan="4">
<item row="0" column="1" colspan="2">
<widget class="QFontComboBox" name="font_cmb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
Expand All @@ -932,7 +932,7 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="4">
<item row="1" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QDoubleSpinBox" name="font_size_spb">
Expand All @@ -955,13 +955,61 @@
</item>
<item>
<widget class="QLabel" name="unity_lbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> pt</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="tab_width_chk">
<property name="text">
<string>Custom tab width:</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="tab_width_spb">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand Down

0 comments on commit c557690

Please sign in to comment.