Commit be6d3d96f941af9ba478d50bdb924f6cd0e5620a

  • avatar
  • Jakub Wieczorek <faw217 @gm…l.com>
  • Fri Jun 26 23:41:41 CEST 2009
Add a setting that specifies if the url supplied by the user should be
forwarded to the default search engine if it isn't valid.
  
157157 expireHistory->setCurrentIndex(idx);
158158 settings.endGroup();
159159
160 settings.beginGroup(QLatin1String("urlloading"));
161 bool search = settings.value(QLatin1String("searchEngineFallback"), false).toBool();
162 searchEngineFallback->setChecked(search);
163 settings.endGroup();
164
160165 settings.beginGroup(QLatin1String("downloadmanager"));
161166 bool alwaysPromptForFileName = settings.value(QLatin1String("alwaysPromptForFileName"), false).toBool();
162 if (alwaysPromptForFileName)
163 downloadAsk->setChecked(true);
167 downloadAsk->setChecked(alwaysPromptForFileName);
164168 QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation->text()).toString();
165169 downloadsLocation->setText(downloadDirectory);
166170 settings.endGroup();
283283 case 6: idx = -2; break;
284284 }
285285 settings.setValue(QLatin1String("historyLimit"), idx);
286 settings.endGroup();
287
288 settings.beginGroup(QLatin1String("urlloading"));
289 settings.setValue(QLatin1String("searchEngineFallback"), searchEngineFallback->isChecked());
286290 settings.endGroup();
287291
288292 // Appearance
  
149149 </item>
150150 </widget>
151151 </item>
152 <item row="4" column="0" colspan="3">
153 <widget class="QCheckBox" name="searchEngineFallback">
154 <property name="text">
155 <string>Use the default search engine as fallback when the URL given by the user is invalid</string>
156 </property>
157 <property name="checked">
158 <bool>false</bool>
159 </property>
160 </widget>
161 </item>
152162 <item row="5" column="0" colspan="3">
153163 <widget class="QGroupBox" name="groupBox_2">
154164 <property name="title">
  
7070#include "browsermainwindow.h"
7171#include "history.h"
7272#include "historymanager.h"
73#include "tabbar.h"
7473#include "locationbar.h"
74#include "opensearchengine.h"
75#include "opensearchmanager.h"
76#include "tabbar.h"
7577#include "toolbarsearch.h"
7678#include "webactionmapper.h"
7779#include "webpage.h"
926926QUrl TabWidget::guessUrlFromString(const QString &string)
927927{
928928 QUrl url = WebView::guessUrlFromString(string);
929 if (url.isValid())
929
930 // QUrl::isValid() is too much tolerant.
931 // We actually want to check if the url conforms to the RFC, which QUrl::isValid() doesn't state.
932 if (!url.scheme().isEmpty() && !url.host().isEmpty())
930933 return url;
931934
932 // In the future we could do more fancy things such as automatically searching
933 // on the current search engine, looking through our history or something else.
934 QString urlString = QLatin1String("http://") + string;
935 return QUrl::fromEncoded(urlString.toUtf8(), QUrl::TolerantMode);
935 QSettings settings;
936 settings.beginGroup(QLatin1String("urlloading"));
937 bool search = settings.value(QLatin1String("searchEngineFallback"), false).toBool();
938
939 if (search) {
940 url = ToolbarSearch::openSearchManager()->currentEngine()->searchUrl(string.trimmed());
941 } else {
942 QString urlString = QLatin1String("http://") + string.trimmed();
943 url = QUrl::fromEncoded(urlString.toUtf8(), QUrl::TolerantMode);
944 }
945
946 return url;
936947}
937948
938949/*