mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Local library: Improvements on QClickableLabel
This commit is contained in:
parent
ccdc1a235c
commit
694466444e
3 changed files with 14 additions and 9 deletions
|
@ -51,21 +51,18 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
// Horizontal layout that will contain the book button and its icon
|
// Horizontal layout that will contain the book button and its icon
|
||||||
QHBoxLayout * horizontalLayout = new QHBoxLayout(this);
|
QHBoxLayout * horizontalLayout = new QHBoxLayout(this);
|
||||||
|
|
||||||
// Book icon
|
// Book icon label
|
||||||
bookIconArray[i] = new QLabel(this);
|
bookIconArray[i] = new QLabel(this);
|
||||||
|
bookIconArray[i]->setStyleSheet("padding: 20px");
|
||||||
|
|
||||||
// Book button
|
// Book button
|
||||||
bookBtnArray[i] = new QClickableLabel(this);
|
bookBtnArray[i] = new QClickableLabel(this);
|
||||||
bookBtnArray[i]->setProperty("type", "borderless");
|
bookBtnArray[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
bookIconArray[i]->setStyleSheet("padding: 20px");
|
bookBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 20px");
|
||||||
bookBtnArray[i]->setFont(QFont("u001"));
|
bookBtnArray[i]->setFont(QFont("u001"));
|
||||||
|
|
||||||
// Spacer
|
|
||||||
QSpacerItem * horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
|
|
||||||
horizontalLayout->addWidget(bookIconArray[i]);
|
horizontalLayout->addWidget(bookIconArray[i]);
|
||||||
horizontalLayout->addWidget(bookBtnArray[i]);
|
horizontalLayout->addWidget(bookBtnArray[i]);
|
||||||
horizontalLayout->addSpacerItem(horizontalSpacer);
|
|
||||||
ui->booksVerticalLayout->addLayout(horizontalLayout);
|
ui->booksVerticalLayout->addLayout(horizontalLayout);
|
||||||
}
|
}
|
||||||
setupBooksList();
|
setupBooksList();
|
||||||
|
|
|
@ -7,6 +7,12 @@ QClickableLabel::QClickableLabel(QWidget* parent, Qt::WindowFlags f)
|
||||||
|
|
||||||
QClickableLabel::~QClickableLabel() {}
|
QClickableLabel::~QClickableLabel() {}
|
||||||
|
|
||||||
void QClickableLabel::mousePressEvent(QMouseEvent* event) {
|
void QClickableLabel::mousePressEvent(QMouseEvent * event) {
|
||||||
emit clicked();
|
emit clicked();
|
||||||
|
QClickableLabel::setStyleSheet("color: white; background-color: black; border-radius: 10px; padding: 20px");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QClickableLabel::mouseReleaseEvent(QMouseEvent * event) {
|
||||||
|
emit unclicked();
|
||||||
|
QClickableLabel::setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 20px");
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,11 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
void unclicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent * event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent * event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue