From 8558395ba2d6456fca47b6426fc8e666fc5796c9 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 7 Apr 2014 08:21:55 +0200 Subject: [PATCH] Fixed #2 and some fixing. --- CMakeLists.txt | 2 + resources/text/CHANGELOG | 17 +++++ src/gui/feedmessageviewer.cpp | 11 +-- src/gui/feedmessageviewer.h | 7 +- src/gui/feedstoolbar.cpp | 65 ++++++++++++++++ src/gui/feedstoolbar.h | 24 ++++++ src/gui/formsettings.cpp | 10 ++- src/gui/formsettings.ui | 109 +++++++++++++++++++++----- src/gui/toolbareditor.cpp | 7 ++ src/gui/toolbareditor.h | 1 + src/gui/toolbareditor.ui | 136 ++++++++++++++++++++++----------- src/network-web/webbrowser.cpp | 2 + 12 files changed, 317 insertions(+), 74 deletions(-) create mode 100644 src/gui/feedstoolbar.cpp create mode 100644 src/gui/feedstoolbar.h diff --git a/CMakeLists.txt b/CMakeLists.txt index dc46f3d83..501974c32 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,6 +294,7 @@ set(APP_SOURCES src/gui/comboboxwithstatus.cpp src/gui/basetoolbar.cpp src/gui/messagestoolbar.cpp + src/gui/feedstoolbar.cpp src/gui/toolbareditor.cpp # DYNAMIC-SHORTCUTS sources. @@ -371,6 +372,7 @@ set(APP_HEADERS src/gui/comboboxwithstatus.h src/gui/basetoolbar.h src/gui/messagestoolbar.h + src/gui/feedstoolbar.h src/gui/toolbareditor.h # DYNAMIC-SHORTCUTS headers. diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 17eee38eb..dfdecdc0a 100644 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -1,4 +1,21 @@ +

1.9.9.9

+ +Fixed: + + +Added: + + +Changed: + + +

1.9.9.8

Fixed: diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index d10661b86..8d68bd4b2 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -32,6 +32,7 @@ #include "gui/systemtrayicon.h" #include "gui/messagebox.h" #include "gui/messagestoolbar.h" +#include "gui/feedstoolbar.h" #include #include @@ -52,7 +53,7 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent) : TabContent(parent), m_toolBarsEnabled(true), m_listHeadersEnabled(true), - m_toolBarFeeds(new QToolBar(tr("Toolbar for feeds"), this)), + m_toolBarFeeds(new FeedsToolBar(tr("Toolbar for feeds"), this)), m_toolBarMessages(new MessagesToolBar(tr("Toolbar for messages"), this)), m_messagesView(new MessagesView(this)), m_feedsView(new FeedsView(this)), @@ -301,17 +302,11 @@ void FeedMessageViewer::initialize() { m_toolBarFeeds->setFloatable(false); m_toolBarFeeds->setMovable(false); m_toolBarFeeds->setAllowedAreas(Qt::TopToolBarArea); - m_toolBarFeeds->setToolButtonStyle(Qt::ToolButtonIconOnly); - - // Add everything to toolbar. - m_toolBarFeeds->addAction(FormMain::instance()->m_ui->m_actionUpdateAllFeeds); - m_toolBarFeeds->addAction(FormMain::instance()->m_ui->m_actionMarkAllFeedsRead); - m_toolBarFeeds->addAction(FormMain::instance()->m_ui->m_actionClearAllFeeds); + m_toolBarFeeds->loadChangeableActions(); m_toolBarMessages->setFloatable(false); m_toolBarMessages->setMovable(false); m_toolBarMessages->setAllowedAreas(Qt::TopToolBarArea); - m_toolBarMessages->setToolButtonStyle(Qt::ToolButtonIconOnly); m_toolBarMessages->loadChangeableActions(); // Finish web/message browser setup. diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index 52fc45c8b..7f7371f07 100644 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -26,6 +26,7 @@ class WebBrowser; class MessagesView; class MessagesToolBar; +class FeedsToolBar; class FeedsView; class FeedDownloader; class FeedsModelFeed; @@ -55,6 +56,10 @@ class FeedMessageViewer : public TabContent { return m_toolBarMessages; } + inline FeedsToolBar *feedsToolBar() { + return m_toolBarFeeds; + } + // Loads/saves sizes and states of ALL // underlying widgets, this contains primarily // splitters, toolbar and views. @@ -110,7 +115,7 @@ class FeedMessageViewer : public TabContent { private: bool m_toolBarsEnabled; bool m_listHeadersEnabled; - QToolBar *m_toolBarFeeds; + FeedsToolBar *m_toolBarFeeds; MessagesToolBar *m_toolBarMessages; QSplitter *m_feedSplitter; diff --git a/src/gui/feedstoolbar.cpp b/src/gui/feedstoolbar.cpp new file mode 100644 index 000000000..bbc0bb3fd --- /dev/null +++ b/src/gui/feedstoolbar.cpp @@ -0,0 +1,65 @@ +#include "gui/feedstoolbar.h" + +#include "gui/formmain.h" +#include "miscellaneous/settings.h" + + +FeedsToolBar::FeedsToolBar(const QString &title, QWidget *parent) : BaseToolBar(title, parent) { + // Update right margin of filter textbox. + QMargins margins = contentsMargins(); + margins.setRight(margins.right() + FILTER_RIGHT_MARGIN); + setContentsMargins(margins); +} + +FeedsToolBar::~FeedsToolBar() { +} + +QHash FeedsToolBar::availableActions() const { + return FormMain::instance()->allActions();; +} + +QList FeedsToolBar::changeableActions() const { + return actions(); +} + +void FeedsToolBar::saveChangeableActions(const QStringList &actions) { + Settings::instance()->setValue(APP_CFG_GUI, "feeds_toolbar", actions.join(",")); + loadChangeableActions(actions); +} + +void FeedsToolBar::loadChangeableActions() { + QStringList action_names = Settings::instance()->value(APP_CFG_GUI, + "feeds_toolbar", + "m_actionUpdateAllFeeds,m_actionMarkAllFeedsRead").toString().split(',', + QString::SkipEmptyParts); + + loadChangeableActions(action_names); +} + +void FeedsToolBar::loadChangeableActions(const QStringList &actions) { + QHash available_actions = availableActions(); + + clear(); + + // Iterate action names and add respectable actions into the toolbar. + foreach (const QString &action_name, actions) { + if (available_actions.contains(action_name)) { + // Add existing standard action. + addAction(available_actions.value(action_name)); + } + else if (action_name == SEPARATOR_ACTION_NAME) { + // Add new separator. + addSeparator(); + } + else if (action_name == SPACER_ACTION_NAME) { + // Add new spacer. + QWidget *spacer = new QWidget(this); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QAction *action = addWidget(spacer); + action->setIcon(IconFactory::instance()->fromTheme("application-search")); + action->setProperty("type", SPACER_ACTION_NAME); + action->setProperty("name", tr("Toolbar spacer")); + } + } +} diff --git a/src/gui/feedstoolbar.h b/src/gui/feedstoolbar.h new file mode 100644 index 000000000..2198a9956 --- /dev/null +++ b/src/gui/feedstoolbar.h @@ -0,0 +1,24 @@ +#ifndef FEEDSTOOLBAR_H +#define FEEDSTOOLBAR_H + +#include "gui/basetoolbar.h" + + +class FeedsToolBar : public BaseToolBar { + public: + // Constructors and destructors. + explicit FeedsToolBar(const QString &title, QWidget *parent = 0); + virtual ~FeedsToolBar(); + + QHash availableActions() const; + QList changeableActions() const; + void saveChangeableActions(const QStringList &actions); + void loadChangeableActions(); + + // Loads actions as specified by external actions list. + // NOTE: This is used primarily for reloading actions + // when they are changed from settings. + void loadChangeableActions(const QStringList &actions); +}; + +#endif // FEEDSTOOLBAR_H diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 8b7f24c54..e7066df7c 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -33,6 +33,7 @@ #include "gui/systemtrayicon.h" #include "gui/feedmessageviewer.h" #include "gui/feedsview.h" +#include "gui/feedstoolbar.h" #include "gui/formmain.h" #include "gui/messagebox.h" #include "gui/basetoolbar.h" @@ -135,6 +136,8 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form this, SLOT(onMysqlDataStorageEdited())); connect(m_ui->m_txtMysqlUsername->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(onMysqlDataStorageEdited())); + connect(m_ui->m_cmbSelectToolBar, SIGNAL(currentIndexChanged(int)), + m_ui->m_stackedToolbars, SLOT(setCurrentIndex(int))); // Load all settings. loadGeneral(); @@ -772,7 +775,8 @@ void FormSettings::loadInterface() { Qt::ToolButtonIconOnly).toInt())); // Load toolbars. - m_ui->widget->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->messagesToolBar()); + m_ui->m_editorFeedsToolbar->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->feedsToolBar()); + m_ui->m_editorMessagesToolbar->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->messagesToolBar()); } void FormSettings::saveInterface() { @@ -833,8 +837,8 @@ void FormSettings::saveInterface() { settings->setValue(APP_CFG_GUI, "hide_tabbar_one_tab", m_ui->m_hideTabBarIfOneTabVisible->isChecked()); - - m_ui->widget->saveToolBar(); + m_ui->m_editorFeedsToolbar->saveToolBar(); + m_ui->m_editorMessagesToolbar->saveToolBar(); FormMain::instance()->tabWidget()->checkTabBarVisibility(); FormMain::instance()->tabWidget()->feedMessageViewer()->refreshVisualProperties(); diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui index d97d2e9e1..e98080d45 100644 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -6,8 +6,8 @@ 0 0 - 808 - 410 + 820 + 427 @@ -364,8 +364,8 @@ Authors of this application are NOT responsible for lost data. 0 0 - 558 - 337 + 570 + 354 @@ -378,6 +378,9 @@ Authors of this application are NOT responsible for lost data. Icons + + QFormLayout::AllNonFixedFieldsGrow + @@ -391,16 +394,6 @@ Authors of this application are NOT responsible for lost data. - - - - - - - Toolbar button style - - - @@ -578,9 +571,91 @@ Authors of this application are NOT responsible for lost data. Toolbars - - - + + + + + + + + 0 + + + + Toolbar for feeds list + + + + + Toolbar for messages list + + + + + + + + + 0 + 1 + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + Toolbar button style + + + + + + + Select toolbar to edit + + diff --git a/src/gui/toolbareditor.cpp b/src/gui/toolbareditor.cpp index 3bb0ddf3a..72b60d5a3 100644 --- a/src/gui/toolbareditor.cpp +++ b/src/gui/toolbareditor.cpp @@ -34,13 +34,16 @@ void ToolBarEditor::loadFromToolBar(BaseToolBar* tool_bar) { action_item->setData(Qt::UserRole, SEPARATOR_ACTION_NAME); action_item->setIcon(IconFactory::instance()->fromTheme("view-separator")); action_item->setText(tr("Separator")); + action_item->setToolTip(tr("Separator")); } else if (action->property("type").isValid()) { action_item->setData(Qt::UserRole, action->property("type").toString()); action_item->setText(action->property("name").toString()); + action_item->setToolTip(action_item->text()); } else { action_item->setData(Qt::UserRole, action->objectName()); + action_item->setToolTip(action->toolTip()); } } @@ -53,14 +56,17 @@ void ToolBarEditor::loadFromToolBar(BaseToolBar* tool_bar) { if (action->isSeparator()) { action_item->setData(Qt::UserRole, SEPARATOR_ACTION_NAME); action_item->setText(tr("Separator")); + action_item->setToolTip(tr("Separator")); action_item->setIcon(IconFactory::instance()->fromTheme("view-separator")); } else if (action->property("type").isValid()) { action_item->setData(Qt::UserRole, action->property("type").toString()); action_item->setText(action->property("name").toString()); + action_item->setToolTip(action_item->text()); } else { action_item->setData(Qt::UserRole, action->objectName()); + action_item->setToolTip(action->toolTip()); } } } @@ -98,6 +104,7 @@ void ToolBarEditor::insertSeparator() { QListWidgetItem *item = new QListWidgetItem(tr("Separator")); item->setData(Qt::UserRole, SEPARATOR_ACTION_NAME); + item->setToolTip(tr("Separator")); item->setIcon(IconFactory::instance()->fromTheme("view-separator")); if (current_row >= 0) { diff --git a/src/gui/toolbareditor.h b/src/gui/toolbareditor.h index 9d63d5c8e..0aba34e7c 100644 --- a/src/gui/toolbareditor.h +++ b/src/gui/toolbareditor.h @@ -26,6 +26,7 @@ class ToolBarEditor : public QWidget { void saveToolBar(); private slots: + // Insert common controls. void insertSpacer(); void insertSeparator(); diff --git a/src/gui/toolbareditor.ui b/src/gui/toolbareditor.ui index 79a8a3990..83a2b52f7 100644 --- a/src/gui/toolbareditor.ui +++ b/src/gui/toolbareditor.ui @@ -26,13 +26,6 @@ 0 - - - - Available actions - - - @@ -40,8 +33,21 @@ - + + + + Available actions + + + + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + true @@ -57,51 +63,91 @@ Qt::MoveAction - - - - - + true - + + QAbstractItemView::SelectRows + + + QAbstractItemView::ScrollPerPixel + + + QListView::Adjust + + true - - false - - - QAbstractItemView::DragDrop - - - Qt::MoveAction - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - Insert separator - - + + + + + Insert separator + + + + + + + Insert spacer + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - Insert spacer + + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + + + true + + + true + + + false + + + QAbstractItemView::DragDrop + + + Qt::MoveAction + + + true + + + QAbstractItemView::SelectRows + + + QAbstractItemView::ScrollPerPixel + + + QListView::Adjust + + + true diff --git a/src/network-web/webbrowser.cpp b/src/network-web/webbrowser.cpp index b70f9c1f2..b46357ac0 100644 --- a/src/network-web/webbrowser.cpp +++ b/src/network-web/webbrowser.cpp @@ -162,6 +162,8 @@ void WebBrowser::onLoadingProgress(int progress) { } void WebBrowser::onLoadingFinished(bool success) { + Q_UNUSED(success) + m_loadingProgress->hide(); }