Skip to content

Commit

Permalink
v9.29.4~v9.24.5
Browse files Browse the repository at this point in the history
菜单增加边框色
[SFTP]优化上传下载对话框。
[SFTP]优化列表文件大小对齐方式。
[SFTP]修复编辑文件时可能的同步崩溃问题。

v9.29.4~v9.24.5
Add border color to the menu
[SFTP] Optimize the upload and download dialog box.
[SFTP] Optimize the alignment method of list file size.
[SFTP] Fix a possible synchronization crash issue when editing files.
  • Loading branch information
getwingm committed Oct 29, 2023
1 parent 88aa716 commit 5dc74e0
Show file tree
Hide file tree
Showing 15 changed files with 432 additions and 318 deletions.
364 changes: 194 additions & 170 deletions private/languages/woterm_zh.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion private/skins/black/desktop.qss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ QMenuBar::item:pressed {

QMenu {
background-color: rgb(60,60,60); /* sets background of the menu */
border: 1px rgb(60,60,60);
border: 1px solid rgb(46,46,46);
padding: 3px 5px;
margin: 2px; /* can not zero for easy trigger clicked action.*/
}
Expand Down
2 changes: 1 addition & 1 deletion private/skins/blue/desktop.qss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ QMenuBar::item:pressed {

QMenu {
background-color: rgb(0,23,51); /* sets background of the menu */
border: 1px rgb(0,23,51);
border: 1px solid rgb(60,60,60);
padding: 3px 5px;
margin: 2px; /* can not zero for easy trigger clicked action.*/
}
Expand Down
2 changes: 1 addition & 1 deletion private/skins/gold/desktop.qss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ QMenuBar::item:pressed {

QMenu {
background-color: rgb(139, 105, 20); /* sets background of the menu */
border: 1px rgb(139, 105, 20);
border: 1px solid rgb(139, 105, 20);
padding: 3px 5px;
margin: 2px; /* can not zero for easy trigger clicked action.*/
}
Expand Down
2 changes: 1 addition & 1 deletion private/skins/light/desktop.qss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ QMenuBar::item:pressed {

QMenu {
background-color: rgb(240,240,240); /* sets background of the menu */
border: 1px rgb(240,240,240);
border: 1px solid rgb(200,200,200);
padding: 3px 5px;
margin: 2px; /* can not zero for easy trigger clicked action.*/
}
Expand Down
2 changes: 1 addition & 1 deletion woterm/qwosftpremotemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ QVariant QWoSftpRemoteModel::data(const QModelIndex &index, int role) const
}
if(role == Qt::TextAlignmentRole) {
if(col == 4) {
return Qt::AlignRight;
return int(Qt::AlignRight|Qt::AlignVCenter);
}
return QVariant();
}
Expand Down
73 changes: 44 additions & 29 deletions woterm/qwosftptransferwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <QScrollBar>

#define MAX_LOG_SIZE (1024 * 1024 * 5)
#define BUTTON_WIDTH (60)
#define BUTTON_HEIGHT (30)

QWoSftpItemDelegate::QWoSftpItemDelegate(QWidget *parent)
: QStyledItemDelegate(parent)
Expand All @@ -50,8 +52,7 @@ QWoSftpItemDelegate::QWoSftpItemDelegate(QWidget *parent)
void QWoSftpItemDelegate::onRemoveArrived()
{
QWidget *btnRemove = qobject_cast<QWidget*>(sender());
QWidget *parent = btnRemove->parentWidget();
const TaskInfo& ti = parent->property("itemIndex").value<TaskInfo>();
const TaskInfo& ti = btnRemove->property("itemIndex").value<TaskInfo>();
if(ti.isValid()) {
emit removeArrived(ti.taskId);
}
Expand Down Expand Up @@ -107,24 +108,15 @@ QWidget *QWoSftpItemDelegate::createEditor(QWidget *parent, const QStyleOptionVi
{
QWidget *container = m_parent->property("container").value<QWidget*>();
if(container == nullptr) {
container = new QWidget(parent);
container->setAttribute(Qt::WA_ShowWithoutActivating);
QHBoxLayout *layout = new QHBoxLayout(container);
container->setLayout(layout);
layout->setContentsMargins(0,0,0,0);
QIcon remove = QIcon(QPixmap("../private/skins/black/close.png").scaled(24, 24, Qt::KeepAspectRatio ,Qt::SmoothTransformation));
QPushButton *btnRemove = new QPushButton(container);
QPushButton *btnRemove = new QPushButton(parent);
btnRemove->setObjectName("transferRemove");
btnRemove->setIcon(remove);
btnRemove->setText(tr("Delete"));
QObject::connect(btnRemove, SIGNAL(clicked(bool)), this, SLOT(onRemoveArrived()));
QSpacerItem *item1 = new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed);
layout->addSpacerItem(item1);
layout->addWidget(btnRemove);
QSpacerItem *item2 = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
layout->addSpacerItem(item2);
m_parent->setProperty("container", QVariant::fromValue<QWidget*>(container));
QObject::connect(btnRemove, SIGNAL(clicked()), this, SLOT(onRemoveArrived()));
m_parent->setProperty("container", QVariant::fromValue<QWidget*>(btnRemove));
m_parent->setProperty("btnRemove", QVariant::fromValue<QWidget*>(btnRemove));
return btnRemove;
}
return container;
}
Expand All @@ -150,7 +142,9 @@ void QWoSftpItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOpti
return;
}
QRect rt = option.rect;
editor->setGeometry(rt);
QRect btnRt(rt.left() + BUTTON_HEIGHT, rt.top() + (rt.height() - BUTTON_HEIGHT) / 2, BUTTON_WIDTH, BUTTON_HEIGHT);
qDebug() << "updateEditorGeometry" << btnRt << rt;
editor->setGeometry(btnRt);
editor->setProperty("itemIndex", idx.data(ROLE_TASKINFO));
}

Expand All @@ -175,7 +169,7 @@ QWoSftpTransferWidget::QWoSftpTransferWidget(const QString &target, int gid, boo
ui->dirProgress->setRange(0, 100);
ui->dirProgress->setValue(0);
ui->dirProgress->setVisible(false);
ui->taskArea->setVisible(false);
ui->taskArea->setVisible(true);
QObject::connect(ui->btnBrowser, SIGNAL(clicked()), this, SLOT(onLocalFilePathBrowser()));
QObject::connect(ui->btnCopy, SIGNAL(clicked()), this, SLOT(onRemoteFilePathCopy()));

Expand Down Expand Up @@ -205,6 +199,9 @@ QWoSftpTransferWidget::QWoSftpTransferWidget(const QString &target, int gid, boo

m_progressLabel = new QKxLabelAssist(ui->fileProgress);

ui->fileLocal->installEventFilter(this);
ui->fileRemote->installEventFilter(this);
setTaskLabel(ui->fileLocal->text(), ui->fileRemote->text());
resetAll();
}

Expand All @@ -221,7 +218,6 @@ bool QWoSftpTransferWidget::isQueueMode()
void QWoSftpTransferWidget::onAdjustLayout()
{
adjustSize();
m_elidedText = true;
}

void QWoSftpTransferWidget::onLocalFilePathBrowser()
Expand All @@ -233,11 +229,10 @@ void QWoSftpTransferWidget::onLocalFilePathBrowser()
QFileInfo fi(url);
if(!fi.isDir()) {
QString path = fi.absolutePath();
url = "file:///" + path;
}else{
url = "file:///" + url;
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
return;
}
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
QDesktopServices::openUrl(QUrl::fromLocalFile(url));
}

void QWoSftpTransferWidget::onRemoteFilePathCopy()
Expand Down Expand Up @@ -488,7 +483,6 @@ void QWoSftpTransferWidget::runTask(const TaskInfo& ti)
m_taskFiles.clear();
ui->btnStart->hide();
ui->btnStop->setVisible(m_queueMode);
m_elidedText = false;
QWoUtils::setLayoutVisible(ui->dirLayout, ti.isDir);
if(ti.isDir) {
ui->fileCount->setText(QString::number(m_taskFiles.length()));
Expand Down Expand Up @@ -727,12 +721,12 @@ void QWoSftpTransferWidget::setTaskLabel(const QString &_local, const QString &_

ui->fileLocal->setProperty("fileLocal", local);
ui->fileRemote->setProperty("fileRemote", remote);
if(m_elidedText) {
QFontMetrics fm1(ui->fileLocal->font());
QFontMetrics fm2(ui->fileRemote->font());
local = fm1.elidedText(local, Qt::ElideLeft, ui->fileLocal->width());
remote = fm2.elidedText(remote, Qt::ElideLeft, ui->fileRemote->width());
}

QFontMetrics fm1(ui->fileLocal->font());
QFontMetrics fm2(ui->fileRemote->font());
local = fm1.elidedText(local, Qt::ElideLeft, ui->fileLocal->width());
remote = fm2.elidedText(remote, Qt::ElideLeft, ui->fileRemote->width());

ui->fileLocal->setText(local);
ui->fileRemote->setText(remote);
}
Expand Down Expand Up @@ -855,3 +849,24 @@ void QWoSftpTransferWidget::paintEvent(QPaintEvent *e)
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}

bool QWoSftpTransferWidget::eventFilter(QObject *obj, QEvent *ev)
{
QEvent::Type t = ev->type();
if(obj == ui->fileLocal) {
if(t == QEvent::Resize) {
QString local = obj->property("fileLocal").toString();
QFontMetrics fm(ui->fileLocal->font());
local = fm.elidedText(local, Qt::ElideLeft, ui->fileLocal->width());
ui->fileLocal->setText(local);
}
}else if(obj == ui->fileRemote) {
if(t == QEvent::Resize) {
QString remote = obj->property("fileRemote").toString();
QFontMetrics fm(ui->fileRemote->font());
remote = fm.elidedText(remote, Qt::ElideLeft, ui->fileRemote->width());
ui->fileRemote->setText(remote);
}
}
return QWidget::eventFilter(obj, ev);
}
2 changes: 1 addition & 1 deletion woterm/qwosftptransferwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ private slots:
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void paintEvent(QPaintEvent *e);
virtual bool eventFilter(QObject *obj, QEvent *ev);
private:
Ui::QWoSftpTransferWidget *ui;
QPoint m_dragPosition;
QString m_target;
int m_gid;
bool m_queueMode;

bool m_elidedText;
EAbortExpected m_abortExpected;

QPointer<QWoSshFtp> m_sftp;
Expand Down
2 changes: 1 addition & 1 deletion woterm/qwosftptransferwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<width>4421</width>
<height>254</height>
</rect>
</property>
Expand Down
Loading

0 comments on commit 5dc74e0

Please sign in to comment.