mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
refine dialogs
Use QDialogButtonBox in all dialogs.
This commit is contained in:
parent
c83fcf6ce9
commit
517d1ed139
@ -9,8 +9,6 @@ VDirInfoDialog::VDirInfoDialog(const QString &title, const QString &info,
|
|||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(nameEdit, &QLineEdit::textChanged, this, &VDirInfoDialog::enableOkButton);
|
connect(nameEdit, &QLineEdit::textChanged, this, &VDirInfoDialog::enableOkButton);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VDirInfoDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VDirInfoDialog::reject);
|
|
||||||
|
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
@ -25,19 +23,16 @@ void VDirInfoDialog::setupUI()
|
|||||||
nameEdit->selectAll();
|
nameEdit->selectAll();
|
||||||
nameLabel->setBuddy(nameEdit);
|
nameLabel->setBuddy(nameEdit);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
QHBoxLayout *topLayout = new QHBoxLayout();
|
QHBoxLayout *topLayout = new QHBoxLayout();
|
||||||
topLayout->addWidget(nameLabel);
|
topLayout->addWidget(nameLabel);
|
||||||
topLayout->addWidget(nameEdit);
|
topLayout->addWidget(nameEdit);
|
||||||
|
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
@ -45,7 +40,7 @@ void VDirInfoDialog::setupUI()
|
|||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
@ -54,6 +49,7 @@ void VDirInfoDialog::setupUI()
|
|||||||
|
|
||||||
void VDirInfoDialog::enableOkButton()
|
void VDirInfoDialog::enableOkButton()
|
||||||
{
|
{
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(!nameEdit->text().isEmpty());
|
okBtn->setEnabled(!nameEdit->text().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class VDirInfoDialog : public QDialog
|
class VDirInfoDialog : public QDialog
|
||||||
@ -25,8 +25,7 @@ private:
|
|||||||
QLabel *infoLabel;
|
QLabel *infoLabel;
|
||||||
QLabel *nameLabel;
|
QLabel *nameLabel;
|
||||||
QLineEdit *nameEdit;
|
QLineEdit *nameEdit;
|
||||||
QPushButton *okBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
QPushButton *cancelBtn;
|
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString info;
|
QString info;
|
||||||
|
@ -9,8 +9,6 @@ VFileInfoDialog::VFileInfoDialog(const QString &title, const QString &info,
|
|||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(nameEdit, &QLineEdit::textChanged, this, &VFileInfoDialog::enableOkButton);
|
connect(nameEdit, &QLineEdit::textChanged, this, &VFileInfoDialog::enableOkButton);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VFileInfoDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VFileInfoDialog::reject);
|
|
||||||
|
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
@ -25,19 +23,16 @@ void VFileInfoDialog::setupUI()
|
|||||||
nameEdit->selectAll();
|
nameEdit->selectAll();
|
||||||
nameLabel->setBuddy(nameEdit);
|
nameLabel->setBuddy(nameEdit);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
QHBoxLayout *topLayout = new QHBoxLayout();
|
QHBoxLayout *topLayout = new QHBoxLayout();
|
||||||
topLayout->addWidget(nameLabel);
|
topLayout->addWidget(nameLabel);
|
||||||
topLayout->addWidget(nameEdit);
|
topLayout->addWidget(nameEdit);
|
||||||
|
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
@ -45,7 +40,7 @@ void VFileInfoDialog::setupUI()
|
|||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
@ -54,6 +49,7 @@ void VFileInfoDialog::setupUI()
|
|||||||
|
|
||||||
void VFileInfoDialog::enableOkButton()
|
void VFileInfoDialog::enableOkButton()
|
||||||
{
|
{
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(!nameEdit->text().isEmpty());
|
okBtn->setEnabled(!nameEdit->text().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class VFileInfoDialog : public QDialog
|
class VFileInfoDialog : public QDialog
|
||||||
@ -25,8 +25,7 @@ private:
|
|||||||
QLabel *infoLabel;
|
QLabel *infoLabel;
|
||||||
QLabel *nameLabel;
|
QLabel *nameLabel;
|
||||||
QLineEdit *nameEdit;
|
QLineEdit *nameEdit;
|
||||||
QPushButton *okBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
QPushButton *cancelBtn;
|
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString info;
|
QString info;
|
||||||
|
@ -13,8 +13,6 @@ VInsertImageDialog::VInsertImageDialog(const QString &title, const QString &defa
|
|||||||
connect(imageTitleEdit, &QLineEdit::textChanged, this, &VInsertImageDialog::enableOkButton);
|
connect(imageTitleEdit, &QLineEdit::textChanged, this, &VInsertImageDialog::enableOkButton);
|
||||||
connect(pathEdit, &QLineEdit::textChanged, this, &VInsertImageDialog::enableOkButton);
|
connect(pathEdit, &QLineEdit::textChanged, this, &VInsertImageDialog::enableOkButton);
|
||||||
connect(browseBtn, &QPushButton::clicked, this, &VInsertImageDialog::handleBrowseBtnClicked);
|
connect(browseBtn, &QPushButton::clicked, this, &VInsertImageDialog::handleBrowseBtnClicked);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VInsertImageDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VInsertImageDialog::reject);
|
|
||||||
|
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
@ -52,21 +50,17 @@ void VInsertImageDialog::setupUI()
|
|||||||
topLayout->setColumnStretch(1, 1);
|
topLayout->setColumnStretch(1, 1);
|
||||||
topLayout->setColumnStretch(2, 0);
|
topLayout->setColumnStretch(2, 0);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
imagePreviewLabel = new QLabel();
|
imagePreviewLabel = new QLabel();
|
||||||
imagePreviewLabel->setVisible(false);
|
imagePreviewLabel->setVisible(false);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
mainLayout->addWidget(imagePreviewLabel);
|
mainLayout->addWidget(imagePreviewLabel);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
@ -79,6 +73,7 @@ void VInsertImageDialog::enableOkButton()
|
|||||||
if (imageTitleEdit->text().isEmpty() || !image) {
|
if (imageTitleEdit->text().isEmpty() || !image) {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(enabled);
|
okBtn->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
|
||||||
class VInsertImageDialog : public QDialog
|
class VInsertImageDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -40,8 +41,7 @@ private:
|
|||||||
QLabel *pathLabel;
|
QLabel *pathLabel;
|
||||||
QLineEdit *pathEdit;
|
QLineEdit *pathEdit;
|
||||||
QPushButton *browseBtn;
|
QPushButton *browseBtn;
|
||||||
QPushButton *okBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
QPushButton *cancelBtn;
|
|
||||||
QLabel *imagePreviewLabel;
|
QLabel *imagePreviewLabel;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
|
@ -8,8 +8,6 @@ VNewDirDialog::VNewDirDialog(const QString &title, const QString &info, const QS
|
|||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(nameEdit, &QLineEdit::textChanged, this, &VNewDirDialog::enableOkButton);
|
connect(nameEdit, &QLineEdit::textChanged, this, &VNewDirDialog::enableOkButton);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VNewDirDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VNewDirDialog::reject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNewDirDialog::setupUI()
|
void VNewDirDialog::setupUI()
|
||||||
@ -24,19 +22,16 @@ void VNewDirDialog::setupUI()
|
|||||||
nameEdit->selectAll();
|
nameEdit->selectAll();
|
||||||
nameLabel->setBuddy(nameEdit);
|
nameLabel->setBuddy(nameEdit);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
QHBoxLayout *topLayout = new QHBoxLayout();
|
QHBoxLayout *topLayout = new QHBoxLayout();
|
||||||
topLayout->addWidget(nameLabel);
|
topLayout->addWidget(nameLabel);
|
||||||
topLayout->addWidget(nameEdit);
|
topLayout->addWidget(nameEdit);
|
||||||
|
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
@ -44,14 +39,15 @@ void VNewDirDialog::setupUI()
|
|||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
setLayout(mainLayout);
|
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
setLayout(mainLayout);
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNewDirDialog::enableOkButton(const QString &editText)
|
void VNewDirDialog::enableOkButton(const QString &editText)
|
||||||
{
|
{
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(!editText.isEmpty());
|
okBtn->setEnabled(!editText.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class VNewDirDialog : public QDialog
|
class VNewDirDialog : public QDialog
|
||||||
@ -24,8 +24,7 @@ private:
|
|||||||
|
|
||||||
QLabel *nameLabel;
|
QLabel *nameLabel;
|
||||||
QLineEdit *nameEdit;
|
QLineEdit *nameEdit;
|
||||||
QPushButton *okBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
QPushButton *cancelBtn;
|
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString info;
|
QString info;
|
||||||
|
@ -8,8 +8,6 @@ VNewFileDialog::VNewFileDialog(const QString &title, const QString &info, const
|
|||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(nameEdit, &QLineEdit::textChanged, this, &VNewFileDialog::enableOkButton);
|
connect(nameEdit, &QLineEdit::textChanged, this, &VNewFileDialog::enableOkButton);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VNewFileDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VNewFileDialog::reject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNewFileDialog::setupUI()
|
void VNewFileDialog::setupUI()
|
||||||
@ -24,19 +22,16 @@ void VNewFileDialog::setupUI()
|
|||||||
nameEdit->selectAll();
|
nameEdit->selectAll();
|
||||||
nameLabel->setBuddy(nameEdit);
|
nameLabel->setBuddy(nameEdit);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
QHBoxLayout *topLayout = new QHBoxLayout();
|
QHBoxLayout *topLayout = new QHBoxLayout();
|
||||||
topLayout->addWidget(nameLabel);
|
topLayout->addWidget(nameLabel);
|
||||||
topLayout->addWidget(nameEdit);
|
topLayout->addWidget(nameEdit);
|
||||||
|
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
@ -44,14 +39,16 @@ void VNewFileDialog::setupUI()
|
|||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
setLayout(mainLayout);
|
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
setLayout(mainLayout);
|
||||||
|
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNewFileDialog::enableOkButton(const QString &editText)
|
void VNewFileDialog::enableOkButton(const QString &editText)
|
||||||
{
|
{
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(!editText.isEmpty());
|
okBtn->setEnabled(!editText.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class VNewFileDialog : public QDialog
|
class VNewFileDialog : public QDialog
|
||||||
@ -25,7 +25,7 @@ private:
|
|||||||
QLabel *nameLabel;
|
QLabel *nameLabel;
|
||||||
QLineEdit *nameEdit;
|
QLineEdit *nameEdit;
|
||||||
QPushButton *okBtn;
|
QPushButton *okBtn;
|
||||||
QPushButton *cancelBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString info;
|
QString info;
|
||||||
|
@ -13,8 +13,6 @@ VNewNotebookDialog::VNewNotebookDialog(const QString &title, const QString &info
|
|||||||
connect(nameEdit, &QLineEdit::textChanged, this, &VNewNotebookDialog::enableOkButton);
|
connect(nameEdit, &QLineEdit::textChanged, this, &VNewNotebookDialog::enableOkButton);
|
||||||
connect(pathEdit, &QLineEdit::textChanged, this, &VNewNotebookDialog::enableOkButton);
|
connect(pathEdit, &QLineEdit::textChanged, this, &VNewNotebookDialog::enableOkButton);
|
||||||
connect(browseBtn, &QPushButton::clicked, this, &VNewNotebookDialog::handleBrowseBtnClicked);
|
connect(browseBtn, &QPushButton::clicked, this, &VNewNotebookDialog::handleBrowseBtnClicked);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VNewNotebookDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VNewNotebookDialog::reject);
|
|
||||||
|
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
@ -45,20 +43,17 @@ void VNewNotebookDialog::setupUI()
|
|||||||
topLayout->addWidget(browseBtn, 1, 2);
|
topLayout->addWidget(browseBtn, 1, 2);
|
||||||
topLayout->addWidget(importCheck, 2, 1);
|
topLayout->addWidget(importCheck, 2, 1);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
if (infoLabel) {
|
if (infoLabel) {
|
||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
@ -66,6 +61,7 @@ void VNewNotebookDialog::setupUI()
|
|||||||
|
|
||||||
void VNewNotebookDialog::enableOkButton()
|
void VNewNotebookDialog::enableOkButton()
|
||||||
{
|
{
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(!pathEdit->text().isEmpty() && !nameEdit->text().isEmpty());
|
okBtn->setEnabled(!pathEdit->text().isEmpty() && !nameEdit->text().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ class QLineEdit;
|
|||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QString;
|
class QString;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
|
||||||
class VNewNotebookDialog : public QDialog
|
class VNewNotebookDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -35,8 +36,7 @@ private:
|
|||||||
QLineEdit *pathEdit;
|
QLineEdit *pathEdit;
|
||||||
QCheckBox *importCheck;
|
QCheckBox *importCheck;
|
||||||
QPushButton *browseBtn;
|
QPushButton *browseBtn;
|
||||||
QPushButton *okBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
QPushButton *cancelBtn;
|
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString info;
|
QString info;
|
||||||
|
@ -10,8 +10,6 @@ VNotebookInfoDialog::VNotebookInfoDialog(const QString &title, const QString &in
|
|||||||
setupUI();
|
setupUI();
|
||||||
|
|
||||||
connect(nameEdit, &QLineEdit::textChanged, this, &VNotebookInfoDialog::enableOkButton);
|
connect(nameEdit, &QLineEdit::textChanged, this, &VNotebookInfoDialog::enableOkButton);
|
||||||
connect(okBtn, &QPushButton::clicked, this, &VNotebookInfoDialog::accept);
|
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, &VNotebookInfoDialog::reject);
|
|
||||||
|
|
||||||
enableOkButton();
|
enableOkButton();
|
||||||
}
|
}
|
||||||
@ -35,14 +33,12 @@ void VNotebookInfoDialog::setupUI()
|
|||||||
topLayout->addRow(nameLabel, nameEdit);
|
topLayout->addRow(nameLabel, nameEdit);
|
||||||
topLayout->addRow(pathLabel, pathEdit);
|
topLayout->addRow(pathLabel, pathEdit);
|
||||||
|
|
||||||
okBtn = new QPushButton(tr("&OK"));
|
// Ok is the default button.
|
||||||
okBtn->setDefault(true);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
cancelBtn = new QPushButton(tr("&Cancel"));
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
QHBoxLayout *btmLayout = new QHBoxLayout();
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
btmLayout->addStretch();
|
|
||||||
btmLayout->addWidget(okBtn);
|
|
||||||
btmLayout->addWidget(cancelBtn);
|
|
||||||
|
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
pathEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
pathEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
@ -50,7 +46,7 @@ void VNotebookInfoDialog::setupUI()
|
|||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addLayout(btmLayout);
|
mainLayout->addWidget(m_btnBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
@ -58,6 +54,7 @@ void VNotebookInfoDialog::setupUI()
|
|||||||
|
|
||||||
void VNotebookInfoDialog::enableOkButton()
|
void VNotebookInfoDialog::enableOkButton()
|
||||||
{
|
{
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
okBtn->setEnabled(!nameEdit->text().isEmpty());
|
okBtn->setEnabled(!nameEdit->text().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QDialogButtonBox;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class VNotebookInfoDialog : public QDialog
|
class VNotebookInfoDialog : public QDialog
|
||||||
@ -26,8 +26,7 @@ private:
|
|||||||
QLabel *nameLabel;
|
QLabel *nameLabel;
|
||||||
QLineEdit *nameEdit;
|
QLineEdit *nameEdit;
|
||||||
QLineEdit *pathEdit;
|
QLineEdit *pathEdit;
|
||||||
QPushButton *okBtn;
|
QDialogButtonBox *m_btnBox;
|
||||||
QPushButton *cancelBtn;
|
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
QString info;
|
QString info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user