ff7tk  0.02
Toolkit for making FF7 Tools
DoubleCheckBox.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // copyright 2012 -2016 Chris Rizzitello <sithlord48@gmail.com> //
3 // //
4 // This file is part of FF7tk //
5 // //
6 // FF7tk is free software: you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation, either version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // FF7tk is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License for more details. //
15 /****************************************************************************/
16 
17 #include "DoubleCheckBox.h"
18 DoubleCheckBox::DoubleCheckBox(qreal Scale,QWidget *parent) :
19  QWidget(parent)
20 {
21  scale=Scale;
22  init_display();
24 }
25 DoubleCheckBox::DoubleCheckBox(const QString &text,qreal Scale,QWidget *parent ) :
26  QWidget(parent)
27 {
28  scale=Scale;
29  init_display();
31  setText(text);
32 }
34 {
35  cb_one = new QCheckBox;
36  cb_two = new QCheckBox;
37  label = new QLabel;
38  cb_one->setMaximumSize(22*scale,22*scale);
39  cb_two->setMaximumSize(22*scale,22*scale);
40  QHBoxLayout *boxLayout = new QHBoxLayout;
41  boxLayout->addWidget(cb_one);
42  boxLayout->addWidget(cb_two);
43  boxLayout->setContentsMargins(0,0,0,0);
44  boxLayout->setSpacing(2);
45  QHBoxLayout *Final = new QHBoxLayout;
46  Final->addWidget(label);
47  Final->addLayout(boxLayout);
48  Final->setContentsMargins(0,0,0,0);
49  this->setLayout(Final);
50 }
52 {
53  connect(cb_one,SIGNAL(toggled(bool)),this,SLOT(cb_one_toggled(bool)));
54  connect(cb_two,SIGNAL(toggled(bool)),this,SLOT(cb_two_toggled(bool)));
55 }
56 void DoubleCheckBox::setText(QString text){label->setText(text);}
58 {
59  switch(box)
60  {
61  case 1: cb_one->setChecked(checked); break;
62  case 2: cb_two->setChecked(checked); break;
63  default: break;
64  }
65 }
67 {
68  switch(box)
69  {
70  case 1: return cb_one->isChecked(); break;
71  case 2: return cb_two->isChecked(); break;
72  default: return false; break;
73  }
74 }
77 
78 void DoubleCheckBox::setBoxToolTip(int box,QString text)
79 {
80  switch(box)
81  {
82  case 1: cb_one->setToolTip(text); break;
83  case 2: cb_two->setToolTip(text); break;
84  default: break;
85  }
86 }
87 void DoubleCheckBox::setToolTip(QString text){label->setToolTip(text);}
void box2_toggled(bool checked)
Signal: box2 has had its state changed.
void box1_toggled(bool checked)
Signal: box1 has had its state changed.
bool checked(int box)
check if a box has been checked .
void setToolTip(QString text)
Set the tooltip for the widget.
QCheckBox * cb_one
void setChecked(int box, bool checked)
set if a box is checked
void setText(QString text)
set the text displayed
void cb_one_toggled(bool checked)
void setBoxToolTip(int box, QString text)
Set the tooltip for a checkbox.
DoubleCheckBox(qreal Scale=1, QWidget *parent=0)
create a new empty Double Checkbox
void cb_two_toggled(bool checked)
QCheckBox * cb_two