2015-12-04 04:41:17 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
2017-05-30 20:42:21 +00:00
|
|
|
#include "DolphinQt2/Resources.h"
|
2015-12-20 23:36:39 +00:00
|
|
|
#include "DolphinQt2/Settings.h"
|
2015-12-04 04:41:17 +00:00
|
|
|
#include "DolphinQt2/ToolBar.h"
|
|
|
|
|
2016-01-25 11:36:39 +00:00
|
|
|
static QSize ICON_SIZE(32, 32);
|
2015-12-04 04:41:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
|
2015-12-04 04:41:17 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
setMovable(false);
|
|
|
|
setFloatable(false);
|
|
|
|
setIconSize(ICON_SIZE);
|
2015-12-04 04:41:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
MakeActions();
|
2017-05-31 23:49:47 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &ToolBar::UpdateIcons);
|
2016-06-24 08:43:46 +00:00
|
|
|
UpdateIcons();
|
2016-02-15 01:56:40 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
EmulationStopped();
|
2015-12-04 04:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ToolBar::EmulationStarted()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_play_action->setEnabled(false);
|
|
|
|
m_play_action->setVisible(false);
|
|
|
|
m_pause_action->setEnabled(true);
|
|
|
|
m_pause_action->setVisible(true);
|
2016-03-20 05:41:00 +00:00
|
|
|
m_stop_action->setEnabled(true);
|
|
|
|
m_stop_action->setVisible(true);
|
2016-06-24 08:43:46 +00:00
|
|
|
m_fullscreen_action->setEnabled(true);
|
|
|
|
m_screenshot_action->setEnabled(true);
|
2015-12-04 04:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ToolBar::EmulationPaused()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_play_action->setEnabled(true);
|
|
|
|
m_play_action->setVisible(true);
|
|
|
|
m_pause_action->setEnabled(false);
|
|
|
|
m_pause_action->setVisible(false);
|
2016-03-20 05:41:00 +00:00
|
|
|
m_stop_action->setEnabled(true);
|
|
|
|
m_stop_action->setVisible(true);
|
2015-12-04 04:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ToolBar::EmulationStopped()
|
|
|
|
{
|
2016-06-24 08:43:46 +00: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-04 04:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ToolBar::MakeActions()
|
|
|
|
{
|
2016-03-20 05:41:00 +00:00
|
|
|
constexpr int button_width = 65;
|
2017-06-30 09:24:09 +00:00
|
|
|
m_open_action = addAction(tr("Open"), this, &ToolBar::OpenPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_open_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-06-30 09:24:09 +00:00
|
|
|
m_play_action = addAction(tr("Play"), this, &ToolBar::PlayPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_play_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-06-30 09:24:09 +00:00
|
|
|
m_pause_action = addAction(tr("Pause"), this, &ToolBar::PausePressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_pause_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-06-30 09:24:09 +00:00
|
|
|
m_stop_action = addAction(tr("Stop"), this, &ToolBar::StopPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_stop_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-07-23 10:58:32 +00:00
|
|
|
m_fullscreen_action = addAction(tr("FullScr"), this, &ToolBar::FullScreenPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_fullscreen_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-07-23 10:58:32 +00:00
|
|
|
m_screenshot_action = addAction(tr("ScrShot"), this, &ToolBar::ScreenShotPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_screenshot_action)->setMinimumWidth(button_width);
|
2015-12-04 04:41:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
addSeparator();
|
2015-12-04 04:41:17 +00:00
|
|
|
|
2017-07-23 10:58:32 +00:00
|
|
|
m_config_action = addAction(tr("Config"), this, &ToolBar::SettingsPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_config_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-06-30 09:24:09 +00:00
|
|
|
m_graphics_action = addAction(tr("Graphics"), this, &ToolBar::GraphicsPressed);
|
2017-06-15 23:39:59 +00:00
|
|
|
widgetForAction(m_graphics_action)->setMinimumWidth(button_width);
|
|
|
|
|
2017-06-30 09:24:09 +00:00
|
|
|
m_controllers_action = addAction(tr("Controllers"), this, &ToolBar::ControllersPressed);
|
2016-03-20 05:41:00 +00:00
|
|
|
widgetForAction(m_controllers_action)->setMinimumWidth(button_width);
|
2017-05-09 16:49:10 +00:00
|
|
|
m_controllers_action->setEnabled(true);
|
2015-12-04 04:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ToolBar::UpdateIcons()
|
|
|
|
{
|
2017-05-30 20:42:21 +00:00
|
|
|
m_open_action->setIcon(Resources::GetScaledThemeIcon("open"));
|
|
|
|
m_play_action->setIcon(Resources::GetScaledThemeIcon("play"));
|
|
|
|
m_pause_action->setIcon(Resources::GetScaledThemeIcon("pause"));
|
|
|
|
m_stop_action->setIcon(Resources::GetScaledThemeIcon("stop"));
|
|
|
|
m_fullscreen_action->setIcon(Resources::GetScaledThemeIcon("fullscreen"));
|
|
|
|
m_screenshot_action->setIcon(Resources::GetScaledThemeIcon("screenshot"));
|
|
|
|
m_config_action->setIcon(Resources::GetScaledThemeIcon("config"));
|
|
|
|
m_controllers_action->setIcon(Resources::GetScaledThemeIcon("classic"));
|
2017-06-15 23:39:59 +00:00
|
|
|
m_graphics_action->setIcon(Resources::GetScaledThemeIcon("graphics"));
|
2015-12-04 04:41:17 +00:00
|
|
|
}
|