Skip to content

Commit

Permalink
added settings page and db manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Crylia committed Apr 3, 2024
1 parent d9ddfe8 commit 574efcd
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Qml Svg Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Qml Svg Core)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Qml Svg Core Sql)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Qml Svg Core Sql)

find_package(SDL2 QUIET)

Expand Down Expand Up @@ -56,6 +56,7 @@ target_link_libraries(CryliaPlayer PRIVATE
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Sql
${SDL_LIBRARIES}
${SDL_MIXER_LIBRARY}
PkgConfig::LIBAV
Expand Down
14 changes: 13 additions & 1 deletion src/View/MainWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ void MainWidget::setupMainWidget( ) {
stackedLayout->addWidget(homePage);
stackedLayout->addWidget(playlistPage);
stackedLayout->addWidget(localFolderPage);
stackedLayout->addWidget(settingsPage);

pageManager.GetActivePage( )->setVisible(true);
playlistPage->setVisible(false);
localFolderPage->setVisible(false);
settingsPage->setVisible(false);

hbox->addLayout(stackedLayout, 0);

Expand All @@ -36,16 +38,25 @@ void MainWidget::setupMainWidget( ) {
stackedLayout->itemAt(0)->widget( )->setVisible(true);
stackedLayout->itemAt(1)->widget( )->setVisible(false);
stackedLayout->itemAt(2)->widget( )->setVisible(false);
stackedLayout->itemAt(3)->widget( )->setVisible(false);
}
else if (page->GetName( ) == "playlist") {
stackedLayout->itemAt(0)->widget( )->setVisible(false);
stackedLayout->itemAt(1)->widget( )->setVisible(true);
stackedLayout->itemAt(2)->widget( )->setVisible(false);
stackedLayout->itemAt(3)->widget( )->setVisible(false);
}
else if (page->GetName( ) == "localFolder") {
stackedLayout->itemAt(0)->widget( )->setVisible(false);
stackedLayout->itemAt(1)->widget( )->setVisible(false);
stackedLayout->itemAt(2)->widget( )->setVisible(true);
stackedLayout->itemAt(3)->widget( )->setVisible(false);
}
else if (page->GetName( ) == "settings") {
stackedLayout->itemAt(0)->widget( )->setVisible(false);
stackedLayout->itemAt(1)->widget( )->setVisible(false);
stackedLayout->itemAt(2)->widget( )->setVisible(false);
stackedLayout->itemAt(3)->widget( )->setVisible(true);
}
});

Expand All @@ -59,7 +70,8 @@ MainWidget::MainWidget(QWidget* parent)
playlistNav(new PlaylistNavModule(this)),
playlistPage(new PlaylistPage(this)),
homePage(new HomePage(this)),
localFolderPage(new LocalFolderPage(this)) {
localFolderPage(new LocalFolderPage(this)),
settingsPage(new SettingsPage(this)) {
pageManager.SetActivePage(homePage);
setupMainWidget( );
}
Expand Down
2 changes: 2 additions & 0 deletions src/View/MainWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Pages/Playlist/PlaylistPage.h"
#include "Pages/Home/HomePage.h"
#include "Pages/LocalFolder/LocalFolderPage.h"
#include "Pages/Settings/SettingsPage.h"
#include "../Controller/PageManager/PageManager.h"

class MainWidget : public QWidget {
Expand All @@ -24,6 +25,7 @@ class MainWidget : public QWidget {
PlaylistPage* playlistPage;
HomePage* homePage;
LocalFolderPage* localFolderPage;
SettingsPage* settingsPage;

FloatingControls* floatingControlls;

Expand Down
18 changes: 16 additions & 2 deletions src/View/Modules/PageNavModule/PageNavModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ PageNavModule::PageNavModule(QWidget* parent) :
QFrame(parent),
home(new PageNavigator(new HomePage( ), "Home", ":icons/home-outline.svg", "#81D4FA")),
localFiles(new PageNavigator(new LocalFolderPage( ), "Local Files", ":icons/folder-outline.svg", "#FFE082")),
playlist(new PageNavigator(new PlaylistPage( ), "Playlist", ":icons/magnify.svg", "#CE93D8")) {
playlist(new PageNavigator(new PlaylistPage( ), "Playlist", ":icons/magnify.svg", "#CE93D8")),
settings(new PageNavigator(new SettingsPage( ), "Settings", ":icons/magnify.svg", "#C5E1A5")) {
this->setStyleSheet(R"(
background-color: #282828;
Expand All @@ -13,31 +14,44 @@ PageNavModule::PageNavModule(QWidget* parent) :
applyShadow(this);
this->setFixedSize(300, 180);
this->setFixedSize(300, 240);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(home);
layout->addWidget(settings);
layout->addWidget(localFiles);
layout->addWidget(playlist);
home->select( );
PageManager& pageManager = PageManager::getInstance( );
connect(home, &PageNavigator::SelectedChanged, [&pageManager, this](Page* page) {
home->select( );
localFiles->unselect( );
playlist->unselect( );
settings->unselect( );
emit pageManager.ActivePageChanged(page);
});
connect(localFiles, &PageNavigator::SelectedChanged, [&pageManager, this](Page* page) {
home->unselect( );
localFiles->select( );
playlist->unselect( );
settings->unselect( );
emit pageManager.ActivePageChanged(page);
});
connect(playlist, &PageNavigator::SelectedChanged, [&pageManager, this](Page* page) {
home->unselect( );
localFiles->unselect( );
playlist->select( );
settings->unselect( );
emit pageManager.ActivePageChanged(page);
});
connect(settings, &PageNavigator::SelectedChanged, [&pageManager, this](Page* page) {
home->unselect( );
localFiles->unselect( );
playlist->unselect( );
settings->select( );
emit pageManager.ActivePageChanged(page);
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/View/Modules/PageNavModule/PageNavModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#include <QWidget>
#include <QVector>
#include <QFrame>
#include <QSizePolicy>

#include "../../Widgets/PageNavigator/PageNavigator.h"
#include "../../Tools/SvgToPixmap.hpp"
#include "../../Pages/Home/HomePage.h"
#include "../../Pages/Playlist/PlaylistPage.h"
#include "../../Pages/LocalFolder/LocalFolderPage.h"
#include "../../Pages/Settings/SettingsPage.h"
#include "../../../Controller/PageManager/PageManager.h"

class PageNavModule : public QFrame {
Expand All @@ -19,6 +21,7 @@ class PageNavModule : public QFrame {
PageNavigator* home;
PageNavigator* localFiles;
PageNavigator* playlist;
PageNavigator* settings;

public:
PageNavModule(QWidget* parent = nullptr);
Expand Down
13 changes: 13 additions & 0 deletions src/View/Pages/Settings/SettingsPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "SettingsPage.h"

SettingsPage::SettingsPage(QWidget* parent) :Page(parent) {

setStyleSheet(R"(
background-color: #282828;
border-radius: 12px;
)");

applyShadow(this);
}

SettingsPage::~SettingsPage( ) { }
18 changes: 18 additions & 0 deletions src/View/Pages/Settings/SettingsPage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <QWidget>
#include <QFrame>

#include "../../Tools/SvgToPixmap.hpp"
#include "../Page.h"

class SettingsPage : public Page {
Q_OBJECT
private:

public:
SettingsPage(QWidget* parent = nullptr);
~SettingsPage( );

std::string GetName( ) { return "settings"; }
};
9 changes: 9 additions & 0 deletions src/View/Widgets/PageNavigator/PageNavigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ PageNavigator::PageNavigator(Page* page, QString text, QString icon, QString col
connect(this, &QPushButton::clicked, [this]( ) {
emit SelectedChanged(this->page);
});

this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);

}

void PageNavigator::unselect( ) {
Expand All @@ -63,6 +66,9 @@ void PageNavigator::unselect( ) {
border: 4px solid #414141;
border-radius: 6px;
}
#Text{
color: #E0E0E0;
}
)");
}

Expand All @@ -72,6 +78,9 @@ void PageNavigator::select( ) {
border: 4px solid )" + m_color + R"(;
border-radius: 6px;
}
#Text{
color: #E0E0E0;
}
)");
}

Expand Down
13 changes: 13 additions & 0 deletions src/core/database/DatabaseManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "DatabaseManager.h"

DbManager::DbManager( ) :
m_db(QSqlDatabase::addDatabase("QSQLITE")) {
m_db.setDatabaseName(QString("../../../database/CryliaPlayerDB.sqlite3"));

if (!m_db.open( )) {
std::cout << "Error: Could not open database" << std::endl;
}

}

DbManager::~DbManager( ) { }
14 changes: 14 additions & 0 deletions src/core/database/DatabaseManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <QSqlDatabase>
#include <QString>
#include <iostream>

class DbManager {
private:
QSqlDatabase m_db;
public:
DbManager( );
~DbManager( );
};

0 comments on commit 574efcd

Please sign in to comment.