1 // dlgoptionsgeneral.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/18/2010 Added this text. :-)
17 #include "dlgoptionsgeneral.h"
25 DlgOptionsGeneral::DlgOptionsGeneral(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
26 QDialog(parent, flags)
30 #ifdef QC_PREDEFINED_LOCALE
32 Widget9Layout->addMultiCellWidget(bgGraphicView, 0, 2, 0, 0); //use empty space as well
34 // Fill combobox with languages:
35 QStringList languageList = SYSTEM->getLanguageList();
36 languageList.prepend("en");
38 for(QStringList::Iterator it=languageList.begin(); it!=languageList.end(); it++)
40 DEBUG->print("DlgOptionsGeneral::init: adding %s to combobox", (*it).toLatin1().data());
42 QString l = SYSTEM->symbolToLanguage(*it);
44 if (l.isEmpty() == false)
46 DEBUG->print("DlgOptionsGeneral::init: %s", l.toLatin1().data());
47 ui.cbLanguage->addItem(l);
48 ui.cbLanguageCmd->addItem(l);
52 settings.beginGroup("Appearance");
54 // set current language:
55 QString def_lang = "en";
56 #ifdef QC_PREDEFINED_LOCALE
57 def_lang = QC_PREDEFINED_LOCALE;
59 QString lang = settings.value("Language", def_lang).toString();
60 // ui.cbLanguage->setCurrentText(SYSTEM->symbolToLanguage(lang));
61 ui.cbLanguage->setItemText(ui.cbLanguage->currentIndex(), SYSTEM->symbolToLanguage(lang));
63 QString langCmd = settings.value("LanguageCmd", def_lang).toString();
64 // ui.cbLanguageCmd->setCurrentText(SYSTEM->symbolToLanguage(langCmd));
65 ui.cbLanguageCmd->setItemText(ui.cbLanguageCmd->currentIndex(), SYSTEM->symbolToLanguage(langCmd));
69 bool showCrosshairs = settings.value("ShowCrosshairs", true).toBool();
70 ui.cbShowCrosshairs->setChecked(showCrosshairs);
73 bool scaleGrid = settings.value("ScaleGrid", true).toBool();
74 ui.cbScaleGrid->setChecked(scaleGrid);
75 QString minGridSpacing = settings.value("MinGridSpacing", "10").toString();
76 // ui.cbMinGridSpacing->setCurrentText(minGridSpacing);
77 ui.cbMinGridSpacing->setItemText(ui.cbMinGridSpacing->currentIndex(), minGridSpacing);
80 QString maxPreview = settings.value("MaxPreview", "100").toString();
81 // ui.cbMaxPreview->setCurrentText(maxPreview);
82 ui.cbMaxPreview->setItemText(ui.cbMaxPreview->currentIndex(), maxPreview);
85 QString backgroundColor = settings.value("BackgroundColor", "Black").toString();
86 // ui.cbBackgroundColor->setCurrentText(backgroundColor);
87 ui.cbBackgroundColor->setItemText(ui.cbBackgroundColor->currentIndex(), backgroundColor);
88 QString gridColor = settings.value("GridColor", "Gray").toString();
89 // ui.cbGridColor->setCurrentText(gridColor);
90 ui.cbGridColor->setItemText(ui.cbGridColor->currentIndex(), gridColor);
91 QString metaGridColor = settings.value("MetaGridColor", "#404040").toString();
92 // ui.cbMetaGridColor->setCurrentText(metaGridColor);
93 ui.cbMetaGridColor->setItemText(ui.cbMetaGridColor->currentIndex(), metaGridColor);
94 QString selectedColor = settings.value("SelectedColor", "#a54747").toString();
95 // ui.cbSelectedColor->setCurrentText(selectedColor);
96 ui.cbSelectedColor->setItemText(ui.cbSelectedColor->currentIndex(), selectedColor);
97 QString highlightedColor = settings.value("HighlightedColor", "#739373").toString();
98 // ui.cbHighlightedColor->setCurrentText(highlightedColor);
99 ui.cbHighlightedColor->setItemText(ui.cbHighlightedColor->currentIndex(), highlightedColor);
102 QString sizeStatus = settings.value("StatusBarFontSize", "9").toString();
103 // ui.cbSizeStatus->setCurrentText(sizeStatus);
104 ui.cbSizeStatus->setItemText(ui.cbSizeStatus->currentIndex(), sizeStatus);
108 settings.beginGroup("Paths");
109 ui.lePathTranslations->setText(settings.value("Translations", "").toString());
110 ui.lePathHatch->setText(settings.value("Patterns", "").toString());
111 ui.lePathFonts->setText(settings.value("Fonts", "").toString());
112 ui.lePathScripts->setText(settings.value("Scripts", "").toString());
113 ui.lePathLibrary->setText(settings.value("Library", "").toString());
116 ui.cbUnit->setInsertPolicy(QComboBox::InsertAlphabetically);
119 for(int i=RS2::None; i<RS2::LastUnit; i++)
121 if (i != (int)RS2::None)
122 ui.cbUnit->addItem(Units::unitToString((RS2::Unit)i));
126 //#warning "Need to port to Qt4... !!! FIX !!!"
128 // cbUnit->listBox()->sort();
130 ui.cbUnit->setInsertPolicy(QComboBox::InsertAtBottom);
131 ui.cbUnit->addItem(Units::unitToString(RS2::None), 0);
133 QString def_unit = "Millimeter";
134 #ifdef QC_PREDEFINED_UNIT
135 def_unit = QC_PREDEFINED_UNIT;
137 settings.beginGroup("Defaults");
138 // ui.cbUnit->setCurrentText(QObject::tr(RS_SETTINGS->readEntry("/Unit", def_unit)));
139 // ui.cbUnit->setItemText(ui.cbUnit->currentIndex(), QObject::tr(RS_SETTINGS->readEntry("/Unit", def_unit)));
140 ui.cbUnit->setItemText(ui.cbUnit->currentIndex(), (settings.value("Unit", def_unit).toString()));
143 restartNeeded = false;
146 DlgOptionsGeneral::~DlgOptionsGeneral()
150 void DlgOptionsGeneral::setRestartNeeded()
152 restartNeeded = true;
155 void DlgOptionsGeneral::ok()
157 //SYSTEM->loadTranslation(cbLanguage->currentText());
158 settings.beginGroup("Appearance");
159 settings.setValue("Language", SYSTEM->languageToSymbol(ui.cbLanguage->currentText()));
160 settings.setValue("LanguageCmd", SYSTEM->languageToSymbol(ui.cbLanguageCmd->currentText()));
161 settings.setValue("ShowCrosshairs", ui.cbShowCrosshairs->isChecked());
162 settings.setValue("ScaleGrid", ui.cbScaleGrid->isChecked());
163 settings.setValue("MinGridSpacing", ui.cbMinGridSpacing->currentText());
164 settings.setValue("MaxPreview", ui.cbMaxPreview->currentText());
165 settings.setValue("BackgroundColor", ui.cbBackgroundColor->currentText());
166 settings.setValue("GridColor", ui.cbGridColor->currentText());
167 settings.setValue("MetaGridColor", ui.cbMetaGridColor->currentText());
168 settings.setValue("SelectedColor", ui.cbSelectedColor->currentText());
169 settings.setValue("HighlightedColor", ui.cbHighlightedColor->currentText());
170 settings.setValue("StatusBarFontSize", ui.cbSizeStatus->currentText());
173 settings.beginGroup("Paths");
174 settings.setValue("Translations", ui.lePathTranslations->text());
175 settings.setValue("Patterns", ui.lePathHatch->text());
176 settings.setValue("Fonts", ui.lePathFonts->text());
177 settings.setValue("Scripts", ui.lePathScripts->text());
178 settings.setValue("Library", ui.lePathLibrary->text());
181 settings.beginGroup("Defaults");
182 settings.setValue("Unit", Units::unitToString(Units::stringToUnit(ui.cbUnit->currentText()), false/*untr.*/));
185 if (restartNeeded == true)
187 QMessageBox::warning( this, tr("Preferences"),
188 tr("Please restart the application to apply all changes."), QMessageBox::Ok, Qt::NoButton);