#include <QGroupBox>
#include <QLabel>
#include <QMap>
+#include <QSizePolicy>
+#include <QPalette>
+#include <QFont>
#include <QToolButton>
#include <QVBoxLayout>
QGroupBox* group;
};
+class QtxInfoPanel::TitleLabel: public QLabel
+{
+public:
+ TitleLabel(const QString &text, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
+ QLabel(text, parent, f){
+ this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ QString color_bg = this->palette().color(QPalette::Highlight).darker().name();
+ QString color_fg = this->palette().color(QPalette::HighlightedText).name();
+ this->setStyleSheet(QString("QLabel {{background:%1; color:%2;}}").arg(color_bg).arg(color_fg));
+ this->setTextFormat(Qt::PlainText);
+ QFont font= QFont();
+ font.setBold(true);
+ this->setFont(font);
+ this->setContentsMargins(2, 5, 2, 5);
+ }
+};
+
QtxInfoPanel::Container::Container( QWidget* parent )
: QWidget( parent ), group( 0 )
{
{
container = new Container( this );
QVBoxLayout* layout = new QVBoxLayout(this);
+ title = new TitleLabel("");
layout->setMargin( 0 );
+ layout->addWidget( title );
layout->addWidget( container );
layout->addStretch();
+ title->setVisible(!title->text().isEmpty());
}
QtxInfoPanel::~QtxInfoPanel()
return id;
}
+void QtxInfoPanel::setTitle( const QString& text )
+{
+ title->setText(text);
+ title->setVisible(!title->text().isEmpty());
+}
+
void QtxInfoPanel::remove( const int id )
{
QWidget* widget = find( id );
if ( widget )
{
Container* group = dynamic_cast<Container*>( widget->parentWidget() );
- if ( group )
+ if ( !group )
+ {
+ group = dynamic_cast<Container*>( widget->parentWidget()->parentWidget() );
+ group->remove( id );
+ }
+ else
group->remove( id );
}
}
Q_OBJECT
class Container;
+ class TitleLabel;
public:
QtxInfoPanel( QWidget* = 0 );
~QtxInfoPanel();
int addLabel( const QString&, const int = -1 );
- int addLabel( const QString&, Qt::Alignment = Qt::AlignLeft, const int = -1 );
+ int addLabel( const QString&, Qt::Alignment, const int = -1 );
int addAction( QAction*, const int = -1 );
int addGroup( const QString&, const int = -1 );
+ void setTitle( const QString& );
void remove( const int );
void clear( const int = -1 );
private:
Container* container;
+ TitleLabel* title;
};
#ifdef WIN32