All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DisplayWidget.cpp
Go to the documentation of this file.
1 #include "../ApplicationController.h"
2 #include "../events/MapEvents.h"
3 #include "../Utils.h"
4 
5 #include "ui_DisplayWidgetForm.h"
6 #include "DisplayWidget.h"
7 
8 // Qt
9 #include <QColor>
10 #include <QColorDialog>
11 #include <QFrame>
12 #include <QPalette>
13 
14 // Boost
15 #include <boost/lexical_cast.hpp>
16 
18 AbstractSettingWidget(parent),
19 m_ui(new Ui::DisplayWidgetForm)
20 {
21  m_ui->setupUi(this);
22 
23  m_resumeText = tr("Configurations of the display");
24 
25  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
26  QString hexColor = sett.value("display/defaultDisplayColor").toString();
27  QColor dColor;
28  dColor.setNamedColor(hexColor);
29 
30  QPalette palette = m_ui->m_backColor->palette();
31 
32  if(!dColor.isValid())
33  {
34  palette.setColor(QPalette::Window, Qt::white);
35  }
36  else
37  {
38  palette.setColor(QPalette::Window, dColor);
39  }
40 
41  m_ui->m_backColor->setPalette(palette);
42  m_ui->m_backColor->setAutoFillBackground(true);
43 
44  connect(m_ui->m_changeBackgroundPushButton, SIGNAL(clicked()), SLOT(onChangeBackgroundPushButton()));
45 }
46 
48 {
49  delete m_ui;
50 }
51 
53 {
54  QColor color = QColorDialog::getColor(m_ui->m_backColor->palette().color(QPalette::Window), this);
55 
56  if(!color.isValid())
57  return;
58 
59  QPalette palette = m_ui->m_backColor->palette();
60  palette.setColor(QPalette::Window, color);
61  m_ui->m_backColor->setPalette(palette);
62  m_ui->m_backColor->setAutoFillBackground(true);
63 
64  changeApplyButtonState(true);
65 }
66 
68 {
69  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
70 
71  sett.setValue("display/defaultDisplayColor", m_ui->m_backColor->palette().color(QPalette::Window).name());
72 
73  te::qt::af::evt::MapColorChanged mapColorChanged(m_ui->m_backColor->palette().color(QPalette::Window));
74 
76 
77  changeApplyButtonState(false);
78 }
79 
81 {
82  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
83  QString hexColor = sett.value("display/defaultDisplayColor").toString();
84  QColor dColor;
85  dColor.setNamedColor(hexColor);
86 
87  QPalette palette = m_ui->m_backColor->palette();
88 
89  if(!dColor.isValid())
90  {
91  palette.setColor(QPalette::Window, Qt::white);
92  }
93  else
94  {
95  palette.setColor(QPalette::Window, dColor);
96  }
97 
98  m_ui->m_backColor->setPalette(palette);
99  m_ui->m_backColor->setAutoFillBackground(true);
100 }
101 
103 {
104  saveChanges();
105 }
106 
107 void te::qt::af::DisplayWidget::getHelpInformations(QString& ns, QString& helpFile)
108 {
109  ns = "dpi.inpe.br.apf";
110  helpFile = "apf/settings/display/DisplayConfig.html";
111 }
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This event signals that the color of the map display changed.
Definition: MapEvents.h:75
A frame for setting Table options.
virtual void getHelpInformations(QString &ns, QString &helpFile)
DisplayWidget(QWidget *parent=0)
A frame for setting display options.
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
Ui::DisplayWidgetForm * m_ui
Definition: DisplayWidget.h:74