change file format from dos to unix

This commit is contained in:
Le Tan 2017-02-26 20:01:29 +08:00
parent 517d1ed139
commit b879b2c208
2 changed files with 94 additions and 94 deletions

View File

@ -1,59 +1,59 @@
#include <QtWidgets> #include <QtWidgets>
#include "vfileinfodialog.h" #include "vfileinfodialog.h"
VFileInfoDialog::VFileInfoDialog(const QString &title, const QString &info, VFileInfoDialog::VFileInfoDialog(const QString &title, const QString &info,
const QString &defaultName, const QString &defaultName,
QWidget *parent) QWidget *parent)
: QDialog(parent), infoLabel(NULL), title(title), info(info), defaultName(defaultName) : QDialog(parent), infoLabel(NULL), title(title), info(info), defaultName(defaultName)
{ {
setupUI(); setupUI();
connect(nameEdit, &QLineEdit::textChanged, this, &VFileInfoDialog::enableOkButton); connect(nameEdit, &QLineEdit::textChanged, this, &VFileInfoDialog::enableOkButton);
enableOkButton(); enableOkButton();
} }
void VFileInfoDialog::setupUI() void VFileInfoDialog::setupUI()
{ {
if (!info.isEmpty()) { if (!info.isEmpty()) {
infoLabel = new QLabel(info); infoLabel = new QLabel(info);
} }
nameLabel = new QLabel(tr("&Name:")); nameLabel = new QLabel(tr("&Name:"));
nameEdit = new QLineEdit(defaultName); nameEdit = new QLineEdit(defaultName);
nameEdit->selectAll(); nameEdit->selectAll();
nameLabel->setBuddy(nameEdit); nameLabel->setBuddy(nameEdit);
// Ok is the default button. // Ok is the default button.
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 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);
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok); QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3); nameEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
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->addWidget(m_btnBox); mainLayout->addWidget(m_btnBox);
mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(mainLayout); setLayout(mainLayout);
setWindowTitle(title); setWindowTitle(title);
} }
void VFileInfoDialog::enableOkButton() void VFileInfoDialog::enableOkButton()
{ {
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok); QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
okBtn->setEnabled(!nameEdit->text().isEmpty()); okBtn->setEnabled(!nameEdit->text().isEmpty());
} }
QString VFileInfoDialog::getNameInput() const QString VFileInfoDialog::getNameInput() const
{ {
return nameEdit->text(); return nameEdit->text();
} }

View File

@ -1,35 +1,35 @@
#ifndef VFILEINFODIALOG_H #ifndef VFILEINFODIALOG_H
#define VFILEINFODIALOG_H #define VFILEINFODIALOG_H
#include <QDialog> #include <QDialog>
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QDialogButtonBox; class QDialogButtonBox;
class QString; class QString;
class VFileInfoDialog : public QDialog class VFileInfoDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
VFileInfoDialog(const QString &title, const QString &info, const QString &defaultName, VFileInfoDialog(const QString &title, const QString &info, const QString &defaultName,
QWidget *parent = 0); QWidget *parent = 0);
QString getNameInput() const; QString getNameInput() const;
private slots: private slots:
void enableOkButton(); void enableOkButton();
private: private:
void setupUI(); void setupUI();
QLabel *infoLabel; QLabel *infoLabel;
QLabel *nameLabel; QLabel *nameLabel;
QLineEdit *nameEdit; QLineEdit *nameEdit;
QDialogButtonBox *m_btnBox; QDialogButtonBox *m_btnBox;
QString title; QString title;
QString info; QString info;
QString defaultName; QString defaultName;
}; };
#endif // VFILEINFODIALOG_H #endif // VFILEINFODIALOG_H