[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [brprint3d] /: Fix multiple issues with BigButton
From:       Tomaz Canabrava <tomaz.canabrava () intel ! com>
Date:       2015-11-30 23:47:41
Message-ID: E1a3YAX-0000MT-Or () scm ! kde ! org
[Download RAW message or body]

Git commit 2b316297878ef4fa437910bdfd6b9df0506a1d2d by Tomaz Canabrava.
Committed on 30/11/2015 at 22:55.
Pushed by tcanabrava into branch 'master'.

Fix multiple issues with BigButton

1 - don't pass QString or QIcon via value, pass them via const-ref
2 - do not use default arguments when you need real arguments.
3 - do not pass '0' as parent, parent is the owner of the widget.
4 - be carefull with the code style
5 - use tr() between strings that you need translated
6 - do not \n an string on a push button, it knows how to handle itself.
7 - use proper names for functions/methods, isChecked() is good, getCheckedStatus \
isn't.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>

M  +12   -8    BigButton.cpp
M  +4    -4    BigButton.h
M  +8    -8    brprint3d.cpp

http://commits.kde.org/brprint3d/2b316297878ef4fa437910bdfd6b9df0506a1d2d

diff --git a/BigButton.cpp b/BigButton.cpp
index 3f9eb7d..1170319 100755
--- a/BigButton.cpp
+++ b/BigButton.cpp
@@ -23,31 +23,35 @@
 #include "BigButton.h"
 #include "ui_BigButton.h"
 
-BigButton::BigButton(QWidget *parent, QString name, bool isCheckable, QString \
iconPath) : +BigButton::BigButton(QWidget *parent, const QString& name,const QString& \
iconPath,  bool isCheckable) :  QWidget(parent),
     ui(new Ui::BigButton)
-{   QPixmap pix(iconPath);
+{   
+    QPixmap pix(iconPath);
     ui->setupUi(this);
     ui->label->setText(name);
     ui->pushButton->setCheckable(isCheckable);
-    connect(ui->pushButton,&QPushButton::clicked,this,&BigButton::clicked);
     ui->pushButton->setIcon(QIcon(pix));
-    ui->pushButton->setIconSize(QSize(50,50));
+    ui->pushButton->setIconSize(QSize(50,50)); //TODO: Hardcoded value, change this \
to something calculated for the current display. +    connect(ui->pushButton, \
&QPushButton::clicked, this, &BigButton::clicked);  }
 
 BigButton::~BigButton()
 {
     delete ui;
 }
-bool BigButton::getCheckedStatus(){
 
+bool BigButton::isChecked()
+{
     return ui->pushButton->isChecked();
-
 }
-void BigButton::setIcon(QIcon icon){
 
+void BigButton::setIcon(const QIcon& icon)
+{
     ui->pushButton->setIcon(icon);
 }
-void BigButton::setChecked(bool b){
+
+void BigButton::setChecked(bool b)
+{
     ui->pushButton->setChecked(b);
 }
diff --git a/BigButton.h b/BigButton.h
index a2beb39..d5ea784 100755
--- a/BigButton.h
+++ b/BigButton.h
@@ -35,11 +35,11 @@ class BigButton : public QWidget
     Q_OBJECT
 
 public:
-    explicit BigButton(QWidget *parent = 0, QString name = "", bool isCheckable = \
false, QString pix = ""); +    explicit BigButton(QWidget *parent, const QString& \
name, const QString& pix, bool isCheckable = false);  ~BigButton();
-public slots:
-    bool getCheckedStatus();
-    void setIcon(QIcon icon);
+
+    bool isChecked();
+    void setIcon(const QIcon& icon);
     void setChecked(bool b);
 
 private:
diff --git a/brprint3d.cpp b/brprint3d.cpp
index 9a25c0e..c0021d6 100755
--- a/brprint3d.cpp
+++ b/brprint3d.cpp
@@ -28,18 +28,18 @@ BrPrint3D::BrPrint3D(QWidget *parent) : QMainWindow(parent),
     ui(new Ui::BrPrint3D)
 {
     ui->setupUi(this);
-    bt_import = new BigButton(0,"Import \nGCode",false,":/Icons/Icons/import.png");
-    bt_open = new BigButton(0,"Open File",false,":/Icons/Icons/openFile.png");
-    bt_connect = new BigButton(0,"Connect",true,":/Icons/Icons/connect.png");
+    bt_import = new BigButton(this,tr("Import GCode"),":/Icons/Icons/import.png", \
false); +    bt_open = new BigButton(this,tr("Open \
File"),":/Icons/Icons/openFile.png", false); +    bt_connect = new \
BigButton(this,tr("Connect"),":/Icons/Icons/connect.png", true);  
     ui->ly_ConteinerLeft->addWidget(bt_import);
     ui->ly_ConteinerLeft->addWidget(bt_open);
     ui->ly_ConteinerLeft->addWidget(bt_connect);
 
-    bt_play = new BigButton(0,"Play",true,":/Icons/Icons/play.png");
-    bt_pause = new BigButton(0,"Pause",true,":/Icons/Icons/pause.png");
-    bt_stop = new BigButton(0,"Stop",false,":/Icons/Icons/stop.png");
-    bt_stopOnEmergency = new BigButton(0,"Emergency \
\nStop",false,":/Icons/Icons/emergency.png"); +    bt_play = new \
BigButton(this,tr("Play"),":/Icons/Icons/play.png", true); +    bt_pause = new \
BigButton(this,tr("Pause"),":/Icons/Icons/pause.png", true); +    bt_stop = new \
BigButton(this,tr("Stop"),":/Icons/Icons/stop.png", false); +    bt_stopOnEmergency = \
new BigButton(this,tr("Emergency Stop"),":/Icons/Icons/emergency.png", false);  
     ui->ly_ConteinerRight->addWidget(bt_play);
     ui->ly_ConteinerRight->addWidget(bt_pause);
@@ -110,7 +110,7 @@ void BrPrint3D::openFile()
                 vtkView->renderGcode(text);
                 gcode.close();
                 ui->_ManualControl->setGcodePreview(text);
-                if (bt_connect->getCheckedStatus())
+                if (bt_connect->isChecked())
                     bt_play->setEnabled(true);
 
             }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic