mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
Format code using clang-format
This commit is contained in:
@ -5,120 +5,112 @@
|
||||
#include <QFileDialog>
|
||||
#include <QGridLayout>
|
||||
|
||||
|
||||
AddLibraryDialog::AddLibraryDialog(QWidget * parent)
|
||||
:QDialog(parent)
|
||||
AddLibraryDialog::AddLibraryDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setupUI();
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void AddLibraryDialog::setupUI()
|
||||
{
|
||||
textLabel = new QLabel(tr("Comics folder : "));
|
||||
path = new QLineEdit;
|
||||
textLabel->setBuddy(path);
|
||||
connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
|
||||
textLabel = new QLabel(tr("Comics folder : "));
|
||||
path = new QLineEdit;
|
||||
textLabel->setBuddy(path);
|
||||
connect(path, SIGNAL(textChanged(QString)), this, SLOT(pathSetted(QString)));
|
||||
|
||||
nameLabel = new QLabel(tr("Library name : "));
|
||||
nameEdit = new QLineEdit;
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
|
||||
nameLabel = new QLabel(tr("Library name : "));
|
||||
nameEdit = new QLineEdit;
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(nameSetted(QString)));
|
||||
|
||||
accept = new QPushButton(tr("Add"));
|
||||
accept->setDisabled(true);
|
||||
connect(accept,SIGNAL(clicked()),this,SLOT(add()));
|
||||
accept = new QPushButton(tr("Add"));
|
||||
accept->setDisabled(true);
|
||||
connect(accept, SIGNAL(clicked()), this, SLOT(add()));
|
||||
|
||||
cancel = new QPushButton(tr("Cancel"));
|
||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||
cancel = new QPushButton(tr("Cancel"));
|
||||
connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
find = new QPushButton(QIcon(":/images/find_folder.png"),"");
|
||||
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
|
||||
find = new QPushButton(QIcon(":/images/find_folder.png"), "");
|
||||
connect(find, SIGNAL(clicked()), this, SLOT(findPath()));
|
||||
|
||||
QGridLayout * content = new QGridLayout;
|
||||
QGridLayout *content = new QGridLayout;
|
||||
|
||||
content->addWidget(nameLabel,0,0);
|
||||
content->addWidget(nameEdit,0,1);
|
||||
content->addWidget(nameLabel, 0, 0);
|
||||
content->addWidget(nameEdit, 0, 1);
|
||||
|
||||
content->addWidget(textLabel,1,0);
|
||||
content->addWidget(path,1,1);
|
||||
content->addWidget(find,1,2);
|
||||
content->setColumnStretch(2,0);
|
||||
content->addWidget(textLabel, 1, 0);
|
||||
content->addWidget(path, 1, 1);
|
||||
content->addWidget(find, 1, 2);
|
||||
content->setColumnStretch(2, 0);
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(accept);
|
||||
bottomLayout->addWidget(cancel);
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout;
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(accept);
|
||||
bottomLayout->addWidget(cancel);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(content);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(content);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addLayout(bottomLayout);
|
||||
|
||||
QHBoxLayout * imgMainLayout = new QHBoxLayout;
|
||||
QLabel * imgLabel = new QLabel(this);
|
||||
QPixmap p(":/images/openLibrary.png");
|
||||
imgLabel->setPixmap(p);
|
||||
imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop);
|
||||
imgMainLayout->addLayout(mainLayout);
|
||||
QHBoxLayout *imgMainLayout = new QHBoxLayout;
|
||||
QLabel *imgLabel = new QLabel(this);
|
||||
QPixmap p(":/images/openLibrary.png");
|
||||
imgLabel->setPixmap(p);
|
||||
imgMainLayout->addWidget(imgLabel); //,0,Qt::AlignTop);
|
||||
imgMainLayout->addLayout(mainLayout);
|
||||
|
||||
setLayout(imgMainLayout);
|
||||
setLayout(imgMainLayout);
|
||||
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Add an existing library"));
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Add an existing library"));
|
||||
}
|
||||
|
||||
void AddLibraryDialog::add()
|
||||
{
|
||||
//accept->setEnabled(false);
|
||||
emit(addLibrary(QDir::cleanPath(path->text()),nameEdit->text()));
|
||||
//accept->setEnabled(false);
|
||||
emit(addLibrary(QDir::cleanPath(path->text()), nameEdit->text()));
|
||||
}
|
||||
|
||||
void AddLibraryDialog::nameSetted(const QString & text)
|
||||
void AddLibraryDialog::nameSetted(const QString &text)
|
||||
{
|
||||
if(!text.isEmpty())
|
||||
{
|
||||
if(!path->text().isEmpty())
|
||||
{
|
||||
QFileInfo fi(path->text());
|
||||
if(fi.isDir())
|
||||
accept->setEnabled(true);
|
||||
else
|
||||
accept->setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
accept->setEnabled(false);
|
||||
if (!text.isEmpty()) {
|
||||
if (!path->text().isEmpty()) {
|
||||
QFileInfo fi(path->text());
|
||||
if (fi.isDir())
|
||||
accept->setEnabled(true);
|
||||
else
|
||||
accept->setEnabled(false);
|
||||
}
|
||||
} else
|
||||
accept->setEnabled(false);
|
||||
}
|
||||
|
||||
void AddLibraryDialog::pathSetted(const QString & text)
|
||||
void AddLibraryDialog::pathSetted(const QString &text)
|
||||
{
|
||||
QFileInfo fi(text);
|
||||
if(fi.isDir())
|
||||
{
|
||||
if(!nameEdit->text().isEmpty())
|
||||
accept->setEnabled(true);
|
||||
}
|
||||
else
|
||||
accept->setEnabled(false);
|
||||
QFileInfo fi(text);
|
||||
if (fi.isDir()) {
|
||||
if (!nameEdit->text().isEmpty())
|
||||
accept->setEnabled(true);
|
||||
} else
|
||||
accept->setEnabled(false);
|
||||
}
|
||||
|
||||
void AddLibraryDialog::findPath()
|
||||
{
|
||||
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
|
||||
if(!s.isEmpty())
|
||||
{
|
||||
path->setText(s);
|
||||
if(!nameEdit->text().isEmpty())
|
||||
accept->setEnabled(true);
|
||||
}
|
||||
else
|
||||
accept->setEnabled(false);
|
||||
QString s = QFileDialog::getExistingDirectory(0, "Comics directory", ".");
|
||||
if (!s.isEmpty()) {
|
||||
path->setText(s);
|
||||
if (!nameEdit->text().isEmpty())
|
||||
accept->setEnabled(true);
|
||||
} else
|
||||
accept->setEnabled(false);
|
||||
}
|
||||
|
||||
void AddLibraryDialog::close()
|
||||
{
|
||||
path->clear();
|
||||
nameEdit->clear();
|
||||
accept->setEnabled(false);
|
||||
QDialog::close();
|
||||
path->clear();
|
||||
nameEdit->clear();
|
||||
accept->setEnabled(false);
|
||||
QDialog::close();
|
||||
}
|
||||
|
Reference in New Issue
Block a user