From 16a98a57ba8ada826527ffa1500bf092045757a0 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 29 Jan 2014 13:26:49 +0100 Subject: [PATCH] Many things changed and tweaked: added one button to tray icon menu. --- src/gui/feedmessageviewer.cpp | 2 ++ src/gui/feedsview.cpp | 45 ++++++++++++++++++++++--- src/gui/feedsview.h | 3 ++ src/gui/formmain.cpp | 4 +-- src/gui/formstandardcategorydetails.cpp | 4 +-- src/gui/formstandardcategorydetails.ui | 2 +- src/gui/formstandardfeeddetails.cpp | 39 +++++++++++++++++++-- src/gui/formstandardfeeddetails.h | 8 +++++ src/gui/formstandardfeeddetails.ui | 13 +++---- 9 files changed, 101 insertions(+), 19 deletions(-) diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index f920dff19..3537be674 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -219,6 +219,8 @@ void FeedMessageViewer::createConnections() { SIGNAL(triggered()), this, SLOT(updateAllFeeds())); connect(FormMain::instance()->m_ui->m_actionAddStandardCategory, SIGNAL(triggered()), m_feedsView, SLOT(addNewStandardCategory())); + connect(FormMain::instance()->m_ui->m_actionAddStandardFeed, + SIGNAL(triggered()), m_feedsView, SLOT(addNewStandardFeed())); connect(FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory, SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem())); connect(FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode, diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 0462ab5d9..61b85dfa3 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -10,6 +10,7 @@ #include "core/feedsmodelstandardcategory.h" #include "gui/formmain.h" #include "gui/formstandardcategorydetails.h" +#include "gui/formstandardfeeddetails.h" #include "gui/systemtrayicon.h" #include "gui/messagebox.h" @@ -79,15 +80,15 @@ void FeedsView::addNewStandardCategory() { // it is used probably by feed updater or application // is quitting. if (SystemTrayIcon::isSystemTrayActivated()) { - SystemTrayIcon::instance()->showMessage(tr("Cannot add category"), - tr("You cannot add new category now because feed update is ongoing."), + SystemTrayIcon::instance()->showMessage(tr("Cannot add standard category"), + tr("You cannot add new standard category now because feed update is ongoing."), QSystemTrayIcon::Warning); } else { MessageBox::show(this, QMessageBox::Warning, - tr("Cannot add category"), - tr("You cannot add new category now because feed update is ongoing.")); + tr("Cannot add standard category"), + tr("You cannot add new standard category now because feed update is ongoing.")); } // Thus, cannot delete and quit the method. @@ -123,6 +124,42 @@ void FeedsView::editStandardCategory(FeedsModelStandardCategory *category) { delete form_pointer.data(); } +void FeedsView::addNewStandardFeed() { + if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { + // Lock was not obtained because + // it is used probably by feed updater or application + // is quitting. + if (SystemTrayIcon::isSystemTrayActivated()) { + SystemTrayIcon::instance()->showMessage(tr("Cannot add standard feed"), + tr("You cannot add new standard feed now because feed update is ongoing."), + QSystemTrayIcon::Warning); + } + else { + MessageBox::show(this, + QMessageBox::Warning, + tr("Cannot add standard feed"), + tr("You cannot add new standard feed now because feed update is ongoing.")); + } + + // Thus, cannot delete and quit the method. + return; + } + + QPointer form_pointer = new FormStandardFeedDetails(m_sourceModel, this); + + if (form_pointer.data()->exec(NULL) == QDialog::Accepted) { + // TODO: nova kategorie pridana + } + else { + // TODO: nova kategorie nepridana + } + + delete form_pointer.data(); + + // Changes are done, unlock the update master lock. + SystemFactory::instance()->applicationCloseLock()->unlock(); +} + void FeedsView::editSelectedItem() { if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { // Lock was not obtained because diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index a9cdde993..63dfed5c6 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -76,6 +76,9 @@ class FeedsView : public QTreeView { void addNewStandardCategory(); void editStandardCategory(FeedsModelStandardCategory *category); + // Standard feed manipulators. + void addNewStandardFeed(); + // Reloads counts for selected feeds. void updateCountsOfSelectedFeeds(bool update_total_too = true); diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index d7fc6d050..50ee735a1 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -86,8 +86,6 @@ QList FormMain::allActions() { return actions; } - - void FormMain::prepareMenus() { // Setup menu for tray icon. if (SystemTrayIcon::isSystemTrayAvailable()) { @@ -98,6 +96,8 @@ void FormMain::prepareMenus() { #endif // Add needed items to the menu. + m_trayMenu->addAction(m_ui->m_actionUpdateAllFeeds); + m_trayMenu->addSeparator(); m_trayMenu->addAction(m_ui->m_actionSettings); m_trayMenu->addAction(m_ui->m_actionQuit); diff --git a/src/gui/formstandardcategorydetails.cpp b/src/gui/formstandardcategorydetails.cpp index 92a7295ff..d8ad0a23f 100644 --- a/src/gui/formstandardcategorydetails.cpp +++ b/src/gui/formstandardcategorydetails.cpp @@ -67,7 +67,7 @@ void FormStandardCategoryDetails::setEditableCategory(FeedsModelStandardCategory int FormStandardCategoryDetails::exec(FeedsModelStandardCategory *input_category) { if (input_category == NULL) { // User is adding new category. - setWindowTitle(tr("Add new category")); + setWindowTitle(tr("Add new standard category")); // Make sure that "default" icon is used as the default option for new // categories. @@ -75,7 +75,7 @@ int FormStandardCategoryDetails::exec(FeedsModelStandardCategory *input_category } else { // User is editing existing category. - setWindowTitle(tr("Edit existing category")); + setWindowTitle(tr("Edit existing standard category")); setEditableCategory(input_category); } diff --git a/src/gui/formstandardcategorydetails.ui b/src/gui/formstandardcategorydetails.ui index 97205c707..b4e9871a9 100644 --- a/src/gui/formstandardcategorydetails.ui +++ b/src/gui/formstandardcategorydetails.ui @@ -17,7 +17,7 @@ - Dialog + diff --git a/src/gui/formstandardfeeddetails.cpp b/src/gui/formstandardfeeddetails.cpp index 3be052508..bf1200e9a 100644 --- a/src/gui/formstandardfeeddetails.cpp +++ b/src/gui/formstandardfeeddetails.cpp @@ -1,13 +1,48 @@ #include "gui/formstandardfeeddetails.h" #include "core/feedsmodel.h" +#include "gui/iconthemefactory.h" +#if !defined(Q_OS_WIN) +#include "gui/messagebox.h" +#endif + +#include FormStandardFeedDetails::FormStandardFeedDetails(FeedsModel *model, QWidget *parent) - : QDialog(parent), m_ui(new Ui::FormStandardFeedDetails) { - m_ui->setupUi(this); + : QDialog(parent) { + initialize(); } FormStandardFeedDetails::~FormStandardFeedDetails() { delete m_ui; } + +int FormStandardFeedDetails::exec(FeedsModelStandardFeed *input_feed) { + if (input_feed == NULL) { + // User is adding new category. + setWindowTitle(tr("Add new standard feed")); + } + else { + // User is editing existing category. + setWindowTitle(tr("Edit existing standard feed")); + } + + return 0; +} + +void FormStandardFeedDetails::initialize() { + m_ui = new Ui::FormStandardFeedDetails(); + m_ui->setupUi(this); + + // Set flags and attributes. + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); + setWindowIcon(IconThemeFactory::instance()->fromTheme("document-new")); + + // Setup button box. + m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + +#if !defined(Q_OS_WIN) + MessageBox::iconify(m_ui->m_buttonBox); +#endif +} diff --git a/src/gui/formstandardfeeddetails.h b/src/gui/formstandardfeeddetails.h index d591c906f..5dbaf64b7 100644 --- a/src/gui/formstandardfeeddetails.h +++ b/src/gui/formstandardfeeddetails.h @@ -11,14 +11,22 @@ namespace Ui { } class FeedsModel; +class FeedsModelStandardFeed; class FormStandardFeedDetails : public QDialog { Q_OBJECT public: + // Constructors and destructors. explicit FormStandardFeedDetails(FeedsModel *model, QWidget *parent = 0); virtual ~FormStandardFeedDetails(); + public slots: + int exec(FeedsModelStandardFeed *input_feed); + + protected: + void initialize(); + private: Ui::FormStandardFeedDetails *m_ui; }; diff --git a/src/gui/formstandardfeeddetails.ui b/src/gui/formstandardfeeddetails.ui index e6a01ff9b..20e7a547e 100644 --- a/src/gui/formstandardfeeddetails.ui +++ b/src/gui/formstandardfeeddetails.ui @@ -1,9 +1,7 @@ + - - - FormStandardFeedDetails - + 0 @@ -15,7 +13,7 @@ Dialog - + 30 @@ -32,11 +30,10 @@ - - buttonBox + m_buttonBox accepted() FormStandardFeedDetails accept() @@ -52,7 +49,7 @@ - buttonBox + m_buttonBox rejected() FormStandardFeedDetails reject()