From 321731442e71f014df8e49c2b87159adcb815c35 Mon Sep 17 00:00:00 2001 From: jiangdingyuan Date: Thu, 13 Oct 2022 11:28:53 +0800 Subject: [PATCH] build(package): 1.3.1 --- .gitattributes | 3 + .gitignore | 143 ++++++++++++++++++ common/horizontalorverticalmode.cpp | 65 ++++++++ common/horizontalorverticalmode.h | 35 +++++ common/singleton.h | 18 +++ common/ukui_settings_monitor.cpp | 61 ++++++++ common/ukui_settings_monitor.h | 51 +++++++ test/test_aptUtilHelper/CMakeLists.txt | 24 ++- test/test_aptUtilHelper/main.cpp | 44 +++++- test/test_networkdevicebrowse/main.cpp | 4 +- test/test_remote/remoteWidget.cpp | 2 +- test/test_remote/remoteWidget.h | 4 +- .../custom_ui/custom_combo_box/CMakeLists.txt | 45 ++++++ test/ui/custom_ui/custom_combo_box/main.cpp | 26 ++++ ui/custom_ui/custom_message_box.cpp | 1 + ui/main_win_ui/left_widget.cpp | 1 - ui/mainwindow.cpp | 53 ++++++- ui/mainwindow.h | 14 +- ui/rename_printer_dialog.cpp | 1 + 19 files changed, 571 insertions(+), 24 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100755 common/horizontalorverticalmode.cpp create mode 100755 common/horizontalorverticalmode.h create mode 100644 common/singleton.h create mode 100644 common/ukui_settings_monitor.cpp create mode 100644 common/ukui_settings_monitor.h create mode 100644 test/ui/custom_ui/custom_combo_box/CMakeLists.txt create mode 100644 test/ui/custom_ui/custom_combo_box/main.cpp diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..44b50b6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +debian/changelog merge=ours +debian/compat merge=ours +debian/source/format merge=ours diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a81cd13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,143 @@ +# ---> C +# Object files +*.o +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ + +# ---> C++ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# ---> CMake +CMakeList.txt.user* +CMakeCache.txt +CMakeFiles +CMakeScripts +Makefile +cmake_install.cmake +install_manifest.txt + +# ---> Qt +# C++ objects and libs + +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# Qt-es + +/.qmake.cache +/.qmake.stash +/.qt_for_python +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +qrc_*.cpp +ui_*.h +Makefile* +*-build-* +*.qm + +# QtCreator + +*.autosave + +#QtCtreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# ---> VisualStudioCode +.settings + +build/ + +.vscode + +run + +# debian +/debian/files + +# global +/GPATH +/GRTAGS +/GTAGS + +# build +/obj-* +/debian/.debhelper +/debian/kylin-printer +/debian/kylin-printer.debhelper.log +/debian/kylin-printer.substvars + +/.pc + +#nodejs +/node_modules +/.husky +/package.json +/package-lock.json +/.idea \ No newline at end of file diff --git a/common/horizontalorverticalmode.cpp b/common/horizontalorverticalmode.cpp new file mode 100755 index 0000000..1c334ce --- /dev/null +++ b/common/horizontalorverticalmode.cpp @@ -0,0 +1,65 @@ +#include "horizontalorverticalmode.h" + +static const QString KYLIN_ROTATION_PATH = "/"; + +static const QString KYLIN_ROTATION_SERVICE = "com.kylin.statusmanager.interface"; + +static const QString KYLIN_ROTATION_INTERFACE = "com.kylin.statusmanager.interface"; + +HorizontalOrVerticalMode::HorizontalOrVerticalMode() +{ + QDBusConnection::sessionBus().connect(KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH, KYLIN_ROTATION_INTERFACE, + QString("rotations_change_signal"), this, SLOT(rotationChanged(QString))); + QDBusConnection::sessionBus().connect(KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH, KYLIN_ROTATION_INTERFACE, + QString("mode_change_signal"), this, SLOT(modeChanged(bool))); +} +deviceMode HorizontalOrVerticalMode::defaultModeCapture() +{ // method + QDBusMessage message_pcORpad = QDBusMessage::createMethodCall( + KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH, KYLIN_ROTATION_INTERFACE, QString("get_current_tabletmode")); + QDBusPendingReply reply_pcORpad = QDBusConnection::sessionBus().call(message_pcORpad); + if (!reply_pcORpad.isValid()) { + return PCMode; + } + if (reply_pcORpad.value()) { //平板模式 + QDBusMessage message = QDBusMessage::createMethodCall( + KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH, KYLIN_ROTATION_INTERFACE, QString("get_current_rotation")); + QDBusPendingReply reply = QDBusConnection::sessionBus().call(message); + if (reply.value() == "normal" || reply.value() == "upside-down") { + return PADHorizontalMode; //横屏 + } else { + return PADVerticalMode; //竖屏 + } + return PADHorizontalMode; //横屏 + + } else { + return PCMode; // pc模式 + } + return PCMode; // pc模式 +} + +void HorizontalOrVerticalMode::rotationChanged(QString res) +{ // signal + if (res == QString::fromLocal8Bit("normal") || res == QString::fromLocal8Bit("upside-down")) { + Q_EMIT RotationSig(PADHorizontalMode); //平板横屏 + } else { + Q_EMIT RotationSig(PADVerticalMode); //平板竖屏 + } +} +void HorizontalOrVerticalMode::modeChanged(bool res) +{ + if (res) { + QDBusMessage message = QDBusMessage::createMethodCall( + KYLIN_ROTATION_SERVICE, KYLIN_ROTATION_PATH, KYLIN_ROTATION_INTERFACE, QString("get_current_rotation")); + QDBusPendingReply reply = QDBusConnection::sessionBus().call(message); + if (reply.value() == "normal" || reply.value() == "upside-down") { + Q_EMIT RotationSig(PADHorizontalMode); //平板横屏 + + } else { + Q_EMIT RotationSig(PADVerticalMode); //平板竖屏 + } + } else { + Q_EMIT RotationSig(PCMode); // pc模式 + } + Q_EMIT RotationSig(PCMode); // pc模式 +} diff --git a/common/horizontalorverticalmode.h b/common/horizontalorverticalmode.h new file mode 100755 index 0000000..25f1abc --- /dev/null +++ b/common/horizontalorverticalmode.h @@ -0,0 +1,35 @@ +#ifndef HORIZONTALORVERTICALMODE_H +#define HORIZONTALORVERTICALMODE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum deviceMode { + PADHorizontalMode = 1, //平板横屏 + PADVerticalMode = 2, //平板竖屏 + PCMode = 3 // pc模式 +}; + +class HorizontalOrVerticalMode : public QObject +{ + Q_OBJECT +public: + HorizontalOrVerticalMode(); + deviceMode defaultModeCapture(); +Q_SIGNALS: + void RotationSig(deviceMode); // true:horizontal;false:vertical +private Q_SLOTS: + void rotationChanged(QString res); + void modeChanged(bool res); +}; + + +#endif // HORIZONTALORVERTICALMODE_H diff --git a/common/singleton.h b/common/singleton.h new file mode 100644 index 0000000..90a6fdc --- /dev/null +++ b/common/singleton.h @@ -0,0 +1,18 @@ +#pragma once + +template +class Singleton { +public: + static T& instance() { + static T instance; + return instance; + } + +protected: + Singleton() {} + virtual ~Singleton() {} + +private: + Singleton(const Singleton&) = delete; + Singleton& operator= (const Singleton) = delete; +}; diff --git a/common/ukui_settings_monitor.cpp b/common/ukui_settings_monitor.cpp new file mode 100644 index 0000000..a03e14b --- /dev/null +++ b/common/ukui_settings_monitor.cpp @@ -0,0 +1,61 @@ +//#include "gsettings_monitor.h" +#include "horizontalorverticalmode.h" +#include "ukui_settings_monitor.h" +#include "QTimer" +UkuiSettingsMonitor::UkuiSettingsMonitor() +{ +// d_ptrGsetting = new GsettingsMonitor(); + d_ptrDbus = new HorizontalOrVerticalMode(); + +// connect(d_ptrGsetting, &GsettingsMonitor::transparencyUpdate, this, &UkuiSettingsMonitor::transparencyUpdate); +// connect(d_ptrGsetting, &GsettingsMonitor::styleStatusUpdate, this, [=](GsettingsMonitor::StyleStatus status){ +// emit styleStatusUpdate(StyleStatus(status)); +// }); + connect(d_ptrDbus, &HorizontalOrVerticalMode::RotationSig, this, [=](deviceMode mode){ + emit tabletModeUpdate(TabletStatus(mode)); + }); + +} + +UkuiSettingsMonitor::~UkuiSettingsMonitor() +{ +// delete d_ptrGsetting; + delete d_ptrDbus; +} + +//int UkuiSettingsMonitor::transparency() const +//{ +// return d_ptrGsetting->transparency(); +//} + +//UkuiSettingsMonitor::StyleStatus UkuiSettingsMonitor::styleStatus() const +//{ +// return StyleStatus(d_ptrGsetting->styleStatus()); +//} + +UkuiSettingsMonitor::TabletStatus UkuiSettingsMonitor::tabletMode() const +{ + return TabletStatus(d_ptrDbus->defaultModeCapture()); +} + +void UkuiSettingsMonitor::startTest(TabletStatus status) +{ + static int cnt = 0; + QTimer *timer = new QTimer(); + connect(timer, &QTimer::timeout, [=](){ + if (status != None) { + emit this->tabletModeUpdate(status); + return ; + } + cnt++; + + if (cnt % 2 == 0) { + emit this->tabletModeUpdate(TabletStatus::PCMode); + } else { + emit this->tabletModeUpdate(TabletStatus::PADHorizontalMode); + } + }); + timer->start(1000); + +} + diff --git a/common/ukui_settings_monitor.h b/common/ukui_settings_monitor.h new file mode 100644 index 0000000..d693ed6 --- /dev/null +++ b/common/ukui_settings_monitor.h @@ -0,0 +1,51 @@ +#ifndef UKUI_SETTINGS_MONITOR_H +#define UKUI_SETTINGS_MONITOR_H + +#include +#include "singleton.h" + +//class GsettingsMonitor; +class HorizontalOrVerticalMode; + +class UkuiSettingsMonitor final : public QObject, + public Singleton +{ + Q_OBJECT + friend class Singleton; +private: + UkuiSettingsMonitor(); + ~UkuiSettingsMonitor() override; +public: + enum TabletStatus { + None = 0, + PADHorizontalMode = 1, //平板横屏 + PADVerticalMode = 2, //平板竖屏 + PCMode = 3 // pc模式 + }; + + enum StyleStatus{ + NONE = 0, + LIGHT, + DARK + }; + + + void startTest(TabletStatus status = None); +// int transparency() const; +// StyleStatus styleStatus() const; + TabletStatus tabletMode() const; + +signals: +// void transparencyUpdate(int transparency); +// void styleStatusUpdate(StyleStatus styleStatus); + void tabletModeUpdate(TabletStatus tabletMode); + +private: +// GsettingsMonitor *d_ptrGsetting{nullptr}; + HorizontalOrVerticalMode *d_ptrDbus{nullptr}; +}; + + + + +#endif // UKUI_SETTINGS_MONITOR_H \ No newline at end of file diff --git a/test/test_aptUtilHelper/CMakeLists.txt b/test/test_aptUtilHelper/CMakeLists.txt index 2ca9792..06ed7c4 100644 --- a/test/test_aptUtilHelper/CMakeLists.txt +++ b/test/test_aptUtilHelper/CMakeLists.txt @@ -30,7 +30,9 @@ find_package(KF5WindowSystem REQUIRED) #Gsetting find_package(PkgConfig REQUIRED) pkg_check_modules(QGSETTINGS REQUIRED IMPORTED_TARGET gsettings-qt) - +pkg_check_modules(KYSDKQTWIDGETS_PKG kysdk-qtwidgets) +pkg_check_modules(KYSDKKABASE_PKG kysdk-kabase) +pkg_check_modules(KYSDKQTWIDGETS_PKG kysdk-qtwidgets) set (SOURCE_PATH ../..) # add ukui log @@ -38,9 +40,9 @@ file(GLOB_RECURSE UKUI_LOG4QT "/usr/lib/libukui-log4qt.so") #add include include_directories(${SOURCE_PATH}/printer_manager/) +include_directories(${SOURCE_PATH}/device_manager/) include_directories(${SOURCE_PATH}/common/) include_directories(${SOURCE_PATH}/util/) -include_directories(${SOURCE_PATH}/backend/) include_directories(${SOURCE_PATH}/ui/) add_definitions("-Wall") @@ -48,10 +50,12 @@ add_definitions("-Wall") file(GLOB ${PROJECT_NAME}_SRC "main.cpp" - "${SOURCE_PATH}/ui/gse*" - "${SOURCE_PATH}/printer_manager/deviceInfo*" - "${SOURCE_PATH}/printer_manager/ukuiApt*" + "${SOURCE_PATH}/device_manager/device_information.*" + "${SOURCE_PATH}/printer_manager/ukui_apt*" "${SOURCE_PATH}/common/common*" + "${SOURCE_PATH}/common/global_variable.h" + "${SOURCE_PATH}/ui/gsettings_monitor.*" + "${SOURCE_PATH}/util/information_collector.*" ) # SET(ui_RESOURCE ${SOURCE_PATH}/ui/picture.qrc) @@ -72,6 +76,16 @@ add_executable(${PROJECT_NAME} # ${QM_FILES} ) +target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_INCLUDE_DIRS}) +target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_LIBRARY_DIRS}) +target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${KYSDKQTWIDGETS_PKG_LIBRARIES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKKABASE_PKG_INCLUDE_DIRS}) +target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKKABASE_PKG_LIBRARY_DIRS}) +target_link_libraries(${PROJECT_NAME} ${KYSDKKABASE_PKG_LIBRARIES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_INCLUDE_DIRS}) +target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKQTWIDGETS_PKG_LIBRARY_DIRS}) +target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${KYSDKQTWIDGETS_PKG_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} ${UKUI_LOG4QT}) target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::X11Extras Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::DBus) diff --git a/test/test_aptUtilHelper/main.cpp b/test/test_aptUtilHelper/main.cpp index 2ae1c09..25f97ae 100644 --- a/test/test_aptUtilHelper/main.cpp +++ b/test/test_aptUtilHelper/main.cpp @@ -1,25 +1,55 @@ -#include "ukuiApt.h" +#include "ukui_apt.h" #include -#include +#include -int main(int argc, char *argv[]) +void apt_test() { - QApplication app(argc, argv); bool install = false; - aptUtilHelper* aptHelper = new aptUtilHelper(DeviceInformation()); + + AptUtilHelper* aptHelper = new AptUtilHelper(DeviceInformation()); QEventLoop eventloop; - QObject::connect(aptHelper, &aptUtilHelper::succeed, [&eventloop, &install]() { + QObject::connect(aptHelper, &AptUtilHelper::succeed, [&eventloop, &install]() { // qDebug() << devInfo.name <<"`s package: Install succeed"; install = true; eventloop.quit(); }); - QObject::connect(aptHelper, &aptUtilHelper::failed, [&eventloop, &install]() { + QObject::connect(aptHelper, &AptUtilHelper::failed, [&eventloop, &install]() { // qDebug() << devInfo.name <<"`s package: Install failed"; install = false; eventloop.quit(); }); aptHelper->startWorker(); eventloop.exec(); +} + +void deb_test() +{ + bool install = false; + + // DebUtilHelper* aptHelper = new DebUtilHelper("/home/kylin/upgrade_hub/kylin-update-frontend/kylin-update-frontend_1.0.0.36kord_amd64.deb"); + DebUtilHelper* aptHelper = new DebUtilHelper("/home/kylin/upgrade_hub/kylin-system-updater/kylin-calculator_1.1.0~rc12_amd64.deb"); + QEventLoop eventloop; + + QObject::connect(aptHelper, &DebUtilHelper::succeed, [&eventloop, &install]() { + // qDebug() << devInfo.name <<"`s package: Install succeed"; + install = true; + eventloop.quit(); + }); + QObject::connect(aptHelper, &DebUtilHelper::failed, [&eventloop, &install]() { + // qDebug() << devInfo.name <<"`s package: Install failed"; + install = false; + eventloop.quit(); + }); + aptHelper->startWorker(); + eventloop.exec(); +} + + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + // apt_test(); + deb_test(); app.exec(); } diff --git a/test/test_networkdevicebrowse/main.cpp b/test/test_networkdevicebrowse/main.cpp index 277a501..83b8ae4 100644 --- a/test/test_networkdevicebrowse/main.cpp +++ b/test/test_networkdevicebrowse/main.cpp @@ -96,7 +96,9 @@ int main(int argc, char **argv) { // test_LpinfoBrowser(); // test_snmpwalk(); - +// "usb://HP/LaserJet%20M506?serial=PHC8LC5BFW" +// "HP-LaserJet-M506" +// "hp/hp-laserjet_m506-ps.ppd.gz" // UkuiPrinterManager::getInstance().addPrinter("a", "b", "c", "d"); return app.exec(); diff --git a/test/test_remote/remoteWidget.cpp b/test/test_remote/remoteWidget.cpp index c06ae43..71c71a4 100644 --- a/test/test_remote/remoteWidget.cpp +++ b/test/test_remote/remoteWidget.cpp @@ -10,7 +10,7 @@ #include "global_variable.h" RemoteWidget::RemoteWidget(QWidget *parent) - :CustomWidget(parent) + :CustomTransWidget(parent) { initUi(); initConnect(); diff --git a/test/test_remote/remoteWidget.h b/test/test_remote/remoteWidget.h index 9504596..a0bdb00 100644 --- a/test/test_remote/remoteWidget.h +++ b/test/test_remote/remoteWidget.h @@ -6,10 +6,10 @@ #include #include #include "custom_push_button.h" -#include "custom_widget.h" +#include "custom_trans_widget.h" #include -class RemoteWidget : public CustomWidget +class RemoteWidget : public CustomTransWidget { Q_OBJECT private: diff --git a/test/ui/custom_ui/custom_combo_box/CMakeLists.txt b/test/ui/custom_ui/custom_combo_box/CMakeLists.txt new file mode 100644 index 0000000..c22177b --- /dev/null +++ b/test/ui/custom_ui/custom_combo_box/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.5) +# Set Project Name +project(custom_combo_box LANGUAGES C CXX) + +if(CMAKE_VERSION VERSION_LESS "3.7.0") + set(CMAKE_INCLUDE_CURRENT_DIR ON) +endif() + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools X11Extras Network DBus REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools X11Extras Network DBus REQUIRED) + + +set (SOURCE_PATH ../../../..) +#add include_directories +include_directories( + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/${SOURCE_PATH}/ui/custom_ui +) + +set(${PROJECT_NAME}_SRC + ${PROJECT_SOURCE_DIR}/${SOURCE_PATH}/ui/custom_ui/custom_combo_box.cpp +) + +set(${PROJECT_NAME}_HDR + ${PROJECT_SOURCE_DIR}/${SOURCE_PATH}/ui/custom_ui/custom_combo_box.h +) + +add_executable(${PROJECT_NAME} + main.cpp + ${${PROJECT_NAME}_SRC} + ${${PROJECT_NAME}_HDR} +) + +target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::X11Extras Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::DBus) + +#dependencies +target_link_libraries(${PROJECT_NAME} "-lpthread -lz") \ No newline at end of file diff --git a/test/ui/custom_ui/custom_combo_box/main.cpp b/test/ui/custom_ui/custom_combo_box/main.cpp new file mode 100644 index 0000000..3eea4bd --- /dev/null +++ b/test/ui/custom_ui/custom_combo_box/main.cpp @@ -0,0 +1,26 @@ +#include +#include "custom_combo_box.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + CustomComboBox *b = new CustomComboBox(); + + b->setDefaultPreItem("1"); + b->setDefaultPreItem("2", true); + + b->setDefaultAfterItem("3"); + // b->setDefaultAfterItem("4", true); + b->setDefaultAfterItem("5"); + + // b->addItem("aaa"); + + // b->clear(); + + b->addItem("aaa"); + + b->show(); + + app.exec(); +} \ No newline at end of file diff --git a/ui/custom_ui/custom_message_box.cpp b/ui/custom_ui/custom_message_box.cpp index 2117bd4..2b5d572 100644 --- a/ui/custom_ui/custom_message_box.cpp +++ b/ui/custom_ui/custom_message_box.cpp @@ -33,6 +33,7 @@ QPushButton *CustomMessageBox::clickedButton() int CustomMessageBox::exec() { + this->setWindowTitle(""); m_ret = QMessageBox::exec(); return m_ret; } diff --git a/ui/main_win_ui/left_widget.cpp b/ui/main_win_ui/left_widget.cpp index 59876c1..61239e7 100644 --- a/ui/main_win_ui/left_widget.cpp +++ b/ui/main_win_ui/left_widget.cpp @@ -103,7 +103,6 @@ void LeftWidget::initDeviceListSector() m_ScrollArea->setProperty("drawScrollBarGroove", false); - m_ScrollArea->setFixedSize(DEVICE_LIST_SECTION); m_ScrollArea->setWidgetResizable(true); m_HLayoutDeviceList->setSpacing(0); diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 6be4479..0e6eda5 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -92,20 +92,18 @@ void MainWindow::initModule() setWindowTitle(tr("Printer")); // setWindowIcon(QIcon::fromTheme("kylin-printer")); setFixedSize(MAIN_WIN_WIDTH,MAIN_WIN_HEIGHT); - setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - //Dbus m_dbus = DaemonIpcDbus::getInstance(); m_leftWidget = new LeftWidget(this); m_leftWidget->setObjectName("leftWidget"); - m_leftWidget->setFixedSize(QSize(NAVIGATION_SECTOR_WIDTH,MAIN_WIN_HEIGHT)); + m_leftWidget->setFixedWidth(NAVIGATION_SECTOR_WIDTH); m_leftWidget->setAutoFillBackground(true); m_leftWidget->setBackgroundRole(QPalette::Window); m_rightWidget= new RightWidget(this); m_rightWidget->setObjectName("rightWidget"); - m_rightWidget->setFixedSize(QSize(EXHBITION_SECTOR_WIDTH,MAIN_WIN_HEIGHT)); + m_rightWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); m_rightWidget->setAutoFillBackground(true); m_rightWidget->setBackgroundRole(QPalette::Base); m_rightWidget->hideExhbitionSector(); @@ -154,6 +152,9 @@ void MainWindow::initConnect() connect(g_popWindow,&PopWindowManager::manualInstallShowRequest,this,&MainWindow::recvDeviceIn); connect(this,SIGNAL(updateMainWin()),this,SLOT(updateImmediately())); connect(this,SIGNAL(modifyPPD(QString)),this,SLOT(updateByChangePPD(QString))); + + connect(&UkuiSettingsMonitor::instance(), &UkuiSettingsMonitor::tabletModeUpdate, + this, &MainWindow::handleTabletMode); } void MainWindow::initQSS() { @@ -165,7 +166,6 @@ void MainWindow::initQSS() m_HLayoutWholeWin->addSpacing(0); m_HLayoutWholeWin->addWidget(m_leftWidget); m_HLayoutWholeWin->addWidget(m_rightWidget); - m_HLayoutWholeWin->addStretch(); } void MainWindow::updateRightWidgetByCheckBtn(const UkuiUsbPrinter& printer) @@ -431,3 +431,46 @@ quint32 MainWindow::getWindowId(void) { return m_windowId; } + + +void MainWindow::enableMaximum() +{ + setMaximumSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX); +} + +void MainWindow::disableMaximum() +{ + setMaximumSize(this->minimumSize()); +} + +void MainWindow::handleTabletMode(UkuiSettingsMonitor::TabletStatus status) +{ + switch (status) { + case UkuiSettingsMonitor::TabletStatus::PCMode: + handlePCMode(); + break; + case UkuiSettingsMonitor::TabletStatus::PADHorizontalMode: + case UkuiSettingsMonitor::TabletStatus::PADVerticalMode: + handlePADMode(); + break; + default: + break; + } +} + +void MainWindow::handlePADMode() +{ + enableMaximum(); + showMaximized(); +} + +void MainWindow::handlePCMode() +{ + disableMaximum(); +} + +void MainWindow::showEvent(QShowEvent *event) +{ + handleTabletMode(UkuiSettingsMonitor::instance().tabletMode()); + QMainWindow::showEvent(event); +} \ No newline at end of file diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 9788d2f..5aab261 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -18,6 +18,8 @@ #include "job_manager_window.h" #include "deb_install_window.h" +#include "ukui_settings_monitor.h" + #define g_printerManger UkuiPrinterManager::getInstance() class MainWindow : public QMainWindow { @@ -25,8 +27,8 @@ class MainWindow : public QMainWindow public: static MainWindow *getInstance(); protected: - void keyPressEvent(QKeyEvent *event); - bool eventFilter(QObject* watched, QEvent* event); + void keyPressEvent(QKeyEvent *event) override; + bool eventFilter(QObject* watched, QEvent* event) override; signals: void updateMainWin(); void modifyPPD(QString); @@ -64,6 +66,8 @@ private slots: void updateImmediately(); void updateByRename(QString printerName); void recvDeviceIn(DeviceInformation&); + void enableMaximum(); + void disableMaximum(); private: ~MainWindow(); @@ -102,7 +106,13 @@ private: //=======================test接口========================= +protected: + virtual void handlePCMode(); + virtual void handlePADMode(); + void showEvent(QShowEvent *event) override; +private: + void handleTabletMode(UkuiSettingsMonitor::TabletStatus status); }; diff --git a/ui/rename_printer_dialog.cpp b/ui/rename_printer_dialog.cpp index 317c65e..e76370b 100644 --- a/ui/rename_printer_dialog.cpp +++ b/ui/rename_printer_dialog.cpp @@ -17,6 +17,7 @@ RenamePrinterDialog::RenamePrinterDialog(QString printerName, QWidget *parent) connect(ui->acceptButton, &QPushButton::clicked, this, &RenamePrinterDialog::acceptButtonClicked); connect(ui->cancelButton, &QPushButton::clicked, this, &RenamePrinterDialog::reject); + connect(ui->printerNameEdit, &QLineEdit::returnPressed, this, &RenamePrinterDialog::acceptButtonClicked); connect(ui->printerNameEdit, &QLineEdit::textChanged, [=](const QString &str){ ui->statusLabel->setText(""); auto res = UkuiPrinterManager::getInstance().printerNameCheck(str, m_printers);