Merge branch 'master' into macOS_fixes
This commit is contained in:
commit
74fe1dcee7
@ -2,6 +2,9 @@
|
||||
—————
|
||||
|
||||
Added:
|
||||
▪ Toolbar editor can reset toolbars.
|
||||
▪ Toolbar editor now uses iconified tool buttons.
|
||||
▪ Double mouse click on feed or recycle bin items in feeds list now opens all messages of the item in newspaper mode.
|
||||
▪ Columns in message list can be hidden/shown/reordered with context menu. (issue #115)
|
||||
▪ Auto-update notification is now switchable. (issue #119)
|
||||
▪ Messages which are not removed or restored are not instantly deleted from list, they are striked-through instead. This is more resource friendly.
|
||||
|
@ -35,6 +35,10 @@ BaseToolBar::~BaseToolBar() {
|
||||
qDebug("Destroying BaseToolBar instance.");
|
||||
}
|
||||
|
||||
void BaseBar::loadSavedActions() {
|
||||
loadSpecificActions(getSpecificActions(savedActions()));
|
||||
}
|
||||
|
||||
QAction *BaseBar::findMatchingAction(const QString &action, const QList<QAction*> &actions) const {
|
||||
foreach (QAction *act, actions) {
|
||||
if (act->objectName() == action) {
|
||||
|
@ -34,8 +34,15 @@ class BaseBar {
|
||||
// state into the settings.
|
||||
virtual void saveChangeableActions(const QStringList &actions) = 0;
|
||||
|
||||
// Returns list of default actions.
|
||||
virtual QStringList defaultActions() const = 0;
|
||||
virtual QStringList savedActions() const = 0;
|
||||
|
||||
// Loads the toolbar state from settings.
|
||||
virtual void loadChangeableActions() = 0;
|
||||
virtual void loadSavedActions();
|
||||
|
||||
virtual QList<QAction*> getSpecificActions(const QStringList &actions) = 0;
|
||||
virtual void loadSpecificActions(const QList<QAction*> &actions) = 0;
|
||||
|
||||
protected:
|
||||
QAction *findMatchingAction(const QString &action, const QList<QAction *> &actions) const;
|
||||
|
@ -74,8 +74,8 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
|
||||
|
||||
// Prepare tabs.
|
||||
//m_ui->m_tabWidget->initializeTabs();
|
||||
tabWidget()->feedMessageViewer()->feedsToolBar()->loadChangeableActions();
|
||||
tabWidget()->feedMessageViewer()->messagesToolBar()->loadChangeableActions();
|
||||
tabWidget()->feedMessageViewer()->feedsToolBar()->loadSavedActions();
|
||||
tabWidget()->feedMessageViewer()->messagesToolBar()->loadSavedActions();
|
||||
|
||||
// Establish connections.
|
||||
createConnections();
|
||||
@ -87,7 +87,7 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
|
||||
setupIcons();
|
||||
loadSize();
|
||||
|
||||
m_statusBar->loadChangeableActions();
|
||||
m_statusBar->loadSavedActions();
|
||||
}
|
||||
|
||||
FormMain::~FormMain() {
|
||||
|
@ -229,8 +229,8 @@ void FeedMessageViewer::initialize() {
|
||||
m_toolBarMessages->setMovable(false);
|
||||
m_toolBarMessages->setAllowedAreas(Qt::TopToolBarArea);
|
||||
|
||||
m_toolBarFeeds->loadChangeableActions();
|
||||
m_toolBarMessages->loadChangeableActions();
|
||||
m_toolBarFeeds->loadSavedActions();
|
||||
m_toolBarMessages->loadSavedActions();
|
||||
|
||||
m_messagesBrowser->clear();
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
#include <QWidgetAction>
|
||||
|
||||
|
||||
FeedsToolBar::FeedsToolBar(const QString &title, QWidget *parent) : BaseToolBar(title, parent) {
|
||||
// Update right margin of filter textbox.
|
||||
@ -42,20 +44,12 @@ QList<QAction*> FeedsToolBar::changeableActions() const {
|
||||
|
||||
void FeedsToolBar::saveChangeableActions(const QStringList &actions) {
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::FeedsToolbarActions, actions.join(QSL(",")));
|
||||
loadChangeableActions(actions);
|
||||
loadSpecificActions(getSpecificActions(actions));
|
||||
}
|
||||
|
||||
void FeedsToolBar::loadChangeableActions() {
|
||||
QStringList action_names = qApp->settings()->value(GROUP(GUI), SETTING(GUI::FeedsToolbarActions)).toString().split(',',
|
||||
QString::SkipEmptyParts);
|
||||
|
||||
loadChangeableActions(action_names);
|
||||
}
|
||||
|
||||
void FeedsToolBar::loadChangeableActions(const QStringList &actions) {
|
||||
QList<QAction*> FeedsToolBar::getSpecificActions(const QStringList &actions) {
|
||||
QList<QAction*> available_actions = availableActions();
|
||||
|
||||
clear();
|
||||
QList<QAction*> spec_actions;
|
||||
|
||||
// Iterate action names and add respectable actions into the toolbar.
|
||||
foreach (const QString &action_name, actions) {
|
||||
@ -63,21 +57,49 @@ void FeedsToolBar::loadChangeableActions(const QStringList &actions) {
|
||||
|
||||
if (matching_action != nullptr) {
|
||||
// Add existing standard action.
|
||||
addAction(matching_action);
|
||||
spec_actions.append(matching_action);
|
||||
}
|
||||
else if (action_name == SEPARATOR_ACTION_NAME) {
|
||||
// Add new separator.
|
||||
addSeparator();
|
||||
QAction *act = new QAction(this);
|
||||
act->setSeparator(true);
|
||||
|
||||
spec_actions.append(act);
|
||||
}
|
||||
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);
|
||||
QWidgetAction *action = new QWidgetAction(this);
|
||||
|
||||
action->setDefaultWidget(spacer);
|
||||
action->setIcon(qApp->icons()->fromTheme(QSL("system-search")));
|
||||
action->setProperty("type", SPACER_ACTION_NAME);
|
||||
action->setProperty("name", tr("Toolbar spacer"));
|
||||
|
||||
spec_actions.append(action);
|
||||
}
|
||||
}
|
||||
|
||||
return spec_actions;
|
||||
}
|
||||
|
||||
void FeedsToolBar::loadSpecificActions(const QList<QAction*> &actions) {
|
||||
clear();
|
||||
|
||||
foreach (QAction *act, actions) {
|
||||
addAction(act);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList FeedsToolBar::defaultActions() const {
|
||||
return QString(GUI::FeedsToolbarActionsDef).split(',',
|
||||
QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
QStringList FeedsToolBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::FeedsToolbarActions)).toString().split(',',
|
||||
QString::SkipEmptyParts);
|
||||
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ class FeedsToolBar : public BaseToolBar {
|
||||
QList<QAction*> availableActions() const;
|
||||
QList<QAction*> 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);
|
||||
QList<QAction*> getSpecificActions(const QStringList &actions);
|
||||
void loadSpecificActions(const QList<QAction*> &actions);
|
||||
|
||||
QStringList defaultActions() const;
|
||||
QStringList savedActions() const;
|
||||
};
|
||||
|
||||
#endif // FEEDSTOOLBAR_H
|
||||
|
@ -505,6 +505,24 @@ void FeedsView::contextMenuEvent(QContextMenuEvent *event) {
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsView::mouseDoubleClickEvent(QMouseEvent *event) {
|
||||
QModelIndex idx = indexAt(event->pos());
|
||||
|
||||
if (idx.isValid()) {
|
||||
RootItem *item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(idx));
|
||||
|
||||
if (item->kind() == RootItemKind::Feed || item->kind() == RootItemKind::Bin) {
|
||||
const QList<Message> messages = m_sourceModel->messagesForItem(item);
|
||||
|
||||
if (!messages.isEmpty()) {
|
||||
emit openMessagesInNewspaperView(item, messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTreeView::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void FeedsView::saveSortState(int column, Qt::SortOrder order) {
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::DefaultSortColumnFeeds, column);
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::DefaultSortOrderFeeds, order);
|
||||
|
@ -110,6 +110,8 @@ class FeedsView : public QTreeView {
|
||||
// Show custom context menu.
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
private slots:
|
||||
void expandItemDelayed(const QModelIndex &idx);
|
||||
void markSelectedItemReadStatus(RootItem::ReadStatus read);
|
||||
|
@ -52,7 +52,7 @@ QList<QAction*> MessagesToolBar::changeableActions() const {
|
||||
|
||||
void MessagesToolBar::saveChangeableActions(const QStringList& actions) {
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::MessagesToolbarDefaultButtons, actions.join(QSL(",")));
|
||||
loadChangeableActions(actions);
|
||||
loadSpecificActions(getSpecificActions(actions));
|
||||
|
||||
// If user hidden search messages box, then remove the filter.
|
||||
if (!changeableActions().contains(m_actionSearchMessages)) {
|
||||
@ -60,10 +60,9 @@ void MessagesToolBar::saveChangeableActions(const QStringList& actions) {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesToolBar::loadChangeableActions(const QStringList& actions) {
|
||||
QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList &actions) {
|
||||
QList<QAction*> available_actions = availableActions();
|
||||
|
||||
clear();
|
||||
QList<QAction*> spec_actions;
|
||||
|
||||
// Iterate action names and add respectable actions into the toolbar.
|
||||
foreach (const QString &action_name, actions) {
|
||||
@ -71,31 +70,48 @@ void MessagesToolBar::loadChangeableActions(const QStringList& actions) {
|
||||
|
||||
if (matching_action != nullptr) {
|
||||
// Add existing standard action.
|
||||
addAction(matching_action);
|
||||
spec_actions.append(matching_action);
|
||||
}
|
||||
else if (action_name == SEPARATOR_ACTION_NAME) {
|
||||
// Add new separator.
|
||||
addSeparator();
|
||||
QAction *act = new QAction(this);
|
||||
act->setSeparator(true);
|
||||
|
||||
spec_actions.append(act);
|
||||
}
|
||||
else if (action_name == SEACRH_MESSAGES_ACTION_NAME) {
|
||||
// Add search box.
|
||||
addAction(m_actionSearchMessages);
|
||||
spec_actions.append(m_actionSearchMessages);
|
||||
}
|
||||
else if (action_name == HIGHLIGHTER_ACTION_NAME) {
|
||||
// Add filter button.
|
||||
addAction(m_actionMessageHighlighter);
|
||||
spec_actions.append(m_actionMessageHighlighter);
|
||||
}
|
||||
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);
|
||||
QWidgetAction *action = new QWidgetAction(this);
|
||||
|
||||
action->setDefaultWidget(spacer);
|
||||
action->setIcon(qApp->icons()->fromTheme(QSL("go-jump")));
|
||||
action->setProperty("type", SPACER_ACTION_NAME);
|
||||
action->setProperty("name", tr("Toolbar spacer"));
|
||||
|
||||
spec_actions.append(action);
|
||||
}
|
||||
}
|
||||
|
||||
return spec_actions;
|
||||
}
|
||||
|
||||
void MessagesToolBar::loadSpecificActions(const QList<QAction*> &actions) {
|
||||
clear();
|
||||
|
||||
foreach (QAction *act, actions) {
|
||||
addAction(act);
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesToolBar::handleMessageHighlighterChange(QAction *action) {
|
||||
@ -145,10 +161,13 @@ void MessagesToolBar::initializeHighlighter() {
|
||||
this, SLOT(handleMessageHighlighterChange(QAction*)));
|
||||
}
|
||||
|
||||
void MessagesToolBar::loadChangeableActions() {
|
||||
QStringList action_names = qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::MessagesToolbarDefaultButtons)).toString().split(',',
|
||||
QString::SkipEmptyParts);
|
||||
|
||||
loadChangeableActions(action_names);
|
||||
QStringList MessagesToolBar::defaultActions() const {
|
||||
return QString(GUI::MessagesToolbarDefaultButtonsDef).split(',',
|
||||
QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
QStringList MessagesToolBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::MessagesToolbarDefaultButtons)).toString().split(',',
|
||||
QString::SkipEmptyParts);
|
||||
}
|
||||
|
@ -45,12 +45,16 @@ class MessagesToolBar : public BaseToolBar {
|
||||
QList<QAction*> availableActions() const;
|
||||
QList<QAction*> 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);
|
||||
void loadSpecificActions(const QList<QAction*> &actions);
|
||||
|
||||
QList<QAction*> getSpecificActions(const QStringList &actions);
|
||||
|
||||
QStringList defaultActions() const;
|
||||
QStringList savedActions() const;
|
||||
|
||||
signals:
|
||||
void messageSearchPatternChanged(const QString &pattern);
|
||||
|
@ -58,6 +58,8 @@ void SettingsLocalization::loadSettings() {
|
||||
item->setIcon(0, qApp->icons()->miscIcon(QString(FLAG_ICON_SUBFOLDER) + QDir::separator() + language.m_code));
|
||||
}
|
||||
|
||||
m_ui->m_treeLanguages->sortByColumn(0, Qt::AscendingOrder);
|
||||
|
||||
QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(qApp->localization()->loadedLanguage(), Qt::MatchContains, 1);
|
||||
|
||||
if (!matching_items.isEmpty()) {
|
||||
|
@ -72,7 +72,7 @@ StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent), m_mutex(new Mutex(QM
|
||||
}
|
||||
|
||||
StatusBar::~StatusBar() {
|
||||
clear();
|
||||
clear();
|
||||
qDebug("Destroying StatusBar instance.");
|
||||
}
|
||||
|
||||
@ -94,28 +94,26 @@ void StatusBar::saveChangeableActions(const QStringList &actions) {
|
||||
QMutexLocker locker(*m_mutex);
|
||||
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::StatusbarActions, actions.join(QSL(",")));
|
||||
loadChangeableActions(actions);
|
||||
loadSpecificActions(getSpecificActions(actions));
|
||||
}
|
||||
|
||||
void StatusBar::loadChangeableActions() {
|
||||
QMutexLocker locker(*m_mutex);
|
||||
|
||||
QStringList action_names = qApp->settings()->value(GROUP(GUI), SETTING(GUI::StatusbarActions)).toString().split(',',
|
||||
QString::SkipEmptyParts);
|
||||
|
||||
loadChangeableActions(action_names);
|
||||
QStringList StatusBar::defaultActions() const {
|
||||
return QString(GUI::StatusbarActionsDef).split(',', QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
void StatusBar::loadChangeableActions(const QStringList &action_names) {
|
||||
clear();
|
||||
QStringList StatusBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::StatusbarActions)).toString().split(',', QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
bool progress_visible = actions().contains(m_barProgressFeedsAction) &&
|
||||
QList<QAction*> StatusBar::getSpecificActions(const QStringList &actions) {
|
||||
bool progress_visible = this->actions().contains(m_barProgressFeedsAction) &&
|
||||
m_lblProgressFeeds->isVisible() &&
|
||||
m_barProgressFeeds->isVisible();
|
||||
QList<QAction*> available_actions = availableActions();
|
||||
QList<QAction*> spec_actions;
|
||||
|
||||
// Iterate action names and add respectable actions into the toolbar.
|
||||
foreach (const QString &action_name, action_names) {
|
||||
foreach (const QString &action_name, actions) {
|
||||
QAction *matching_action = findMatchingAction(action_name, available_actions);
|
||||
QAction *action_to_add;
|
||||
QWidget *widget_to_add;
|
||||
@ -186,8 +184,36 @@ void StatusBar::loadChangeableActions(const QStringList &action_names) {
|
||||
|
||||
if (action_to_add != nullptr && widget_to_add != nullptr) {
|
||||
action_to_add->setProperty("widget", QVariant::fromValue((void*) widget_to_add));
|
||||
addPermanentWidget(widget_to_add);
|
||||
addAction(action_to_add);
|
||||
spec_actions.append(action_to_add);
|
||||
}
|
||||
}
|
||||
|
||||
return spec_actions;
|
||||
}
|
||||
|
||||
void StatusBar::loadSpecificActions(const QList<QAction*> &actions) {
|
||||
foreach (QAction *act, this->actions()) {
|
||||
QWidget *widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : nullptr;
|
||||
|
||||
if (widget != nullptr) {
|
||||
removeWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
removeWidget(m_barProgressDownload);
|
||||
removeWidget(m_barProgressFeeds);
|
||||
removeWidget(m_lblProgressDownload);
|
||||
removeWidget(m_lblProgressFeeds);
|
||||
clear();
|
||||
|
||||
foreach (QAction *act, actions) {
|
||||
QWidget *widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : nullptr;
|
||||
|
||||
addAction(act);
|
||||
|
||||
// And also add widget.
|
||||
if (widget != nullptr) {
|
||||
addPermanentWidget(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,10 @@ class StatusBar : public QStatusBar, public BaseBar {
|
||||
QList<QAction*> availableActions() const;
|
||||
QList<QAction*> changeableActions() const;
|
||||
void saveChangeableActions(const QStringList &actions);
|
||||
void loadChangeableActions();
|
||||
QStringList defaultActions() const;
|
||||
QStringList savedActions() const;
|
||||
QList<QAction*> getSpecificActions(const QStringList &actions);
|
||||
void loadSpecificActions(const QList<QAction*> &actions);
|
||||
|
||||
public slots:
|
||||
// Progress bar operations
|
||||
@ -54,7 +57,6 @@ class StatusBar : public QStatusBar, public BaseBar {
|
||||
|
||||
private:
|
||||
void clear();
|
||||
void loadChangeableActions(const QStringList &action_names);
|
||||
|
||||
Mutex *m_mutex;
|
||||
|
||||
|
@ -28,14 +28,15 @@ ToolBarEditor::ToolBarEditor(QWidget *parent)
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// Create connections.
|
||||
connect(m_ui->m_btnInsertSeparator, &QPushButton::clicked, this, &ToolBarEditor::insertSeparator);
|
||||
connect(m_ui->m_btnInsertSpacer, &QPushButton::clicked, this, &ToolBarEditor::insertSpacer);
|
||||
connect(m_ui->m_btnInsertSeparator, &QToolButton::clicked, this, &ToolBarEditor::insertSeparator);
|
||||
connect(m_ui->m_btnInsertSpacer, &QToolButton::clicked, this, &ToolBarEditor::insertSpacer);
|
||||
|
||||
connect(m_ui->m_btnAddSelectedAction, &QPushButton::clicked, this, &ToolBarEditor::addSelectedAction);
|
||||
connect(m_ui->m_btnDeleteAllActions, &QPushButton::clicked, this, &ToolBarEditor::deleteAllActions);
|
||||
connect(m_ui->m_btnDeleteSelectedAction, &QPushButton::clicked, this, &ToolBarEditor::deleteSelectedAction);
|
||||
connect(m_ui->m_btnMoveActionUp, &QPushButton::clicked, this, &ToolBarEditor::moveActionUp);
|
||||
connect(m_ui->m_btnMoveActionDown, &QPushButton::clicked, this, &ToolBarEditor::moveActionDown);
|
||||
connect(m_ui->m_btnAddSelectedAction, &QToolButton::clicked, this, &ToolBarEditor::addSelectedAction);
|
||||
connect(m_ui->m_btnDeleteAllActions, &QToolButton::clicked, this, &ToolBarEditor::deleteAllActions);
|
||||
connect(m_ui->m_btnDeleteSelectedAction, &QToolButton::clicked, this, &ToolBarEditor::deleteSelectedAction);
|
||||
connect(m_ui->m_btnMoveActionUp, &QToolButton::clicked, this, &ToolBarEditor::moveActionUp);
|
||||
connect(m_ui->m_btnMoveActionDown, &QToolButton::clicked, this, &ToolBarEditor::moveActionDown);
|
||||
connect(m_ui->m_btnReset, &QToolButton::clicked, this, &ToolBarEditor::resetToolBar);
|
||||
|
||||
connect(m_ui->m_listAvailableActions, &QListWidget::itemSelectionChanged, this, &ToolBarEditor::updateActionsAvailability);
|
||||
connect(m_ui->m_listActivatedActions, &QListWidget::itemSelectionChanged, this, &ToolBarEditor::updateActionsAvailability);
|
||||
@ -43,6 +44,15 @@ ToolBarEditor::ToolBarEditor(QWidget *parent)
|
||||
connect(m_ui->m_listAvailableActions, &QListWidget::itemDoubleClicked, this, &ToolBarEditor::addSelectedAction);
|
||||
|
||||
m_ui->m_listActivatedActions->installEventFilter(this);
|
||||
|
||||
m_ui->m_btnInsertSeparator->setIcon(qApp->icons()->fromTheme(QSL("insert-object")));
|
||||
m_ui->m_btnInsertSpacer->setIcon(qApp->icons()->fromTheme(QSL("go-jump")));
|
||||
m_ui->m_btnAddSelectedAction->setIcon(qApp->icons()->fromTheme(QSL("back")));
|
||||
m_ui->m_btnDeleteAllActions->setIcon(qApp->icons()->fromTheme(QSL("application-exit")));
|
||||
m_ui->m_btnDeleteSelectedAction->setIcon(qApp->icons()->fromTheme(QSL("forward")));
|
||||
m_ui->m_btnMoveActionDown->setIcon(qApp->icons()->fromTheme(QSL("down")));
|
||||
m_ui->m_btnMoveActionUp->setIcon(qApp->icons()->fromTheme(QSL("up")));
|
||||
m_ui->m_btnReset->setIcon(qApp->icons()->fromTheme(QSL("reload")));
|
||||
}
|
||||
|
||||
ToolBarEditor::~ToolBarEditor() {
|
||||
@ -55,6 +65,29 @@ void ToolBarEditor::loadFromToolBar(BaseBar *tool_bar) {
|
||||
QList<QAction*> activated_actions = m_toolBar->changeableActions();
|
||||
QList<QAction*> available_actions = m_toolBar->availableActions();
|
||||
|
||||
loadEditor(activated_actions, available_actions);
|
||||
}
|
||||
|
||||
void ToolBarEditor::saveToolBar() {
|
||||
QStringList action_names;
|
||||
|
||||
for (int i = 0; i < m_ui->m_listActivatedActions->count(); i++) {
|
||||
action_names.append(m_ui->m_listActivatedActions->item(i)->data(Qt::UserRole).toString());
|
||||
}
|
||||
|
||||
m_toolBar->saveChangeableActions(action_names);
|
||||
}
|
||||
|
||||
void ToolBarEditor::resetToolBar() {
|
||||
if (m_toolBar != nullptr) {
|
||||
loadEditor(m_toolBar->getSpecificActions(m_toolBar->defaultActions()), m_toolBar->availableActions());
|
||||
}
|
||||
}
|
||||
|
||||
void ToolBarEditor::loadEditor(const QList<QAction *> activated_actions, const QList<QAction *> available_actions) {
|
||||
m_ui->m_listActivatedActions->clear();
|
||||
m_ui->m_listAvailableActions->clear();
|
||||
|
||||
foreach (const QAction *action, activated_actions) {
|
||||
QListWidgetItem *action_item = new QListWidgetItem(action->icon(), action->text().replace('&', ""), m_ui->m_listActivatedActions);
|
||||
|
||||
@ -98,20 +131,10 @@ void ToolBarEditor::loadFromToolBar(BaseBar *tool_bar) {
|
||||
}
|
||||
|
||||
m_ui->m_listAvailableActions->sortItems(Qt::AscendingOrder);
|
||||
m_ui->m_listAvailableActions->setCurrentRow(0);
|
||||
m_ui->m_listAvailableActions->setCurrentRow(m_ui->m_listAvailableActions->count() >= 0 ? 0 : -1);
|
||||
m_ui->m_listActivatedActions->setCurrentRow(m_ui->m_listActivatedActions->count() >= 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
void ToolBarEditor::saveToolBar() {
|
||||
QStringList action_names;
|
||||
|
||||
for (int i = 0; i < m_ui->m_listActivatedActions->count(); i++) {
|
||||
action_names.append(m_ui->m_listActivatedActions->item(i)->data(Qt::UserRole).toString());
|
||||
}
|
||||
|
||||
m_toolBar->saveChangeableActions(action_names);
|
||||
}
|
||||
|
||||
bool ToolBarEditor::eventFilter(QObject *object, QEvent *event) {
|
||||
if (object == m_ui->m_listActivatedActions) {
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
|
@ -66,10 +66,14 @@ class ToolBarEditor : public QWidget {
|
||||
void deleteSelectedAction();
|
||||
void deleteAllActions();
|
||||
|
||||
void resetToolBar();
|
||||
|
||||
signals:
|
||||
void setupChanged();
|
||||
|
||||
private:
|
||||
void loadEditor(const QList<QAction*> activated_actions, const QList<QAction*> available_actions);
|
||||
|
||||
QScopedPointer<Ui::ToolBarEditor> m_ui;
|
||||
BaseBar *m_toolBar;
|
||||
};
|
||||
|
109
src/gui/toolbareditor.ui
Normal file → Executable file
109
src/gui/toolbareditor.ui
Normal file → Executable file
@ -65,17 +65,32 @@
|
||||
<item row="1" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnMoveActionUp">
|
||||
<property name="text">
|
||||
<widget class="QToolButton" name="m_btnMoveActionUp">
|
||||
<property name="toolTip">
|
||||
<string>Move action up</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnMoveActionDown">
|
||||
<property name="text">
|
||||
<widget class="QToolButton" name="m_btnMoveActionDown">
|
||||
<property name="toolTip">
|
||||
<string>Move action down</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -86,23 +101,28 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnInsertSeparator">
|
||||
<property name="text">
|
||||
<widget class="QToolButton" name="m_btnInsertSeparator">
|
||||
<property name="toolTip">
|
||||
<string>Insert separator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnInsertSpacer">
|
||||
<property name="text">
|
||||
<string>Insert spacer</string>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnAddSelectedAction">
|
||||
<property name="text">
|
||||
<string>Add selected action</string>
|
||||
<widget class="QToolButton" name="m_btnInsertSpacer">
|
||||
<property name="toolTip">
|
||||
<string>Insert spacer</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -114,17 +134,55 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnDeleteSelectedAction">
|
||||
<property name="text">
|
||||
<string>Delete selected action</string>
|
||||
<widget class="QToolButton" name="m_btnAddSelectedAction">
|
||||
<property name="toolTip">
|
||||
<string>Add selected action</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnDeleteAllActions">
|
||||
<property name="text">
|
||||
<widget class="QToolButton" name="m_btnDeleteSelectedAction">
|
||||
<property name="toolTip">
|
||||
<string>Delete selected action</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="m_btnDeleteAllActions">
|
||||
<property name="toolTip">
|
||||
<string>Delete all actions</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="m_btnReset">
|
||||
<property name="toolTip">
|
||||
<string>Reset toolbar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -166,6 +224,17 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_listActivatedActions</tabstop>
|
||||
<tabstop>m_listAvailableActions</tabstop>
|
||||
<tabstop>m_btnMoveActionUp</tabstop>
|
||||
<tabstop>m_btnMoveActionDown</tabstop>
|
||||
<tabstop>m_btnInsertSeparator</tabstop>
|
||||
<tabstop>m_btnInsertSpacer</tabstop>
|
||||
<tabstop>m_btnAddSelectedAction</tabstop>
|
||||
<tabstop>m_btnDeleteSelectedAction</tabstop>
|
||||
<tabstop>m_btnDeleteAllActions</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -42,6 +42,8 @@ void TreeViewColumnsMenu::prepareMenu() {
|
||||
}
|
||||
|
||||
void TreeViewColumnsMenu::actionTriggered(bool toggle) {
|
||||
Q_UNUSED(toggle)
|
||||
|
||||
QAction *send_act = qobject_cast<QAction*>(sender());
|
||||
|
||||
header()->setSectionHidden(send_act->data().toInt(), !send_act->isChecked());
|
||||
|
@ -89,6 +89,7 @@ QList<Language> Localization::installedLanguages() const {
|
||||
languages << new_language;
|
||||
}
|
||||
}
|
||||
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user