Mercurial > projects > qtd
comparison demos/browser/browsermainwindow.d @ 80:85c59c4e5f19
remove QLatin1String and other fixes
author | mandel |
---|---|
date | Sun, 24 May 2009 15:25:41 +0000 |
parents | 0654fc9bac95 |
children | 87bb4e622f9e |
comparison
equal
deleted
inserted
replaced
79:957f549cfc65 | 80:85c59c4e5f19 |
---|---|
166 public: | 166 public: |
167 | 167 |
168 static QUrl guessUrlFromString(string string) | 168 static QUrl guessUrlFromString(string string) |
169 { | 169 { |
170 string urlStr = string.trimmed(); | 170 string urlStr = string.trimmed(); |
171 auto test = new QRegExp(QLatin1String("^[a-zA-Z]+\\:.*")); | 171 auto test = new QRegExp("^[a-zA-Z]+\\:.*"); |
172 | 172 |
173 // Check if it looks like a qualified URL. Try parsing it and see. | 173 // Check if it looks like a qualified URL. Try parsing it and see. |
174 bool hasSchema = test.exactMatch(urlStr); | 174 bool hasSchema = test.exactMatch(urlStr); |
175 if (hasSchema) { | 175 if (hasSchema) { |
176 QUrl url = QUrl.fromEncoded(urlStr.toUtf8(), QUrl.TolerantMode); | 176 QUrl url = QUrl.fromEncoded(urlStr.toUtf8(), QUrl.TolerantMode); |
187 // Might be a shorturl - try to detect the schema. | 187 // Might be a shorturl - try to detect the schema. |
188 if (!hasSchema) { | 188 if (!hasSchema) { |
189 int dotIndex = urlStr.indexOf(QLatin1Char('.')); | 189 int dotIndex = urlStr.indexOf(QLatin1Char('.')); |
190 if (dotIndex != -1) { | 190 if (dotIndex != -1) { |
191 string prefix = urlStr.left(dotIndex).toLower(); | 191 string prefix = urlStr.left(dotIndex).toLower(); |
192 QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : "http"; | 192 QByteArray schema = (prefix == "ftp") ? prefix.toLatin1() : "http"; |
193 QUrl url = | 193 QUrl url = |
194 QUrl.fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl.TolerantMode); | 194 QUrl.fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl.TolerantMode); |
195 if (url.isValid()) | 195 if (url.isValid()) |
196 return url; | 196 return url; |
197 } | 197 } |
290 } | 290 } |
291 | 291 |
292 void slotHome() | 292 void slotHome() |
293 { | 293 { |
294 QSettings settings; | 294 QSettings settings; |
295 settings.beginGroup(QLatin1String("MainWindow")); | 295 settings.beginGroup("MainWindow"); |
296 string home = settings.value(QLatin1String("home"), QLatin1String("http://qtsoftware.com/")).toString(); | 296 string home = settings.value("home", "http://qtsoftware.com/").toString(); |
297 loadPage(home); | 297 loadPage(home); |
298 } | 298 } |
299 | 299 |
300 protected: | 300 protected: |
301 | 301 |
321 void save() | 321 void save() |
322 { | 322 { |
323 BrowserApplication.instance().saveSession(); | 323 BrowserApplication.instance().saveSession(); |
324 | 324 |
325 QSettings settings; | 325 QSettings settings; |
326 settings.beginGroup(QLatin1String("BrowserMainWindow")); | 326 settings.beginGroup("BrowserMainWindow"); |
327 QByteArray data = saveState(false); | 327 QByteArray data = saveState(false); |
328 settings.setValue(QLatin1String("defaultState"), data); | 328 settings.setValue("defaultState", data); |
329 settings.endGroup(); | 329 settings.endGroup(); |
330 } | 330 } |
331 | 331 |
332 void slotLoadProgress(int progress) | 332 void slotLoadProgress(int progress) |
333 { | 333 { |
752 private: | 752 private: |
753 | 753 |
754 void loadDefaultState() | 754 void loadDefaultState() |
755 { | 755 { |
756 QSettings settings; | 756 QSettings settings; |
757 settings.beginGroup(QLatin1String("BrowserMainWindow")); | 757 settings.beginGroup("BrowserMainWindow"); |
758 QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); | 758 QByteArray data = settings.value("defaultState").toByteArray(); |
759 restoreState(data); | 759 restoreState(data); |
760 settings.endGroup(); | 760 settings.endGroup(); |
761 } | 761 } |
762 | 762 |
763 void setupMenu() | 763 void setupMenu() |
918 | 918 |
919 QAction[] bookmarksActions; | 919 QAction[] bookmarksActions; |
920 | 920 |
921 QAction showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this); | 921 QAction showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this); |
922 showAllBookmarksAction.triggered().connect(&this.slotShowBookmarksDialog); | 922 showAllBookmarksAction.triggered().connect(&this.slotShowBookmarksDialog); |
923 m_addBookmark = new QAction(QIcon(QLatin1String(":addbookmark.png")), tr("Add Bookmark..."), this); | 923 m_addBookmark = new QAction(new QIcon(":addbookmark.png"), tr("Add Bookmark..."), this); |
924 m_addBookmark.setIconVisibleInMenu(false); | 924 m_addBookmark.setIconVisibleInMenu(false); |
925 | 925 |
926 m_addBookmark.triggered().connect(&this.slotAddBookmark); | 926 m_addBookmark.triggered().connect(&this.slotAddBookmark); |
927 m_addBookmark.setShortcut(QKeySequence(Qt.CTRL | Qt.Key_D)); | 927 m_addBookmark.setShortcut(QKeySequence(Qt.CTRL | Qt.Key_D)); |
928 | 928 |