Physical printers: Delete selected printer

+ Added context menu for the cog-button near the printer presets
This commit is contained in:
YuSanka 2020-06-24 12:28:00 +02:00
parent 89035febfa
commit 8ac839f427
4 changed files with 76 additions and 22 deletions

View file

@ -1489,17 +1489,32 @@ void PhysicalPrinterCollection::save_printer(const PhysicalPrinter& edited_print
bool PhysicalPrinterCollection::delete_printer(const std::string& name)
{
auto it = this->find_printer_internal(name);
if (it == m_printers.end())
return false;
const PhysicalPrinter& printer = *it;
if (it == m_printers.end())
return false;
// Erase the preset file.
boost::nowide::remove(printer.file.c_str());
m_printers.erase(it);
return true;
}
bool PhysicalPrinterCollection::delete_selected_printer()
{
if (!has_selection())
return false;
const PhysicalPrinter& printer = this->get_selected_printer();
// Erase the preset file.
boost::nowide::remove(printer.file.c_str());
// Remove the preset from the list.
m_printers.erase(m_printers.begin() + m_idx_selected);
// unselect all printers
unselect_printer();
return true;
}
PhysicalPrinter& PhysicalPrinterCollection::select_printer_by_name(const std::string& name)
{
auto it = this->find_printer_internal(name);