Initially fixed #28.

This commit is contained in:
Martin Rotter 2015-06-13 16:17:34 +02:00
parent 37f4ad4cfe
commit 8ba6583a8c
7 changed files with 49 additions and 47 deletions

View file

@ -2,6 +2,7 @@
<center><h2>2.4.1</h2></center>
Added:
<ul>
<li>Unavailable actions in menus are automatically disabled when such a situation arises. (issue #28)</li>
<li><b>Added support for Google auto-suggest API.</b> Just type your phrase in internal web browser location text box and Google will help you out.</li>
</ul>

View file

@ -263,7 +263,7 @@ void FeedMessageViewer::switchFeedComponentVisibility() {
void FeedMessageViewer::updateMessageButtonsAvailability() {
bool one_message_selected = m_messagesView->selectionModel()->selectedRows().size() == 1;
bool atleast_one_message_selected = m_messagesView->selectionModel()->selectedRows().size() >= 1;
bool atleast_one_message_selected = !m_messagesView->selectionModel()->selectedRows().isEmpty();
bool recycle_bin_selected = m_messagesView->sourceModel()->loadedSelection().mode() == FeedsSelection::MessagesFromRecycleBin;
FormMain *form_main = qApp->mainForm();
@ -281,6 +281,27 @@ void FeedMessageViewer::updateMessageButtonsAvailability() {
// TODO: To samo udělat s feedy, řešit pouze buttony, které se týkají výběru, ale také vzít v potaz, zda zrovna běží update.
}
void FeedMessageViewer::updateFeedButtonsAvailability() {
bool critical_action_running = qApp->feedUpdateLock()->isLocked();
bool feed_selected = !m_feedsView->selectionModel()->selectedRows().isEmpty();
FormMain *form_main = qApp->mainForm();
form_main->m_ui->m_actionAddCategory->setEnabled(!critical_action_running);
form_main->m_ui->m_actionAddFeed->setEnabled(!critical_action_running);
form_main->m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
form_main->m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
form_main->m_ui->m_actionClearSelectedFeeds->setEnabled(feed_selected);
form_main->m_ui->m_actionDeleteSelectedFeedCategory->setEnabled(!critical_action_running && feed_selected);
form_main->m_ui->m_actionEditSelectedFeedCategory->setEnabled(!critical_action_running && feed_selected);
form_main->m_ui->m_actionImportFeeds->setEnabled(!critical_action_running);
form_main->m_ui->m_actionMarkSelectedFeedsAsRead->setEnabled(feed_selected);
form_main->m_ui->m_actionMarkSelectedFeedsAsUnread->setEnabled(feed_selected);
form_main->m_ui->m_actionUpdateAllFeeds->setEnabled(!critical_action_running);
form_main->m_ui->m_actionUpdateSelectedFeeds->setEnabled(!critical_action_running && feed_selected);
form_main->m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(feed_selected);
form_main->m_ui->m_menuAddItem->setEnabled(!critical_action_running);
}
void FeedMessageViewer::createConnections() {
FormMain *form_main = qApp->mainForm();
@ -294,6 +315,10 @@ void FeedMessageViewer::createConnections() {
connect(m_messagesView, SIGNAL(currentMessagesRemoved()), this, SLOT(updateMessageButtonsAvailability()));
connect(m_messagesView, SIGNAL(currentMessagesChanged(QList<Message>)), this, SLOT(updateMessageButtonsAvailability()));
connect(m_feedsView, SIGNAL(feedsSelected(FeedsSelection)), this, SLOT(updateFeedButtonsAvailability()));
connect(qApp->feedUpdateLock(), SIGNAL(locked()), this, SLOT(updateFeedButtonsAvailability()));
connect(qApp->feedUpdateLock(), SIGNAL(unlocked()), this, SLOT(updateFeedButtonsAvailability()));
// If user selects feeds, load their messages.
connect(m_feedsView, SIGNAL(feedsSelected(FeedsSelection)), m_messagesView, SLOT(loadFeeds(FeedsSelection)));
@ -351,7 +376,7 @@ void FeedMessageViewer::createConnections() {
SIGNAL(triggered()), m_feedsView, SLOT(clearSelectedFeeds()));
connect(form_main->m_ui->m_actionClearAllFeeds,
SIGNAL(triggered()), m_feedsView, SLOT(clearAllFeeds()));
connect(form_main->m_ui->m_actionUpdateSelectedFeedsCategories,
connect(form_main->m_ui->m_actionUpdateSelectedFeeds,
SIGNAL(triggered()), m_feedsView, SLOT(updateSelectedFeeds()));
connect(form_main->m_ui->m_actionUpdateAllFeeds,
SIGNAL(triggered()), m_feedsView, SLOT(updateAllFeeds()));
@ -461,6 +486,7 @@ void FeedMessageViewer::initializeViews() {
setTabOrder(m_toolBarMessages, m_messagesBrowser);
updateMessageButtonsAvailability();
updateFeedButtonsAvailability();
}
void FeedMessageViewer::showDbCleanupAssistant() {
@ -491,6 +517,13 @@ void FeedMessageViewer::refreshVisualProperties() {
}
void FeedMessageViewer::updateFeeds(QList<FeedsModelFeed *> feeds) {
if (!qApp->feedUpdateLock()->tryLock()) {
qApp->showGuiMessage(tr("Cannot update all items"),
tr("You cannot update all items because another another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm());
return;
}
if (m_feedDownloader == NULL) {
m_feedDownloader = new FeedDownloader();
m_feedDownloaderThread = new QThread();

View file

@ -117,6 +117,7 @@ class FeedMessageViewer : public TabContent {
void switchFeedComponentVisibility();
void updateMessageButtonsAvailability();
void updateFeedButtonsAvailability();
protected:
// Initializes some properties of the widget.

View file

@ -167,14 +167,11 @@ void FeedsView::loadExpandedStates() {
}
void FeedsView::updateAllFeeds() {
if (qApp->feedUpdateLock()->tryLock()) {
emit feedsUpdateRequested(allFeeds());
}
else {
qApp->showGuiMessage(tr("Cannot update all items"),
tr("You cannot update all items because another another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm());
}
emit feedsUpdateRequested(allFeeds());
}
void FeedsView::updateSelectedFeeds() {
emit feedsUpdateRequested(selectedFeeds());
}
void FeedsView::updateAllFeedsOnStartup() {
@ -184,17 +181,6 @@ void FeedsView::updateAllFeedsOnStartup() {
}
}
void FeedsView::updateSelectedFeeds() {
if (qApp->feedUpdateLock()->tryLock()) {
emit feedsUpdateRequested(selectedFeeds());
}
else {
qApp->showGuiMessage(tr("Cannot update selected items"),
tr("You cannot update selected items because another critical operation is ongoing."),
QSystemTrayIcon::Warning, qApp->mainForm());
}
}
void FeedsView::executeNextAutoUpdate() {
if (!qApp->feedUpdateLock()->tryLock()) {
qDebug("Delaying scheduled feed auto-updates for one minute due to another running update.");
@ -561,7 +547,7 @@ void FeedsView::selectPreviousItem() {
void FeedsView::initializeContextMenuCategoriesFeeds() {
m_contextMenuCategoriesFeeds = new QMenu(tr("Context menu for feeds"), this);
m_contextMenuCategoriesFeeds->addActions(QList<QAction*>() <<
qApp->mainForm()->m_ui->m_actionUpdateSelectedFeedsCategories <<
qApp->mainForm()->m_ui->m_actionUpdateSelectedFeeds <<
qApp->mainForm()->m_ui->m_actionEditSelectedFeedCategory <<
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode <<
qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsRead <<

View file

@ -122,7 +122,7 @@ QList<QAction*> FormMain::allActions() {
actions << m_ui->m_actionSwitchImportanceOfSelectedMessages;
actions << m_ui->m_actionDeleteSelectedMessages;
actions << m_ui->m_actionUpdateAllFeeds;
actions << m_ui->m_actionUpdateSelectedFeedsCategories;
actions << m_ui->m_actionUpdateSelectedFeeds;
actions << m_ui->m_actionEditSelectedFeedCategory;
actions << m_ui->m_actionDeleteSelectedFeedCategory;
actions << m_ui->m_actionViewSelectedItemsNewspaperMode;
@ -251,7 +251,7 @@ void FormMain::setupIcons() {
// Feeds/messages.
m_ui->m_menuAddItem->setIcon(icon_theme_factory->fromTheme("item-new"));
m_ui->m_actionUpdateAllFeeds->setIcon(icon_theme_factory->fromTheme("item-update-all"));
m_ui->m_actionUpdateSelectedFeedsCategories->setIcon(icon_theme_factory->fromTheme("item-update-selected"));
m_ui->m_actionUpdateSelectedFeeds->setIcon(icon_theme_factory->fromTheme("item-update-selected"));
m_ui->m_actionClearSelectedFeeds->setIcon(icon_theme_factory->fromTheme("mail-remove"));
m_ui->m_actionClearAllFeeds->setIcon(icon_theme_factory->fromTheme("mail-remove"));
m_ui->m_actionDeleteSelectedFeedCategory->setIcon(icon_theme_factory->fromTheme("item-remove"));
@ -450,27 +450,9 @@ void FormMain::showAbout() {
}
void FormMain::showUpdates() {
if (!qApp->feedUpdateLock()->tryLock()) {
if (SystemTrayIcon::isSystemTrayActivated()) {
qApp->trayIcon()->showMessage(tr("Cannot check for updates"),
tr("You cannot check for updates because feed update is ongoing."),
QSystemTrayIcon::Warning);
}
else {
MessageBox::show(this,
QMessageBox::Warning,
tr("Cannot check for updates"),
tr("You cannot check for updates because feed update is ongoing."));
}
return;
}
QPointer<FormUpdate> form_update = new FormUpdate(this);
form_update.data()->exec();
delete form_update.data();
qApp->feedUpdateLock()->unlock();
}
void FormMain::showWiki() {

View file

@ -138,7 +138,7 @@
<addaction name="m_actionAddFeed"/>
</widget>
<addaction name="m_actionUpdateAllFeeds"/>
<addaction name="m_actionUpdateSelectedFeedsCategories"/>
<addaction name="m_actionUpdateSelectedFeeds"/>
<addaction name="separator"/>
<addaction name="m_menuAddItem"/>
<addaction name="m_actionEditSelectedFeedCategory"/>
@ -274,12 +274,12 @@
<string notr="true">Ctrl+Shift+U</string>
</property>
</action>
<action name="m_actionUpdateSelectedFeedsCategories">
<action name="m_actionUpdateSelectedFeeds">
<property name="text">
<string>Update &amp;selected feeds</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+U</string>
<string>Ctrl+U</string>
</property>
</action>
<action name="m_actionEditSelectedFeedCategory">

View file

@ -193,8 +193,7 @@ void FormUpdate::startUpdate() {
// via self-update feature.
close();
qDebug("Preparing to launch external installer '%s'.",
qPrintable(QDir::toNativeSeparators(m_updateFilePath)));
qDebug("Preparing to launch external installer '%s'.", qPrintable(QDir::toNativeSeparators(m_updateFilePath)));
#if defined(Q_OS_WIN)
long exec_result = (long) ShellExecute(NULL,