Skip to content

Commit

Permalink
Merge branch 'hotfix/0.2.1' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
trollixx committed Nov 19, 2015
2 parents fcf0cef + 5fb2e90 commit 45bb34f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,14 @@ void Application::extract(const QString &filePath, const QString &destination, c

QNetworkReply *Application::download(const QUrl &url)
{
static const QString userAgent = userAgentJson();
static const QString ua = userAgent();
static const QString uaJson = userAgentJson();

QNetworkRequest request(url);
request.setHeader(QNetworkRequest::UserAgentHeader, ua);

if (url.host().endsWith(QLatin1String(".zealdocs.org", Qt::CaseInsensitive)))
request.setRawHeader("X-Zeal-User-Agent", userAgent.toUtf8());
request.setRawHeader("X-Zeal-User-Agent", uaJson.toUtf8());

return m_networkManager->get(request);
}
Expand Down Expand Up @@ -218,6 +220,10 @@ void Application::applySettings()
}
}

QString Application::userAgent()
{
return QString("Zeal/%1").arg(QCoreApplication::applicationVersion());
}

QString Application::userAgentJson() const
{
Expand Down
1 change: 1 addition & 0 deletions src/core/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private slots:
void applySettings();

private:
static inline QString userAgent();
QString userAgentJson() const;

static Application *m_instance;
Expand Down
8 changes: 4 additions & 4 deletions src/core/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void Settings::load()
m_settings->endGroup();

m_settings->beginGroup(GroupProxy);
proxyType = m_settings->value(QStringLiteral("type"), ProxyType::System).value<ProxyType>();
proxyType = static_cast<ProxyType>(m_settings->value(QStringLiteral("type"),
ProxyType::System).toUInt());
proxyHost = m_settings->value(QStringLiteral("host")).toString();
proxyPort = m_settings->value(QStringLiteral("port"), 0).toInt();
proxyAuthenticate = m_settings->value(QStringLiteral("authenticate"), false).toBool();
Expand Down Expand Up @@ -126,7 +127,7 @@ void Settings::load()
// Avoid curly braces (QTBUG-885)
QUuid::createUuid().toString().mid(1, 36)).toString();
version = m_settings->value(QStringLiteral("version"),
QCoreApplication::applicationVersion()).toString();
QCoreApplication::applicationVersion()).toString();
m_settings->endGroup();
}

Expand Down Expand Up @@ -170,11 +171,10 @@ void Settings::save()

m_settings->beginGroup(GroupInternal);
m_settings->setValue(QStringLiteral("install_id"), installId);
m_settings->setValue(QStringLiteral("version"), version);
m_settings->setValue(QStringLiteral("version"), QCoreApplication::applicationVersion());
m_settings->endGroup();

m_settings->sync();

emit updated();
}

2 changes: 1 addition & 1 deletion src/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Settings : public QObject
/// TODO: QString customCss;

// Network
enum ProxyType {
enum ProxyType : unsigned int {
None,
System,
UserDefined
Expand Down
4 changes: 3 additions & 1 deletion src/registry/docset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ Docset::Docset(const QString &path) :
}

/// TODO: Verify if this is needed
if (plist[InfoPlist::DashDocSetFamily].toString() == QLatin1String("cheatsheet"))
if (plist.contains(InfoPlist::DashDocSetFamily)
&& plist[InfoPlist::DashDocSetFamily].toString() == QLatin1String("cheatsheet")) {
m_name = m_name + QLatin1String("cheats");
}

if (!dir.cd(QStringLiteral("Resources")) || !dir.exists(QStringLiteral("docSet.dsidx")))
return;
Expand Down
2 changes: 1 addition & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ portable {
DEFINES += PORTABLE_BUILD
}

VERSION = 0.2.0
VERSION = 0.2.1
DEFINES += ZEAL_VERSION=\\\"$${VERSION}\\\"

HEADERS += \
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/searchedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void SearchEdit::showCompletions(const QString &newValue)
const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
const int textWidth = fontMetrics().width(newValue);

if (!m_prefixCompleter)
if (m_prefixCompleter)
m_prefixCompleter->setCompletionPrefix(text());

const QString completed = currentCompletion(newValue).mid(newValue.size());
Expand Down

0 comments on commit 45bb34f

Please sign in to comment.