1 #include <ui_ToolbarsWidgetForm.h>
6 #include "../../../common/STLUtils.h"
7 #include "../ApplicationController.h"
11 #include <QInputDialog>
12 #include <QMessageBox>
15 void SetToolbars(QComboBox* cmb, std::vector< QList<QAction*> >& acts)
18 std::vector<QToolBar*>::iterator it;
20 for(it=bars.begin(); it != bars.end(); ++it)
23 cmb->addItem(tb->objectName(), QVariant::fromValue<QObject*>(tb));
24 acts.push_back(tb->actions());
30 QAbstractItemModel* old_m = view->model();
33 view->setModel(model);
38 void UpdateActions(QList<QAction*>& acts, QAction* act,
const bool& toAdd)
48 std::set<QToolBar*>::const_iterator it;
50 for(it = bars.begin(); it != bars.end(); ++it)
64 m_ui(new Ui::ToolbarsWidgetForm)
71 m_ui->m_addToolButton->setIcon(QIcon::fromTheme(
"list-add"));
72 m_ui->m_removeToolButton->setIcon(QIcon::fromTheme(
"list-remove"));
73 m_ui->m_actionsListViewWidget->setSelectionMode(QAbstractItemView::SingleSelection);
79 connect (
m_ui->m_actionsListViewWidget->model(), SIGNAL(updateAction(QAction*,
const bool&)), SLOT(
updateActions(QAction*,
const bool&)));
81 m_resumeText = tr(
"Add, remove or modify system tool bars.");
94 for (
int i=0; i<m_ui->m_toolbarsComboBox->count(); i++)
96 QToolBar* bar = (QToolBar*) m_ui->m_toolbarsComboBox->itemData(i, Qt::UserRole).value<QObject*>();
98 bar->addActions(m_actions[i]);
104 std::set<QToolBar*>::iterator it;
106 for(it = m_createdBars.begin(); it != m_createdBars.end(); ++it)
118 m_createdBars.clear();
119 m_removedToolBars.clear();
121 changeApplyButtonState(
false);
128 m_createdBars.clear();
129 m_removedToolBars.clear();
132 m_ui->m_toolbarsComboBox->clear();
137 currentToolbarChanged(0);
142 ns =
"dpi.inpe.br.apf";
143 helpFile =
"apf/settings/toolbar/ToolbarConfig.html";
148 if(idx < 0 || m_actions.empty())
151 QList<QAction*> acts = m_actions[idx];
158 QString text = QInputDialog::getText(
this, tr(
"Creating tool bar"), tr(
"Tool bar name:"),
QLineEdit::Normal, tr(
"Name of the new toolbar"), &ok);
165 QMessageBox::warning(
this, tr(
"Creating tool bar"), tr(
"Empty tool bar name not allowed!"));
169 QToolBar* bar =
new QToolBar;
170 bar->setObjectName(text);
172 m_createdBars.insert(bar);
174 int count = m_ui->m_toolbarsComboBox->count();
176 m_ui->m_toolbarsComboBox->addItem(bar->objectName(), QVariant::fromValue<QObject*>(bar));
178 QList<QAction*> acts;
179 m_actions.push_back(acts);
181 changeApplyButtonState(
true);
183 m_ui->m_toolbarsComboBox->setCurrentIndex(count);
188 QString msg = tr(
"Did you really want to remove tool bar?");
190 if(QMessageBox::question(
this, tr(
"Tool bars customization"), msg, QMessageBox::No, QMessageBox::Yes) == QMessageBox::No)
193 int idx = m_ui->m_toolbarsComboBox->currentIndex();
195 QToolBar* bar = (QToolBar*)m_ui->m_toolbarsComboBox->itemData(idx, Qt::UserRole).value<QObject*>();
197 m_removedToolBars.insert(bar);
199 m_ui->m_toolbarsComboBox->removeItem(idx);
201 changeApplyButtonState(
true);
211 int idx = m_ui->m_toolbarsComboBox->currentIndex();
214 changeApplyButtonState(
true);
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
TEQTAFEXPORT void UpdateToolBarsInTheSettings()
Update plugins file.
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
void addToolBar(const QString &id, QToolBar *bar)
Register the toolbar in the list of the known toolbars and dispatch an event.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...