Upgrade logic of loading/saving/displaying icons of feeds/categories.
This commit is contained in:
parent
86a53e011b
commit
478b03a025
@ -51,6 +51,7 @@
|
||||
<file>./graphics/Faenza/emblems/64/emblem-downloads.png</file>
|
||||
<file>./graphics/Faenza/emblems/64/emblem-system.png</file>
|
||||
<file>./graphics/Faenza/index.theme</file>
|
||||
<file>./graphics/Faenza/mimetypes/64/application-rss+xml.png</file>
|
||||
<file>./graphics/Faenza/mimetypes/64/image-x-generic.png</file>
|
||||
<file>./graphics/Faenza/mimetypes/64/text-html.png</file>
|
||||
<file>./graphics/Faenza/places/64/folder.png</file>
|
||||
|
File diff suppressed because one or more lines are too long
@ -28,7 +28,7 @@ discover_used_icons() {
|
||||
#echo "Root src folder: \"$ROOT_SRC_FOLDER\"."
|
||||
|
||||
# Now we discover all usages of icons.
|
||||
local ICON_NAMES=$(grep -Prioh '(?<=fromTheme\(QSL\(\")[-a-z]+' "$ROOT_SRC_FOLDER" | sort -u)
|
||||
local ICON_NAMES=$(grep -Prioh '(?<=fromTheme\(QSL\(\")[-\+a-z]+' "$ROOT_SRC_FOLDER" | sort -u)
|
||||
|
||||
cd "$RESOURCES_FOLDER"
|
||||
|
||||
|
@ -12,18 +12,10 @@
|
||||
|
||||
Category::Category(RootItem* parent) : RootItem(parent) {
|
||||
setKind(RootItemKind::Category);
|
||||
|
||||
if (icon().isNull()) {
|
||||
setIcon(qApp->icons()->fromTheme(QSL("folder")));
|
||||
}
|
||||
}
|
||||
|
||||
Category::Category(const Category& other) : RootItem(other) {
|
||||
setKind(RootItemKind::Category);
|
||||
|
||||
if (icon().isNull()) {
|
||||
setIcon(qApp->icons()->fromTheme(QSL("folder")));
|
||||
}
|
||||
}
|
||||
|
||||
Category::Category(const QSqlRecord& record) : Category(nullptr) {
|
||||
@ -37,12 +29,7 @@ Category::Category(const QSqlRecord& record) : Category(nullptr) {
|
||||
setTitle(record.value(CAT_DB_TITLE_INDEX).toString());
|
||||
setDescription(record.value(CAT_DB_DESCRIPTION_INDEX).toString());
|
||||
setCreationDate(TextFactory::parseDateTime(record.value(CAT_DB_DCREATED_INDEX).value<qint64>()).toLocalTime());
|
||||
|
||||
QIcon loaded_icon = qApp->icons()->fromByteArray(record.value(CAT_DB_ICON_INDEX).toByteArray());
|
||||
|
||||
if (!loaded_icon.isNull()) {
|
||||
setIcon(loaded_icon);
|
||||
}
|
||||
setIcon(qApp->icons()->fromByteArray(record.value(CAT_DB_ICON_INDEX).toByteArray()));
|
||||
}
|
||||
|
||||
Category::~Category() {}
|
||||
|
@ -46,7 +46,7 @@ int FormFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, c
|
||||
loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot);
|
||||
|
||||
if (input_feed == nullptr) {
|
||||
// User is adding new category.
|
||||
// User is adding new feed.
|
||||
setWindowTitle(tr("Add new feed"));
|
||||
|
||||
// Make sure that "default" icon is used as the default option for new
|
||||
@ -164,10 +164,6 @@ void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) {
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::onNoIconSelected() {
|
||||
m_ui->m_btnIcon->setIcon(QIcon());
|
||||
}
|
||||
|
||||
void FormFeedDetails::onLoadIconFromFile() {
|
||||
QFileDialog dialog(this, tr("Select icon file for the feed"),
|
||||
qApp->homeFolder(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
|
||||
@ -190,7 +186,7 @@ void FormFeedDetails::onLoadIconFromFile() {
|
||||
}
|
||||
|
||||
void FormFeedDetails::onUseDefaultIcon() {
|
||||
m_ui->m_btnIcon->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
|
||||
m_ui->m_btnIcon->setIcon(QIcon());
|
||||
}
|
||||
|
||||
void FormFeedDetails::apply() {}
|
||||
@ -285,7 +281,6 @@ void FormFeedDetails::createConnections() {
|
||||
// Icon connections.
|
||||
connect(m_actionFetchIcon, &QAction::triggered, this, &FormFeedDetails::guessIconOnly);
|
||||
connect(m_actionLoadIconFromFile, &QAction::triggered, this, &FormFeedDetails::onLoadIconFromFile);
|
||||
connect(m_actionNoIcon, &QAction::triggered, this, &FormFeedDetails::onNoIconSelected);
|
||||
connect(m_actionUseDefaultIcon, &QAction::triggered, this, &FormFeedDetails::onUseDefaultIcon);
|
||||
}
|
||||
|
||||
@ -343,11 +338,8 @@ void FormFeedDetails::initialize() {
|
||||
m_actionLoadIconFromFile = new QAction(qApp->icons()->fromTheme(QSL("image-x-generic")),
|
||||
tr("Load icon from file..."),
|
||||
this);
|
||||
m_actionNoIcon = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
|
||||
tr("Do not use icon"),
|
||||
this);
|
||||
m_actionUseDefaultIcon = new QAction(qApp->icons()->fromTheme(QSL("application-rss+xml")),
|
||||
tr("Use default icon"),
|
||||
tr("Use default icon from icon theme"),
|
||||
this);
|
||||
m_actionFetchIcon = new QAction(qApp->icons()->fromTheme(QSL("emblem-downloads")),
|
||||
tr("Fetch icon from feed"),
|
||||
@ -355,7 +347,6 @@ void FormFeedDetails::initialize() {
|
||||
m_iconMenu->addAction(m_actionFetchIcon);
|
||||
m_iconMenu->addAction(m_actionLoadIconFromFile);
|
||||
m_iconMenu->addAction(m_actionUseDefaultIcon);
|
||||
m_iconMenu->addAction(m_actionNoIcon);
|
||||
m_ui->m_btnIcon->setMenu(m_iconMenu);
|
||||
|
||||
// Set feed metadata fetch label.
|
||||
|
@ -22,7 +22,7 @@ class FormFeedDetails : public QDialog {
|
||||
public:
|
||||
|
||||
// Constructors and destructors.
|
||||
explicit FormFeedDetails(ServiceRoot* service_root, QWidget* parent = 0);
|
||||
explicit FormFeedDetails(ServiceRoot* service_root, QWidget* parent = nullptr);
|
||||
virtual ~FormFeedDetails();
|
||||
|
||||
public slots:
|
||||
@ -50,7 +50,6 @@ class FormFeedDetails : public QDialog {
|
||||
void onAutoUpdateTypeChanged(int new_index);
|
||||
|
||||
// Icon selectors.
|
||||
void onNoIconSelected();
|
||||
void onLoadIconFromFile();
|
||||
void onUseDefaultIcon();
|
||||
|
||||
@ -78,7 +77,6 @@ class FormFeedDetails : public QDialog {
|
||||
QAction* m_actionLoadIconFromFile;
|
||||
QAction* m_actionUseDefaultIcon;
|
||||
QAction* m_actionFetchIcon;
|
||||
QAction* m_actionNoIcon;
|
||||
};
|
||||
|
||||
#endif // FORMFEEDDETAILS_H
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "services/abstract/rootitem.h"
|
||||
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "services/abstract/category.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
@ -170,7 +171,18 @@ QVariant RootItem::data(int column, int role) const {
|
||||
|
||||
case Qt::DecorationRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return icon();
|
||||
QIcon ico = icon();
|
||||
|
||||
if (ico.isNull()) {
|
||||
if (kind() == RootItemKind::Feed) {
|
||||
return qApp->icons()->fromTheme(QSL("application-rss+xml"));
|
||||
}
|
||||
else if (kind() == RootItemKind::Category) {
|
||||
return qApp->icons()->fromTheme(QSL("folder"));
|
||||
}
|
||||
}
|
||||
|
||||
return ico;
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
|
@ -45,7 +45,6 @@ void FormStandardCategoryDetails::createConnections() {
|
||||
|
||||
// Icon connections.
|
||||
connect(m_actionLoadIconFromFile, SIGNAL(triggered()), this, SLOT(onLoadIconFromFile()));
|
||||
connect(m_actionNoIcon, SIGNAL(triggered()), this, SLOT(onNoIconSelected()));
|
||||
connect(m_actionUseDefaultIcon, SIGNAL(triggered()), this, SLOT(onUseDefaultIcon()));
|
||||
}
|
||||
|
||||
@ -154,10 +153,6 @@ void FormStandardCategoryDetails::onDescriptionChanged(const QString& new_descri
|
||||
}
|
||||
}
|
||||
|
||||
void FormStandardCategoryDetails::onNoIconSelected() {
|
||||
m_ui->m_btnIcon->setIcon(QIcon());
|
||||
}
|
||||
|
||||
void FormStandardCategoryDetails::onLoadIconFromFile() {
|
||||
QFileDialog dialog(this, tr("Select icon file for the category"),
|
||||
qApp->homeFolder(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
|
||||
@ -180,7 +175,7 @@ void FormStandardCategoryDetails::onLoadIconFromFile() {
|
||||
}
|
||||
|
||||
void FormStandardCategoryDetails::onUseDefaultIcon() {
|
||||
m_ui->m_btnIcon->setIcon(qApp->icons()->fromTheme(QSL("folder")));
|
||||
m_ui->m_btnIcon->setIcon(QIcon());
|
||||
}
|
||||
|
||||
void FormStandardCategoryDetails::initialize() {
|
||||
@ -205,15 +200,11 @@ void FormStandardCategoryDetails::initialize() {
|
||||
m_actionLoadIconFromFile = new QAction(qApp->icons()->fromTheme(QSL("image-x-generic")),
|
||||
tr("Load icon from file..."),
|
||||
this);
|
||||
m_actionNoIcon = new QAction(qApp->icons()->fromTheme(QSL("dialog-error")),
|
||||
tr("Do not use icon"),
|
||||
this);
|
||||
m_actionUseDefaultIcon = new QAction(qApp->icons()->fromTheme(QSL("folder")),
|
||||
tr("Use default icon"),
|
||||
tr("Use default icon from icon theme"),
|
||||
this);
|
||||
m_iconMenu->addAction(m_actionLoadIconFromFile);
|
||||
m_iconMenu->addAction(m_actionUseDefaultIcon);
|
||||
m_iconMenu->addAction(m_actionNoIcon);
|
||||
m_ui->m_btnIcon->setMenu(m_iconMenu);
|
||||
|
||||
// Setup tab order.
|
||||
|
@ -43,7 +43,6 @@ class FormStandardCategoryDetails : public QDialog {
|
||||
void onDescriptionChanged(const QString& new_description);
|
||||
|
||||
// Icon selectors.
|
||||
void onNoIconSelected();
|
||||
void onLoadIconFromFile();
|
||||
void onUseDefaultIcon();
|
||||
|
||||
@ -70,7 +69,6 @@ class FormStandardCategoryDetails : public QDialog {
|
||||
QMenu* m_iconMenu;
|
||||
QAction* m_actionLoadIconFromFile;
|
||||
QAction* m_actionUseDefaultIcon;
|
||||
QAction* m_actionNoIcon;
|
||||
};
|
||||
|
||||
#endif // FORMCATEGORYDETAILS_H
|
||||
|
@ -28,7 +28,7 @@ void FormStandardFeedDetails::apply() {
|
||||
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||
new_feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(
|
||||
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
new_feed->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
|
||||
new_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
|
||||
|
||||
if (m_editableFeed == nullptr) {
|
||||
// Add the feed.
|
||||
@ -67,7 +67,7 @@ void FormStandardFeedDetails::setEditableFeed(Feed* editable_feed) {
|
||||
FormFeedDetails::setEditableFeed(editable_feed);
|
||||
StandardFeed* feed = qobject_cast<StandardFeed*>(editable_feed);
|
||||
|
||||
m_ui->m_cmbType->setCurrentIndex(m_ui->m_cmbType->findData(QVariant::fromValue((int) feed->type())));
|
||||
m_ui->m_cmbType->setCurrentIndex(m_ui->m_cmbType->findData(QVariant::fromValue(int(feed->type()))));
|
||||
m_ui->m_cmbEncoding->setCurrentIndex(m_ui->m_cmbEncoding->findData(feed->encoding(), Qt::DisplayRole, Qt::MatchFixedString));
|
||||
m_ui->m_gbAuthentication->setChecked(feed->passwordProtected());
|
||||
m_ui->m_txtUsername->lineEdit()->setText(feed->username());
|
||||
|
@ -9,7 +9,7 @@ class FormStandardFeedDetails : public FormFeedDetails {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FormStandardFeedDetails(ServiceRoot* service_root, QWidget* parent = 0);
|
||||
explicit FormStandardFeedDetails(ServiceRoot* service_root, QWidget* parent = nullptr);
|
||||
|
||||
protected slots:
|
||||
void apply();
|
||||
|
@ -195,7 +195,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||
new_feed->setEncoding(feed_encoding);
|
||||
new_feed->setUrl(feed_url);
|
||||
new_feed->setCreationDate(QDateTime::currentDateTime());
|
||||
new_feed->setIcon(feed_icon.isNull() ? qApp->icons()->fromTheme(QSL("application-rss+xml")) : feed_icon);
|
||||
new_feed->setIcon(feed_icon);
|
||||
|
||||
if (feed_type == QL1S("RSS1")) {
|
||||
new_feed->setType(StandardFeed::Rdf);
|
||||
@ -237,7 +237,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||
StandardCategory* new_category = new StandardCategory(active_model_item);
|
||||
|
||||
new_category->setTitle(category_title);
|
||||
new_category->setIcon(category_icon.isNull() ? qApp->icons()->fromTheme(QSL("folder")) : category_icon);
|
||||
new_category->setIcon(category_icon);
|
||||
new_category->setCreationDate(QDateTime::currentDateTime());
|
||||
new_category->setDescription(category_description);
|
||||
active_model_item->appendChild(new_category);
|
||||
|
Loading…
x
Reference in New Issue
Block a user