1 //===========================================
2 // Lumina Desktop Source Code
3 // Copyright (c) 2016, Ken Moore
4 // Available under the 3-clause BSD license
5 // See the LICENSE file for full details
6 //===========================================
7 #include "page_session_locale.h"
8 #include "ui_page_session_locale.h"
9
10 //==========
11 // PUBLIC
12 //==========
page_session_locale(QWidget * parent)13 page_session_locale::page_session_locale(QWidget *parent) : PageWidget(parent), ui(new Ui::page_session_locale()){
14 ui->setupUi(this);
15 setupLocales();
16 connect(ui->combo_locale_lang, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
17 connect(ui->combo_locale_collate, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
18 connect(ui->combo_locale_ctype, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
19 connect(ui->combo_locale_message, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
20 connect(ui->combo_locale_monetary, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
21 connect(ui->combo_locale_numeric, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
22 connect(ui->combo_locale_time, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged()) );
23 updateIcons();
24 }
25
~page_session_locale()26 page_session_locale::~page_session_locale(){
27
28 }
29
30 //================
31 // PUBLIC SLOTS
32 //================
SaveSettings()33 void page_session_locale::SaveSettings(){
34 QSettings sessionsettings("lumina-desktop","sessionsettings");
35 sessionsettings.setValue("InitLocale/LANG", ui->combo_locale_lang->currentData().toString() );
36 sessionsettings.setValue("InitLocale/LC_MESSAGES", ui->combo_locale_message->currentData().toString() );
37 sessionsettings.setValue("InitLocale/LC_TIME", ui->combo_locale_time->currentData().toString() );
38 sessionsettings.setValue("InitLocale/LC_NUMERIC", ui->combo_locale_numeric->currentData().toString() );
39 sessionsettings.setValue("InitLocale/LC_MONETARY", ui->combo_locale_monetary->currentData().toString() );
40 sessionsettings.setValue("InitLocale/LC_COLLATE", ui->combo_locale_collate->currentData().toString() );
41 sessionsettings.setValue("InitLocale/LC_CTYPE", ui->combo_locale_ctype->currentData().toString() );
42 emit HasPendingChanges(false);
43 }
44
LoadSettings(int)45 void page_session_locale::LoadSettings(int){
46 emit HasPendingChanges(false);
47 emit ChangePageTitle( tr("Desktop Settings") );
48 QSettings sessionsettings("lumina-desktop","sessionsettings");
49
50 QString val = sessionsettings.value("InitLocale/LANG", "").toString();
51 int index = ui->combo_locale_lang->findData(val);
52 if(index<0){ index = 0; } //system default
53 ui->combo_locale_lang->setCurrentIndex(index);
54 val = sessionsettings.value("InitLocale/LC_MESSAGES", "").toString();
55 index = ui->combo_locale_message->findData(val);
56 if(index<0){ index = 0; } //system default
57 ui->combo_locale_message->setCurrentIndex(index);
58 val = sessionsettings.value("InitLocale/LC_TIME", "").toString();
59 index = ui->combo_locale_time->findData(val);
60 if(index<0){ index = 0; } //system default
61 ui->combo_locale_time->setCurrentIndex(index);
62 val = sessionsettings.value("InitLocale/NUMERIC", "").toString();
63 index = ui->combo_locale_numeric->findData(val);
64 if(index<0){ index = 0; } //system default
65 ui->combo_locale_numeric->setCurrentIndex(index);
66 val = sessionsettings.value("InitLocale/MONETARY", "").toString();
67 index = ui->combo_locale_monetary->findData(val);
68 if(index<0){ index = 0; } //system default
69 ui->combo_locale_monetary->setCurrentIndex(index);
70 val = sessionsettings.value("InitLocale/COLLATE", "").toString();
71 index = ui->combo_locale_collate->findData(val);
72 if(index<0){ index = 0; } //system default
73 ui->combo_locale_collate->setCurrentIndex(index);
74 val = sessionsettings.value("InitLocale/CTYPE", "").toString();
75 index = ui->combo_locale_ctype->findData(val);
76 if(index<0){ index = 0; } //system default
77 ui->combo_locale_ctype->setCurrentIndex(index);
78 }
79
updateIcons()80 void page_session_locale::updateIcons(){
81
82 }
83
84 //=================
85 // PRIVATE
86 //=================
setupLocales()87 void page_session_locale::setupLocales(){
88 //Available localizations
89 QStringList langs = LUtils::knownLocales();
90 langs.sort();
91 QString def = tr("System Default");
92 ui->combo_locale_lang->addItem(def,"");
93 ui->combo_locale_collate->addItem(def,"");
94 ui->combo_locale_ctype->addItem(def,"");
95 ui->combo_locale_message->addItem(def,"");
96 ui->combo_locale_monetary->addItem(def,"");
97 ui->combo_locale_numeric->addItem(def,"");
98 ui->combo_locale_time->addItem(def,"");
99 for(int i=0; i<langs.length(); i++){
100 QString lan = QLocale(langs[i]).nativeLanguageName();
101 ui->combo_locale_lang->addItem(lan,langs[i]);
102 ui->combo_locale_collate->addItem(lan,langs[i]);
103 ui->combo_locale_ctype->addItem(lan,langs[i]);
104 ui->combo_locale_message->addItem(lan,langs[i]);
105 ui->combo_locale_monetary->addItem(lan,langs[i]);
106 ui->combo_locale_numeric->addItem(lan,langs[i]);
107 ui->combo_locale_time->addItem(lan,langs[i]);
108 }
109 }
110 //=================
111 // PRIVATE SLOTS
112 //=================
113