* Minor fixes in database storage
[someplayer] / src / mainwindow.cpp
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 #include <QFileDialog>
4 #include <QMessageBox>
5 #include <QFile>
6
7 #include "player/player.h"
8
9 #include "library.h"
10
11 using namespace SomePlayer::DataObjects;
12
13 MainWindow::MainWindow(QWidget *parent) :
14         QMainWindow(parent),
15         ui(new Ui::MainWindow)
16 {
17         _library = new Library(_DATABASE_PATH_, _PLAYLISTS_PATH_);
18         ui->setupUi(this);
19         connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openMedia()));
20         connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt()));
21         connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
22         connect(ui->actionPlayer, SIGNAL(triggered()), this, SLOT(player()));
23         connect(ui->actionLibrary, SIGNAL(triggered()), this, SLOT(library()));
24         setAnimated(true);
25         _playerForm = new PlayerForm(_library, ui->stackedWidget);
26         _libraryForm = new LibraryForm(_library, ui->stackedWidget);
27         ui->stackedWidget->insertWidget(0, _playerForm);
28         ui->stackedWidget->insertWidget(1, _libraryForm);
29         connect(_playerForm, SIGNAL(library()), this, SLOT(library()));
30         connect(_libraryForm, SIGNAL(player()), this, SLOT(player()));
31         library();
32 }
33
34 MainWindow::~MainWindow()
35 {
36         delete _playerForm;
37         delete _libraryForm;
38         delete ui;
39 }
40
41 void MainWindow::openMedia()
42 {
43 //      SomePlayer::DataObjects::Library *l = new SomePlayer::DataObjects::Library("/tmp", "/tmp");
44 //      l->addDirectory("/mnt/music/Three Days Grace");
45 }
46
47 void MainWindow::aboutQt() {
48         QMessageBox::aboutQt(this, "About Qt");
49 }
50
51 void MainWindow::about() {
52         QMessageBox::about(this, "About SomePlayer", "Alternate music player for Maemo 5 "
53                                            "written in C++ with Qt4\n\n"
54                                            "Author: Nikolay Tischenko aka \"somebody\" <niktischenko@gmail.com>");
55 }
56
57 void MainWindow::player() {
58         _playerForm->show();
59         ui->stackedWidget->setCurrentIndex(0);
60         setWindowTitle("SomePlayer");
61 }
62
63 void MainWindow::library() {
64         _libraryForm->show();
65         ui->stackedWidget->setCurrentIndex(1);
66         setWindowTitle("SomePlayer Library");
67 }