From 5dc330ed01b856728e59af1fb1224510a1461ed2 Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Mon, 17 Oct 2022 16:53:05 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=90=9E=20fix(=E6=8A=95=E5=B1=8F?= =?UTF-8?q?=E6=A8=A1=E5=9D=97):=20=E4=BF=AE=E6=94=B9=E6=8A=95=E5=B1=8F?= =?UTF-8?q?=E6=8E=A7=E5=88=B6Tab=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为了解决投屏Tab被全屏覆盖问题 --- common/CMakeLists.txt | 1 + {ui => common}/publicattributes.hpp | 0 pcscreenmanage/CMakeLists.txt | 11 +- pcscreenmanage/curtain/curtain.cpp | 116 +++++++++++++---- pcscreenmanage/curtain/curtain.h | 28 +++- pcscreenmanage/curtain/curtain.pri | 12 -- pcscreenmanage/curtain/fullscreenwindow.cpp | 121 ------------------ pcscreenmanage/curtain/fullscreenwindow.h | 84 ------------ pcscreenmanage/pcscreenmanage.cpp | 93 ++++++++++---- pcscreenmanage/pcscreenmanage.h | 28 ++-- {ui/view => pcscreenmanage}/suspendtabbar.cpp | 54 +++----- {ui/view => pcscreenmanage}/suspendtabbar.h | 7 +- ui/CMakeLists.txt | 3 - ui/mainwindow.cpp | 94 +------------- ui/mainwindow.h | 3 - 15 files changed, 243 insertions(+), 412 deletions(-) rename {ui => common}/publicattributes.hpp (100%) delete mode 100644 pcscreenmanage/curtain/curtain.pri delete mode 100644 pcscreenmanage/curtain/fullscreenwindow.cpp delete mode 100644 pcscreenmanage/curtain/fullscreenwindow.h rename {ui/view => pcscreenmanage}/suspendtabbar.cpp (85%) rename {ui/view => pcscreenmanage}/suspendtabbar.h (92%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 57edd07..180acf1 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -23,6 +23,7 @@ set(MOBILE_COMMON_SOURCES generatetools.h generatetools.cpp highlight-effect.h + publicattributes.hpp serverstatus.h serverstatus.cpp util.h diff --git a/ui/publicattributes.hpp b/common/publicattributes.hpp similarity index 100% rename from ui/publicattributes.hpp rename to common/publicattributes.hpp diff --git a/pcscreenmanage/CMakeLists.txt b/pcscreenmanage/CMakeLists.txt index b9c3091..72c7074 100644 --- a/pcscreenmanage/CMakeLists.txt +++ b/pcscreenmanage/CMakeLists.txt @@ -2,8 +2,6 @@ set(MOBILE_CURTAIN_SOURCES curtain/curtain.h curtain/curtain.cpp - curtain/fullscreenwindow.h - curtain/fullscreenwindow.cpp ) source_group(curtain FILES ${MOBILE_CURTAIN_SOURCES}) @@ -25,11 +23,19 @@ set(MOBILE_SOURCES ${CONTROL_SOURCES} pcscreenmanage.h pcscreenmanage.cpp + suspendtabbar.cpp + suspendtabbar.h screenmanagemsg.pb.h screenmanagemsg.pb.cc ) add_library(pcscreenmanage ${MOBILE_SOURCES}) +find_package(PkgConfig REQUIRED) +pkg_check_modules(KYSDK_QTWIDGETS kysdk-qtwidgets) +target_include_directories(pcscreenmanage PUBLIC ${KYSDK_QTWIDGETS_INCLUDE_DIRS}) +target_link_directories(pcscreenmanage PUBLIC ${KYSDK_QTWIDGETS_LIBRARY_DIRS}) +target_link_libraries(pcscreenmanage PUBLIC ${KYSDK_QTWIDGETS_LIBRARIES}) + target_include_directories(pcscreenmanage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/curtain) target_include_directories(pcscreenmanage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/pcscreen) target_include_directories(pcscreenmanage PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/control) @@ -40,6 +46,7 @@ find_package(Qt5WebEngineWidgets COMPONENTS WebEngineWidgets REQUIRED) target_link_libraries(pcscreenmanage PUBLIC Qt${QT_VERSION_MAJOR}::Widgets ${Qt5WebEngineWidgets_LIBRARIES} + mobile_common ) diff --git a/pcscreenmanage/curtain/curtain.cpp b/pcscreenmanage/curtain/curtain.cpp index 67d3d87..e831c50 100644 --- a/pcscreenmanage/curtain/curtain.cpp +++ b/pcscreenmanage/curtain/curtain.cpp @@ -53,14 +53,18 @@ #include #include #include +#include #include #include #include #include #include +#include +#include #include #include #include +#include Curtain::Curtain(QWidget *parent) : QWidget(parent), m_view(new QWebEngineView(this)) { @@ -70,6 +74,7 @@ Curtain::Curtain(QWidget *parent) : QWidget(parent), m_view(new QWebEngineView(t layout->setMargin(0); layout->setSpacing(0); setLayout(layout); + m_view->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); m_view->setContextMenuPolicy(Qt::NoContextMenu); connect(m_view->page(), &QWebEnginePage::fullScreenRequested, this, &Curtain::fullScreenRequested); @@ -79,27 +84,74 @@ Curtain::Curtain(QWidget *parent) : QWidget(parent), m_view(new QWebEngineView(t system(common.toUtf8().constData()); qApp->setOverrideCursor(QCursor(Qt::ArrowCursor)); }); + + m_suspendTabBar = new SuspendTabBar(SuspendTabBar::Display::Whole, false, this); + connect(m_suspendTabBar, &SuspendTabBar::sigBtnClicked, this, &Curtain::slotTabBtnClicked); + m_view->stackUnder(m_suspendTabBar); + + auto exitAction = new QAction(this); + exitAction->setShortcut(Qt::Key_Escape); + addAction(exitAction); + connect(exitAction, &QAction::triggered, [this]() { + Q_EMIT sigStateChange(Curtain::States::ReturnDesktop); + hideView(); + }); } -Curtain::~Curtain() {} +Curtain::~Curtain() +{ + delete m_suspendTabBar1; +} + +void Curtain::setTheme(PublicAttributes::Theme theme) +{ + m_theme = theme; + if (m_suspendTabBar) { + m_suspendTabBar->setTheme(m_theme); + } +} void Curtain::showView() { - if (m_fullScreenWindow && m_fullScreenWindow->isHidden()) { - m_fullScreenWindow->show(); - m_fullScreenWindow->showFullScreen(); - m_fullScreenWindow->activateWindow(); - m_fullScreenWindow->setFocus(); - } + m_suspendTabBar1->hideTabBar(); show(); + showMaximized(); + showFullScreen(); } void Curtain::hideView() { - if (m_fullScreenWindow && !m_fullScreenWindow->isHidden()) { - m_fullScreenWindow->hide(); - } hide(); + if (m_suspendTabBar1 == nullptr) { + m_suspendTabBar1 = new SuspendTabBar(SuspendTabBar::Display::Whole, true); + connect(m_suspendTabBar1, &SuspendTabBar::sigBtnClicked, this, &Curtain::slotTabBtnClicked); + } + m_suspendTabBar1->setTheme(m_theme); + m_suspendTabBar1->setDeskBtnState(true); + m_suspendTabBar1->showTabBar(); +} + +void Curtain::hideTabBar() +{ + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->hideTabBar(); + } +} + +void Curtain::showTabBar() +{ + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->showTabBar(); + } +} + +void Curtain::resizeEvent(QResizeEvent *event) +{ + QRect viewGeometry(QPoint(0, 0), size()); + m_view->setGeometry(viewGeometry); + m_suspendTabBar->showTabBar(); + + QWidget::resizeEvent(event); } void Curtain::loadUrl(QString &url) @@ -107,24 +159,38 @@ void Curtain::loadUrl(QString &url) qInfo() << "Sending request to projection service."; m_url = url; m_view->setUrl(QUrl(m_url)); + showMaximized(); + showFullScreen(); } void Curtain::fullScreenRequested(QWebEngineFullScreenRequest request) { - if (request.toggleOn()) { - if (m_fullScreenWindow) - return; - request.accept(); - FullScreenWindow *fullScreenWindow = new FullScreenWindow(m_view); - connect(fullScreenWindow, &FullScreenWindow::sigHideView, this, [=]() { - hideView(); - Q_EMIT sigHideView(); - }); - m_fullScreenWindow.reset(fullScreenWindow); - } else { - if (!m_fullScreenWindow) - return; - request.accept(); - m_fullScreenWindow.reset(); + request.accept(); + showMaximized(); + showFullScreen(); +} + +void Curtain::slotTabBtnClicked(SuspendTabBar::BtnType type) +{ + switch (type) { + case SuspendTabBar::BtnType::ControlBtn: { + // 暂时先模拟键盘进入反控 + showView(); + hideTabBar(); + QString common = "xdotool key ctrl+h"; + system(common.toUtf8().constData()); + Q_EMIT sigStateChange(Curtain::States::Control); + } break; + case SuspendTabBar::BtnType::ReturnDesktopBtn: { + hideView(); + Q_EMIT sigStateChange(Curtain::States::ReturnDesktop); + } break; + case SuspendTabBar::BtnType::ScreenShareBtn: { + showView(); + Q_EMIT sigStateChange(Curtain::States::ScreenShare); + } break; + case SuspendTabBar::BtnType::ExitBtn: { + Q_EMIT sigStateChange(Curtain::States::Exit); + } break; } } \ No newline at end of file diff --git a/pcscreenmanage/curtain/curtain.h b/pcscreenmanage/curtain/curtain.h index 0e662ad..e663d99 100644 --- a/pcscreenmanage/curtain/curtain.h +++ b/pcscreenmanage/curtain/curtain.h @@ -51,12 +51,14 @@ #ifndef CURTAIN_H #define CURTAIN_H -#include "fullscreenwindow.h" - #include #include #include +#include +#include #include +#include "suspendtabbar.h" +#include "publicattributes.hpp" class Curtain : public QWidget { @@ -64,22 +66,40 @@ class Curtain : public QWidget public: explicit Curtain(QWidget *parent = nullptr); ~Curtain(); + enum States { + Control = 0, // 反控 + ControlClose, // 取消反控 + ReturnDesktop, // 返回桌面 + ScreenShare, // 投屏 + Exit, // 退出 + }; + Q_ENUM(States) + void setTheme(PublicAttributes::Theme theme); void showView(); void hideView(); + void hideTabBar(); + void showTabBar(); + +protected: + void resizeEvent(QResizeEvent *event) override; + // bool eventFilter(QObject *obj, QEvent *event) override; public: void loadUrl(QString &url); Q_SIGNALS: - void sigHideView(); + void sigStateChange(Curtain::States); private Q_SLOTS: void fullScreenRequested(QWebEngineFullScreenRequest request); + void slotTabBtnClicked(SuspendTabBar::BtnType type); private: QWebEngineView *m_view; - QScopedPointer m_fullScreenWindow; QString m_url = ""; + PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light; // 主题 + SuspendTabBar *m_suspendTabBar = nullptr; + SuspendTabBar *m_suspendTabBar1 = nullptr; }; #endif // CURTAIN_H diff --git a/pcscreenmanage/curtain/curtain.pri b/pcscreenmanage/curtain/curtain.pri deleted file mode 100644 index bd57c84..0000000 --- a/pcscreenmanage/curtain/curtain.pri +++ /dev/null @@ -1,12 +0,0 @@ -QT += webenginewidgets - -HEADERS += $$PWD/curtain.h \ - $$PWD/fullscreenwindow.h \ - $$PWD/fullscreennotification.h - -SOURCES += $$PWD/curtain.cpp \ - $$PWD/fullscreenwindow.cpp \ - $$PWD/fullscreennotification.cpp - - - diff --git a/pcscreenmanage/curtain/fullscreenwindow.cpp b/pcscreenmanage/curtain/fullscreenwindow.cpp deleted file mode 100644 index 0af12a1..0000000 --- a/pcscreenmanage/curtain/fullscreenwindow.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "fullscreenwindow.h" - -#include -#include -#include -#include -#include - -FullScreenWindow::FullScreenWindow(QWebEngineView *oldView, QWidget *parent) - : QWidget(parent), m_view(new QWebEngineView(this)), m_oldView(oldView), - m_oldGeometry(oldView->window()->geometry()) -{ - setWindowFlags(Qt::FramelessWindowHint); //无边框 - m_view->setContextMenuPolicy(Qt::NoContextMenu); - - // this->setWindowState(Qt::WindowFullScreen); - // QRect rect = qApp->desktop()->geometry(); - // rect.setY(-1); - // rect.setHeight(rect.height()); - // this->setGeometry(rect); - - auto exitAction = new QAction(this); - exitAction->setShortcut(Qt::Key_Escape); - connect(exitAction, &QAction::triggered, [this]() { - // m_view->triggerPageAction(QWebEnginePage::ExitFullScreen); - Q_EMIT sigHideView(); - }); - // auto ctrlhAction = new QAction(this); - // ctrlhAction->setShortcut(QKeySequence(QLatin1String("Ctrl+H"))); - // connect(ctrlhAction, &QAction::triggered, [this]() { - // //qInfo() << "HHHHHHHHHHHHHHHH"; - // Q_EMIT sigControlState(true); - // }); - // auto ctrlgAction = new QAction(this); - // ctrlgAction->setShortcut(QKeySequence(QLatin1String("Ctrl+G"))); - // connect(ctrlgAction, &QAction::triggered, [this]() { - // //qInfo() << "GGGGGGGGGGGGGGGGGGGGG"; - // Q_EMIT sigControlState(false); - // }); - addAction(exitAction); - // addAction(ctrlhAction); - // addAction(ctrlgAction); - - m_view->setPage(m_oldView->page()); - setGeometry(m_oldGeometry); - showFullScreen(); - m_oldView->window()->hide(); -} - -FullScreenWindow::~FullScreenWindow() -{ - m_oldView->setPage(m_view->page()); - m_oldView->window()->setGeometry(m_oldGeometry); - m_oldView->window()->show(); - hide(); -} - -void FullScreenWindow::resizeEvent(QResizeEvent *event) -{ - QWindowsWindowFunctions::setHasBorderInFullScreen(this->windowHandle(), true); - QRect viewGeometry(QPoint(0, 0), size()); - m_view->setGeometry(viewGeometry); - - QWidget::resizeEvent(event); -} - -// void FullScreenWindow::showEvent(QShowEvent *event) -// { -// QWindowsWindowFunctions::setHasBorderInFullScreen(this->windowHandle(), true); -// // qInfo() << "111111111111111111111111111111111"; -// } diff --git a/pcscreenmanage/curtain/fullscreenwindow.h b/pcscreenmanage/curtain/fullscreenwindow.h deleted file mode 100644 index 6c961f9..0000000 --- a/pcscreenmanage/curtain/fullscreenwindow.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FULLSCREENWINDOW_H -#define FULLSCREENWINDOW_H - -#include -#include -#include -#include - - -QT_BEGIN_NAMESPACE -class QWebEngineView; -QT_END_NAMESPACE - -class FullScreenWindow : public QWidget -{ - Q_OBJECT -public: - explicit FullScreenWindow(QWebEngineView *oldView, QWidget *parent = nullptr); - ~FullScreenWindow(); - -protected: - void resizeEvent(QResizeEvent *event) override; - // void showEvent(QShowEvent *event) override; -Q_SIGNALS: - // void sigControlState(bool); - void sigHideView(); - -private: - QWebEngineView *m_view; - QWebEngineView *m_oldView; - QRect m_oldGeometry; -}; - -#endif // FULLSCREENWINDOW_H diff --git a/pcscreenmanage/pcscreenmanage.cpp b/pcscreenmanage/pcscreenmanage.cpp index 9397604..603cf67 100644 --- a/pcscreenmanage/pcscreenmanage.cpp +++ b/pcscreenmanage/pcscreenmanage.cpp @@ -30,6 +30,17 @@ PcScreenManage::~PcScreenManage() } } +void PcScreenManage::setTheme(PublicAttributes::Theme theme) +{ + m_theme = theme; + if (m_curtain != nullptr) { + m_curtain->setTheme(m_theme); + } + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->setTheme(m_theme); + } +} + void PcScreenManage::disconnected() { m_isService = true; @@ -106,19 +117,17 @@ void PcScreenManage::startCurtain(QString roomid) { if (m_curtain == nullptr) { m_curtain = new Curtain; - connect(m_curtain, &Curtain::sigHideView, this, [=]() { - Q_EMIT sigRequestReceived(ScreenMsg::HideView); - }); - QRect geometry = QGuiApplication::primaryScreen()->availableGeometry(); - m_curtain->setGeometry(geometry); - m_curtain->showMaximized(); + connect(m_curtain, &Curtain::sigStateChange, this, &PcScreenManage::slotStateChange); } QString targetUrl; if (!roomid.isEmpty()) { targetUrl = LOAD_URL.arg(m_address).arg(roomid); qInfo() << "targetUrl = " << targetUrl; } + m_curtain->showFullScreen(); + m_curtain->showMaximized(); m_curtain->loadUrl(targetUrl); + m_curtain->setTheme(m_theme); } void PcScreenManage::startControl() @@ -151,20 +160,6 @@ void PcScreenManage::startControl() } } -void PcScreenManage::showCurtain() -{ - if (m_curtain != nullptr) { - m_curtain->showView(); - } -} - -void PcScreenManage::hideCurtain() -{ - if (m_curtain != nullptr) { - m_curtain->hideView(); - } -} - void PcScreenManage::startedControl() { ScreenManageMsg message; @@ -179,6 +174,13 @@ void PcScreenManage::exitControl() sendMessage(message); } +void PcScreenManage::showView() +{ + if (m_curtain != nullptr) { + m_curtain->showView(); + } +} + void PcScreenManage::closePcScreenService() { qInfo() << "Closing the projection service..."; @@ -292,11 +294,16 @@ void PcScreenManage::onMessageReadyRead() } break; case ScreenManageMsg::STARTEDCONTROL: { qInfo() << "Enter anti control."; - Q_EMIT sigRequestReceived(ScreenMsg::StartedControl); + m_suspendTabBar = new SuspendTabBar(SuspendTabBar::Display::Part, true); + connect(m_suspendTabBar, &SuspendTabBar::sigBtnClicked, this, &PcScreenManage::slotTabBtnClicked); + m_suspendTabBar->setTheme(m_theme); + m_suspendTabBar->showTabBar(); } break; case ScreenManageMsg::EXITCONTROL: { qInfo() << "Exit anti control."; - Q_EMIT sigRequestReceived(ScreenMsg::ExitControl); + QString common = "xdotool key ctrl+g"; + system(common.toUtf8().constData()); + m_curtain->showTabBar(); } break; } } @@ -341,6 +348,48 @@ void PcScreenManage::slotSocketDisconnect() // Q_EMIT sigRequestReceived(ScreenMsg::Disconnect); } +void PcScreenManage::slotStateChange(Curtain::States state) +{ + switch (state) { + case Curtain::States::Control: { + // 进入反控 + m_curtain->hideTabBar(); + startedControl(); + } break; + case Curtain::States::ReturnDesktop: { + Q_EMIT sigRequestReceived(ScreenMsg::HideView); + } break; + case Curtain::States::ScreenShare: { + Q_EMIT sigRequestReceived(ScreenMsg::ShowView); + } break; + case Curtain::States::Exit: { + Q_EMIT sigRequestReceived(ScreenMsg::ScreenExit); + disconnected(); + } break; + } +} + +void PcScreenManage::slotTabBtnClicked(SuspendTabBar::BtnType type) +{ + switch (type) { + case SuspendTabBar::BtnType::ControlBtn: { + // 退出反控 + exitControl(); + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->hideTabBar(); + } + } break; + case SuspendTabBar::BtnType::ExitBtn: { + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->hideTabBar(); + delete m_suspendTabBar; + m_suspendTabBar = nullptr; + } + disconnected(); + } break; + } +} + int PcScreenManage::sendMessage(const ScreenManageMsg &message) { if (m_messageTcpSocket == nullptr) { diff --git a/pcscreenmanage/pcscreenmanage.h b/pcscreenmanage/pcscreenmanage.h index f69bfaf..5405b70 100644 --- a/pcscreenmanage/pcscreenmanage.h +++ b/pcscreenmanage/pcscreenmanage.h @@ -10,6 +10,8 @@ #include "pcscreen.h" #include "curtain.h" #include "control.h" +#include "suspendtabbar.h" +#include "publicattributes.hpp" class PcScreenManage : public QObject { @@ -28,26 +30,26 @@ public: Successfully = 6, // 投屏请求成功 StartedControl = 7, // 启动反控 ExitControl = 8, // 退出反控 - HideView = 9, //隐藏投屏 + HideView = 9, // 隐藏投屏 + ShowView = 10, // 显示投屏 }; Q_ENUM(ScreenMsg) + void setTheme(PublicAttributes::Theme theme); + // 断开通信通道 void disconnected(); // 连接服务端 void connectService(const QString host); // 设置验证结果 void setConnectionRespond(bool isAgree); - // 显示幕布 - void showCurtain(); - // 隐藏幕布 - void hideCurtain(); // 通知对端进入反控 void startedControl(); // 通知对端退出反控 void exitControl(); -public: + void showView(); + private: // 获取投屏服务 void startPcService(); @@ -72,6 +74,8 @@ private Q_SLOTS: void onMessageReadyRead(); void handleStateChange(QAbstractSocket::SocketState state); void slotSocketDisconnect(); + void slotStateChange(Curtain::States state); + void slotTabBtnClicked(SuspendTabBar::BtnType type); private: QTcpServer *m_tcpServer = nullptr; // Tcp服务 @@ -80,12 +84,14 @@ private: QThread *m_pcScreenThread = nullptr; //投屏服务线程 Curtain *m_curtain = nullptr; // 投屏幕布 Control *m_control = nullptr; // 反控 + SuspendTabBar *m_suspendTabBar = nullptr; - QString m_address = ""; // 客服端ip - qint64 m_dataSize = 0; // 接收的数据大小 - QByteArray m_data; // 需要发送的数据 - bool m_isHead = true; // 是否为消息头 - bool m_isService = true; // 是否为服务端 + QString m_address = ""; // 客服端ip + qint64 m_dataSize = 0; // 接收的数据大小 + QByteArray m_data; // 需要发送的数据 + bool m_isHead = true; // 是否为消息头 + bool m_isService = true; // 是否为服务端 + PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light; // 主题 }; #endif // PCSCREENMANAGE_H \ No newline at end of file diff --git a/ui/view/suspendtabbar.cpp b/pcscreenmanage/suspendtabbar.cpp similarity index 85% rename from ui/view/suspendtabbar.cpp rename to pcscreenmanage/suspendtabbar.cpp index b74276e..4b62a81 100644 --- a/ui/view/suspendtabbar.cpp +++ b/pcscreenmanage/suspendtabbar.cpp @@ -17,25 +17,30 @@ const int WINTHREE_W = 168; const int WINTHREE_H = 56; const double TRANSPARENCY = 0.75; -SuspendTabBar::SuspendTabBar(SuspendTabBar::Display mode, QWidget *parent) : QWidget(parent) +SuspendTabBar::SuspendTabBar(SuspendTabBar::Display mode, bool isTool, QWidget *parent) : QWidget(parent) { setProperty("useStyleWindowManager", false); setProperty("useSystemStyleBlur", true); setAttribute(Qt::WA_TranslucentBackground, true); - setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); + if (isTool) { + setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); + } else { + setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + } if (mode == SuspendTabBar::Display::Whole) { initWholeUI(); } else { initPartUI(); } - m_openBtn = new OpenBtn(this); + m_openBtn = new OpenBtn(isTool, parent); connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); - m_openBtn->show(); + m_openBtn->setFixedHeight(1); initAnimation(); activateWindow(); setFocus(); + QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); - setGeometry(availableGeometry.width() / 2 - width() / 2, 0, width(), height()); + move(availableGeometry.width() / 2 - width() / 2, 0); } SuspendTabBar::~SuspendTabBar() @@ -73,17 +78,6 @@ void SuspendTabBar::setTheme(PublicAttributes::Theme theme) update(); } -void SuspendTabBar::setControlState(bool isControl) -{ - if (isControl) { - m_ctrlBtnState = false; - m_controlBtn->setIcon(QIcon(":/tabbaricon/controlclose.svg")); - } else { - m_ctrlBtnState = true; - m_controlBtn->setIcon(QIcon(":/tabbaricon/control.svg")); - } -} - void SuspendTabBar::hideTabBar() { hide(); @@ -94,6 +88,8 @@ void SuspendTabBar::showTabBar() { show(); m_openBtn->show(); + activateWindow(); + setFocus(); } void SuspendTabBar::setDeskBtnState(bool isDesktop) @@ -209,7 +205,7 @@ void SuspendTabBar::initPartUI() m_controlBtn->setFocusPolicy(Qt::NoFocus); m_exitBtn->setFocusPolicy(Qt::NoFocus); - m_controlBtn->setIcon(QIcon(":/tabbaricon/control.svg")); + m_controlBtn->setIcon(QIcon(":/tabbaricon/controlclose.svg")); m_controlBtn->setToolTip(tr("Counter control (activate Ctrl+H, cancel Ctrl+G)")); m_exitBtn->setToolTip(tr("End screen projection")); @@ -251,25 +247,11 @@ void SuspendTabBar::onClicked() kdk::KToolButton *btn = qobject_cast(sender()); if (btn == m_controlBtn) { - if (m_ctrlBtnState) { - m_ctrlBtnState = false; - m_controlBtn->setIcon(QIcon(":/tabbaricon/controlclose.svg")); - Q_EMIT sigBtnClicked(SuspendTabBar::BtnType::ControlBtn); - } else { - m_ctrlBtnState = true; - m_controlBtn->setIcon(QIcon(":/tabbaricon/control.svg")); - Q_EMIT sigBtnClicked(SuspendTabBar::BtnType::ControlCloseBtn); - } + Q_EMIT sigBtnClicked(SuspendTabBar::BtnType::ControlBtn); } else if (btn == m_switchDeskBtn) { if (m_deskBtnState) { - m_deskBtnState = false; - m_switchDeskBtn->setIcon(QIcon(":/tabbaricon/screenshare.svg")); - m_switchDeskBtn->setToolTip(tr("Back to the desktop")); Q_EMIT sigBtnClicked(SuspendTabBar::BtnType::ReturnDesktopBtn); } else { - m_deskBtnState = true; - m_switchDeskBtn->setIcon(QIcon(":/tabbaricon/desktop.svg")); - m_switchDeskBtn->setToolTip(tr("Resume screen projection")); Q_EMIT sigBtnClicked(SuspendTabBar::BtnType::ScreenShareBtn); } } @@ -289,11 +271,15 @@ void SuspendTabBar::onExitClicked() Q_EMIT sigBtnClicked(SuspendTabBar::BtnType::ExitBtn); } -OpenBtn::OpenBtn(QWidget *parent) : QWidget(parent) +OpenBtn::OpenBtn(bool isTool, QWidget *parent) : QWidget(parent) { setProperty("useStyleWindowManager", false); setAttribute(Qt::WA_TranslucentBackground, true); - setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus | Qt::Tool); + if (isTool) { + setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus | Qt::Tool); + } else { + setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus); + } m_openBtn = new kdk::KToolButton(this); connect(m_openBtn, &kdk::KToolButton::clicked, this, &OpenBtn::sigClicked); diff --git a/ui/view/suspendtabbar.h b/pcscreenmanage/suspendtabbar.h similarity index 92% rename from ui/view/suspendtabbar.h rename to pcscreenmanage/suspendtabbar.h index b75c62d..03cd881 100644 --- a/ui/view/suspendtabbar.h +++ b/pcscreenmanage/suspendtabbar.h @@ -19,12 +19,12 @@ public: }; Q_ENUM(Display) - SuspendTabBar(SuspendTabBar::Display mode = SuspendTabBar::Display::Whole, QWidget *parent = nullptr); + SuspendTabBar(SuspendTabBar::Display mode = SuspendTabBar::Display::Whole, bool isTool = false, + QWidget *parent = nullptr); ~SuspendTabBar(); enum BtnType { ControlBtn = 0, // 反控按钮 - ControlCloseBtn, // 取消反控 ReturnDesktopBtn, // 返回桌面 ScreenShareBtn, // 投屏 ExitBtn, // 退出 @@ -32,7 +32,6 @@ public: Q_ENUM(BtnType) void setTheme(PublicAttributes::Theme theme); - void setControlState(bool isControl); void hideTabBar(); void showTabBar(); void setDeskBtnState(bool isDesktop); @@ -72,7 +71,7 @@ class OpenBtn : public QWidget { Q_OBJECT public: - OpenBtn(QWidget *parent = nullptr); + OpenBtn(bool isTool = false, QWidget *parent = nullptr); void setTheme(PublicAttributes::Theme theme); diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 05b13d0..454743b 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -72,8 +72,6 @@ set(MOBILE_UI_VIEW_SOURCES view/searchedit.h view/backgroundwin.cpp view/backgroundwin.h - view/suspendtabbar.cpp - view/suspendtabbar.h view/levitationbutton.cpp view/levitationbutton.h ) @@ -84,7 +82,6 @@ set(MOBILE_UI_SOURCES ${MOBILE_UI_INITCONNECTWIN_SOURCES} ${MOBILE_UI_STORAGELIST_SOURCES} ${MOBILE_UI_VIEW_SOURCES} - publicattributes.hpp mainwindow.h mainwindow.cpp) diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index f4a95d3..ae633d4 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -82,15 +82,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) if (event->key() == Qt::Key_F1) { m_titlebar->initHelp(); } - // else if (event->key() == Qt::Key_H && event->modifiers() == Qt::ControlModifier) { - // m_suspendTabBar->setControlState(true); - // m_pcScreen->startedControl(); - // m_suspendTabBar->hide(); - // } else if (event->key() == Qt::Key_G && event->modifiers() == Qt::ControlModifier) { - // m_suspendTabBar->setControlState(false); - // m_pcScreen->exitControl(); - // m_suspendTabBar->show(); - // } QWidget::keyPressEvent(event); } @@ -105,7 +96,6 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) void MainWindow::resizeEvent(QResizeEvent *event) { - qDebug() << this->x() << " " << this->y(); Q_UNUSED(event); if (m_listItemWidget) { m_listItemWidget->setViewHeight(); @@ -334,8 +324,8 @@ void MainWindow::changeLightTheme() if (m_connectedWin != nullptr) { m_connectedWin->setTheme(m_theme); } - if (m_suspendTabBar != nullptr) { - m_suspendTabBar->setTheme(m_theme); + if (m_pcScreen != nullptr) { + m_pcScreen->setTheme(m_theme); } } @@ -352,8 +342,8 @@ void MainWindow::changeDarkTheme() if (m_connectedWin != nullptr) { m_connectedWin->setTheme(m_theme); } - if (m_suspendTabBar != nullptr) { - m_suspendTabBar->setTheme(m_theme); + if (m_pcScreen != nullptr) { + m_pcScreen->setTheme(m_theme); } } @@ -793,7 +783,6 @@ void MainWindow::slotDisconnect() deleteStackedWidget(); deleteMobileListWidget(); deleteTransmissionDialog(); - deleteSuspendTab(); stopLoadUI(); slotContinueSearch(); if (m_isServerConnect) { @@ -1058,15 +1047,10 @@ void MainWindow::slotRequestReceived(PcScreenManage::ScreenMsg msg) stopLoadUI(); if (m_connectInfo.deviceRole == ConnectionService::DeviceRole::INITIATOR) { hide(); - m_suspendTabBar = new SuspendTabBar(SuspendTabBar::Display::Whole); - connect(m_suspendTabBar, &SuspendTabBar::sigBtnClicked, this, &MainWindow::slotTabBtnClicked); - m_suspendTabBar->setTheme(m_theme); - m_suspendTabBar->showTabBar(); } } break; case PcScreenManage::ScreenMsg::ScreenExit: { // 投屏退出 - deleteSuspendTab(); show(); if (m_connectInfo.deviceRole == ConnectionService::DeviceRole::RECIPIENT && m_connectedWin != nullptr) { m_connectedWin->restoreScreenButton(); @@ -1092,7 +1076,6 @@ void MainWindow::slotRequestReceived(PcScreenManage::ScreenMsg msg) } break; case PcScreenManage::ScreenMsg::Disconnect: { // 投屏断开 - deleteSuspendTab(); disconnectScreen(); show(); QString str1 = QString(tr("End of screen projection")); @@ -1103,34 +1086,12 @@ void MainWindow::slotRequestReceived(PcScreenManage::ScreenMsg msg) m_messageBox->addButton(QString(tr("OK")), QMessageBox::AcceptRole); m_messageBox->show(); } break; - case PcScreenManage::ScreenMsg::StartedControl: { - // 进入反控 - // if (m_connectInfo.deviceRole == ConnectionService::DeviceRole::INITIATOR && m_suspendTabBar == nullptr) { - // m_suspendTabBar = new SuspendTabBar(SuspendTabBar::Display::Part); - // connect(m_suspendTabBar, &SuspendTabBar::sigBtnClicked, this, &MainWindow::slotTabBtnClicked); - // m_suspendTabBar->setTheme(m_theme); - // m_suspendTabBar->setControlState(true); - // m_suspendTabBar->showTabBar(); - // } - } break; - case PcScreenManage::ScreenMsg::ExitControl: { - // if (m_connectInfo.deviceRole == ConnectionService::DeviceRole::RECIPIENT && m_suspendTabBar != nullptr) { - // // 暂时先模拟键盘退出 - // QString common = "xdotool key ctrl+g"; - // system(common.toUtf8().constData()); - // // 退出反控 - // m_suspendTabBar->setControlState(false); - // m_suspendTabBar->showTabBar(); - // } else if (m_connectInfo.deviceRole == ConnectionService::DeviceRole::INITIATOR && m_suspendTabBar != - // nullptr) { - // m_suspendTabBar->setControlState(false); - // m_suspendTabBar->hideTabBar(); - // } - } break; case PcScreenManage::ScreenMsg::HideView: { - m_suspendTabBar->setDeskBtnState(true); show(); } break; + case PcScreenManage::ScreenMsg::ShowView: { + hide(); + } break; } } @@ -1679,52 +1640,11 @@ void MainWindow::slotExitPcScreen() if (m_connectedWin != nullptr) { m_connectedWin->restoreScreenButton(); } - deleteSuspendTab(); if (m_pcScreen != nullptr) { m_pcScreen->disconnected(); } } -void MainWindow::slotTabBtnClicked(SuspendTabBar::BtnType type) -{ - switch (type) { - case SuspendTabBar::BtnType::ControlBtn: { - // if (m_suspendTabBar != nullptr) { - // m_suspendTabBar->hideTabBar(); - // } - // 暂时先模拟键盘进入反控 - m_pcScreen->showCurtain(); - QString common = "xdotool key ctrl+h"; - system(common.toUtf8().constData()); - m_suspendTabBar->setDeskBtnState(false); - // m_pcScreen->startedControl(); - } break; - case SuspendTabBar::BtnType::ControlCloseBtn: { - m_pcScreen->exitControl(); - } break; - case SuspendTabBar::BtnType::ReturnDesktopBtn: { - m_pcScreen->hideCurtain(); - show(); - } break; - case SuspendTabBar::BtnType::ScreenShareBtn: { - m_pcScreen->showCurtain(); - hide(); - } break; - case SuspendTabBar::BtnType::ExitBtn: { - slotExitPcScreen(); - show(); - } break; - } -} - -void MainWindow::deleteSuspendTab() -{ - if (m_suspendTabBar != nullptr) { - delete m_suspendTabBar; - m_suspendTabBar = nullptr; - } -} - void MainWindow::connectMobileFileList() { connect(m_mobileFileList, &MobileFileList::sigPictureClicked, this, &MainWindow::slotItemButtonClicked); diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 83aa78b..15ae8e1 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -135,7 +135,6 @@ private: void initPcSearchInfo(); void discInit(); void deInitDisc(); - void deleteSuspendTab(); void connectMobileFileList(); void connectMobileStorage(); @@ -183,7 +182,6 @@ private: LoadDialog *m_loadDialog = nullptr; //加载动画 LoadAnimation *m_loadAnimation = nullptr; // 打开/更新加载界面 QTimer *m_timer = nullptr; // 连接加载定时器,连接超时处理 - SuspendTabBar *m_suspendTabBar = nullptr; // 投屏控制Tab int m_fileSyncIndex = 2; // 手机文件同步堆栈窗口索引 QListView::ViewMode m_classificationMode = QListView::IconMode; // 分类列表当前视图模式 @@ -256,7 +254,6 @@ public Q_SLOTS: void slotConnectedWinBtnClicked(ConnectedWin::BtnType type); void slotExitMobileScreen(); void slotExitPcScreen(); - void slotTabBtnClicked(SuspendTabBar::BtnType type); }; #endif // MAINWINDOW_H From f77eb22339082da5bbd72fea05ecd6a5e9188487 Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Tue, 18 Oct 2022 10:12:42 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=90=9E=20fix(UI=E6=A8=A1=E5=9D=97):?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E5=8F=8D=E6=8E=A7=E6=97=B6Tab=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pcscreenmanage/curtain/curtain.cpp | 4 +++- pcscreenmanage/pcscreenmanage.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pcscreenmanage/curtain/curtain.cpp b/pcscreenmanage/curtain/curtain.cpp index e831c50..9fb5234 100644 --- a/pcscreenmanage/curtain/curtain.cpp +++ b/pcscreenmanage/curtain/curtain.cpp @@ -113,7 +113,9 @@ void Curtain::setTheme(PublicAttributes::Theme theme) void Curtain::showView() { - m_suspendTabBar1->hideTabBar(); + if (m_suspendTabBar1 != nullptr) { + m_suspendTabBar1->hideTabBar(); + } show(); showMaximized(); showFullScreen(); diff --git a/pcscreenmanage/pcscreenmanage.cpp b/pcscreenmanage/pcscreenmanage.cpp index 603cf67..06681bd 100644 --- a/pcscreenmanage/pcscreenmanage.cpp +++ b/pcscreenmanage/pcscreenmanage.cpp @@ -377,6 +377,8 @@ void PcScreenManage::slotTabBtnClicked(SuspendTabBar::BtnType type) exitControl(); if (m_suspendTabBar != nullptr) { m_suspendTabBar->hideTabBar(); + delete m_suspendTabBar; + m_suspendTabBar = nullptr; } } break; case SuspendTabBar::BtnType::ExitBtn: { From fc98d4abb989095a82ace209d581bee375de27a7 Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Tue, 18 Oct 2022 10:40:22 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=90=9E=20fix(UI=E6=A8=A1=E5=9D=97):?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E6=82=AC=E6=B5=AETab=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pcscreenmanage/suspendtabbar.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pcscreenmanage/suspendtabbar.cpp b/pcscreenmanage/suspendtabbar.cpp index 4b62a81..ebaaa67 100644 --- a/pcscreenmanage/suspendtabbar.cpp +++ b/pcscreenmanage/suspendtabbar.cpp @@ -24,17 +24,20 @@ SuspendTabBar::SuspendTabBar(SuspendTabBar::Display mode, bool isTool, QWidget * setAttribute(Qt::WA_TranslucentBackground, true); if (isTool) { setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); + m_openBtn = new OpenBtn(isTool, this); + connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); + m_openBtn->setFixedHeight(1); } else { setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + m_openBtn = new OpenBtn(isTool, parent); + connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); + m_openBtn->setFixedHeight(1); } if (mode == SuspendTabBar::Display::Whole) { initWholeUI(); } else { initPartUI(); } - m_openBtn = new OpenBtn(isTool, parent); - connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); - m_openBtn->setFixedHeight(1); initAnimation(); activateWindow(); setFocus(); @@ -46,7 +49,8 @@ SuspendTabBar::SuspendTabBar(SuspendTabBar::Display mode, bool isTool, QWidget * SuspendTabBar::~SuspendTabBar() { if (m_openBtn != nullptr) { - m_openBtn->deleteLater(); + qDebug() << "aaaaaaaaaaaaaaa"; + delete m_openBtn; m_openBtn = nullptr; } } From 93477324ecadb563f433c8fd41c86374df3e5250 Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Tue, 18 Oct 2022 16:29:21 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=90=9E=20fix(UI=E6=A8=A1=E5=9D=97):?= =?UTF-8?q?=20=E9=9A=90=E8=97=8F=E6=9C=80=E5=A4=A7=E5=8C=96=E6=8C=89?= =?UTF-8?q?=E9=92=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=8F=8C=E5=87=BB=E6=94=BE?= =?UTF-8?q?=E5=A4=A7=E7=BC=A9=E5=B0=8F=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 并且删除了一些无用代码 --- ui/mainwindow.cpp | 4 -- ui/view/titlebar.cpp | 138 +++++-------------------------------------- ui/view/titlebar.h | 25 +------- 3 files changed, 19 insertions(+), 148 deletions(-) diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 3846cf8..a4e8c94 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -354,9 +354,6 @@ void MainWindow::initUI() m_titlebar = new Titlebar(this); connect(m_titlebar, &Titlebar::sigAboutWinShow, this, &MainWindow::slotAboutWinShow); - connect(m_titlebar, &Titlebar::sigSearchResult, this, &MainWindow::onRecvSearchResult); - connect(m_titlebar, &Titlebar::sigSearchInitFail, this, &MainWindow::slotSearchInitFail); - connect(this, &MainWindow::sigClearSearchLine, m_titlebar, &Titlebar::onBackButtonClick); m_homepage = new HomePage; m_homepage->setDeviceCode(m_wifiIp); @@ -1219,7 +1216,6 @@ void MainWindow::initPcSearchInfo() // m_fileSyncManage->setSearchPath(FileSyncManage::SEARCH_TYPE::TYPE_PC, m_connectInfo.deviceName); // connect(m_fileSyncManage, SIGNAL(sigDownFileFail(QString, QString)), this, // SLOT(slotDownFileFail(QString, QString))); - // connect(m_fileSyncManage, &FileSyncManage::sigSearchInfoFinsh, m_titlebar, &Titlebar::onSearchInstalled); // connect(m_fileSyncManage, &FileSyncManage::sigTempFileDownFinish, this, &MainWindow::slotDownTempFileFinish); // m_fileSyncManage->downloadSearch(); } diff --git a/ui/view/titlebar.cpp b/ui/view/titlebar.cpp index d4ec1ec..4d9c65e 100644 --- a/ui/view/titlebar.cpp +++ b/ui/view/titlebar.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include Titlebar::Titlebar(QWidget *parent) : QWidget(parent) @@ -11,17 +13,7 @@ Titlebar::Titlebar(QWidget *parent) : QWidget(parent) connectInit(); } -Titlebar::~Titlebar() -{ - if (m_menu != nullptr) { - delete m_menu; - m_menu = nullptr; - } - if (m_searchServer != nullptr) { - delete m_searchServer; - m_searchServer = nullptr; - } -} +Titlebar::~Titlebar() {} void Titlebar::initUI() { @@ -38,14 +30,6 @@ void Titlebar::initUI() m_titleIcon->setIcon(QIcon::fromTheme("kylin-multi-collaboration")); m_titleIcon->setContentsMargins(8, 8, 8, 8); - m_searchLine = new kdk::KSearchLineEdit(this); - m_searchLine->setClearButtonEnabled(true); - m_searchLine->setPlaceholderText(tr("Search")); - m_searchLine->setFocusPolicy(Qt::ClickFocus); - m_searchLine->setContextMenuPolicy(Qt::DefaultContextMenu); - m_searchLine->hide(); - - m_searchLine->setFixedSize(230, 32); m_menuBtn = new QToolButton(this); m_menu = new QMenu(); m_menuBtn->setToolTip(tr("Menu")); @@ -94,8 +78,6 @@ void Titlebar::initUI() layout->addWidget(m_titleIcon); layout->addWidget(m_titleNameLab); layout->addStretch(); - layout->addWidget(m_searchLine); - layout->addStretch(); layout->addWidget(m_menuBtn); layout->addWidget(m_minBtn); layout->addWidget(m_maxBtn); @@ -104,6 +86,7 @@ void Titlebar::initUI() layout->setContentsMargins(0, 4, 0, 0); setLayout(layout); + m_maxBtn->hide(); } void Titlebar::hideButton() @@ -148,6 +131,17 @@ void Titlebar::setBackground(bool isDefault) } } +void Titlebar::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (window()->isMaximized()) { + window()->showNormal(); + m_maxBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic")); + } else { + window()->showMaximized(); + m_maxBtn->setIcon(QIcon::fromTheme("window-restore-symbolic")); + } +} + // 连接槽 void Titlebar::connectInit() { @@ -157,11 +151,6 @@ void Titlebar::connectInit() connect(m_closeBtn, &QPushButton::clicked, this, &Titlebar::onClicked); // 连接菜单信号槽 connect(m_menu, &QMenu::triggered, this, &Titlebar::triggerMenu); - connect(m_searchLine, &kdk::KSearchLineEdit::textChanged, this, &Titlebar::onTextChanged); - connect(m_searchLine, &kdk::KSearchLineEdit::returnPressed, this, &Titlebar::onReturnPressed); - connect(this, &Titlebar::sigSearchLineShow, this, [this]() { - // m_searchLine->show(); - }); } // 设置菜单按钮 @@ -236,99 +225,4 @@ void Titlebar::initHelp() msg << "kylin-mobile-assistant"; if (QDBusConnection::sessionBus().isConnected()) QDBusConnection::sessionBus().call(msg); -} - -void Titlebar::onTextChanged() -{ - if (!m_mutex.try_lock()) { - return; - } - if (m_searchServer == nullptr) { - qWarning() << "search server is not ready!"; - return; - } - m_query = m_searchLine->text().trimmed(); - m_mutex.unlock(); - if (m_query.isEmpty()) { - return; - } - - auto search = [this]() { - if (!m_mutex.try_lock()) { - return; - } - Q_EMIT sigStartSearch(); - m_resultMap.clear(); - m_searchServer->search(m_resultMap, m_query); - Q_EMIT sigSearchResult(m_resultMap); - m_mutex.unlock(); - }; - std::thread searchThread(search); - searchThread.detach(); -} - -void Titlebar::onReturnPressed() -{ - onTextChanged(); -} - -void Titlebar::onSearchInstalled(bool isUpdated, QString searchInfoPath) -{ - qInfo() << "searchInfo installed"; - - if (!m_mutex.try_lock()) { - return; - } - if (m_searchServer != nullptr) { - m_searchLine->clear(); - delete m_searchServer; - m_searchServer = nullptr; - } - m_searchServer = new SearchServer(); - m_searchServer->setSearchDbPath(searchInfoPath); - if (m_searchServer) { - if (m_searchServer->init() < 0) { - qWarning() << "load search server fail"; - Q_EMIT sigSearchInitFail(); - return; - } - } - m_mutex.unlock(); - - if (!isUpdated) { - qInfo() << "use old searchInfo"; - Q_EMIT sigSearchLineShow(); - } else { - if (m_searchServer) { - qInfo() << "use new searchInfo"; - auto searchInit = [this]() { - m_mutex.lock(); - if (m_searchServer->createIndex() >= 0) { - Q_EMIT sigSearchLineShow(); - } else { - qWarning() << "search server init fail"; - Q_EMIT sigSearchInitFail(); - } - m_mutex.unlock(); - }; - std::thread searchInitThread(searchInit); - searchInitThread.detach(); - } - } -} - -void Titlebar::hideSearchLine() -{ - qInfo() << "searchLine hide"; - m_searchLine->hide(); - m_searchLine->clear(); - if (m_searchServer != nullptr) { - delete m_searchServer; - m_searchServer = nullptr; - } -} - -void Titlebar::onBackButtonClick() -{ - m_searchLine->clear(); -} +} \ No newline at end of file diff --git a/ui/view/titlebar.h b/ui/view/titlebar.h index c374daa..c3bf4aa 100644 --- a/ui/view/titlebar.h +++ b/ui/view/titlebar.h @@ -13,11 +13,7 @@ #include #include #include -#include #include - -#include "searchserver.h" -#include "fileinfo.h" #include "publicattributes.hpp" class Titlebar : public QWidget @@ -27,27 +23,18 @@ public: Titlebar(QWidget *parent = nullptr); ~Titlebar(); void hideButton(); - void hideSearchLine(); void initHelp(); // 设置帮助Action void setTheme(PublicAttributes::Theme theme); void setBackground(bool isDefault = true); +protected: + void mouseDoubleClickEvent(QMouseEvent *event); + Q_SIGNALS: void sigAboutWinShow(); - void sigSearchResult(const QMap &searchResult); - void sigSearchLineShow(); - void sigSearchInitFail(); - void sigStartSearch(); - public Q_SLOTS: void onClicked(void); void triggerMenu(QAction *); - void onSearchInstalled(bool isUpdated, QString searchInfoPath); - void onBackButtonClick(); - -private Q_SLOTS: - void onTextChanged(); - void onReturnPressed(); private: void initUI(); @@ -58,7 +45,6 @@ private: private: QPushButton *m_titleIcon = nullptr; QLabel *m_titleNameLab = nullptr; - kdk::KSearchLineEdit *m_searchLine = nullptr; QToolButton *m_menuBtn = nullptr; // 菜单按钮 QMenu *m_menu = nullptr; // 菜单 QList m_actions; // action组 @@ -67,11 +53,6 @@ private: QPushButton *m_closeBtn = nullptr; // 关闭按钮 PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light; // 主题 bool m_isDefault = true; - - SearchServer *m_searchServer = nullptr; - QString m_query = ""; - QMap m_resultMap; - QMutex m_mutex; }; #endif // TITLEBAR_H From ec6b53cdcd4b96262628d7ca57246cdd8472b986 Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Wed, 19 Oct 2022 16:44:22 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=90=9E=20fix(UI=E6=A8=A1=E5=9D=97):?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E6=96=87=E7=AE=A1=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E4=B8=BA=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index a4e8c94..4edc5f5 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -959,7 +959,7 @@ void MainWindow::slotMountError(bool isMount, QString error) { qInfo() << "mountFtpError:" << error; if (isMount) { - QMessageBox::warning(this, tr("Warning"), tr("Peony access can be error-prone"), QMessageBox::Ok); + setToolTipWin(tr("Peony access can be error-prone"), kdk::TipType::Warning); } else { setToolTipWin(tr("Umount failed"), kdk::TipType::Warning); } From 9d5db32bcdaadb3ab17aa2279e88fd10737b022e Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Wed, 19 Oct 2022 16:45:42 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=90=9E=20fix(UI=E6=A8=A1=E5=9D=97):?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E6=8A=95=E5=B1=8F=E5=8F=8D=E6=8E=A7?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主要调整投屏幕布的显示隐藏以及悬浮tab的显示隐藏 --- pcscreenmanage/curtain/curtain.cpp | 8 +++++- pcscreenmanage/curtain/curtain.h | 1 - pcscreenmanage/pcscreen/pcscreen.cpp | 12 ++++---- pcscreenmanage/pcscreenmanage.cpp | 42 +++++++++++++++++++++++++--- pcscreenmanage/pcscreenmanage.h | 4 +++ pcscreenmanage/suspendtabbar.cpp | 13 ++------- 6 files changed, 58 insertions(+), 22 deletions(-) diff --git a/pcscreenmanage/curtain/curtain.cpp b/pcscreenmanage/curtain/curtain.cpp index 9fb5234..8805073 100644 --- a/pcscreenmanage/curtain/curtain.cpp +++ b/pcscreenmanage/curtain/curtain.cpp @@ -100,7 +100,9 @@ Curtain::Curtain(QWidget *parent) : QWidget(parent), m_view(new QWebEngineView(t Curtain::~Curtain() { - delete m_suspendTabBar1; + if (m_suspendTabBar1 != nullptr) { + delete m_suspendTabBar1; + } } void Curtain::setTheme(PublicAttributes::Theme theme) @@ -109,6 +111,9 @@ void Curtain::setTheme(PublicAttributes::Theme theme) if (m_suspendTabBar) { m_suspendTabBar->setTheme(m_theme); } + if (m_suspendTabBar1 != nullptr) { + m_suspendTabBar1->setTheme(m_theme); + } } void Curtain::showView() @@ -192,6 +197,7 @@ void Curtain::slotTabBtnClicked(SuspendTabBar::BtnType type) Q_EMIT sigStateChange(Curtain::States::ScreenShare); } break; case SuspendTabBar::BtnType::ExitBtn: { + hideView(); Q_EMIT sigStateChange(Curtain::States::Exit); } break; } diff --git a/pcscreenmanage/curtain/curtain.h b/pcscreenmanage/curtain/curtain.h index e663d99..14c1c15 100644 --- a/pcscreenmanage/curtain/curtain.h +++ b/pcscreenmanage/curtain/curtain.h @@ -83,7 +83,6 @@ public: protected: void resizeEvent(QResizeEvent *event) override; - // bool eventFilter(QObject *obj, QEvent *event) override; public: void loadUrl(QString &url); diff --git a/pcscreenmanage/pcscreen/pcscreen.cpp b/pcscreenmanage/pcscreen/pcscreen.cpp index 58457e6..3a758ad 100644 --- a/pcscreenmanage/pcscreen/pcscreen.cpp +++ b/pcscreenmanage/pcscreen/pcscreen.cpp @@ -32,12 +32,12 @@ void PCScreen::startService() QThread::msleep(8000); Q_EMIT sigStartedScreen(m_roomid); }); - // connect(m_process, &QProcess::errorOccurred, [&](QProcess::ProcessError error) { - // if (!isNormalExit) { - // qInfo() << "Screen projection service error:" << error; - // Q_EMIT sigStartError(); - // } - // }); + connect(m_process, &QProcess::errorOccurred, [&](QProcess::ProcessError error) { + if (!isNormalExit) { + qInfo() << "Screen projection service error:" << error; + Q_EMIT sigStartError(); + } + }); getRoomId(); m_process->start(COMMON, QStringList() << m_roomid); } else { diff --git a/pcscreenmanage/pcscreenmanage.cpp b/pcscreenmanage/pcscreenmanage.cpp index 06681bd..e36a4d9 100644 --- a/pcscreenmanage/pcscreenmanage.cpp +++ b/pcscreenmanage/pcscreenmanage.cpp @@ -4,6 +4,10 @@ #include #include +// #define KYLIN_CONNECTIVITY_TOOLS_PATH "/" +// #define KYLIN_CONNECTIVITY_TOOLS_SERVICE "com.kylinos.connectivity.tools" +// #define KYLIN_CONNECTIVITY_TOOLS_INTERFACE "com.kylinos.connectivity.tools" + const int LISTEN_PORT = 27192; QString LOAD_URL = "http://%1:27190/%2"; @@ -115,6 +119,11 @@ void PcScreenManage::startPcService() void PcScreenManage::startCurtain(QString roomid) { + // 服务端 + // m_dbusInterface = new QDBusInterface(KYLIN_CONNECTIVITY_TOOLS_SERVICE, KYLIN_CONNECTIVITY_TOOLS_PATH, + // KYLIN_CONNECTIVITY_TOOLS_INTERFACE, QDBusConnection::sessionBus()); + // QObject::connect(m_dbusInterface, SIGNAL(enterClient(bool)), this, SLOT(slotEnterControl(bool))); + if (m_curtain == nullptr) { m_curtain = new Curtain; connect(m_curtain, &Curtain::sigStateChange, this, &PcScreenManage::slotStateChange); @@ -202,6 +211,11 @@ void PcScreenManage::closePcScreenService() void PcScreenManage::closeCurtain() { qInfo() << "Closing curtain..."; + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->hideTabBar(); + delete m_suspendTabBar; + m_suspendTabBar = nullptr; + } if (m_curtain != nullptr) { ScreenManageMsg message; message.set_msg(ScreenManageMsg::CURTAINEXIT); @@ -301,9 +315,17 @@ void PcScreenManage::onMessageReadyRead() } break; case ScreenManageMsg::EXITCONTROL: { qInfo() << "Exit anti control."; - QString common = "xdotool key ctrl+g"; - system(common.toUtf8().constData()); - m_curtain->showTabBar(); + if (m_isService) { + QString common = "xdotool key ctrl+g"; + system(common.toUtf8().constData()); + m_curtain->showTabBar(); + } else { + if (m_suspendTabBar != nullptr) { + m_suspendTabBar->hideTabBar(); + delete m_suspendTabBar; + m_suspendTabBar = nullptr; + } + } } break; } } @@ -363,8 +385,8 @@ void PcScreenManage::slotStateChange(Curtain::States state) Q_EMIT sigRequestReceived(ScreenMsg::ShowView); } break; case Curtain::States::Exit: { - Q_EMIT sigRequestReceived(ScreenMsg::ScreenExit); disconnected(); + Q_EMIT sigRequestReceived(ScreenMsg::HideView); } break; } } @@ -392,6 +414,18 @@ void PcScreenManage::slotTabBtnClicked(SuspendTabBar::BtnType type) } } +// void PcScreenManage::slotEnterControl(bool isControl) +// { +// qInfo() << "Receive anti control message, current status: " << isControl; +// if (isControl) { +// m_curtain->showView(); +// m_curtain->hideTabBar(); +// startedControl(); +// } else { +// exitControl(); +// } +// } + int PcScreenManage::sendMessage(const ScreenManageMsg &message) { if (m_messageTcpSocket == nullptr) { diff --git a/pcscreenmanage/pcscreenmanage.h b/pcscreenmanage/pcscreenmanage.h index 5405b70..6ae3a66 100644 --- a/pcscreenmanage/pcscreenmanage.h +++ b/pcscreenmanage/pcscreenmanage.h @@ -6,6 +6,8 @@ #include #include #include +//#include +//#include #include "screenmanagemsg.pb.h" #include "pcscreen.h" #include "curtain.h" @@ -76,6 +78,7 @@ private Q_SLOTS: void slotSocketDisconnect(); void slotStateChange(Curtain::States state); void slotTabBtnClicked(SuspendTabBar::BtnType type); + // void slotEnterControl(bool isControl); private: QTcpServer *m_tcpServer = nullptr; // Tcp服务 @@ -85,6 +88,7 @@ private: Curtain *m_curtain = nullptr; // 投屏幕布 Control *m_control = nullptr; // 反控 SuspendTabBar *m_suspendTabBar = nullptr; + // QDBusInterface *m_dbusInterface = nullptr; // 反控dbus QString m_address = ""; // 客服端ip qint64 m_dataSize = 0; // 接收的数据大小 diff --git a/pcscreenmanage/suspendtabbar.cpp b/pcscreenmanage/suspendtabbar.cpp index ebaaa67..210fb01 100644 --- a/pcscreenmanage/suspendtabbar.cpp +++ b/pcscreenmanage/suspendtabbar.cpp @@ -24,15 +24,12 @@ SuspendTabBar::SuspendTabBar(SuspendTabBar::Display mode, bool isTool, QWidget * setAttribute(Qt::WA_TranslucentBackground, true); if (isTool) { setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); - m_openBtn = new OpenBtn(isTool, this); - connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); - m_openBtn->setFixedHeight(1); } else { setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - m_openBtn = new OpenBtn(isTool, parent); - connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); - m_openBtn->setFixedHeight(1); } + m_openBtn = new OpenBtn(isTool, parent); + connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); + m_openBtn->setFixedHeight(1); if (mode == SuspendTabBar::Display::Whole) { initWholeUI(); } else { @@ -49,7 +46,6 @@ SuspendTabBar::SuspendTabBar(SuspendTabBar::Display mode, bool isTool, QWidget * SuspendTabBar::~SuspendTabBar() { if (m_openBtn != nullptr) { - qDebug() << "aaaaaaaaaaaaaaa"; delete m_openBtn; m_openBtn = nullptr; } @@ -197,11 +193,8 @@ void SuspendTabBar::initPartUI() setFixedSize(WINTWO_W, WINTWO_H); m_controlBtn = new kdk::KToolButton(this); m_exitBtn = new QPushButton(this); - m_openBtn = new OpenBtn; - m_openBtn->show(); connect(m_controlBtn, &kdk::KToolButton::clicked, this, &SuspendTabBar::onClicked); - connect(m_openBtn, &OpenBtn::sigClicked, this, &SuspendTabBar::onOpenClicked); connect(m_exitBtn, &QPushButton::clicked, this, &SuspendTabBar::onExitClicked); m_controlBtn->setType(kdk::KToolButtonType::Flat); From 733ea1ae3abb0eb5b1472715aabd55707002b61b Mon Sep 17 00:00:00 2001 From: "liujialin@kylinos.cn" Date: Wed, 19 Oct 2022 17:23:45 +0800 Subject: [PATCH 7/9] =?UTF-8?q?feat(UI=E6=A8=A1=E5=9D=97):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=89=8D=E8=BF=9B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/mainwindow.cpp | 11 +++++++ ui/mainwindow.h | 1 + ui/storagelist/mobilestoragewidget.cpp | 45 ++++++++++++++++++-------- ui/storagelist/mobilestoragewidget.h | 2 ++ 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 361e666..6f7033c 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -1802,5 +1802,16 @@ void MainWindow::connectMobileStorage() connect(m_mobileStorageWidget, &MobileStorageWidget::sigSearchResult, this, &MainWindow::onRecvSearchResult); connect(m_mobileStorageWidget, &MobileStorageWidget::sigSearchInitFail, this, &MainWindow::slotSearchInitFail); connect(this, &MainWindow::sigSearchUpdate, m_mobileStorageWidget, &MobileStorageWidget::onReturnPressed); + connect(m_mobileStorageWidget, &MobileStorageWidget::sigForwardButtonEnabled, this, [=](QString indexPath) { + m_saveListPath << indexPath; + }); + + connect(m_mobileStorageWidget, &MobileStorageWidget::sigForwardButtonClicked, this, [=]() { + if (m_saveListPath.size() > 0) { + QString lastPath = m_saveListPath.last(); + slotCdMobileStorageDirectory(lastPath); + m_saveListPath.removeLast(); + } + }); m_mobileStorageWidget->setMode(m_storageMode); } diff --git a/ui/mainwindow.h b/ui/mainwindow.h index e06cb38..0b17076 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -201,6 +201,7 @@ private: bool m_isUpdated; QString m_searchInfoPath; QString m_searchKeyword; + QStringList m_saveListPath; Q_SIGNALS: // 提供dbus服务 void sigConnected(QString); diff --git a/ui/storagelist/mobilestoragewidget.cpp b/ui/storagelist/mobilestoragewidget.cpp index f6cb04e..36e7244 100644 --- a/ui/storagelist/mobilestoragewidget.cpp +++ b/ui/storagelist/mobilestoragewidget.cpp @@ -76,11 +76,11 @@ void MobileStorageWidget::initUI() retreatButton->setFlat(true); retreatButton->setCursor(Qt::PointingHandCursor); - // QPushButton *forwardButton = new QPushButton(this); - // forwardButton->setIcon(QIcon::fromTheme("go-next-symbolic")); - // forwardButton->setFixedSize(16, 16); - // forwardButton->setFlat(true); - // forwardButton->setCursor(Qt::PointingHandCursor); + QPushButton *forwardButton = new QPushButton(this); + forwardButton->setIcon(QIcon::fromTheme("go-next-symbolic")); + forwardButton->setFixedSize(16, 16); + forwardButton->setFlat(true); + forwardButton->setCursor(Qt::PointingHandCursor); QFont font; font.setBold(true); @@ -143,7 +143,7 @@ void MobileStorageWidget::initUI() refreshButton->setFlat(true); fileListHLayout->addWidget(retreatButton); - // fileListHLayout->addWidget(forwardButton); + fileListHLayout->addWidget(forwardButton); // fileListHLayout->addSpacing(28); fileListHLayout->addWidget(crumb); fileListHLayout->addStretch(); @@ -195,12 +195,22 @@ void MobileStorageWidget::initUI() this->setBackgroundRole(QPalette::Base); connect(retreatButton, &QPushButton::clicked, this, [=]() { + QString indexPath; + for (int i = 2; i < crumb->currentIndex() + 1; i++) { + indexPath += "/" + crumb->tabText(i); + } + Q_EMIT sigForwardButtonEnabled(indexPath); + int currentIndex = crumb->currentIndex(); if (currentIndex > 0) { crumb->setCurrentIndex(currentIndex - 1); } }); + connect(forwardButton, &QPushButton::clicked, this, [=]() { + Q_EMIT sigForwardButtonClicked(); + }); + connect(refreshButton, &QPushButton::clicked, this, [=]() { for (int i = 2; i < crumb->currentIndex() + 1; i++) { m_currentIndexPath += "/" + crumb->tabText(i); @@ -250,7 +260,6 @@ void MobileStorageWidget::initUI() } slotHideCopyToComputerWidget(); - //当前索引路径 刷新界面 Q_EMIT sigCurrentIndexPath(m_currentIndexPath); } @@ -279,11 +288,11 @@ void MobileStorageWidget::initPcUI() retreatButton->setFlat(true); retreatButton->setCursor(Qt::PointingHandCursor); - // QPushButton *forwardButton = new QPushButton(this); - // forwardButton->setIcon(QIcon::fromTheme("go-next-symbolic")); - // forwardButton->setFixedSize(16, 16); - // forwardButton->setFlat(true); - // forwardButton->setCursor(Qt::PointingHandCursor); + QPushButton *forwardButton = new QPushButton(this); + forwardButton->setIcon(QIcon::fromTheme("go-next-symbolic")); + forwardButton->setFixedSize(16, 16); + forwardButton->setFlat(true); + forwardButton->setCursor(Qt::PointingHandCursor); QFont font; font.setBold(true); @@ -339,7 +348,7 @@ void MobileStorageWidget::initPcUI() fileListHLayout->addWidget(retreatButton); fileListHLayout->addSpacing(20); - // fileListHLayout->addWidget(forwardButton); + fileListHLayout->addWidget(forwardButton); // fileListHLayout->addSpacing(28); fileListHLayout->addWidget(crumb); fileListHLayout->addStretch(); @@ -387,12 +396,22 @@ void MobileStorageWidget::initPcUI() this->setBackgroundRole(QPalette::Base); connect(retreatButton, &QPushButton::clicked, this, [=]() { + QString indexPath; + for (int i = 1; i < crumb->currentIndex() + 1; i++) { + indexPath += "/" + crumb->tabText(i); + } + Q_EMIT sigForwardButtonEnabled(indexPath); + int currentIndex = crumb->currentIndex(); if (currentIndex > 0) { crumb->setCurrentIndex(currentIndex - 1); } }); + connect(forwardButton, &QPushButton::clicked, this, [=]() { + Q_EMIT sigForwardButtonClicked(); + }); + connect(refreshButton, &QPushButton::clicked, this, [=]() { for (int i = 2; i < crumb->currentIndex() + 1; i++) { m_currentIndexPath += "/" + crumb->tabText(i); diff --git a/ui/storagelist/mobilestoragewidget.h b/ui/storagelist/mobilestoragewidget.h index 1416d8f..05b5104 100644 --- a/ui/storagelist/mobilestoragewidget.h +++ b/ui/storagelist/mobilestoragewidget.h @@ -64,6 +64,8 @@ Q_SIGNALS: void sigSearchInitFail(); void sigSearchInstalled(bool isUpdated, QString searchInfoPath); void sigSearchKeyword(QString query); + void sigForwardButtonEnabled(QString indexPath); + void sigForwardButtonClicked(); private: MobileStorageViewWidget *m_mobileStorageViewWidget = nullptr; From 392acd2775211880cd9bd957bae0b7d50a665966 Mon Sep 17 00:00:00 2001 From: "liujialin@kylinos.cn" Date: Wed, 19 Oct 2022 19:11:25 +0800 Subject: [PATCH 8/9] =?UTF-8?q?fix(UI=E6=A8=A1=E5=9D=97):=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3PC=E4=B8=8EPC=E7=82=B9=E5=87=BB=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=9D=A2=E5=8C=85=E5=B1=91=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/storagelist/mobilestoragewidget.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/storagelist/mobilestoragewidget.cpp b/ui/storagelist/mobilestoragewidget.cpp index 36e7244..9b40544 100644 --- a/ui/storagelist/mobilestoragewidget.cpp +++ b/ui/storagelist/mobilestoragewidget.cpp @@ -397,7 +397,7 @@ void MobileStorageWidget::initPcUI() connect(retreatButton, &QPushButton::clicked, this, [=]() { QString indexPath; - for (int i = 1; i < crumb->currentIndex() + 1; i++) { + for (int i = 0; i < crumb->currentIndex() + 1; i++) { indexPath += "/" + crumb->tabText(i); } Q_EMIT sigForwardButtonEnabled(indexPath); @@ -413,9 +413,10 @@ void MobileStorageWidget::initPcUI() }); connect(refreshButton, &QPushButton::clicked, this, [=]() { - for (int i = 2; i < crumb->currentIndex() + 1; i++) { - m_currentIndexPath += "/" + crumb->tabText(i); + for (int i = 0; i < crumb->currentIndex() + 1; i++) { + m_currentIndexPath += crumb->tabText(i); } + Q_EMIT sigUpdateClicked(m_currentIndexPath); }); From 48855369022caee94e848afcd65413c3c73076e4 Mon Sep 17 00:00:00 2001 From: "liujialin@kylinos.cn" Date: Wed, 19 Oct 2022 19:21:34 +0800 Subject: [PATCH 9/9] =?UTF-8?q?fix(UI=E6=A8=A1=E5=9D=97):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0PC=E4=B8=8EPC=E6=90=9C=E7=B4=A2=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/mainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index ff3d2ee..f4a6c3f 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -927,6 +927,8 @@ void MainWindow::slotDownTempFileFinish(QString filePath) stopLoadUI(); if (m_isPcSearchInfo) { m_isPcSearchInfo = false; + m_isUpdated = true; + m_searchInfoPath = filePath; } else if (!filePath.isEmpty()) { FileInfo::fileOpen(filePath); } else {