Skip to content

Commit

Permalink
conneting playlist with playlistview
Browse files Browse the repository at this point in the history
  • Loading branch information
shellohunter committed Mar 22, 2012
1 parent d386256 commit 2d17beb
Show file tree
Hide file tree
Showing 36 changed files with 872 additions and 204 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Thumbs.db
*.swp
*.log
*.pyc
*~
2 changes: 1 addition & 1 deletion source/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int Cli::cli_parser(char * clistring)
char * temp = NULL;
vector<string> splited;

LOG_VERBOSE("<cli> %s(%s)\n", __FUNCTION__, clistring);
LOG_VERBOSE("<cli> %s(%s)\n", __FUNCTION_NAME__, clistring);

if(strlen(clistring) == 0) return OK;

Expand Down
32 changes: 18 additions & 14 deletions source/database/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
#include <string.h>
#include "database.h"

#if DBG_MEMLEAK
int Song::counter = 0; /* for dbg only */
#endif

void Song::toString()
{
LOG_INFO("<Song> %02d. [%s], [%s], by [%s]. \n",
index,
index,
name.c_str(),
url.c_str(),
artistName.c_str());
Expand All @@ -24,12 +26,14 @@ bool Song::operator==(const Song& song)
return false;
}

#if DBG_MEMLEAK
int Artist::counter = 0; /* for dbg only */
#endif

void Artist::toString()
{
LOG_INFO("<Aritist> %02d. [%s], [%d], url [%s]. \n",
index,
index,
name.c_str(),
gender,
imgurl.c_str());
Expand All @@ -47,19 +51,19 @@ bool Artist::operator==(const Artist& artist)
KaraokeDatabase::KaraokeDatabase()
{
LOG_API();
}
}

KaraokeDatabase::KaraokeDatabase(string filepath)
{
LOG_API();
open(filepath);
}
}

KaraokeDatabase::~KaraokeDatabase()
{
{
LOG_API();
close();
}
}

int KaraokeDatabase::open(string filepath)
{
Expand Down Expand Up @@ -183,7 +187,7 @@ int KaraokeDatabase::getSong(Song & song, int index)
pSqlMsg = (char*)malloc(SQLMSG_LEN * sizeof(char));
if (NULL == pSqlMsg)
{
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION__);
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION_NAME__);
return E_OUT_OF_MEMORY;
}
memset(pSqlMsg, 0,SQLMSG_LEN * sizeof(char));
Expand Down Expand Up @@ -271,7 +275,7 @@ DataSet<Song*>& KaraokeDatabase::getSongs(DataSet<Song*>& songs, string songName
pSqlMsg = (char*)malloc(SQLMSG_LEN * sizeof(char));
if (NULL == pSqlMsg)
{
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION__);
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION_NAME__);
//return E_OUT_OF_MEMORY;
return songs;
}
Expand Down Expand Up @@ -377,7 +381,7 @@ DataSet<Song*>& KaraokeDatabase::getSongs(DataSet<Song*>& songs, int startIndex,
pSqlMsg = (char*)malloc(SQLMSG_LEN * sizeof(char));
if (NULL == pSqlMsg)
{
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION__);
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION_NAME__);
//return E_OUT_OF_MEMORY;
return songs;
}
Expand Down Expand Up @@ -470,7 +474,7 @@ DataSet<Song*>& KaraokeDatabase::getSongsByArtist(DataSet<Song*>& songs, int art
{
return songs;
}

}

DataSet<Song*>& KaraokeDatabase::getSongsByArtist(DataSet<Song*>& songs, string artistName)
Expand All @@ -494,7 +498,7 @@ DataSet<Song*>& KaraokeDatabase::getSongsByArtist(DataSet<Song*>& songs, string
pSqlMsg = (char*)malloc(SQLMSG_LEN * sizeof(char));
if (NULL == pSqlMsg)
{
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION__);
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION_NAME__);
//return E_OUT_OF_MEMORY;
return songs;
}
Expand Down Expand Up @@ -612,7 +616,7 @@ int KaraokeDatabase::getArtist(Artist & artist, int index)
pSqlMsg = (char*)malloc(SQLMSG_LEN * sizeof(char));
if (NULL == pSqlMsg)
{
LOG_INFO("<SQlite> Cannot malloc memory in %s\n", __FUNCTION__);
LOG_INFO("<SQlite> Cannot malloc memory in %s\n", __FUNCTION_NAME__);
return E_OUT_OF_MEMORY;
}
memset(pSqlMsg, 0,SQLMSG_LEN * sizeof(char));
Expand Down Expand Up @@ -685,7 +689,7 @@ int KaraokeDatabase::getArtist(Artist & artist, int index)

return rc;
}

DataSet<Artist*>& KaraokeDatabase::getArtists(DataSet<Artist*>& artists, string artistName)
{
char *pSqlMsg = NULL, pPara[SQLMSG_PARA_LEN] = {0};
Expand All @@ -707,7 +711,7 @@ DataSet<Artist*>& KaraokeDatabase::getArtists(DataSet<Artist*>& artists, string
pSqlMsg = (char*)malloc(SQLMSG_LEN * sizeof(char));
if (NULL == pSqlMsg)
{
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION__);
LOG_ERROR("<SQlite> Cannot malloc memory in %s\n", __FUNCTION_NAME__);
//return E_OUT_OF_MEMORY;
return artists;
}
Expand Down
6 changes: 3 additions & 3 deletions source/gui/GuiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int cli_gm_resume(int argc, const char ** argv)

if(GuiManager::gm)
{
LOG_INFO("<cli> %s(%s) \n", __FUNCTION__, argv[1]);
LOG_INFO("<cli> %s(%s) \n", __FUNCTION_NAME__, argv[1]);
GuiManager::gm->activate(argv[1]);
}
return OK;
Expand All @@ -52,7 +52,7 @@ CliItem guiManagerCli[] =

GuiModule::GuiModule(const char * moduleName)
{
LOG_INFO("<GuiModule> %s->%s() \n", moduleName, __FUNCTION__);
LOG_INFO("<GuiModule> %s->%s() \n", moduleName, __FUNCTION_NAME__);

strncpy(name, moduleName, GUI_MODULE_NAME_LENGTH);

Expand All @@ -65,7 +65,7 @@ GuiModule::GuiModule(const char * moduleName)

GuiModule::~GuiModule()
{
LOG_INFO("<GuiModule> %s->%s() \n", name, __FUNCTION__);
LOG_INFO("<GuiModule> %s->%s() \n", name, __FUNCTION_NAME__);
}


Expand Down
2 changes: 1 addition & 1 deletion source/gui/GuiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct
#define GUI_MODULE_MENU "menu"
#define GUI_MODULE_CATEGORY "category"
#define GUI_MODULE_SEARCHRESULT "searchresult"
#define GUI_MODULE_PLAYLIST "playlist"
#define GUI_MODULE_PLAYLIST "playlistview"
#define GUI_MODULE_PLAYER "player"
#define GUI_MODULE_SINGERLIST "singerlist"

Expand Down
35 changes: 28 additions & 7 deletions source/gui/Karaoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static void IPCHandler(IPCNotify * notify)
}



Karaoke::Karaoke() : background()
{
LOG_API();
Expand All @@ -39,13 +40,26 @@ Karaoke::Karaoke() : background()
log_init();

/* create gui modules */
guiManager.append(new Login(&background));
guiManager.append(new Category(&background));
guiManager.append(new PlayListView(&background));
guiManager.append(new SearchResult(&background));
guiManager.append(new Player(&background));
guiManager.append(new SingerList(&background));
guiManager.append(new Menu(&background));
login = new Login(&background);
guiManager.append(login);

category = new Category(&background);
guiManager.append(category);

player = new Player(&background);
guiManager.append(player);

playlistview = new PlayListView(&background);
guiManager.append(playlistview);

searchresult = new SearchResult(&background);
guiManager.append(searchresult);

singerlist = new SingerList(&background);
guiManager.append(singerlist);

menu = new Menu(&background);
guiManager.append(menu);

dbg_init();

Expand All @@ -56,6 +70,13 @@ Karaoke::~Karaoke()
LOG_API();
DELETE(ipc);
DELETE(cli);
DELETE(menu);
DELETE(singerlist);
DELETE(searchresult);
DELETE(playlistview);
DELETE(player);
DELETE(login);

}

int Karaoke::resume()
Expand Down
10 changes: 9 additions & 1 deletion source/gui/Karaoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ class Karaoke
GuiManager guiManager;
Background background;

Login * login;
Category * category;
Player * player;
PlayListView * playlistview;
SearchResult * searchresult;
SingerList * singerlist;
Menu * menu;


IPC * ipc;
Cli * cli;

};


Expand Down
3 changes: 3 additions & 0 deletions source/gui/Karaoke.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
<file>images/menu-goto-playlist.png</file>
<file>images/menu-goto-player.png</file>
<file>images/menu-goto-logout.png</file>
<file>images/playlist_item_normal.png</file>
<file>images/playlist_item_hl.png</file>
<file>images/item-playing.png</file>
</qresource>
</RCC>
1 change: 1 addition & 0 deletions source/gui/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ src_files = Split("""
songlist/SongListView.cpp
singerlist/SingerList.cpp
playlist/PlayListView.cpp
playlist/PlayListItem.cpp
player/player.cpp
background/Background.cpp
../database/database.cpp
Expand Down
7 changes: 4 additions & 3 deletions source/gui/background/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ int Background::setBackground(QString & imagePath)
LOG_API();

QPalette palette = this->palette();
palette.setBrush(QPalette::Background, QBrush(QPixmap(imagePath)));
palette.setBrush(QPalette::Background, QBrush(QPixmap(":/images/background_normal.png")));
this->setPalette(palette);
return 0;
}

int Background::clearBackground()
{
LOG_API();

this->setPalette(QPalette());
QPalette palette = this->palette();
palette.setColor(QPalette::Background, QColor(0,0,0,0));
this->setPalette(palette);
return 0;
}
2 changes: 2 additions & 0 deletions source/gui/background/Background.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Background : public QWidget
{
public:
Background(QWidget * parent = NULL);

public slots:
int setBackground(QString & imagePath);
int clearBackground();
};
Expand Down
6 changes: 2 additions & 4 deletions source/gui/category/category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
MBtnCategory::MBtnCategory(const QString & text, ECategoryType type, Category * parent)
:QPushButton(text, parent->root)
{
LOG_API();

QObject::connect(this, SIGNAL(signalMouseEvent(MBtnCategory *)), parent, SLOT(slotCategorySelected(MBtnCategory *)));
this->setStyleSheet("color:red; border:1px solid #AAAAAA; background-color: white;");
this->setFixedSize(135,128);
Expand Down Expand Up @@ -162,7 +160,7 @@ int Category::processMessage(int msg, void * data)

void Category::slotCategorySelected(MBtnCategory * button)
{
LOG_VERBOSE("<category> %s(%s)", __FUNCTION__,qPrintable(button->text()));
LOG_VERBOSE("<category> %s(%s)", __FUNCTION_NAME__,qPrintable(button->text()));

GuiEvent event;
event.type = GUI_EVENT_RESUME_PAGE;
Expand Down Expand Up @@ -288,7 +286,7 @@ bool Category::eventFilter(QObject * obj, QEvent * event)

void Category::mouseClick(MBtnCategory * button)
{
LOG_VERBOSE("<category> dbg trace line %d, %s. %s",__LINE__, __FUNCTION__,qPrintable(button->text()));
LOG_VERBOSE("<category> dbg trace line %d, %s. %s",__LINE__, __FUNCTION_NAME__,qPrintable(button->text()));
moveFocus(button);
}

Expand Down
Binary file added source/gui/images/item-playing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/gui/images/playlist_item_hl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/gui/images/playlist_item_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion source/gui/login/Login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@ int Login::init()
palette.setBrush(QPalette::Background, QBrush(QPixmap(":/images/dialog_background.png")));
root->setPalette(palette);
root->setGeometry(260, 120, 300, 150);
root->setStyleSheet("QPushButton {background: lightgray; color: blue; font: 14px bold;}");

kb = new KeyBoard("");
label_title = new QLabel(QObject::tr("Welcome to karaoke!"), root);
label_title = new QLabel(QObject::tr("Welcome to Karaoke!"), root);
label_title->setStyleSheet("color: red; font: 24px bold;");
label_title->setAlignment(Qt::AlignCenter);
label_username = new QLabel(QObject::tr("username"), root);
label_username->setStyleSheet("padding-left: 10px;");
label_password = new QLabel(QObject::tr("password"), root);
label_password->setStyleSheet("padding-left: 10px;");
edit_username = new InputLine(kb, root);
edit_password = new InputLine(kb, root);
edit_password->echo(false);
btn_login = new Button(QObject::tr("Login"), root);
//btn_login->setStyleSheet("{background: whitesmoke; barder:none; color: blue; font: 16px;}");
btn_register = new Button(QObject::tr("Register"), root);
btn_exit = new Button(QObject::tr("Exit"), root);


QGridLayout *layoutGrid = new QGridLayout();
layoutGrid->addWidget(label_title, 0,0,1,3);
layoutGrid->addWidget(label_username, 1,0);
Expand Down
1 change: 1 addition & 0 deletions source/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ int main(int argc, char ** argv)
QApplication app(argc, argv);
Karaoke * x = new Karaoke();


x->resume();
return app.exec();
}
Loading

0 comments on commit 2d17beb

Please sign in to comment.