Skip to content

Commit a13b89d

Browse files
committed
penButtons as qmap
1 parent 31dbddf commit a13b89d

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/tools.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
extern "C" {
3131
#include "utils/Settings.h"
3232
}
33-
extern QPushButton **penButtons;
33+
extern QMap<qint64, QPushButton*> penButtons;
3434

3535
extern DrawingWidget *drawing;
3636
extern FloatingWidget *floatingWidget;
@@ -60,8 +60,6 @@ extern int getPen();
6060
extern void setPenStyle(int style);
6161
extern void setLineStyle(int style);
6262

63-
extern QPushButton **penButtons;
64-
6563
extern QPushButton *typeButton;
6664

6765
extern OverView *ov;

src/tools/pen.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../tools.h"
22

3-
QPushButton **penButtons;
3+
QMap<qint64, QPushButton*> penButtons;
44

55
QPushButton *penSwitch;
66

@@ -65,8 +65,6 @@ void setLineStyle(int style){
6565
}
6666

6767
void setupPenType(){
68-
penButtons = (QPushButton**)calloc(1024, sizeof(QPushButton*));
69-
7068
penButtons[PEN] = create_button(":images/pen.svg", [=](){
7169
setPen(PEN);
7270
});

src/tools/update.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ void updateGoBackButtons(){
4444
}
4545

4646
void backgroundStyleEvent(){
47-
for(int i=0; i<1024; i++){
48-
if(penButtons[i] != nullptr){
49-
//printf("%d\n", i);
50-
penButtons[i]->setStyleSheet(QString("background-color: none;"));
51-
}
47+
for (auto it = penButtons.begin(); it != penButtons.end(); ++it) {
48+
it.value()->setStyleSheet(QString("background-color: none;"));
5249
}
5350
int btns[] = {
5451
getPen(), drawing->getLineStyle(),

0 commit comments

Comments
 (0)