mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Local library: Basic list working
This commit is contained in:
parent
97bc34530c
commit
7c79bd4843
8 changed files with 187 additions and 11 deletions
|
@ -40,6 +40,7 @@ SOURCES += \
|
|||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
otamanager.cpp \
|
||||
qclickablelabel.cpp \
|
||||
quit.cpp \
|
||||
reader.cpp \
|
||||
savedwords.cpp \
|
||||
|
@ -71,6 +72,7 @@ HEADERS += \
|
|||
locallibrarywidget.h \
|
||||
mainwindow.h \
|
||||
otamanager.h \
|
||||
qclickablelabel.h \
|
||||
quit.h \
|
||||
reader.h \
|
||||
savedwords.h \
|
||||
|
|
|
@ -1,14 +1,91 @@
|
|||
#include "locallibrarywidget.h"
|
||||
#include "ui_locallibrarywidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QScreen>
|
||||
|
||||
localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::localLibraryWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setFont(QFont("u001"));
|
||||
|
||||
/*for(int i = 7; i <= 9; i++) {
|
||||
bookBtnArray[i]->deleteLater();
|
||||
bookIconArray[i]->deleteLater();
|
||||
}*/
|
||||
//bookBtnArray[7]->deleteLater();
|
||||
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
|
||||
buttonsNumber = 4;
|
||||
}
|
||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n") {
|
||||
buttonsNumber = 5;
|
||||
}
|
||||
else if(global::deviceID == "n437\n" or global::deviceID == "n873\n") {
|
||||
buttonsNumber = 5;
|
||||
}
|
||||
else {
|
||||
buttonsNumber = 3;
|
||||
}
|
||||
|
||||
// Getting the screen's size
|
||||
sW = QGuiApplication::screens()[0]->size().width();
|
||||
sH = QGuiApplication::screens()[0]->size().height();
|
||||
|
||||
// Defining what the default icon size will be
|
||||
if(global::deviceID == "n705\n") {
|
||||
stdIconWidth = sW / 16;
|
||||
stdIconHeight = sH / 16;
|
||||
}
|
||||
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
||||
stdIconWidth = sW / 18;
|
||||
stdIconHeight = sH / 18;
|
||||
}
|
||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
||||
stdIconWidth = sW / 16.5;
|
||||
stdIconHeight = sH / 16.5;
|
||||
}
|
||||
else {
|
||||
stdIconWidth = sW / 18;
|
||||
stdIconHeight = sH / 18;
|
||||
}
|
||||
|
||||
for(int i = 1; i <= buttonsNumber; i++) {
|
||||
// Horizontal layout that will contain the book button and its icon
|
||||
QHBoxLayout * horizontalLayout = new QHBoxLayout(this);
|
||||
|
||||
// Book icon
|
||||
bookIconArray[i] = new QLabel(this);
|
||||
|
||||
// Book button
|
||||
bookBtnArray[i] = new QClickableLabel(this);
|
||||
bookBtnArray[i]->setProperty("type", "borderless");
|
||||
bookIconArray[i]->setStyleSheet("padding: 20px");
|
||||
bookBtnArray[i]->setFont(QFont("u001"));
|
||||
|
||||
// Spacer
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
horizontalLayout->addWidget(bookIconArray[i]);
|
||||
horizontalLayout->addWidget(bookBtnArray[i]);
|
||||
horizontalLayout->addSpacerItem(horizontalSpacer);
|
||||
ui->booksVerticalLayout->addLayout(horizontalLayout);
|
||||
}
|
||||
setupBooksList();
|
||||
}
|
||||
|
||||
localLibraryWidget::~localLibraryWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void localLibraryWidget::setupBooksList() {
|
||||
for(int i = 1; i <= buttonsNumber; i++) {
|
||||
QPixmap pixmap(":/resources/starred_star.png");
|
||||
bookIconArray[i]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight));
|
||||
bookBtnArray[i]->setText("<b>Book " + QString::number(i) + "</b><br>Description");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
#define LOCALLIBRARYWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
|
||||
#include "functions.h"
|
||||
#include "qclickablelabel.h"
|
||||
|
||||
namespace Ui {
|
||||
class localLibraryWidget;
|
||||
|
@ -12,11 +16,22 @@ class localLibraryWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QString className = this->metaObject()->className();
|
||||
explicit localLibraryWidget(QWidget *parent = nullptr);
|
||||
~localLibraryWidget();
|
||||
int buttonsNumber;
|
||||
int sW;
|
||||
int sH;
|
||||
int stdIconWidth;
|
||||
int stdIconHeight;
|
||||
|
||||
private slots:
|
||||
void setupBooksList();
|
||||
|
||||
private:
|
||||
Ui::localLibraryWidget *ui;
|
||||
Ui::localLibraryWidget * ui;
|
||||
QLabel * bookIconArray[10];
|
||||
QClickableLabel * bookBtnArray[10];
|
||||
};
|
||||
|
||||
#endif // LOCALLIBRARYWIDGET_H
|
||||
|
|
|
@ -10,19 +10,40 @@
|
|||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Hello</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<widget class="QLabel" name="localLibraryLabel">
|
||||
<property name="text">
|
||||
<string><b>Local library</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="booksVerticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -998,5 +998,6 @@ void MainWindow::resetWifiIconClickedWhileReconnecting() {
|
|||
void MainWindow::setupLocalLibraryWidget() {
|
||||
localLibraryWidgetWindow = new localLibraryWidget();
|
||||
libraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->stackedWidget->insertWidget(1, localLibraryWidgetWindow);
|
||||
ui->homeStackedWidget->insertWidget(1, localLibraryWidgetWindow);
|
||||
ui->homeStackedWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
|
|
@ -191,6 +191,18 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="5" column="0">
|
||||
|
@ -359,7 +371,20 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_6">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7"/>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
12
qclickablelabel.cpp
Normal file
12
qclickablelabel.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "qclickablelabel.h"
|
||||
|
||||
QClickableLabel::QClickableLabel(QWidget* parent, Qt::WindowFlags f)
|
||||
: QLabel(parent) {
|
||||
|
||||
}
|
||||
|
||||
QClickableLabel::~QClickableLabel() {}
|
||||
|
||||
void QClickableLabel::mousePressEvent(QMouseEvent* event) {
|
||||
emit clicked();
|
||||
}
|
23
qclickablelabel.h
Normal file
23
qclickablelabel.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef QCLICKABLELABEL_H
|
||||
#define QCLICKABLELABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <Qt>
|
||||
|
||||
class QClickableLabel : public QLabel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QClickableLabel(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
~QClickableLabel();
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
|
||||
};
|
||||
|
||||
#endif // CLICKABLELABEL_H
|
Loading…
Reference in a new issue