change: change code style to Linux style except indent.
This commit is contained in:
@@ -26,50 +26,54 @@
|
||||
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
FileField::FileField(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
directory_mode_(false)
|
||||
namespace olive
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
FileField::FileField(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, directory_mode_(false)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
|
||||
line_edit_ = new QLineEdit();
|
||||
connect(line_edit_, &QLineEdit::textChanged, this, &FileField::LineEditChanged);
|
||||
connect(line_edit_, &QLineEdit::textEdited, this, &FileField::FilenameChanged);
|
||||
layout->addWidget(line_edit_);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
browse_btn_ = new QPushButton();
|
||||
browse_btn_->setIcon(icon::Open);
|
||||
connect(browse_btn_, &QPushButton::clicked, this, &FileField::BrowseBtnClicked);
|
||||
layout->addWidget(browse_btn_);
|
||||
line_edit_ = new QLineEdit();
|
||||
connect(line_edit_, &QLineEdit::textChanged, this,
|
||||
&FileField::LineEditChanged);
|
||||
connect(line_edit_, &QLineEdit::textEdited, this,
|
||||
&FileField::FilenameChanged);
|
||||
layout->addWidget(line_edit_);
|
||||
|
||||
browse_btn_ = new QPushButton();
|
||||
browse_btn_->setIcon(icon::Open);
|
||||
connect(browse_btn_, &QPushButton::clicked, this,
|
||||
&FileField::BrowseBtnClicked);
|
||||
layout->addWidget(browse_btn_);
|
||||
}
|
||||
|
||||
void FileField::BrowseBtnClicked()
|
||||
{
|
||||
QString s;
|
||||
QString s;
|
||||
|
||||
if (directory_mode_) {
|
||||
s = QFileDialog::getExistingDirectory(this, tr("Open Directory"));
|
||||
} else {
|
||||
s = QFileDialog::getOpenFileName(this, tr("Open File"));
|
||||
}
|
||||
if (directory_mode_) {
|
||||
s = QFileDialog::getExistingDirectory(this, tr("Open Directory"));
|
||||
} else {
|
||||
s = QFileDialog::getOpenFileName(this, tr("Open File"));
|
||||
}
|
||||
|
||||
if (!s.isEmpty()) {
|
||||
line_edit_->setText(s);
|
||||
emit FilenameChanged(s);
|
||||
}
|
||||
if (!s.isEmpty()) {
|
||||
line_edit_->setText(s);
|
||||
emit FilenameChanged(s);
|
||||
}
|
||||
}
|
||||
|
||||
void FileField::LineEditChanged(const QString& text)
|
||||
void FileField::LineEditChanged(const QString &text)
|
||||
{
|
||||
if (QFileInfo::exists(text) || text.isEmpty()) {
|
||||
line_edit_->setStyleSheet(QString());
|
||||
} else {
|
||||
line_edit_->setStyleSheet(QStringLiteral("QLineEdit {color: red;}"));
|
||||
}
|
||||
if (QFileInfo::exists(text) || text.isEmpty()) {
|
||||
line_edit_->setStyleSheet(QString());
|
||||
} else {
|
||||
line_edit_->setStyleSheet(QStringLiteral("QLineEdit {color: red;}"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,49 +24,48 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace olive {
|
||||
|
||||
class FileField : public QWidget
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class FileField : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FileField(QWidget* parent = nullptr);
|
||||
FileField(QWidget *parent = nullptr);
|
||||
|
||||
QString GetFilename() const
|
||||
{
|
||||
return line_edit_->text();
|
||||
}
|
||||
QString GetFilename() const
|
||||
{
|
||||
return line_edit_->text();
|
||||
}
|
||||
|
||||
void SetFilename(const QString& s)
|
||||
{
|
||||
line_edit_->setText(s);
|
||||
}
|
||||
void SetFilename(const QString &s)
|
||||
{
|
||||
line_edit_->setText(s);
|
||||
}
|
||||
|
||||
void SetPlaceholder(const QString& s)
|
||||
{
|
||||
line_edit_->setPlaceholderText(s);
|
||||
}
|
||||
void SetPlaceholder(const QString &s)
|
||||
{
|
||||
line_edit_->setPlaceholderText(s);
|
||||
}
|
||||
|
||||
void SetDirectoryMode(bool e)
|
||||
{
|
||||
directory_mode_ = e;
|
||||
}
|
||||
void SetDirectoryMode(bool e)
|
||||
{
|
||||
directory_mode_ = e;
|
||||
}
|
||||
|
||||
signals:
|
||||
void FilenameChanged(const QString& filename);
|
||||
void FilenameChanged(const QString &filename);
|
||||
|
||||
private:
|
||||
QLineEdit* line_edit_;
|
||||
QLineEdit *line_edit_;
|
||||
|
||||
QPushButton* browse_btn_;
|
||||
QPushButton *browse_btn_;
|
||||
|
||||
bool directory_mode_;
|
||||
bool directory_mode_;
|
||||
|
||||
private slots:
|
||||
void BrowseBtnClicked();
|
||||
|
||||
void LineEditChanged(const QString &text);
|
||||
void BrowseBtnClicked();
|
||||
|
||||
void LineEditChanged(const QString &text);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user