diff --git a/src/core/basenetworkaccessmanager.cpp b/src/core/basenetworkaccessmanager.cpp index 13c6e6490..da71bbe83 100644 --- a/src/core/basenetworkaccessmanager.cpp +++ b/src/core/basenetworkaccessmanager.cpp @@ -19,7 +19,7 @@ void BaseNetworkAccessManager::loadSettings() { qDebug("Settings of BaseNetworkAccessManager changed."); QNetworkProxy new_proxy; - QNetworkProxy::ProxyType selected_proxy_type = static_cast(Settings::getInstance()->value(APP_CFG_PROXY, + QNetworkProxy::ProxyType selected_proxy_type = static_cast(Settings::instance()->value(APP_CFG_PROXY, "proxy_type", QNetworkProxy::NoProxy).toInt()); @@ -29,7 +29,7 @@ void BaseNetworkAccessManager::loadSettings() { return; } - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); // Custom proxy is selected, set it up. new_proxy.setType(selected_proxy_type); diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp index 7f73b3a97..c8ac51d81 100644 --- a/src/core/databasefactory.cpp +++ b/src/core/databasefactory.cpp @@ -30,7 +30,7 @@ DatabaseFactory *DatabaseFactory::instance() { } void DatabaseFactory::assemblyDatabaseFilePath() { - if (Settings::getInstance()->type() == Settings::Portable) { + if (Settings::instance()->type() == Settings::Portable) { m_databasePath = qApp->applicationDirPath() + QDir::separator() + QString(APP_DB_PATH); diff --git a/src/core/dynamicshortcuts.cpp b/src/core/dynamicshortcuts.cpp index 29352a9f5..5cbf9403f 100644 --- a/src/core/dynamicshortcuts.cpp +++ b/src/core/dynamicshortcuts.cpp @@ -10,7 +10,7 @@ DynamicShortcuts::DynamicShortcuts() { } void DynamicShortcuts::save(const QList actions) { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); foreach (QAction *action, actions) { settings->setValue(APP_CFG_CUTS, @@ -20,7 +20,7 @@ void DynamicShortcuts::save(const QList actions) { } void DynamicShortcuts::load(const QList actions) { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); foreach (QAction *action, actions) { QString shortcut_for_action = settings->value(APP_CFG_CUTS, diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 2628c16cd..00a249195 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -22,8 +22,8 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) { m_rootItem = new FeedsModelRootItem(); m_rootItem->setId(NO_PARENT_CATEGORY); m_rootItem->setTitle(tr("root")); - m_rootItem->setIcon(IconThemeFactory::getInstance()->fromTheme("folder-red")); - m_countsIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-important"); + m_rootItem->setIcon(IconThemeFactory::instance()->fromTheme("folder-red")); + m_countsIcon = IconThemeFactory::instance()->fromTheme("mail-mark-important"); m_headerData << tr("Title"); m_tooltipData << tr("Titles of feeds/categories.") << tr("Counts of unread/all meesages."); diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp index 74eb16b61..b3db8fbe6 100755 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -25,26 +25,6 @@ FeedsModelCategory::FeedsModelCategory(const FeedsModelCategory &other) FeedsModelCategory::~FeedsModelCategory() { } -int FeedsModelCategory::countOfAllMessages() const { - int total_count = 0; - - foreach (FeedsModelRootItem *child_item, m_childItems) { - total_count += child_item->countOfAllMessages(); - } - - return total_count; -} - -int FeedsModelCategory::countOfUnreadMessages() const { - int total_count = 0; - - foreach (FeedsModelRootItem *child_item, m_childItems) { - total_count += child_item->countOfUnreadMessages(); - } - - return total_count; -} - FeedsModelCategory:: Type FeedsModelCategory::type() const { return m_type; } diff --git a/src/core/feedsmodelcategory.h b/src/core/feedsmodelcategory.h index 1a9d5420d..f62afc207 100755 --- a/src/core/feedsmodelcategory.h +++ b/src/core/feedsmodelcategory.h @@ -24,12 +24,6 @@ class FeedsModelCategory : public FeedsModelRootItem { explicit FeedsModelCategory(const FeedsModelCategory &other); virtual ~FeedsModelCategory(); - // Counts of messages. - // NOTE: Counts of messages in categories include - // counts of messages from all children. - int countOfAllMessages() const; - int countOfUnreadMessages() const; - // All types of categories offer these getters/setters. Type type() const; void setType(const Type &type); diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index a7102cb46..f979c8207 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -68,11 +68,23 @@ QVariant FeedsModelRootItem::data(int column, int role) const { } int FeedsModelRootItem::countOfAllMessages() const { - return 0; + int total_count = 0; + + foreach (FeedsModelRootItem *child_item, m_childItems) { + total_count += child_item->countOfAllMessages(); + } + + return total_count; } int FeedsModelRootItem::countOfUnreadMessages() const { - return 0; + int total_count = 0; + + foreach (FeedsModelRootItem *child_item, m_childItems) { + total_count += child_item->countOfUnreadMessages(); + } + + return total_count; } void FeedsModelRootItem::setIcon(const QIcon &icon) { diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index f50e682f1..bd308d125 100755 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -33,6 +33,7 @@ class FeedsModelRootItem { virtual QVariant data(int column, int role) const; // Each item offers "counts" of messages. + // Returns counts of messages of all child items summed up. virtual int countOfUnreadMessages() const; virtual int countOfAllMessages() const; diff --git a/src/core/feedsmodelstandardcategory.cpp b/src/core/feedsmodelstandardcategory.cpp index 1103adb60..6eb3a024d 100755 --- a/src/core/feedsmodelstandardcategory.cpp +++ b/src/core/feedsmodelstandardcategory.cpp @@ -69,7 +69,7 @@ QVariant FeedsModelStandardCategory::data(int column, int role) const { case Qt::DecorationRole: if (column == FDS_MODEL_TITLE_INDEX) { return m_icon.isNull() ? - IconThemeFactory::getInstance()->fromTheme("folder-black") : + IconThemeFactory::instance()->fromTheme("folder-black") : m_icon; } else { diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp index a3315a3f4..42bf8f3de 100755 --- a/src/core/feedsmodelstandardfeed.cpp +++ b/src/core/feedsmodelstandardfeed.cpp @@ -89,7 +89,7 @@ QVariant FeedsModelStandardFeed::data(int column, int role) const { case Qt::DecorationRole: if (column == FDS_MODEL_TITLE_INDEX) { return m_icon.isNull() ? - IconThemeFactory::getInstance()->fromTheme("application-rss+xml") : + IconThemeFactory::instance()->fromTheme("application-rss+xml") : m_icon; } else { @@ -130,7 +130,7 @@ QVariant FeedsModelStandardFeed::data(int column, int role) const { void FeedsModelStandardFeed::update() { QByteArray feed_contents; - int download_timeout = Settings::getInstance()->value(APP_CFG_FEEDS, + int download_timeout = Settings::instance()->value(APP_CFG_FEEDS, "download_timeout", DOWNLOAD_TIMEOUT).toInt(); diff --git a/src/core/localization.cpp b/src/core/localization.cpp index 1019091b5..2c9c003b2 100644 --- a/src/core/localization.cpp +++ b/src/core/localization.cpp @@ -12,11 +12,12 @@ Localization::Localization() { } -QList Localization::getInstalledLanguages() { +QList Localization::installedLanguages() { QList languages; QDir file_dir(APP_LANG_PATH); QTranslator translator; + // Iterate all found language files. foreach (const QFileInfo &file, file_dir.entryInfoList(QStringList() << "rssguard_*.qm", QDir::Files, QDir::Name)) { diff --git a/src/core/localization.h b/src/core/localization.h index 787fed102..f834e8d4b 100644 --- a/src/core/localization.h +++ b/src/core/localization.h @@ -4,7 +4,7 @@ // Loads currently active language. // NOTE: Macro is used due to QTranslator persistency. #define LoadLocalization(); \ - QString locale_name = Settings::getInstance()->value( \ + QString locale_name = Settings::instance()->value( \ APP_CFG_GEN, \ "language", \ "en").toString(); \ @@ -41,12 +41,13 @@ struct Language { class Localization { private: + // Constructor. explicit Localization(); public: // Returns list of installed application localizations. // This list is used ie. in settings dialog. - static QList getInstalledLanguages(); + static QList installedLanguages(); }; #endif // LOCALIZATION_H diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index 9ee30d39e..f2917dd9b 100644 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -38,9 +38,9 @@ bool MessagesModel::submitAll() { } void MessagesModel::setupIcons() { - m_favoriteIcon = IconThemeFactory::getInstance()->fromTheme("favorites"); - m_readIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk"); - m_unreadIcon = IconThemeFactory::getInstance()->fromTheme("mail-mark-important"); + m_favoriteIcon = IconThemeFactory::instance()->fromTheme("favorites"); + m_readIcon = IconThemeFactory::instance()->fromTheme("mail-mark-not-junk"); + m_unreadIcon = IconThemeFactory::instance()->fromTheme("mail-mark-important"); } void MessagesModel::fetchAll() { @@ -59,9 +59,7 @@ QList MessagesModel::currentFeeds() const { return m_currentFeeds; } - void MessagesModel::loadMessages(const QList feed_ids) { - // Conversion of parameter. m_currentFeeds = feed_ids; QString assembled_ids = textualFeeds().join(", "); @@ -75,7 +73,7 @@ void MessagesModel::loadMessages(const QList feed_ids) { QStringList MessagesModel::textualFeeds() const { QStringList stringy_ids; - stringy_ids.reserve(m_currentFeeds.count()); + stringy_ids.reserve(m_currentFeeds.size()); foreach (int feed_id, m_currentFeeds) { stringy_ids.append(QString::number(feed_id)); diff --git a/src/core/messagesmodel.h b/src/core/messagesmodel.h index 7c8d61c7c..2c7e33166 100644 --- a/src/core/messagesmodel.h +++ b/src/core/messagesmodel.h @@ -80,6 +80,8 @@ class MessagesModel : public QSqlTableModel { void feedCountsChanged(); protected: + // Returns selected feed ids in concatenated textual form, + // which is used for SQL queries. QStringList textualFeeds() const; // Sets up header data. diff --git a/src/core/networkfactory.h b/src/core/networkfactory.h index 738b34da4..524b754be 100644 --- a/src/core/networkfactory.h +++ b/src/core/networkfactory.h @@ -6,6 +6,7 @@ class NetworkFactory { private: + // Constructor. explicit NetworkFactory(); public: @@ -14,7 +15,6 @@ class NetworkFactory { static QNetworkReply::NetworkError downloadFile(const QString &url, int timeout, QByteArray &output); - }; #endif // NETWORKFACTORY_H diff --git a/src/core/parsingfactory.cpp b/src/core/parsingfactory.cpp index ed5cb693f..e968a3832 100644 --- a/src/core/parsingfactory.cpp +++ b/src/core/parsingfactory.cpp @@ -10,8 +10,6 @@ ParsingFactory::ParsingFactory() { } QList ParsingFactory::parseAsATOM10(const QString &data) { - // TODO: Implement this. - QList messages; QDomDocument xml_file; QDateTime current_time = QDateTime::currentDateTime(); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 9f65f6678..1980eb6a6 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -32,7 +32,7 @@ QSettings::Status Settings::checkSettings() { return status(); } -Settings *Settings::getInstance() { +Settings *Settings::instance() { if (s_instance.isNull()) { setupSettings(); } diff --git a/src/core/settings.h b/src/core/settings.h index 43bc6eaf2..29a9d5c98 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -9,17 +9,19 @@ class Settings : public QSettings { Q_OBJECT public: + // Describes possible types of loaded settings. enum Type { Portable, NonPortable }; // Singleton getter. - static Settings *getInstance(); + static Settings *instance(); // Destructor. virtual ~Settings(); + // Type of used settings. Type type() const; // Getter/setter for settings values. diff --git a/src/gui/cornerbutton.cpp b/src/gui/cornerbutton.cpp index d689bc71a..bd792dfbd 100644 --- a/src/gui/cornerbutton.cpp +++ b/src/gui/cornerbutton.cpp @@ -6,7 +6,7 @@ CornerButton::CornerButton(QWidget *parent) : QToolButton(parent) { setToolTip(tr("Open new tab")); setAutoRaise(true); - setIcon(IconThemeFactory::getInstance()->fromTheme("list-add")); + setIcon(IconThemeFactory::instance()->fromTheme("list-add")); } CornerButton::~CornerButton() { diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 3558abd76..282ad2300 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -49,7 +49,7 @@ FeedMessageViewer::~FeedMessageViewer() { } void FeedMessageViewer::saveSize() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); // Store offsets of splitters. settings->setValue(APP_CFG_GUI, @@ -70,7 +70,7 @@ void FeedMessageViewer::saveSize() { } void FeedMessageViewer::loadSize() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); int default_msg_section_size = m_messagesView->header()->defaultSectionSize(); // Restore offsets of splitters. @@ -86,6 +86,7 @@ void FeedMessageViewer::loadSize() { settings->value(APP_CFG_GUI, KEY_MESSAGES_VIEW + QString::number(MSG_DB_DCREATED_INDEX), default_msg_section_size).toInt()); + // TODO: Perhaps make toolbar icon size changeable, // this concerns toolbars of web browsers too. } @@ -119,7 +120,7 @@ void FeedMessageViewer::updateAllFeeds() { } void FeedMessageViewer::onFeedUpdatesStarted() { - FormMain::getInstance()->statusBar()->showProgress(0, tr("Feed update started")); + FormMain::instance()->statusBar()->showProgress(0, tr("Feed update started")); } void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, @@ -127,14 +128,14 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, int total) { // Some feed got updated. m_feedsView->updateCountsOfParticularFeed(feed, true); - FormMain::getInstance()->statusBar()->showProgress((current * 100.0) / total, + FormMain::instance()->statusBar()->showProgress((current * 100.0) / total, tr("Updated feed '%1'").arg(feed->title())); } void FeedMessageViewer::onFeedUpdatesFinished() { // Updates of some feeds finished, unlock the lock. SystemFactory::getInstance()->applicationCloseLock()->unlock(); - FormMain::getInstance()->statusBar()->clearProgress(); + FormMain::instance()->statusBar()->clearProgress(); } void FeedMessageViewer::createConnections() { @@ -154,13 +155,13 @@ void FeedMessageViewer::createConnections() { // Message openers. connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(QList)), - FormMain::getInstance()->m_ui->m_tabWidget, + FormMain::instance()->m_ui->m_tabWidget, SLOT(addBrowserWithMessages(QList))); connect(m_messagesView, SIGNAL(openLinkNewTab(QString)), - FormMain::getInstance()->m_ui->m_tabWidget, + FormMain::instance()->m_ui->m_tabWidget, SLOT(addLinkedBrowser(QString))); connect(m_feedsView, SIGNAL(openMessagesInNewspaperView(QList)), - FormMain::getInstance()->m_ui->m_tabWidget, + FormMain::instance()->m_ui->m_tabWidget, SLOT(addBrowserWithMessages(QList))); // Downloader connections. @@ -174,39 +175,39 @@ void FeedMessageViewer::createConnections() { this, SLOT(onFeedUpdatesProgress(FeedsModelFeed*,int,int))); // Toolbar forwardings. - connect(FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages, + connect(FormMain::instance()->m_ui->m_actionSwitchImportanceOfSelectedMessages, SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance())); - connect(FormMain::getInstance()->m_ui->m_actionDeleteSelectedMessages, + connect(FormMain::instance()->m_ui->m_actionDeleteSelectedMessages, SIGNAL(triggered()), m_messagesView, SLOT(deleteSelectedMessages())); - connect(FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsRead, + connect(FormMain::instance()->m_ui->m_actionMarkSelectedMessagesAsRead, SIGNAL(triggered()), m_messagesView, SLOT(markSelectedMessagesRead())); - connect(FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsUnread, + connect(FormMain::instance()->m_ui->m_actionMarkSelectedMessagesAsUnread, SIGNAL(triggered()), m_messagesView, SLOT(markSelectedMessagesUnread())); - connect(FormMain::getInstance()->m_ui->m_actionOpenSelectedSourceArticlesExternally, + connect(FormMain::instance()->m_ui->m_actionOpenSelectedSourceArticlesExternally, SIGNAL(triggered()), m_messagesView, SLOT(openSelectedSourceArticlesExternally())); - connect(FormMain::getInstance()->m_ui->m_actionOpenSelectedSourceArticlesInternally, + connect(FormMain::instance()->m_ui->m_actionOpenSelectedSourceArticlesInternally, SIGNAL(triggered()), m_messagesView, SLOT(openSelectedSourceMessagesInternally())); - connect(FormMain::getInstance()->m_ui->m_actionOpenSelectedMessagesInternally, + connect(FormMain::instance()->m_ui->m_actionOpenSelectedMessagesInternally, SIGNAL(triggered()), m_messagesView, SLOT(openSelectedMessagesInternally())); - connect(FormMain::getInstance()->m_ui->m_actionMarkAllFeedsRead, + connect(FormMain::instance()->m_ui->m_actionMarkAllFeedsRead, SIGNAL(triggered()), m_feedsView, SLOT(markAllFeedsRead())); - connect(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead, + connect(FormMain::instance()->m_ui->m_actionMarkFeedsAsRead, SIGNAL(triggered()), m_feedsView, SLOT(markSelectedFeedsRead())); - connect(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread, + connect(FormMain::instance()->m_ui->m_actionMarkFeedsAsUnread, SIGNAL(triggered()), m_feedsView, SLOT(markSelectedFeedsUnread())); - connect(FormMain::getInstance()->m_ui->m_actionClearFeeds, + connect(FormMain::instance()->m_ui->m_actionClearFeeds, SIGNAL(triggered()), m_feedsView, SLOT(clearSelectedFeeds())); - connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeedsCategories, + connect(FormMain::instance()->m_ui->m_actionUpdateSelectedFeedsCategories, SIGNAL(triggered()), this, SLOT(updateSelectedFeeds())); - connect(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds, + connect(FormMain::instance()->m_ui->m_actionUpdateAllFeeds, SIGNAL(triggered()), this, SLOT(updateAllFeeds())); - connect(FormMain::getInstance()->m_ui->m_actionAddNewCategory, + connect(FormMain::instance()->m_ui->m_actionAddNewCategory, SIGNAL(triggered()), m_feedsView, SLOT(addNewCategory())); - connect(FormMain::getInstance()->m_ui->m_actionEditSelectedFeedCategory, + connect(FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory, SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem())); - connect(FormMain::getInstance()->m_ui->m_actionViewSelectedItemsNewspaperMode, + connect(FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode, SIGNAL(triggered()), m_feedsView, SLOT(openSelectedFeedsInNewspaperMode())); - connect(FormMain::getInstance()->m_ui->m_actionDeleteSelectedFeedsCategories, + connect(FormMain::instance()->m_ui->m_actionDeleteSelectedFeedsCategories, SIGNAL(triggered()), m_feedsView, SLOT(deleteSelectedItems())); } @@ -218,20 +219,20 @@ void FeedMessageViewer::initialize() { m_toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); // Add everything to toolbar. - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkAllFeedsRead); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionUpdateAllFeeds); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionMarkAllFeedsRead); m_toolBar->addSeparator(); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeedsCategories); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionAddNewFeed); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionEditSelectedFeedCategory); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteSelectedFeedsCategories); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionClearFeeds); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionUpdateSelectedFeedsCategories); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionAddNewFeed); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionDeleteSelectedFeedsCategories); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionMarkFeedsAsRead); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionMarkFeedsAsUnread); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionClearFeeds); m_toolBar->addSeparator(); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsRead); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsUnread); - m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionDeleteSelectedMessages); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionMarkSelectedMessagesAsRead); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionMarkSelectedMessagesAsUnread); + m_toolBar->addAction(FormMain::instance()->m_ui->m_actionDeleteSelectedMessages); // Finish web/message browser setup. m_messagesBrowser->setNavigationBarVisible(false); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 5bed3ed40..7739a2918 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -190,16 +190,16 @@ void FeedsView::updateCountsOfParticularFeed(FeedsModelFeed *feed, void FeedsView::initializeContextMenuCategoriesFeeds() { m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this); m_contextMenuCategoriesFeeds->addActions(QList() << - FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeedsCategories << - FormMain::getInstance()->m_ui->m_actionViewSelectedItemsNewspaperMode << - FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead << - FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread); + FormMain::instance()->m_ui->m_actionUpdateSelectedFeedsCategories << + FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode << + FormMain::instance()->m_ui->m_actionMarkFeedsAsRead << + FormMain::instance()->m_ui->m_actionMarkFeedsAsUnread); } void FeedsView::initializeContextMenuEmptySpace() { m_contextMenuEmptySpace = new QMenu(tr("Context menu for feeds"), this); m_contextMenuEmptySpace->addActions(QList() << - FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds); + FormMain::instance()->m_ui->m_actionUpdateAllFeeds); } diff --git a/src/gui/formabout.cpp b/src/gui/formabout.cpp index 53f05dbfa..cb7ca0905 100644 --- a/src/gui/formabout.cpp +++ b/src/gui/formabout.cpp @@ -12,7 +12,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) // Set flags and attributes. setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); - setWindowIcon(IconThemeFactory::getInstance()->fromTheme("help-about")); + setWindowIcon(IconThemeFactory::instance()->fromTheme("help-about")); m_ui->m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH)); // Load information from embedded text files. diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp index 1a17a8dac..fac118f78 100644 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -58,7 +58,7 @@ void FormCategoryDetails::initialize() { // Set flags and attributes. setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); - setWindowIcon(IconThemeFactory::getInstance()->fromTheme("document-new")); + setWindowIcon(IconThemeFactory::instance()->fromTheme("document-new")); } void FormCategoryDetails::loadCategories(const QList categories, diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index a63a45f84..dac7269a4 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -54,7 +54,7 @@ FormMain::~FormMain() { } } -FormMain *FormMain::getInstance() { +FormMain *FormMain::instance() { return s_instance; } @@ -124,7 +124,7 @@ void FormMain::processExecutionMessage(const QString &message) { if (message == APP_IS_RUNNING) { if (SystemTrayIcon::isSystemTrayActivated()) { - SystemTrayIcon::getInstance()->showMessage(APP_NAME, + SystemTrayIcon::instance()->showMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information, TRAY_ICON_BUBBLE_TIMEOUT); @@ -206,39 +206,39 @@ bool FormMain::event(QEvent *event) { void FormMain::setupIcons() { // Setup icons of this main window. - m_ui->m_actionSettings->setIcon(IconThemeFactory::getInstance()->fromTheme("preferences-system")); - m_ui->m_actionQuit->setIcon(IconThemeFactory::getInstance()->fromTheme("application-exit")); - m_ui->m_actionAboutGuard->setIcon(IconThemeFactory::getInstance()->fromTheme("help-about")); - m_ui->m_actionImport->setIcon(IconThemeFactory::getInstance()->fromTheme("document-import")); - m_ui->m_actionExport->setIcon(IconThemeFactory::getInstance()->fromTheme("document-export")); - m_ui->m_actionFullscreen->setIcon(IconThemeFactory::getInstance()->fromTheme("view-fullscreen")); + m_ui->m_actionSettings->setIcon(IconThemeFactory::instance()->fromTheme("preferences-system")); + m_ui->m_actionQuit->setIcon(IconThemeFactory::instance()->fromTheme("application-exit")); + m_ui->m_actionAboutGuard->setIcon(IconThemeFactory::instance()->fromTheme("help-about")); + m_ui->m_actionImport->setIcon(IconThemeFactory::instance()->fromTheme("document-import")); + m_ui->m_actionExport->setIcon(IconThemeFactory::instance()->fromTheme("document-export")); + m_ui->m_actionFullscreen->setIcon(IconThemeFactory::instance()->fromTheme("view-fullscreen")); // Web browser. - m_ui->m_actionAddBrowser->setIcon(IconThemeFactory::getInstance()->fromTheme("list-add")); - m_ui->m_actionCloseCurrentTab->setIcon(IconThemeFactory::getInstance()->fromTheme("list-remove")); - m_ui->m_actionCloseAllTabs->setIcon(IconThemeFactory::getInstance()->fromTheme("list-remove")); - m_ui->m_menuCurrentTab->setIcon(IconThemeFactory::getInstance()->fromTheme("go-home")); + m_ui->m_actionAddBrowser->setIcon(IconThemeFactory::instance()->fromTheme("list-add")); + m_ui->m_actionCloseCurrentTab->setIcon(IconThemeFactory::instance()->fromTheme("list-remove")); + m_ui->m_actionCloseAllTabs->setIcon(IconThemeFactory::instance()->fromTheme("list-remove")); + m_ui->m_menuCurrentTab->setIcon(IconThemeFactory::instance()->fromTheme("go-home")); // Feeds/messages. - m_ui->m_actionUpdateAllFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save-as")); - m_ui->m_actionUpdateSelectedFeedsCategories->setIcon(IconThemeFactory::getInstance()->fromTheme("document-save")); - m_ui->m_actionClearFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-junk")); - m_ui->m_actionDeleteSelectedFeedsCategories->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete")); - m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-junk")); - m_ui->m_actionAddNewCategory->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new")); - m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new")); - m_ui->m_actionEditSelectedFeedCategory->setIcon(IconThemeFactory::getInstance()->fromTheme("gnome-other")); - m_ui->m_actionMarkAllFeedsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk")); - m_ui->m_actionMarkFeedsAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk")); - m_ui->m_actionMarkFeedsAsUnread->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-important")); - m_ui->m_actionMarkFeedsAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk")); - m_ui->m_actionMarkSelectedMessagesAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-not-junk")); - m_ui->m_actionMarkSelectedMessagesAsUnread->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-important")); - m_ui->m_actionSwitchImportanceOfSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("favorites")); - m_ui->m_actionOpenSelectedSourceArticlesInternally->setIcon(IconThemeFactory::getInstance()->fromTheme("document-open")); - m_ui->m_actionOpenSelectedSourceArticlesExternally->setIcon(IconThemeFactory::getInstance()->fromTheme("document-open")); - m_ui->m_actionOpenSelectedMessagesInternally->setIcon(IconThemeFactory::getInstance()->fromTheme("document-open")); - m_ui->m_actionViewSelectedItemsNewspaperMode->setIcon(IconThemeFactory::getInstance()->fromTheme("document-multiple")); + m_ui->m_actionUpdateAllFeeds->setIcon(IconThemeFactory::instance()->fromTheme("document-save-as")); + m_ui->m_actionUpdateSelectedFeedsCategories->setIcon(IconThemeFactory::instance()->fromTheme("document-save")); + m_ui->m_actionClearFeeds->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-junk")); + m_ui->m_actionDeleteSelectedFeedsCategories->setIcon(IconThemeFactory::instance()->fromTheme("edit-delete")); + m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-junk")); + m_ui->m_actionAddNewCategory->setIcon(IconThemeFactory::instance()->fromTheme("document-new")); + m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::instance()->fromTheme("document-new")); + m_ui->m_actionEditSelectedFeedCategory->setIcon(IconThemeFactory::instance()->fromTheme("gnome-other")); + m_ui->m_actionMarkAllFeedsRead->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-not-junk")); + m_ui->m_actionMarkFeedsAsRead->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-not-junk")); + m_ui->m_actionMarkFeedsAsUnread->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-important")); + m_ui->m_actionMarkFeedsAsRead->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-not-junk")); + m_ui->m_actionMarkSelectedMessagesAsRead->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-not-junk")); + m_ui->m_actionMarkSelectedMessagesAsUnread->setIcon(IconThemeFactory::instance()->fromTheme("mail-mark-important")); + m_ui->m_actionSwitchImportanceOfSelectedMessages->setIcon(IconThemeFactory::instance()->fromTheme("favorites")); + m_ui->m_actionOpenSelectedSourceArticlesInternally->setIcon(IconThemeFactory::instance()->fromTheme("document-open")); + m_ui->m_actionOpenSelectedSourceArticlesExternally->setIcon(IconThemeFactory::instance()->fromTheme("document-open")); + m_ui->m_actionOpenSelectedMessagesInternally->setIcon(IconThemeFactory::instance()->fromTheme("document-open")); + m_ui->m_actionViewSelectedItemsNewspaperMode->setIcon(IconThemeFactory::instance()->fromTheme("document-multiple")); // Setup icons for underlying components: opened web browsers... foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) { @@ -251,22 +251,25 @@ void FormMain::setupIcons() { void FormMain::loadSize() { QRect screen = qApp->desktop()->screenGeometry(); + Settings *settings = Settings::instance(); // Reload main window size & position. - resize(Settings::getInstance()->value(APP_CFG_GUI, - "window_size", - size()).toSize()); - move(Settings::getInstance()->value(APP_CFG_GUI, - "window_position", - screen.center() - rect().center()).toPoint()); + resize(settings->value(APP_CFG_GUI, + "window_size", + size()).toSize()); + move(settings->value(APP_CFG_GUI, + "window_position", + screen.center() - rect().center()).toPoint()); // Adjust dimensions of "feeds & messages" widget. m_ui->m_tabWidget->feedMessageViewer()->loadSize(); } void FormMain::saveSize() { - Settings::getInstance()->setValue(APP_CFG_GUI, "window_position", pos()); - Settings::getInstance()->setValue(APP_CFG_GUI, "window_size", size()); + Settings *settings = Settings::instance(); + + settings->setValue(APP_CFG_GUI, "window_position", pos()); + settings->setValue(APP_CFG_GUI, "window_size", size()); m_ui->m_tabWidget->feedMessageViewer()->saveSize(); } @@ -324,7 +327,7 @@ void FormMain::loadWebBrowserMenu(int index) { void FormMain::closeEvent(QCloseEvent *event) { if (SystemTrayIcon::isSystemTrayActivated()) { - if (Settings::getInstance()->value(APP_CFG_GUI, + if (Settings::instance()->value(APP_CFG_GUI, "close_win_action", 0).toInt() == 0) { // User selected to minimize the application if its main diff --git a/src/gui/formmain.h b/src/gui/formmain.h index bba9e7348..8b61ecff5 100644 --- a/src/gui/formmain.h +++ b/src/gui/formmain.h @@ -36,7 +36,7 @@ class FormMain : public QMainWindow { StatusBar *statusBar(); // Singleton accessor. - static FormMain *getInstance(); + static FormMain *instance(); protected: // Creates all needed menus and sets them up. diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 9f8c6cf60..4af02309b 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -26,7 +26,7 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form // Set flags and attributes. setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); - setWindowIcon(IconThemeFactory::getInstance()->fromTheme("preferences-system")); + setWindowIcon(IconThemeFactory::instance()->fromTheme("preferences-system")); // Setup behavior. m_ui->m_treeLanguages->setColumnCount(5); @@ -147,7 +147,7 @@ void FormSettings::selectBrowserExecutable() { } void FormSettings::loadFeedsMessages() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), "-nosession %1"); m_ui->m_txtExternalBrowserExecutable->setText(settings->value(APP_CFG_MESSAGES, @@ -158,7 +158,7 @@ void FormSettings::loadFeedsMessages() { } void FormSettings::saveFeedsMessages() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); settings->setValue(APP_CFG_MESSAGES, "external_browser_executable", @@ -268,7 +268,7 @@ void FormSettings::saveSettings() { saveLanguage(); saveFeedsMessages(); - Settings::getInstance()->checkSettings(); + Settings::instance()->checkSettings(); promptForRestart(); accept(); @@ -291,7 +291,7 @@ void FormSettings::onProxyTypeChanged(int index) { } void FormSettings::loadBrowser() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); // Load settings of web browser GUI. m_initialSettings.m_webBrowserProgress = settings->value(APP_CFG_BROWSER, @@ -310,7 +310,7 @@ void FormSettings::loadBrowser() { } void FormSettings::saveBrowser() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); // Save settings of GUI of web browser. settings->setValue(APP_CFG_BROWSER, @@ -333,10 +333,10 @@ void FormSettings::loadProxy() { m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); // Load the settings. - QNetworkProxy::ProxyType selected_proxy_type = static_cast(Settings::getInstance()->value(APP_CFG_PROXY, + QNetworkProxy::ProxyType selected_proxy_type = static_cast(Settings::instance()->value(APP_CFG_PROXY, "proxy_type", QNetworkProxy::NoProxy).toInt()); - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type)); m_ui->m_txtProxyHost->setText(settings->value(APP_CFG_PROXY, @@ -350,7 +350,7 @@ void FormSettings::loadProxy() { } void FormSettings::saveProxy() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); settings->setValue(APP_CFG_PROXY, "proxy_type", m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex())); @@ -368,17 +368,17 @@ void FormSettings::saveProxy() { } void FormSettings::loadLanguage() { - foreach (const Language &language, Localization::getInstalledLanguages()) { + foreach (const Language &language, Localization::installedLanguages()) { QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages); item->setText(0, language.m_name); item->setText(1, language.m_code); item->setText(2, language.m_version); item->setText(3, language.m_author); item->setText(4, language.m_email); - item->setIcon(0, IconThemeFactory::getInstance()->fromTheme(language.m_code)); + item->setIcon(0, IconThemeFactory::instance()->fromTheme(language.m_code)); } - QList matching_items = m_ui->m_treeLanguages->findItems(Settings::getInstance()->value(APP_CFG_GEN, + QList matching_items = m_ui->m_treeLanguages->findItems(Settings::instance()->value(APP_CFG_GEN, "language", "en").toString(), Qt::MatchExactly, @@ -394,7 +394,7 @@ void FormSettings::saveLanguage() { return; } - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); QString actual_lang = settings->value(APP_CFG_GEN, "language", "en").toString(); @@ -408,7 +408,7 @@ void FormSettings::saveLanguage() { } void FormSettings::loadShortcuts() { - m_ui->m_shortcuts->populate(FormMain::getInstance()->getActions()); + m_ui->m_shortcuts->populate(FormMain::instance()->getActions()); } void FormSettings::saveShortcuts() { @@ -416,7 +416,7 @@ void FormSettings::saveShortcuts() { m_ui->m_shortcuts->updateShortcuts(); // Save new shortcuts to the settings. - DynamicShortcuts::save(FormMain::getInstance()->getActions()); + DynamicShortcuts::save(FormMain::instance()->getActions()); } void FormSettings::loadGeneral() { @@ -449,7 +449,7 @@ void FormSettings::saveGeneral() { } void FormSettings::loadInterface() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); // Load settings of tray icon. if (SystemTrayIcon::isSystemTrayAvailable()) { @@ -471,9 +471,9 @@ void FormSettings::loadInterface() { } // Load settings of icon theme. - QString current_theme = IconThemeFactory::getInstance()->getCurrentIconTheme(); + QString current_theme = IconThemeFactory::instance()->currentIconTheme(); - foreach (const QString &icon_theme_name, IconThemeFactory::getInstance()->getInstalledIconThemes()) { + foreach (const QString &icon_theme_name, IconThemeFactory::instance()->installedIconThemes()) { if (icon_theme_name == APP_NO_THEME) { // Add just "no theme" on other systems. m_ui->m_cmbIconTheme->addItem(tr("no icon theme"), @@ -502,9 +502,9 @@ void FormSettings::loadInterface() { } // Load skin. - QString selected_skin = SkinFactory::getInstance()->getSelectedSkinName(); + QString selected_skin = SkinFactory::instance()->selectedSkinName(); - foreach (const Skin &skin, SkinFactory::getInstance()->getInstalledSkins()) { + foreach (const Skin &skin, SkinFactory::instance()->installedSkins()) { QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() << skin.m_visibleName << skin.m_version << @@ -544,7 +544,7 @@ void FormSettings::loadInterface() { } void FormSettings::saveInterface() { - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); // Save tray icon. if (SystemTrayIcon::isSystemTrayAvailable()) { @@ -555,18 +555,18 @@ void FormSettings::saveInterface() { settings->setValue(APP_CFG_GUI, "start_hidden", m_ui->m_checkHidden->isChecked()); if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) { - SystemTrayIcon::getInstance()->show(); + SystemTrayIcon::instance()->show(); } else { - FormMain::getInstance()->display(); + FormMain::instance()->display(); SystemTrayIcon::deleteInstance(); } } // Save selected icon theme. QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString(); - QString original_icon_theme = IconThemeFactory::getInstance()->getCurrentIconTheme(); - IconThemeFactory::getInstance()->setCurrentIconTheme(selected_icon_theme); + QString original_icon_theme = IconThemeFactory::instance()->currentIconTheme(); + IconThemeFactory::instance()->setCurrentIconTheme(selected_icon_theme); // Check if icon theme was changed. if (selected_icon_theme != original_icon_theme) { @@ -577,8 +577,8 @@ void FormSettings::saveInterface() { if (m_ui->m_treeSkins->selectedItems().size() > 0) { Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value(); - if (SkinFactory::getInstance()->getSelectedSkinName() != active_skin.m_baseName) { - SkinFactory::getInstance()->setCurrentSkinName(active_skin.m_baseName); + if (SkinFactory::instance()->selectedSkinName() != active_skin.m_baseName) { + SkinFactory::instance()->setCurrentSkinName(active_skin.m_baseName); m_changedDataTexts.append(tr("skin changed")); } } diff --git a/src/gui/iconthemefactory.cpp b/src/gui/iconthemefactory.cpp index 41bc7be02..6965a80d0 100755 --- a/src/gui/iconthemefactory.cpp +++ b/src/gui/iconthemefactory.cpp @@ -22,7 +22,7 @@ IconThemeFactory::~IconThemeFactory() { qDebug("Destroying IconThemeFactory instance."); } -IconThemeFactory *IconThemeFactory::getInstance() { +IconThemeFactory *IconThemeFactory::instance() { if (s_instance.isNull()) { s_instance = new IconThemeFactory(qApp); } @@ -37,7 +37,7 @@ void IconThemeFactory::setupSearchPaths() { "\'").join(", "))); } -QString IconThemeFactory::getCurrentIconTheme() { +QString IconThemeFactory::currentIconTheme() { return m_currentIconTheme; } @@ -57,14 +57,14 @@ QIcon IconThemeFactory::fromTheme(const QString &name) { } void IconThemeFactory::setCurrentIconTheme(const QString &theme_name) { - Settings::getInstance()->setValue(APP_CFG_GUI, + Settings::instance()->setValue(APP_CFG_GUI, "icon_theme", theme_name); } void IconThemeFactory::loadCurrentIconTheme() { - QStringList installed_themes = getInstalledIconThemes(); - QString theme_name_from_settings = Settings::getInstance()->value(APP_CFG_GUI, + QStringList installed_themes = installedIconThemes(); + QString theme_name_from_settings = Settings::instance()->value(APP_CFG_GUI, "icon_theme", APP_THEME_DEFAULT).toString(); @@ -94,7 +94,7 @@ void IconThemeFactory::loadCurrentIconTheme() { } } -QStringList IconThemeFactory::getInstalledIconThemes() { +QStringList IconThemeFactory::installedIconThemes() { QStringList icon_theme_names; icon_theme_names << APP_NO_THEME; diff --git a/src/gui/iconthemefactory.h b/src/gui/iconthemefactory.h index bbeeeb5fa..0f4d9fb95 100755 --- a/src/gui/iconthemefactory.h +++ b/src/gui/iconthemefactory.h @@ -12,7 +12,7 @@ class IconThemeFactory : public QObject { public: // Singleton getter. - static IconThemeFactory *getInstance(); + static IconThemeFactory *instance(); // Destructor. virtual ~IconThemeFactory(); @@ -25,7 +25,7 @@ class IconThemeFactory : public QObject { void setupSearchPaths(); // Returns list of installed themes, including "default" theme. - QStringList getInstalledIconThemes(); + QStringList installedIconThemes(); // Loads name of selected icon theme (from settings) for the application and // activates it. If that particular theme is not installed, then @@ -33,18 +33,16 @@ class IconThemeFactory : public QObject { void loadCurrentIconTheme(); // Returns name of currently activated theme for the application. - QString getCurrentIconTheme(); + QString currentIconTheme(); // Sets icon theme with given name as the active one and loads it. void setCurrentIconTheme(const QString &theme_name); private: - QHash m_cachedIcons; - // Constructor. explicit IconThemeFactory(QObject *parent = 0); - // Holds name of the current icon theme. + QHash m_cachedIcons; QString m_currentIconTheme; // Singleton. diff --git a/src/gui/locationlineedit.cpp b/src/gui/locationlineedit.cpp index f79434e10..ead0414d8 100644 --- a/src/gui/locationlineedit.cpp +++ b/src/gui/locationlineedit.cpp @@ -52,7 +52,7 @@ void LocationLineEdit::mousePressEvent(QMouseEvent *event) { void LocationLineEdit::paintEvent(QPaintEvent *event) { // Draw "progress bar" if needed. - Settings *settings = Settings::getInstance(); + Settings *settings = Settings::instance(); if (m_progress > 0 && settings->value(APP_CFG_BROWSER, "browser_colored_progress_enabled", diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 6e8232012..3da6c0b31 100644 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -145,13 +145,13 @@ void MessagesView::contextMenuEvent(QContextMenuEvent *event) { void MessagesView::initializeContextMenu() { m_contextMenu = new QMenu(tr("Context menu for messages"), this); m_contextMenu->addActions(QList() << - FormMain::getInstance()->m_ui->m_actionOpenSelectedSourceArticlesExternally << - FormMain::getInstance()->m_ui->m_actionOpenSelectedSourceArticlesInternally << - FormMain::getInstance()->m_ui->m_actionOpenSelectedMessagesInternally << - FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsRead << - FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsUnread << - FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages << - FormMain::getInstance()->m_ui->m_actionDeleteSelectedMessages); + FormMain::instance()->m_ui->m_actionOpenSelectedSourceArticlesExternally << + FormMain::instance()->m_ui->m_actionOpenSelectedSourceArticlesInternally << + FormMain::instance()->m_ui->m_actionOpenSelectedMessagesInternally << + FormMain::instance()->m_ui->m_actionMarkSelectedMessagesAsRead << + FormMain::instance()->m_ui->m_actionMarkSelectedMessagesAsUnread << + FormMain::instance()->m_ui->m_actionSwitchImportanceOfSelectedMessages << + FormMain::instance()->m_ui->m_actionDeleteSelectedMessages); } void MessagesView::mousePressEvent(QMouseEvent *event) { @@ -227,9 +227,9 @@ void MessagesView::loadFeeds(const QList &feed_ids) { } void MessagesView::openSelectedSourceArticlesExternally() { - QString browser = Settings::getInstance()->value(APP_CFG_MESSAGES, + QString browser = Settings::instance()->value(APP_CFG_MESSAGES, "external_browser_executable").toString(); - QString arguments = Settings::getInstance()->value(APP_CFG_MESSAGES, + QString arguments = Settings::instance()->value(APP_CFG_MESSAGES, "external_browser_arguments", "%1").toString(); diff --git a/src/gui/shortcutcatcher.cpp b/src/gui/shortcutcatcher.cpp index ca0a2c272..31eb03826 100644 --- a/src/gui/shortcutcatcher.cpp +++ b/src/gui/shortcutcatcher.cpp @@ -44,7 +44,7 @@ ShortcutCatcher::ShortcutCatcher(QWidget *parent) // Create clear button. m_clearButton = new QToolButton(this); - m_clearButton->setIcon(IconThemeFactory::getInstance()->fromTheme("document-revert")); + m_clearButton->setIcon(IconThemeFactory::instance()->fromTheme("document-revert")); m_clearButton->setFocusPolicy(Qt::NoFocus); m_clearButton->setToolTip(tr("Reset shortcut.")); diff --git a/src/gui/skinfactory.cpp b/src/gui/skinfactory.cpp index 05d826bcd..f84b34364 100644 --- a/src/gui/skinfactory.cpp +++ b/src/gui/skinfactory.cpp @@ -19,7 +19,7 @@ SkinFactory::~SkinFactory() { qDebug("Destroying SkinFactory instance."); } -SkinFactory *SkinFactory::getInstance() { +SkinFactory *SkinFactory::instance() { if (s_instance.isNull()) { s_instance = new SkinFactory(qApp); } @@ -28,9 +28,9 @@ SkinFactory *SkinFactory::getInstance() { } void SkinFactory::loadCurrentSkin() { - QString skin_name_from_settings = getSelectedSkinName(); + QString skin_name_from_settings = selectedSkinName(); bool skin_parsed; - Skin skin_data = getSkinInfo(skin_name_from_settings, &skin_parsed); + Skin skin_data = skinInfo(skin_name_from_settings, &skin_parsed); if (skin_parsed) { loadSkinFromData(skin_data); @@ -93,24 +93,24 @@ bool SkinFactory::loadSkinFromData(const Skin &skin) { } void SkinFactory::setCurrentSkinName(const QString &skin_name) { - Settings::getInstance()->setValue(APP_CFG_GUI, "skin", skin_name); + Settings::instance()->setValue(APP_CFG_GUI, "skin", skin_name); } -QString SkinFactory::getSelectedSkinName() { - return Settings::getInstance()->value(APP_CFG_GUI, +QString SkinFactory::selectedSkinName() { + return Settings::instance()->value(APP_CFG_GUI, "skin", APP_SKIN_DEFAULT).toString(); } -QString SkinFactory::getCurrentMarkup() { +QString SkinFactory::currentMarkup() { return m_currentSkin.m_layoutMarkup; } -QString SkinFactory::getCurrentMarkupLayout() { +QString SkinFactory::currentMarkupLayout() { return m_currentSkin.m_layoutMarkupWrapper; } -Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) { +Skin SkinFactory::skinInfo(const QString &skin_name, bool *ok) { Skin skin; QString styles; QFile skin_file(APP_SKIN_PATH + QDir::separator() + skin_name); @@ -171,7 +171,7 @@ Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) { return skin; } -QList SkinFactory::getInstalledSkins() { +QList SkinFactory::installedSkins() { QList skins; bool skin_load_ok; QStringList skin_directories = QDir(APP_SKIN_PATH).entryList(QDir::Dirs | @@ -186,7 +186,7 @@ QList SkinFactory::getInstalledSkins() { foreach (const QString &skin_file, skin_files) { // Check if skin file is valid and add it if it is valid. - Skin skin_info = getSkinInfo(base_directory + QDir::separator() + skin_file, + Skin skin_info = skinInfo(base_directory + QDir::separator() + skin_file, &skin_load_ok); if (skin_load_ok) { diff --git a/src/gui/skinfactory.h b/src/gui/skinfactory.h index 481d06794..d469b7aa3 100644 --- a/src/gui/skinfactory.h +++ b/src/gui/skinfactory.h @@ -29,6 +29,7 @@ class SkinFactory : public QObject { Q_OBJECT private: + // Constructor. explicit SkinFactory(QObject *parent = 0); // Loads the skin from give skin_data. @@ -38,7 +39,7 @@ class SkinFactory : public QObject { public: // Singleton getter. - static SkinFactory *getInstance(); + static SkinFactory *instance(); // Destructor. virtual ~SkinFactory(); @@ -47,19 +48,19 @@ class SkinFactory : public QObject { void loadCurrentSkin(); // Returns contents of current layout markup. - QString getCurrentMarkup(); - QString getCurrentMarkupLayout(); + QString currentMarkup(); + QString currentMarkupLayout(); // Returns the name of the skin, that should be activated // after application restart. - QString getSelectedSkinName(); + QString selectedSkinName(); // Gets skin about a particular skin. - Skin getSkinInfo(const QString &skin_name, bool *ok = NULL); + Skin skinInfo(const QString &skin_name, bool *ok = NULL); // Returns list of installed skins, including "default system skin". // NOTE: Default skin always lies at position 0. - QList getInstalledSkins(); + QList installedSkins(); // Sets the desired skin as the active one if it exists. void setCurrentSkinName(const QString &skin_name); diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index cbc368112..f74eceb06 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -14,7 +14,7 @@ StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) { // Initializations of widgets for status bar. m_fullscreenSwitcher = new QToolButton(this); m_fullscreenSwitcher->setAutoRaise(true); - m_fullscreenSwitcher->setIcon(IconThemeFactory::getInstance()->fromTheme("view-fullscreen")); + m_fullscreenSwitcher->setIcon(IconThemeFactory::instance()->fromTheme("view-fullscreen")); m_fullscreenSwitcher->setText(tr("Fullscreen mode")); m_fullscreenSwitcher->setToolTip(tr("Switch application between fulscreen/normal states right from this status bar icon.")); diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 5b6538b34..275b423c6 100644 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -23,7 +23,7 @@ bool TrayIconMenu::event(QEvent *event) { if (QtSingleApplication::activeModalWidget() != NULL && event->type() == QEvent::Show) { QTimer::singleShot(0, this, SLOT(hide())); - SystemTrayIcon::getInstance()->showMessage(APP_LONG_NAME, + SystemTrayIcon::instance()->showMessage(APP_LONG_NAME, tr("Close opened modal dialogs first."), QSystemTrayIcon::Warning); } @@ -69,16 +69,16 @@ bool SystemTrayIcon::isSystemTrayAvailable() { } bool SystemTrayIcon::isSystemTrayActivated() { - return SystemTrayIcon::isSystemTrayAvailable() && Settings::getInstance()->value(APP_CFG_GUI, + return SystemTrayIcon::isSystemTrayAvailable() && Settings::instance()->value(APP_CFG_GUI, "use_tray_icon", true).toBool(); } -SystemTrayIcon *SystemTrayIcon::getInstance() { +SystemTrayIcon *SystemTrayIcon::instance() { if (s_trayIcon.isNull()) { s_trayIcon = new SystemTrayIcon(APP_ICON_PATH, APP_ICON_PLAIN_PATH, - FormMain::getInstance()); + FormMain::instance()); } return s_trayIcon; diff --git a/src/gui/systemtrayicon.h b/src/gui/systemtrayicon.h index cbf1e6dfe..0975d707a 100644 --- a/src/gui/systemtrayicon.h +++ b/src/gui/systemtrayicon.h @@ -40,7 +40,7 @@ class SystemTrayIcon : public QSystemTrayIcon { // Creates new tray icon if necessary and returns it. // WARNING: Use this in cooperation with SystemTrayIcon::isSystemTrayActivated(). - static SystemTrayIcon *getInstance(); + static SystemTrayIcon *instance(); // Sets the number to be visible in the tray icon, -1 removes it. void setNumber(int number = -1); diff --git a/src/gui/tabbar.cpp b/src/gui/tabbar.cpp index 6a99c698e..82ac04434 100644 --- a/src/gui/tabbar.cpp +++ b/src/gui/tabbar.cpp @@ -55,7 +55,7 @@ void TabBar::mousePressEvent(QMouseEvent *event) { // Check if user clicked tab with middle button. // NOTE: This needs to be done here because // destination does not know the original event. - if (event->button() & Qt::MiddleButton && Settings::getInstance()->value(APP_CFG_GUI, + if (event->button() & Qt::MiddleButton && Settings::instance()->value(APP_CFG_GUI, "tab_close_mid_button", true).toBool()) { if (tabType(tab_index) == TabBar::Closable) { @@ -76,7 +76,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent *event) { // Check if user clicked tab with middle button. // NOTE: This needs to be done here because // destination does not know the original event. - if (event->button() & Qt::LeftButton && Settings::getInstance()->value(APP_CFG_GUI, + if (event->button() & Qt::LeftButton && Settings::instance()->value(APP_CFG_GUI, "tab_close_double_button", true).toBool()) { if (tabType(tab_index) == TabBar::Closable) { @@ -88,7 +88,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent *event) { // Check if new tab should be opened with initial web browser. // NOTE: This check could be unnecesary here and should be done in // destination object but we keep it here for consistency. - else if (Settings::getInstance()->value(APP_CFG_GUI, + else if (Settings::instance()->value(APP_CFG_GUI, "tab_new_double_button", true).toBool()) { emit emptySpaceDoubleClicked(); diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp index 1baecc837..315861c07 100644 --- a/src/gui/tabwidget.cpp +++ b/src/gui/tabwidget.cpp @@ -29,7 +29,7 @@ void TabWidget::setupCornerButton() { } void TabWidget::checkTabBarVisibility() { - tabBar()->setVisible(count() > 1 || !Settings::getInstance()->value(APP_CFG_GUI, + tabBar()->setVisible(count() > 1 || !Settings::instance()->value(APP_CFG_GUI, "hide_tabbar_one_tab", true).toBool()); } @@ -76,7 +76,7 @@ void TabWidget::setupIcons() { for (int index = 0; index < count(); index++) { // Index 0 usually contains widget which displays feeds & messages. if (tabBar()->tabType(index) == TabBar::FeedReader) { - setTabIcon(index, IconThemeFactory::getInstance()->fromTheme("application-rss+xml")); + setTabIcon(index, IconThemeFactory::instance()->fromTheme("application-rss+xml")); } // Other indexes probably contain WebBrowsers. else { @@ -84,13 +84,13 @@ void TabWidget::setupIcons() { if (active_browser != NULL && active_browser->icon().isNull()) { // We found WebBrowser instance of this tab page, which // has no suitable icon, load a new one from the icon theme. - setTabIcon(index, IconThemeFactory::getInstance()->fromTheme("text-html")); + setTabIcon(index, IconThemeFactory::instance()->fromTheme("text-html")); } } } // Setup corner button icon. - m_cornerButton->setIcon(IconThemeFactory::getInstance()->fromTheme("list-add")); + m_cornerButton->setIcon(IconThemeFactory::instance()->fromTheme("list-add")); } bool TabWidget::closeTab(int index) { @@ -194,7 +194,7 @@ int TabWidget::addLinkedBrowser(const QString &initial_url) { } int TabWidget::addLinkedBrowser(const QUrl &initial_url) { - return addBrowser(Settings::getInstance()->value(APP_CFG_BROWSER, + return addBrowser(Settings::instance()->value(APP_CFG_BROWSER, "queue_tabs", true).toBool(), false, @@ -214,14 +214,14 @@ int TabWidget::addBrowser(bool move_after_current, // Insert web browser after current tab. final_index = insertTab(currentIndex() + 1, browser, - IconThemeFactory::getInstance()->fromTheme("text-html"), + IconThemeFactory::instance()->fromTheme("text-html"), tr("Web browser"), TabBar::Closable); } else { // Add new browser as the last tab. final_index = addTab(browser, - IconThemeFactory::getInstance()->fromTheme("text-html"), + IconThemeFactory::instance()->fromTheme("text-html"), tr("Web browser"), TabBar::Closable); } diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index c40258469..beea31459 100644 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -122,7 +122,7 @@ void WebBrowser::createConnections() { connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl))); // Connect this WebBrowser to global TabWidget. - TabWidget *tab_widget = FormMain::getInstance()->getTabWidget(); + TabWidget *tab_widget = FormMain::instance()->getTabWidget(); connect(m_webView, SIGNAL(newTabRequested()), tab_widget, SLOT(addEmptyBrowser())); connect(m_webView, SIGNAL(linkMiddleClicked(QUrl)), tab_widget, SLOT(addLinkedBrowser(QUrl))); @@ -167,9 +167,9 @@ void WebBrowser::clear() { } void WebBrowser::navigateToMessages(const QList &messages) { - SkinFactory *factory = SkinFactory::getInstance(); + SkinFactory *factory = SkinFactory::instance(); QString messages_layout; - QString default_message_layout = factory->getCurrentMarkup(); + QString default_message_layout = factory->currentMarkup(); foreach (const Message &message, messages) { messages_layout.append(default_message_layout.arg(message.m_title, @@ -181,14 +181,14 @@ void WebBrowser::navigateToMessages(const QList &messages) { message.m_created.toString(Qt::DefaultLocaleShortDate))); } - QString layout_wrapper = factory->getCurrentMarkupLayout().arg(messages.size() == 1 ? + QString layout_wrapper = factory->currentMarkupLayout().arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"), messages_layout); m_webView->setHtml(layout_wrapper, QUrl(INTERNAL_URL_NEWSPAPER)); emit iconChanged(m_index, - IconThemeFactory::getInstance()->fromTheme("document-multiple")); + IconThemeFactory::instance()->fromTheme("document-multiple")); } void WebBrowser::updateZoomGui() { @@ -254,11 +254,11 @@ void WebBrowser::setFocus(Qt::FocusReason reason) { } void WebBrowser::setupIcons() { - m_actionZoom->setIcon(IconThemeFactory::getInstance()->fromTheme("zoom-fit-best")); - m_actionBack->setIcon(IconThemeFactory::getInstance()->fromTheme("go-previous")); - m_actionForward->setIcon(IconThemeFactory::getInstance()->fromTheme("go-next")); - m_actionReload->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh")); - m_actionStop->setIcon(IconThemeFactory::getInstance()->fromTheme("process-stop")); + m_actionZoom->setIcon(IconThemeFactory::instance()->fromTheme("zoom-fit-best")); + m_actionBack->setIcon(IconThemeFactory::instance()->fromTheme("go-previous")); + m_actionForward->setIcon(IconThemeFactory::instance()->fromTheme("go-next")); + m_actionReload->setIcon(IconThemeFactory::instance()->fromTheme("view-refresh")); + m_actionStop->setIcon(IconThemeFactory::instance()->fromTheme("process-stop")); m_webView->setupIcons(); } diff --git a/src/gui/webview.cpp b/src/gui/webview.cpp index 3a1994841..ac0dc8be0 100644 --- a/src/gui/webview.cpp +++ b/src/gui/webview.cpp @@ -57,17 +57,17 @@ void WebView::createConnections() { } void WebView::setupIcons() { - m_actionReload->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh")); - m_actionCopyLink->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-copy")); - m_actionCopyImage->setIcon(IconThemeFactory::getInstance()->fromTheme("insert-image")); + m_actionReload->setIcon(IconThemeFactory::instance()->fromTheme("view-refresh")); + m_actionCopyLink->setIcon(IconThemeFactory::instance()->fromTheme("edit-copy")); + m_actionCopyImage->setIcon(IconThemeFactory::instance()->fromTheme("insert-image")); #if QT_VERSION >= 0x040800 - m_actionCopyImageUrl->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-copy")); + m_actionCopyImageUrl->setIcon(IconThemeFactory::instance()->fromTheme("edit-copy")); #endif - m_actionOpenLinkThisTab->setIcon(IconThemeFactory::getInstance()->fromTheme("text-html")); - m_actionOpenLinkNewTab->setIcon(IconThemeFactory::getInstance()->fromTheme("text-html")); - m_actionOpenImageNewTab->setIcon(IconThemeFactory::getInstance()->fromTheme("insert-image")); + m_actionOpenLinkThisTab->setIcon(IconThemeFactory::instance()->fromTheme("text-html")); + m_actionOpenLinkNewTab->setIcon(IconThemeFactory::instance()->fromTheme("text-html")); + m_actionOpenImageNewTab->setIcon(IconThemeFactory::instance()->fromTheme("insert-image")); } void WebView::initializeActions() { @@ -111,9 +111,9 @@ void WebView::initializeActions() { } void WebView::displayErrorPage() { - setHtml(SkinFactory::getInstance()->getCurrentMarkupLayout().arg( + setHtml(SkinFactory::instance()->currentMarkupLayout().arg( tr("Error page"), - SkinFactory::getInstance()->getCurrentMarkup().arg(tr("Page not found"), + SkinFactory::instance()->currentMarkup().arg(tr("Page not found"), tr("Check your internet connection or website address"), QString(), tr("This failure can be caused by:
    " @@ -132,8 +132,8 @@ void WebView::popupContextMenu(const QPoint &pos) { QMenu link_submenu(tr("Hyperlink"), this); QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(pos); - image_submenu.setIcon(IconThemeFactory::getInstance()->fromTheme("image-x-generic")); - link_submenu.setIcon(IconThemeFactory::getInstance()->fromTheme("text-html")); + image_submenu.setIcon(IconThemeFactory::instance()->fromTheme("image-x-generic")); + link_submenu.setIcon(IconThemeFactory::instance()->fromTheme("text-html")); // Assemble the menu from actions. context_menu.addAction(m_actionReload); @@ -198,7 +198,7 @@ void WebView::mousePressEvent(QMouseEvent *event) { void WebView::mouseReleaseEvent(QMouseEvent *event) { if (event->button() & Qt::MiddleButton) { - bool are_gestures_enabled = Settings::getInstance()->value(APP_CFG_BROWSER, + bool are_gestures_enabled = Settings::instance()->value(APP_CFG_BROWSER, "gestures_enabled", true).toBool(); if (are_gestures_enabled) { diff --git a/src/main.cpp b/src/main.cpp index 4f8ba79d7..c2b08744c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,9 +65,9 @@ int main(int argc, char *argv[]) { // Add an extra path for non-system icon themes and set current icon theme // and skin. - IconThemeFactory::getInstance()->setupSearchPaths(); - IconThemeFactory::getInstance()->loadCurrentIconTheme(); - SkinFactory::getInstance()->loadCurrentSkin(); + IconThemeFactory::instance()->setupSearchPaths(); + IconThemeFactory::instance()->loadCurrentIconTheme(); + SkinFactory::instance()->loadCurrentSkin(); // Load localization and setup locale before any widget is constructed. LoadLocalization(); @@ -92,13 +92,13 @@ int main(int argc, char *argv[]) { DynamicShortcuts::load(window.getActions()); // Display welcome dialog if application is launched for the first time. - if (Settings::getInstance()->value(APP_CFG_GEN, "first_start", true).toBool()) { - Settings::getInstance()->setValue(APP_CFG_GEN, "first_start", false); + if (Settings::instance()->value(APP_CFG_GEN, "first_start", true).toBool()) { + Settings::instance()->setValue(APP_CFG_GEN, "first_start", false); FormWelcome(&window).exec(); } // Display main window. - if (Settings::getInstance()->value(APP_CFG_GUI, "start_hidden", + if (Settings::instance()->value(APP_CFG_GUI, "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) { qDebug("Hiding the main window when the application is starting."); @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) { // Display tray icon if it is enabled and available. if (SystemTrayIcon::isSystemTrayActivated()) { - SystemTrayIcon::getInstance()->show(); + SystemTrayIcon::instance()->show(); } // Setup single-instance behavior.