Skip to content

Commit

Permalink
Merge pull request BlueQuartzSoftware#15 from imikejackson/feature/0_…
Browse files Browse the repository at this point in the history
…StatusBarWidgets

Add buttons to the StatusBar to toggle the Issues, Console and DataStructure
  • Loading branch information
imikejackson authored Jun 16, 2017
2 parents 46520da + 9ef403f commit 6bd9b63
Show file tree
Hide file tree
Showing 5 changed files with 420 additions and 20 deletions.
15 changes: 15 additions & 0 deletions Source/Applications/SIMPLView/SIMPLView_UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,17 @@ void SIMPLView_UI::setupGui()
pipelineViewWidget->addPipelineMessageObserver(issuesWidget);
startPipelineBtn->setStyleSheet(getStartPipelineIdleStyle());
startPipelineBtn->setDisabled(true);


m_StatusBar = new StatusBarWidget();
this->statusBar()->insertPermanentWidget(0, m_StatusBar, 0);

m_StatusBar->setButtonAction(issuesDockWidget, StatusBarWidget::Button::Issues);
m_StatusBar->setButtonAction(stdOutDockWidget, StatusBarWidget::Button::Console);
m_StatusBar->setButtonAction(dataBrowserDockWidget, StatusBarWidget::Button::DataStructure);

connect(issuesWidget, SIGNAL(tableHasErrors(bool)), m_StatusBar, SLOT(issuesTableHasErrors(bool)));
connect(issuesWidget, SIGNAL(tableHasErrors(bool)), issuesDockWidget, SLOT(setVisible(bool)));
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1140,9 +1151,11 @@ void SIMPLView_UI::cleanupPipeline()
// -----------------------------------------------------------------------------
void SIMPLView_UI::insertDockWidgetActions(QMenu* menu)
{
#if 0
menu->addAction(issuesDockWidget->toggleViewAction());
menu->addAction(stdOutDockWidget->toggleViewAction());
menu->addAction(dataBrowserDockWidget->toggleViewAction());
#endif
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1172,9 +1185,11 @@ QList<QAction*> SIMPLView_UI::getDummyDockWidgetActions()
// -----------------------------------------------------------------------------
void SIMPLView_UI::removeDockWidgetActions(QMenu* menu)
{
#if 0
menu->removeAction(issuesDockWidget->toggleViewAction());
menu->removeAction(stdOutDockWidget->toggleViewAction());
menu->removeAction(dataBrowserDockWidget->toggleViewAction());
#endif
}

// -----------------------------------------------------------------------------
Expand Down
129 changes: 126 additions & 3 deletions Source/Applications/SIMPLView/StatusBarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <QtCore/QDebug>
#include <QtWidgets/QDockWidget>

#include "SVWidgetsLib/QtSupport/QtSStyles.h"

// Include the MOC generated CPP file which has all the QMetaObject methods/data
#include "moc_StatusBarWidget.cpp"

Expand All @@ -48,6 +50,7 @@ StatusBarWidget::StatusBarWidget(QWidget* parent)
: QFrame(parent)
{
this->setupUi(this);
setupGui();
}

// -----------------------------------------------------------------------------
Expand All @@ -57,12 +60,111 @@ StatusBarWidget::~StatusBarWidget()
{
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatusBarWidget::setupGui()
{
QString style = generateStyleSheet(false);
consoleBtn->setStyleSheet(style);
issuesBtn->setStyleSheet(style);
dataBrowserBtn->setStyleSheet(style);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatusBarWidget::updateStyle()
{
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QString StatusBarWidget::generateStyleSheet(bool error)
{
QFont font = QtSStyles::GetBrandingLabelFont();
QString fontString;
QTextStream fontStringStream(&fontString);

fontStringStream << "font: " << font.weight() << " ";
#if defined(Q_OS_MAC)
fontStringStream << font.pointSize();
#elif defined(Q_OS_WIN)
fontStringStream << font.pointSize();
#else
fontStringStream << font.pointSize();
#endif
fontStringStream << "pt \"" << font.family() << "\";";

QString style;
QTextStream ss(&style);

QColor offBgColor(200, 200, 200);
QColor onBgColor(90, 90, 90);
QColor offTextColor(50, 50, 50);
QColor onTextColor(240, 240, 240);
QColor offBorderColor(120, 120, 120);
QColor onBorderColor(200, 200, 200);

if(error)
{
offBgColor = QColor(255, 150, 150);
onBgColor = QColor(220, 60, 60);
offBorderColor = QColor(220, 0, 0);
onBorderColor = QColor(200, 0, 0);
}

int borderRadius = 3;

ss << "QPushButton {";
ss << fontString;
ss << "background-color: " << offBgColor.name() << ";";
ss << "color:" << offTextColor.name() << ";";
ss << "border: 1px solid " << offBorderColor.name() << ";";
ss << "border-radius: " << borderRadius << "px;";
ss << "padding: 1 8 1 8px;";
ss << "margin: 2 2 2 2px;";
ss << "}";

ss << "QPushButton:hover {";
ss << fontString;
ss << "background-color: " << offBgColor.name() << ";";
ss << "color:" << offTextColor.name() << ";";
ss << "border: 2px solid " << offBorderColor.name() << ";";
ss << "border-radius: " << borderRadius << "px;";
ss << "padding: 1 8 1 8px;";
ss << "margin: 1 1 1 1px;";
ss << "}";

ss << "QPushButton:checked {";
ss << fontString;
ss << "background-color: " << onBgColor.name() << ";";
ss << "color:" << onTextColor.name() << ";";
ss << "border: 1px solid " << onBorderColor.name() << ";";
ss << "border-radius: " << borderRadius << "px;";
ss << "padding: 1 8 1 8px;";
ss << "margin: 2 2 2 2px;";
ss << "}";

ss << "QPushButton:checked:hover {";
ss << fontString;
ss << "background-color: " << onBgColor.name() << ";";
ss << "color:" << onTextColor.name() << ";";
ss << "border: 1px solid " << onBorderColor.name() << ";";
ss << "border-radius: " << borderRadius << "px;";
ss << "padding: 1 8 1 8px;";
ss << "margin: 1 1 1 1px;";
ss << "}";

return style;
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatusBarWidget::issuesVisibilityChanged(bool b)
{
//qDebug() << "issuesVisibilityChanged" << static_cast<int>(b);
issuesBtn->blockSignals(true);
issuesBtn->setChecked(b);
issuesBtn->blockSignals(false);
Expand All @@ -73,7 +175,6 @@ void StatusBarWidget::issuesVisibilityChanged(bool b)
// -----------------------------------------------------------------------------
void StatusBarWidget::consolVisibilityChanged(bool b)
{
// qDebug() << "consolVisibilityChanged" << static_cast<int>(b);
consoleBtn->blockSignals(true);
consoleBtn->setChecked(b);
consoleBtn->blockSignals(false);
Expand All @@ -84,12 +185,21 @@ void StatusBarWidget::consolVisibilityChanged(bool b)
// -----------------------------------------------------------------------------
void StatusBarWidget::dataBrowserVisibilityChanged(bool b)
{
// qDebug() << "dataBrowserVisibilityChanged" << static_cast<int>(b);
dataBrowserBtn->blockSignals(true);
dataBrowserBtn->setChecked(b);
dataBrowserBtn->blockSignals(false);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatusBarWidget::toolboxVisibilityChanged(bool b)
{
// toolboxBtn->blockSignals(true);
// toolboxBtn->setChecked(b);
// toolboxBtn->blockSignals(false);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
Expand All @@ -109,5 +219,18 @@ void StatusBarWidget::setButtonAction(QDockWidget* dock, Button btn)
connect(dataBrowserBtn, SIGNAL(toggled(bool)), dock, SLOT(setVisible(bool)));
connect(dock, SIGNAL(visibilityChanged(bool)), this, SLOT(dataBrowserVisibilityChanged(bool)));
break;
case Button::Toolbox:
// connect(toolboxBtn, SIGNAL(toggled(bool)), dock, SLOT(setVisible(bool)));
// connect(dock, SIGNAL(visibilityChanged(bool)), this, SLOT(dataBrowserVisibilityChanged(bool)));
break;
}
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatusBarWidget::issuesTableHasErrors(bool b)
{
QString style = generateStyleSheet(b);
issuesBtn->setStyleSheet(style);
}
37 changes: 33 additions & 4 deletions Source/Applications/SIMPLView/StatusBarWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

#ifndef _StatusBarWidget_h_
#define _StatusBarWidget_h_
#ifndef _statusBarWidget_h_
#define _statusBarWidget_h_

#include <QtWidgets/QFrame>

Expand All @@ -58,7 +58,8 @@ class StatusBarWidget : public QFrame, private Ui::StatusBarWidget
{
Issues = 0,
Console = 1,
DataStructure = 2
DataStructure = 2,
Toolbox = 3
};


Expand All @@ -69,6 +70,17 @@ class StatusBarWidget : public QFrame, private Ui::StatusBarWidget
*/
void setButtonAction(QDockWidget *dock, Button btn);

/**
* @brief updateStyle
*/
void updateStyle();

/**
* @brief generateStyleSheet
* @param error
* @return
*/
QString generateStyleSheet(bool error);

public slots:
/**
Expand All @@ -87,11 +99,28 @@ class StatusBarWidget : public QFrame, private Ui::StatusBarWidget
*/
void dataBrowserVisibilityChanged(bool b);

/**
* @brief toolboxVisibilityChanged
* @param b
*/
void toolboxVisibilityChanged(bool b);

/**
* @brief issuesTableHasErrors
* @param b
*/
void issuesTableHasErrors(bool b);

protected:

/**
* @brief setupGui
*/
void setupGui();

private:
StatusBarWidget(const StatusBarWidget&); // Copy Constructor Not Implemented
void operator=(const StatusBarWidget&); // Operator '=' Not Implemented
};

#endif /* StatusBarWidget_H_ */
#endif /* _statusBarWidget_H_ */
Loading

0 comments on commit 6bd9b63

Please sign in to comment.