Skip to content

Commit

Permalink
Starting to add support to override the default language settings via
Browse files Browse the repository at this point in the history
GeneralConfigWidget
  • Loading branch information
rkhaotix committed Jul 27, 2017
1 parent dd44e68 commit fac15c7
Show file tree
Hide file tree
Showing 8 changed files with 527 additions and 403 deletions.
1 change: 1 addition & 0 deletions conf/dtd/pgmodeler.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<!ATTLIST configuration history-max-length CDATA #IMPLIED>
<!ATTLIST configuration source-editor-app CDATA #IMPLIED>
<!ATTLIST configuration source-editor-args CDATA #IMPLIED>
<!ATTLIST configuration ui-language CDATA #IMPLIED>

<!ELEMENT session (file+)>
<!ELEMENT recent-models (file+)>
Expand Down
4 changes: 4 additions & 0 deletions conf/schemas/pgmodeler.sch
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ $sp [<configuration op-list-size="] {op-list-size} ["] $br
[ source-editor-args="] {source-editor-args} ["] $br
%end

%if {ui-language} %then
[ ui-language="] {ui-language} ["] $br
%end

[/>] $br

%if {file} %then
Expand Down
1 change: 1 addition & 0 deletions libparsers/src/parsersattributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ namespace ParsersAttributes {
TYPE=QString("type"),
TYPES=QString("types"),
TYPE_CLASS=QString("type-class"),
UI_LANGUAGE=QString("ui-language"),
UNDERLINE=QString("underline"),
UNIQUE=QString("unique"),
UNLOGGED=QString("unlogged"),
Expand Down
1 change: 1 addition & 0 deletions libparsers/src/parsersattributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ namespace ParsersAttributes {
TYPE,
TYPES,
TYPE_CLASS,
UI_LANGUAGE,
UNDERLINE,
UNIQUE,
UNLOGGED,
Expand Down
33 changes: 33 additions & 0 deletions libpgmodeler_ui/src/generalconfigwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ GeneralConfigWidget::GeneralConfigWidget(QWidget * parent) : BaseConfigWidget(pa
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::MIN_OBJECT_OPACITY]=QString();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::HISTORY_MAX_LENGTH]=QString();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::SOURCE_EDITOR_APP]=QString();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::UI_LANGUAGE]=QString();

simp_obj_creation_ht=new HintTextWidget(simp_obj_creation_hint, this);
simp_obj_creation_ht->setText(simple_obj_creation_chk->statusTip());
Expand Down Expand Up @@ -162,6 +163,18 @@ GeneralConfigWidget::GeneralConfigWidget(QWidget * parent) : BaseConfigWidget(pa
min_obj_opacity_ht=new HintTextWidget(min_obj_opacity_hint, this);
min_obj_opacity_ht->setText(min_obj_opacity_spb->statusTip());

autosave_ht=new HintTextWidget(autosave_hint, this);
autosave_ht->setText(autosave_interv_chk->statusTip());

op_history_ht=new HintTextWidget(op_history_hint, this);
op_history_ht->setText(oplist_size_spb->statusTip());

ui_language_ht=new HintTextWidget(ui_language_hint, this);
ui_language_ht->setText(ui_language_cmb->statusTip());

grid_size_ht=new HintTextWidget(grid_size_hint, this);
grid_size_ht->setText(grid_size_spb->statusTip());

selectPaperSize();

QList<QCheckBox *> chk_boxes=this->findChildren<QCheckBox *>();
Expand Down Expand Up @@ -214,6 +227,25 @@ GeneralConfigWidget::GeneralConfigWidget(QWidget * parent) : BaseConfigWidget(pa
check_upd_chk->setChecked(false);
check_upd_chk->setVisible(false);
#endif

//Retrieving the available UI dictionaries
QStringList langs = QDir(GlobalAttributes::LANGUAGES_DIR +
GlobalAttributes::DIR_SEPARATOR,
QString("*.qm"), QDir::Name, QDir::AllEntries | QDir::NoDotAndDotDot).entryList();

langs.replaceInStrings(QString(".qm"), QString());
ui_language_cmb->addItem(trUtf8("System default"));
QString native_lang;

for(QString lang : langs)
{
native_lang = QLocale(lang).nativeLanguageName();
native_lang[0] = native_lang[0].toUpper();
ui_language_cmb->addItem(QString("%1 (%2 : %3)")
.arg(native_lang)
.arg(QLocale::languageToString(QLocale(lang).language()))
.arg(lang), lang);
}
}

void GeneralConfigWidget::loadConfiguration(void)
Expand Down Expand Up @@ -416,6 +448,7 @@ void GeneralConfigWidget::saveConfiguration(void)

config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::SOURCE_EDITOR_APP]=source_editor_edt->text();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::SOURCE_EDITOR_ARGS]=source_editor_args_edt->text();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::UI_LANGUAGE]=ui_language_cmb->currentData().toString();

config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::_FILE_]=QString();
config_params[ParsersAttributes::CONFIGURATION][ParsersAttributes::RECENT_MODELS]=QString();
Expand Down
3 changes: 2 additions & 1 deletion libpgmodeler_ui/src/generalconfigwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class GeneralConfigWidget: public BaseConfigWidget, public Ui::GeneralConfigWidg
HintTextWidget *simp_obj_creation_ht, *confirm_validation_ht, *corner_move_ht,
*save_last_pos_ht, *invert_rangesel_ht, *disable_smooth_ht,
*hide_ext_attribs_ht, *hide_table_tags_ht, *hide_rel_name_ht,
*code_completion_ht, *use_placeholders_ht, *min_obj_opacity_ht;
*code_completion_ht, *use_placeholders_ht, *min_obj_opacity_ht,
*autosave_ht, *op_history_ht, *ui_language_ht, *grid_size_ht;

ColorPickerWidget *line_numbers_cp, *line_numbers_bg_cp, *line_highlight_cp;

Expand Down
4 changes: 2 additions & 2 deletions libpgmodeler_ui/ui/configurationform.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<width>813</width>
<height>600</height>
</rect>
</property>
Expand All @@ -21,7 +21,7 @@
</property>
<property name="minimumSize">
<size>
<width>750</width>
<width>800</width>
<height>600</height>
</size>
</property>
Expand Down

0 comments on commit fac15c7

Please sign in to comment.