Commit 994a2970 authored by saubatn's avatar saubatn
Browse files

UPDATE Default Widget has now name / description label that can be hidden...

UPDATE Default Widget has now name / description label that can be hidden (ajustable visibility, true by default).

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@119 ec899d31-69d1-42ba-9299-647d76f65fb3
parent daea682a
......@@ -41,17 +41,17 @@ DefaultActionWidget::DefaultActionWidget(Action *action): QFrame() {
QLabel *iconPicture = new QLabel;
iconPicture->setPixmap(myAction->getIcon());
nameLayout->addWidget(iconPicture);
QLabel *actionName = new QLabel(myAction->getName());
nameLayout->addWidget(actionName);
actionNameLabel= new QLabel(myAction->getName());
nameLayout->addWidget(actionNameLabel);
widgetLayout->addLayout(nameLayout);
// get the proper text height
actionName->adjustSize();
actionNameLabel->adjustSize();
// fix the icon height
iconPicture->setFixedSize(actionName->height(),actionName->height());
iconPicture->setFixedSize(actionNameLabel->height(), actionNameLabel->height());
iconPicture->setScaledContents(true);
QLabel *descriptionLabel = new QLabel("Description : " + myAction->getDescription());
descriptionLabel = new QLabel("Description : " + myAction->getDescription());
descriptionLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
descriptionLabel->setLineWidth(3);
descriptionLabel->setWordWrap(true);
......@@ -104,6 +104,16 @@ void DefaultActionWidget::setButtonVisibility(bool visible) {
buttonFrame->setVisible(visible);
}
void DefaultActionWidget::setNameVisibility(bool visible)
{
this->actionNameLabel->setVisible(visible);
}
void DefaultActionWidget::setDescriptionVisibility(bool visible)
{
this->descriptionLabel->setVisible(visible);
}
// -------------------- updateObjectController --------------------
void DefaultActionWidget::update() {
// force update
......
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef DEFAULTACTIONWIDGET_H
#define DEFAULTACTIONWIDGET_H
......@@ -40,49 +40,63 @@ class Action;
class ObjectController;
/** Build a default widget for a given action using its Qt properties.
* It should be good enough in most of the case.
* The default widget contains a description, a reminder of the target component names,
* and an applyable/revertable ObjectController that allows you to edit/modify properties
* of the action.
*
* The button frame contains an "Apply" and a "Revert" button. The Apply button updates
* the action properties using the value entered by the user in the GUI. I.e., its clicked()
* signal is connected the the action applySlot() slot.
* The revert button resets the values in GUI to the initial values (all modification in the GUI
* are cancelled).
* You can easily show or hide the button frame usint setButtonVisibility()
*
* update() updates the widget using the actual/current properties and target of the action.
* This method should be called by an action in the overriden getWidget method.
* A typical getWidget() method of an action should use the lazy instanciation pattern to instanciate
* DefaultActionWidget the first time it is called, and call the DefaultActionWidget instance update() method
* for any subsequent calls.
*/
* It should be good enough in most of the case.
* The default widget contains a description, a reminder of the target component names,
* and an applyable/revertable ObjectController that allows you to edit/modify properties
* of the action.
*
* The button frame contains an "Apply" and a "Revert" button. The Apply button updates
* the action properties using the value entered by the user in the GUI. I.e., its clicked()
* signal is connected the the action applySlot() slot.
* The revert button resets the values in GUI to the initial values (all modification in the GUI
* are cancelled).
* You can easily show or hide the button frame usint setButtonVisibility()
*
* update() updates the widget using the actual/current properties and target of the action.
* This method should be called by an action in the overriden getWidget method.
* A typical getWidget() method of an action should use the lazy instanciation pattern to instanciate
* DefaultActionWidget the first time it is called, and call the DefaultActionWidget instance update() method
* for any subsequent calls.
*/
class CAMITK_API DefaultActionWidget : public QFrame {
public:
/// create a default action widget for the given action
DefaultActionWidget(Action *);
/// create a default action widget for the given action
DefaultActionWidget(Action *);
virtual ~DefaultActionWidget();
virtual ~DefaultActionWidget();
/// update display (target and property controller)
void update();
/// update display (target and property controller)
void update();
/// if false then the apply/revert buttons are shown
void setButtonVisibility(bool);
/// if false then the apply/revert buttons are shown
void setButtonVisibility(bool);
/// defines whether the name of the widget is visible or not
/// true by default
void setNameVisibility(bool visible);
/// defines whether the description of the widget is visible or not
/// true by default
void setDescriptionVisibility(bool visible);
private:
/// the managed action
Action *myAction;
/// the managed action
Action *myAction;
/// the object controller with the properties of the default widget
ObjectController * objectController;
/// the target list label
QLabel *targetLabel;
/// the object controller with the properties of the default widget
ObjectController * objectController;
/// the target list label
QLabel *targetLabel;
/// the action name displayed in the widget
QLabel *actionNameLabel;
/// the description of the action displayed in the widget
QLabel *descriptionLabel;
/// this frame contains the Apply/Revert buttons and can be hide using setButtonVisibility()
QFrame *buttonFrame;
/// this frame contains the Apply/Revert buttons and can be hide using setButtonVisibility()
QFrame *buttonFrame;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment