yacreader/YACReaderLibrary/rename_library_dialog.cpp
2012-05-20 16:12:22 +02:00

68 lines
1.6 KiB
C++

#include "rename_library_dialog.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
RenameLibraryDialog::RenameLibraryDialog(QWidget * parent)
:QDialog(parent)
{
setupUI();
}
void RenameLibraryDialog::setupUI()
{
newNameLabel = new QLabel(tr("New Library Name : "));
newNameEdit = new QLineEdit;
newNameLabel->setBuddy(newNameEdit);
accept = new QPushButton(tr("Rename"));
//accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(rename()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
QHBoxLayout *nameLayout = new QHBoxLayout;
nameLayout->addWidget(newNameLabel);
nameLayout->addWidget(newNameEdit);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(nameLayout);
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/edit.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Rename current library"));
}
void RenameLibraryDialog::rename()
{
//accept->setEnabled(false);
emit(renameLibrary(newNameEdit->text()));
close();
}
void RenameLibraryDialog::close()
{
newNameEdit->clear();
//accept->setEnabled(false);
QDialog::close();
}