Fix config persa al riavvio: file di configurazione fisso condiviso tra nemo e defaultuser (/home/nemo/.config/harbour/calibreweb.conf) + migrazione automatica dei valori gia' salvati (server, credenziali, margini, segnalibri)
This commit is contained in:
@@ -83,7 +83,9 @@ rpm/ spec e desktop file
|
|||||||
## Limiti noti
|
## Limiti noti
|
||||||
|
|
||||||
- La password è salvata in chiaro nelle impostazioni dell'app
|
- La password è salvata in chiaro nelle impostazioni dell'app
|
||||||
(`~/.config/harbour/calibreweb.conf`) — accettabile per uso personale.
|
(`/home/nemo/.config/harbour/calibreweb.conf`) — accettabile per uso
|
||||||
|
personale. Il file è fisso e condiviso tra launcher (nemo) e debug SSH
|
||||||
|
(defaultuser): la config non dipende dall'utente che avvia l'app.
|
||||||
- La ricerca usa il motore del server; risultati identici alla UI web.
|
- La ricerca usa il motore del server; risultati identici alla UI web.
|
||||||
- Il core C++ (parsing, auth, download) è testato con Qt 5.15 contro feed
|
- Il core C++ (parsing, auth, download) è testato con Qt 5.15 contro feed
|
||||||
OPDS reali e un mock con Basic Auth; la UI Silica richiede il SDK per
|
OPDS reali e un mock con Basic Auth; la UI Silica richiede il SDK per
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ in locale.
|
|||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Wed Aug 19 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.2.0-1
|
* Wed Aug 19 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.2.0-1
|
||||||
|
- Fix configurazione persa: file di configurazione unico e fisso
|
||||||
|
(/home/nemo/.config/harbour/calibreweb.conf) indipendente dall'utente
|
||||||
|
che avvia l'app (launcher nemo / debug SSH defaultuser), con migrazione
|
||||||
|
automatica dei valori gia' salvati
|
||||||
- Lettore EPUB nativo (WebView): capitoli, reflow A-/A+, margini
|
- Lettore EPUB nativo (WebView): capitoli, reflow A-/A+, margini
|
||||||
configurabili, posizione salvata in locale (QSettings) e ripristinata
|
configurabili, posizione salvata in locale (QSettings) e ripristinata
|
||||||
all'apertura
|
all'apertura
|
||||||
|
|||||||
+53
-1
@@ -4,17 +4,69 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
QString Settings::configPath()
|
||||||
|
{
|
||||||
|
const QString dir = QStringLiteral("/home/nemo/.config/harbour");
|
||||||
|
QDir().mkpath(dir);
|
||||||
|
return dir + QStringLiteral("/calibreweb.conf");
|
||||||
|
}
|
||||||
|
|
||||||
Settings::Settings(QObject *parent)
|
Settings::Settings(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_settings(QStringLiteral("harbour"), QStringLiteral("calibreweb"))
|
, m_settings(configPath(), QSettings::IniFormat)
|
||||||
{
|
{
|
||||||
|
migrateIfNeeded();
|
||||||
// diagnostica: path reale del file di configurazione e valori letti all'avvio
|
// diagnostica: path reale del file di configurazione e valori letti all'avvio
|
||||||
qDebug() << "Settings file:" << m_settings.fileName();
|
qDebug() << "Settings file:" << m_settings.fileName();
|
||||||
|
if (m_settings.status() != QSettings::NoError)
|
||||||
|
qDebug() << "Settings WARNING: file di configurazione non accessibile (permessi?)";
|
||||||
qDebug() << "Settings read: serverUrl=[" << serverUrl() << "] user=[" << username()
|
qDebug() << "Settings read: serverUrl=[" << serverUrl() << "] user=[" << username()
|
||||||
<< "] ssl=" << ignoreSslErrors() << "margin=" << readerMargin()
|
<< "] ssl=" << ignoreSslErrors() << "margin=" << readerMargin()
|
||||||
<< "marginV=" << readerMarginV();
|
<< "marginV=" << readerMarginV();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::migrateIfNeeded()
|
||||||
|
{
|
||||||
|
if (!serverUrl().isEmpty())
|
||||||
|
return; // il file condiviso ha gia' una configurazione
|
||||||
|
// Sorgenti candidate: config per-utente corrente + i path noti degli altri
|
||||||
|
// utenti (launcher=nemo, debug SSH=defaultuser). La prima con valori vince.
|
||||||
|
const QStringList candidates = QStringList()
|
||||||
|
<< QSettings(QStringLiteral("harbour"), QStringLiteral("calibreweb")).fileName()
|
||||||
|
<< QStringLiteral("/home/nemo/.config/harbour/calibreweb.conf")
|
||||||
|
<< QStringLiteral("/home/defaultuser/.config/harbour/calibreweb.conf");
|
||||||
|
for (const QString &cand : candidates) {
|
||||||
|
QSettings src(cand, QSettings::IniFormat);
|
||||||
|
const QString url = src.value(QStringLiteral("serverUrl")).toString();
|
||||||
|
if (url.isEmpty())
|
||||||
|
continue;
|
||||||
|
m_settings.setValue(QStringLiteral("serverUrl"), url);
|
||||||
|
m_settings.setValue(QStringLiteral("username"), src.value(QStringLiteral("username")));
|
||||||
|
m_settings.setValue(QStringLiteral("password"), src.value(QStringLiteral("password")));
|
||||||
|
m_settings.setValue(QStringLiteral("ignoreSslErrors"),
|
||||||
|
src.value(QStringLiteral("ignoreSslErrors")));
|
||||||
|
m_settings.setValue(QStringLiteral("readerMargin"),
|
||||||
|
src.value(QStringLiteral("readerMargin"), 24));
|
||||||
|
m_settings.setValue(QStringLiteral("readerMarginV"),
|
||||||
|
src.value(QStringLiteral("readerMarginV"), 0));
|
||||||
|
// segnalibri di lettura per libro+formato
|
||||||
|
src.beginGroup(QStringLiteral("bookmarks"));
|
||||||
|
const QStringList groups = src.childGroups();
|
||||||
|
for (const QString &g : groups) {
|
||||||
|
src.beginGroup(g);
|
||||||
|
const QStringList keys = src.childKeys();
|
||||||
|
for (const QString &k : keys)
|
||||||
|
m_settings.setValue(QStringLiteral("bookmarks/%1/%2").arg(g).arg(k),
|
||||||
|
src.value(k));
|
||||||
|
src.endGroup();
|
||||||
|
}
|
||||||
|
src.endGroup();
|
||||||
|
m_settings.sync();
|
||||||
|
qDebug() << "Settings: importati i valori da" << cand;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Settings::serverUrl() const
|
QString Settings::serverUrl() const
|
||||||
{
|
{
|
||||||
return m_settings.value(QStringLiteral("serverUrl")).toString();
|
return m_settings.value(QStringLiteral("serverUrl")).toString();
|
||||||
|
|||||||
@@ -66,6 +66,15 @@ signals:
|
|||||||
void baseUrlChanged();
|
void baseUrlChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Path fisso condiviso: l'app deve leggere/scrivere SEMPRE lo stesso file,
|
||||||
|
// sia avviata dal launcher (utente nemo) sia da SSH di debug (defaultuser).
|
||||||
|
// Con QSettings("harbour","calibreweb") il file dipende dalla HOME
|
||||||
|
// dell'utente che avvia -> configurazione invisibile dall'altro utente.
|
||||||
|
static QString configPath();
|
||||||
|
// Importa i valori dalla vecchia config per-utente (~/.config/harbour/...) se
|
||||||
|
// il file condiviso e' vuoto: copre la configurazione fatta prima del fix.
|
||||||
|
void migrateIfNeeded();
|
||||||
|
|
||||||
QSettings m_settings;
|
QSettings m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user