Skip to content

Commit 3bb1af0

Browse files
committed
Merge branch 'hotfix/0.3.1' into stable
2 parents e18ff9c + 783fb12 commit 3bb1af0

8 files changed

+127
-25
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Get binary builds for Windows and Linux from the [download page](https://zealdoc
3535

3636
## How to use
3737

38-
After installing Zeal, you need to download docsets. Go to *File->Options->Docsets*, select the ones you want, and click the *Download* button.
38+
After installing Zeal, you need to download docsets. Go to *Tools->Docsets*, select the ones you want, and click the *Download* button.
3939

4040
## How to compile
4141

qmake/common.pri

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ RCC_DIR = $$BUILD_ROOT/.rcc
3030
UI_DIR = $$BUILD_ROOT/.ui
3131

3232
# Application version
33-
VERSION = 0.3.0
33+
VERSION = 0.3.1
3434
DEFINES += ZEAL_VERSION=\\\"$${VERSION}\\\"
3535

3636
# Browser engine
@@ -63,3 +63,10 @@ CONFIG(zeal_portable) {
6363
unix:!macx {
6464
isEmpty(PREFIX): PREFIX = /usr
6565
}
66+
67+
unix:!macx:packagesExist(appindicator-0.1) {
68+
CONFIG += link_pkgconfig
69+
PKGCONFIG += appindicator-0.1 gtk+-2.0
70+
DEFINES += USE_APPINDICATOR
71+
message("AppIndicator support: Yes.")
72+
}

src/libs/core/application.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "application.h"
2424

2525
#include "extractor.h"
26+
#include "networkaccessmanager.h"
2627
#include "settings.h"
2728

2829
#include <registry/docsetregistry.h>
@@ -35,7 +36,6 @@
3536
#include <QJsonDocument>
3637
#include <QJsonObject>
3738
#include <QMetaObject>
38-
#include <QNetworkAccessManager>
3939
#include <QNetworkProxy>
4040
#include <QNetworkReply>
4141
#include <QScopedPointer>
@@ -59,7 +59,7 @@ Application::Application(QObject *parent) :
5959
m_instance = this;
6060

6161
m_settings = new Settings(this);
62-
m_networkManager = new QNetworkAccessManager(this);
62+
m_networkManager = new NetworkAccessManager(this);
6363

6464
// Extractor setup
6565
m_extractorThread = new QThread(this);
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2016 Oleg Shparber
4+
** Contact: https://go.zealdocs.org/l/contact
5+
**
6+
** This file is part of Zeal.
7+
**
8+
** Zeal is free software: you can redistribute it and/or modify
9+
** it under the terms of the GNU General Public License as published by
10+
** the Free Software Foundation, either version 3 of the License, or
11+
** (at your option) any later version.
12+
**
13+
** Zeal is distributed in the hope that it will be useful,
14+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
** GNU General Public License for more details.
17+
**
18+
** You should have received a copy of the GNU General Public License
19+
** along with Zeal. If not, see <https://www.gnu.org/licenses/>.
20+
**
21+
****************************************************************************/
22+
23+
#include "networkaccessmanager.h"
24+
25+
#include <QNetworkRequest>
26+
27+
using namespace Zeal::Core;
28+
29+
NetworkAccessManager::NetworkAccessManager(QObject *parent)
30+
: QNetworkAccessManager(parent)
31+
{
32+
}
33+
34+
QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operation op,
35+
const QNetworkRequest &request,
36+
QIODevice *outgoingData)
37+
{
38+
// Detect URLs without schema, and prevent them from being requested on a local filesytem.
39+
const QUrl url = request.url();
40+
if (url.scheme() == QLatin1String("file") && !url.host().isEmpty())
41+
return QNetworkAccessManager::createRequest(GetOperation, QNetworkRequest(), outgoingData);
42+
43+
return QNetworkAccessManager::createRequest(op, request, outgoingData);
44+
}

src/libs/core/networkaccessmanager.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2016 Oleg Shparber
4+
** Contact: https://go.zealdocs.org/l/contact
5+
**
6+
** This file is part of Zeal.
7+
**
8+
** Zeal is free software: you can redistribute it and/or modify
9+
** it under the terms of the GNU General Public License as published by
10+
** the Free Software Foundation, either version 3 of the License, or
11+
** (at your option) any later version.
12+
**
13+
** Zeal is distributed in the hope that it will be useful,
14+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
** GNU General Public License for more details.
17+
**
18+
** You should have received a copy of the GNU General Public License
19+
** along with Zeal. If not, see <https://www.gnu.org/licenses/>.
20+
**
21+
****************************************************************************/
22+
23+
#ifndef ZEAL_CORE_NETWORKACCESSMANAGER_H
24+
#define ZEAL_CORE_NETWORKACCESSMANAGER_H
25+
26+
#include <QNetworkAccessManager>
27+
28+
namespace Zeal {
29+
namespace Core {
30+
31+
class NetworkAccessManager : public QNetworkAccessManager
32+
{
33+
Q_OBJECT
34+
public:
35+
NetworkAccessManager(QObject *parent = nullptr);
36+
37+
protected:
38+
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
39+
QIODevice *outgoingData = nullptr) override;
40+
};
41+
42+
} // namespace Core
43+
} // namespace Zeal
44+
45+
#endif // ZEAL_CORE_NETWORKACCESSMANAGER_H

src/libs/ui/docsetsdialog.cpp

+21-14
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ DocsetsDialog::DocsetsDialog(Core::Application *app, QWidget *parent) :
9898
[this, selectionModel]() {
9999
ui->removeDocsetsButton->setEnabled(selectionModel->hasSelection());
100100

101-
for (const QModelIndex &index : selectionModel->selectedIndexes()) {
101+
for (const QModelIndex &index : selectionModel->selectedRows()) {
102102
if (index.data(ListModel::UpdateAvailableRole).toBool()) {
103103
ui->updateSelectedDocsetsButton->setEnabled(true);
104104
return;
@@ -135,7 +135,7 @@ DocsetsDialog::DocsetsDialog(Core::Application *app, QWidget *parent) :
135135

136136
selectionModel = ui->availableDocsetList->selectionModel();
137137
connect(selectionModel, &QItemSelectionModel::selectionChanged, [this, selectionModel]() {
138-
for (const QModelIndex &index : selectionModel->selectedIndexes()) {
138+
for (const QModelIndex &index : selectionModel->selectedRows()) {
139139
if (!index.data(ProgressItemDelegate::ShowProgressRole).toBool()) {
140140
ui->downloadDocsetsButton->setEnabled(true);
141141
return;
@@ -217,7 +217,7 @@ void DocsetsDialog::addDashFeed()
217217

218218
void DocsetsDialog::updateSelectedDocsets()
219219
{
220-
for (const QModelIndex &index : ui->installedDocsetList->selectionModel()->selectedIndexes()) {
220+
for (const QModelIndex &index : ui->installedDocsetList->selectionModel()->selectedRows()) {
221221
if (!index.data(Registry::ListModel::UpdateAvailableRole).toBool())
222222
continue;
223223

@@ -245,7 +245,7 @@ void DocsetsDialog::removeSelectedDocsets()
245245

246246
int ret;
247247

248-
const QModelIndexList selectedIndexes = selectonModel->selectedIndexes();
248+
const QModelIndexList selectedIndexes = selectonModel->selectedRows();
249249
if (selectedIndexes.size() == 1) {
250250
const QString docsetTitle = selectedIndexes.first().data().toString();
251251
ret = QMessageBox::question(this, QStringLiteral("Zeal"),
@@ -286,7 +286,7 @@ void DocsetsDialog::updateDocsetFilter(const QString &filterString)
286286
void DocsetsDialog::downloadSelectedDocsets()
287287
{
288288
QItemSelectionModel *selectionModel = ui->availableDocsetList->selectionModel();
289-
for (const QModelIndex &index : selectionModel->selectedIndexes()) {
289+
for (const QModelIndex &index : selectionModel->selectedRows()) {
290290
selectionModel->select(index, QItemSelectionModel::Deselect);
291291

292292
// Do nothing if a download is already in progress.
@@ -693,18 +693,21 @@ void DocsetsDialog::removeDocset(const QString &name)
693693
const QString tmpPath = docsetPath + QLatin1String(".deleteme.")
694694
+ QString::number(QDateTime::currentMSecsSinceEpoch());
695695

696-
// Rename first to allow simultaneous installation.
697-
// TODO: Check for error
698-
QDir().rename(docsetPath, tmpPath);
699-
696+
// Remove from registry first to avoid renaming files in use on Windows.
700697
m_docsetRegistry->remove(name);
701698

702-
QFuture<bool> future = QtConcurrent::run([tmpPath] {
703-
return QDir(tmpPath).removeRecursively();
704-
});
699+
// Rename first to allow simultaneous installation.
700+
if (!QDir().rename(docsetPath, tmpPath)) {
701+
const QString error = tr("Cannot delete docset <b>%1</b>! Please try closing other "
702+
"applications first, as they may be accessing the docset "
703+
"files.").arg(title);
704+
QMessageBox::warning(this, QStringLiteral("Zeal"), error);
705+
m_docsetsBeingDeleted.removeOne(name);
706+
m_docsetRegistry->addDocset(docsetPath);
707+
return;
708+
}
705709

706710
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>();
707-
watcher->setFuture(future);
708711
connect(watcher, &QFutureWatcher<void>::finished, [=] {
709712
if (!watcher->result()) {
710713
QMessageBox::warning(this, QStringLiteral("Zeal"),
@@ -719,6 +722,10 @@ void DocsetsDialog::removeDocset(const QString &name)
719722

720723
m_docsetsBeingDeleted.removeOne(name);
721724
});
725+
726+
watcher->setFuture(QtConcurrent::run([tmpPath] {
727+
return QDir(tmpPath).removeRecursively();
728+
}));
722729
}
723730

724731
void DocsetsDialog::updateCombinedProgress()
@@ -749,7 +756,7 @@ void DocsetsDialog::resetProgress()
749756
ui->addFeedButton->setEnabled(true);
750757
QItemSelectionModel *selectionModel = ui->installedDocsetList->selectionModel();
751758
bool hasSelectedUpdates = false;
752-
for (const QModelIndex &index : selectionModel->selectedIndexes()) {
759+
for (const QModelIndex &index : selectionModel->selectedRows()) {
753760
if (index.data(Registry::ListModel::UpdateAvailableRole).toBool()) {
754761
hasSelectedUpdates = true;
755762
break;

src/libs/ui/forms/docsetsdialog.ui

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<property name="selectionMode">
3333
<enum>QAbstractItemView::ExtendedSelection</enum>
3434
</property>
35+
<property name="selectionBehavior">
36+
<enum>QAbstractItemView::SelectRows</enum>
37+
</property>
3538
<property name="iconSize">
3639
<size>
3740
<width>16</width>
@@ -116,6 +119,9 @@
116119
<property name="selectionMode">
117120
<enum>QAbstractItemView::ExtendedSelection</enum>
118121
</property>
122+
<property name="selectionBehavior">
123+
<enum>QAbstractItemView::SelectRows</enum>
124+
</property>
119125
<property name="iconSize">
120126
<size>
121127
<width>16</width>

src/libs/ui/ui.pri

-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ ZEAL_LIB_NAME = Ui
22

33
QT += widgets
44

5-
unix:!macx:packagesExist(appindicator-0.1) {
6-
CONFIG += link_pkgconfig
7-
PKGCONFIG += appindicator-0.1 gtk+-2.0
8-
DEFINES += USE_APPINDICATOR
9-
message("AppIndicator support: Yes.")
10-
}
11-
125
# QxtGlobalShortcut dependencies
136
unix:!macx {
147
QT += x11extras

0 commit comments

Comments
 (0)