QTfrontend/ui/widget/frameTeam.cpp
changeset 13235 d5a029299407
parent 11046 47a8c19ecb60
child 13239 6fa6626eb273
equal deleted inserted replaced
13233:d23742ccf92b 13235:d5a029299407
    26 #include "teamselhelper.h"
    26 #include "teamselhelper.h"
    27 #include "hwconsts.h"
    27 #include "hwconsts.h"
    28 #include "DataManager.h"
    28 #include "DataManager.h"
    29 
    29 
    30 FrameTeams::FrameTeams(QWidget* parent) :
    30 FrameTeams::FrameTeams(QWidget* parent) :
    31     QFrame(parent), mainLayout(this), nonInteractive(false)
    31     QFrame(parent), mainLayout(this), nonInteractive(false),
       
    32     hasDecoFrame(false)
    32 {
    33 {
    33     QPalette newPalette = palette();
    34     QPalette newPalette = palette();
    34     newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00));
    35     newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00));
    35     setPalette(newPalette);
    36     setPalette(newPalette);
    36     setAutoFillBackground(true);
    37     setAutoFillBackground(true);
    71 //  int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
    72 //  int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
    72     mainLayout.addWidget(pTeamShowWidget);
    73     mainLayout.addWidget(pTeamShowWidget);
    73     teamToWidget.insert(team, pTeamShowWidget);
    74     teamToWidget.insert(team, pTeamShowWidget);
    74     QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
    75     QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
    75     QCoreApplication::postEvent(parentWidget(), pevent);
    76     QCoreApplication::postEvent(parentWidget(), pevent);
       
    77     updateDecoFrame();
    76 }
    78 }
    77 
    79 
    78 void FrameTeams::removeTeam(HWTeam team)
    80 void FrameTeams::removeTeam(HWTeam team)
    79 {
    81 {
    80     tmapTeamToWidget::iterator it=teamToWidget.find(team);
    82     tmapTeamToWidget::iterator it=teamToWidget.find(team);
    82     mainLayout.removeWidget(it.value());
    84     mainLayout.removeWidget(it.value());
    83     it.value()->deleteLater();
    85     it.value()->deleteLater();
    84     teamToWidget.erase(it);
    86     teamToWidget.erase(it);
    85     QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
    87     QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
    86     QCoreApplication::postEvent(parentWidget(), pevent);
    88     QCoreApplication::postEvent(parentWidget(), pevent);
       
    89     updateDecoFrame();
    87 }
    90 }
    88 
    91 
    89 void FrameTeams::resetTeams()
    92 void FrameTeams::resetTeams()
    90 {
    93 {
    91     for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); )
    94     for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); )
   132 
   135 
   133 QSize FrameTeams::sizeHint() const
   136 QSize FrameTeams::sizeHint() const
   134 {
   137 {
   135     return QSize(-1, teamToWidget.size() * 39 + 9);
   138     return QSize(-1, teamToWidget.size() * 39 + 9);
   136 }
   139 }
       
   140 
       
   141 void FrameTeams::setDecoFrameEnabled(bool enabled)
       
   142 {
       
   143     hasDecoFrame = enabled;
       
   144     updateDecoFrame();
       
   145 }
       
   146 
       
   147 void FrameTeams::updateDecoFrame()
       
   148 {
       
   149     if (hasDecoFrame && teamToWidget.size() >= 1)
       
   150     {
       
   151         setStyleSheet(
       
   152             "FrameTeams{"
       
   153             "border: solid;"
       
   154             "border-width: 1px;"
       
   155             "border-radius: 16px;"
       
   156             "border-color: #ffcc00;"
       
   157             "}"
       
   158         );
       
   159     }
       
   160     else
       
   161     {
       
   162         setStyleSheet("FrameTeams{ border: transparent }");
       
   163     }
       
   164 }