main_window: repaint tool icons

This commit is contained in:
Megamouse 2017-07-12 18:55:02 +02:00 committed by Ivan
parent cfa7d04c49
commit 73bbfcb246
3 changed files with 56 additions and 13 deletions

View File

@ -72,10 +72,7 @@ void main_window::Init()
guiSettings.reset(new gui_settings());
// Load Icons: This needs to happen before any actions or buttons are created
icon_play = QIcon(":/Icons/play.png");
icon_pause = QIcon(":/Icons/pause.png");
icon_stop = QIcon(":/Icons/stop.png");
icon_restart = QIcon(":/Icons/restart.png");
RepaintToolBarIcons();
appIcon = QIcon(":/rpcs3.ico");
// add toolbar widgets (crappy Qt designer is not able to)
@ -617,6 +614,53 @@ void main_window::SaveWindowState()
gameListFrame->SaveSettings();
}
void main_window::RepaintToolBarIcons()
{
QColor newColor = guiSettings->GetValue(GUI::mw_toolIconColor).value<QColor>();
icon_play = game_list_frame::colorizedIcon(QIcon(":/Icons/play.png"), GUI::mw_tool_icon_color, newColor);
icon_pause = game_list_frame::colorizedIcon(QIcon(":/Icons/pause.png"), GUI::mw_tool_icon_color, newColor);
icon_stop = game_list_frame::colorizedIcon(QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color, newColor);
icon_restart = game_list_frame::colorizedIcon(QIcon(":/Icons/restart.png"), GUI::mw_tool_icon_color, newColor);
icon_fullscreen_on = game_list_frame::colorizedIcon(QIcon(":/Icons/fullscreen.png"), GUI::mw_tool_icon_color, newColor);
icon_fullscreen_off = game_list_frame::colorizedIcon(QIcon(":/Icons/fullscreen_invert.png"), GUI::mw_tool_icon_color, newColor);
ui->toolbar_config->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/configure.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_controls->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/controllers.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_disc->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/disc.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_grid->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/grid.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_list->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/list.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_refresh->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/refresh.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_snap->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/screenshot.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_sort->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/sort.png"), GUI::mw_tool_icon_color, newColor));
ui->toolbar_stop->setIcon(game_list_frame::colorizedIcon(QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color, newColor));
if (Emu.IsRunning())
{
ui->toolbar_start->setIcon(icon_pause);
}
else if (Emu.IsStopped() && !Emu.GetPath().empty())
{
ui->toolbar_start->setIcon(icon_restart);
}
else
{
ui->toolbar_start->setIcon(icon_play);
}
if (isFullScreen())
{
ui->toolbar_fullscreen->setIcon(icon_fullscreen_on);
}
else
{
ui->toolbar_fullscreen->setIcon(icon_fullscreen_off);
}
ui->sizeSlider->setStyleSheet(QString("QSlider::handle:horizontal{ background: rgba(%1, %2, %3, %4); }")
.arg(newColor.red()).arg(newColor.green()).arg(newColor.blue()).arg(newColor.alpha()));
}
void main_window::OnEmuRun()
{
debuggerFrame->EnableButtons(true);
@ -977,6 +1021,7 @@ void main_window::CreateConnects()
connect(&dlg, &settings_dialog::GuiSettingsSaveRequest, this, &main_window::SaveWindowState);
connect(&dlg, &settings_dialog::GuiSettingsSyncRequest, [=]() {ConfigureGuiFromSettings(true); });
connect(&dlg, &settings_dialog::GuiStylesheetRequest, this, &main_window::RequestGlobalStylesheetChange);
connect(&dlg, &settings_dialog::ToolBarRepaintRequest, this, &main_window::RepaintToolBarIcons);
connect(&dlg, &settings_dialog::accepted, [this](){
gameListFrame->LoadSettings();
QColor tbc = guiSettings->GetValue(GUI::mw_toolBarColor).value<QColor>();
@ -1129,12 +1174,12 @@ void main_window::CreateConnects()
if (isFullScreen())
{
showNormal();
ui->toolbar_fullscreen->setIcon(QIcon(":/Icons/fullscreen.png"));
ui->toolbar_fullscreen->setIcon(icon_fullscreen_on);
}
else
{
showFullScreen();
ui->toolbar_fullscreen->setIcon(QIcon(":/Icons/fullscreen_invert.png"));
ui->toolbar_fullscreen->setIcon(icon_fullscreen_off);
}
});
connect(ui->toolbar_controls, &QAction::triggered, [=]() { pad_settings_dialog dlg(this); dlg.exec(); });
@ -1313,7 +1358,7 @@ void main_window::mouseDoubleClickEvent(QMouseEvent *event)
if (event->button() == Qt::LeftButton)
{
showNormal();
ui->toolbar_fullscreen->setIcon(QIcon(":/Icons/fullscreen.png"));
ui->toolbar_fullscreen->setIcon(icon_fullscreen_on);
}
}
}

View File

@ -37,6 +37,8 @@ class main_window : public QMainWindow
QIcon icon_pause;
QIcon icon_stop;
QIcon icon_restart;
QIcon icon_fullscreen_on;
QIcon icon_fullscreen_off;
#ifdef _WIN32
QIcon icon_thumb_play;
@ -78,6 +80,7 @@ private Q_SLOTS:
void DecryptSPRXLibraries();
void SaveWindowState();
void RepaintToolBarIcons();
protected:
void closeEvent(QCloseEvent *event) override;
@ -88,6 +91,7 @@ private:
void CreateDockWindows();
void ConfigureGuiFromSettings(bool configureAll = false);
void EnableMenus(bool enabled);
void keyPressEvent(QKeyEvent *keyEvent);
void mouseDoubleClickEvent(QMouseEvent *event);

View File

@ -128,12 +128,6 @@ margin-left:14px;</string>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QSlider::handle:horizontal {
background: #404040;
}
</string>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>