#include "FractoriumPch.h" #include "Fractorium.h" #include "QssDialog.h" /// /// Initialize the toolbar UI. /// void Fractorium::InitToolbarUI() { auto clGroup = new QActionGroup(this); clGroup->addAction(ui.ActionCpu); clGroup->addAction(ui.ActionCL); auto spGroup = new QActionGroup(this); spGroup->addAction(ui.ActionSP); spGroup->addAction(ui.ActionDP); SyncOptionsToToolbar(); connect(ui.ActionCpu, SIGNAL(triggered(bool)), this, SLOT(OnActionCpu(bool)), Qt::QueuedConnection); connect(ui.ActionCL, SIGNAL(triggered(bool)), this, SLOT(OnActionCL(bool)), Qt::QueuedConnection); connect(ui.ActionSP, SIGNAL(triggered(bool)), this, SLOT(OnActionSP(bool)), Qt::QueuedConnection); connect(ui.ActionDP, SIGNAL(triggered(bool)), this, SLOT(OnActionDP(bool)), Qt::QueuedConnection); connect(ui.ActionStyle, SIGNAL(triggered(bool)), this, SLOT(OnActionStyle(bool)), Qt::QueuedConnection); } /// /// Called when the CPU render option on the toolbar is clicked. /// /// Check state, action only taken if true. void Fractorium::OnActionCpu(bool checked) { if (checked && m_Settings->OpenCL()) { m_Settings->OpenCL(false); ShutdownAndRecreateFromOptions(); } } /// /// Called when the OpenCL render option on the toolbar is clicked. /// /// Check state, action only taken if true. void Fractorium::OnActionCL(bool checked) { if (checked && !m_Settings->OpenCL()) { m_Settings->OpenCL(true); ShutdownAndRecreateFromOptions(); } } /// /// Called when the single precision render option on the toolbar is clicked. /// /// Check state, action only taken if true. void Fractorium::OnActionSP(bool checked) { if (checked && m_Settings->Double()) { m_Settings->Double(false); ShutdownAndRecreateFromOptions(); } } /// /// Called when the double precision render option on the toolbar is clicked. /// /// Check state, action only taken if true. void Fractorium::OnActionDP(bool checked) { if (checked && !m_Settings->Double()) { m_Settings->Double(true); ShutdownAndRecreateFromOptions(); } } /// /// Called when the show style button is clicked. /// /// Ignored void Fractorium::OnActionStyle(bool checked) { m_QssDialog->show(); } /// /// Sync options data to the check state of the toolbar buttons. /// This does not trigger a clicked() event. /// void Fractorium::SyncOptionsToToolbar() { static bool openCL = !OpenCLInfo::Instance().Devices().empty(); if (!openCL) { ui.ActionCL->setEnabled(false); } if (openCL && m_Settings->OpenCL()) { ui.ActionCpu->setChecked(false); ui.ActionCL->setChecked(true); } else { ui.ActionCpu->setChecked(true); ui.ActionCL->setChecked(false); } if (m_Settings->Double()) { ui.ActionSP->setChecked(false); ui.ActionDP->setChecked(true); } else { ui.ActionSP->setChecked(true); ui.ActionDP->setChecked(false); } }