Before this fix when kiwix-desktop was launched with a paused download
inherited from a previous session, cancelling that download didn't
remove the download files (incomplete .zim and .zim.aria2 files) because
the path of a paused Aria2 download is not available until it is
resumed. Now the path of a book being downloaded is taken from the
library (thanks to the previous commit).
When a book is downloaded via a metalink URL the fake path (with a
".beingdownloadedbykiwix" suffix appended to it) recorded for it in
the library could not in general be used to obtain the real name (and,
hence, path) of the ZIM file. Now the book path is "corrected" as soon
as the file name becomes available.
One subtlety of this refactoring is that
ContentManager::downloadDisappeared() is now NOT called from
updateDownloads() directly/synchronously but is invoked via a signal
and is thus executed in the main thread.
A new class DownloadManager was introduced as a new home for
ContentManagerModel::Downloads, but it is going to grow into a more
serious unit of code that will consolidate most functionality
related to download management.
The change in #1048 prevented opening of blank tab and urls that are no longer valid. Now, we will need to open them as well, as we will need the exact number of tabs to reopen in order to correctly restore current tab index.
Clicking and hovering the description dropdown of zim no longer whites out. Replaced manual drawing with default handling as it is no longer necessary.
Before this change a library entry having keyboard focus (selected with
tab and up/down keys) was not readable since the text was displayed in
white colour on light blue background.
Now the library entry line separator extends all the way to the right
(into the book open/download control column).
This is achieved by having QStyledItemDelegate::paint() execute before
ContentManagerDelegate::paintBookState() and the latter must take care
to not paint over the line separator painted by the former.
Indirect access from ContentManagerModel to ContentManager (via
KiwixApp) contained a race condition that could lead to a crash.
Here is the call chain:
- In KiwixApp::init() the KiwixApp::mp_manager data member is initialized
as follows:
mp_manager = new ContentManager(&m_library, mp_downloader);
- ContentManager's constructor creates the model and the view:
mp_view = new ContentManagerView();
managerModel = new ContentManagerModel(this);
updateModel();
auto treeView = mp_view->getView();
treeView->setModel(managerModel);
treeView->show();
- This starts a cascade of asynchronous events that will eventually
result in ContentManagerModel::sort() being executed. The latter has
to call ContentManager::sortBy() and if it does so indirectly via
`KiwixApp::getContentManager()` before the constructor of
ContentManager has completed (and KiwixApp::mp_manager has been
assigned to) a crash is imminent.
This commit eliminates that issue.
- made the download ring a little darker so that it doesn't become
invisible when highlighted
- changed the background color of the button for the Open/Download actions
(drawn in the last column) from white to transparent so that it
doesn't look ugly on the highlighted line.