source: flair-src/branches/mavlink/tools/FlairGCS/src/FormLayout.cpp @ 77

Last change on this file since 77 was 15, checked in by Bayard Gildas, 6 years ago

sources reformatted with flair-format-dir script

File size: 1.7 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5#include "FormLayout.h"
6#include "Layout.h"
7#include <QWidget>
8#include <QFormLayout>
9#include <QEvent>
10
11FormLayout::FormLayout(Layout *parent, int row, int col, QString name,
12                       QString type)
13    : XmlWidget(name, type, parent) {
14  visible_widget = new QWidget();
15
16  // create a grid to put label and object
17  visible_widget->setObjectName(name);
18
19  parent->addWidget(visible_widget, row, col);
20  object_layout = new QFormLayout(visible_widget);
21  object_layout->setHorizontalSpacing(2);
22  object_layout->setVerticalSpacing(2);
23  object_layout->setContentsMargins(2, 2, 2, 2);
24
25  visible_widget->installEventFilter(this);
26}
27
28FormLayout::~FormLayout() {}
29
30bool FormLayout::IsUptodate(void) {
31  // si le widget n'est pas enabled, sa palette est differente de rouge (greyed)
32  // donc on renvoit true
33  // permet de ne pas envoyer les modifs d'un widget disabled
34  // if(label->palette()==red_pal) return false;
35  if (visible_widget->palette() == red_pal)
36    return false;
37  return true;
38}
39
40bool FormLayout::eventFilter(QObject *o, QEvent *e) {
41  if (o == visible_widget) {
42    switch (e->type()) {
43    case QEvent::EnabledChange: {
44      QPalette palette = visible_widget->palette();
45      QPalette result;
46
47      if (palette == red_pal)
48        result = red_pal_greyed;
49      if (palette == red_pal_greyed)
50        result = red_pal;
51      if (palette == black_pal)
52        result = black_pal_greyed;
53      if (palette == black_pal_greyed)
54        result = black_pal;
55
56      visible_widget->setPalette(result);
57    }
58
59    default:
60      break;
61    }
62  }
63  return QObject::eventFilter(o, e);
64}
Note: See TracBrowser for help on using the repository browser.