51 #include <OpenFlipper/common/RendererInfo.hh>
54 #if QT_VERSION >= 0x050000
60 #include "postProcessorWidget.hh"
63 PostProcessorDialog::PostProcessorDialog(QWidget *_parent)
68 list->setContextMenuPolicy(Qt::CustomContextMenu);
69 activeList->setContextMenuPolicy(Qt::CustomContextMenu);
71 connect(closeButton, SIGNAL(clicked()),
this, SLOT(accept()));
72 connect(list,SIGNAL(customContextMenuRequested(
const QPoint&)),
this,SLOT(slotContextMenuActivate(
const QPoint&)));
73 connect(activeList,SIGNAL(customContextMenuRequested(
const QPoint&)),
this,SLOT(slotContextMenuDeactivate(
const QPoint&)));
74 connect(activateButton,SIGNAL(clicked()),
this,SLOT(slotActivatePostProcessor()));
75 connect(deactivateButton,SIGNAL(clicked()),
this,SLOT(slotDeactivatePostProcessor()));
76 connect(upButton,SIGNAL(clicked()),
this,SLOT(slotMoveUp()));
77 connect(downButton,SIGNAL(clicked()),
this,SLOT(slotMoveDown()));
78 connect(saveButton,SIGNAL(clicked()),
this,SLOT(slotSaveActive()));
79 connect(refreshButton,SIGNAL(clicked()),
this,SLOT(refresh()));
82 QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
84 closeButton->setIcon( QIcon(iconPath +
"window-close.png"));
85 saveButton->setIcon( QIcon(iconPath +
"document-save.png"));
86 refreshButton->setIcon( QIcon(iconPath +
"edit-redo.png"));
90 void PostProcessorDialog::closeEvent(QCloseEvent *_event)
96 void PostProcessorDialog::showEvent ( QShowEvent * )
114 QListWidgetItem *activeItem =
new QListWidgetItem(
"");
115 activeList->addItem(activeItem);
116 QFrame* frame = createFrame(*postProcessorManager()[
id]);
117 activeItem->setSizeHint(frame->sizeHint());
118 activeList->setItemWidget(activeItem,frame);
122 for (
unsigned int i = 0 ; i < postProcessorManager().
available() ; ++i)
130 QFrame* frame = createFrame(*processor);
132 QListWidgetItem *item =
new QListWidgetItem(
"");
133 item->setSizeHint( frame->sizeHint() );
137 list->setItemWidget(item, frame);
142 found = (*iter == i);
144 list->setRowHidden(list->row(item),
true);
151 QList<QListWidgetItem*> selectedItems = list->selectedItems();
153 for (
int i=0; i < selectedItems.size(); ++i)
155 QListWidgetItem* item = selectedItems[i];
156 const int currentRow = list->row( item );
161 item->setHidden(
true);
162 item->setSelected(
false);
165 QListWidgetItem *activeItem =
new QListWidgetItem(
"");
166 activeList->addItem(activeItem);
167 activeItem->setSelected(
true);
169 QFrame* frame = createFrame(*postProcessorManager()[currentRow]);
170 activeItem->setSizeHint( frame->sizeHint() );
171 activeList->setItemWidget(activeItem,frame);
181 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
183 for (
int i=0; i < selectedItems.size(); ++i)
185 QListWidgetItem* activeItem = selectedItems[i];
187 const unsigned chainPos = activeList->row(activeItem);
189 QListWidgetItem* item = list->item(activeID);
195 item->setHidden(
false);
196 item->setSelected(
true);
204 activeItem = activeList->takeItem(activeList->row(activeItem));
215 if (_from >= static_cast<unsigned>(activeList->count()))
218 if (_to >= static_cast<unsigned>(activeList->count()))
219 _to = activeList->count()-1;
225 QListWidgetItem* activeItem = activeList->takeItem(_from);
226 activeList->insertItem(_to,activeItem);
227 QFrame* frame = createFrame(*postProcessorManager()[
activeRowToRow_[_from]]);
228 activeItem->setSizeHint(frame->sizeHint());
229 activeList->setItemWidget(activeItem,frame);
230 activeList->setItemSelected(activeItem,
true);
233 const int chainPos = _from;
239 int inc = (_from > _to)? -1: +1;
240 for(
unsigned int currentRow = _from;currentRow != _to; currentRow += inc)
252 QMenu *menu =
new QMenu(list);
255 action = menu->addAction(tr(
"Activate"));
258 menu->exec(list->mapToGlobal(_point),0);
264 if (!activeList->count())
267 QMenu *menu =
new QMenu(activeList);
270 action = menu->addAction(tr(
"Up"));
271 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(
slotMoveUp()));
272 action = menu->addAction(tr(
"Down"));
273 connect(action,SIGNAL(triggered(
bool)),
this,SLOT(
slotMoveDown()));
274 action = menu->addAction(tr(
"Deactivate"));
277 menu->exec(activeList->mapToGlobal(_point),0);
283 QFrame* frame =
new QFrame();
284 QHBoxLayout* hlayout =
new QHBoxLayout;
286 QLabel* name =
new QLabel( _pPI.
name );
289 font.setPointSize(10);
291 QLabel* version =
new QLabel( _pPI.
version );
292 QPushButton* optionsButton =
new QPushButton(
"Options");
293 hlayout->addWidget(name);
294 hlayout->addStretch();
295 hlayout->addWidget(version);
297 optionsButton->setEnabled(
false);
300 optionsButton->setEnabled(
true);
301 connect(optionsButton,SIGNAL(clicked()),_pPI.
optionsAction,SLOT(trigger()));
304 QVBoxLayout* vlayout =
new QVBoxLayout;
306 QLabel* description =
new QLabel( _pPI.
description );
308 vlayout->addLayout(hlayout,20);
310 QHBoxLayout* optionsLayout =
new QHBoxLayout();
311 vlayout->addLayout(optionsLayout);
312 optionsLayout->addWidget(description);
313 optionsLayout->addStretch();
314 optionsLayout->addWidget(optionsButton);
316 frame->setLayout(vlayout);
324 template<
typename TCmp>
330 bool operator()(QListWidgetItem* left, QListWidgetItem* right)
332 return TCmp()(list_->row(left) , list_->row(right));
339 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
346 for(
int i=0; i < selectedItems.size() && activeList->row(selectedItems[i]) == activeList->count()-1-i;++i)
350 for (
int i=selectedItems.size()-1+start; i >= 0 ; --i)
352 QListWidgetItem* activeItem = activeList->selectedItems()[i];
353 unsigned selectedRow = activeList->row(activeItem);
362 QList<QListWidgetItem*> selectedItems = activeList->selectedItems();
369 for(
int i=0; i < selectedItems.size() && activeList->row(selectedItems[i]) == i;++i)
373 for (
int i=start; i < selectedItems.size(); ++i)
375 QListWidgetItem* activeItem = selectedItems[i];
376 unsigned selectedRow = activeList->row(activeItem);
383 QStringList activeList(
"");
388 activeList.push_back(postProcessorManager()[
id]->name);
396 return OpenFlipperSettings().
value(QString(
"PostProcessor/Viewer/%1").arg(_examiner),QStringList(
"")).toStringList();
402 for (QStringList::iterator iter = active.begin(); iter != active.end(); ++iter)
404 postProcessorManager().
append(*iter,_examiner);
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
void remove(int _id, int _chainIdx)
Remove a post processor at the specified chain index.
QString name
Name of the plugin ( requested from the plugin on load)
unsigned int available()
number of available post processor
void append(unsigned int _active, int _viewerId)
Append the active post processor to the chain for viewer.
void slotContextMenuActivate(const QPoint &_point)
Show the custom context menu for activation.
void insert(unsigned int _active, int _chainIdx, int _viewerId)
Insert the active post processor to the chain for viewer.
QString description
Description of the plugin.
int numActive(int _id)
Get the number of active post processors for viewer.
unsigned currentExaminer_
holds the examiner id for the window
std::vector< unsigned > activeRowToRow_
maps activeRow from activeList (same as chainIdx from RendererInfo) to row from list (same as activeI...
QString version
Version of the plugin.
void updateExaminer(unsigned _viewer)
request an update for an specified viewer
static void loadSavedPostProcessors(const unsigned _examiner)
append all saved post processors
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void slotContextMenuDeactivate(const QPoint &_point)
Show the custom context menu for deactivation.
void slotDeactivatePostProcessor()
Deactivates the current postProcessor.
void refresh()
refreshes the content of the dialog with current examiner
void slotMoveUp()
move the selected active postprocessor 1 up
QAction * optionsAction
Possible action to add an options action or menu to the system.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void slotMovePostProcessor(unsigned _from, unsigned _to)
Move the position/ordering of postprocessor in the postprocessor.
void slotMoveDown()
move the selected active postprocessor 1 down
void initWindow()
initiaize the window with the post processors of the current examiner
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void slotSaveActive()
saves active post processor chain
unsigned int activeId(int _id, int _chainIdx=0)
Get the id of the active post processor for viewer at chain index.
void slotActivatePostProcessor()
Activates the post processor (triggered via the context menu)
static QStringList getSavedPostProcessorNames(const unsigned _examiner)
return the names of all saved post processors