version 1.6.0

QAD::File add "is_save" flag
This commit is contained in:
2020-08-13 13:00:52 +03:00
parent 11e665c419
commit 58432fa62e
6 changed files with 35 additions and 17 deletions

View File

@@ -101,7 +101,7 @@ void StringListEdit::editItem() {
PathEdit::PathEdit(QWidget * parent): QWidget(parent), lay(QBoxLayout::LeftToRight, this) {
is_dir = is_abs = false;
is_dir = is_abs = is_save = false;
filter = tr("All files(*)");
line = new CLineEdit(this);
//line->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -134,10 +134,24 @@ void PathEdit::resizeEvent(QResizeEvent *) {
}
void PathEdit::setValue(const QString & v) {
line->setText(v);
if (!is_dir && is_save)
butt_select->setIcon(QIcon(":/icons/document-save.png"));
else
butt_select->setIcon(QIcon(":/icons/document-open.png"));
}
void PathEdit::select() {
QString ret;
if (is_dir) ret = QFileDialog::getExistingDirectory(this, tr("Select directory"), value());
else ret = QFileDialog::getSaveFileName(this, tr("Select file"), value(), filter);
else {
if (is_save)
ret = QFileDialog::getSaveFileName(this, tr("Select file"), value(), filter);
else
ret = QFileDialog::getOpenFileName(this, tr("Select file"), value(), filter);
}
if (ret.isEmpty()) return;
if (!is_abs)
ret = QDir::current().relativeFilePath(ret);
@@ -465,16 +479,18 @@ void QVariantEdit::_setEnum(const QAD::Enum & v) {
void QVariantEdit::_setFile(const QAD::File & v) {
_path->is_dir = false;
_path->filter = v.filter;
_path->is_abs = v.is_abs;
_path->is_save = v.is_save;
_path->setValue(v.file);
_path->filter = v.filter;
_path->is_abs = v.is_abs;
}
void QVariantEdit::_setDir(const QAD::Dir & v) {
_path->is_dir = true;
_path->setValue(v.dir);
_path->is_abs = v.is_abs;
_path->setValue(v.dir);
}