⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmcontrolbar.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* qmcontrolbar.cpp * * $Id: qmcontrolbar.cpp,v 1.51.2.1 2002/09/23 19:26:49 kyllingstad Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2002 Apollo Team.  See CREDITS file. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html */#include "qmcontrolbar.h"#include "qmaboutdialog.h"#include "qmcompactwindow.h"#include "qmconfig.h"#include "qmconfigdialog.h"#include "qmdefaultmenuitem.h"#include "qmdiritem.h"#include "qmfiledialog.h"#include "qmmainwindow.h"#include "qmmenubutton.h"#include "qmpixmapsupplier.h"#include "qmplaylist.h"#include "qmsongitem.h"#include "message.h"#include <iostream>#include <qapplication.h>#include <qdialog.h>#include <qdir.h>#include <qfiledialog.h>#include <qheader.h>#include <qiconset.h>#include <qlabel.h>#include <qlistview.h>#include <qmessagebox.h>#include <qpopupmenu.h>#include <qrect.h>#include <qstringlist.h>#include <qtoolbar.h>#include <qtoolbutton.h>#include <qaction.h>/** * \file qmcontrolbar.cpp * \brief The toolbar with the play etc. buttons *//*!  \class QmControlBar qmcontrolbar.h  \brief Represents the control bar.  The control bar is the tool bar with the play/pause/stop/next/prev etc.  It is a very central class as it is from here the user executes most  commands.*//*!*/QmControlBar::QmControlBar(	QmMainWindow *parent,	const char *name)	: QToolBar(parent, name),	  m_pMainWindow(parent),	  m_pCompactWindow(0),	  m_pMainFileDialog( new QmFileDialog() ),	  m_MainFileDialogAvailable( true ),	  m_StopClicked( false ){	setHorizontalStretchable(true);    m_Trash.setAutoDelete( true );    m_pTrashTimer = new QTimer( this );    connect( m_pTrashTimer, SIGNAL( timeout() ),             this, SLOT( cleanup() ) );    QmPixmapSupplier *sup = QmPixmapSupplier::instance();    m_pFileMenu = new QPopupMenu(this);	// It would be best if there was only an 'Append' item, but QFileDialog only supports	// either files or folders at one time, not both.    QString add_song_text( tr("Add songs...") );    QAction *file_add_song = new QAction("",                                         QIconSet( sup->pixmap( "icons-songitem" )),                                         add_song_text,                                         CTRL + Key_I,                                         this);    connect( file_add_song, SIGNAL(activated()),             this, SLOT(addFiles()));    QAction *file_add_song_sys = new QAction("",                                             QIconSet( sup->pixmap( "icons-songitem" )),                                             add_song_text,                                             0,                                             this);    connect( file_add_song_sys, SIGNAL(activated()),             this, SLOT(addFiles()));    file_add_song->addTo( m_pFileMenu );    m_pSystrayActionMap.insert( ActionAddSongs, file_add_song_sys );	QFont f = m_pFileMenu->font();    QString add_dir_text( tr("Add dir...") );	int adddirid = m_pFileMenu->insertItem(new QmDefaultMenuItem(add_dir_text, f));	m_pFileMenu->setAccel(CTRL + Key_D, adddirid);	m_pFileMenu->connectItem(adddirid, this, SLOT(addDir()));    m_pFileMenu->changeItem( adddirid, QIconSet( sup->pixmap( "icons-folder" ) ),							 sup->pixmap( "icons-folder" ) );    QAction *file_add_dir = new QAction("",                                        QIconSet( sup->pixmap( "icons-folder" ) ),                                        add_dir_text,                                        0,                                        this);    connect( file_add_dir, SIGNAL(activated()),             this, SLOT(addDir()));    m_pSystrayActionMap.insert( ActionAddDir, file_add_dir );    QString add_playlist_text( tr("Add playlist...") );    QAction *file_add_playlist = new QAction( "",                                              QIconSet( sup->pixmap( "icons-playlist" )),                                              add_playlist_text,                                              CTRL + Key_O,                                              this );    connect( file_add_playlist, SIGNAL(activated()),             this, SLOT(addPlayList()));    QAction *file_add_playlist_sys = new QAction( "",                                                  QIconSet( sup->pixmap( "icons-playlist" )),                                                  add_playlist_text,                                                  0,                                                  this );    connect( file_add_playlist_sys, SIGNAL(activated()),             this, SLOT(addPlayList()));    file_add_playlist->addTo( m_pFileMenu );    m_pSystrayActionMap.insert( ActionAddPlaylist, file_add_playlist_sys );    QAction *file_save_playlist = new QAction( "",                                               tr("Save playlist..."),                                               CTRL + Key_S,                                               this );    connect( file_save_playlist, SIGNAL(activated()),             this, SLOT(savePlayList()));    file_save_playlist->addTo( m_pFileMenu );    QAction *file_load_playlist = new QAction( "",                                               tr("Load Playlist list ..."),                                               CTRL + Key_L,                                               this );    connect( file_load_playlist, SIGNAL(activated()),             this, SLOT(loadPlayListTree()));    file_load_playlist->addTo( m_pFileMenu );    m_pFileMenu->insertSeparator();    QAction *file_quit = new QAction( "",                                      tr("Quit"),                                      CTRL + Key_Q,                                      this );    connect( file_quit, SIGNAL(activated()),             qApp, SLOT(quit()));    file_quit->addTo( m_pFileMenu );    m_pAddFiles = new QmMenuButton(QIconSet( sup->pixmap( "icons-eject" ) ),								   tr("Add files"),								   this,								   m_pFileMenu);	connect(m_pAddFiles, SIGNAL(iconClicked()), this, SLOT(addDir()));    m_pPlayListMenu = new QPopupMenu(this);    m_pPlayListMenu->insertItem(tr("Clear"),								m_pMainWindow,								SLOT(clearPlayList()));	m_pPlayListMenu->insertItem(tr("Remove"),								m_pMainWindow,								SLOT(removeItem()),								Key_Delete);    m_pPlayListMenu->insertItem(tr("Mark as bad"),								m_pMainWindow,								SLOT(setMark()));	f = m_pPlayListMenu->font();    QString mark_edit_text( tr("Mark editor...") );    int markedid = m_pPlayListMenu->insertItem(new QmDefaultMenuItem(mark_edit_text, f));	m_pPlayListMenu->connectItem(markedid, m_pMainWindow, SLOT(showMarkDialog()));    QAction *mark_edit_action = new QAction("",                                            mark_edit_text,                                            0,                                            this);    connect( mark_edit_action, SIGNAL(activated()),             m_pMainWindow, SLOT(showMarkDialog()));    m_pSystrayActionMap.insert( ActionMarkEdit, mark_edit_action );    m_pPlayListMenu->insertSeparator();    m_pPlayListMenu->insertItem(tr("Find..."),								m_pMainWindow,								SLOT(activateSearch()),                                CTRL + Key_F);        m_pPlayListButton = new QmMenuButton(QIconSet( sup->pixmap( "icons-playlist" ) ),										 tr("Modify playlist"),										 this,										 m_pPlayListMenu);	connect(m_pPlayListButton, SIGNAL(iconClicked()), m_pMainWindow, SLOT(showMarkDialog()));	    m_pOptionsMenu = new QPopupMenu(this);	f = m_pOptionsMenu->font();    QString settings_text( tr("Settings...") );	int settingsid = m_pOptionsMenu->insertItem(new QmDefaultMenuItem(settings_text, f));	m_pOptionsMenu->connectItem(settingsid, this, SLOT(openConfigDialog()));    QAction *settings_action = new QAction("",                                           QIconSet( sup->pixmap( "icons-options" ) ),                                           settings_text,                                           0,                                           this);    connect( settings_action, SIGNAL( activated() ),             this, SLOT(openConfigDialog()));    m_pSystrayActionMap.insert( ActionSettings, settings_action );	m_pOptionsMenu->insertSeparator();//     m_pOptionsMenu->insertItem(tr("Respawn mpg123 player"), m_pMainWindow, SLOT(startPlayer()));    QAction *respawn_action = new QAction("",                                          tr("Respawn mpg123 player"),                                          0,                                          this);    connect( respawn_action, SIGNAL( activated() ),             m_pMainWindow, SLOT(startPlayer()));    respawn_action->addTo( m_pOptionsMenu );    m_pSystrayActionMap.insert( ActionRespawn, respawn_action );    m_pOptionsMenu->insertItem(tr("Show player messages"), m_pMainWindow, SLOT(showPlayerMessages()));	m_pOptionsMenu->insertSeparator();	m_pBrowserMenu = new QPopupMenu(this);	m_pBrowserMenu->setCaption(tr("Browser Menu"));	m_pBrowserMenu->insertTearOffHandle();    m_BrowserId			= m_pBrowserMenu->insertItem(tr("Browser"),													 this,													 SLOT(toggleBrowser()),													 CTRL + Key_B);    m_BrowserLeftId		= m_pBrowserMenu->insertItem(tr("Left"),													 m_pMainWindow,													 SLOT(setBrowserLeft()));    m_BrowserRightId	= m_pBrowserMenu->insertItem(tr("Right"),													 m_pMainWindow,													 SLOT(setBrowserRight()));    m_BrowserTopId		= m_pBrowserMenu->insertItem(tr("Top"),													 m_pMainWindow,													 SLOT(setBrowserTop()));    m_BrowserBottomId	= m_pBrowserMenu->insertItem(tr("Bottom"),													 m_pMainWindow,													 SLOT(setBrowserBottom()));    m_BrowserFullId		= m_pBrowserMenu->insertItem(tr("Full"),													 this,													 SLOT(togglePlayList()));		m_pOptionsMenu->insertItem(tr("Browser..."), m_pBrowserMenu);	m_pOptionsMenu->insertSeparator();    m_pOptionsMenu->insertItem(tr("About Qt..."), this, SLOT(aboutQt()));//     m_pOptionsMenu->insertItem(tr("About..."), this, SLOT(about()));    QAction *about_action = new QAction("",                                        tr("About..."),                                        0,                                        this);    connect( about_action, SIGNAL( activated() ),             this, SLOT(about()));    about_action->addTo( m_pOptionsMenu );    m_pSystrayActionMap.insert( ActionAbout, about_action );    m_pOptions = new QmMenuButton(QIconSet( sup->pixmap( "icons-options" ) ),								  tr("Options"),								  this,								  m_pOptionsMenu);	connect(m_pOptions, SIGNAL(iconClicked()), this, SLOT(openConfigDialog()));		addSeparator();	    m_pPrev = new QToolButton(QIconSet( sup->pixmap( "icons-prev" ) ),							  tr("Previous (Shortcut: Alt+1)"),							  tr("Play previous song"),							  m_pMainWindow,							  SLOT(prev()),							  this);	m_pPrev->setAccel(ALT+'1');        m_pStop = new QToolButton(QIconSet( sup->pixmap( "icons-stop" ) ),							  tr("Stop (Shortcut: Alt+2)"),							  tr("Stop the playing song"),							  m_pMainWindow,							  SLOT(stop()),							  this);	m_pStop->setAccel(ALT+'2');    m_pPause = new QToolButton(QIconSet( sup->pixmap( "icons-pause" ) ),							   tr("Pause (Shortcut: Alt+3)"),							   tr("Pause the playing song"),							   m_pMainWindow,							   SLOT(pause()),							   this);	m_pPause->setToggleButton(true);	m_pPause->setAccel(ALT+'3');    m_pPlay = new QToolButton(QIconSet( sup->pixmap( "icons-play" ) ),							  tr("Play (Shortcut: Alt+4)"),							  tr("Play the highlighted song"),							  m_pMainWindow,							  SLOT(play()),							  this);	m_pPlay->setAccel(ALT+'4');    m_pNext = new QToolButton(QIconSet( sup->pixmap( "icons-next" ) ),							  tr("Next (Shortcut: Alt+5)"),							  tr("Play next song"),							  m_pMainWindow,							  SLOT(next()),							  this);	m_pNext->setAccel(ALT+'5');    m_pRandom = new QToolButton(QIconSet( sup->pixmap( "icons-random" ) ),                                tr("Toggle random mode (Shortcut: Alt+6)"),                                tr("Random mode"),                                m_pMainWindow,                                SLOT(toggleRandomMode()),                                this);    m_pRandom->setToggleButton(true);	m_pRandom->setAccel(ALT+'6');    m_pLoop = new QToolButton(QIconSet( sup->pixmap( "icons-loop" ) ),							  tr("Cycle loop mode (Shortcut: Alt+7)"),							  tr("Loop mode"),							  m_pMainWindow,							  SLOT(cycleLoopMode()),							  this);    m_pLoop->setToggleButton(true);	m_pLoop->setAccel(ALT+'7');    	addSeparator();	    m_pMinimize = new QToolButton(QIconSet( sup->pixmap( "icons-minimize" ) ),								  tr("Minimize (Shortcut: Alt+8)"),								  tr("Minimize window"),								  this,								  SLOT(showCompactWindow()),								  this);	m_pMinimize->setAccel(ALT+'8');    	QLabel *stretch =  new QLabel("", this);	stretch->setBackgroundColor(backgroundColor());	setStretchableWidget(stretch);		int show_browser;	QmConfig::instance()->get("main-window", "show-browser", show_browser);	bool menu_flag = (show_browser == 0 ? false : true);		m_pBrowserMenu->setItemChecked(m_BrowserId, menu_flag);	m_pBrowserMenu->setItemEnabled(m_BrowserLeftId, menu_flag);	m_pBrowserMenu->setItemEnabled(m_BrowserRightId, menu_flag);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -