Mercurial > projects > qtd
comparison demos/browser/settings.d @ 77:0654fc9bac95
more porting
author | mandel |
---|---|
date | Sun, 24 May 2009 13:46:32 +0000 |
parents | 37caa90ce503 |
children | 85c59c4e5f19 |
comparison
equal
deleted
inserted
replaced
76:454e4b4beb59 | 77:0654fc9bac95 |
---|---|
65 //: QDialog(parent) | 65 //: QDialog(parent) |
66 { | 66 { |
67 setupUi(this); | 67 setupUi(this); |
68 exceptionsButton.clicked.connect(&this.showExceptions); | 68 exceptionsButton.clicked.connect(&this.showExceptions); |
69 setHomeToCurrentPageButton.clicked.connect(&this.setHomeToCurrentPage); | 69 setHomeToCurrentPageButton.clicked.connect(&this.setHomeToCurrentPage); |
70 cookiesButton.clicked.connect(&this.showCookies())); | 70 cookiesButton.clicked.connect(&this.showCookies()); |
71 standardFontButton.clicked.connect(this.chooseFont); | 71 standardFontButton.clicked.connect(this.chooseFont); |
72 fixedFontButton.clicked.connect(&this.chooseFixedFont); | 72 fixedFontButton.clicked.connect(&this.chooseFixedFont); |
73 | 73 |
74 loadDefaults(); | 74 loadDefaults(); |
75 loadFromSettings(); | 75 loadFromSettings(); |
76 } | 76 } |
77 | 77 |
78 void accept(); | 78 void accept() |
79 { | 79 { |
80 saveToSettings(); | 80 saveToSettings(); |
81 QDialog.accept(); | 81 QDialog.accept(); |
82 } | 82 } |
83 | 83 |
84 private: | 84 private: |
85 | 85 |
86 void loadDefaults() | 86 void loadDefaults() |
87 { | 87 { |
88 QWebSettings defaultSettings = QWebSettings.globalSettings(); | 88 QWebSettings defaultSettings = QWebSettings.globalSettings(); |
89 QString standardFontFamily = defaultSettings.fontFamily(QWebSettings.StandardFont); | 89 string standardFontFamily = defaultSettings.fontFamily(QWebSettings.StandardFont); |
90 int standardFontSize = defaultSettings.fontSize(QWebSettings.DefaultFontSize); | 90 int standardFontSize = defaultSettings.fontSize(QWebSettings.DefaultFontSize); |
91 standardFont = QFont(standardFontFamily, standardFontSize); | 91 standardFont = QFont(standardFontFamily, standardFontSize); |
92 standardLabel.setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); | 92 standardLabel.setText(Format(QLatin1String("{} {}"), standardFont.family(), standardFont.pointSize())); |
93 | 93 |
94 QString fixedFontFamily = defaultSettings.fontFamily(QWebSettings.FixedFont); | 94 string fixedFontFamily = defaultSettings.fontFamily(QWebSettings.FixedFont); |
95 int fixedFontSize = defaultSettings.fontSize(QWebSettings.DefaultFixedFontSize); | 95 int fixedFontSize = defaultSettings.fontSize(QWebSettings.DefaultFixedFontSize); |
96 fixedFont = QFont(fixedFontFamily, fixedFontSize); | 96 fixedFont = QFont(fixedFontFamily, fixedFontSize); |
97 fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); | 97 fixedLabel.setText(Format(QLatin1String("{} {}"), fixedFont.family(), fixedFont.pointSize())); |
98 | 98 |
99 downloadsLocation.setText(QDesktopServices.storageLocation(QDesktopServices.DesktopLocation)); | 99 downloadsLocation.setText(QDesktopServices.storageLocation(QDesktopServices.DesktopLocation)); |
100 | 100 |
101 enableJavascript.setChecked(defaultSettings.testAttribute(QWebSettings.JavascriptEnabled)); | 101 enableJavascript.setChecked(defaultSettings.testAttribute(QWebSettings.JavascriptEnabled)); |
102 enablePlugins.setChecked(defaultSettings.testAttribute(QWebSettings.PluginsEnabled)); | 102 enablePlugins.setChecked(defaultSettings.testAttribute(QWebSettings.PluginsEnabled)); |
103 } | 103 } |
104 | 104 |
105 void loadFromSettings() | 105 void loadFromSettings() |
106 { | 106 { |
107 QSettings settings; | 107 auto settings = new QSettings; |
108 settings.beginGroup(QLatin1String("MainWindow")); | 108 settings.beginGroup(QLatin1String("MainWindow")); |
109 QString defaultHome = QLatin1String("http://qtsoftware.com"); | 109 string defaultHome = QLatin1String("http://qtsoftware.com"); |
110 homeLineEdit.setText(settings.value(QLatin1String("home"), defaultHome).toString()); | 110 homeLineEdit.setText(settings.value(QLatin1String("home"), defaultHome).toString()); |
111 settings.endGroup(); | 111 settings.endGroup(); |
112 | 112 |
113 settings.beginGroup(QLatin1String("history")); | 113 settings.beginGroup(QLatin1String("history")); |
114 int historyExpire = settings.value(QLatin1String("historyExpire")).toInt(); | 114 int historyExpire = settings.value(QLatin1String("historyExpire")).toInt(); |
125 } | 125 } |
126 expireHistory.setCurrentIndex(idx); | 126 expireHistory.setCurrentIndex(idx); |
127 settings.endGroup(); | 127 settings.endGroup(); |
128 | 128 |
129 settings.beginGroup(QLatin1String("downloadmanager")); | 129 settings.beginGroup(QLatin1String("downloadmanager")); |
130 QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation.text()).toString(); | 130 string downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation.text()).toString(); |
131 downloadsLocation.setText(downloadDirectory); | 131 downloadsLocation.setText(downloadDirectory); |
132 settings.endGroup(); | 132 settings.endGroup(); |
133 | 133 |
134 settings.beginGroup(QLatin1String("general")); | 134 settings.beginGroup(QLatin1String("general")); |
135 openLinksIn.setCurrentIndex(settings.value(QLatin1String("openLinksIn"), openLinksIn.currentIndex()).toInt()); | 135 openLinksIn.setCurrentIndex(settings.value(QLatin1String("openLinksIn"), openLinksIn.currentIndex()).toInt()); |
139 // Appearance | 139 // Appearance |
140 settings.beginGroup(QLatin1String("websettings")); | 140 settings.beginGroup(QLatin1String("websettings")); |
141 fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont)); | 141 fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont)); |
142 standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont)); | 142 standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont)); |
143 | 143 |
144 standardLabel.setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); | 144 standardLabel.setText(Format(QLatin1String("{} {}"), standardFont.family(), standardFont.pointSize())); |
145 fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); | 145 fixedLabel.setText(Format(QLatin1String("{} {}"), fixedFont.family(), fixedFont.pointSize())); |
146 | 146 |
147 enableJavascript.setChecked(settings.value(QLatin1String("enableJavascript"), enableJavascript.isChecked()).toBool()); | 147 enableJavascript.setChecked(settings.value(QLatin1String("enableJavascript"), enableJavascript.isChecked()).toBool()); |
148 enablePlugins.setChecked(settings.value(QLatin1String("enablePlugins"), enablePlugins.isChecked()).toBool()); | 148 enablePlugins.setChecked(settings.value(QLatin1String("enablePlugins"), enablePlugins.isChecked()).toBool()); |
149 userStyleSheet.setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString()); | 149 userStyleSheet.setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString()); |
150 settings.endGroup(); | 150 settings.endGroup(); |
226 settings.beginGroup(QLatin1String("websettings")); | 226 settings.beginGroup(QLatin1String("websettings")); |
227 settings.setValue(QLatin1String("fixedFont"), fixedFont); | 227 settings.setValue(QLatin1String("fixedFont"), fixedFont); |
228 settings.setValue(QLatin1String("standardFont"), standardFont); | 228 settings.setValue(QLatin1String("standardFont"), standardFont); |
229 settings.setValue(QLatin1String("enableJavascript"), enableJavascript.isChecked()); | 229 settings.setValue(QLatin1String("enableJavascript"), enableJavascript.isChecked()); |
230 settings.setValue(QLatin1String("enablePlugins"), enablePlugins.isChecked()); | 230 settings.setValue(QLatin1String("enablePlugins"), enablePlugins.isChecked()); |
231 QString userStyleSheetString = userStyleSheet.text(); | 231 string userStyleSheetString = userStyleSheet.text(); |
232 if (QFile.exists(userStyleSheetString)) | 232 if (QFile.exists(userStyleSheetString)) |
233 settings.setValue(QLatin1String("userStyleSheet"), QUrl.fromLocalFile(userStyleSheetString)); | 233 settings.setValue(QLatin1String("userStyleSheet"), QUrl.fromLocalFile(userStyleSheetString)); |
234 else | 234 else |
235 settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString)); | 235 settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString)); |
236 settings.endGroup(); | 236 settings.endGroup(); |
314 { | 314 { |
315 bool ok; | 315 bool ok; |
316 QFont font = QFontDialog.getFont(&ok, standardFont, this); | 316 QFont font = QFontDialog.getFont(&ok, standardFont, this); |
317 if ( ok ) { | 317 if ( ok ) { |
318 standardFont = font; | 318 standardFont = font; |
319 standardLabel.setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); | 319 standardLabel.setText(Format(QLatin1String("{} {}"), font.family(), font.pointSize())); |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 void chooseFixedFont() | 323 void chooseFixedFont() |
324 { | 324 { |
325 bool ok; | 325 bool ok; |
326 QFont font = QFontDialog.getFont(&ok, fixedFont, this); | 326 QFont font = QFontDialog.getFont(&ok, fixedFont, this); |
327 if ( ok ) { | 327 if ( ok ) { |
328 fixedFont = font; | 328 fixedFont = font; |
329 fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); | 329 fixedLabel.setText(Format(QLatin1String("{} {}"), font.family(), font.pointSize())); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 private: | 333 private: |
334 | 334 |