Reworked "Save as" to include a profile list

This commit is contained in:
Flora Aubry 2023-01-13 16:34:11 +00:00 committed by Adam Honse
parent 9ef8ea3fba
commit 94a8ce3cbe
2 changed files with 41 additions and 5 deletions

View file

@ -1,6 +1,7 @@
#include <QCloseEvent>
#include "ResourceManager.h"
#include "OpenRGBDialog2.h"
#include "ProfileManager.h"
#include "OpenRGBProfileSaveDialog.h"
#include "ui_OpenRGBProfileSaveDialog.h"
@ -12,6 +13,25 @@ Ui::OpenRGBProfileSaveDialog::OpenRGBProfileSaveDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::OpenRGBProfileSaveDialogUi)
{
ui->setupUi(this);
std::vector<std::string> filenames = ResourceManager::get()->GetProfileManager()->profile_list;
if(filenames.empty())
{
ui->list_profile->setVisible(false);
ui->existing->setVisible(false);
}
else
{
for(const std::string& f: filenames)
{
ui->list_profile->addItem(QString::fromStdString(f));
}
connect(ui->list_profile, &QListWidget::currentItemChanged, [=](){
ui->lineEdit->setText(ui->list_profile->currentItem()->text());
});
}
}
Ui::OpenRGBProfileSaveDialog::~OpenRGBProfileSaveDialog()

View file

@ -6,18 +6,34 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>110</height>
<width>184</width>
<height>186</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Profile Name</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="existing">
<property name="text">
<string>New Profile Name:</string>
<string>Save to an existing profile:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="list_profile"/>
</item>
<item>
<widget class="QLabel" name="new_2">
<property name="text">
<string>Create a new profile:</string>
</property>
</widget>
</item>