diff -r 8c93d8e38494 -r 88a03c1a52d9 gui.h --- a/gui.h Mon May 06 00:10:56 2013 +0300 +++ b/gui.h Mon May 06 03:31:03 2013 +0300 @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include "gldraw.h" #include "config.h" @@ -183,6 +185,37 @@ void slot_lastSecondCleanup (); }; +// ============================================================================= +// LabeledWidget +// +// Convenience class for a widget with a label beside it. +// ============================================================================= +template class LabeledWidget : public QWidget { +public: + LabeledWidget (const char* labelstr, QWidget* parent) : QWidget (parent) { + m_widget = new R (this); + m_label = new QLabel (labelstr, this); + + m_layout = new QHBoxLayout; + m_layout->addWidget (m_label); + m_layout->addWidget (m_widget); + setLayout (m_layout); + } + + R* widget () const { return m_widget; } + R* w () const { return m_widget; } + QLabel* label () const { return m_label; } + QLabel* l () const { return m_label; } + void setWidget (R* widget) { m_widget = widget; } + void setLabel (QLabel* label) { m_label = label; } + operator R* () { return m_widget; } + +private: + R* m_widget; + QLabel* m_label; + QHBoxLayout* m_layout; +}; + // ----------------------------------------------------------------------------- // Other GUI-related stuff not directly part of ForgeWindow: QPixmap getIcon (const char* sIconName);