diff --git a/src/dialog/vdirinfodialog.cpp b/src/dialog/vdirinfodialog.cpp index 05af15fa..eef7d3dd 100644 --- a/src/dialog/vdirinfodialog.cpp +++ b/src/dialog/vdirinfodialog.cpp @@ -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); diff --git a/src/dialog/vfileinfodialog.cpp b/src/dialog/vfileinfodialog.cpp index 1209777a..a3450a9a 100644 --- a/src/dialog/vfileinfodialog.cpp +++ b/src/dialog/vfileinfodialog.cpp @@ -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); diff --git a/src/dialog/vinsertimagedialog.cpp b/src/dialog/vinsertimagedialog.cpp index fc7d72b9..76c56877 100644 --- a/src/dialog/vinsertimagedialog.cpp +++ b/src/dialog/vinsertimagedialog.cpp @@ -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); } diff --git a/src/dialog/vnewdirdialog.cpp b/src/dialog/vnewdirdialog.cpp index 1755a1a4..124883d9 100644 --- a/src/dialog/vnewdirdialog.cpp +++ b/src/dialog/vnewdirdialog.cpp @@ -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); } diff --git a/src/dialog/vnewfiledialog.cpp b/src/dialog/vnewfiledialog.cpp index 5a11e8ed..c4f72734 100644 --- a/src/dialog/vnewfiledialog.cpp +++ b/src/dialog/vnewfiledialog.cpp @@ -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); } diff --git a/src/dialog/vnewnotebookdialog.cpp b/src/dialog/vnewnotebookdialog.cpp index f5faf570..6f168150 100644 --- a/src/dialog/vnewnotebookdialog.cpp +++ b/src/dialog/vnewnotebookdialog.cpp @@ -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); +} diff --git a/src/dialog/vnewnotebookdialog.h b/src/dialog/vnewnotebookdialog.h index 1aa68e1b..e2a212c1 100644 --- a/src/dialog/vnewnotebookdialog.h +++ b/src/dialog/vnewnotebookdialog.h @@ -23,6 +23,9 @@ private slots: void enableOkButton(); void handleBrowseBtnClicked(); +protected: + void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + private: void setupUI(); diff --git a/src/dialog/vnotebookinfodialog.cpp b/src/dialog/vnotebookinfodialog.cpp index 40efa3f2..73b68044 100644 --- a/src/dialog/vnotebookinfodialog.cpp +++ b/src/dialog/vnotebookinfodialog.cpp @@ -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); } diff --git a/src/vnotebookselector.cpp b/src/vnotebookselector.cpp index c851288b..b5684cb7 100644 --- a/src/vnotebookselector.cpp +++ b/src/vnotebookselector.cpp @@ -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();