-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
#include <QWidget> | ||
#include <QFrame> | ||
#include <QLayout> | ||
|
||
class PlaylistWidget : public QFrame { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <QPixmap> | ||
#include <QString> | ||
#include <QSvgRenderer> | ||
#include <QPainter> | ||
|
||
static QPixmap RenderSvg(QString path, int w, int h) { | ||
QSvgRenderer renderer(path); | ||
QPixmap pixmap(w, h); | ||
pixmap.fill(Qt::transparent); | ||
QPainter painter(&pixmap); | ||
renderer.render(&painter); | ||
|
||
return pixmap; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "PageNavigator.h" | ||
#include "SelectHandler.hpp" | ||
|
||
PageNavigator::PageNavigator(QString text, QString icon, QWidget* parent) | ||
:m_text(new QLabel(text)), m_icon(new QLabel( )) { | ||
|
||
m_icon->setPixmap(icon); | ||
|
||
setObjectName("PageNavigator"); | ||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||
setStyleSheet(R"( | ||
#PageNavigator{ | ||
border: 4px solid #414141; | ||
border-radius: 8px; | ||
color: #E0E0E0; | ||
} | ||
)"); | ||
|
||
QFont font = m_text->font( ); | ||
font.setPointSize(16); | ||
font.setWeight(QFont::Bold); | ||
m_text->setFont(font); | ||
|
||
QHBoxLayout* layout = new QHBoxLayout(this); | ||
layout->addWidget(m_icon, 0, Qt::AlignLeft); | ||
layout->addWidget(m_text, 1, Qt::AlignLeft); | ||
|
||
connect(this, &QPushButton::clicked, [this]( ) { | ||
SelectHandler* sh = SelectHandler::GetInstance( ); | ||
|
||
sh->setSelected(this); | ||
}); | ||
|
||
} | ||
|
||
void PageNavigator::unselect( ) { | ||
setStyleSheet(R"( | ||
#PageNavigator{ | ||
border: 4px solid #414141; | ||
border-radius: 6px; | ||
color: #E0E0E0; | ||
} | ||
)"); | ||
} | ||
|
||
void PageNavigator::select( ) { | ||
setStyleSheet(R"( | ||
#PageNavigator{ | ||
border: 4px solid #81D4FA; | ||
border-radius: 6px; | ||
color: #E0E0E0; | ||
} | ||
)"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <QWidget> | ||
#include <QLabel> | ||
#include <QLayout> | ||
#include <QFont> | ||
#include <QPushButton> | ||
|
||
class PageNavigator :public QPushButton { | ||
Q_OBJECT | ||
private: | ||
QLabel* m_text; | ||
QLabel* m_icon; | ||
|
||
public: | ||
PageNavigator(QString text, QString icon, QWidget* parent = nullptr); | ||
|
||
void unselect( ); | ||
void select( ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
|
||
#include <QWidget> | ||
#include "PageNavigator.h" | ||
|
||
/* | ||
Singleton to handle PageNavigator widget selects | ||
*/ | ||
class SelectHandler { | ||
public: | ||
static SelectHandler* GetInstance( ); | ||
|
||
~SelectHandler( ) { } | ||
SelectHandler(const SelectHandler&) = delete; | ||
void operator=(const SelectHandler&) = delete; | ||
|
||
void setSelected(PageNavigator* newSelected); | ||
|
||
PageNavigator* getSelected( ); | ||
|
||
private: | ||
SelectHandler( ) { } | ||
|
||
static SelectHandler* instance; | ||
|
||
PageNavigator* selected = nullptr; | ||
}; | ||
|
||
SelectHandler* SelectHandler::instance = nullptr; | ||
|
||
SelectHandler* SelectHandler::GetInstance( ) { | ||
if (instance == nullptr) | ||
instance = new SelectHandler( ); | ||
return instance; | ||
} | ||
|
||
void SelectHandler::setSelected(PageNavigator* newSelected) { | ||
if (!newSelected && (newSelected == selected)) | ||
return; | ||
|
||
if (this->selected == nullptr) { | ||
this->selected = newSelected; | ||
newSelected->select( ); | ||
return; | ||
} | ||
|
||
selected->unselect( ); | ||
newSelected->select( ); | ||
this->selected = newSelected; | ||
} | ||
|
||
PageNavigator* SelectHandler::getSelected( ) { | ||
return selected; | ||
} |