diff --git a/CMakeLists.txt b/CMakeLists.txt index 14bd6181a..e45ad527f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -354,6 +354,7 @@ set(APP_SOURCES src/dynamic-shortcuts/dynamicshortcuts.cpp # MISCELLANEOUS sources. + src/miscellaneous/application.cpp src/miscellaneous/debugging.cpp src/miscellaneous/settings.cpp src/miscellaneous/systemfactory.cpp @@ -387,7 +388,6 @@ set(APP_SOURCES src/network-web/downloader.cpp # MAIN sources. - src/application.cpp src/main.cpp ) @@ -436,6 +436,7 @@ set(APP_HEADERS src/dynamic-shortcuts/shortcutbutton.h # MISCELLANEOUS headers. + src/miscellaneous/application.h src/miscellaneous/settings.h src/miscellaneous/localization.h src/miscellaneous/systemfactory.h @@ -459,9 +460,6 @@ set(APP_HEADERS src/network-web/webbrowser.h src/network-web/webview.h src/network-web/downloader.h - - # MAIN headers. - src/application.h ) # APP form files. diff --git a/README.md b/README.md index 3549140ab..3ba334385 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ RSS Guard is written in C++. It is pretty fast even with tons of messages loaded * MySQL. * “portable” mode support, * feed categorization, +* can be fully controlled via keyboard, * feed authentication (Digest-MD5, BASIC, NTLM-2), * handles tons of messages & feeds, * sweet look & feel, diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 7a7552d12..8d4e5bd07 100644 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -3,7 +3,7 @@ Fixed: Added: diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index 1396561c4..427c8f7c4 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -17,7 +17,7 @@ #include "core/feedsmodelrootitem.h" -#include "application.h" +#include "miscellaneous/application.h" #include diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp old mode 100644 new mode 100755 index 2618feb4e..7005137f7 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -18,10 +18,10 @@ #include "core/messagesmodel.h" #include "definitions/definitions.h" +#include "miscellaneous/application.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/databasefactory.h" #include "miscellaneous/iconfactory.h" -#include "application.h" #include #include diff --git a/src/dynamic-shortcuts/dynamicshortcuts.cpp b/src/dynamic-shortcuts/dynamicshortcuts.cpp old mode 100644 new mode 100755 index b2b51a557..80f1acad2 --- a/src/dynamic-shortcuts/dynamicshortcuts.cpp +++ b/src/dynamic-shortcuts/dynamicshortcuts.cpp @@ -18,8 +18,8 @@ #include "dynamic-shortcuts/dynamicshortcuts.h" #include "definitions/definitions.h" +#include "miscellaneous/application.h" #include "miscellaneous/settings.h" -#include "application.h" #include diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp old mode 100644 new mode 100755 index 06d291ab1..7a2908b97 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -163,7 +163,7 @@ void FeedMessageViewer::updateTrayIconStatus(int unread_messages, void FeedMessageViewer::onFeedUpdatesStarted() { //: Text display in status bar when feed update is started. - FormMain::instance()->statusBar()->showProgress(0, tr("Feed update started")); + qApp->mainForm()->statusBar()->showProgress(0, tr("Feed update started")); } void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, @@ -171,7 +171,7 @@ void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, int total) { // Some feed got updated. m_feedsView->updateCountsOfParticularFeed(feed, true); - FormMain::instance()->statusBar()->showProgress((current * 100.0) / total, + qApp->mainForm()->statusBar()->showProgress((current * 100.0) / total, //: Text display in status bar when particular feed is updated. tr("Updated feed '%1'").arg(feed->title())); } @@ -181,7 +181,7 @@ void FeedMessageViewer::onFeedUpdatesFinished() { qApp->closeLock()->unlock(); // And also hide progress bar. - FormMain::instance()->statusBar()->clearProgress(); + qApp->mainForm()->statusBar()->clearProgress(); // TODO: Check integrity and conformance of this. m_messagesView->reloadSelections(1); @@ -192,7 +192,7 @@ void FeedMessageViewer::switchFeedComponentVisibility() { } void FeedMessageViewer::createConnections() { - FormMain *form_main = FormMain::instance(); + FormMain *form_main = qApp->mainForm(); // Filtering & searching. connect(m_toolBarMessages, SIGNAL(messageSearchPatternChanged(QString)), diff --git a/src/gui/feedstoolbar.cpp b/src/gui/feedstoolbar.cpp old mode 100644 new mode 100755 index 57742945f..4d841c03a --- a/src/gui/feedstoolbar.cpp +++ b/src/gui/feedstoolbar.cpp @@ -17,8 +17,9 @@ #include "gui/feedstoolbar.h" -#include "gui/formmain.h" +#include "miscellaneous/application.h" #include "miscellaneous/settings.h" +#include "miscellaneous/iconfactory.h" FeedsToolBar::FeedsToolBar(const QString &title, QWidget *parent) : BaseToolBar(title, parent) { @@ -32,7 +33,14 @@ FeedsToolBar::~FeedsToolBar() { } QHash FeedsToolBar::availableActions() const { - return FormMain::instance()->allActions();; + QList application_actions = qApp->userActions(); + QHash available_actions; + + foreach (QAction *application_action, application_actions) { + available_actions.insert(application_action->objectName(), application_action); + } + + return available_actions; } QList FeedsToolBar::changeableActions() const { diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp old mode 100644 new mode 100755 index 4819472d5..3004e50de --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -470,19 +470,19 @@ void FeedsView::selectPreviousItem() { void FeedsView::initializeContextMenuCategoriesFeeds() { m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this); m_contextMenuCategoriesFeeds->addActions(QList() << - FormMain::instance()->m_ui->m_actionUpdateSelectedFeedsCategories << - FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory << - FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode << - FormMain::instance()->m_ui->m_actionMarkSelectedFeedsAsRead << - FormMain::instance()->m_ui->m_actionMarkSelectedFeedsAsUnread); + qApp->mainForm()->m_ui->m_actionUpdateSelectedFeedsCategories << + qApp->mainForm()->m_ui->m_actionEditSelectedFeedCategory << + qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode << + qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsRead << + qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsUnread); } void FeedsView::initializeContextMenuEmptySpace() { m_contextMenuEmptySpace = new QMenu(tr("Context menu for feeds"), this); m_contextMenuEmptySpace->addActions(QList() << - FormMain::instance()->m_ui->m_actionUpdateAllFeeds << - FormMain::instance()->m_ui->m_actionAddCategory << - FormMain::instance()->m_ui->m_actionAddFeed); + qApp->mainForm()->m_ui->m_actionUpdateAllFeeds << + qApp->mainForm()->m_ui->m_actionAddCategory << + qApp->mainForm()->m_ui->m_actionAddFeed); } void FeedsView::setupAppearance() { diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index 09619fad1..3626d8bc8 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -19,6 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" +#include "miscellaneous/application.h" #include "miscellaneous/systemfactory.h" #include "miscellaneous/databasefactory.h" #include "miscellaneous/iconfactory.h" @@ -33,7 +34,6 @@ #include "gui/statusbar.h" #include "gui/feedmessageviewer.h" #include "gui/formupdate.h" -#include "application.h" #include #include @@ -43,14 +43,10 @@ #include -FormMain *FormMain::s_instance; - FormMain::FormMain(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, f), m_ui(new Ui::FormMain) { m_ui->setupUi(this); - - // Initialize singleton. - s_instance = this; + qApp->setMainForm(this); m_statusBar = new StatusBar(this); setStatusBar(m_statusBar); @@ -64,7 +60,7 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f) // Add these actions to the list of actions of the main window. // This allows to use actions via shortcuts // even if main menu is not visible. - addActions(allActions().values()); + addActions(allActions()); // Prepare tabs. m_ui->m_tabWidget->initializeTabs(); @@ -81,58 +77,51 @@ FormMain::~FormMain() { delete m_ui; } -FormMain *FormMain::instance() { - return s_instance; -} - -QHash FormMain::allActions() { - // TODO: nevytvaret pokazde novej hash ale udelat jeden - // a ten pak pouzivat. - // tohle by mohl bejt kandidat - QHash actions; +QList FormMain::allActions() { + QList actions; // Add basic actions. - actions.insert(m_ui->m_actionSettings->objectName(), m_ui->m_actionSettings); - actions.insert(m_ui->m_actionImportFeeds->objectName(), m_ui->m_actionImportFeeds); - actions.insert(m_ui->m_actionExportFeeds->objectName(), m_ui->m_actionExportFeeds); - actions.insert(m_ui->m_actionQuit->objectName(), m_ui->m_actionQuit); - actions.insert(m_ui->m_actionFullscreen->objectName(), m_ui->m_actionFullscreen); - actions.insert(m_ui->m_actionAboutGuard->objectName(), m_ui->m_actionAboutGuard); - actions.insert(m_ui->m_actionSwitchFeedsList->objectName(), m_ui->m_actionSwitchFeedsList); - actions.insert(m_ui->m_actionSwitchMainWindow->objectName(), m_ui->m_actionSwitchMainWindow); - actions.insert(m_ui->m_actionSwitchMainMenu->objectName(), m_ui->m_actionSwitchMainMenu); - actions.insert(m_ui->m_actionSwitchToolBars->objectName(), m_ui->m_actionSwitchToolBars); - actions.insert(m_ui->m_actionSwitchListHeaders->objectName(), m_ui->m_actionSwitchListHeaders); + actions << m_ui->m_actionSettings; + actions << m_ui->m_actionImportFeeds; + actions << m_ui->m_actionExportFeeds; + actions << m_ui->m_actionQuit; + actions << m_ui->m_actionFullscreen; + actions << m_ui->m_actionAboutGuard; + actions << m_ui->m_actionSwitchFeedsList; + actions << m_ui->m_actionSwitchMainWindow; + actions << m_ui->m_actionSwitchMainMenu; + actions << m_ui->m_actionSwitchToolBars; + actions << m_ui->m_actionSwitchListHeaders; // Add web browser actions - actions.insert(m_ui->m_actionAddBrowser->objectName(), m_ui->m_actionAddBrowser); - actions.insert(m_ui->m_actionCloseCurrentTab->objectName(), m_ui->m_actionCloseCurrentTab); - actions.insert(m_ui->m_actionCloseAllTabs->objectName(), m_ui->m_actionCloseAllTabs); + actions << m_ui->m_actionAddBrowser; + actions << m_ui->m_actionCloseCurrentTab; + actions << m_ui->m_actionCloseAllTabs; // Add feeds/messages actions. - actions.insert(m_ui->m_actionOpenSelectedSourceArticlesExternally->objectName(), m_ui->m_actionOpenSelectedSourceArticlesExternally); - actions.insert(m_ui->m_actionOpenSelectedSourceArticlesInternally->objectName(), m_ui->m_actionOpenSelectedSourceArticlesInternally); - actions.insert(m_ui->m_actionOpenSelectedMessagesInternally->objectName(), m_ui->m_actionOpenSelectedMessagesInternally); - actions.insert(m_ui->m_actionMarkAllFeedsRead->objectName(), m_ui->m_actionMarkAllFeedsRead); - actions.insert(m_ui->m_actionMarkSelectedFeedsAsRead->objectName(), m_ui->m_actionMarkSelectedFeedsAsRead); - actions.insert(m_ui->m_actionMarkSelectedFeedsAsUnread->objectName(), m_ui->m_actionMarkSelectedFeedsAsUnread); - actions.insert(m_ui->m_actionClearSelectedFeeds->objectName(), m_ui->m_actionClearSelectedFeeds); - actions.insert(m_ui->m_actionMarkSelectedMessagesAsRead->objectName(), m_ui->m_actionMarkSelectedMessagesAsRead); - actions.insert(m_ui->m_actionMarkSelectedMessagesAsUnread->objectName(), m_ui->m_actionMarkSelectedMessagesAsUnread); - actions.insert(m_ui->m_actionSwitchImportanceOfSelectedMessages->objectName(), m_ui->m_actionSwitchImportanceOfSelectedMessages); - actions.insert(m_ui->m_actionDeleteSelectedMessages->objectName(), m_ui->m_actionDeleteSelectedMessages); - actions.insert(m_ui->m_actionUpdateAllFeeds->objectName(), m_ui->m_actionUpdateAllFeeds); - actions.insert(m_ui->m_actionUpdateSelectedFeedsCategories->objectName(), m_ui->m_actionUpdateSelectedFeedsCategories); - actions.insert(m_ui->m_actionEditSelectedFeedCategory->objectName(), m_ui->m_actionEditSelectedFeedCategory); - actions.insert(m_ui->m_actionDeleteSelectedFeedCategory->objectName(), m_ui->m_actionDeleteSelectedFeedCategory); - actions.insert(m_ui->m_actionViewSelectedItemsNewspaperMode->objectName(), m_ui->m_actionViewSelectedItemsNewspaperMode); - actions.insert(m_ui->m_actionAddCategory->objectName(), m_ui->m_actionAddCategory); - actions.insert(m_ui->m_actionAddFeed->objectName(), m_ui->m_actionAddFeed); - actions.insert(m_ui->m_actionSelectNextFeedCategory->objectName(), m_ui->m_actionSelectNextFeedCategory); - actions.insert(m_ui->m_actionSelectPreviousFeedCategory->objectName(), m_ui->m_actionSelectPreviousFeedCategory); - actions.insert(m_ui->m_actionSelectNextMessage->objectName(), m_ui->m_actionSelectNextMessage); - actions.insert(m_ui->m_actionSelectPreviousMessage->objectName(), m_ui->m_actionSelectPreviousMessage); - actions.insert(m_ui->m_actionDefragmentDatabase->objectName(), m_ui->m_actionDefragmentDatabase); + actions << m_ui->m_actionOpenSelectedSourceArticlesExternally; + actions << m_ui->m_actionOpenSelectedSourceArticlesInternally; + actions << m_ui->m_actionOpenSelectedMessagesInternally; + actions << m_ui->m_actionMarkAllFeedsRead; + actions << m_ui->m_actionMarkSelectedFeedsAsRead; + actions << m_ui->m_actionMarkSelectedFeedsAsUnread; + actions << m_ui->m_actionClearSelectedFeeds; + actions << m_ui->m_actionMarkSelectedMessagesAsRead; + actions << m_ui->m_actionMarkSelectedMessagesAsUnread; + actions << m_ui->m_actionSwitchImportanceOfSelectedMessages; + actions << m_ui->m_actionDeleteSelectedMessages; + actions << m_ui->m_actionUpdateAllFeeds; + actions << m_ui->m_actionUpdateSelectedFeedsCategories; + actions << m_ui->m_actionEditSelectedFeedCategory; + actions << m_ui->m_actionDeleteSelectedFeedCategory; + actions << m_ui->m_actionViewSelectedItemsNewspaperMode; + actions << m_ui->m_actionAddCategory; + actions << m_ui->m_actionAddFeed; + actions << m_ui->m_actionSelectNextFeedCategory; + actions << m_ui->m_actionSelectPreviousFeedCategory; + actions << m_ui->m_actionSelectNextMessage; + actions << m_ui->m_actionSelectPreviousMessage; + actions << m_ui->m_actionDefragmentDatabase; return actions; } diff --git a/src/gui/formmain.h b/src/gui/formmain.h old mode 100644 new mode 100755 index 2ecf71d5f..f7aedb673 --- a/src/gui/formmain.h +++ b/src/gui/formmain.h @@ -58,10 +58,7 @@ class FormMain : public QMainWindow { // Returns list of all globally available actions. // NOTE: This is used for setting dynamic shortcuts // for given actions. - QHash allActions(); - - // Singleton accessor. - static FormMain *instance(); + QList allActions(); protected: // Creates all needed menus and sets them up. @@ -120,8 +117,6 @@ class FormMain : public QMainWindow { Ui::FormMain *m_ui; QMenu *m_trayMenu; StatusBar *m_statusBar; - - static FormMain *s_instance; }; #endif // FORMMAIN_H diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui old mode 100644 new mode 100755 index fe976cad3..12811bab4 --- a/src/gui/formmain.ui +++ b/src/gui/formmain.ui @@ -178,7 +178,7 @@ Quit the application. - Ctrl+Shift+Q + Ctrl+Q QAction::QuitRole @@ -228,7 +228,7 @@ Add new web browser tab. - Ctrl+Shift+T + Ctrl+T @@ -259,6 +259,9 @@ Update &selected feeds + + Ctrl+U + @@ -421,7 +424,7 @@ Select &next feed/category - Ctrl+Down + S @@ -429,7 +432,7 @@ Select &previous feed/category - Ctrl+Up + A @@ -437,7 +440,7 @@ Select &next message - Alt+Down + W @@ -445,7 +448,7 @@ Select &previous message - Alt+Up + Q @@ -480,6 +483,9 @@ Enable &JavaScript + + J + @@ -488,6 +494,9 @@ Enable external &plugins + + P + @@ -496,6 +505,9 @@ Auto-load &images + + I + diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 7b44e6d9e..d62393064 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -20,6 +20,7 @@ #include "definitions/definitions.h" #include "core/feeddownloader.h" #include "core/feedsmodel.h" +#include "miscellaneous/application.h" #include "miscellaneous/settings.h" #include "miscellaneous/databasefactory.h" #include "miscellaneous/localization.h" @@ -39,7 +40,6 @@ #include "gui/basetoolbar.h" #include "gui/messagestoolbar.h" #include "dynamic-shortcuts/dynamicshortcuts.h" -#include "application.h" #include #include @@ -221,8 +221,8 @@ void FormSettings::saveFeedsMessages() { settings->setValue(APP_CFG_FEEDS, "feeds_update_on_startup", m_ui->m_checkUpdateAllFeedsOnStartup->isChecked()); settings->setValue(APP_CFG_FEEDS, "count_format", m_ui->m_cmbCountsFeedList->currentText()); - FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->updateAutoUpdateStatus(); - FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->reloadWholeLayout(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->updateAutoUpdateStatus(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->reloadWholeLayout(); } void FormSettings::displayProxyPassword(int state) { @@ -472,7 +472,7 @@ void FormSettings::saveLanguage() { } void FormSettings::loadShortcuts() { - m_ui->m_shortcuts->populate(FormMain::instance()->allActions().values()); + m_ui->m_shortcuts->populate(qApp->mainForm()->allActions()); } void FormSettings::saveShortcuts() { @@ -480,7 +480,7 @@ void FormSettings::saveShortcuts() { m_ui->m_shortcuts->updateShortcuts(); // Save new shortcuts to the settings. - DynamicShortcuts::save(FormMain::instance()->allActions().values()); + DynamicShortcuts::save(qApp->mainForm()->allActions()); } void FormSettings::loadDataStorage() { @@ -759,8 +759,8 @@ void FormSettings::loadInterface() { Qt::ToolButtonIconOnly).toInt())); // Load toolbars. - m_ui->m_editorFeedsToolbar->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->feedsToolBar()); - m_ui->m_editorMessagesToolbar->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->messagesToolBar()); + m_ui->m_editorFeedsToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsToolBar()); + m_ui->m_editorMessagesToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesToolBar()); } void FormSettings::saveInterface() { @@ -823,6 +823,6 @@ void FormSettings::saveInterface() { m_ui->m_editorFeedsToolbar->saveToolBar(); m_ui->m_editorMessagesToolbar->saveToolBar(); - FormMain::instance()->tabWidget()->checkTabBarVisibility(); - FormMain::instance()->tabWidget()->feedMessageViewer()->refreshVisualProperties(); + qApp->mainForm()->tabWidget()->checkTabBarVisibility(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->refreshVisualProperties(); } diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp old mode 100644 new mode 100755 index 5324ded57..d92036005 --- a/src/gui/messagebox.cpp +++ b/src/gui/messagebox.cpp @@ -17,8 +17,8 @@ #include "gui/messagebox.h" +#include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" -#include "application.h" #include #include diff --git a/src/gui/messagestoolbar.cpp b/src/gui/messagestoolbar.cpp old mode 100644 new mode 100755 index 3ff6c3059..a8c6d2fd1 --- a/src/gui/messagestoolbar.cpp +++ b/src/gui/messagestoolbar.cpp @@ -39,9 +39,16 @@ MessagesToolBar::~MessagesToolBar() { } QHash MessagesToolBar::availableActions() const { - QHash available_actions = FormMain::instance()->allActions(); + QList application_actions = qApp->mainForm()->allActions(); + QHash available_actions; + + foreach (QAction *application_action, application_actions) { + available_actions.insert(application_action->objectName(), application_action); + } + available_actions.insert(SEACRH_MESSAGES_ACTION_NAME, m_actionSearchMessages); available_actions.insert(HIGHLIGHTER_ACTION_NAME, m_actionMessageHighlighter); + return available_actions; } diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp old mode 100644 new mode 100755 index eef86c505..8aa51a288 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -147,13 +147,13 @@ void MessagesView::contextMenuEvent(QContextMenuEvent *event) { void MessagesView::initializeContextMenu() { m_contextMenu = new QMenu(tr("Context menu for messages"), this); m_contextMenu->addActions(QList() << - 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); + qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally << + qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesInternally << + qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally << + qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsRead << + qApp->mainForm()->m_ui->m_actionMarkSelectedMessagesAsUnread << + qApp->mainForm()->m_ui->m_actionSwitchImportanceOfSelectedMessages << + qApp->mainForm()->m_ui->m_actionDeleteSelectedMessages); } void MessagesView::mousePressEvent(QMouseEvent *event) { diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp old mode 100644 new mode 100755 index 632129db8..76eec5a07 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -18,10 +18,10 @@ #include "gui/systemtrayicon.h" #include "definitions/definitions.h" +#include "miscellaneous/application.h" #include "miscellaneous/settings.h" #include "gui/formmain.h" #include "gui/formsettings.h" -#include "application.h" #include #include diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp old mode 100644 new mode 100755 index 8526fbfe2..7dfbe64f9 --- a/src/gui/tabwidget.cpp +++ b/src/gui/tabwidget.cpp @@ -18,6 +18,7 @@ #include "gui/tabwidget.h" #include "definitions/definitions.h" +#include "miscellaneous/application.h" #include "miscellaneous/settings.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/iconfactory.h" @@ -26,7 +27,6 @@ #include "gui/formmain.h" #include "gui/feedmessageviewer.h" #include "gui/plaintoolbutton.h" -#include "application.h" #include #include @@ -67,13 +67,13 @@ void TabWidget::setupMainMenuButton() { void TabWidget::openMainMenu() { if (m_menuMain == NULL) { m_menuMain = new QMenu(tr("Main menu"), this); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuFile); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuView); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuFeeds); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuMessages); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuWebBrowser); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuTools); - m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuHelp); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuFile); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuView); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuFeeds); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuMessages); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuWebBrowser); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuTools); + m_menuMain->addMenu(qApp->mainForm()->m_ui->m_menuHelp); } QPoint button_position = m_btnMainMenu->pos(); diff --git a/src/main.cpp b/src/main.cpp old mode 100644 new mode 100755 index e242447ca..cb81ccb84 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ #include "gui/systemtrayicon.h" #include "gui/feedmessageviewer.h" #include "gui/feedsview.h" -#include "application.h" +#include "miscellaneous/application.h" // Needed for setting ini file format on Mac OS. #ifdef Q_OS_MAC @@ -96,13 +96,12 @@ int main(int argc, char *argv[]) { // Instantiate main application window. FormMain main_window; - application.setMainForm(&main_window); // Set correct information for main window. main_window.setWindowTitle(APP_LONG_NAME); // Now is a good time to initialize dynamic keyboard shortcuts. - DynamicShortcuts::load(main_window.allActions().values()); + DynamicShortcuts::load(main_window.allActions()); // Display main window. if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", diff --git a/src/application.cpp b/src/miscellaneous/application.cpp similarity index 82% rename from src/application.cpp rename to src/miscellaneous/application.cpp index ae8e1c67e..a4f73e5fd 100755 --- a/src/application.cpp +++ b/src/miscellaneous/application.cpp @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "application.h" +#include "miscellaneous/application.h" #include "miscellaneous/systemfactory.h" #include "gui/feedsview.h" @@ -25,13 +25,23 @@ Application::Application(const QString &id, int &argc, char **argv) - : QtSingleApplication(id, argc, argv), m_closeLock(NULL), m_mainForm(NULL), m_trayIcon(NULL), m_settings(NULL), m_system(NULL) { + : QtSingleApplication(id, argc, argv), + m_closeLock(NULL), m_userActions(QList()), m_mainForm(NULL), + m_trayIcon(NULL), m_settings(NULL), m_system(NULL) { } Application::~Application() { delete m_closeLock; } +QList Application::userActions() { + if (m_mainForm != NULL && m_userActions.isEmpty()) { + m_userActions = m_mainForm->allActions(); + } + + return m_userActions; +} + SystemTrayIcon *Application::trayIcon() { if (m_trayIcon == NULL) { m_trayIcon = new SystemTrayIcon(APP_ICON_PATH, APP_ICON_PLAIN_PATH, m_mainForm); diff --git a/src/application.h b/src/miscellaneous/application.h old mode 100644 new mode 100755 similarity index 94% rename from src/application.h rename to src/miscellaneous/application.h index 234aba7b1..195c73618 --- a/src/application.h +++ b/src/miscellaneous/application.h @@ -26,6 +26,7 @@ #include "gui/systemtrayicon.h" #include +#include #if defined(qApp) #undef qApp @@ -36,6 +37,7 @@ class FormMain; +class QAction; // TODO: presunout nektery veci sem, settings atp class Application : public QtSingleApplication { @@ -46,6 +48,8 @@ class Application : public QtSingleApplication { explicit Application(const QString &id, int &argc, char **argv); virtual ~Application(); + QList userActions(); + inline SystemFactory *system() { if (m_system == NULL) { m_system = new SystemFactory(this); @@ -110,6 +114,7 @@ class Application : public QtSingleApplication { // tries to lock the lock for writing), then no other // action will be allowed to lock for reading. QMutex *m_closeLock; + QList m_userActions; FormMain *m_mainForm; SystemTrayIcon *m_trayIcon; Settings *m_settings; diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp old mode 100644 new mode 100755 index bcdbfec57..5e75be607 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -19,7 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include diff --git a/src/miscellaneous/debugging.cpp b/src/miscellaneous/debugging.cpp old mode 100644 new mode 100755 index 84112f4d2..8bddc8579 --- a/src/miscellaneous/debugging.cpp +++ b/src/miscellaneous/debugging.cpp @@ -18,7 +18,7 @@ #include "miscellaneous/debugging.h" #include "definitions/definitions.h" -#include "application.h" +#include "miscellaneous/application.h" #include diff --git a/src/miscellaneous/iconfactory.h b/src/miscellaneous/iconfactory.h old mode 100644 new mode 100755 index eb1a7e23f..5e9b0de8e --- a/src/miscellaneous/iconfactory.h +++ b/src/miscellaneous/iconfactory.h @@ -21,7 +21,7 @@ #include #include "definitions/definitions.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include diff --git a/src/miscellaneous/localization.cpp b/src/miscellaneous/localization.cpp old mode 100644 new mode 100755 index a21112c19..e24fd6485 --- a/src/miscellaneous/localization.cpp +++ b/src/miscellaneous/localization.cpp @@ -19,7 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp old mode 100644 new mode 100755 index 99181a6d6..01f67a25b --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -18,7 +18,7 @@ #include "miscellaneous/settings.h" #include "definitions/definitions.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include diff --git a/src/miscellaneous/skinfactory.cpp b/src/miscellaneous/skinfactory.cpp old mode 100644 new mode 100755 index b1ef28bdc..04eff0c93 --- a/src/miscellaneous/skinfactory.cpp +++ b/src/miscellaneous/skinfactory.cpp @@ -19,7 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include diff --git a/src/miscellaneous/systemfactory.cpp b/src/miscellaneous/systemfactory.cpp old mode 100644 new mode 100755 index ebae24734..4b39db48b --- a/src/miscellaneous/systemfactory.cpp +++ b/src/miscellaneous/systemfactory.cpp @@ -19,7 +19,7 @@ #include "definitions/definitions.h" #include "network-web/networkfactory.h" -#include "application.h" +#include "miscellaneous/application.h" #if defined(Q_OS_WIN) #include diff --git a/src/network-web/basenetworkaccessmanager.cpp b/src/network-web/basenetworkaccessmanager.cpp index 2d6cf1172..0955c4612 100755 --- a/src/network-web/basenetworkaccessmanager.cpp +++ b/src/network-web/basenetworkaccessmanager.cpp @@ -19,7 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include diff --git a/src/network-web/webbrowser.cpp b/src/network-web/webbrowser.cpp old mode 100644 new mode 100755 index 0f4cfbc21..1161aca8a --- a/src/network-web/webbrowser.cpp +++ b/src/network-web/webbrowser.cpp @@ -175,7 +175,7 @@ void WebBrowser::createConnections() { connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl))); // Connect this WebBrowser to global TabWidget. - TabWidget *tab_widget = FormMain::instance()->tabWidget(); + TabWidget *tab_widget = qApp->mainForm()->tabWidget(); connect(m_webView, SIGNAL(newTabRequested()), tab_widget, SLOT(addEmptyBrowser())); connect(m_webView, SIGNAL(linkMiddleClicked(QUrl)), tab_widget, SLOT(addLinkedBrowser(QUrl))); diff --git a/src/network-web/webbrowsernetworkaccessmanager.cpp b/src/network-web/webbrowsernetworkaccessmanager.cpp old mode 100644 new mode 100755 index 567eed16a..5d3d5810f --- a/src/network-web/webbrowsernetworkaccessmanager.cpp +++ b/src/network-web/webbrowsernetworkaccessmanager.cpp @@ -17,7 +17,7 @@ #include "network-web/webbrowsernetworkaccessmanager.h" -#include "application.h" +#include "miscellaneous/application.h" #include diff --git a/src/network-web/webfactory.cpp b/src/network-web/webfactory.cpp old mode 100644 new mode 100755 index df3c9a9f9..d19ccb104 --- a/src/network-web/webfactory.cpp +++ b/src/network-web/webfactory.cpp @@ -2,7 +2,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" -#include "application.h" +#include "miscellaneous/application.h" #include #include