campos en di?logos correctamente alineados (QGridLayout)

This commit is contained in:
Luis Ángel San Martín 2012-06-30 11:18:03 +02:00
parent 6cff6162d2
commit 960cadee41
4 changed files with 52 additions and 47 deletions

View File

@ -3,7 +3,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QGridLayout>
AddLibraryDialog::AddLibraryDialog(QWidget * parent)
@ -32,18 +32,15 @@ void AddLibraryDialog::setupUI()
find = new QPushButton(QIcon(":/images/comicFolder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QHBoxLayout *nameLayout = new QHBoxLayout;
QGridLayout * content = new QGridLayout;
nameLayout->addWidget(nameLabel);
nameLayout->addWidget(nameEdit);
QHBoxLayout *libraryLayout = new QHBoxLayout;
libraryLayout->addWidget(textLabel);
libraryLayout->addWidget(path);
libraryLayout->addWidget(find);
libraryLayout->setStretchFactor(find,0); //TODO
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);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
@ -51,8 +48,7 @@ void AddLibraryDialog::setupUI()
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(nameLayout);
mainLayout->addLayout(libraryLayout);
mainLayout->addLayout(content);
mainLayout->addStretch();
mainLayout->addLayout(bottomLayout);

View File

@ -3,7 +3,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QSizePolicy>
CreateLibraryDialog::CreateLibraryDialog(QWidget * parent)
@ -33,17 +33,19 @@ void CreateLibraryDialog::setupUI()
find = new QPushButton(QIcon(":/images/comicFolder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
QHBoxLayout *nameLayout = new QHBoxLayout;
QGridLayout * content = new QGridLayout;
nameLayout->addWidget(nameLabel);
nameLayout->addWidget(nameEdit);
//QHBoxLayout *nameLayout = new QHBoxLayout;
QHBoxLayout *libraryLayout = new QHBoxLayout;
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
libraryLayout->addWidget(textLabel);
libraryLayout->addWidget(path);
libraryLayout->addWidget(find);
libraryLayout->setStretchFactor(find,0); //TODO
//QHBoxLayout *libraryLayout = new QHBoxLayout;
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnMinimumWidth(2,0); //TODO
QHBoxLayout *middleLayout = new QHBoxLayout;
@ -54,17 +56,23 @@ void CreateLibraryDialog::setupUI()
progressBar->hide();
currentFileLabel = new QLabel("");
currentFileLabel->setWordWrap(true);
middleLayout->addWidget(currentFileLabel);
middleLayout->addStretch();
middleLayout->setSizeConstraint(QLayout::SetMaximumSize);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
message->setWordWrap(true);
//message->hide();
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(nameLayout);
mainLayout->addLayout(libraryLayout);
mainLayout->addLayout(content);
mainLayout->addLayout(middleLayout);
mainLayout->addStretch();
mainLayout->addWidget(progressBar);
@ -86,6 +94,9 @@ void CreateLibraryDialog::setupUI()
void CreateLibraryDialog::create()
{
progressBar->show();
message->show();
currentFileLabel->setText("Importing : \n\n\n\n\n");
this->adjustSize();
accept->setEnabled(false);
emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
}
@ -102,9 +113,10 @@ void CreateLibraryDialog::findPath()
void CreateLibraryDialog::showCurrentFile(QString file)
{
currentFileLabel->setText(file);
currentFileLabel->setText(tr("Importing : \n") + file);
currentFileLabel->update();
this->update();
//this->adjustSize();
//is->update();
}
void CreateLibraryDialog::close()
{
@ -112,6 +124,7 @@ void CreateLibraryDialog::close()
path->clear();
nameEdit->clear();
currentFileLabel->setText("");
this->adjustSize();
accept->setEnabled(true);
QDialog::close();
}
@ -123,7 +136,8 @@ UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
{
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addWidget(message = new QLabel(tr("Updating....")));
mainLayout->addWidget(currentFileLabel = new QLabel(""));
mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
currentFileLabel->setWordWrap(true);
QHBoxLayout * bottom = new QHBoxLayout;
bottom->addStretch();
@ -164,5 +178,6 @@ void UpdateLibraryDialog::showCurrentFile(QString file)
void UpdateLibraryDialog::close()
{
currentFileLabel->setText("");
this->adjustSize();
QDialog::close();
}

View File

@ -16,6 +16,7 @@
private:
QLabel * nameLabel;
QLabel * textLabel;
QLabel * message;
QProgressBar *progressBar;
QLabel * currentFileLabel;
QLineEdit * path;

View File

@ -3,7 +3,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QGridLayout>
ImportLibraryDialog::ImportLibraryDialog(QWidget * parent)
@ -41,25 +41,20 @@ void ImportLibraryDialog::setupUI()
findDest = new QPushButton(QIcon(":/images/open.png"),"");
connect(findDest,SIGNAL(clicked()),this,SLOT(findDestination()));
QHBoxLayout *nameLayout = new QHBoxLayout;
QGridLayout * content = new QGridLayout;
nameLayout->addWidget(nameLabel);
nameLayout->addWidget(nameEdit);
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
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
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnStretch(2,0); //TODO
content->addWidget(destLabel,2,0);
content->addWidget(destPath,2,1);
content->addWidget(findDest,2,2);
//destLayout->setStretchFactor(findDest,0); //TODO
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch();
@ -73,9 +68,7 @@ void ImportLibraryDialog::setupUI()
progressBar->hide();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(nameLayout);
mainLayout->addLayout(libraryLayout);
mainLayout->addLayout(destLayout);
mainLayout->addLayout(content);
//mainLayout->addWidget(progress = new QLabel());
mainLayout->addStretch();
mainLayout->addWidget(progressBar);