RepRaptor/sdwindow.cpp
NeoTheFox 2d6d09743e Fixed crash in SD window
Fixed '\r\n' at the end of string and pressing "ok" with no selection
2015-03-26 21:12:38 +03:00

34 lines
746 B
C++

#include "sdwindow.h"
#include "ui_sdwindow.h"
SDWindow::SDWindow(QStringList files, QWidget *parent) :
QDialog(parent),
ui(new Ui::SDWindow)
{
ui->setupUi(this);
ui->fileslist->setSelectionMode(QListView::SingleSelection);
if(!files.isEmpty())
{
ui->fileslist->addItems(files);
ui->fileslist->setCurrentItem(ui->fileslist->itemAt(0,0));
}
}
SDWindow::~SDWindow()
{
delete ui;
}
void SDWindow::on_buttonBox_accepted()
{
if(ui->fileslist->count() > 0) emit fileSelected(ui->fileslist->currentItem()->text());
}
void SDWindow::on_fileslist_doubleClicked(const QModelIndex &)
{
if(ui->fileslist->count() > 0) emit fileSelected(ui->fileslist->currentItem()->text());
this->close();
}