mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
refine the layout of dialogs
Use gridlayout and formlayout to make a more beautiful dialog. Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
41abbb21d0
commit
9b6afa013d
@ -38,12 +38,15 @@ void VDirInfoDialog::setupUI()
|
||||
btmLayout->addWidget(okBtn);
|
||||
btmLayout->addWidget(cancelBtn);
|
||||
|
||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
if (infoLabel) {
|
||||
mainLayout->addWidget(infoLabel);
|
||||
}
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(btmLayout);
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(title);
|
||||
|
@ -20,7 +20,7 @@ void VFileInfoDialog::setupUI()
|
||||
if (!info.isEmpty()) {
|
||||
infoLabel = new QLabel(info);
|
||||
}
|
||||
nameLabel = new QLabel(tr("&Name"));
|
||||
nameLabel = new QLabel(tr("&Name:"));
|
||||
nameEdit = new QLineEdit(defaultName);
|
||||
nameEdit->selectAll();
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
@ -38,12 +38,15 @@ void VFileInfoDialog::setupUI()
|
||||
btmLayout->addWidget(okBtn);
|
||||
btmLayout->addWidget(cancelBtn);
|
||||
|
||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
if (infoLabel) {
|
||||
mainLayout->addWidget(infoLabel);
|
||||
}
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(btmLayout);
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(title);
|
||||
|
@ -33,30 +33,29 @@ void VInsertImageDialog::setupUI()
|
||||
pathEdit = new QLineEdit(defaultPath);
|
||||
pathLabel->setBuddy(pathEdit);
|
||||
browseBtn = new QPushButton(tr("&Browse"));
|
||||
QHBoxLayout *pathLayout = new QHBoxLayout();
|
||||
pathLayout->addWidget(pathLabel);
|
||||
pathLayout->addWidget(pathEdit);
|
||||
pathLayout->addWidget(browseBtn);
|
||||
|
||||
imageTitleLabel = new QLabel(tr("&Title:"));
|
||||
imageTitleLabel = new QLabel(tr("&Image title:"));
|
||||
imageTitleEdit = new QLineEdit(defaultImageTitle);
|
||||
imageTitleEdit->selectAll();
|
||||
imageTitleLabel->setBuddy(imageTitleEdit);
|
||||
QRegExp regExp("[\\w\\(\\)@#%\\*\\-\\+=\\?<>\\,\\.\\s]+");
|
||||
QValidator *validator = new QRegExpValidator(regExp, this);
|
||||
imageTitleEdit->setValidator(validator);
|
||||
QHBoxLayout *titleLayout = new QHBoxLayout();
|
||||
titleLayout->addWidget(imageTitleLabel);
|
||||
titleLayout->addWidget(imageTitleEdit);
|
||||
|
||||
QGridLayout *topLayout = new QGridLayout();
|
||||
topLayout->addWidget(pathLabel, 0, 0);
|
||||
topLayout->addWidget(pathEdit, 0, 1);
|
||||
topLayout->addWidget(browseBtn, 0, 2);
|
||||
topLayout->addWidget(imageTitleLabel, 1, 0);
|
||||
topLayout->addWidget(imageTitleEdit, 1, 1, 1, 2);
|
||||
topLayout->setColumnStretch(0, 0);
|
||||
topLayout->setColumnStretch(1, 1);
|
||||
topLayout->setColumnStretch(2, 0);
|
||||
|
||||
okBtn = new QPushButton(tr("&OK"));
|
||||
okBtn->setDefault(true);
|
||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
||||
|
||||
QVBoxLayout *topLayout = new QVBoxLayout();
|
||||
topLayout->addLayout(pathLayout);
|
||||
topLayout->addLayout(titleLayout);
|
||||
|
||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
||||
btmLayout->addStretch();
|
||||
btmLayout->addWidget(okBtn);
|
||||
@ -70,7 +69,7 @@ void VInsertImageDialog::setupUI()
|
||||
mainLayout->addLayout(btmLayout);
|
||||
mainLayout->addWidget(imagePreviewLabel);
|
||||
setLayout(mainLayout);
|
||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ void VNewDirDialog::setupUI()
|
||||
btmLayout->addWidget(okBtn);
|
||||
btmLayout->addWidget(cancelBtn);
|
||||
|
||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
if (infoLabel) {
|
||||
mainLayout->addWidget(infoLabel);
|
||||
@ -44,7 +46,7 @@ void VNewDirDialog::setupUI()
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(btmLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ void VNewFileDialog::setupUI()
|
||||
btmLayout->addWidget(okBtn);
|
||||
btmLayout->addWidget(cancelBtn);
|
||||
|
||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
if (infoLabel) {
|
||||
mainLayout->addWidget(infoLabel);
|
||||
@ -44,7 +46,7 @@ void VNewFileDialog::setupUI()
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(btmLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
|
@ -26,25 +26,25 @@ void VNewNotebookDialog::setupUI()
|
||||
}
|
||||
nameLabel = new QLabel(tr("Notebook &name:"));
|
||||
nameEdit = new QLineEdit(defaultName);
|
||||
nameEdit->selectAll();
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
QHBoxLayout *nameLayout = new QHBoxLayout();
|
||||
nameLayout->addWidget(nameLabel);
|
||||
nameLayout->addWidget(nameEdit);
|
||||
|
||||
QLabel *pathLabel = new QLabel(tr("Notebook &path:"));
|
||||
pathEdit = new QLineEdit(defaultPath);
|
||||
pathLabel->setBuddy(pathEdit);
|
||||
browseBtn = new QPushButton(tr("&Browse"));
|
||||
QHBoxLayout *pathLayout = new QHBoxLayout();
|
||||
pathLayout->addWidget(pathLabel);
|
||||
pathLayout->addWidget(pathEdit);
|
||||
pathLayout->addWidget(browseBtn);
|
||||
|
||||
importCheck = new QCheckBox(tr("Import existing notebook"), this);
|
||||
importCheck->setChecked(true);
|
||||
importCheck->setToolTip(tr("When checked, VNote won't create a new config file if there already exists one."));
|
||||
|
||||
QGridLayout *topLayout = new QGridLayout();
|
||||
topLayout->addWidget(nameLabel, 0, 0);
|
||||
topLayout->addWidget(nameEdit, 0, 1, 1, 2);
|
||||
topLayout->addWidget(pathLabel, 1, 0);
|
||||
topLayout->addWidget(pathEdit, 1, 1);
|
||||
topLayout->addWidget(browseBtn, 1, 2);
|
||||
topLayout->addWidget(importCheck, 2, 1);
|
||||
|
||||
okBtn = new QPushButton(tr("&OK"));
|
||||
okBtn->setDefault(true);
|
||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
||||
@ -57,12 +57,10 @@ void VNewNotebookDialog::setupUI()
|
||||
if (infoLabel) {
|
||||
mainLayout->addWidget(infoLabel);
|
||||
}
|
||||
mainLayout->addLayout(nameLayout);
|
||||
mainLayout->addLayout(pathLayout);
|
||||
mainLayout->addWidget(importCheck);
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(btmLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
@ -92,3 +90,9 @@ bool VNewNotebookDialog::getImportCheck() const
|
||||
{
|
||||
return importCheck->isChecked();
|
||||
}
|
||||
|
||||
void VNewNotebookDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
nameEdit->setFocus();
|
||||
QDialog::showEvent(event);
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ private slots:
|
||||
void enableOkButton();
|
||||
void handleBrowseBtnClicked();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
|
@ -25,17 +25,15 @@ void VNotebookInfoDialog::setupUI()
|
||||
nameEdit = new QLineEdit(defaultName);
|
||||
nameEdit->selectAll();
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
QHBoxLayout *nameLayout = new QHBoxLayout();
|
||||
nameLayout->addWidget(nameLabel);
|
||||
nameLayout->addWidget(nameEdit);
|
||||
|
||||
QLabel *pathLabel = new QLabel(tr("Notebook &path:"));
|
||||
pathEdit = new QLineEdit(defaultPath);
|
||||
pathLabel->setBuddy(pathEdit);
|
||||
pathEdit->setReadOnly(true);
|
||||
QHBoxLayout *pathLayout = new QHBoxLayout();
|
||||
pathLayout->addWidget(pathLabel);
|
||||
pathLayout->addWidget(pathEdit);
|
||||
|
||||
QFormLayout *topLayout = new QFormLayout();
|
||||
topLayout->addRow(nameLabel, nameEdit);
|
||||
topLayout->addRow(pathLabel, pathEdit);
|
||||
|
||||
okBtn = new QPushButton(tr("&OK"));
|
||||
okBtn->setDefault(true);
|
||||
@ -45,15 +43,16 @@ void VNotebookInfoDialog::setupUI()
|
||||
btmLayout->addWidget(okBtn);
|
||||
btmLayout->addWidget(cancelBtn);
|
||||
|
||||
pathEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
if (infoLabel) {
|
||||
mainLayout->addWidget(infoLabel);
|
||||
}
|
||||
mainLayout->addLayout(nameLayout);
|
||||
mainLayout->addLayout(pathLayout);
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addLayout(btmLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ bool VNotebookSelector::newNotebook()
|
||||
QString defaultPath;
|
||||
|
||||
do {
|
||||
VNewNotebookDialog dialog(tr("Create notebook"), info, defaultName,
|
||||
VNewNotebookDialog dialog(tr("Create Notebook"), info, defaultName,
|
||||
defaultPath, this);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString name = dialog.getNameInput();
|
||||
|
Loading…
x
Reference in New Issue
Block a user