예제 #1
0
void MainBottomWidget::postionChanged(qreal pos)
{
	int tmp = (int)(pos * m_maxDuration / 1000);
	int min = tmp / 60;
	int sec = tmp % 60;
	QString str = QString("%1:%2").arg(QString::number(min, 10)).arg(QString::number(sec, 10));
	m_currentPostion->setText(str);
	emit setPostion( (qint64)(pos * m_maxDuration));
}
예제 #2
0
void QSprite::setPostion(QString name, int xpos, int ypos)
{
    setPostion(name, QPoint(xpos, ypos));
}
예제 #3
0
MusicWindow::MusicWindow(QWidget *parent) : MainWindow(parent)
{
    this->setWindowIcon(QIcon(":/images/icons/app_icon"));

    systemTrayIcon = new MySystemTrayIcon(this);
    connect(systemTrayIcon, SIGNAL(showWindow()), this, SLOT(show()));
    connect(systemTrayIcon, SIGNAL(quit()), this, SLOT(close()));

    player = new MyPlayer();
    connect(player, SIGNAL(playerStateChanged(int)), this, SLOT(playerStateChanged(int)));
    connect(player, SIGNAL(musicChanged(QString,int)), this, SLOT(musicChanged(QString,int)));

    topBar = new TopBar(this);
    connect(topBar, SIGNAL(setMinSize()), this, SLOT(showMinimized()));
    connect(topBar, SIGNAL(setMaxSize()), this, SLOT(setMaxSize()));
    connect(topBar, SIGNAL(closeWindow()), this, SLOT(hide()));
    connect(topBar, SIGNAL(quit()), this, SLOT(close()));
    connect(topBar, SIGNAL(setBackgroud(QString)), this, SLOT(setBackgroud(QString)));
    connect(topBar, SIGNAL(aboutQtMusic()), this, SLOT(aboutQtMusic()));

    fuctionPage = new QStackedWidget;
    fuctionPage->setMinimumWidth(200);

    lyricLabel = new LyricLabel(false, this);
    connect(player, SIGNAL(positionChanged(qint64)), lyricLabel, SLOT(postionChanged(qint64)));
    connect(lyricLabel, SIGNAL(changeTo(qint64)), player, SLOT(setPosition(qint64)));

    networkPage = new NetworkPage();

    QLabel *label2 = new QLabel("Network");
    label2->setAlignment(Qt::AlignCenter);
    QLabel *label3 = new QLabel("Download");
    label3->setAlignment(Qt::AlignCenter);
    fuctionPage->addWidget(lyricLabel);
    fuctionPage->addWidget(networkPage);
    fuctionPage->addWidget(label3);
    fuctionPage->setCurrentIndex(0);
    connect(topBar, SIGNAL(selectFuction(int)), fuctionPage, SLOT(setCurrentIndex(int)));

    musicPage = new MusicPage;
    musicPage->setMaximumWidth(500);
    musicPage->setMinimumWidth(300);
    connect(musicPage, SIGNAL(tryToCreateList(QString)), this, SLOT(tryToCreateList(QString)));
    connect(musicPage, SIGNAL(deleteList(QString)), this, SLOT(deleteList(QString)));
    connect(musicPage, SIGNAL(addMusics()), this, SLOT(addMusics()));
    connect(musicPage, SIGNAL(play(QString,int)), player, SLOT(playTheMusic(QString,int)));
    connect(musicPage, SIGNAL(removeTheMusic(QString,int)), this, SLOT(removeTheMusic(QString,int)));
    connect(musicPage, SIGNAL(removeAllMusics(QString)), this, SLOT(removeAllMusics(QString)));
    connect(musicPage, SIGNAL(moveMusic(QString,int,int)), this, SLOT(moveMusic(QString,int,int)));

    bottomBar = new BottomBar(this);
    connect(bottomBar, SIGNAL(setVoice(int)), player, SLOT(setVoice(int)));
    connect(bottomBar, SIGNAL(setMode(int)), player, SLOT(setPlayMode(int)));
    connect(bottomBar, SIGNAL(setPostion(qint64)), player, SLOT(setPosition(qint64)));
    connect(bottomBar, SIGNAL(setPostion(qint64)), lyricLabel, SLOT(setPostion(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), bottomBar, SLOT(setMaxDuration(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), bottomBar, SLOT(changePostionTo(qint64)));
    connect(musicPage, SIGNAL(play(QString,int)), bottomBar, SLOT(setPostionAvailable()));
    connect(bottomBar, SIGNAL(tryplay()), this, SLOT(clickPlay()));
    connect(bottomBar, SIGNAL(playPre()), this, SLOT(playPre()));
    connect(bottomBar, SIGNAL(playNext()), this, SLOT(playNext()));
    connect(systemTrayIcon, SIGNAL(setMode(int)), bottomBar, SLOT(setPlayMode(int)));
    connect(bottomBar, SIGNAL(setMode(int)), systemTrayIcon, SLOT(setPlayMode(int)));
    connect(bottomBar, SIGNAL(showLyric(QString)), topBar, SLOT(changeFuction(QString)));
    //connect(lyricLabel, SIGNAL(changeTo(qint64)), bottomBar, SLOT(changePostionTo(qint64)));
    //connect(lyricLabel, SIGNAL(changeTo(qint64)), bottomBar, SIGNAL(setPostion(qint64)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(topBar);

    QSplitter *splitter = new QSplitter(Qt::Horizontal, this);
    //设定分割窗口的分割条在拖动时是否为实时更新 true为实时更新 false则在拖动时只显示一条灰色的线条
    //在拖动到位并弹起鼠标后再显示分隔条
    splitter->setOpaqueResize(false);
    splitter->setChildrenCollapsible(false);
    splitter->addWidget(fuctionPage);
    splitter->addWidget(musicPage);
    splitter->setStretchFactor(0, 10);
    splitter->setStretchFactor(1, 1);
    splitter->setStyleSheet("QSplitter::handle { background-color: rgba(0,0,0,0%) }");
    splitter->setHandleWidth(4);
    mainLayout->addWidget(splitter);
    mainLayout->addWidget(bottomBar);
    mainLayout->setMargin(1);
    mainLayout->setSpacing(3);
    this->setLayout(mainLayout);

    dealMouse();
    readData();
}