diff --git a/test/testbodyresizer/main.cpp b/test/testbodyresizer/main.cpp index 950dfe46..eed0b833 100644 --- a/test/testbodyresizer/main.cpp +++ b/test/testbodyresizer/main.cpp @@ -4,7 +4,8 @@ int main ( int argc, char* argv[] ) { - //QQtApplication::setHighDpiScaling(); + QQtApplication::setHighDpiScaling(); + QQtApplication a ( argc, argv ); //MainWindow w; diff --git a/test/testwindowattribute/AppRoot/skin/default.qss b/test/testwindowattribute/AppRoot/skin/default.qss new file mode 100644 index 00000000..09e37969 --- /dev/null +++ b/test/testwindowattribute/AppRoot/skin/default.qss @@ -0,0 +1,24 @@ +/*spinbox 抬起样式*/ +QTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button { + subcontrol-origin:border; + subcontrol-position:right; + width: 12px; +} + +QTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button { + subcontrol-origin:border; + subcontrol-position:left; + width: 12px; +} + +/*按钮按下样式*/ +QTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ + subcontrol-origin:border; + subcontrol-position:right; + width: 12px; +} + +QTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ + subcontrol-position:left; + width: 12px; +} diff --git a/test/testwindowattribute/android/AndroidManifest.xml b/test/testwindowattribute/android/AndroidManifest.xml new file mode 100644 index 00000000..1fc35d2d --- /dev/null +++ b/test/testwindowattribute/android/AndroidManifest.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/testwindowattribute/android/res/drawable-hdpi/ic_launcher_round.png b/test/testwindowattribute/android/res/drawable-hdpi/ic_launcher_round.png new file mode 100644 index 00000000..3e1aeefe Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-hdpi/ic_launcher_round.png differ diff --git a/test/testwindowattribute/android/res/drawable-hdpi/icon.png b/test/testwindowattribute/android/res/drawable-hdpi/icon.png new file mode 100644 index 00000000..85e68717 Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-hdpi/icon.png differ diff --git a/test/testwindowattribute/android/res/drawable-ldpi/ic_launcher_round.png b/test/testwindowattribute/android/res/drawable-ldpi/ic_launcher_round.png new file mode 100644 index 00000000..66178784 Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-ldpi/ic_launcher_round.png differ diff --git a/test/testwindowattribute/android/res/drawable-ldpi/icon.png b/test/testwindowattribute/android/res/drawable-ldpi/icon.png new file mode 100644 index 00000000..88ee6f7d Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-ldpi/icon.png differ diff --git a/test/testwindowattribute/android/res/drawable-mdpi/ic_launcher_round.png b/test/testwindowattribute/android/res/drawable-mdpi/ic_launcher_round.png new file mode 100644 index 00000000..22d1ab6d Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-mdpi/ic_launcher_round.png differ diff --git a/test/testwindowattribute/android/res/drawable-mdpi/icon.png b/test/testwindowattribute/android/res/drawable-mdpi/icon.png new file mode 100644 index 00000000..e5c37c2d Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-mdpi/icon.png differ diff --git a/test/testwindowattribute/android/res/drawable-xhdpi/ic_launcher_round.png b/test/testwindowattribute/android/res/drawable-xhdpi/ic_launcher_round.png new file mode 100644 index 00000000..88ee6f7d Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-xhdpi/ic_launcher_round.png differ diff --git a/test/testwindowattribute/android/res/drawable-xxhdpi/ic_launcher_round.png b/test/testwindowattribute/android/res/drawable-xxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..e5c37c2d Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-xxhdpi/ic_launcher_round.png differ diff --git a/test/testwindowattribute/android/res/drawable-xxxhdpi/ic_launcher_round.png b/test/testwindowattribute/android/res/drawable-xxxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..85e68717 Binary files /dev/null and b/test/testwindowattribute/android/res/drawable-xxxhdpi/ic_launcher_round.png differ diff --git a/test/testwindowattribute/main.cpp b/test/testwindowattribute/main.cpp new file mode 100644 index 00000000..96b8e014 --- /dev/null +++ b/test/testwindowattribute/main.cpp @@ -0,0 +1,13 @@ +#include "mainwindow.h" +#include + +int main ( int argc, char* argv[] ) +{ + QQtApplication::setHighDpiScaling(); + + QQtApplication a ( argc, argv ); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/test/testwindowattribute/mainwindow.cpp b/test/testwindowattribute/mainwindow.cpp new file mode 100644 index 00000000..c52e50b9 --- /dev/null +++ b/test/testwindowattribute/mainwindow.cpp @@ -0,0 +1,54 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include +#include + +#include + +MainWindow::MainWindow ( QWidget* parent ) : + QMainWindow ( parent ), + ui ( new Ui::MainWindow ) +{ + ui->setupUi ( this ); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_pushButton_clicked() +{ + setFullScreen ( this, true ); +} + +void MainWindow::on_pushButton_2_clicked() +{ + setFullScreen ( this, false ); +} + +void MainWindow::on_pushButton_3_clicked() +{ + setShadowEffect ( this ); +} + +void MainWindow::on_pushButton_4_clicked() +{ + graphicsEffect()->setEnabled ( false ); +} + +void MainWindow::on_pushButton_5_clicked() +{ + setMainWindow ( this, true ); +} + +void MainWindow::on_pushButton_6_clicked() +{ + setMainWindow ( this, false ); +} + +void MainWindow::on_pushButton_7_clicked() +{ + setFadeEffect ( this ); +} diff --git a/test/testwindowattribute/mainwindow.h b/test/testwindowattribute/mainwindow.h new file mode 100644 index 00000000..7979edf2 --- /dev/null +++ b/test/testwindowattribute/mainwindow.h @@ -0,0 +1,37 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow ( QWidget* parent = 0 ); + ~MainWindow(); + +private slots: + void on_pushButton_clicked(); + + void on_pushButton_2_clicked(); + + void on_pushButton_3_clicked(); + + void on_pushButton_4_clicked(); + + void on_pushButton_5_clicked(); + + void on_pushButton_6_clicked(); + + void on_pushButton_7_clicked(); + +private: + Ui::MainWindow* ui; +}; + +#endif // MAINWINDOW_H diff --git a/test/testwindowattribute/mainwindow.ui b/test/testwindowattribute/mainwindow.ui new file mode 100644 index 00000000..ba0f4bb9 --- /dev/null +++ b/test/testwindowattribute/mainwindow.ui @@ -0,0 +1,168 @@ + + + MainWindow + + + + 0 + 0 + 540 + 353 + + + + testwindowattribute + + + + + + 30 + 30 + 81 + 31 + + + + + 0 + 0 + + + + FullScreen + + + + + + 30 + 70 + 81 + 31 + + + + + 0 + 0 + + + + NormalScreen + + + + + + 240 + 30 + 81 + 31 + + + + + 0 + 0 + + + + ShadowEffect + + + + + + 240 + 80 + 81 + 31 + + + + + 0 + 0 + + + + Close ShadowEffect + + + + + + 30 + 150 + 81 + 31 + + + + + 0 + 0 + + + + Main Window + + + + + + 30 + 190 + 81 + 31 + + + + + 0 + 0 + + + + Sub Window + + + + + + 240 + 150 + 81 + 31 + + + + FadeEffect + + + + + + + 0 + 0 + 540 + 17 + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/test/testwindowattribute/qqtwidgeteffect.cpp b/test/testwindowattribute/qqtwidgeteffect.cpp new file mode 100644 index 00000000..9217eb23 --- /dev/null +++ b/test/testwindowattribute/qqtwidgeteffect.cpp @@ -0,0 +1,34 @@ +#include + +#include +#include + +void setShadowEffect ( QWidget* widget ) +{ + Q_ASSERT ( widget ); + + /* + * blurRadius 阴影清晰度,越小越清晰 + * dx x方向阴影位置和偏移量,正值在右方,值越大偏移越大 + * dy y方向阴影位置和偏移量,正值在下方,值越大偏移越大 + */ + static QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect; + shadow->setBlurRadius ( 10 ); + shadow->setColor ( QColor ( 0, 0, 0, 160 ) ); + shadow->setOffset ( 5, 5 ); + shadow->setEnabled ( true ); + widget->setGraphicsEffect ( shadow ); + +} + +void setFadeEffect ( QWidget* widget, quint32 millseconds, qreal startOpacity, qreal endOpacity ) +{ + Q_ASSERT ( widget ); + + static QPropertyAnimation* show_animation_ = new QPropertyAnimation ( widget, "windowOpacity" ); + show_animation_->setDuration ( millseconds ); + show_animation_->setStartValue ( startOpacity ); + show_animation_->setEndValue ( endOpacity ); + show_animation_->start(); + widget->show(); +} diff --git a/test/testwindowattribute/qqtwidgeteffect.h b/test/testwindowattribute/qqtwidgeteffect.h new file mode 100644 index 00000000..d6dabb94 --- /dev/null +++ b/test/testwindowattribute/qqtwidgeteffect.h @@ -0,0 +1,15 @@ +#ifndef QQTWIDGETEFFECT_H +#define QQTWIDGETEFFECT_H + +#include + +//#include +#define QQTSHARED_EXPORT + +//shadow effect (子控件) +void QQTSHARED_EXPORT setShadowEffect ( QWidget* widget ); + +//fade effect +void QQTSHARED_EXPORT setFadeEffect ( QWidget* widget, quint32 millseconds = 2000, qreal startOpacity = 0, qreal endOpacity = 1 ); + +#endif // QQTWIDGETEFFECT_H diff --git a/test/testwindowattribute/qqtwindowattribute.cpp b/test/testwindowattribute/qqtwindowattribute.cpp new file mode 100644 index 00000000..6290b940 --- /dev/null +++ b/test/testwindowattribute/qqtwindowattribute.cpp @@ -0,0 +1,59 @@ +#include + +#include +#include +#include + +void setFrameless ( QWidget* widget, bool open ) +{ + Q_ASSERT ( widget ); + pline() << widget->windowFlags(); + if ( open ) + widget->setWindowFlags ( Qt::FramelessWindowHint | widget->windowFlags() ); + else + widget->setWindowFlag ( Qt::FramelessWindowHint, false ); + pline() << widget->windowFlags(); +} + +void setMainWindow ( QWidget* widget, bool open ) +{ + Q_ASSERT ( widget ); + pline() << widget->windowFlags(); + if ( open ) + { + widget->setWindowFlags ( Qt::Window | widget->windowFlags() ); + widget->setWindowFlag ( Qt::SubWindow, false ); + } + else + { + //独立的子窗口是不存在的。 + widget->setWindowFlag ( Qt::Widget, true ); + //怎么了,不能单独使用。 + //widget->setWindowFlags ( Qt::SubWindow | widget->windowFlags() ); + } + pline() << widget->windowFlags(); +} + +void setFullScreen ( QWidget* widget, bool open, QRect normalGeometry ) +{ + Q_ASSERT ( widget ); + pline() << widget->windowFlags(); + if ( open ) + { + //确保不是子窗口 + widget->setWindowFlags ( Qt::Window | widget->windowFlags() ); + widget->setWindowFlags ( Qt::FramelessWindowHint | widget->windowFlags() ); + widget->showFullScreen(); + } + else + { + //确保不是子窗口 + widget->setWindowFlags ( Qt::Window | widget->windowFlags() ); + //取消frameless + widget->setWindowFlag ( Qt::FramelessWindowHint, false ); + widget->showNormal(); + widget->setGeometry ( normalGeometry ); + moveCenter ( widget ); + } + pline() << widget->windowFlags(); +} diff --git a/test/testwindowattribute/qqtwindowattribute.h b/test/testwindowattribute/qqtwindowattribute.h new file mode 100644 index 00000000..d4c12859 --- /dev/null +++ b/test/testwindowattribute/qqtwindowattribute.h @@ -0,0 +1,22 @@ +#ifndef QQTWINDOWATTRIBUTE_H +#define QQTWINDOWATTRIBUTE_H + +#include + +//#include +#define QQTSHARED_EXPORT + +//frameless +void QQTSHARED_EXPORT setFrameless ( QWidget* widget, bool open = true ); + +//主、子窗口 +void QQTSHARED_EXPORT setMainWindow ( QWidget* widget, bool open = true ); + +//full screen (normal screen, +size) +void QQTSHARED_EXPORT setFullScreen ( QWidget* widget, bool open = true, QRect normalGeometry = QRect ( 0, 0, 800, 600 ) ); + +//子窗体填充主窗体 + + + +#endif // QQTWINDOWATTRIBUTE_H diff --git a/test/testwindowattribute/testwindowattribute.pro b/test/testwindowattribute/testwindowattribute.pro new file mode 100644 index 00000000..c1611ded --- /dev/null +++ b/test/testwindowattribute/testwindowattribute.pro @@ -0,0 +1,83 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-10-06T08:16:10 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = testwindowattribute +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +include($${PWD}/../../multi-link/add_base_manager.pri) + +CONFIG += use_source +use_source { + +add_file(qqtwindowattribute.h) +add_file(qqtwindowattribute.cpp) + +add_file(qqtwidgeteffect.h) +add_file(qqtwidgeteffect.cpp) + +HEADERS += \ + qqtwindowattribute.h \ + qqtwidgeteffect.h +SOURCES += \ + qqtwindowattribute.cpp \ + qqtwidgeteffect.cpp + +} +#------------------------------------------------- +#用户工程配置 +#------------------------------------------------- +add_version(1,0,0,0) +add_deploy() +add_deploy_config($${PWD}/AppRoot) +add_dependent_manager(QQt) +system(touch main.cpp) + +#------------------------------------------------- +#用户工程配置 +#------------------------------------------------- +equals(QSYS_PRIVATE, macOS) { + CONFIG += app_bundle +} + +contains(QSYS_PRIVATE, Android|AndroidX86) { + CONFIG += mobility + MOBILITY = + DISTFILES += \ + android/AndroidManifest.xml + + ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android +} + +message ($${TARGET} config $${CONFIG}) +message ($${TARGET} DEFINE $${DEFINES}) +message ($${TARGET} prelink $${QMAKE_PRE_LINK}) +message ($${TARGET} postlink $${QMAKE_POST_LINK})