Skip to content

Commit

Permalink
feat: support select uab file
Browse files Browse the repository at this point in the history
As title.
And fix some issues:
* Lose focus when the right menu pop-up;
* Package status check error.

Log: support select uab file.
  • Loading branch information
rb-union committed Oct 9, 2024
1 parent dce608e commit 0dc94b8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/deb-installer/model/deblistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ void DebListModel::slotUpWrongStatusRow()
installErrorPackages.append(iteratorpackageOperateStatus.key()); // 保存下标
}
// 保存安装失败的包
if (iteratorpackageOperateStatus.value() == Success) {
if (iteratorpackageOperateStatus.value() == Pkg::PackageOperationStatus::Success) {
installSuccessPackages.append(iteratorpackageOperateStatus.key());
}
}
Expand Down
21 changes: 13 additions & 8 deletions src/deb-installer/model/packagelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ void PackagesListView::focusInEvent(QFocusEvent *event)
}
}

void PackagesListView::focusOutEvent(QFocusEvent *event)
{
// not change focus index when the right menu pop-up.
if (event->reason() != Qt::PopupFocusReason) {
this->clearSelection();
m_currentIndex = -1;
m_currModelIndex = this->model()->index(-1, -1);
emit signalCurrentIndexRow(-1);
}

DListView::focusOutEvent(event);
}

/**
* @brief event 事件
*/
Expand All @@ -288,13 +301,5 @@ bool PackagesListView::event(QEvent *event)
}
}

// 焦点切出事件
if (event->type() == QEvent::FocusOut) {
this->clearSelection();
m_currentIndex = -1;
m_currModelIndex = this->model()->index(-1, -1);
emit signalCurrentIndexRow(-1);
}

return DListView::event(event);
}
2 changes: 2 additions & 0 deletions src/deb-installer/model/packagelistview.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public slots:
*/
void focusInEvent(QFocusEvent *event) override;

void focusOutEvent(QFocusEvent *event) override;

/**
* @brief event 事件
*/
Expand Down
4 changes: 2 additions & 2 deletions src/deb-installer/model/proxy_package_list_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,11 @@ void ProxyPackageListModel::onSourceDataChanged(const QModelIndex &topLeft,

const int leftCount = info.rightCount - info.count;
const int proxyTopIndex = leftCount + topLeft.row();
const int proxyBottonIndex = leftCount + bottomRight.row();
const int proxyBottomIndex = leftCount + bottomRight.row();

// check index valid interal
const QModelIndex proxyTopLeft = this->index(proxyTopIndex);
const QModelIndex proxyBottomRight = this->index(proxyBottonIndex);
const QModelIndex proxyBottomRight = this->index(proxyBottomIndex);

if (proxyTopLeft.isValid() && proxyBottomRight.isValid()) {
Q_EMIT dataChanged(proxyTopLeft, proxyBottomRight, roles);
Expand Down
3 changes: 2 additions & 1 deletion src/deb-installer/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ Pkg::PackageType Utils::detectPackage(const QString &filePath)

if (info.suffix().toLower() == "deb" || mime.name().startsWith("application/vnd.debian.binary-package")) {
return Pkg::Deb;
} else if (info.suffix().toLower() == "uab") {
}
if (info.suffix().toLower() == "uab") {
return Pkg::Uab;
}

Expand Down
2 changes: 1 addition & 1 deletion src/deb-installer/view/widgets/filechoosewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void FileChooseWidget::chooseFiles()
// 为DFileDialog指定父对象
DFileDialog dialog(this); // 获取文件
dialog.setFileMode(QFileDialog::ExistingFiles);
dialog.setNameFilter("Debian Package Files (*.deb)");
dialog.setNameFilter("Debian / Linglong Package Files (*.deb *.uab)");
dialog.setDirectory(historyDir); // 设置打开的路径为保存的路径
auto mode = dialog.exec(); // 打开文件选择窗口

Expand Down

0 comments on commit 0dc94b8

Please sign in to comment.