Skip to content

Commit

Permalink
box finish!
Browse files Browse the repository at this point in the history
  • Loading branch information
Sugar0612 committed Jun 17, 2021
1 parent 0d1b39f commit 7e78d26
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion MusicPlayers.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2021-06-12T03:08:02. -->
<!-- Written by QtCreator 4.11.1, 2021-06-17T14:29:52. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
19 changes: 15 additions & 4 deletions create_list.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#include "create_list.h"

#include <QFont>
create_list::create_list(QWidget *parent) : QWidget(parent)
{

QFont font;
font.setFamily("幼圆");

this ->resize(350, 200);
this ->setWindowTitle("歌单创建窗口");
this ->setWindowIcon(QIcon(":/coin/mymusic.png")); // 主窗口的图标设置!

name = new QLineEdit(this);
name ->setGeometry(40, 40, 200, 40);
name ->setGeometry(80, 40, 200, 40);

list_name = new QLabel("歌单名", this);
list_name->setFont(font);
list_name ->setGeometry(10, 40, 60, 40);

ok = new QPushButton(this);
ok ->setText("确定");
ok ->setGeometry(40, 100, 70, 40);
ok ->setGeometry(80, 100, 60, 30);

cancel = new QPushButton(this);
cancel ->setText("取消");
cancel ->setGeometry(180, 100, 70, 40);
cancel ->setGeometry(210, 100, 60, 30);

connect(ok, &QPushButton::clicked, [=] () {
this ->hide();
Expand Down
2 changes: 2 additions & 0 deletions create_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include "mybtn.h"

class create_list : public QWidget
Expand All @@ -14,6 +15,7 @@ class create_list : public QWidget

QPushButton *ok, *cancel;
QLineEdit *name;
QLabel *list_name;
explicit create_list(QWidget *parent = nullptr);

signals:
Expand Down
5 changes: 4 additions & 1 deletion lrc_win_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <QLabel>
#include <QPainter>
#include <QFont>
#include <QIcon>


lrc_win_main::lrc_win_main(QWidget *parent) : QWidget(parent)
{
Expand All @@ -11,7 +13,8 @@ lrc_win_main::lrc_win_main(QWidget *parent) : QWidget(parent)
font.setWeight(25);
setWindowFlag(Qt::FramelessWindowHint); // 删除以前的 最大化 最小化 关闭自己写


this ->setWindowTitle("歌词窗口");
this ->setWindowIcon(QIcon(":/coin/mymusic.png")); // 主窗口的图标设置!
this ->resize(500, 80);

this->setWindowFlags(Qt::FramelessWindowHint); //使得窗体透明
Expand Down
13 changes: 8 additions & 5 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// 关闭窗口按钮
connect(clsb, &QPushButton::clicked, [=](){
this ->close();
lrc ->hide();
});


Expand Down Expand Up @@ -493,8 +494,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
QSqlQuery sql;
QString user_id_qstr = QString("%1").arg(user_id);
sql.exec("insert into localmusic values(" + user_id_qstr + ",\"" + this ->filem + "\");");
local_w ->setGeometry(musiclist ->width(), btnL->height(), this->width() - musiclist ->width(), this ->height() - btnL->height());
local_w ->setGeometry(musiclist ->width(), btnL->height(), this->width() - musiclist ->width(), this ->height() - btnL->height() - 100);
local_w ->setStyleSheet("QListWidget::Item{height: 60px;}");
local_w ->setHorizontalHeaderLabels(QStringList() << " " << "歌曲" << " " << " " << " ");
localinit(local_w); // init QlistWidget
local_w ->show();
tab_search ->hide();
Expand Down Expand Up @@ -688,11 +690,11 @@ void MainWindow::initPro() {

void MainWindow::initMysql() {
db = QSqlDatabase::addDatabase("QMYSQL"); // 加载mysql 驱动
db.setHostName("localhost"); // 主机名
db.setHostName("8.133.131.37"); // 主机名
db.setPort(3306); // 端口
db.setDatabaseName("musicbase"); // 库名
db.setUserName("root"); //用户名
db.setPassword("tsy20010612"); // 密码
db.setUserName("user"); //用户名
db.setPassword("Tsy20010612"); // 密码
bool ok = db.open(); //打开数据库
if (ok) qDebug() << "connect ok!" << endl;

Expand Down Expand Up @@ -1509,6 +1511,7 @@ void MainWindow::play_net_Music(int row, int col) {
// 收藏到 歌单
else if (col == 5) {
in_list = 1; // 收藏不插入播放队列
is_insert = 2;
g_row = row;
} else return;

Expand Down Expand Up @@ -1983,7 +1986,7 @@ void MainWindow::parseJson2(QString json) {
g_lrc = net_lrc;

if(is_insert == 1) insert_nowplay(net_file, net_name, net_image, net_lrc); //将网络歌曲插入到队列
else { // 插入到喜爱音乐里面
else if (is_insert == 0) { // 插入到喜爱音乐里面
QSqlQuery like_db;
int row = -1;
for(int i = 0; i < tab_search->rowCount(); ++i) {
Expand Down
14 changes: 8 additions & 6 deletions show_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ show_list::show_list(int id, QWidget *parent) : QWidget(parent), user_id(id)


void show_list::initMysql() {
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("musicbase");
db.setUserName("root");
db.setPassword("tsy20010612");
db.open();
db = QSqlDatabase::addDatabase("QMYSQL"); // 加载mysql 驱动
db.setHostName("8.133.131.37"); // 主机名
db.setPort(3306); // 端口
db.setDatabaseName("musicbase"); // 库名
db.setUserName("user"); //用户名
db.setPassword("Tsy20010612"); // 密码
bool ok = db.open(); //打开数据库
if (ok) qDebug() << "connect ok!" << endl;
}


Expand Down
12 changes: 7 additions & 5 deletions sign_in_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

sign_in_win::sign_in_win(QWidget *parent) : QWidget(parent)
{
this ->setWindowTitle("登录窗口");
this ->setWindowIcon(QIcon(":/coin/mymusic.png")); // 主窗口的图标设置!
this ->setFixedSize(350, 200);
user_name = new QLineEdit(this);
user_password = new QLineEdit(this);
Expand Down Expand Up @@ -56,11 +58,11 @@ void sign_in_win::user_sign_in() {

void sign_in_win::initMysql() {
db = QSqlDatabase::addDatabase("QMYSQL"); // 加载mysql 驱动
db.setHostName("localhost"); // 主机名
db.setHostName("8.133.131.37"); // 主机名
db.setPort(3306); // 端口
db.setDatabaseName("musicbase"); // 库名
db.setUserName("root"); //用户名
db.setPassword("tsy20010612"); // 密码
db.setUserName("user"); //用户名
db.setPassword("Tsy20010612"); // 密码
bool ok = db.open(); //打开数据库
if(ok) qDebug() << "connect !" << endl;
else qDebug() << "error!" << endl;
if (ok) qDebug() << "connect ok!" << endl;
}
14 changes: 10 additions & 4 deletions sign_up_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ sign_up_win::sign_up_win(QWidget *parent) : QWidget(parent)
// 初始化
_initMysql();

this ->setWindowTitle("登录窗口");
this ->setWindowIcon(QIcon(":/coin/mymusic.png")); // 主窗口的图标设置!


this ->setFixedSize(350, 200);
login_user_name = new QLineEdit(this);
login_user_password = new QLineEdit(this);
Expand Down Expand Up @@ -51,9 +55,11 @@ void sign_up_win::user_sign_up() {

void sign_up_win::_initMysql() {
db = QSqlDatabase::addDatabase("QMYSQL"); // 加载mysql 驱动
db.setHostName("localhost"); // 主机名
db.setHostName("8.133.131.37"); // 主机名
db.setPort(3306); // 端口
db.setDatabaseName("musicbase"); // 库名
db.setUserName("root"); //用户名
db.setPassword("tsy20010612"); // 密码
db.open(); //打开数据库
db.setUserName("user"); //用户名
db.setPassword("Tsy20010612"); // 密码
bool ok = db.open(); //打开数据库
if (ok) qDebug() << "connect ok!" << endl;
}

0 comments on commit 7e78d26

Please sign in to comment.