-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddlyricswindow.cpp
More file actions
39 lines (30 loc) · 864 Bytes
/
addlyricswindow.cpp
File metadata and controls
39 lines (30 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "addlyricswindow.h"
#include "ui_addlyricswindow.h"
addLyricsWindow::addLyricsWindow(QWidget *parent, QString songName) :
QDialog(parent),
ui(new Ui::addLyricsWindow)
{
ui->setupUi(this);
a_songName = songName;
connect(ui->buttonCancel, SIGNAL(clicked()), this, SLOT(cancel()));
connect(ui->buttonSave, SIGNAL(clicked()), this, SLOT(saveLyrics()));
}
void addLyricsWindow::cancel()
{
this->destroy();
}
void addLyricsWindow::saveLyrics()
{
QString filename(a_songName.remove(a_songName.lastIndexOf("."), a_songName.length()-a_songName.lastIndexOf(".")));
QFile file(filename + ".lyrics");
if(file.open(QFile::WriteOnly | QFile::Text))
{
QTextStream out(&file);
out << ui->textEdit->document()->toPlainText();
}
cancel();
}
addLyricsWindow::~addLyricsWindow()
{
delete ui;
}