MediaSearchWidget::MediaSearchWidget(QWidget *parent) :
    QWidget(parent)
{
//    m_animate = new StateMachineServer;

    this->setMinimumSize(160, 20);
    this->setFixedSize(160, 20);

    m_searchKeyEdit = new QLineEdit;
    m_searchKeyEdit->setText( tr("Searching...") );

    QToolButton* searchBtn = new QToolButton;

    QSize size = QSize( 20, this->size().height() );
    searchBtn->setMinimumSize(size);
    searchBtn->setMaximumSize(size);
    searchBtn->setIconSize(size);
    searchBtn->setIcon( QIcon(":/images/Button-search.png"));
    searchBtn->setFocusPolicy(Qt::NoFocus);// 得到焦点时,不显示虚线框
    searchBtn->setCursor(QCursor(Qt::PointingHandCursor));

    QHBoxLayout *editLayout = new QHBoxLayout();
    editLayout->setContentsMargins(0, 0, 0, 0);
    editLayout->addStretch();
    editLayout->addWidget(searchBtn);
    m_searchKeyEdit->setLayout(editLayout);
    // 设置输入框中文件输入区,不让输入的文字在被隐藏在按钮下
    m_searchKeyEdit->setTextMargins(0, 1, size.width(), 1);

    QHBoxLayout* hLayout = new QHBoxLayout;
    hLayout->setContentsMargins(0,0,0,0);
    hLayout->setSpacing(4);
    hLayout->addWidget(m_searchKeyEdit);
    hLayout->setAlignment(Qt::AlignLeft);
    this->setLayout(hLayout);

    connect(searchBtn, SIGNAL(clicked()), this, SLOT(searchMusic()) );
//    connect(this, SIGNAL(animateHide()), m_animate, SIGNAL(transHide()) );
//    /connect(this, SIGNAL(animateShow()), m_animate, SIGNAL(transShow()) );

}
Beispiel #2
0
//设计头部
void TitleGroupBox::setTitleUi()
{
    this ->setObjectName(tr("titleGroupBox"));

    //创建按钮
    lab_logo = new QLabel(this);                    //创建 Logo 图标
    lab_logoWords = new QLabel(this);               //创建 Logo 文字
    tbn_closeWindow = new QToolButton(this);        //创建 退出 按钮
    tbn_hideWindow = new QToolButton(this);         //创建 关闭 按钮
    tbn_miniWindow = new QToolButton(this);         //创建 最小化 按钮
    tbn_setting = new QToolButton(this);            //创建 设置 按钮
    tbn_theme = new QToolButton(this);              //创建 主题 按钮
    tbn_simple = new QToolButton(this);             //创建 MiNi窗口 按钮
    tbn_simple->setText("精简");                     //................
    tbn_switch_music = new QToolButton(this);       //创建 切换音乐模式 按钮
    tbn_switch_music->setText("音 乐");              //..................
    tbn_switch_video = new QToolButton(this);       //创建 切换视频模式 按钮
    tbn_switch_video->setText("视 频");              //..................
    lab_bearHead = new QLabel(this);                //创建 小熊头 图标
    lab_bearFoot = new QLabel(this);                //创建 小熊脚 图标
    lab_searchFrame = new QLabel;
    lab_searchBg = new QLabel;
    ln_search = new QLineEdit;                      //创建 搜索框
    ln_search->setPlaceholderText("搜索歌曲......");
    tbn_search = new QToolButton;                   //创建 搜索按钮
    lab_logo->setAlignment(Qt::AlignCenter);

    //设置按钮固定大小
    tbn_closeWindow->setFixedSize(11, 11);
    tbn_hideWindow->setFixedSize(11, 11);
    tbn_miniWindow->setFixedSize(11, 11);
    tbn_setting->setFixedSize(13, 13);
    tbn_theme->setFixedSize(15, 15);
    tbn_simple->setFixedSize(30, 14);
    tbn_switch_music->setFixedSize(tbn_switchMusicVideo_width, tbn_switchMusicVideo_height);
    tbn_switch_video->setFixedSize(tbn_switchMusicVideo_width, tbn_switchMusicVideo_height);
    lab_logo->setFixedSize(50, 50);
    lab_logoWords->setFixedSize(51, 31);
    lab_bearHead->setFixedSize(41, 29);
    lab_bearFoot->setFixedSize(18, 6);
    lab_searchFrame->setFixedSize(200, 22);
    lab_searchBg->setFixedHeight(21);
    tbn_search->setFixedSize(15, 15);

    //设置按钮提示
    tbn_closeWindow->setToolTip("退出程序");
    tbn_hideWindow->setToolTip("最小化到系统托盘");
    tbn_miniWindow->setToolTip("最小化");
    tbn_setting->setToolTip("设置");
    tbn_theme->setToolTip("更换主题");

    //布局
    layout_H = new QHBoxLayout;
    layout_H->addStretch();
    layout_H->addWidget(tbn_simple);
    layout_H->addWidget(tbn_theme);
    layout_H->addWidget(tbn_setting);
    layout_H->addWidget(tbn_miniWindow);
    layout_H->addWidget(tbn_hideWindow);
    layout_H->addWidget(tbn_closeWindow);
    layout_H->setSpacing(9);
    layout_H->setContentsMargins(0, 0, 11, 0);

    layout_search = new QHBoxLayout;
    layout_search->addWidget(ln_search);
    layout_search->addWidget(tbn_search);
    layout_search->setSpacing(0);
    layout_search->setContentsMargins(3, 0, 5, 0);

    layout_searchFrame = new QGridLayout;
    layout_searchFrame->addWidget(lab_searchBg, 0, 0, 1, 1);
    layout_searchFrame->addLayout(layout_search, 0, 0, 1, 1);
    layout_searchFrame->setSpacing(0);
    layout_searchFrame->setMargin(0);
    lab_searchFrame->setLayout(layout_searchFrame);

    //顶级布局
    layout_top = new QGridLayout;
    layout_top->addWidget(lab_logo, 8, 10, 50, 45);
    layout_top->addWidget(lab_logoWords, 53, 10, 31, 51);
    layout_top->addWidget(tbn_switch_music, 20, 500, tbn_switchMusicVideo_height, tbn_switchMusicVideo_width);
    layout_top->addWidget(lab_bearHead, 4, 500+(tbn_switchMusicVideo_height-29)/2, 29, 41);
    layout_top->addWidget(lab_bearFoot, 22+tbn_switchMusicVideo_height, 500+(tbn_switchMusicVideo_height-23)/2, 6, 18);
    layout_top->addWidget(tbn_switch_video, 20, 600, tbn_switchMusicVideo_height, tbn_switchMusicVideo_width);
    layout_top->addLayout(layout_H, 6, 650, 15, 50);
    layout_top->addWidget(lab_searchFrame, 33, 650, 15, 50);
    layout_top->setSpacing(0);
    layout_top->setMargin(0);
    layout_top->setContentsMargins(10, 8, 0, 0);
    this->setLayout(layout_top);

    tbn_switch_video->setToolTip("切换到视频播放");

    //显示设置按钮对象名称
    lab_logo->setObjectName("lab_logo");
    lab_logoWords->setObjectName("lab_logoWords");
    tbn_closeWindow->setObjectName("tbn_closeWindow");
    tbn_hideWindow->setObjectName("tbn_hideWindow");
    tbn_miniWindow->setObjectName("tbn_miniWindow");
    tbn_setting->setObjectName("tbn_setting");
    tbn_theme->setObjectName("tbn_theme");
    tbn_simple->setObjectName("tbn_simple_head");
    tbn_switch_music->setObjectName("tbn_switch_music");
    tbn_switch_video->setObjectName("tbn_switch_video");
    lab_bearHead->setObjectName("lab_bearHead");
    lab_bearFoot->setObjectName("lab_bearFoot");
    lab_searchBg->setObjectName("lab_searchBg");
    ln_search->setObjectName("ln_search");
    tbn_search->setObjectName("tbn_search");
/*
    QMatrix logoMatrix;
    logoMatrix.rotate(rotateAngle -= angleOffset);
    lab_logo->setPixmap(QPixmap(":/Images/logo_rotate.png").transformed(logoMatrix,Qt::SmoothTransformation));
*/
    //设置样式表
    setStyleSheet(
                "#titleGroupBox{"
                    "border: 0 solid white;"
                    "background: rgba(51, 73, 100, 180);"
                "}"

                //设置 Logo 样式表
                "#lab_logo{"
//                    "border-image: url(:/Images/logo.png);"
                "}"
                "#lab_logoWords{"
                    "border-image: url();"
                "}"

                //设置 关闭窗口 样式表
                "#tbn_closeWindow{"
                    "border-image: url(:/Images/closeWindow.png);"
                "}"
                "#tbn_closeWindow:hover{"
                    "border-image: url(:/Images/closeWindow_hover.png);"
                "}"

                "#tbn_hideWindow{"
                    "border-image: url(:/Images/hideWindow.png);"
                "}"
                "#tbn_hideWindow:hover{"
                    "border-image: url(:/Images/hideWindow_hover.png);"
                "}"

                "#tbn_miniWindow{"                                               //设置 最小化按钮 样式表
                    "border-image: url(:/Images/miniWindow.png);"
                "}"
                "#tbn_miniWindow::hover{"
                    "border-image: url(:/Images/miniWindow_hover.png);"
                "}"

                "#tbn_setting{"                                                  //设置 设置按钮 样式表
                    "border-image: url(:/Images/setting.png);"
                "}"
                 "#tbn_setting:hover{"
                    "border-image: url(:/Images/setting_hover.png);"
                "}"

                "#tbn_theme{"
                    "border-image: url(:/Images/theme.png);"
                "}"
                "#tbn_theme::hover{"
                    "border-image: url(:/Images/theme_hover.png);"
                "}"

                "#tbn_simple_head{"
                    "background: rgba(0, 0, 0, 0);"
                    "color: rgb(230, 230, 230);"
                "}"
                "#tbn_simple_head::hover{"
                    "background: rgba(0, 0, 0, 0);"
                    "color: rgb(23, 215, 255);"
                "}"

                "#tbn_switch_music, #tbn_switch_video{"
                    "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(255, 255, 255, 230), stop:0.4 rgba(50, 50, 50, 100), stop:0.5 rgba(50, 50, 50, 100), stop:0.6 rgba(50, 50, 50, 100), stop:1 rgba(255, 255, 255, 230));"
                    "border: 1px solid rgba(255, 255, 255, 60);"
                    "border-radius: 2px;"
                    "font-size: 11pt;"
                    "color: rgba(200, 255, 255, 255);"
                "}"

                "#tbn_switch_music:hover, #tbn_switch_video:hover{"
                    "background: rgba(0, 0, 0, 130);"
                "}"

                "#lab_bearHead{"
                    "border-image: url(:/Images/bear_head.png);"
                "}"
                "#lab_bearFoot{"
                    "border-image: url(:/Images/bear_foot.png);"
                "}"

                "#lab_searchBg{"
                    "height: 21;"
                    "border-radius: 10px;"
                    "background: rgba(0, 0, 0, 100);"
                "}"

                "#ln_search{"
                    "padding:2px 2px;"
                    "background: rgba(0, 0, 0, 0);"
                    "border: 0;"
                    "color: rgb(200, 255, 255);"
                "}"

                "#tbn_search{"
                    "border-image: url(:/Images/search);"
                "}"
                );


    lab_logoWords ->setText("<html><body><p><center><span style='color:#ffffff;'>小妖精</span></center></p></body></html>");

    connect(tbn_switch_video, SIGNAL(clicked()), this, SLOT(ShowVideoPlayerSlot()));            //播放视频
    connect(tbn_search, SIGNAL(clicked()), this, SLOT(searchMusic()));

    timer_logoRotate = new QTimer(this);
    timer_logoRotatePause = new QTimer(this);
    connect(timer_logoRotate, SIGNAL(timeout()), this, SLOT(timeout_logoRotate()));
    connect(timer_logoRotatePause, SIGNAL(timeout()), this, SLOT(timeout_logoRotetaRedo()));
    timer_logoRotate->start(timer_rotateStart);
}
Beispiel #3
0
Widget::Widget(QWidget *parent, Qt::WindowFlags flags)
    : QWidget(parent, flags)
{
    //设置窗体最小的尺寸
    setMinimumSize(1000, 650);
    //设置窗体图标
    setWindowIcon(QPixmap(":/images/winIcon_100.png"));

    //设置窗体标题
    setWindowTitle(tr("Haku"));

    //设置鼠标跟踪
    //setMouseTracking(true);

    //设置窗体标题栏,自定义,此时可以缩放,但不能移动,所以可能需要重新实现鼠标移动事件
    flags = Qt::CustomizeWindowHint;
    flags |= Qt::FramelessWindowHint; //无边框,会无法移动以及缩放
    //flags |= Qt::WindowStaysOnTopHint;
    setWindowFlags(flags);
    //setAttribute(Qt::WA_TranslucentBackground,true);

    //设置透明
    //setWindowOpacity(0);

    //设置皮肤
    //this->setAutoFillBackground(true);
    //QPalette mainPalette;
    //mainPalette.setBrush(QPalette::Background, QBrush(skinPic));
    //this->setPalette(mainPalette);
    setSkin(skinPic);

    //设置窗体的字体
    font = QFont("ZYSong18030", 14);
    setFont(font);

    /***************************************************************************/
    //创建主布局及三个子布局,并设置布局
    mainLayout = new QGridLayout(this);
    mainLayout->setSpacing(0);
    mainLayout->setMargin(0);
    firstLayout = new QHBoxLayout;
    secondLayout = new QHBoxLayout;
    threeLayout = new QHBoxLayout;
    mainLayout->addLayout(firstLayout, 0, 0, 1, 1);
    mainLayout->addLayout(secondLayout, 1, 0, 5, 1);
    mainLayout->addLayout(threeLayout, 6, 0, 1, 1);


    /***************************************************************************/
    //创建第一个子布局
    userImage = new QPushButton;
    userImage->setFlat(true);
    userImagePix = new QPixmap(":/images/haku_icon_40.png");
    userImage->setIcon(*userImagePix);
    userImage->setIconSize((*userImagePix).size());
    userImage->setToolTip(tr("更换头像"));

    userName = new QPushButton;
    userName->setFlat(true);
    userName->setText(tr("Haku520"));
    userName->setToolTip(tr("更改用户名"));

    searchEdit = new QLineEdit;
    searchBtn = new QPushButton;
    searchBtn->setFlat(true);
    searchBtn->setIcon(QPixmap(":/images/searchIcon.png"));
    searchBtn->setToolTip(tr("搜索歌曲"));
    //输入完毕或点击搜索按钮则搜索歌曲
    connect(searchEdit, SIGNAL(editingFinished()), this, SLOT(searchMusic()));
    connect(searchBtn, SIGNAL(clicked()), this, SLOT(searchMusic()));

    skinBtn = new QPushButton;
    skinBtn->setFlat(true);
    skinBtn->setIcon(QPixmap(":/images/skinIcon.png"));
    skinBtn->setToolTip(tr("更换皮肤"));
    //连接更换皮肤的槽函数
    connect(skinBtn, SIGNAL(clicked()), this, SLOT(changeSkin()));

    preferenceBtn = new QPushButton;
    preferenceBtn->setFlat(true);
    preferenceBtn->setIcon(QPixmap(":/images/preferenceIcon.png"));
    preferenceBtn->setToolTip(tr("设置"));

    controlBtn = new QPushButton;
    controlBtn->setFlat(true);
    controlBtn->setIcon(QPixmap(":/images/controlIcon.png"));
    controlBtn->setToolTip(tr("遥控器"));

    hideBtn = new QPushButton;
    hideBtn->setFlat(true);
    hideBtn->setIcon(QPixmap(":/images/hideIcon.png"));
    hideBtn->setToolTip(tr("隐藏音乐库"));

    minimumBtn = new QPushButton;
    minimumBtn->setFlat(true);
    minimumBtn->setIcon(QPixmap(":/images/minimumIcon.png"));
    minimumBtn->setToolTip(tr("最小化窗口"));

    closeBtn = new QPushButton;
    closeBtn->setFlat(true);
    closeBtn->setIcon(QPixmap(":/images/closeIcon.png"));
    closeBtn->setToolTip(tr("关闭"));

    //将各个按钮添加到第一个子布局上
    firstLayout->setMargin(0);
    firstLayout->addWidget(userImage);
    firstLayout->addWidget(userName);
    firstLayout->addStretch();
    firstLayout->addWidget(searchEdit);
    firstLayout->addWidget(searchBtn);
    firstLayout->addStretch();
    firstLayout->addWidget(skinBtn);
    firstLayout->addWidget(preferenceBtn);
    firstLayout->addWidget(controlBtn);
    firstLayout->addWidget(hideBtn);
    firstLayout->addWidget(minimumBtn);
    firstLayout->addWidget(closeBtn);

    //添加信号槽,暂时只实现退出按钮,其余的之后得补上!
    connect(closeBtn, SIGNAL(clicked()), this, SLOT(quitEmit()));
    connect(minimumBtn, SIGNAL(clicked()), this, SLOT(minWidget()));


    /***********************************************************************/
    //创建第二个子布局
    secFrameLayout = new SecFrame;
    secondLayout->addWidget(secFrameLayout);

    //接收从第二个子布局发送过来的可以播放的信号,对传递过来的这首歌曲进行播放控制
    connect(secFrameLayout, SIGNAL(SendToTop(SingleMusic *)),
            this, SLOT(PreplayOrpauseMusic(SingleMusic*)));

    //接收从主界面传递过来的搜索音乐的信号,让downloadDisplay窗体直接进行实际的搜索
    connect(this, SIGNAL(searchMusicString(QString)),
            secFrameLayout->downloadDisplay,
            SLOT(search(QString)));
    //试听音乐时,能够及时反映出播放按钮及进度条的显示
    //connect(secFrameLayout, SIGNAL(changeBtnIcon(bool)), this, SLOT(currentIsPlaying(bool)));

    connect(secFrameLayout, SIGNAL(closePrevMusic()), this, SLOT(closePreMusic()));

    /***********************************************************************/
    //创建第三个子布局
    playerBtn = new QPushButton;
    playerBtn->setFlat(true);
    playerBtn->setIcon(QPixmap(":/images/playerIcon.png"));
    playerBtn->setIconSize(QPixmap(":/images/playerIcon.png").size());
    //关联上歌曲的播放控制事件
    playBool = true;
    connect(playerBtn, SIGNAL(clicked()), this, SLOT(player()));

    preMusicBtn = new QPushButton;
    preMusicBtn->setFlat(true);
    preMusicBtn->setIcon(QPixmap(":/images/preMusicIcon.png"));
    preMusicBtn->setIconSize(QPixmap(":/images/preMusicIcon.png").size());
    //下面是测试用,之后用其正统的功能(即播放上一首歌曲)替换掉
    connect(preMusicBtn, SIGNAL(clicked()), this, SLOT(prevMusic()));

    nextMusicBtn = new QPushButton;
    nextMusicBtn->setFlat(true);
    nextMusicBtn->setIcon(QPixmap(":/images/nextMusicIcon.png"));
    nextMusicBtn->setIconSize(QPixmap(":/images/nextMusicIcon.png").size());

    loveMusicBtn = new QPushButton;
    loveMusicBtn->setFlat(true);
    loveMusicBtn->setIcon(QPixmap(":/images/loveIcon.png"));
    loveMusicBtn->setIconSize(QPixmap(":/images/loveIcon.png").size());
    loveMusicBtn->setToolTip(tr("收藏"));

    downloadBtn = new QPushButton;
    downloadBtn->setFlat(true);
    downloadBtn->setIcon(QPixmap(":/images/downloadIcon.png"));
    downloadBtn->setIconSize(QPixmap(":/images/downloadIcon.png").size());
    downloadBtn->setToolTip(tr("下载"));

    similarBtn = new QPushButton;
    similarBtn->setFlat(true);
    similarBtn->setIcon(QPixmap(":/images/similarIcon.png"));
    similarBtn->setIconSize(QPixmap(":/images/similarIcon.png").size());
    similarBtn->setToolTip(tr("相似歌曲"));

    orderBtn = new QPushButton;
    orderBtn->setFlat(true);
    orderBtn->setIcon(QPixmap(":/images/orderIcon.png"));
    orderBtn->setIconSize(QPixmap(":/images/orderIcon.png").size());
    orderBtn->setToolTip(tr("播放顺序"));

    volumeBtn = new QPushButton;
    volumeBtn->setFlat(true);
    volumeBtn->setIcon(QPixmap(":/images/volumeIcon.png"));
    volumeBtn->setIconSize(QPixmap(":/images/volumeIcon.png").size());
    volumeBtn->setToolTip(tr("音量"));

    soundEffectsBtn = new QPushButton;
    soundEffectsBtn->setFlat(true);
    soundEffectsBtn->setIcon(QPixmap(":/images/soundEffectsIcon.png"));
    soundEffectsBtn->setIconSize(QPixmap(":/images/soundEffectsIcon.png").size());
    soundEffectsBtn->setToolTip(tr("音效"));

    lyricBtn = new QPushButton;
    lyricBtn->setFlat(true);
    lyricBtn->setIcon(QPixmap(":/images/lyricIcon.png"));
    lyricBtn->setIconSize(QPixmap(":/images/lyricIcon.png").size());
    lyricBtn->setToolTip(tr("歌词"));

    playQueueBtn = new QPushButton;
    playQueueBtn->setFlat(true);
    playQueueBtn->setIcon(QPixmap(":/images/playQueueIcon.png"));
    playQueueBtn->setIconSize(QPixmap(":/images/playQueueIcon.png").size());
    playQueueBtn->setToolTip(tr("播放队列"));

    /*********************************进度条的定义**********************************/


    /********************************以上是进度条的定义*****************************/

    //将相关元素添加到第三个子布局上
    threeLayout->addSpacing(60);
    threeLayout->setMargin(0);
    threeLayout->addWidget(preMusicBtn);
    threeLayout->addWidget(playerBtn);
    threeLayout->addWidget(nextMusicBtn);
    threeLayout->addSpacing(3);

    //添加进度条
    createSlider();
    threeLayout->addWidget(sliderFrame);

    threeLayout->addSpacing(3);
    threeLayout->addWidget(loveMusicBtn);
    threeLayout->addWidget(downloadBtn);
    threeLayout->addWidget(similarBtn);
    threeLayout->addWidget(orderBtn);
    threeLayout->addWidget(volumeBtn);
    threeLayout->addWidget(soundEffectsBtn);
    threeLayout->addWidget(lyricBtn);
    threeLayout->addWidget(playQueueBtn);


}
void MediaSearchWidget::searchMusic()
{
    QString key = m_searchKeyEdit->text();
    emit searchMusic(key);
}