feat(ui): show the application journal in the Logs screen
The Logs screen only offered /var/log/pacman.log, which is unreadable without root and says nothing about what the app itself did. Let the user switch between that file and the new application journal, refresh it live while an operation runs, and record navigation and dialog events so the screen tells the whole story. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
3 files changed
+99
-7
No files matched your search
+58
-1
@@ -28,6 +28,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "app-logging.h"
|
||||
#include "log-manager.h"
|
||||
#include "browse-page.h"
|
||||
#include "cleanup-page.h"
|
||||
#include "dashboard-page.h"
|
||||
@@ -660,9 +661,13 @@ void MainWindow::setupMenuBar() {
|
||||
|
||||
QMenu* fileMenu = menuBar->addMenu("Fichier");
|
||||
fileMenu->addAction("Exporter la liste affichée...", this, [this] {
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("export de la liste affichée"));
|
||||
m_browse->exportCsv();
|
||||
});
|
||||
fileMenu->addAction("Exporter l'historique...", this, [this] {
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("export de l'historique"));
|
||||
m_history->exportCsv();
|
||||
});
|
||||
fileMenu->addSeparator();
|
||||
@@ -770,7 +775,11 @@ void MainWindow::setupShortcuts() {
|
||||
bind(QKeySequence(QStringLiteral("Ctrl+U")), [this]() {
|
||||
m_navGroup->button(NavUpdates)->click();
|
||||
});
|
||||
bind(QKeySequence(QStringLiteral("Ctrl+E")), [this]() { m_browse->exportCsv(); });
|
||||
bind(QKeySequence(QStringLiteral("Ctrl+E")), [this]() {
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("export de la liste affichée"));
|
||||
m_browse->exportCsv();
|
||||
});
|
||||
bind(QKeySequence::Quit, [this]() { close(); });
|
||||
}
|
||||
|
||||
@@ -781,6 +790,23 @@ void MainWindow::setupShortcuts() {
|
||||
void MainWindow::onNavChanged(int id) {
|
||||
qCDebug(pacmgrUi) << "navigate to page" << id;
|
||||
|
||||
QString pageName;
|
||||
switch (id) {
|
||||
case NavDashboard: pageName = QStringLiteral("tableau de bord"); break;
|
||||
case NavSearch: pageName = QStringLiteral("recherche"); break;
|
||||
case NavInstalled: pageName = QStringLiteral("installés"); break;
|
||||
case NavUpdates: pageName = QStringLiteral("mises à jour"); break;
|
||||
case NavCleanup: pageName = QStringLiteral("nettoyage"); break;
|
||||
case NavHistory: pageName = QStringLiteral("historique"); break;
|
||||
case NavLogs: pageName = QStringLiteral("logs"); break;
|
||||
case NavPlugins: pageName = QStringLiteral("plugins"); break;
|
||||
default: break;
|
||||
}
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("ui"),
|
||||
pageName.isEmpty() ? QStringLiteral("navigation → page %1").arg(id)
|
||||
: QStringLiteral("navigation → %1").arg(pageName));
|
||||
|
||||
switch (id) {
|
||||
case NavDashboard:
|
||||
m_pages->setCurrentWidget(m_dashboard);
|
||||
@@ -832,6 +858,9 @@ void MainWindow::onOpenPage(const QString& pageId) {
|
||||
void MainWindow::onOpenPackage(const QString& name) {
|
||||
if (name.isEmpty()) return;
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("ui"),
|
||||
QStringLiteral("ouverture des détails de %1").arg(name));
|
||||
m_browse->selectOnNextLoad(name);
|
||||
if (QAbstractButton* button = m_navGroup->button(NavInstalled)) button->click();
|
||||
statusBar()->showMessage(QString("Ouverture des détails de %1...").arg(name));
|
||||
@@ -846,10 +875,14 @@ void MainWindow::onStartRequested(const AppCore::StartResult& result, const QStr
|
||||
}
|
||||
|
||||
void MainWindow::onRefresh() {
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("clic rafraîchir les sources"));
|
||||
handleStartResult(m_core->refresh(), "Rafraîchissement des sources");
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateAll() {
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("clic tout mettre à jour"));
|
||||
handleStartResult(m_core->updateAll(), "Mise à jour globale");
|
||||
}
|
||||
|
||||
@@ -868,6 +901,11 @@ void MainWindow::onTrayActivated(QSystemTrayIcon::ActivationReason reason) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void MainWindow::applyCredentialMode(AppCore::CredentialMode mode) {
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("ui"),
|
||||
QStringLiteral("mode d'identifiants → %1")
|
||||
.arg(mode == AppCore::CredentialMode::AtLaunch ? QStringLiteral("au lancement")
|
||||
: QStringLiteral("à chaque fois")));
|
||||
m_core->setCredentialMode(mode);
|
||||
// Per-session credentials: prompt once now so operations don't re-ask. The
|
||||
// core reports the mode change in the status bar itself.
|
||||
@@ -879,21 +917,34 @@ void MainWindow::applyCredentialMode(AppCore::CredentialMode mode) {
|
||||
bool MainWindow::promptForSudoPassword() {
|
||||
if (m_core->hasSudoPassword()) return true;
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("ui"),
|
||||
QStringLiteral("demande du mot de passe administrateur"));
|
||||
|
||||
bool ok = false;
|
||||
const QString password = QInputDialog::getText(
|
||||
this, "Authentification",
|
||||
"Mot de passe administrateur (sudo) :",
|
||||
QLineEdit::Password, QString(), &ok);
|
||||
if (!ok) {
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("ui"),
|
||||
QStringLiteral("mot de passe refusé par l'utilisateur"));
|
||||
statusBar()->showMessage("Opération annulée : identifiants requis.");
|
||||
return false;
|
||||
}
|
||||
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("mot de passe fourni"));
|
||||
m_core->setSudoPassword(password);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::showActionError(const QString& title, const QString& error, bool locked) {
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("erreur"),
|
||||
QStringLiteral("%1 : %2").arg(title, error.isEmpty() ? QStringLiteral("sans détail") : error));
|
||||
|
||||
// A locked database is the one failure the app can resolve on its own, so it
|
||||
// gets its own dialog instead of a message the user has to act on by hand.
|
||||
if (locked) {
|
||||
@@ -930,6 +981,10 @@ void MainWindow::handleStartResult(const AppCore::StartResult& result,
|
||||
}
|
||||
|
||||
void MainWindow::handleDatabaseLock(const QString& title) {
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("verrou"),
|
||||
QStringLiteral("%1 : %2").arg(title, m_core->databaseLockDescription()));
|
||||
|
||||
// The other manager frequently finishes while the failed operation was
|
||||
// unwinding: retry straight away rather than announcing a lock that is gone.
|
||||
if (!m_core->databaseLocked()) {
|
||||
@@ -1095,6 +1150,8 @@ void MainWindow::onCoreHistoryChanged() {
|
||||
}
|
||||
|
||||
void MainWindow::onCheckForUpdates() {
|
||||
LogManager::instance().logEvent(QStringLiteral("ui"),
|
||||
QStringLiteral("clic vérifier les mises à jour"));
|
||||
m_core->checkForAppUpdate();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user