mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
a?adido el codigo adecuado para relaizar los imports (falta incluir las opciones) comprobado que si se elimina la conexi?n a la BD despu?s del primer load, se puede manipular el archivo library.ydb
152 lines
3.9 KiB
C++
152 lines
3.9 KiB
C++
#include "import_library_dialog.h"
|
|
|
|
#include <QHBoxLayout>
|
|
#include <QVBoxLayout>
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
ImportLibraryDialog::ImportLibraryDialog(QWidget * parent)
|
|
:QDialog(parent),progressCount(0)
|
|
{
|
|
setupUI();
|
|
}
|
|
|
|
void ImportLibraryDialog::setupUI()
|
|
{
|
|
nameLabel = new QLabel(tr("Library Name : "));
|
|
nameEdit = new QLineEdit;
|
|
nameLabel->setBuddy(nameEdit);
|
|
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameEntered()));
|
|
|
|
textLabel = new QLabel(tr("Package location : "));
|
|
path = new QLineEdit;
|
|
textLabel->setBuddy(path);
|
|
|
|
destLabel = new QLabel(tr("Destination folder : "));
|
|
destPath = new QLineEdit;
|
|
textLabel->setBuddy(destPath);
|
|
|
|
accept = new QPushButton(tr("Unpack"));
|
|
accept->setDisabled(true);
|
|
connect(accept,SIGNAL(clicked()),this,SLOT(add()));
|
|
|
|
cancel = new QPushButton(tr("Cancel"));
|
|
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
|
//connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected()));
|
|
|
|
find = new QPushButton(QIcon(":/images/coversPackage.png"),"");
|
|
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
|
|
|
|
findDest = new QPushButton(QIcon(":/images/open.png"),"");
|
|
connect(findDest,SIGNAL(clicked()),this,SLOT(findDestination()));
|
|
|
|
QHBoxLayout *nameLayout = new QHBoxLayout;
|
|
|
|
nameLayout->addWidget(nameLabel);
|
|
nameLayout->addWidget(nameEdit);
|
|
|
|
QHBoxLayout *libraryLayout = new QHBoxLayout;
|
|
|
|
libraryLayout->addWidget(textLabel);
|
|
libraryLayout->addWidget(path);
|
|
libraryLayout->addWidget(find);
|
|
libraryLayout->setStretchFactor(find,0); //TODO
|
|
|
|
QHBoxLayout *destLayout = new QHBoxLayout;
|
|
|
|
destLayout->addWidget(destLabel);
|
|
destLayout->addWidget(destPath);
|
|
destLayout->addWidget(findDest);
|
|
destLayout->setStretchFactor(findDest,0); //TODO
|
|
|
|
|
|
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
|
bottomLayout->addStretch();
|
|
bottomLayout->addWidget(accept);
|
|
bottomLayout->addWidget(cancel);
|
|
|
|
progressBar = new QProgressBar(this);
|
|
progressBar->setMinimum(0);
|
|
progressBar->setMaximum(0);
|
|
progressBar->setTextVisible(false);
|
|
progressBar->hide();
|
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
mainLayout->addLayout(nameLayout);
|
|
mainLayout->addLayout(libraryLayout);
|
|
mainLayout->addLayout(destLayout);
|
|
//mainLayout->addWidget(progress = new QLabel());
|
|
mainLayout->addStretch();
|
|
mainLayout->addWidget(progressBar);
|
|
mainLayout->addLayout(bottomLayout);
|
|
|
|
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
|
QLabel * imgLabel = new QLabel(this);
|
|
QPixmap p(":/images/importLibrary.png");
|
|
imgLabel->setPixmap(p);
|
|
imgMainLayout->addWidget(imgLabel);
|
|
imgMainLayout->addLayout(mainLayout);
|
|
|
|
setLayout(imgMainLayout);
|
|
|
|
setModal(true);
|
|
setWindowTitle(tr("Extract a catalog"));
|
|
}
|
|
|
|
void ImportLibraryDialog::add()
|
|
{
|
|
accept->setEnabled(false);
|
|
progressBar->show();
|
|
emit(unpackCLC(QDir::cleanPath(path->text()),QDir::cleanPath(destPath->text()),nameEdit->text()));
|
|
}
|
|
|
|
void ImportLibraryDialog::findPath()
|
|
{
|
|
QString s = QFileDialog::getOpenFileName(0,"Covers Package",".",tr("Compresed library covers (*.clc)"));
|
|
if(!s.isEmpty())
|
|
{
|
|
path->setText(s);
|
|
if(!destPath->text().isEmpty() && !nameEdit->text().isEmpty())
|
|
accept->setEnabled(true);
|
|
}
|
|
}
|
|
|
|
|
|
void ImportLibraryDialog::findDestination()
|
|
{
|
|
QString s = QFileDialog::getExistingDirectory(0,"Folder",".",QFileDialog::ShowDirsOnly);
|
|
if(!s.isEmpty())
|
|
{
|
|
destPath->setText(s);
|
|
if(!path->text().isEmpty() && !nameEdit->text().isEmpty())
|
|
accept->setEnabled(true);
|
|
}
|
|
}
|
|
|
|
void ImportLibraryDialog::nameEntered()
|
|
{
|
|
if(!nameEdit->text().isEmpty())
|
|
{
|
|
if(!path->text().isEmpty() && !destPath->text().isEmpty())
|
|
accept->setEnabled(true);
|
|
}
|
|
else
|
|
accept->setEnabled(false);
|
|
}
|
|
|
|
void ImportLibraryDialog::close()
|
|
{
|
|
path->clear();
|
|
destPath->clear();
|
|
nameEdit->clear();
|
|
accept->setEnabled(false);
|
|
progressBar->hide();
|
|
QDialog::hide();
|
|
}
|
|
|
|
void ImportLibraryDialog::closeEvent ( QCloseEvent * e )
|
|
{
|
|
close();
|
|
}
|