Skip to content

Commit

Permalink
v9.29.2
Browse files Browse the repository at this point in the history
[SFTP]编辑文件,增加弹泡提示并同步和弹框提示并确认才同步两种功能优化。
[SSH]修复默认加载~/.ssh/config 和 /etc/ssh/ssh_config系统配置,导致连接异常缺陷。

[SFTP] Edit the file, add bubble prompt and synchronize, and optimize the two functions of pop-up prompt and confirm before synchronizing.
[SSH] Fix default loading~/. ssh/config and/etc/ssh/ssh_ Configuration of the config system resulted in abnormal connection defects.
  • Loading branch information
getwingm committed Oct 23, 2023
1 parent c9b8694 commit f228711
Show file tree
Hide file tree
Showing 14 changed files with 645 additions and 146 deletions.
305 changes: 172 additions & 133 deletions private/languages/woterm_zh.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions woterm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ set(SOURCE_FILES
qkxtouchpoint.cpp
qkxloadingbarwidget.cpp
qkxpositionitem.cpp
qkxbubblesyncwidget.cpp
qkxplaintextedit.cpp
#window object
main.cpp
qwotheme.cpp
Expand Down Expand Up @@ -230,6 +232,8 @@ set(HEADER_FILES
qkxmessagebox.h
qkxloadingbarwidget.h
qkxpositionitem.h
qkxbubblesyncwidget.h
qkxplaintextedit.h
# window object
qwotheme.h
qwoapplication.h
Expand Down Expand Up @@ -400,6 +404,7 @@ set(OTHER_FILES
woterm.qrc
qwoplaybookmanagedialog.ui
qwoplaybookconfiguredialog.ui
qkxbubblesyncwidget.ui
# window object
qwoplaybookwidget.ui
qkxfilterlistview.ui
Expand Down
128 changes: 128 additions & 0 deletions woterm/qkxbubblesyncwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*******************************************************************************************
*
* Copyright (C) 2023 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
*
* Contact: http://www.aoyiduo.com
*
* this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
* more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
*
*******************************************************************************************/

#include "qkxbubblesyncwidget.h"
#include "ui_qkxbubblesyncwidget.h"

#include <QDesktopWidget>
#include <QScreen>
#include <QGuiApplication>
#include <QTimer>
#include <QCursor>
#include <QDebug>

QKxBubbleSyncWidget::QKxBubbleSyncWidget(QWidget *parent) :
QWidget(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowStaysOnTopHint | Qt::Tool),
ui(new Ui::QKxBubbleSyncWidget)
{
ui->setupUi(this);

setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(ui->btnClose, SIGNAL(clicked()), this, SLOT(close()));

ui->content->setReadOnly(true);

QString style = "QToolButton{border:0;border-radius:3px;}\r\n";
style += "QToolButton:hover{background-color:rgba(255,255,255,128)}\r\n";
style += "QToolButton:pressed{background-color:rgba(200,200,200,128)}";
ui->btnClose->setStyleSheet(style);

setFixedSize(240, 180);
resetLayout();
}

QKxBubbleSyncWidget::~QKxBubbleSyncWidget()
{
delete ui;
}

void QKxBubbleSyncWidget::setMessage(const QString& title, const QString &msg, int timeout)
{
Task t;
t.content = msg;
t.title = title;
t.timeout = timeout;
m_tasks.append(t);
if(m_tasks.length() > 1) {
return;
}
if(m_timer == nullptr) {
m_timer = new QTimer(this);
QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
}
m_timer->start(timeout);
ui->title->setText(title);
ui->content->setPlainText(msg);
resetLayout();
}

void QKxBubbleSyncWidget::onResetLayout()
{
QSize sz = size();
QScreen *screen = QGuiApplication::primaryScreen();
QRect rt = screen->geometry();
rt.setLeft(rt.right() - sz.width());
rt.setTop(rt.bottom() - sz.height());
setGeometry(rt);
show();
}

void QKxBubbleSyncWidget::onTimeout()
{
if(m_tasks.isEmpty()) {
if(isCursorHover()) {
return;
}
deleteLater();
return;
}
m_tasks.takeFirst();
if(m_tasks.isEmpty()) {
if(isCursorHover()) {
return;
}
deleteLater();
return;
}
Task t = m_tasks.first();
ui->title->setText(t.title);
ui->content->setPlainText(t.content);
m_timer->start(t.timeout);
}

void QKxBubbleSyncWidget::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton) {
move(event->globalPos() - m_dragPosition);
event->accept();
}
}

void QKxBubbleSyncWidget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
event->accept();
}
}

bool QKxBubbleSyncWidget::isCursorHover()
{
QPoint pt = QCursor::pos();
QRect rt = geometry();
//qDebug() << pt << rt << rt.contains(pt);
return rt.contains(pt);
}

void QKxBubbleSyncWidget::resetLayout()
{
QMetaObject::invokeMethod(this, "onResetLayout", Qt::QueuedConnection);
}
56 changes: 56 additions & 0 deletions woterm/qkxbubblesyncwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*******************************************************************************************
*
* Copyright (C) 2023 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
*
* Contact: http://www.aoyiduo.com
*
* this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
* more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
*
*******************************************************************************************/

#ifndef QKXBUBBLESYNCWIDGET_H
#define QKXBUBBLESYNCWIDGET_H

#include <QWidget>
#include <QPointer>
#include <QList>

namespace Ui {
class QKxBubbleSyncWidget;
}

class QTimer;

class QKxBubbleSyncWidget : public QWidget
{
Q_OBJECT

public:
explicit QKxBubbleSyncWidget(QWidget *parent = nullptr);
~QKxBubbleSyncWidget();

void setMessage(const QString& title, const QString& msg, int timeout = 1000);
Q_INVOKABLE void resetLayout();
private slots:
void onResetLayout();
void onTimeout();
private:
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
private:
bool isCursorHover();
private:
Ui::QKxBubbleSyncWidget *ui;
QPointer<QTimer> m_timer;
QPoint m_dragPosition;

struct Task{
QString title;
QString content;
int timeout;
};
QList<Task> m_tasks;
};

#endif // QKXBUBBLESYNCWIDGET_H
93 changes: 93 additions & 0 deletions woterm/qkxbubblesyncwidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QKxBubbleSyncWidget</class>
<widget class="QWidget" name="QKxBubbleSyncWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>137</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="title">
<property name="text">
<string>title</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="btnClose">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="woterm.qrc">
<normaloff>:/woterm/resource/images/close.png</normaloff>:/woterm/resource/images/close.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPlainTextEdit" name="content">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="woterm.qrc"/>
</resources>
<connections/>
</ui>
68 changes: 68 additions & 0 deletions woterm/qkxplaintextedit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*******************************************************************************************
*
* Copyright (C) 2023 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
*
* Contact: http://www.aoyiduo.com
*
* this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
* more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
*
*******************************************************************************************/

#include "qkxplaintextedit.h"

#include <QMouseEvent>
#include <QDebug>

QKxPlainTextEdit::QKxPlainTextEdit(QWidget *parent)
: QPlainTextEdit(parent)
{
setMouseTracking(true);
setAttribute(Qt::WA_Hover,true);
}

QKxPlainTextEdit::~QKxPlainTextEdit()
{

}

void QKxPlainTextEdit::mousePressEvent(QMouseEvent *e)
{
m_clickedAnchor = (e->button() & Qt::LeftButton) ? anchorAt(e->pos()) : QString();
QPlainTextEdit::mousePressEvent(e);
}

void QKxPlainTextEdit::mouseMoveEvent(QMouseEvent *e)
{
QString link = anchorAt(e->pos());
if(link.isEmpty()) {
unsetCursor();
}else{
setCursor(Qt::ArrowCursor);
}
QPlainTextEdit::mouseMoveEvent(e);
}

void QKxPlainTextEdit::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() & Qt::LeftButton && !m_clickedAnchor.isEmpty() && anchorAt(e->pos()) == m_clickedAnchor) {
emit linkActivated(m_clickedAnchor);
}

QPlainTextEdit::mouseReleaseEvent(e);
}

bool QKxPlainTextEdit::event(QEvent *e)
{
if(QEvent::HoverMove == e->type()){
QHoverEvent *hoverEvent = static_cast<QHoverEvent*>(e);
QString link = anchorAt(hoverEvent->pos());
if(link.isEmpty()) {
unsetCursor();
}else{
setCursor(Qt::ArrowCursor);
}
qDebug() << hoverEvent->pos() << "anchor: " << link;
}
return QWidget::event(e);
}
Loading

0 comments on commit f228711

Please sign in to comment.