Toolbar stuff.
This commit is contained in:
parent
af7adc7964
commit
2f683e88ce
@ -12,23 +12,3 @@ BaseToolBar::BaseToolBar(const QString &title, QWidget *parent)
|
|||||||
BaseToolBar::~BaseToolBar() {
|
BaseToolBar::~BaseToolBar() {
|
||||||
qDebug("Destroying BaseToolBar instance.");
|
qDebug("Destroying BaseToolBar instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseToolBar::loadChangeableActions() {
|
|
||||||
QHash<QString, QAction*> available_actions = FormMain::instance()->allActions();
|
|
||||||
QStringList action_names = Settings::instance()->value(APP_CFG_GUI,
|
|
||||||
"messages_toolbar",
|
|
||||||
"m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages").toString().split(',',
|
|
||||||
QString::SkipEmptyParts);
|
|
||||||
|
|
||||||
actions().clear();
|
|
||||||
|
|
||||||
// Iterate action names and add respectable actions into the toolbar.
|
|
||||||
foreach (const QString &action_name, action_names) {
|
|
||||||
if (available_actions.contains(action_name)) {
|
|
||||||
addAction(available_actions.value(action_name));
|
|
||||||
}
|
|
||||||
else if (action_name == SEPARATOR_ACTION_NAME) {
|
|
||||||
addSeparator();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -14,7 +14,7 @@ class BaseToolBar : public QToolBar {
|
|||||||
|
|
||||||
virtual QList<QAction*> changeableActions() const = 0;
|
virtual QList<QAction*> changeableActions() const = 0;
|
||||||
virtual void saveChangeableActions() const = 0;
|
virtual void saveChangeableActions() const = 0;
|
||||||
virtual void loadChangeableActions();
|
virtual void loadChangeableActions() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -51,6 +51,10 @@ class FeedMessageViewer : public TabContent {
|
|||||||
return m_feedsView;
|
return m_feedsView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline MessagesToolBar *messagesToolBar() {
|
||||||
|
return m_toolBarMessages;
|
||||||
|
}
|
||||||
|
|
||||||
// Loads/saves sizes and states of ALL
|
// Loads/saves sizes and states of ALL
|
||||||
// underlying widgets, this contains primarily
|
// underlying widgets, this contains primarily
|
||||||
// splitters, toolbar and views.
|
// splitters, toolbar and views.
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include "gui/feedsview.h"
|
#include "gui/feedsview.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
|
#include "gui/basetoolbar.h"
|
||||||
|
#include "gui/messagestoolbar.h"
|
||||||
#include "qtsingleapplication/qtsingleapplication.h"
|
#include "qtsingleapplication/qtsingleapplication.h"
|
||||||
#include "dynamic-shortcuts/dynamicshortcuts.h"
|
#include "dynamic-shortcuts/dynamicshortcuts.h"
|
||||||
|
|
||||||
@ -769,6 +771,8 @@ void FormSettings::loadInterface() {
|
|||||||
"toolbar_style",
|
"toolbar_style",
|
||||||
Qt::ToolButtonIconOnly).toInt()));
|
Qt::ToolButtonIconOnly).toInt()));
|
||||||
|
|
||||||
|
// Load toolbars.
|
||||||
|
m_ui->widget->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->messagesToolBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::saveInterface() {
|
void FormSettings::saveInterface() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_pageGeneral">
|
<widget class="QWidget" name="m_pageGeneral">
|
||||||
<layout class="QFormLayout" name="formLayout_5">
|
<layout class="QFormLayout" name="formLayout_5">
|
||||||
@ -286,8 +286,8 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>564</width>
|
<width>100</width>
|
||||||
<height>364</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
@ -332,7 +332,7 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_tabIconSkin">
|
<widget class="QWidget" name="m_tabIconSkin">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -364,8 +364,8 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>560</width>
|
<width>558</width>
|
||||||
<height>336</height>
|
<height>337</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
@ -574,6 +574,16 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="m_tabToolBars">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Toolbars</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||||
|
<item>
|
||||||
|
<widget class="ToolBarEditor" name="widget" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -1219,6 +1229,12 @@ Authors of this application are NOT responsible for lost data.</string>
|
|||||||
<header>dynamicshortcutswidget.h</header>
|
<header>dynamicshortcutswidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ToolBarEditor</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>toolbareditor.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
|
|
||||||
|
#include <QWidgetAction>
|
||||||
|
|
||||||
|
|
||||||
MessagesToolBar::MessagesToolBar(const QString &title, QWidget *parent)
|
MessagesToolBar::MessagesToolBar(const QString &title, QWidget *parent)
|
||||||
: BaseToolBar(title, parent),
|
: BaseToolBar(title, parent),
|
||||||
m_spacer(new QWidget(this)),
|
m_spacer(new QWidget(this)),
|
||||||
m_txtFilter(new BaseLineEdit(this)) {
|
m_txtFilter(new BaseLineEdit(this)) {
|
||||||
m_spacer->setObjectName(SPACER_OBJECT_NAME);
|
|
||||||
m_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
m_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
m_txtFilter->setObjectName(FILTER_OBJECT_NAME);
|
|
||||||
m_txtFilter->setFixedWidth(FILTER_WIDTH);
|
m_txtFilter->setFixedWidth(FILTER_WIDTH);
|
||||||
m_txtFilter->setPlaceholderText(tr("Filter messages"));
|
m_txtFilter->setPlaceholderText(tr("Filter messages"));
|
||||||
|
|
||||||
@ -65,8 +65,24 @@ void MessagesToolBar::saveChangeableActions() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesToolBar::loadChangeableActions() {
|
void MessagesToolBar::loadChangeableActions() {
|
||||||
BaseToolBar::loadChangeableActions();
|
QHash<QString, QAction*> available_actions = FormMain::instance()->allActions();
|
||||||
|
QStringList action_names = Settings::instance()->value(APP_CFG_GUI,
|
||||||
|
"messages_toolbar",
|
||||||
|
"m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages").toString().split(',',
|
||||||
|
QString::SkipEmptyParts);
|
||||||
|
|
||||||
addWidget(m_spacer);
|
actions().clear();
|
||||||
addWidget(m_txtFilter);
|
|
||||||
|
// Iterate action names and add respectable actions into the toolbar.
|
||||||
|
foreach (const QString &action_name, action_names) {
|
||||||
|
if (available_actions.contains(action_name)) {
|
||||||
|
addAction(available_actions.value(action_name));
|
||||||
|
}
|
||||||
|
else if (action_name == SEPARATOR_ACTION_NAME) {
|
||||||
|
addSeparator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addWidget(m_spacer)->setObjectName(SPACER_OBJECT_NAME);
|
||||||
|
addWidget(m_txtFilter)->setObjectName(FILTER_OBJECT_NAME);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ class MessagesToolBar : public BaseToolBar {
|
|||||||
private:
|
private:
|
||||||
QWidget *m_spacer;
|
QWidget *m_spacer;
|
||||||
BaseLineEdit *m_txtFilter;
|
BaseLineEdit *m_txtFilter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NEWSTOOLBAR_H
|
#endif // NEWSTOOLBAR_H
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#include "gui/toolbareditor.h"
|
#include "gui/toolbareditor.h"
|
||||||
|
|
||||||
#include "gui/basetoolbar.h"
|
#include "gui/basetoolbar.h"
|
||||||
|
#include "gui/formmain.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
ToolBarEditor::ToolBarEditor(QWidget *parent)
|
ToolBarEditor::ToolBarEditor(QWidget *parent)
|
||||||
: QDialog(parent), m_ui(new Ui::ToolBarEditor) {
|
: QWidget(parent), m_ui(new Ui::ToolBarEditor) {
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +18,24 @@ ToolBarEditor::~ToolBarEditor() {
|
|||||||
void ToolBarEditor::loadFromToolBar(BaseToolBar* tool_bar) {
|
void ToolBarEditor::loadFromToolBar(BaseToolBar* tool_bar) {
|
||||||
m_toolBar = tool_bar;
|
m_toolBar = tool_bar;
|
||||||
|
|
||||||
// TODO: nastavit dialog podle toolbaru
|
QList<QAction*> activated_actions = m_toolBar->changeableActions();
|
||||||
|
QList<QAction*> available_actions = FormMain::instance()->allActions().values();
|
||||||
|
|
||||||
|
foreach (QAction *action, activated_actions) {
|
||||||
|
QListWidgetItem *action_item = new QListWidgetItem(action->icon(),
|
||||||
|
action->text().replace('&', ""),
|
||||||
|
m_ui->m_listActivatedActions);
|
||||||
|
action_item->setData(Qt::UserRole, QVariant::fromValue((intptr_t) action));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QAction *action, available_actions) {
|
||||||
|
if (!activated_actions.contains(action)) {
|
||||||
|
QListWidgetItem *action_item = new QListWidgetItem(action->icon(),
|
||||||
|
action->text().replace('&', ""),
|
||||||
|
m_ui->m_listAvailableActions);
|
||||||
|
action_item->setData(Qt::UserRole, QVariant::fromValue((intptr_t) action));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBarEditor::saveToolBar() {
|
void ToolBarEditor::saveToolBar() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef TOOLBAREDITOR_H
|
#ifndef TOOLBAREDITOR_H
|
||||||
#define TOOLBAREDITOR_H
|
#define TOOLBAREDITOR_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "ui_toolbareditor.h"
|
#include "ui_toolbareditor.h"
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ namespace Ui {
|
|||||||
class BaseToolBar;
|
class BaseToolBar;
|
||||||
|
|
||||||
// TODO: dialog pro úpravu prirazeneho toolbaru.
|
// TODO: dialog pro úpravu prirazeneho toolbaru.
|
||||||
class ToolBarEditor : public QDialog {
|
class ToolBarEditor : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -1,17 +1,118 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ToolBarEditor</class>
|
<class>ToolBarEditor</class>
|
||||||
<widget name="ToolBarEditor" class="QDialog">
|
<widget class="QWidget" name="ToolBarEditor">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>610</width>
|
||||||
<height>300</height>
|
<height>415</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Available actions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Activated actions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" rowspan="4">
|
||||||
|
<widget class="QListWidget" name="m_listActivatedActions">
|
||||||
|
<property name="showDropIndicator" stdset="0">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropOverwriteMode">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragDrop</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2" rowspan="4">
|
||||||
|
<widget class="QListWidget" name="m_listAvailableActions">
|
||||||
|
<property name="showDropIndicator" stdset="0">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropOverwriteMode">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragDrop</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="3">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Insert separator</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user