| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | // Copyright 2015 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2+
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QIcon>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | #include "DolphinQt2/Settings.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | #include "DolphinQt2/ToolBar.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-25 22:36:39 +11:00
										 |  |  | static QSize ICON_SIZE(32, 32); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | ToolBar::ToolBar(QWidget* parent) : QToolBar(parent) | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   setToolButtonStyle(Qt::ToolButtonTextUnderIcon); | 
					
						
							|  |  |  |   setMovable(false); | 
					
						
							|  |  |  |   setFloatable(false); | 
					
						
							|  |  |  |   setIconSize(ICON_SIZE); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   MakeActions(); | 
					
						
							|  |  |  |   UpdateIcons(); | 
					
						
							| 
									
										
										
										
											2016-02-15 12:56:40 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   EmulationStopped(); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolBar::EmulationStarted() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_play_action->setEnabled(false); | 
					
						
							|  |  |  |   m_play_action->setVisible(false); | 
					
						
							|  |  |  |   m_pause_action->setEnabled(true); | 
					
						
							|  |  |  |   m_pause_action->setVisible(true); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   m_stop_action->setEnabled(true); | 
					
						
							|  |  |  |   m_stop_action->setVisible(true); | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_fullscreen_action->setEnabled(true); | 
					
						
							|  |  |  |   m_screenshot_action->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolBar::EmulationPaused() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_play_action->setEnabled(true); | 
					
						
							|  |  |  |   m_play_action->setVisible(true); | 
					
						
							|  |  |  |   m_pause_action->setEnabled(false); | 
					
						
							|  |  |  |   m_pause_action->setVisible(false); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   m_stop_action->setEnabled(true); | 
					
						
							|  |  |  |   m_stop_action->setVisible(true); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolBar::EmulationStopped() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_play_action->setEnabled(true); | 
					
						
							|  |  |  |   m_play_action->setVisible(true); | 
					
						
							|  |  |  |   m_pause_action->setEnabled(false); | 
					
						
							|  |  |  |   m_pause_action->setVisible(false); | 
					
						
							|  |  |  |   m_stop_action->setEnabled(false); | 
					
						
							|  |  |  |   m_fullscreen_action->setEnabled(false); | 
					
						
							|  |  |  |   m_screenshot_action->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolBar::MakeActions() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   constexpr int button_width = 65; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_open_action = addAction(tr("Open"), this, SIGNAL(OpenPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_open_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_play_action = addAction(tr("Play"), this, SIGNAL(PlayPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_play_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_pause_action = addAction(tr("Pause"), this, SIGNAL(PausePressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_pause_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_stop_action = addAction(tr("Stop"), this, SIGNAL(StopPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_stop_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_fullscreen_action = addAction(tr("Full Screen"), this, SIGNAL(FullScreenPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_fullscreen_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_screenshot_action = addAction(tr("Screen Shot"), this, SIGNAL(ScreenShotPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_screenshot_action)->setMinimumWidth(button_width); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   addSeparator(); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_paths_action = addAction(tr("Paths"), this, SIGNAL(PathsPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_paths_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_config_action = addAction(tr("Settings"), this, SIGNAL(SettingsPressed())); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_config_action)->setMinimumWidth(button_width); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_controllers_action = addAction(tr("Controllers")); | 
					
						
							| 
									
										
										
										
											2016-03-20 16:41:00 +11:00
										 |  |  |   widgetForAction(m_controllers_action)->setMinimumWidth(button_width); | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_controllers_action->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolBar::UpdateIcons() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   QString dir = Settings().GetThemeDir(); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   m_open_action->setIcon(QIcon(QStringLiteral("open.png").prepend(dir))); | 
					
						
							|  |  |  |   m_paths_action->setIcon(QIcon(QStringLiteral("browse.png").prepend(dir))); | 
					
						
							|  |  |  |   m_play_action->setIcon(QIcon(QStringLiteral("play.png").prepend(dir))); | 
					
						
							|  |  |  |   m_pause_action->setIcon(QIcon(QStringLiteral("pause.png").prepend(dir))); | 
					
						
							|  |  |  |   m_stop_action->setIcon(QIcon(QStringLiteral("stop.png").prepend(dir))); | 
					
						
							|  |  |  |   m_fullscreen_action->setIcon(QIcon(QStringLiteral("fullscreen.png").prepend(dir))); | 
					
						
							|  |  |  |   m_screenshot_action->setIcon(QIcon(QStringLiteral("screenshot.png").prepend(dir))); | 
					
						
							|  |  |  |   m_config_action->setIcon(QIcon(QStringLiteral("config.png").prepend(dir))); | 
					
						
							|  |  |  |   m_controllers_action->setIcon(QIcon(QStringLiteral("classic.png").prepend(dir))); | 
					
						
							| 
									
										
										
										
											2015-12-03 20:41:17 -08:00
										 |  |  | } |