Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/2480_show_required_props_and_default_vals_in_al…
…g_diags' into develop Conflicts: Code/Mantid/MantidQt/API/CMakeLists.txt Refs #2480.
- Loading branch information
Showing
16 changed files
with
202 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Code/Mantid/MantidQt/API/inc/MantidQtAPI/PropertyInfoWidget.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef MANTID_API_PROPERTYINFOWIDGET_H | ||
#define MANTID_API_PROPERTYINFOWIDGET_H | ||
|
||
#include <QFrame> | ||
#include <QMap> | ||
#include <QLabel> | ||
|
||
namespace MantidQt | ||
{ | ||
namespace API | ||
{ | ||
/** | ||
* A widget used in dialogs to display various information about a property. | ||
*/ | ||
class PropertyInfoWidget : public QFrame | ||
{ | ||
Q_OBJECT; | ||
|
||
public: | ||
/// Enumerating the info that can be displayed by this widget. | ||
enum Info { INVALID, REPLACE, RESTORE }; | ||
|
||
/// Constructor. | ||
PropertyInfoWidget(QWidget *parent = 0); | ||
|
||
/// Set the given icon's visibility. | ||
void setInfoVisible( Info info, bool visible ); | ||
/// Set the given icon's tool tip. | ||
void setInfoToolTip( Info info, const QString & toolTip ); | ||
|
||
private: | ||
/// Map enum to labels. | ||
QMap<Info, QLabel *> m_labels; | ||
}; | ||
} | ||
} | ||
|
||
#endif /* MANTID_API_PROPERTYINFOWIDGET_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "MantidQtAPI/PropertyInfoWidget.h" | ||
|
||
#include <QHBoxLayout> | ||
#include <QIcon> | ||
#include <QPair> | ||
|
||
namespace MantidQt | ||
{ | ||
namespace API | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param parent :: this widget's parent | ||
*/ | ||
PropertyInfoWidget::PropertyInfoWidget(QWidget *parent) | ||
: QFrame(parent), m_labels() | ||
{ | ||
setLayout(new QHBoxLayout(this)); | ||
layout()->setSpacing(1); | ||
layout()->setContentsMargins(0, 0, 0, 0); | ||
|
||
QMap<Info, QPair<QString, QString>> pathsAndToolTips; | ||
pathsAndToolTips[REPLACE] = QPair<QString, QString>(":/replace.png", "A workspace with this name already exists and so will be overwritten."); | ||
pathsAndToolTips[RESTORE] = QPair<QString, QString>(":/restore.png", "This was a previously-entered value."); | ||
|
||
foreach( const auto info, pathsAndToolTips.keys() ) | ||
{ | ||
const QString iconPath = pathsAndToolTips[info].first; | ||
const QString toolTip = pathsAndToolTips[info].second; | ||
|
||
auto label = new QLabel(this); | ||
label->setPixmap(QPixmap(iconPath).scaledToHeight(15)); | ||
label->setVisible(false); | ||
label->setToolTip(toolTip); | ||
|
||
layout()->addWidget(label); | ||
m_labels[info] = label; | ||
} | ||
|
||
auto label = new QLabel("*"); | ||
auto palette = label->palette(); | ||
palette.setColor(QPalette::WindowText, Qt::darkRed); | ||
label->setPalette(palette); | ||
label->setVisible(false); | ||
layout()->addWidget(label); | ||
m_labels[INVALID] = label; | ||
} | ||
|
||
/** | ||
* Set the given icon's visibility. | ||
* | ||
* @param icon :: icon to set | ||
* @param visible :: whether or not the icon should be visible | ||
*/ | ||
void PropertyInfoWidget::setInfoVisible( Info info, bool visible ) | ||
{ | ||
m_labels[info]->setVisible(visible); | ||
} | ||
|
||
/** | ||
* Set the given icon's tool tip. | ||
* | ||
* @param icon :: icon to set | ||
* @param toolTip :: the contents of the tool tip | ||
*/ | ||
void PropertyInfoWidget::setInfoToolTip( Info info, const QString & toolTip ) | ||
{ | ||
m_labels[info]->setToolTip(toolTip); | ||
} | ||
|
||
}//namespace | ||
}//namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.