This commit is contained in:
Martin Rotter 2023-01-27 09:04:07 +01:00
parent c49f1fc1e6
commit a3510afd4d
6 changed files with 49 additions and 28 deletions

View File

@ -290,6 +290,8 @@ void TextBrowserViewer::loadMessages(const QList<Message>& messages, RootItem* r
auto html_messages = prepareHtmlForMessage(messages, root);
html_messages.m_html = IOFactory::readFile("aa.html");
setHtml(html_messages.m_html, html_messages.m_baseUrl);
emit loadingFinished(true);
}

View File

@ -294,6 +294,12 @@ ServiceRoot::LabelOperation ServiceRoot::supportedLabelOperations() const {
return LabelOperation::Adding | LabelOperation::Editing | LabelOperation::Deleting;
}
QString ServiceRoot::additionalTooltip() const {
return tr("Number of feeds: %1\n"
"Number of categories: %2")
.arg(QString::number(getSubTreeFeeds().size()), QString::number(getSubTreeCategories().size()));
}
void ServiceRoot::saveAccountDataToDatabase() {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());

View File

@ -62,6 +62,7 @@ class ServiceRoot : public RootItem {
virtual bool supportsFeedAdding() const;
virtual bool supportsCategoryAdding() const;
virtual LabelOperation supportedLabelOperations() const;
virtual QString additionalTooltip() const;
virtual void saveAccountDataToDatabase();
virtual QVariantHash customDatabaseData() const;
virtual void setCustomDatabaseData(const QVariantHash& data);

View File

@ -48,9 +48,16 @@ RootItem* GmailServiceRoot::obtainNewTreeForSyncIn() const {
inbox->setKeepOnTop(true);
root->appendChild(inbox);
root->appendChild(new Feed(tr("Sent"), QSL(GMAIL_SYSTEM_LABEL_SENT), qApp->icons()->fromTheme(QSL("mail-sent")), root));
root->appendChild(new Feed(tr("Drafts"), QSL(GMAIL_SYSTEM_LABEL_DRAFT), qApp->icons()->fromTheme(QSL("gtk-edit")), root));
root->appendChild(new Feed(tr("Spam"), QSL(GMAIL_SYSTEM_LABEL_SPAM), qApp->icons()->fromTheme(QSL("mail-mark-junk")), root));
root
->appendChild(new Feed(tr("Sent"), QSL(GMAIL_SYSTEM_LABEL_SENT), qApp->icons()->fromTheme(QSL("mail-sent")), root));
root->appendChild(new Feed(tr("Drafts"),
QSL(GMAIL_SYSTEM_LABEL_DRAFT),
qApp->icons()->fromTheme(QSL("gtk-edit")),
root));
root->appendChild(new Feed(tr("Spam"),
QSL(GMAIL_SYSTEM_LABEL_SPAM),
qApp->icons()->fromTheme(QSL("mail-mark-junk")),
root));
return root;
}
@ -84,7 +91,8 @@ void GmailServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
}
QList<Message> GmailServiceRoot::obtainNewMessages(Feed* feed,
const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
const QHash<ServiceRoot::BagOfMessages, QStringList>&
stated_messages,
const QHash<QString, QStringList>& tagged_messages) {
Q_UNUSED(stated_messages)
Q_UNUSED(tagged_messages)
@ -116,11 +124,12 @@ QList<QAction*> GmailServiceRoot::contextMenuMessagesList(const QList<Message>&
m_replyToMessage = messages.at(0);
if (m_actionReply == nullptr) {
m_actionReply = new QAction(qApp->icons()->fromTheme(QSL("mail-reply-sender")), tr("Reply to this e-mail message"), this);
m_actionReply =
new QAction(qApp->icons()->fromTheme(QSL("mail-reply-sender")), tr("Reply to this e-mail message"), this);
connect(m_actionReply, &QAction::triggered, this, &GmailServiceRoot::replyToEmail);
}
return { m_actionReply };
return {m_actionReply};
}
else {
return {};
@ -131,7 +140,8 @@ QList<QAction*> GmailServiceRoot::serviceMenu() {
if (m_serviceMenu.isEmpty()) {
ServiceRoot::serviceMenu();
QAction* act_new_email = new QAction(qApp->icons()->fromTheme(QSL("mail-message-new")), tr("Write new e-mail message"), this);
QAction* act_new_email =
new QAction(qApp->icons()->fromTheme(QSL("mail-message-new")), tr("Write new e-mail message"), this);
connect(act_new_email, &QAction::triggered, this, &GmailServiceRoot::writeNewEmail);
m_serviceMenu.append(act_new_email);
@ -191,12 +201,12 @@ QString GmailServiceRoot::code() const {
}
QString GmailServiceRoot::additionalTooltip() const {
return tr("Authentication status: %1\n"
"Login tokens expiration: %2").arg(network()->oauth()->isFullyLoggedIn()
? tr("logged-in")
: tr("NOT logged-in"),
network()->oauth()->tokensExpireIn().isValid() ?
network()->oauth()->tokensExpireIn().toString() : QSL("-"));
return ServiceRoot::additionalTooltip() + QSL("\n") +
tr("Authentication status: %1\n"
"Login tokens expiration: %2")
.arg(network()->oauth()->isFullyLoggedIn() ? tr("logged-in") : tr("NOT logged-in"),
network()->oauth()->tokensExpireIn().isValid() ? network()->oauth()->tokensExpireIn().toString()
: QSL("-"));
}
void GmailServiceRoot::saveAllCachedData(bool ignore_errors) {
@ -210,8 +220,7 @@ void GmailServiceRoot::saveAllCachedData(bool ignore_errors) {
QStringList ids = i.value();
if (!ids.isEmpty()) {
if (network()->markMessagesRead(key, ids, networkProxy()) !=
QNetworkReply::NetworkError::NoError &&
if (network()->markMessagesRead(key, ids, networkProxy()) != QNetworkReply::NetworkError::NoError &&
!ignore_errors) {
addMessageStatesToCache(ids, key);
}
@ -227,14 +236,14 @@ void GmailServiceRoot::saveAllCachedData(bool ignore_errors) {
QList<Message> messages = j.value();
if (!messages.isEmpty()) {
QStringList custom_ids; custom_ids.reserve(messages.size());
QStringList custom_ids;
custom_ids.reserve(messages.size());
for (const Message& msg : messages) {
custom_ids.append(msg.m_customId);
}
if (network()->markMessagesStarred(key, custom_ids, networkProxy()) !=
QNetworkReply::NetworkError::NoError &&
if (network()->markMessagesStarred(key, custom_ids, networkProxy()) != QNetworkReply::NetworkError::NoError &&
!ignore_errors) {
addMessageStatesToCache(messages, key);
}

View File

@ -123,10 +123,12 @@ QString RedditServiceRoot::code() const {
}
QString RedditServiceRoot::additionalTooltip() const {
return tr("Authentication status: %1\n"
return ServiceRoot::additionalTooltip() + QSL("\n") +
tr("Authentication status: %1\n"
"Login tokens expiration: %2")
.arg(network()->oauth()->isFullyLoggedIn() ? tr("logged-in") : tr("NOT logged-in"),
network()->oauth()->tokensExpireIn().isValid() ? network()->oauth()->tokensExpireIn().toString() : QSL("-"));
.arg(network()->oauth()->isFullyLoggedIn() ? tr("logged-in") : tr("NOT logged-in"),
network()->oauth()->tokensExpireIn().isValid() ? network()->oauth()->tokensExpireIn().toString()
: QSL("-"));
}
void RedditServiceRoot::saveAllCachedData(bool ignore_errors) {

View File

@ -363,14 +363,15 @@ QList<Message> TtRssServiceRoot::obtainMessagesViaHeadlines(Feed* feed) {
}
QString TtRssServiceRoot::additionalTooltip() const {
return tr("Username: %1\nServer: %2\n"
return ServiceRoot::additionalTooltip() + QSL("\n") +
tr("Username: %1\nServer: %2\n"
"Last error: %3\nLast login on: %4")
.arg(m_network->username(),
m_network->url(),
NetworkFactory::networkErrorText(m_network->lastError()),
m_network->lastLoginTime().isValid()
? QLocale().toString(m_network->lastLoginTime(), QLocale::FormatType::ShortFormat)
: QSL("-"));
.arg(m_network->username(),
m_network->url(),
NetworkFactory::networkErrorText(m_network->lastError()),
m_network->lastLoginTime().isValid()
? QLocale().toString(m_network->lastLoginTime(), QLocale::FormatType::ShortFormat)
: QSL("-"));
}
TtRssNetworkFactory* TtRssServiceRoot::network() const {