Many things changed and tweaked: added one button to tray icon menu.

This commit is contained in:
Martin Rotter 2014-01-29 13:26:49 +01:00
parent 5338d2d212
commit 16a98a57ba
9 changed files with 101 additions and 19 deletions

View File

@ -219,6 +219,8 @@ void FeedMessageViewer::createConnections() {
SIGNAL(triggered()), this, SLOT(updateAllFeeds())); SIGNAL(triggered()), this, SLOT(updateAllFeeds()));
connect(FormMain::instance()->m_ui->m_actionAddStandardCategory, connect(FormMain::instance()->m_ui->m_actionAddStandardCategory,
SIGNAL(triggered()), m_feedsView, SLOT(addNewStandardCategory())); 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, connect(FormMain::instance()->m_ui->m_actionEditSelectedFeedCategory,
SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem())); SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem()));
connect(FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode, connect(FormMain::instance()->m_ui->m_actionViewSelectedItemsNewspaperMode,

View File

@ -10,6 +10,7 @@
#include "core/feedsmodelstandardcategory.h" #include "core/feedsmodelstandardcategory.h"
#include "gui/formmain.h" #include "gui/formmain.h"
#include "gui/formstandardcategorydetails.h" #include "gui/formstandardcategorydetails.h"
#include "gui/formstandardfeeddetails.h"
#include "gui/systemtrayicon.h" #include "gui/systemtrayicon.h"
#include "gui/messagebox.h" #include "gui/messagebox.h"
@ -79,15 +80,15 @@ void FeedsView::addNewStandardCategory() {
// it is used probably by feed updater or application // it is used probably by feed updater or application
// is quitting. // is quitting.
if (SystemTrayIcon::isSystemTrayActivated()) { if (SystemTrayIcon::isSystemTrayActivated()) {
SystemTrayIcon::instance()->showMessage(tr("Cannot add category"), SystemTrayIcon::instance()->showMessage(tr("Cannot add standard category"),
tr("You cannot add new category now because feed update is ongoing."), tr("You cannot add new standard category now because feed update is ongoing."),
QSystemTrayIcon::Warning); QSystemTrayIcon::Warning);
} }
else { else {
MessageBox::show(this, MessageBox::show(this,
QMessageBox::Warning, QMessageBox::Warning,
tr("Cannot add category"), tr("Cannot add standard category"),
tr("You cannot add new category now because feed update is ongoing.")); tr("You cannot add new standard category now because feed update is ongoing."));
} }
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.
@ -123,6 +124,42 @@ void FeedsView::editStandardCategory(FeedsModelStandardCategory *category) {
delete form_pointer.data(); 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<FormStandardFeedDetails> 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() { void FeedsView::editSelectedItem() {
if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) { if (!SystemFactory::instance()->applicationCloseLock()->tryLockForWrite()) {
// Lock was not obtained because // Lock was not obtained because

View File

@ -76,6 +76,9 @@ class FeedsView : public QTreeView {
void addNewStandardCategory(); void addNewStandardCategory();
void editStandardCategory(FeedsModelStandardCategory *category); void editStandardCategory(FeedsModelStandardCategory *category);
// Standard feed manipulators.
void addNewStandardFeed();
// Reloads counts for selected feeds. // Reloads counts for selected feeds.
void updateCountsOfSelectedFeeds(bool update_total_too = true); void updateCountsOfSelectedFeeds(bool update_total_too = true);

View File

@ -86,8 +86,6 @@ QList<QAction*> FormMain::allActions() {
return actions; return actions;
} }
void FormMain::prepareMenus() { void FormMain::prepareMenus() {
// Setup menu for tray icon. // Setup menu for tray icon.
if (SystemTrayIcon::isSystemTrayAvailable()) { if (SystemTrayIcon::isSystemTrayAvailable()) {
@ -98,6 +96,8 @@ void FormMain::prepareMenus() {
#endif #endif
// Add needed items to the menu. // 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_actionSettings);
m_trayMenu->addAction(m_ui->m_actionQuit); m_trayMenu->addAction(m_ui->m_actionQuit);

View File

@ -67,7 +67,7 @@ void FormStandardCategoryDetails::setEditableCategory(FeedsModelStandardCategory
int FormStandardCategoryDetails::exec(FeedsModelStandardCategory *input_category) { int FormStandardCategoryDetails::exec(FeedsModelStandardCategory *input_category) {
if (input_category == NULL) { if (input_category == NULL) {
// User is adding new category. // 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 // Make sure that "default" icon is used as the default option for new
// categories. // categories.
@ -75,7 +75,7 @@ int FormStandardCategoryDetails::exec(FeedsModelStandardCategory *input_category
} }
else { else {
// User is editing existing category. // User is editing existing category.
setWindowTitle(tr("Edit existing category")); setWindowTitle(tr("Edit existing standard category"));
setEditableCategory(input_category); setEditableCategory(input_category);
} }

View File

@ -17,7 +17,7 @@
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>

View File

@ -1,13 +1,48 @@
#include "gui/formstandardfeeddetails.h" #include "gui/formstandardfeeddetails.h"
#include "core/feedsmodel.h" #include "core/feedsmodel.h"
#include "gui/iconthemefactory.h"
#if !defined(Q_OS_WIN)
#include "gui/messagebox.h"
#endif
#include <QPushButton>
FormStandardFeedDetails::FormStandardFeedDetails(FeedsModel *model, QWidget *parent) FormStandardFeedDetails::FormStandardFeedDetails(FeedsModel *model, QWidget *parent)
: QDialog(parent), m_ui(new Ui::FormStandardFeedDetails) { : QDialog(parent) {
m_ui->setupUi(this); initialize();
} }
FormStandardFeedDetails::~FormStandardFeedDetails() { FormStandardFeedDetails::~FormStandardFeedDetails() {
delete m_ui; 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
}

View File

@ -11,14 +11,22 @@ namespace Ui {
} }
class FeedsModel; class FeedsModel;
class FeedsModelStandardFeed;
class FormStandardFeedDetails : public QDialog { class FormStandardFeedDetails : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
// Constructors and destructors.
explicit FormStandardFeedDetails(FeedsModel *model, QWidget *parent = 0); explicit FormStandardFeedDetails(FeedsModel *model, QWidget *parent = 0);
virtual ~FormStandardFeedDetails(); virtual ~FormStandardFeedDetails();
public slots:
int exec(FeedsModelStandardFeed *input_feed);
protected:
void initialize();
private: private:
Ui::FormStandardFeedDetails *m_ui; Ui::FormStandardFeedDetails *m_ui;
}; };

View File

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>FormStandardFeedDetails</class> <class>FormStandardFeedDetails</class>
<widget name="FormStandardFeedDetails" class="QDialog"> <widget class="QDialog" name="FormStandardFeedDetails">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -15,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<widget name="buttonBox" class="QDialogButtonBox"> <widget class="QDialogButtonBox" name="m_buttonBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>30</x> <x>30</x>
@ -32,11 +30,10 @@
</property> </property>
</widget> </widget>
</widget> </widget>
<pixmapfunction/>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>m_buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>FormStandardFeedDetails</receiver> <receiver>FormStandardFeedDetails</receiver>
<slot>accept()</slot> <slot>accept()</slot>
@ -52,7 +49,7 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>buttonBox</sender> <sender>m_buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>FormStandardFeedDetails</receiver> <receiver>FormStandardFeedDetails</receiver>
<slot>reject()</slot> <slot>reject()</slot>