Adds activeTabChanged() signal to let API users know about this state
change. It might be use to re-polish style sheets.
This commit is contained in:
@@ -13,23 +13,25 @@ IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidge
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(l);
|
||||
|
||||
// Icon label
|
||||
if (icon.isNull())
|
||||
{
|
||||
// QLabel* titleIcon = new QLabel();
|
||||
// titleIcon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(16, 16));
|
||||
// l->addWidget(titleIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
QLabel* titleIcon = new QLabel();
|
||||
titleIcon->setPixmap(icon.pixmap(16, 16));
|
||||
l->addWidget(titleIcon);
|
||||
}
|
||||
_iconLabel = new QLabel();
|
||||
if (!icon.isNull())
|
||||
_iconLabel->setPixmap(icon.pixmap(16, 16));
|
||||
l->addWidget(_iconLabel);
|
||||
|
||||
// Title label
|
||||
QLabel* titleText = new QLabel(title);
|
||||
QFont titleFont = titleText->font();
|
||||
titleText->setFont(titleFont);
|
||||
l->addWidget(titleText, 1);
|
||||
_titleLabel = new QLabel();
|
||||
_titleLabel->setText(title);
|
||||
l->addWidget(_titleLabel, 1);
|
||||
}
|
||||
|
||||
void IconTitleWidget::polishUpdate()
|
||||
{
|
||||
QList<QWidget*> widgets;
|
||||
widgets.append(_iconLabel);
|
||||
widgets.append(_titleLabel);
|
||||
foreach (QWidget* w, widgets)
|
||||
{
|
||||
w->style()->unpolish(w);
|
||||
w->style()->polish(w);
|
||||
w->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,19 @@
|
||||
#include <QFrame>
|
||||
class QIcon;
|
||||
class QString;
|
||||
class QLabel;
|
||||
|
||||
class IconTitleWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);
|
||||
void polishUpdate();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
public:
|
||||
QLabel* _iconLabel;
|
||||
QLabel* _titleLabel;
|
||||
};
|
||||
|
||||
#endif // ICONTITLEWIDGET_H
|
||||
|
||||
@@ -12,8 +12,8 @@ int main(int argc, char *argv[])
|
||||
//Q_INIT_RESOURCE(ads);
|
||||
|
||||
// Load style sheet
|
||||
QFile f(":/stylesheets/default-windows.css");
|
||||
// QFile f(":/stylesheets/vendor-partsolutions.css");
|
||||
// QFile f(":/stylesheets/default-windows.css");
|
||||
QFile f(":/stylesheets/vendor-partsolutions.css");
|
||||
if (f.open(QFile::ReadOnly))
|
||||
{
|
||||
QByteArray ba = f.readAll();
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
#include <QTreeView>
|
||||
#include <QFileSystemModel>
|
||||
|
||||
#include "ads/ContainerWidget.h"
|
||||
#include "ads/SectionWidget.h"
|
||||
#include "ads/SectionContent.h"
|
||||
|
||||
#include "icontitlewidget.h"
|
||||
|
||||
@@ -95,6 +93,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
_container = new ADS_NS::ContainerWidget();
|
||||
_container->setOrientation(Qt::Vertical);
|
||||
QObject::connect(_container, &ADS_NS::ContainerWidget::activeTabChanged, this, &MainWindow::onActiveTabChanged);
|
||||
setCentralWidget(_container);
|
||||
|
||||
// Test #1: Use high-level public API
|
||||
@@ -122,6 +121,15 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bool active)
|
||||
{
|
||||
IconTitleWidget* itw = dynamic_cast<IconTitleWidget*>(sc->titleWidget());
|
||||
if (itw)
|
||||
{
|
||||
itw->polishUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onActionAddSectionContentTriggered()
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "ads/API.h"
|
||||
#include "ads/ContainerWidget.h"
|
||||
#include "ads/SectionContent.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
class ContainerWidget;
|
||||
ADS_NAMESPACE_END
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -21,6 +19,7 @@ public:
|
||||
virtual ~MainWindow();
|
||||
|
||||
private slots:
|
||||
void onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bool active);
|
||||
void onActionAddSectionContentTriggered();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user