small fixes
This commit is contained in:
parent
8d672465dc
commit
ae1f145e17
|
@ -259,7 +259,6 @@ std::unique_ptr<Package> AlpmDatabase::emptyPackage()
|
|||
*/
|
||||
void AlpmDatabase::databaseDownloadFinished()
|
||||
{
|
||||
removeBusyFlag();
|
||||
auto *reply = static_cast<QNetworkReply *>(sender());
|
||||
reply->deleteLater();
|
||||
bool filesDatabase = reply->property("filesDatabase").toBool();
|
||||
|
@ -274,6 +273,7 @@ void AlpmDatabase::databaseDownloadFinished()
|
|||
if(!QFile::rename(newDatabasePath, backupFile)) {
|
||||
cerr << "An IO error occured when storing database file for [" << name().toLocal8Bit().data() << "]: Unable to rename present database file." << endl;
|
||||
reply = nullptr;
|
||||
removeBusyFlag();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -285,10 +285,11 @@ void AlpmDatabase::databaseDownloadFinished()
|
|||
QWriteLocker locker(lock());
|
||||
m_dbPath = newDatabasePath;
|
||||
}
|
||||
initAsSoonAsPossible();
|
||||
init();
|
||||
} else {
|
||||
locker.relock();
|
||||
cerr << "An IO error occured when storing database file for [" << name().toLocal8Bit().data() << "]: Unable to create/write output file." << endl;
|
||||
removeBusyFlag();
|
||||
}
|
||||
} else {
|
||||
cerr << "An error occured when dwonloading database file for [" << name().toLocal8Bit().data() << "]: " << reply->errorString().toLocal8Bit().data() << endl;
|
||||
|
@ -296,6 +297,8 @@ void AlpmDatabase::databaseDownloadFinished()
|
|||
cerr << "-> Attempting to download regular database file instead of files database file." << endl;
|
||||
locker.unlock();
|
||||
downloadDatabase(m_downloadTargetDir, false);
|
||||
} else {
|
||||
removeBusyFlag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,8 +498,8 @@ void Manager::initAlpmDataBases()
|
|||
if(localDatabase()) {
|
||||
loaders << static_cast<AlpmPackageLoader *>(localDatabase()->init());
|
||||
}
|
||||
for(auto &syncDbEntry : m_syncDbMap) {
|
||||
loaders << static_cast<AlpmPackageLoader *>(syncDbEntry.second->init());
|
||||
for(auto &syncDb : m_syncDbs) {
|
||||
loaders << static_cast<AlpmPackageLoader *>(syncDb->init());
|
||||
}
|
||||
for(auto *loader : loaders) {
|
||||
if(loader) {
|
||||
|
|
|
@ -58,17 +58,17 @@ public:
|
|||
void setWriteCacheBeforeGone(bool writeCacheBeforeGone);
|
||||
bool isAutoCacheMaintenanceEnabled() const;
|
||||
void setAutoCacheMaintenanceEnabled(bool enabled);
|
||||
void writeCache();
|
||||
void restoreCache();
|
||||
void cleanCache();
|
||||
void wipeCache();
|
||||
void maintainCache();
|
||||
Q_SLOT void writeCache();
|
||||
Q_SLOT void restoreCache();
|
||||
Q_SLOT void cleanCache();
|
||||
Q_SLOT void wipeCache();
|
||||
Q_SLOT void maintainCache();
|
||||
|
||||
// updating
|
||||
bool isAutoUpdateEnabled() const;
|
||||
void setAutoUpdateEnabled(bool enabled);
|
||||
void updateAlpmDatabases();
|
||||
void forceUpdateAlpmDatabases();
|
||||
Q_SLOT void updateAlpmDatabases();
|
||||
Q_SLOT void forceUpdateAlpmDatabases();
|
||||
|
||||
// package lookup
|
||||
AlpmPackage *packageFromDatabase(const QString &dbName, const QString &pkgName);
|
||||
|
|
10
gui/main.cpp
10
gui/main.cpp
|
@ -58,6 +58,7 @@ int main(int argc, char *argv[])
|
|||
if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
|
||||
// configure Qt
|
||||
qtConfigArgs.applySettings();
|
||||
QApplication application(argc, argv);
|
||||
|
||||
// find directory with web files
|
||||
QString webdir;
|
||||
|
@ -67,11 +68,6 @@ int main(int argc, char *argv[])
|
|||
webdir = QStringLiteral("/usr/share/" PROJECT_NAME "/web");
|
||||
}
|
||||
|
||||
// create app
|
||||
QApplication application(argc, argv);
|
||||
MainWindow mainWindow(webdir);
|
||||
mainWindow.show();
|
||||
|
||||
// setup manager
|
||||
Manager manager(config);
|
||||
cerr << shchar << "Loading databases ..." << endl;
|
||||
|
@ -89,6 +85,10 @@ int main(int argc, char *argv[])
|
|||
manager.setAutoCacheMaintenanceEnabled(true);
|
||||
manager.setAutoUpdateEnabled(true);
|
||||
|
||||
// create app
|
||||
MainWindow mainWindow(webdir, &manager);
|
||||
mainWindow.show();
|
||||
|
||||
// run Qt event loop
|
||||
return application.exec();
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "./mainwindow.h"
|
||||
#include "./webpage.h"
|
||||
|
||||
#include "../alpm/manager.h"
|
||||
|
||||
#include "resources/config.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
@ -17,7 +19,9 @@ namespace RepoIndex {
|
|||
/*!
|
||||
* \brief Constructs a new main window.
|
||||
*/
|
||||
MainWindow::MainWindow(const QString &webdir)
|
||||
MainWindow::MainWindow(const QString &webdir, Manager *manager) :
|
||||
m_manager(manager),
|
||||
m_contextMenu(nullptr)
|
||||
{
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
setWindowTitle(QStringLiteral(APP_NAME));
|
||||
|
@ -79,12 +83,24 @@ bool MainWindow::event(QEvent *event)
|
|||
*/
|
||||
void MainWindow::showInfoWebViewContextMenu(const QPoint &)
|
||||
{
|
||||
QAction copyAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy"), nullptr);
|
||||
copyAction.setDisabled(m_webView.selectedText().isEmpty());
|
||||
connect(©Action, &QAction::triggered, this, &MainWindow::copyInfoWebViewSelection);
|
||||
QMenu menu;
|
||||
menu.addAction(©Action);
|
||||
menu.exec(QCursor::pos());
|
||||
if(!m_contextMenu) {
|
||||
m_contextMenu = new QMenu(this);
|
||||
auto *reloadAction = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), tr("Reload UI"), m_contextMenu);
|
||||
connect(reloadAction, &QAction::triggered, &m_webView, &WEB_VIEW_PROVIDER::reload);
|
||||
m_copyAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy"), m_contextMenu);
|
||||
connect(m_copyAction, &QAction::triggered, this, &MainWindow::copyInfoWebViewSelection);
|
||||
auto *updateAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-download")), tr("Update sync-databases"), m_contextMenu);
|
||||
connect(updateAction, &QAction::triggered, m_manager, &Manager::forceUpdateAlpmDatabases);
|
||||
auto *wipeCacheAction = new QAction(QIcon::fromTheme(QStringLiteral("document-revert")), tr("Wipe cached packages"), m_contextMenu);
|
||||
connect(wipeCacheAction, &QAction::triggered, m_manager, &Manager::wipeCache);
|
||||
m_contextMenu->addAction(m_copyAction);
|
||||
m_contextMenu->addAction(reloadAction);
|
||||
m_contextMenu->addSeparator();
|
||||
m_contextMenu->addAction(updateAction);
|
||||
m_contextMenu->addAction(wipeCacheAction);
|
||||
}
|
||||
m_copyAction->setDisabled(m_webView.selectedText().isEmpty());
|
||||
m_contextMenu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
|
||||
namespace RepoIndex {
|
||||
|
||||
class Manager;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(const QString &webdir);
|
||||
MainWindow(const QString &webdir, Manager *manager);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
@ -26,7 +28,10 @@ private slots:
|
|||
void copyInfoWebViewSelection();
|
||||
|
||||
private:
|
||||
Manager *m_manager;
|
||||
WEB_VIEW_PROVIDER m_webView;
|
||||
QMenu *m_contextMenu;
|
||||
QAction *m_copyAction;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,17 @@
|
|||
if(color) {
|
||||
this.rowElement.style.backgroundColor = color;
|
||||
}
|
||||
this.rowElement.onclick = function(e) {
|
||||
repoindex.pageManager.packageManager.showPackageInfoForIndex(this.entry.index, typeof e === "object" && e.button === 1);
|
||||
this.rowElement.onmousedown = function(e) {
|
||||
if(!repoindex.isFirefox) {
|
||||
repoindex.pageManager.packageManager.showPackageInfoForIndex(this.entry.index, typeof e === "object" && (e.button === 1 || e.button === 2));
|
||||
}
|
||||
};
|
||||
this.rowElement.oncontextmenu = function(e) {
|
||||
e.preventDefault();
|
||||
// Firefox doesn't support properly support mouse events -> use context menu event to show package info
|
||||
if(repoindex.isFirefox) {
|
||||
repoindex.pageManager.packageManager.showPackageInfoForIndex(this.entry.index, true);
|
||||
}
|
||||
};
|
||||
|
||||
this.initTableRow = function() {
|
||||
|
@ -155,6 +164,9 @@
|
|||
repoindex.addField(tb, "Repository", repoindex.makeStr(entry.info.repo));
|
||||
}
|
||||
repoindex.addField(tb, "Version", repoindex.makeStr(basics.ver));
|
||||
if(basics.fdate) {
|
||||
repoindex.addField(tb, "Out-of-date", "since " + repoindex.makeStr(basics.fdate)).style.color = "red";
|
||||
}
|
||||
repoindex.addField(tb, "Description", repoindex.makeStr(basics.desc));
|
||||
if(basics.arch) {
|
||||
repoindex.addField(tb, "Architecture", repoindex.makeStr(basics.arch));
|
||||
|
@ -204,9 +216,6 @@
|
|||
if(details.main) {
|
||||
repoindex.addField(tb, "Maintainer", repoindex.makeStr(details.main));
|
||||
}
|
||||
if(basics.flagdate) {
|
||||
repoindex.addField(tb, "Out-of-date", repoindex.makeStr(basics.flagdate));
|
||||
}
|
||||
if(details.fsub) {
|
||||
repoindex.addField(tb, "First submitted", repoindex.makeStr(details.fsub));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
var repoindex = (function(repoindex) {
|
||||
|
||||
/*!
|
||||
* \brief Adds a bootstrap pagination to the HTML element with the specified id.
|
||||
*/
|
||||
// Adds a bootstrap pagination to the HTML element with the specified id
|
||||
repoindex.Pagination = function(containerId) {
|
||||
// basic initialization
|
||||
this.containerId = containerId;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
var repoindex = (function(repoindex) {
|
||||
|
||||
/*!
|
||||
* \brief Adds bootstrap tabs to the HTML element with the specified id.
|
||||
*/
|
||||
// Adds bootstrap tabs to the HTML element with the specified id.
|
||||
repoindex.Tabbing = function(containerId) {
|
||||
// assemble required element structure
|
||||
this.containerElement = document.createElement("div");
|
||||
|
|
|
@ -385,7 +385,9 @@
|
|||
return function() {
|
||||
func.call(obj, args);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
repoindex.isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
|
||||
|
||||
return repoindex;
|
||||
|
||||
|
|
Loading…
Reference in New Issue