OpenRGBDialog2: Save Profile button with Save Profile As menu
This commit is contained in:
parent
874a63bab7
commit
bca9407f70
3 changed files with 108 additions and 23 deletions
|
|
@ -178,6 +178,15 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
ui->DetectionProgressBar->setFormat("");
|
||||
ui->DetectionProgressBar->setAlignment(Qt::AlignCenter);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Save Profile button action and menu |
|
||||
\*-----------------------------------------------------*/
|
||||
QMenu* saveProfileMenu = new QMenu(this);
|
||||
saveProfileMenu->addAction(ui->ActionSaveProfileAs);
|
||||
|
||||
ui->ButtonSaveProfile->setMenu(saveProfileMenu);
|
||||
ui->ButtonSaveProfile->setDefaultAction(ui->ActionSaveProfile);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up tray icon menu |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -991,28 +1000,8 @@ void Ui::OpenRGBDialog2::on_ProfileSelected()
|
|||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ButtonSaveProfile_clicked()
|
||||
{
|
||||
OpenRGBProfileSaveDialog dialog;
|
||||
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
|
||||
if(profile_manager != NULL)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Open Profile Name Dialog |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string profile_name = dialog.show();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the profile |
|
||||
\*---------------------------------------------------------*/
|
||||
if(profile_manager->SaveProfile(profile_name))
|
||||
{
|
||||
UpdateProfileList();
|
||||
}
|
||||
ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1142,9 +1131,77 @@ void Ui::OpenRGBDialog2::SetDetectionViewState(bool detection_showing)
|
|||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::SaveProfile()
|
||||
{
|
||||
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
|
||||
if(profile_manager != NULL)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Get the profile filename from the profiles list |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string filename = ui->ProfileBox->currentText().toStdString();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the profile |
|
||||
\*---------------------------------------------------------*/
|
||||
profile_manager->SaveProfile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::SaveProfileAs()
|
||||
{
|
||||
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
|
||||
if(profile_manager != NULL)
|
||||
{
|
||||
OpenRGBProfileSaveDialog dialog;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Open Profile Name Dialog |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string profile_name = dialog.show();
|
||||
|
||||
if(!profile_name.empty())
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Extension .orp - OpenRgb Profile |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string filename = profile_name;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Save the profile |
|
||||
\*---------------------------------------------------------*/
|
||||
if(profile_manager->SaveProfile(filename))
|
||||
{
|
||||
UpdateProfileList();
|
||||
|
||||
ui->ProfileBox->setCurrentIndex(ui->ProfileBox->findText(QString::fromStdString(profile_name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ButtonRescan_clicked()
|
||||
{
|
||||
SetDetectionViewState(true);
|
||||
|
||||
ResourceManager::get()->DetectDevices();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ActionSaveProfile_triggered()
|
||||
{
|
||||
if(ui->ProfileBox->currentIndex() >= 0)
|
||||
{
|
||||
SaveProfile();
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveProfileAs();
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ActionSaveProfileAs_triggered()
|
||||
{
|
||||
SaveProfileAs();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ private:
|
|||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
void SetDetectionViewState(bool detection_showing);
|
||||
void SaveProfile();
|
||||
void SaveProfileAs();
|
||||
|
||||
bool device_view_showing = false;
|
||||
|
||||
|
|
@ -101,12 +103,13 @@ private slots:
|
|||
void on_ShowHide();
|
||||
void on_ReShow(QSystemTrayIcon::ActivationReason reason);
|
||||
void on_ProfileSelected();
|
||||
void on_ButtonSaveProfile_clicked();
|
||||
void on_ButtonLoadProfile_clicked();
|
||||
void on_ButtonDeleteProfile_clicked();
|
||||
void on_ButtonToggleDeviceView_clicked();
|
||||
void on_ButtonStopDetection_clicked();
|
||||
void on_ButtonRescan_clicked();
|
||||
void on_ActionSaveProfile_triggered();
|
||||
void on_ActionSaveProfileAs_triggered();
|
||||
};
|
||||
|
||||
#endif // OPENRGBDIALOG2_H
|
||||
|
|
|
|||
|
|
@ -96,10 +96,19 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ButtonSaveProfile">
|
||||
<widget class="QToolButton" name="ButtonSaveProfile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Profile</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
@ -151,6 +160,22 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<action name="ActionSaveProfile">
|
||||
<property name="text">
|
||||
<string>Save Profile</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="ActionSaveProfileAs">
|
||||
<property name="text">
|
||||
<string>Save Profile As...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Profile with custom name</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue