Пример #1
0
//响应鼠标右键点击事件
void MusicList::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu menu;
    menu.addAction(QIcon(":/images/locateButton.png"), tr("定位到当前播放歌曲"), this, SLOT(slot_LocateCurrentMusic()));
    menu.addSeparator();
    menu.addAction(delCurrentMusicAction);
    menu.addAction(clearMusicList);
	menu.addAction(saveListAction);
    menu.addSeparator();
    menu.addAction(closeAction);
    menu.exec(event ->globalPos());//返回鼠标指针的全局位置
    event ->accept();
}
Пример #2
0
//响应鼠标右键点击事件
void MusicList::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu menu;
	menu.addAction(QIcon(":/images/shareMusic.png"), tr("分享"), this, SLOT(slot_ShareCurrentMusic()));
    menu.addAction(QIcon(":/images/locateButton.png"), tr("定位到当前播放歌曲"), this, SLOT(slot_LocateCurrentMusic()));
    menu.addSeparator();
	menu.addAction(QIcon(":/images/delCurrentMusic.png"), tr("删除当前歌曲"), this, SLOT(slot_DelCurrentMusic()));
	menu.addAction(QIcon(":/images/clearMusicList.png"), tr("清空列表"), this, SLOT(slot_ClearAllMusicList()));
	menu.addAction(QIcon(":/images/saveList.png"), tr("保存列表"), this, SLOT(slot_SaveList()));
    menu.addSeparator();
	menu.addAction(QIcon(":/images/quitAction.png"), tr("关闭音乐列表"), parent, SLOT(slot_OpenMusicList()));
    menu.exec(event->globalPos());//返回鼠标指针的全局位置
    event->accept();
}
Пример #3
0
MusicListWidget::MusicListWidget(MusicList *playList, map<QString, int> *mapMusicRows, QWidget *parent)
    : m_playList(playList), m_mapMusicRows(mapMusicRows), m_parent(parent)
{
    //ÉèÖô°¿Ú»ù±¾ÊôÐÔ
    this ->resize(400, 450);//ÉèÖô°Ìå´óС
    this ->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);//È¥µô´°Ìå±ß¿ò
    this ->setAttribute(Qt::WA_TranslucentBackground);//ÉèÖñ³¾°Í¸Ã÷
    this ->setWindowIcon(QIcon(":/images/CZPlayer.png"));//ÉèÖÃlogo
    this ->setWindowTitle(tr("ÒôÀÖÁбí"));

    //ËÑË÷¿ò
    searchLineEdit = new QLineEdit(this);
    searchLineEdit ->setObjectName(tr("searchLineEdit"));
    searchLineEdit ->setText(tr("ËÑË÷¸èÊÖ¡¢¸èÇú"));
    searchLineEdit ->installEventFilter(this);
    //searchLineEdit ->setPlaceholderText(tr("ËÑË÷¸èÊÖ¡¢¸èÇú"));

    //ËÑË÷°´Å¥
    searchButton = new QPushButton(this);
    searchButton ->setObjectName(tr("searchButton"));

    //·µ»Ø
    backButton = new QPushButton(this);
    backButton ->setObjectName(tr("backButton"));
    backButton ->setToolTip(tr("·µ»ØÒôÀÖÁбí"));
    backButton ->setVisible(false);

    //Ìí¼Ó¸èÇú
    addMusicButton = new QPushButton(this);
    addMusicButton ->setObjectName(tr("addMusicButton"));
    addMusicButton ->setToolTip(tr("Ìí¼Ó¸èÇú"));

    //¶¨Î»¸èÇú
    localeButton = new QPushButton(this);
    localeButton ->setObjectName(tr("localeButton"));
    localeButton ->setToolTip(tr("¶¨Î»µ±Ç°²¥·Å¸èÇú"));

    //ɾ³ýµ±Ç°¸èÇú
    delMusicButton = new QPushButton(this);
    delMusicButton ->setObjectName(tr("delMusicButton"));
    delMusicButton ->setToolTip(tr("ɾ³ýµ±Ç°¸èÇú"));

    //ËÑË÷¸èÇú
    findButton = new QPushButton(this);
    findButton ->setObjectName(tr("findButton"));
    findButton ->setToolTip(tr("ËÑË÷¸èÇú"));

	//Ìí¼Ó¸èÇú
	addMusicAction = new QAction(this);
	addMusicAction ->setIcon(QIcon(":/images/addMusic.png"));
	addMusicAction ->setText(tr("Ìí¼Ó¸èÇú"));

	//Ìí¼Ó²¥·ÅÁбí
	addMusicListAction = new QAction(this);
	addMusicListAction ->setIcon(QIcon(":/images/addMusicList.png"));
	addMusicListAction ->setText(tr("ÔØÈë²¥·ÅÁбí"));

    //¶¨Ê±Æ÷
    timer = new QTimer(this);
    timer ->start(1000);

    QSpacerItem *topItem = new QSpacerItem(380, 37, QSizePolicy::Fixed, QSizePolicy::Fixed);
    QSpacerItem *bottomItem = new QSpacerItem(380, 30, QSizePolicy::Fixed, QSizePolicy::Fixed);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout ->addItem(topItem);
    mainLayout ->addWidget(m_playList);
    mainLayout ->addItem(bottomItem);
    this ->setLayout(mainLayout);

    searchLineEdit ->setGeometry(27, 7, 250, 30);
    searchButton ->setGeometry(287, 9, 90, 30);
    backButton ->setGeometry(257, 15, 15, 14);
//    m_playList ->setGeometry(10, 37, 380, 360);
    addMusicButton ->setGeometry(60, 417, 25, 25);
    localeButton ->setGeometry(145, 417, 25, 25);
    delMusicButton ->setGeometry(230, 417, 25, 25);
    findButton ->setGeometry(315, 417, 25, 25);

    //ÐźÅÓë²Û
    connect(addMusicButton, SIGNAL(clicked()), this, SLOT(slot_OnClickedAddMusic()));		//Ìí¼Ó¸èÇú
    connect(localeButton, SIGNAL(clicked()), m_playList, SLOT(slot_LocateCurrentMusic()));	//¶¨Î»µ±Ç°²¥·Å¸èÇú
    connect(delMusicButton, SIGNAL(clicked()), m_playList, SLOT(slot_DelCurrentMusic()));	//ɾ³ýµ±Ç°¸èÇú
    connect(searchButton, SIGNAL(clicked()), this, SLOT(slot_SearchMusic()));				//ËÑË÷¸èÇú
    connect(timer, SIGNAL(timeout()), this, SLOT(slot_LineEditFocus()));					//ÊäÈë¿ò¾Û½¹
    connect(backButton, SIGNAL(clicked()), this, SLOT(slot_BackMusicList()));				//·µ»ØÒôÀÖÁбí
	connect(addMusicAction, SIGNAL(triggered()), this, SLOT(slot_AddMusic()));				//Ìí¼Ó¸èÇú
	connect(addMusicListAction, SIGNAL(triggered()), this, SLOT(slot_AddMusicList()));		//Ìí¼Ó²¥·ÅÁбí
}