diff --git a/buttondefence/buttondefence.cpp b/buttondefence/buttondefence.cpp index 2abc2eb..3d424e8 100644 --- a/buttondefence/buttondefence.cpp +++ b/buttondefence/buttondefence.cpp @@ -180,7 +180,7 @@ void ButtonDefence::setButtonStyle(const ButtonDefence::ButtonStyle &buttonStyle } else if (buttonStyle == ButtonStyle_Msg2) { type = "msg2"; } else { - type = "circle"; + type = "custom"; } setButtonStatus(buttonStatus); diff --git a/buttondefence/buttondefence.h b/buttondefence/buttondefence.h index 2f41144..c52f103 100644 --- a/buttondefence/buttondefence.h +++ b/buttondefence/buttondefence.h @@ -3,12 +3,12 @@ /** * 防区按钮控件 作者:feiyangqingyun(QQ:517216493) 2018-7-2 - * 1:可设置防区样式 圆形、警察、气泡、气泡2、消息、消息2 - * 2:可设置防区状态 布防、撤防、报警、旁路、故障 - * 3:可设置报警切换 - * 4:可设置显示的防区号 - * 5:可设置是否可鼠标拖动 - * 6:发出单击和双击信号 + * 1. 可设置防区样式 圆形、警察、气泡、气泡2、消息、消息2 + * 2. 可设置防区状态 布防、撤防、报警、旁路、故障 + * 3. 可设置报警切换 + * 4. 可设置显示的防区号 + * 5. 可设置是否可鼠标拖动 + * 6. 发出单击和双击信号 */ #include @@ -37,14 +37,16 @@ class ButtonDefence : public QWidget Q_PROPERTY(ButtonStatus buttonStatus READ getButtonStatus WRITE setButtonStatus) public: - //防区样式 圆形、警察、气泡、气泡2、消息、消息2 + //防区样式 圆形、警察、气泡、气泡2、消息、消息2、自定义 + //如果设置的自定义的,则图片拓展名 btn_defence_alarm_custom enum ButtonStyle { ButtonStyle_Circle = 0, ButtonStyle_Police = 1, ButtonStyle_Bubble = 2, ButtonStyle_Bubble2 = 3, ButtonStyle_Msg = 4, - ButtonStyle_Msg2 = 5 + ButtonStyle_Msg2 = 5, + ButtonStyle_Custom = 6 }; //防区状态 布防、撤防、报警、旁路、故障 diff --git a/buttondefence/frmbuttondefence.cpp b/buttondefence/frmbuttondefence.cpp index 03cce01..8b505b9 100644 --- a/buttondefence/frmbuttondefence.cpp +++ b/buttondefence/frmbuttondefence.cpp @@ -31,7 +31,7 @@ void frmButtonDefence::initForm() btn3->setText("#3"); btn3->setGeometry(85, 5, 35, 35); - btnStyle << ui->btnCircle << ui->btnPolice << ui->btnBubble << ui->btnBubble2 << ui->btnMsg << ui->btnMsg2; + btnStyle << ui->btnCircle << ui->btnPolice << ui->btnBubble << ui->btnBubble2 << ui->btnMsg << ui->btnMsg2 << ui->btnCustom; foreach (QPushButton *btn, btnStyle) { connect(btn, SIGNAL(clicked(bool)), this, SLOT(changeStyle())); } @@ -50,6 +50,16 @@ void frmButtonDefence::changeStyle() btn1->setButtonStyle(style); btn2->setButtonStyle(style); btn3->setButtonStyle(style); + + if (index == 6) { + btn1->setText(""); + btn2->setText(""); + btn3->setText(""); + } else { + btn1->setText("#1"); + btn2->setText("#2"); + btn3->setText("#3"); + } } void frmButtonDefence::changeStatus() @@ -69,3 +79,10 @@ void frmButtonDefence::on_ckCanMove_stateChanged(int arg1) btn2->setCanMove(canMove); btn3->setCanMove(canMove); } + +void frmButtonDefence::on_btnPoint_clicked() +{ + qDebug() << "btn1" << "x" << btn1->geometry().x() << "y" << btn1->geometry().y(); + qDebug() << "btn2" << "x" << btn2->geometry().x() << "y" << btn2->geometry().y(); + qDebug() << "btn3" << "x" << btn3->geometry().x() << "y" << btn3->geometry().y(); +} diff --git a/buttondefence/frmbuttondefence.h b/buttondefence/frmbuttondefence.h index 808eb22..0d27758 100644 --- a/buttondefence/frmbuttondefence.h +++ b/buttondefence/frmbuttondefence.h @@ -25,6 +25,8 @@ private slots: void changeStatus(); void on_ckCanMove_stateChanged(int arg1); + void on_btnPoint_clicked(); + private: Ui::frmButtonDefence *ui; ButtonDefence *btn1; diff --git a/buttondefence/frmbuttondefence.ui b/buttondefence/frmbuttondefence.ui index 5e914fc..3d0af0d 100644 --- a/buttondefence/frmbuttondefence.ui +++ b/buttondefence/frmbuttondefence.ui @@ -87,6 +87,13 @@ + + + + 自定义 + + + @@ -129,6 +136,13 @@ + + + + Qt::Horizontal + + + @@ -136,6 +150,13 @@ + + + + 坐标 + + + @@ -155,6 +176,21 @@ + + btnCircle + btnPolice + btnBubble + btnBubble2 + btnMsg + btnMsg2 + btnCustom + btnArming + btnDisarming + btnAlarm + btnBypass + btnError + ckCanMove + diff --git a/buttondefence/image/btn_defence_alarm_custom.png b/buttondefence/image/btn_defence_alarm_custom.png new file mode 100644 index 0000000..4e770af Binary files /dev/null and b/buttondefence/image/btn_defence_alarm_custom.png differ diff --git a/buttondefence/image/btn_defence_arming_custom.png b/buttondefence/image/btn_defence_arming_custom.png new file mode 100644 index 0000000..7de9bcd Binary files /dev/null and b/buttondefence/image/btn_defence_arming_custom.png differ diff --git a/buttondefence/image/btn_defence_bypass_custom.png b/buttondefence/image/btn_defence_bypass_custom.png new file mode 100644 index 0000000..5ac64f1 Binary files /dev/null and b/buttondefence/image/btn_defence_bypass_custom.png differ diff --git a/buttondefence/image/btn_defence_disarming_custom.png b/buttondefence/image/btn_defence_disarming_custom.png new file mode 100644 index 0000000..27265c7 Binary files /dev/null and b/buttondefence/image/btn_defence_disarming_custom.png differ diff --git a/buttondefence/image/btn_defence_error_custom.png b/buttondefence/image/btn_defence_error_custom.png new file mode 100644 index 0000000..460709d Binary files /dev/null and b/buttondefence/image/btn_defence_error_custom.png differ diff --git a/buttondefence/main.qrc b/buttondefence/main.qrc index 562ef7e..2c02e87 100644 --- a/buttondefence/main.qrc +++ b/buttondefence/main.qrc @@ -31,5 +31,10 @@ image/btn_defence_error_msg2.png image/btn_defence_error_police.png image/bg_call.jpg + image/btn_defence_alarm_custom.png + image/btn_defence_arming_custom.png + image/btn_defence_bypass_custom.png + image/btn_defence_disarming_custom.png + image/btn_defence_error_custom.png diff --git a/buttondefence/snap/QQ截图20180704101942.JPG b/buttondefence/snap/QQ截图20180704101942.JPG new file mode 100644 index 0000000..96dffad Binary files /dev/null and b/buttondefence/snap/QQ截图20180704101942.JPG differ diff --git a/buttondefence/snap/QQ截图20180704101947.JPG b/buttondefence/snap/QQ截图20180704101947.JPG new file mode 100644 index 0000000..ea7ab83 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704101947.JPG differ diff --git a/buttondefence/snap/QQ截图20180704101953.JPG b/buttondefence/snap/QQ截图20180704101953.JPG new file mode 100644 index 0000000..1726780 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704101953.JPG differ diff --git a/buttondefence/snap/QQ截图20180704101956.JPG b/buttondefence/snap/QQ截图20180704101956.JPG new file mode 100644 index 0000000..0dfb786 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704101956.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102000.JPG b/buttondefence/snap/QQ截图20180704102000.JPG new file mode 100644 index 0000000..e07bcd0 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102000.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102003.JPG b/buttondefence/snap/QQ截图20180704102003.JPG new file mode 100644 index 0000000..1b195e1 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102003.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102029.JPG b/buttondefence/snap/QQ截图20180704102029.JPG new file mode 100644 index 0000000..ccc88be Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102029.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102034.JPG b/buttondefence/snap/QQ截图20180704102034.JPG new file mode 100644 index 0000000..d877007 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102034.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102037.JPG b/buttondefence/snap/QQ截图20180704102037.JPG new file mode 100644 index 0000000..9ae0f5b Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102037.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102040.JPG b/buttondefence/snap/QQ截图20180704102040.JPG new file mode 100644 index 0000000..7ce6657 Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102040.JPG differ diff --git a/buttondefence/snap/QQ截图20180704102108.JPG b/buttondefence/snap/QQ截图20180704102108.JPG new file mode 100644 index 0000000..08857cf Binary files /dev/null and b/buttondefence/snap/QQ截图20180704102108.JPG differ