Refactoring.

This commit is contained in:
Martin Rotter 2016-08-13 14:02:06 +02:00
parent 79d476a49c
commit 8f94186963
26 changed files with 50 additions and 70 deletions

View File

@ -129,7 +129,7 @@ void FeedsModel::updateFeeds(const QList<Feed*> &feeds) {
if (!qApp->feedUpdateLock()->tryLock()) {
qApp->showGuiMessage(tr("Cannot update all items"),
tr("You cannot update all items because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
return;
}

View File

@ -22,7 +22,6 @@
#include "miscellaneous/textfactory.h"
#include "miscellaneous/databasefactory.h"
#include "miscellaneous/iconfactory.h"
#include "gui/dialogs/formmain.h"
#include "services/abstract/serviceroot.h"
#include "miscellaneous/databasequeries.h"
@ -80,7 +79,7 @@ void MessagesModel::loadMessages(RootItem *item) {
qApp->showGuiMessage(tr("Loading of messages from item '%1' failed.").arg(item->title()),
tr("Loading of messages failed, maybe messages could not be downloaded."),
QSystemTrayIcon::Critical,
qApp->mainForm(),
qApp->mainFormWidget(),
true);
}
}

View File

@ -70,7 +70,7 @@ void DiscoverFeedsButton::linkTriggered(QAction *action) {
qApp->showGuiMessage(tr("Not supported"),
tr("Given account does not support adding feeds."),
QSystemTrayIcon::Warning,
qApp->mainForm(), true);
qApp->mainFormWidget(), true);
}
}

View File

@ -425,7 +425,7 @@ void FeedMessageViewer::showDbCleanupAssistant() {
else {
qApp->showGuiMessage(tr("Cannot cleanup database"),
tr("Cannot cleanup database, because another critical action is running."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
}
}

View File

@ -165,7 +165,7 @@ void FeedsView::addFeedIntoSelectedAccount() {
qApp->showGuiMessage(tr("Not supported"),
tr("Selected account does not support adding of new feeds."),
QSystemTrayIcon::Warning,
qApp->mainForm(), true);
qApp->mainFormWidget(), true);
}
}
}
@ -183,7 +183,7 @@ void FeedsView::addCategoryIntoSelectedAccount() {
qApp->showGuiMessage(tr("Not supported"),
tr("Selected account does not support adding of new categories."),
QSystemTrayIcon::Warning,
qApp->mainForm(), true);
qApp->mainFormWidget(), true);
}
}
}
@ -224,7 +224,7 @@ void FeedsView::editSelectedItem() {
// is quitting.
qApp->showGuiMessage(tr("Cannot edit item"),
tr("Selected item cannot be edited because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method.
return;
}
@ -236,7 +236,7 @@ void FeedsView::editSelectedItem() {
qApp->showGuiMessage(tr("Cannot edit item"),
tr("Selected item cannot be edited, this is not (yet?) supported."),
QSystemTrayIcon::Warning,
qApp->mainForm(),
qApp->mainFormWidget(),
true);
}
@ -251,7 +251,7 @@ void FeedsView::deleteSelectedItem() {
// is quitting.
qApp->showGuiMessage(tr("Cannot delete item"),
tr("Selected item cannot be deleted because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method.
return;
@ -268,7 +268,7 @@ void FeedsView::deleteSelectedItem() {
if (selected_item != nullptr) {
if (selected_item->canBeDeleted()) {
// Ask user first.
if (MessageBox::show(qApp->mainForm(),
if (MessageBox::show(qApp->mainFormWidget(),
QMessageBox::Question,
tr("Deleting \"%1\"").arg(selected_item->title()),
tr("You are about to completely delete item \"%1\".").arg(selected_item->title()),
@ -284,7 +284,7 @@ void FeedsView::deleteSelectedItem() {
qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()),
tr("This item cannot be deleted because something critically failed. Submit bug report."),
QSystemTrayIcon::Critical,
qApp->mainForm(),
qApp->mainFormWidget(),
true);
}
}
@ -292,7 +292,7 @@ void FeedsView::deleteSelectedItem() {
qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()),
tr("This item cannot be deleted, because it does not support it\nor this functionality is not implemented yet."),
QSystemTrayIcon::Critical,
qApp->mainForm(),
qApp->mainFormWidget(),
true);
}
}

View File

@ -20,7 +20,6 @@
#include "definitions/definitions.h"
#include "gui/baselineedit.h"
#include "gui/messagessearchlineedit.h"
#include "gui/dialogs/formmain.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/settings.h"
@ -39,7 +38,7 @@ MessagesToolBar::~MessagesToolBar() {
}
QList<QAction*> MessagesToolBar::availableActions() const {
QList<QAction*> available_actions = qApp->mainForm()->allActions();
QList<QAction*> available_actions = qApp->userActions();
available_actions.append(m_actionSearchMessages);
available_actions.append(m_actionMessageHighlighter);

View File

@ -17,7 +17,6 @@
#include "gui/settings/settingsshortcuts.h"
#include "gui/dialogs/formmain.h"
#include "miscellaneous/application.h"
#include "dynamic-shortcuts/dynamicshortcuts.h"
@ -36,7 +35,7 @@ SettingsShortcuts::~SettingsShortcuts() {
void SettingsShortcuts::loadSettings() {
onBeginLoadSettings();
m_ui->m_shortcuts->populate(qApp->mainForm()->allActions());
m_ui->m_shortcuts->populate(qApp->userActions());
onEndLoadSettings();
}
@ -45,7 +44,7 @@ void SettingsShortcuts::saveSettings() {
onBeginSaveSettings();
m_ui->m_shortcuts->updateShortcuts();
DynamicShortcuts::save(qApp->mainForm()->allActions());
DynamicShortcuts::save(qApp->userActions());
onEndSaveSettings();
}

View File

@ -39,7 +39,7 @@ bool TrayIconMenu::event(QEvent *event) {
QTimer::singleShot(0, this, SLOT(hide()));
qApp->showGuiMessage(QSL(APP_LONG_NAME),
tr("Close opened modal dialogs first."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
}
return QMenu::event(event);

View File

@ -25,7 +25,6 @@
#include "gui/webviewer.h"
#include "gui/discoverfeedsbutton.h"
#include "gui/locationlineedit.h"
#include "gui/dialogs/formmain.h"
#include "services/abstract/serviceroot.h"
#include <QScrollBar>
@ -41,11 +40,6 @@ void WebBrowser::createConnections() {
connect(m_txtLocation,SIGNAL(submitted(QString)), this, SLOT(loadUrl(QString)));
connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl)));
// Connect this WebBrowser to global 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)));
// Change location textbox status according to webpage status.
connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadingStarted()));
connect(m_webView, SIGNAL(loadProgress(int)), this, SLOT(onLoadingProgress(int)));

View File

@ -127,6 +127,10 @@ Mutex *Application::feedUpdateLock() {
return m_updateFeedsLock.data();
}
QWidget *Application::mainFormWidget() {
return m_mainForm;
}
void Application::backupDatabaseSettings(bool backup_database, bool backup_settings,
const QString &target_path, const QString &backup_name) {
if (!QFileInfo(target_path).isWritable()) {

View File

@ -118,6 +118,8 @@ class Application : public QtSingleApplication {
return m_mainForm;
}
QWidget *mainFormWidget();
void setMainForm(FormMain *main_form) {
m_mainForm = main_form;
}

View File

@ -18,7 +18,6 @@
#include "miscellaneous/systemfactory.h"
#include "network-web/networkfactory.h"
#include "gui/dialogs/formmain.h"
#include "miscellaneous/application.h"
#include "miscellaneous/systemfactory.h"
@ -33,6 +32,8 @@
#include <QDomElement>
#include <QDomAttr>
#include <QFuture>
#include <QFileInfo>
#include <QDir>
#include <QFutureWatcher>
#include <QtConcurrent/QtConcurrentRun>
#include <QDesktopServices>
@ -307,6 +308,6 @@ void SystemFactory::checkForUpdatesOnStartup() {
qApp->showGuiMessage(tr("New version available"),
tr("Click the bubble for more information."),
QSystemTrayIcon::Information,
nullptr, true, qApp->mainForm(), SLOT(showUpdates()));
nullptr, true, qApp->mainFormWidget(), SLOT(showUpdates()));
}
}

View File

@ -207,7 +207,7 @@ void DownloadItem::stop() {
void DownloadItem::openFile() {
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()))) {
qApp->showGuiMessage(tr("Cannot open file"), tr("Cannot open output file. Open it manually."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
}
}

View File

@ -21,7 +21,6 @@
#include "services/owncloud/owncloudserviceroot.h"
#include "services/owncloud/network/owncloudnetworkfactory.h"
#include "miscellaneous/application.h"
#include "gui/dialogs/formmain.h"
#include <QTimer>
@ -81,7 +80,7 @@ void FormOwnCloudFeedDetails::apply() {
reject();
qApp->showGuiMessage(tr("Cannot add feed"),
tr("Feed was not added due to error."),
QSystemTrayIcon::Critical, qApp->mainForm(), true);
QSystemTrayIcon::Critical, qApp->mainFormWidget(), true);
}
}

View File

@ -22,7 +22,6 @@
#include "services/owncloud/owncloudserviceroot.h"
#include "services/owncloud/network/owncloudnetworkfactory.h"
#include "services/owncloud/gui/formowncloudfeeddetails.h"
#include "gui/dialogs/formmain.h"
#include <QPointer>
@ -47,7 +46,7 @@ bool OwnCloudFeed::canBeEdited() const {
}
bool OwnCloudFeed::editViaGui() {
QPointer<FormOwnCloudFeedDetails> form_pointer = new FormOwnCloudFeedDetails(serviceRoot(), qApp->mainForm());
QPointer<FormOwnCloudFeedDetails> form_pointer = new FormOwnCloudFeedDetails(serviceRoot(), qApp->mainFormWidget());
form_pointer.data()->exec(this, nullptr);
delete form_pointer.data();

View File

@ -24,7 +24,6 @@
#include "services/owncloud/definitions.h"
#include "services/owncloud/owncloudserviceroot.h"
#include "services/owncloud/gui/formeditowncloudaccount.h"
#include "gui/dialogs/formmain.h"
OwnCloudServiceEntryPoint::OwnCloudServiceEntryPoint() {
@ -34,7 +33,7 @@ OwnCloudServiceEntryPoint::~OwnCloudServiceEntryPoint() {
}
ServiceRoot *OwnCloudServiceEntryPoint::createNewRoot() const {
QScopedPointer<FormEditOwnCloudAccount> form_acc(new FormEditOwnCloudAccount(qApp->mainForm()));
QScopedPointer<FormEditOwnCloudAccount> form_acc(new FormEditOwnCloudAccount(qApp->mainFormWidget()));
return form_acc->execForCreate();
}

View File

@ -23,7 +23,6 @@
#include "miscellaneous/textfactory.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/mutex.h"
#include "gui/dialogs/formmain.h"
#include "services/owncloud/owncloudserviceentrypoint.h"
#include "services/owncloud/owncloudrecyclebin.h"
#include "services/owncloud/owncloudfeed.h"
@ -52,7 +51,7 @@ bool OwnCloudServiceRoot::canBeDeleted() const {
}
bool OwnCloudServiceRoot::editViaGui() {
QScopedPointer<FormEditOwnCloudAccount> form_pointer(new FormEditOwnCloudAccount(qApp->mainForm()));
QScopedPointer<FormEditOwnCloudAccount> form_pointer(new FormEditOwnCloudAccount(qApp->mainFormWidget()));
form_pointer.data()->execForEdit(this);
return true;
@ -203,12 +202,12 @@ void OwnCloudServiceRoot::addNewFeed(const QString &url) {
// is quitting.
qApp->showGuiMessage(tr("Cannot add item"),
tr("Cannot add feed because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method.
return;
}
QScopedPointer<FormOwnCloudFeedDetails> form_pointer(new FormOwnCloudFeedDetails(this, qApp->mainForm()));
QScopedPointer<FormOwnCloudFeedDetails> form_pointer(new FormOwnCloudFeedDetails(this, qApp->mainFormWidget()));
form_pointer.data()->exec(nullptr, this, url);
qApp->feedUpdateLock()->unlock();

View File

@ -25,7 +25,6 @@
#include "gui/baselineedit.h"
#include "gui/messagebox.h"
#include "gui/systemtrayicon.h"
#include "gui/dialogs/formmain.h"
#include "services/abstract/category.h"
#include "services/standard/standardcategory.h"
#include "services/standard/standardserviceroot.h"
@ -131,7 +130,7 @@ void FormStandardCategoryDetails::apply() {
qApp->showGuiMessage(tr("Cannot add category"),
tr("Category was not added due to error."),
QSystemTrayIcon::Critical,
qApp->mainForm(), true);
qApp->mainFormWidget(), true);
}
}
else {

View File

@ -23,7 +23,6 @@
#include "miscellaneous/settings.h"
#include "miscellaneous/iconfactory.h"
#include "core/feedsmodel.h"
#include "gui/dialogs/formmain.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedsview.h"
#include "services/standard/gui/formstandardcategorydetails.h"
@ -98,7 +97,7 @@ bool StandardCategory::performDragDropChange(RootItem *target_item) {
}
bool StandardCategory::editViaGui() {
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(serviceRoot(), qApp->mainForm()));
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(serviceRoot(), qApp->mainFormWidget()));
form_pointer.data()->exec(this, nullptr);
return false;

View File

@ -26,7 +26,6 @@
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/simplecrypt/simplecrypt.h"
#include "network-web/networkfactory.h"
#include "gui/dialogs/formmain.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedsview.h"
#include "services/abstract/recyclebin.h"
@ -93,7 +92,7 @@ StandardServiceRoot *StandardFeed::serviceRoot() const {
}
bool StandardFeed::editViaGui() {
QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(serviceRoot(), qApp->mainForm()));
QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(serviceRoot(), qApp->mainFormWidget()));
form_pointer.data()->exec(this, nullptr);
return false;
}

View File

@ -25,7 +25,6 @@
#include "miscellaneous/mutex.h"
#include "core/feedsmodel.h"
#include "gui/messagebox.h"
#include "gui/dialogs/formmain.h"
#include "exceptions/applicationexception.h"
#include "services/abstract/recyclebin.h"
#include "services/standard/standardserviceentrypoint.h"
@ -62,7 +61,7 @@ void StandardServiceRoot::start(bool freshly_activated) {
if (freshly_activated) {
// In other words, if there are no feeds or categories added.
if (MessageBox::show(qApp->mainForm(), QMessageBox::Question, QObject::tr("Load initial set of feeds"),
if (MessageBox::show(qApp->mainFormWidget(), QMessageBox::Question, QObject::tr("Load initial set of feeds"),
tr("This new account does not include any feeds. You can now add default set of feeds."),
tr("Do you want to load initial set of feeds?"),
QString(), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
@ -89,7 +88,7 @@ void StandardServiceRoot::start(bool freshly_activated) {
}
}
catch (ApplicationException &ex) {
MessageBox::show(qApp->mainForm(), QMessageBox::Critical, tr("Error when loading initial feeds"), ex.message());
MessageBox::show(qApp->mainFormWidget(), QMessageBox::Critical, tr("Error when loading initial feeds"), ex.message());
}
}
}
@ -117,10 +116,6 @@ bool StandardServiceRoot::deleteViaGui() {
return ServiceRoot::deleteViaGui();
}
bool StandardServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
return ServiceRoot::markAsReadUnread(status);
}
bool StandardServiceRoot::supportsFeedAdding() const {
return true;
}
@ -136,12 +131,12 @@ void StandardServiceRoot::addNewFeed(const QString &url) {
// is quitting.
qApp->showGuiMessage(tr("Cannot add item"),
tr("Cannot add feed because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method.
return;
}
QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(this, qApp->mainForm()));
QScopedPointer<FormStandardFeedDetails> form_pointer(new FormStandardFeedDetails(this, qApp->mainFormWidget()));
form_pointer.data()->exec(nullptr, nullptr, url);
qApp->feedUpdateLock()->unlock();
@ -322,25 +317,25 @@ void StandardServiceRoot::addNewCategory() {
// is quitting.
qApp->showGuiMessage(tr("Cannot add category"),
tr("Cannot add category because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method.
return;
}
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(this, qApp->mainForm()));
QScopedPointer<FormStandardCategoryDetails> form_pointer(new FormStandardCategoryDetails(this, qApp->mainFormWidget()));
form_pointer.data()->exec(nullptr, nullptr);
qApp->feedUpdateLock()->unlock();
}
void StandardServiceRoot::importFeeds() {
QScopedPointer<FormStandardImportExport> form(new FormStandardImportExport(this, qApp->mainForm()));
QScopedPointer<FormStandardImportExport> form(new FormStandardImportExport(this, qApp->mainFormWidget()));
form.data()->setMode(FeedsImportExportModel::Import);
form.data()->exec();
}
void StandardServiceRoot::exportFeeds() {
QScopedPointer<FormStandardImportExport> form(new FormStandardImportExport(this, qApp->mainForm()));
QScopedPointer<FormStandardImportExport> form(new FormStandardImportExport(this, qApp->mainFormWidget()));
form.data()->setMode(FeedsImportExportModel::Export);
form.data()->exec();
}

View File

@ -46,9 +46,6 @@ class StandardServiceRoot : public ServiceRoot {
bool canBeEdited() const;
bool canBeDeleted() const;
bool deleteViaGui();
bool markAsReadUnread(ReadStatus status);
bool supportsFeedAdding() const;
bool supportsCategoryAdding() const;

View File

@ -23,7 +23,6 @@
#include "services/tt-rss/ttrssfeed.h"
#include "services/tt-rss/network/ttrssnetworkfactory.h"
#include "miscellaneous/application.h"
#include "gui/dialogs/formmain.h"
#include <QTimer>
@ -76,7 +75,7 @@ void FormTtRssFeedDetails::apply() {
reject();
qApp->showGuiMessage(tr("Cannot add feed"),
tr("Feed was not added due to error."),
QSystemTrayIcon::Critical, qApp->mainForm(), true);
QSystemTrayIcon::Critical, qApp->mainFormWidget(), true);
}
}

View File

@ -22,7 +22,6 @@
#include "miscellaneous/databasequeries.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/textfactory.h"
#include "gui/dialogs/formmain.h"
#include "services/tt-rss/definitions.h"
#include "services/tt-rss/ttrssserviceroot.h"
#include "services/tt-rss/ttrsscategory.h"
@ -100,7 +99,7 @@ bool TtRssFeed::canBeEdited() const {
}
bool TtRssFeed::editViaGui() {
QPointer<FormTtRssFeedDetails> form_pointer = new FormTtRssFeedDetails(serviceRoot(), qApp->mainForm());
QPointer<FormTtRssFeedDetails> form_pointer = new FormTtRssFeedDetails(serviceRoot(), qApp->mainFormWidget());
form_pointer.data()->exec(this, nullptr);
delete form_pointer.data();

View File

@ -20,7 +20,6 @@
#include "definitions/definitions.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/databasequeries.h"
#include "gui/dialogs/formmain.h"
#include "services/tt-rss/definitions.h"
#include "services/tt-rss/ttrssserviceroot.h"
#include "services/tt-rss/gui/formeditaccount.h"
@ -67,7 +66,7 @@ QString TtRssServiceEntryPoint::code() const {
}
ServiceRoot *TtRssServiceEntryPoint::createNewRoot() const {
QScopedPointer<FormEditAccount> form_acc(new FormEditAccount(qApp->mainForm()));
QScopedPointer<FormEditAccount> form_acc(new FormEditAccount(qApp->mainFormWidget()));
return form_acc->execForCreate();
}

View File

@ -22,8 +22,8 @@
#include "miscellaneous/mutex.h"
#include "miscellaneous/textfactory.h"
#include "miscellaneous/databasequeries.h"
#include "gui/dialogs/formmain.h"
#include "network-web/networkfactory.h"
#include "miscellaneous/iconfactory.h"
#include "services/tt-rss/ttrssserviceentrypoint.h"
#include "services/tt-rss/ttrssfeed.h"
#include "services/tt-rss/ttrssrecyclebin.h"
@ -68,7 +68,7 @@ QString TtRssServiceRoot::code() const {
}
bool TtRssServiceRoot::editViaGui() {
QScopedPointer<FormEditAccount> form_pointer(new FormEditAccount(qApp->mainForm()));
QScopedPointer<FormEditAccount> form_pointer(new FormEditAccount(qApp->mainFormWidget()));
form_pointer.data()->execForEdit(this);
return true;
@ -117,12 +117,12 @@ void TtRssServiceRoot::addNewFeed(const QString &url) {
// is quitting.
qApp->showGuiMessage(tr("Cannot add item"),
tr("Cannot add feed because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm(), true);
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
// Thus, cannot delete and quit the method.
return;
}
QScopedPointer<FormTtRssFeedDetails> form_pointer(new FormTtRssFeedDetails(this, qApp->mainForm()));
QScopedPointer<FormTtRssFeedDetails> form_pointer(new FormTtRssFeedDetails(this, qApp->mainFormWidget()));
form_pointer.data()->exec(nullptr, this, url);
qApp->feedUpdateLock()->unlock();