Skip to content

Commit

Permalink
feat: create new branch and upload ktvplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sugar0612 committed Mar 21, 2023
1 parent e4ada8f commit d53f27f
Show file tree
Hide file tree
Showing 136 changed files with 3,701 additions and 0 deletions.
81 changes: 81 additions & 0 deletions KtvPlayer/Control/LoginWidget/loginw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include "loginw.h"

LoginW::LoginW(QWidget *p, int x, int y, int width, int height)
{
this->setParent(p);
setWindowFlags(Qt::FramelessWindowHint);
setGeometry(x, y, width, height);

NorFont.setFamily("宋体");
NorFont.setPointSize(15);

Radfont.setFamily("幼圆");
Radfont.setPointSize(10);

account = new QLineEdit(this);
account->setFont(NorFont);
account->setGeometry(this->width() / 2 - 150, this->height() / 2 - 100, 200, 40);
account->setStyleSheet("QLineEdit{height: 20px;border-style:none; padding:6px; border-radius: 20px;background:rgba(100, 205, 210, 100); }");

password = new QLineEdit(this);
password->setFont(NorFont);
password->setGeometry(this->width() / 2 - 150, this->height() / 2 - 50, 200, 40);
password->setStyleSheet("QLineEdit{height: 20px;border-style:none; padding:6px; border-radius: 20px;background:rgba(100, 205, 210, 100); }");
password->setEchoMode(QLineEdit::Password);

AccountLab = new QLabel(this);
AccountLab->setGeometry(account->x() - 65, account->y(), 100, 40);
AccountLab->setFont(NorFont);
AccountLab->setText("用户名");

PassLab = new QLabel(this);
PassLab->setGeometry(password->x() - 65, password->y(), 100, 40);
PassLab->setFont(NorFont);
PassLab->setText("密码");

RegisterBtn = new NewButton(ResPath + "register.png", ResPath + "register_c.png");
RegisterBtn->setParent(this);
RegisterBtn->move(PassLab->x(), PassLab->y() + 80);

LoginBtn = new NewButton(ResPath + "Login.png", ResPath + "Login_c.png");
LoginBtn->setParent(this);
LoginBtn->move(RegisterBtn->x() + 180, RegisterBtn->y());

Manager = new QRadioButton(this);
Manager->setText("我是管理员");
Manager->setFont(Radfont);
Manager->move(PassLab->x(), PassLab->y() + 50);

User = new QRadioButton(this);
User->setChecked(true);
User->setText("我是用户");
User->setFont(Radfont);
User->move(Manager->x() + 180, Manager->y());

connect(Manager, &QRadioButton::clicked, this, &LoginW::ClickedManger);
connect(User, &QRadioButton::clicked, this, &LoginW::ClickedUser);
connect(RegisterBtn, &QPushButton::clicked, this, [=] () {
emit ShowRegister();
});

connect(LoginBtn, &QPushButton::clicked, this, [=] () {
QString name = account->text();
QString pwd = password->text();
if (Type == 1) emit RequestLogin(name, pwd);
else emit RequestLoginManager(name, pwd);
});
}

void LoginW::ClickedUser() {
Type = (User->isChecked()) ? 1 : 0;
}

void LoginW::ClickedManger() {
Type = (Manager->isChecked()) ? 0 : 1;
}


void LoginW::ClearLineEditText() {
account->setText("");
password->setText("");
}
44 changes: 44 additions & 0 deletions KtvPlayer/Control/LoginWidget/loginw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef LOGINW_H
#define LOGINW_H

#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QRadioButton>

#include <Control/NewButton.h>

#include <QFont>
#include <QDebug>

class LoginW : public QWidget
{
Q_OBJECT
public:
LoginW(QWidget *p, int x, int y, int width, int height);
void ClearLineEditText();

private:
const QString ResPath = ":/Resources/Texture/";

QFont NorFont, Radfont;
QLabel *AccountLab, *PassLab{};
QLineEdit *account, *password;
QRadioButton *Manager{}, *User{};

NewButton *LoginBtn{}, *RegisterBtn{};

int Type = 1; // 0 -> Manager, 1 -> User;

private slots:
void ClickedManger();
void ClickedUser();

signals:
void ShowRegister();
void RequestLogin(QString, QString);
void RequestLoginManager(QString, QString);
};

#endif // LOGINW_H
56 changes: 56 additions & 0 deletions KtvPlayer/Control/LoginWidget/register.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "register.h"

Register::Register(QWidget *p, int x, int y, int width, int height)
{
this->setParent(p);
setWindowFlags(Qt::FramelessWindowHint);
setGeometry(x, y, width, height);

NorFont.setFamily("宋体");
NorFont.setPointSize(15);

account = new QLineEdit(this);
account->setFont(NorFont);
account->setGeometry(this->width() / 2 - 150, this->height() / 2 - 100, 200, 40);
account->setStyleSheet("QLineEdit{height: 20px;border-style:none; padding:6px; border-radius: 20px;background:rgba(100, 205, 210, 100); }");

password = new QLineEdit(this);
password->setFont(NorFont);
password->setGeometry(this->width() / 2 - 150, this->height() / 2 - 50, 200, 40);
password->setStyleSheet("QLineEdit{height: 20px;border-style:none; padding:6px; border-radius: 20px;background:rgba(100, 205, 210, 100); }");
password->setEchoMode(QLineEdit::Password);

AccountLab = new QLabel(this);
AccountLab->setGeometry(account->x() - 65, account->y(), 100, 40);
AccountLab->setFont(NorFont);
AccountLab->setText("用户名");

PassLab = new QLabel(this);
PassLab->setGeometry(password->x() - 65, password->y(), 100, 40);
PassLab->setFont(NorFont);
PassLab->setText("密码");

OkBtn = new NewButton(ResPath + "OK.png", ResPath + "OK_c.png");
OkBtn->setParent(this);
OkBtn->move(PassLab->x(), PassLab->y() + 50);

CancelBtn = new NewButton(ResPath + "Cancel.png", ResPath + "Cancel_c.png");
CancelBtn->setParent(this);
CancelBtn->move(OkBtn->x() + 180, OkBtn->y());

connect(OkBtn, &QPushButton::clicked, this, [=] () {
QString name = account->text();
QString pwd = password->text();
emit RequestRegister(name, pwd);
});

connect(CancelBtn, &NewButton::clicked, this, [=] () {
emit CloseRegister();
});
}


void Register::ClearLineEditText() {
account->setText("");
password->setText("");
}
37 changes: 37 additions & 0 deletions KtvPlayer/Control/LoginWidget/register.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef REGISTER_H
#define REGISTER_H

#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QRadioButton>

#include <Control/NewButton.h>
#include <Module/Sql/Sql.h>

#include <QFont>
#include <QDebug>
#include <QMessageBox>

class Register : public QWidget
{
Q_OBJECT
public:
Register(QWidget *p, int x, int y, int width, int height);
void ClearLineEditText();

private:
const QString ResPath = ":/Resources/Texture/";

QFont NorFont;
QLabel *AccountLab, *PassLab{};
QLineEdit *account, *password;
NewButton *OkBtn{}, *CancelBtn{};

signals:
void CloseRegister();
void RequestRegister(QString, QString);
};

#endif // REGISTER_H
60 changes: 60 additions & 0 deletions KtvPlayer/Control/LrcWidget/Lrcwgt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "Lrcwgt.h"

LrcWgt::LrcWgt(QWidget *parent) : QWidget(parent)
{
QFont font;
font.setFamily("幼圆");
font.setPointSize(23);
font.setWeight(30);
setWindowFlags(Qt::FramelessWindowHint); // 删除以前的 最大化 最小化 关闭自己写

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

this->setWindowFlags(Qt::FramelessWindowHint); //使得窗体透明
this->setAttribute(Qt::WA_TranslucentBackground, true); // 透明显示

this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint); //窗口最前面 不会因为点击而隐藏

LrcLab = new QLabel(this);
LrcLab->setGeometry(0, 0, this ->width(), this ->height());
LrcLab->setFont(font);
LrcLab->setStyleSheet("QLabel{color: rgb(238, 201, 0);}");
LrcLab->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
LrcLab->setText("暂无歌词");
}

void LrcWgt::mouseMoveEvent(QMouseEvent *e) {
// 移动窗口
if(leftflag && e->pos().y() >= 0 && e->pos().y() <= this->height()) {
win_p = e->globalPos();
this->move(win_p - glbal_p);
}
}

void LrcWgt::mousePressEvent(QMouseEvent *e) {
// 点击窗口
if(e->button() == Qt::LeftButton && e->pos().y() >= 0 && e->pos().y() <= this->height()) {
leftflag = true;
glbal_p = e->globalPos() - this->pos();
}
}

//透明设置 可以点击窗口了
void LrcWgt::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
QPen pen;
pen.setColor(QColor(0, 0, 0, 100));
painter.setPen(pen);
painter.setBrush(QBrush(QColor(0, 0, 0, 100)));

painter.drawRect(this->rect());

return QWidget::paintEvent(event);
}

void LrcWgt::SetLrc(QString Lrc) {
LrcLab->setText(Lrc);
}
33 changes: 33 additions & 0 deletions KtvPlayer/Control/LrcWidget/Lrcwgt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef LRCWGT_H
#define LRCWGT_H

#include <QWidget>
#include <QLabel>
#include <QPainter>
#include <QFont>

#include <QMoveEvent>
#include <QPaintEvent>
#include <QIcon>

class LrcWgt : public QWidget
{
Q_OBJECT
public:
LrcWgt(QWidget *p);

public slots:
void SetLrc(QString Lrc);

private:

bool leftflag = false;
QLabel *LrcLab = nullptr;
QPoint glbal_p, win_p; // 用win_p - glabel_p 就是 偏移量

void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void paintEvent(QPaintEvent * event);
};

#endif // LRCWGT_H
Loading

0 comments on commit d53f27f

Please sign in to comment.