diff --git a/QQtExample_Temp.pro b/QQtExample_Temp.pro index 060e5501..e1982085 100644 --- a/QQtExample_Temp.pro +++ b/QQtExample_Temp.pro @@ -1,17 +1,17 @@ -##----------------------------------------------------------------- -##LibQQt样例工程入口 -##不能随便编译,初始设置要求比较严格,请按照规程设置完整。 -##Example要编译,必须先编译完LibQQt -##本Library基于Multi-link技术,Example也是 -##Example工程也就是App工程和Library工程不能放在一起编译,否则会引发 first time bug (add_deploy_library_on_mac). -##Library工程组和App工程组分开编译,不会引发这个bug。 -##----------------------------------------------------------------- -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = - -#SUBDIRS += test/giftest -#SUBDIRS += test/voicetest -#SUBDIRS += examples/exquisite -SUBDIRS += demo/QQtRoseMonitor +##----------------------------------------------------------------- +##LibQQt样例工程入口 +##不能随便编译,初始设置要求比较严格,请按照规程设置完整。 +##Example要编译,必须先编译完LibQQt +##本Library基于Multi-link技术,Example也是 +##Example工程也就是App工程和Library工程不能放在一起编译,否则会引发 first time bug (add_deploy_library_on_mac). +##Library工程组和App工程组分开编译,不会引发这个bug。 +##----------------------------------------------------------------- +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += test/QQtCustomTitleBarMainFormTest +SUBDIRS += test/QQtOSDFormTest +#SUBDIRS += demo/QQtRoseMonitor +#SUBDIRS += examples/exquisite +#SUBDIRS += test/voicetest +#SUBDIRS += test/giftest diff --git a/multi-link b/multi-link index e0e44990..d0a65e5f 160000 --- a/multi-link +++ b/multi-link @@ -1 +1 @@ -Subproject commit e0e449906b9370cdc77aafada37aa285751bbd19 +Subproject commit d0a65e5f49433c1ca446c34926e7e169ef550362 diff --git a/src/exquisite/osdwidgets/qqtosdform.cpp b/src/exquisite/osdwidgets/qqtosdform.cpp new file mode 100644 index 00000000..1b6cf8b3 --- /dev/null +++ b/src/exquisite/osdwidgets/qqtosdform.cpp @@ -0,0 +1 @@ +#include diff --git a/src/exquisite/osdwidgets/qqtosdform.h b/src/exquisite/osdwidgets/qqtosdform.h new file mode 100644 index 00000000..cab330b3 --- /dev/null +++ b/src/exquisite/osdwidgets/qqtosdform.h @@ -0,0 +1,38 @@ +#ifndef QQTOSDFORM_H +#define QQTOSDFORM_H + +#include + +#include +#include + +/** + * QQtOSDForm + * 透明背景的Form,可以应用于作为透明窗口。 + * 这个窗口只是提供实现思路,由于内部窗体的Widget无法直接交给用户继承并且实现,所以给用户方法,在源程序里按照方法实现。 + */ +class QQTSHARED_EXPORT QQtOSDForm : public QQtWidget +{ + Q_OBJECT +public: + explicit QQtOSDForm ( QWidget* parent = nullptr ) : QQtWidget ( parent ) { + //必要,最底层,提供透明背景。 + setAttribute ( Qt::WA_TranslucentBackground, true ); + + //optional,qqtformbodymousehelper,提供支持鼠标点击窗体进行移动。 + //QQtFormBodyMouseHelper* helper = new QQtFormBodyMouseHelper(this); + + //在ui文件里,设置竖向Layout。 + //上边为QQtTitleBar,用户设置高度。 + //下边为QQtOSDFrame,提供透明和边框。 + //在QQtOSDFrame里面实现用户的需求。 + } + + ~QQtOSDForm() {} + +signals: + +public slots: +}; + +#endif // QQTOSDFORM_H diff --git a/src/exquisite/osdwidgets/qqtosdframe.cpp b/src/exquisite/osdwidgets/qqtosdframe.cpp new file mode 100644 index 00000000..52b48b75 --- /dev/null +++ b/src/exquisite/osdwidgets/qqtosdframe.cpp @@ -0,0 +1,24 @@ +#include + +QQtOSDFrame::QQtOSDFrame ( QWidget* parent ) : QQtWidget ( parent ) +{ + setAttribute ( Qt::WA_TranslucentBackground, true ); +} + +QQtOSDFrame::~QQtOSDFrame() {} + +void QQtOSDFrame::paintEvent ( QPaintEvent* event ) +{ + //这个效果一般,如果用户特别需要,自己绘制。 +#if 0 + QPainter p ( this ); + QPen pen = p.pen(); + pen.setWidth ( 3 ); + pen.setColor ( QColor ( 127, 188, 248 ) ); + p.setPen ( pen ); + p.drawLine ( QPoint ( 0, 0 ), QPoint ( 0, height() ) ); + p.drawLine ( QPoint ( 0, height() ), QPoint ( width(), height() ) ); + p.drawLine ( QPoint ( width(), height() ), QPoint ( width(), 0 ) ); +#endif + QQtWidget::paintEvent ( event ); +} diff --git a/src/exquisite/osdwidgets/qqtosdframe.h b/src/exquisite/osdwidgets/qqtosdframe.h new file mode 100644 index 00000000..de9e48d9 --- /dev/null +++ b/src/exquisite/osdwidgets/qqtosdframe.h @@ -0,0 +1,34 @@ +#ifndef QQTOSDFRAME_H +#define QQTOSDFRAME_H + +#include + +#include +#include + +/** + * QQtOSDFrame + * 透明背景的Frame,可以应用于作为透明窗体。 + * + * 提供绘制窗体的边框。 + * 支持QSS修饰。 + * 可以设置背景。 + */ +class QQTSHARED_EXPORT QQtOSDFrame : public QQtWidget +{ + Q_OBJECT +public: + explicit QQtOSDFrame ( QWidget* parent = nullptr ); + + ~QQtOSDFrame(); + +signals: + +public slots: + + // QWidget interface +protected: + virtual void paintEvent ( QPaintEvent* event ) override; +}; + +#endif // QQTOSDFRAME_H diff --git a/src/frame/qqtosdwidget.cpp b/src/exquisite/osdwidgets/qqtosdwidget.cpp similarity index 100% rename from src/frame/qqtosdwidget.cpp rename to src/exquisite/osdwidgets/qqtosdwidget.cpp diff --git a/src/frame/qqtosdwidget.h b/src/exquisite/osdwidgets/qqtosdwidget.h similarity index 74% rename from src/frame/qqtosdwidget.h rename to src/exquisite/osdwidgets/qqtosdwidget.h index 723bd7e9..b893461f 100644 --- a/src/frame/qqtosdwidget.h +++ b/src/exquisite/osdwidgets/qqtosdwidget.h @@ -6,6 +6,10 @@ #include #include +/** + * QQtOSDWidget + * 透明背景的Widget,可以应用于作为透明控件。 + */ class QQTSHARED_EXPORT QQtOSDWidget : public QQtWidget { Q_OBJECT diff --git a/src/exquisite/qqtframelesshelperprivate.cpp b/src/exquisite/qqtframelesshelperprivate.cpp index df00ff1c..ee78307d 100644 --- a/src/exquisite/qqtframelesshelperprivate.cpp +++ b/src/exquisite/qqtframelesshelperprivate.cpp @@ -6,51 +6,51 @@ #include #include -QQtFramelessHelperPrivate::QQtFramelessHelperPrivate(QWidget* parent) - : parent(parent), - isMaximized(false), - direction(None), - buttonMaximized(0), - buttonRestore(0), - buttonClose(0), - buttonMinimized(0), - isMousePressed(false), - QObject(parent) +QQtFramelessHelperPrivate::QQtFramelessHelperPrivate ( QWidget* parent ) + : parent ( parent ), + isMaximized ( false ), + direction ( None ), + buttonMaximized ( 0 ), + buttonRestore ( 0 ), + buttonClose ( 0 ), + buttonMinimized ( 0 ), + isMousePressed ( false ), + QObject ( parent ) { - margins = QMargins(5, 5, 5, 5); - parent->setWindowFlags(parent->windowFlags() | (Qt::FramelessWindowHint)); - parent->installEventFilter(this); + margins = QMargins ( 8, 8, 8, 8 ); + parent->setWindowFlags ( parent->windowFlags() | ( Qt::FramelessWindowHint ) ); + parent->installEventFilter ( this ); - timer = new QTimer(this); - timer->setInterval(400); - connect(timer, SIGNAL(timeout()), this, SLOT(checkPos())); + timer = new QTimer ( this ); + timer->setInterval ( 400 ); + connect ( timer, SIGNAL ( timeout() ), this, SLOT ( checkPos() ) ); timer->start(); } -void QQtFramelessHelperPrivate::addEdgeWidget(QWidget* widget) +void QQtFramelessHelperPrivate::addEdgeWidget ( QWidget* widget ) { - if (!edgeWidgets.contains(widget)) + if ( !edgeWidgets.contains ( widget ) ) { - edgeWidgets.append(widget); + edgeWidgets.append ( widget ); - if (!dragWidgets.contains(widget)) + if ( !dragWidgets.contains ( widget ) ) { - widget->installEventFilter(this); + widget->installEventFilter ( this ); } } } -void QQtFramelessHelperPrivate::addDragWidget(QWidget* widget) +void QQtFramelessHelperPrivate::addDragWidget ( QWidget* widget ) { - if (!dragWidgets.contains(widget)) + if ( !dragWidgets.contains ( widget ) ) { - dragWidgets.append(widget); + dragWidgets.append ( widget ); - if (!edgeWidgets.contains(widget)) + if ( !edgeWidgets.contains ( widget ) ) { - widget->installEventFilter(this); + widget->installEventFilter ( this ); } } } @@ -59,16 +59,16 @@ void QQtFramelessHelperPrivate::checkPos() { QRect rectMustIn = parent->frameGeometry(); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - QRect rectMustNotIn = rectMustIn.marginsRemoved(margins); + QRect rectMustNotIn = rectMustIn.marginsRemoved ( margins ); #else - QRect rectMustNotIn = rectMustIn.adjusted(margins.left(), margins.top(), margins.right(), margins.bottom()); + QRect rectMustNotIn = rectMustIn.adjusted ( margins.left(), margins.top(), margins.right(), margins.bottom() ); #endif QPoint cursorPos = QCursor::pos(); - if (isMaximized || - !parent->isActiveWindow() || - !rectMustIn.contains(cursorPos) || - rectMustNotIn.contains(cursorPos)) + if ( isMaximized || + !parent->isActiveWindow() || + !rectMustIn.contains ( cursorPos ) || + rectMustNotIn.contains ( cursorPos ) ) { direction = None; parent->unsetCursor(); @@ -77,7 +77,7 @@ void QQtFramelessHelperPrivate::checkPos() int baseLeftCoord, baseTopCoord, baseRightCoord, baseBottomCoord; - rectMustNotIn.getCoords(&baseLeftCoord, &baseTopCoord, &baseRightCoord, &baseBottomCoord); + rectMustNotIn.getCoords ( &baseLeftCoord, &baseTopCoord, &baseRightCoord, &baseBottomCoord ); int x, y; x = cursorPos.x(); @@ -85,13 +85,13 @@ void QQtFramelessHelperPrivate::checkPos() direction = None; - if (x < baseLeftCoord) + if ( x < baseLeftCoord ) { - if (y < baseTopCoord) + if ( y < baseTopCoord ) { direction = LeftTop; } - else if (y > baseBottomCoord) + else if ( y > baseBottomCoord ) { direction = LeftBottom; } @@ -100,13 +100,13 @@ void QQtFramelessHelperPrivate::checkPos() direction = Left; } } - else if (x > baseRightCoord) + else if ( x > baseRightCoord ) { - if (y < baseTopCoord) + if ( y < baseTopCoord ) { direction = RightTop; } - else if (y > baseBottomCoord) + else if ( y > baseBottomCoord ) { direction = RightBottom; } @@ -116,9 +116,9 @@ void QQtFramelessHelperPrivate::checkPos() } } - if (direction == None) + if ( direction == None ) { - if (y < baseTopCoord) + if ( y < baseTopCoord ) { direction = Top; } @@ -128,151 +128,151 @@ void QQtFramelessHelperPrivate::checkPos() } } - switch (direction) + switch ( direction ) { - case Left: - case Right: - parent->setCursor(Qt::SizeHorCursor); - break; + case Left: + case Right: + parent->setCursor ( Qt::SizeHorCursor ); + break; - case Top: - case Bottom: - parent->setCursor(Qt::SizeVerCursor); - break; + case Top: + case Bottom: + parent->setCursor ( Qt::SizeVerCursor ); + break; - case LeftTop: - case RightBottom: - parent->setCursor(Qt::SizeFDiagCursor); - break; + case LeftTop: + case RightBottom: + parent->setCursor ( Qt::SizeFDiagCursor ); + break; - case LeftBottom: - case RightTop: - parent->setCursor(Qt::SizeBDiagCursor); - break; + case LeftBottom: + case RightTop: + parent->setCursor ( Qt::SizeBDiagCursor ); + break; } } -void QQtFramelessHelperPrivate::resize(const QPoint& cursorPos) +void QQtFramelessHelperPrivate::resize ( const QPoint& cursorPos ) { QSize oldSize = parent->size(); int x, y, width = 0, height = 0; - switch (direction) + switch ( direction ) { - case Left: // left - width = oldSize.width() - cursorPos.x(); - height = oldSize.height(); + case Left: // left + width = oldSize.width() - cursorPos.x(); + height = oldSize.height(); - x = parent->pos().x() - (width - oldSize.width()); - y = parent->pos().y(); - break; + x = parent->pos().x() - ( width - oldSize.width() ); + y = parent->pos().y(); + break; - case Right: //right - width = cursorPos.x(); - height = oldSize.height(); + case Right: //right + width = cursorPos.x(); + height = oldSize.height(); - x = parent->pos().x(); - y = parent->pos().y(); - break; + x = parent->pos().x(); + y = parent->pos().y(); + break; - case LeftTop: //left top - width = oldSize.width() - cursorPos.x(); - height = oldSize.height() - cursorPos.y(); + case LeftTop: //left top + width = oldSize.width() - cursorPos.x(); + height = oldSize.height() - cursorPos.y(); - x = parent->pos().x() - (width - oldSize.width()); - y = parent->pos().y() - (height - oldSize.height()); - break; + x = parent->pos().x() - ( width - oldSize.width() ); + y = parent->pos().y() - ( height - oldSize.height() ); + break; - case RightTop: //right top - width = cursorPos.x(); - height = oldSize.height() - cursorPos.y(); + case RightTop: //right top + width = cursorPos.x(); + height = oldSize.height() - cursorPos.y(); - x = parent->pos().x(); - y = parent->pos().y() - (height - oldSize.height()); + x = parent->pos().x(); + y = parent->pos().y() - ( height - oldSize.height() ); - break; + break; - case LeftBottom: //left bottom - width = oldSize.width() - cursorPos.x(); - height = cursorPos.y(); + case LeftBottom: //left bottom + width = oldSize.width() - cursorPos.x(); + height = cursorPos.y(); - x = parent->pos().x() - (width - oldSize.width()); - y = parent->pos().y(); + x = parent->pos().x() - ( width - oldSize.width() ); + y = parent->pos().y(); - break; + break; - case RightBottom: //right bottom - width = cursorPos.x(); - height = cursorPos.y(); + case RightBottom: //right bottom + width = cursorPos.x(); + height = cursorPos.y(); - x = parent->pos().x(); - y = parent->pos().y(); - break; + x = parent->pos().x(); + y = parent->pos().y(); + break; - case Top: //top - width = oldSize.width(); - height = oldSize.height() - cursorPos.y(); + case Top: //top + width = oldSize.width(); + height = oldSize.height() - cursorPos.y(); - x = parent->pos().x(); - y = parent->pos().y() - (height - oldSize.height()); - break; + x = parent->pos().x(); + y = parent->pos().y() - ( height - oldSize.height() ); + break; - case Bottom: //bottom - width = oldSize.width(); - height = cursorPos.y(); + case Bottom: //bottom + width = oldSize.width(); + height = cursorPos.y(); - x = parent->pos().x(); - y = parent->pos().y(); - break; + x = parent->pos().x(); + y = parent->pos().y(); + break; } - if (width > (margins.left() + margins.right()) && - height > (margins.top() + margins.bottom())) + if ( width > ( margins.left() + margins.right() ) && + height > ( margins.top() + margins.bottom() ) ) { - parent->move(x, y); - parent->resize(width, height); + parent->move ( x, y ); + parent->resize ( width, height ); } } void QQtFramelessHelperPrivate::refreshMaximizedButton() { - isMaximized = parent->windowState().testFlag(Qt::WindowMaximized); + isMaximized = parent->windowState().testFlag ( Qt::WindowMaximized ); - if (buttonRestore != 0) + if ( buttonRestore != 0 ) { - buttonRestore->setVisible(isMaximized); + buttonRestore->setVisible ( isMaximized ); } - if (buttonMaximized != 0) + if ( buttonMaximized != 0 ) { - buttonMaximized->setVisible(!isMaximized); + buttonMaximized->setVisible ( !isMaximized ); } } -bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event) +bool QQtFramelessHelperPrivate::eventFilter ( QObject* obj, QEvent* event ) { do { - if (event->type() == QEvent::WindowStateChange) + if ( event->type() == QEvent::WindowStateChange ) { refreshMaximizedButton(); break; } - if (event->type() == QEvent::MouseButtonPress) + if ( event->type() == QEvent::MouseButtonPress ) { - QMouseEvent* e = (QMouseEvent*)event; + QMouseEvent* e = ( QMouseEvent* ) event; // no move, no drag - if (e->button() != Qt::LeftButton || isMaximized) + if ( e->button() != Qt::LeftButton || isMaximized ) { break; } checkPos(); - if ((obj == parent || edgeWidgets.contains(qobject_cast(obj))) && direction != None) + if ( ( obj == parent || edgeWidgets.contains ( qobject_cast ( obj ) ) ) && direction != None ) { isMousePressed = true; operation = MoveResize; @@ -280,7 +280,7 @@ bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event) return true; } - if (dragWidgets.contains(qobject_cast(obj)) && direction == None) + if ( dragWidgets.contains ( qobject_cast ( obj ) ) && direction == None ) { isMousePressed = true; operation = MoveDrag; @@ -292,26 +292,26 @@ bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event) break; } - if (event->type() == QEvent::MouseMove && isMousePressed) + if ( event->type() == QEvent::MouseMove && isMousePressed ) { - QMouseEvent* e = (QMouseEvent*)event; + QMouseEvent* e = ( QMouseEvent* ) event; - if (operation == MoveDrag) + if ( operation == MoveDrag ) { - parent->move(e->globalPos() - dragBasePoint); + parent->move ( e->globalPos() - dragBasePoint ); return true; } - if (operation == MoveResize) + if ( operation == MoveResize ) { - if (obj != parent) + if ( obj != parent ) { - QWidget* w = qobject_cast(obj); - resize(w->mapTo(parent, e->pos())); + QWidget* w = qobject_cast ( obj ); + resize ( w->mapTo ( parent, e->pos() ) ); } else { - resize(e->pos()); + resize ( e->pos() ); } return true; @@ -320,11 +320,11 @@ bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event) break; } - if (event->type() == QEvent::MouseButtonRelease) + if ( event->type() == QEvent::MouseButtonRelease ) { - QMouseEvent* e = (QMouseEvent*)event; + QMouseEvent* e = ( QMouseEvent* ) event; - if (e->button() == Qt::LeftButton && isMousePressed) + if ( e->button() == Qt::LeftButton && isMousePressed ) { isMousePressed = false; operation = MoveNone; @@ -335,9 +335,9 @@ bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event) break; } - } while (false); + } while ( false ); - return QObject::eventFilter(obj, event); + return QObject::eventFilter ( obj, event ); } diff --git a/src/frame/qqtapplication.cpp b/src/frame/qqtapplication.cpp index d103f871..bc994de5 100644 --- a/src/frame/qqtapplication.cpp +++ b/src/frame/qqtapplication.cpp @@ -31,18 +31,20 @@ QQtApplication::QQtApplication ( int& argc, char** argv ) : #endif QTextCodec::setCodecForLocale ( QTextCodec::codecForName ( "UTF-8" ) ); + /*配置文件名称设定*/ + //App继承QQtApplication以后,必须设置这三个Value,改变为自己的Value。 /*嵌入式,应用名称必须指定 配置文件路径$CONF_PATH/organizationName/applicationName.conf[.ini]*/ QCoreApplication::setOrganizationName ( "QQt" ); /*专为Mac OS X 准备的,macOS下配置文件: $CONF_PATH/organizationDomain/ApplicationName.ini ... */ QCoreApplication::setOrganizationDomain ( "www.qqt.com" ); // QCoreApplication::setApplicationName ( "QQt" ); - /*设置配置文件所在路径*/ + /*设置配置文件路径*/ QSettings::setDefaultFormat ( QSettings::IniFormat ); QSettings::setPath ( QSettings::IniFormat, QSettings::UserScope, CONFIG_PATH ); QSettings::setPath ( QSettings::IniFormat, QSettings::SystemScope, CONFIG_PATH ); - /*程序中,需要更改语言的位置,可以通过qqtApp->setLanguage实现。languageChanged信号连接到每个页面的更换语言的函数*/ + /*程序中,需要更改语言,可以通过qqtApp->setLanguage实现。languageChanged信号连接到每个页面的刷新语言的函数,一般会在这个槽函数里调用ui->retranslateUI()*/ qqtApp = this; #ifdef __DARWIN__ @@ -59,12 +61,12 @@ QQtApplication::QQtApplication ( int& argc, char** argv ) : pline() << "TSLIB_TSDEVICE:" << QProcessEnvironment::systemEnvironment().value ( "TSLIB_TSDEVICE" ); #endif - /*解决,嵌入式板子上,串口关闭后有时无法打开的问题*/ + /*解决:嵌入式板子上串口关闭后有时无法打开的问题*/ #ifdef __EMBEDDED_LINUX__ system ( "rm -f /tmp/LCK..ttyS*" ); #endif - /*设置语言翻译器,用户需要自己设置语言,(默认为页面上的词汇,设置后为翻译的中文或者英文)*/ + /*设置语言翻译器。用户需要自己设置语言,(默认为页面上的词汇,设置后为翻译的中文或者英文或者俄文或者其他语言。)*/ language = new QTranslator ( this ); /*设置随机数种子*/ @@ -196,7 +198,7 @@ void QQtApplication::slotUPanAutoRun ( int status ) } -void QQtApplication::setTextFont ( QString fontfile, int fontsize ) +bool QQtApplication::setTextFont ( QString fontfile, int fontsize ) { /*这个函数没有任何问题,检测完毕。过去的报错是工作目录不对,无法加载其他数据库*/ /*此处,改为使用QFontDatabase的经典静态方法调用方式*/ @@ -207,12 +209,19 @@ void QQtApplication::setTextFont ( QString fontfile, int fontsize ) pline() << "font file:" << fontfile; pline() << "font id:" << fontID; pline() << "font families:" << QFontDatabase::applicationFontFamilies ( fontID ); - //如果字体不对,这个地方会崩溃,那么我要加处理吗? + //如果字体不对,这个地方会崩溃,那么我要加处理吗?加。 + if ( fontID < 0 ) + { + pline() << QString ( "%1 is setted failed, unexisted, but ignored." ).arg ( fontfile ); + return false; + } QString ziti = QFontDatabase::applicationFontFamilies ( fontID ).at ( 0 ); pline() << "font name:" << ziti; QFont font ( ziti, fontsize ); QApplication::setFont ( font ); + + return true; } diff --git a/src/frame/qqtapplication.h b/src/frame/qqtapplication.h index 6d931c35..9e8fdb9b 100644 --- a/src/frame/qqtapplication.h +++ b/src/frame/qqtapplication.h @@ -19,7 +19,7 @@ public: void setLanguage ( QString qmfile = "./lang/zh_CN.qm" ); //palette - void setTextFont ( QString fontfile = "/usr/lib/fonts/heiti.ttf", + bool setTextFont ( QString fontfile = "/usr/lib/fonts/heiti.ttf", int fontsize = 11 ); //这是设置全部控件的,基本的QSS,通用的QSS,全在这个里,特殊不变的也允许放在这里。 void setQSSStyle ( QString qssfile = "./skin/default.qss" ); diff --git a/src/frame/qqtsysteminfo.cpp b/src/highgrade/qqtsysteminfo.cpp similarity index 100% rename from src/frame/qqtsysteminfo.cpp rename to src/highgrade/qqtsysteminfo.cpp diff --git a/src/frame/qqtsysteminfo.h b/src/highgrade/qqtsysteminfo.h similarity index 100% rename from src/frame/qqtsysteminfo.h rename to src/highgrade/qqtsysteminfo.h diff --git a/src/qqt_header.pri b/src/qqt_header.pri index 14910b50..57d643dd 100644 --- a/src/qqt_header.pri +++ b/src/qqt_header.pri @@ -348,6 +348,9 @@ defineTest(add_defines_QQt){ #click sound widgets DEFINES += __CLICKSOUNDWIDGETS__ + + #on screen display widget + DEFINES += __OSDWIDGETS__ } ######################################################################## @@ -359,8 +362,6 @@ defineTest(add_defines_QQt){ #if you use HighGrade module, open this annotation #高级模块,包含不少的高级功能组件,这个模块可以集中开关。 DEFINES += __HIGHGRADE__ - #依赖网络模块 - !contains (DEFINES, __NETWORKSUPPORT__): DEFINES -= __HIGHGRADE__ contains (DEFINES, __HIGHGRADE__) { } @@ -420,7 +421,7 @@ defineTest(add_include_QQt){ header_path = $$1 #如果参数1为空,那么是用SDK里的路径 用于链接时包含头文件 #此处_bundle代表 mac下头文件在bundle里。 留意 - isEmpty(header_path)header_path=$$PWD + isEmpty(header_path):header_path=$$PWD command = #basic @@ -465,6 +466,7 @@ defineTest(add_include_QQt){ command += $${header_path}/exquisite/gifwidgets command += $${header_path}/exquisite/openglwidgets command += $${header_path}/exquisite/colorwidgets + command += $${header_path}/exquisite/osdwidgets command += $${header_path}/exquisite/mathml command += $${header_path}/exquisite/dmmu diff --git a/src/qqt_source.pri b/src/qqt_source.pri index 3d5e6273..c0c9bc5f 100644 --- a/src/qqt_source.pri +++ b/src/qqt_source.pri @@ -90,6 +90,11 @@ HEADERS += \ $$PWD/gui/qqtgui.h #widgets +SOURCES += \ + $$PWD/widgets/qqttitlebar.cpp +HEADERS += \ + $$PWD/widgets/qqttitlebar.h + SOURCES += \ $$PWD/widgets/qqtspinbox.cpp \ $$PWD/widgets/qqtdoublespinbox.cpp \ @@ -146,16 +151,9 @@ FORMS += \ #frame SOURCES += \ - $$PWD/frame/qqtsysteminfo.cpp + $$PWD/frame/qqtlineeditwithsearch.cpp HEADERS += \ - $$PWD/frame/qqtsysteminfo.h - -SOURCES += \ - $$PWD/frame/qqtlineeditwithsearch.cpp \ - $$PWD/frame/qqtosdwidget.cpp -HEADERS += \ - $$PWD/frame/qqtlineeditwithsearch.h \ - $$PWD/frame/qqtosdwidget.h + $$PWD/frame/qqtlineeditwithsearch.h SOURCES += \ $$PWD/frame/qqtmultipagetablewidget.cpp @@ -531,6 +529,7 @@ contains (DEFINES, __EXQUISITE__) { $$PWD/exquisite/openglwidgets/qqtopenglwindow.h } + #color widgets contains (DEFINES, __COLORWIDGETS__) { SOURCES += \ $$PWD/exquisite/colorwidgets/qqtcolorwidget.cpp \ @@ -539,6 +538,31 @@ contains (DEFINES, __EXQUISITE__) { $$PWD/exquisite/colorwidgets/qqtcolorwidget.h \ $$PWD/exquisite/colorwidgets/qqtcolorlabel.h } + + #on screen display widgets + contains (DEFINES, __OSDWIDGETS__) { + SOURCES += \ + $$PWD/exquisite/osdwidgets/qqtosdwidget.cpp + HEADERS += \ + $$PWD/exquisite/osdwidgets/qqtosdwidget.h + + SOURCES += \ + $$PWD/exquisite/osdwidgets/qqtosdframe.cpp + HEADERS += \ + $$PWD/exquisite/osdwidgets/qqtosdframe.h + + SOURCES += \ + $$PWD/exquisite/osdwidgets/qqtosdform.cpp + HEADERS += \ + $$PWD/exquisite/osdwidgets/qqtosdform.h + } +} + +contains (DEFINES, __HIGHGRADE__) { + SOURCES += \ + $$PWD/highgrade/qqtsysteminfo.cpp + HEADERS += \ + $$PWD/highgrade/qqtsysteminfo.h } include ($$PWD/qqt_3rdparty.pri) diff --git a/src/widgets/qqttitlebar.cpp b/src/widgets/qqttitlebar.cpp new file mode 100644 index 00000000..aa8509f0 --- /dev/null +++ b/src/widgets/qqttitlebar.cpp @@ -0,0 +1,236 @@ +#include +#include +#include +#include +#include +#include +#include "qqttitlebar.h" +#ifdef Q_OS_WIN +//#pragma comment(lib, "user32.lib") +#include +#endif +#include + +QQtTitleBar::QQtTitleBar ( QWidget* parent ) + : QQtWidget ( parent ) +{ + QWidget* win = this->window(); + + win->setWindowFlags ( Qt::FramelessWindowHint | win->windowFlags() ); + win->installEventFilter ( this ); + + //setStyleSheet ( "background-color:rgb(128, 126, 128);" ); + + //int extent = style()->pixelMetric ( QStyle::PM_TitleBarHeight ); + //setFixedHeight ( extent ); + + QHBoxLayout* pLayout = new QHBoxLayout ( this ); + m_pIconLabel = new QQtWidget ( this ); + m_pTitleLabel = new QLabel ( this ); + QSpacerItem* item = new QSpacerItem ( 20, 20, QSizePolicy::Expanding ); + m_pMinimizeButton = new QToolButton ( this ); + m_pMaximizeButton = new QToolButton ( this ); + m_pCloseButton = new QToolButton ( this ); + + //extent = style()->pixelMetric ( QStyle::PM_TitleBarButtonIconSize ); + //m_pIconLabel->setFixedSize ( QSize ( extent, extent ) ); + //m_pIconLabel->setScaledContents ( true ); + m_pIconLabel->setPixmap ( win->windowIcon().pixmap ( m_pIconLabel->size() ) ); + m_pIconLabel->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ); + + m_pTitleLabel->setText ( win->windowTitle() ); + m_pTitleLabel->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ); + + //extent = style()->pixelMetric ( QStyle::PM_TitleBarButtonSize ); + //m_pMinimizeButton->setFixedSize ( QSize ( extent, extent ) ); + //m_pMaximizeButton->setFixedSize ( QSize ( extent, extent ) ); + //m_pCloseButton->setFixedSize ( QSize ( extent, extent ) ); + + m_pMinimizeButton->setIcon ( style()-> standardIcon ( QStyle::SP_TitleBarMinButton ) ); + m_pMaximizeButton->setIcon ( style()-> standardIcon ( QStyle::SP_TitleBarMaxButton ) ); + m_pCloseButton->setIcon ( style()-> standardIcon ( QStyle::SP_TitleBarCloseButton ) ); + + m_pMinimizeButton->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ); + m_pMaximizeButton->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ); + m_pCloseButton->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ); + + m_pIconLabel->setObjectName ( "iconLabel" ); + m_pTitleLabel->setObjectName ( "titleLabel" ); + m_pMinimizeButton->setObjectName ( "minimizeButton" ); + m_pMaximizeButton->setObjectName ( "maximizeButton" ); + m_pCloseButton->setObjectName ( "closeButton" ); + + m_pMinimizeButton->setToolTip ( "Minimize" ); + m_pMaximizeButton->setToolTip ( "Maximize" ); + m_pCloseButton->setToolTip ( "Close" ); + + pLayout->addWidget ( m_pIconLabel ); + pLayout->addSpacing ( 5 ); + pLayout->addWidget ( m_pTitleLabel ); + pLayout->addSpacerItem ( item ); + pLayout->addWidget ( m_pMinimizeButton ); + pLayout->addWidget ( m_pMaximizeButton ); + pLayout->addWidget ( m_pCloseButton ); + pLayout->setSpacing ( 0 ); + pLayout->setContentsMargins ( 8, 1, 8, 1 ); + + setLayout ( pLayout ); + + connect ( m_pMinimizeButton, SIGNAL ( clicked ( bool ) ), this, SLOT ( onClicked() ) ); + connect ( m_pMaximizeButton, SIGNAL ( clicked ( bool ) ), this, SLOT ( onClicked() ) ); + connect ( m_pCloseButton, SIGNAL ( clicked ( bool ) ), this, SLOT ( onClicked() ) ); +} + +QQtTitleBar::~QQtTitleBar() +{ + +} + +void QQtTitleBar::setMinimizeVisible ( bool setting ) +{ + m_pMinimizeButton->setVisible ( setting ); +} + +void QQtTitleBar::setMaximizeVisible ( bool setting ) +{ + m_pMaximizeButton->setVisible ( setting ); +} + +void QQtTitleBar::mouseDoubleClickEvent ( QMouseEvent* event ) +{ + Q_UNUSED ( event ); + + emit m_pMaximizeButton->clicked(); +} + +void QQtTitleBar::mousePressEvent ( QMouseEvent* event ) +{ +#ifdef Q_OS_WIN + if ( ReleaseCapture() ) + { + QWidget* pWindow = this->window(); + if ( pWindow->isTopLevel() ) + { + SendMessage ( HWND ( pWindow->winId() ), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0 ); + } + } + event->ignore(); +#else + if ( event->button() == Qt::LeftButton ) + { + bMousePressed = true; + pressedPoint = event->globalPos(); + } + event->ignore(); +#endif + QQtWidget::mousePressEvent ( event ); +} + +void QQtTitleBar::mouseReleaseEvent ( QMouseEvent* event ) +{ +#ifdef Q_OS_WIN +#else + bMousePressed = false; + event->ignore(); +#endif + QQtWidget::mouseReleaseEvent ( event ); +} + +void QQtTitleBar::mouseMoveEvent ( QMouseEvent* event ) +{ +#ifdef Q_OS_WIN +#else + QWidget* win = window(); + if ( !win->isMaximized() ) + { + QPoint movePoint = event->globalPos() - pressedPoint; + QPoint widgetPos = win->pos(); + pressedPoint = event->globalPos(); + win->move ( widgetPos.x() + movePoint.x(), widgetPos.y() + movePoint.y() ); + } + event->ignore(); +#endif + QQtWidget::mouseMoveEvent ( event ); +} + +bool QQtTitleBar::eventFilter ( QObject* obj, QEvent* event ) +{ + switch ( event->type() ) + { + case QEvent::WindowTitleChange: + { + QWidget* pWidget = qobject_cast ( obj ); + if ( pWidget ) + { + m_pTitleLabel->setText ( pWidget->windowTitle() ); + return true; + } + } + case QEvent::WindowIconChange: + { + QWidget* pWidget = qobject_cast ( obj ); + if ( pWidget ) + { + //必须对外部Widget设置WindowIcon,而不是这个Widget的WindowIcon. + QIcon icon = pWidget->windowIcon(); + m_pIconLabel->setPixmap ( icon.pixmap ( m_pIconLabel->size() ) ); + return true; + } + } + case QEvent::WindowStateChange: + case QEvent::Resize: + { + int extent = m_pTitleLabel->size().height(); + m_pIconLabel->setMinimumSize ( extent, extent ); + updateMaximize(); + return true; + } + default: + break; + } + return QWidget::eventFilter ( obj, event ); +} + +void QQtTitleBar::onClicked() +{ + QToolButton* pButton = qobject_cast ( sender() ); + QWidget* pWindow = this->window(); + if ( pWindow->isTopLevel() ) + { + if ( pButton == m_pMinimizeButton ) + { + pWindow->showMinimized(); + } + else if ( pButton == m_pMaximizeButton ) + { + pWindow->isMaximized() ? pWindow->showNormal() : pWindow->showMaximized(); + } + else if ( pButton == m_pCloseButton ) + { + pWindow->close(); + } + } +} + +void QQtTitleBar::updateMaximize() +{ + QWidget* pWindow = this->window(); + if ( pWindow->isTopLevel() ) + { + bool bMaximize = pWindow->isMaximized(); + if ( bMaximize ) + { + m_pMaximizeButton->setToolTip ( tr ( "Restore" ) ); + m_pMaximizeButton->setProperty ( "maximizeProperty", "restore" ); + m_pMaximizeButton->setIcon ( style()-> standardIcon ( QStyle::SP_TitleBarNormalButton ) ); + } + else + { + m_pMaximizeButton->setProperty ( "maximizeProperty", "maximize" ); + m_pMaximizeButton->setToolTip ( tr ( "Maximize" ) ); + m_pMaximizeButton->setIcon ( style()-> standardIcon ( QStyle::SP_TitleBarMaxButton ) ); + } + + m_pMaximizeButton->setStyle ( QApplication::style() ); + } +} diff --git a/src/widgets/qqttitlebar.h b/src/widgets/qqttitlebar.h new file mode 100644 index 00000000..a8bb53f9 --- /dev/null +++ b/src/widgets/qqttitlebar.h @@ -0,0 +1,66 @@ +#ifndef QQTTITLEBAR +#define QQTTITLEBAR + +#include + +class QLabel; +class QToolButton; + +#include +#include + +class QQTSHARED_EXPORT QQtTitleBar : public QQtWidget +{ + Q_OBJECT + +public: + explicit QQtTitleBar ( QWidget* parent = 0 ); + ~QQtTitleBar(); + + void setMinimizeVisible ( bool setting ); + void setMaximizeVisible ( bool setting ); + + QQtWidget* iconLabel() { return m_pIconLabel; } + QLabel* titleLabel() { return m_pTitleLabel; } + QToolButton* minimizeButton() { return m_pMinimizeButton; } + QToolButton* maximizeButton() { return m_pMaximizeButton; } + QToolButton* closeButton() { return m_pCloseButton; } + +protected: + + // 双击标题栏进行界面的最大化/还原 + virtual void mouseDoubleClickEvent ( QMouseEvent* event ) override; + + // 进行鼠界面的拖动 + virtual void mousePressEvent ( QMouseEvent* event ) override; + + virtual void mouseReleaseEvent ( QMouseEvent* event ) override; + + virtual void mouseMoveEvent ( QMouseEvent* event ) override; + + // 设置界面标题与图标 + virtual bool eventFilter ( QObject* obj, QEvent* event ); + +private slots: + + // 进行最小化、最大化/还原、关闭操作 + void onClicked(); + +private: + + // 最大化/还原 + void updateMaximize(); + +private: + //QLabel会有角上遗漏颜色。 + QQtWidget* m_pIconLabel; + QLabel* m_pTitleLabel; + QToolButton* m_pMinimizeButton; + QToolButton* m_pMaximizeButton; + QToolButton* m_pCloseButton; + bool bMousePressed; + QPoint pressedPoint; + +}; + +#endif // QQTTITLEBAR diff --git a/test/QQtCustomTitleBarMainFormTest/AppRoot/logo.ico b/test/QQtCustomTitleBarMainFormTest/AppRoot/logo.ico new file mode 100644 index 00000000..6f3f15d7 Binary files /dev/null and b/test/QQtCustomTitleBarMainFormTest/AppRoot/logo.ico differ diff --git a/test/QQtCustomTitleBarMainFormTest/AppRoot/logo.png b/test/QQtCustomTitleBarMainFormTest/AppRoot/logo.png new file mode 100644 index 00000000..a4c48998 Binary files /dev/null and b/test/QQtCustomTitleBarMainFormTest/AppRoot/logo.png differ diff --git a/test/QQtCustomTitleBarMainFormTest/QQtCustomTitleBarMainFormTest.pro b/test/QQtCustomTitleBarMainFormTest/QQtCustomTitleBarMainFormTest.pro new file mode 100644 index 00000000..4bd05557 --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/QQtCustomTitleBarMainFormTest.pro @@ -0,0 +1,47 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-07-07T11:17:05 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = QQtCustomTitleBarMainFormTest +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 \ + mainform.cpp + +HEADERS += \ + mainwindow.h \ + mainform.h + +FORMS += \ + mainwindow.ui \ + mainform.ui + +CONFIG += mobility +MOBILITY = + +system("touch main.cpp") +include(../../multi-link/multi-link/add_base_manager.pri) +add_version (1,0,0,0) +add_deploy() +add_dependent_manager(QQt) +add_deploy_config($${PWD}/AppRoot) diff --git a/test/QQtCustomTitleBarMainFormTest/main.cpp b/test/QQtCustomTitleBarMainFormTest/main.cpp new file mode 100644 index 00000000..ed7d9413 --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/main.cpp @@ -0,0 +1,12 @@ +#include "mainform.h" +#include + +int main ( int argc, char* argv[] ) +{ + QQtApplication a ( argc, argv ); + + MainForm w; + w.show(); + + return a.exec(); +} diff --git a/test/QQtCustomTitleBarMainFormTest/mainform.cpp b/test/QQtCustomTitleBarMainFormTest/mainform.cpp new file mode 100644 index 00000000..0146b626 --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/mainform.cpp @@ -0,0 +1,22 @@ +#include "mainform.h" +#include "ui_mainform.h" +#include "qqtframelesshelper.h" + +MainForm::MainForm ( QWidget* parent ) : + QWidget ( parent ), + ui ( new Ui::MainForm ) +{ + ui->setupUi ( this ); + //如果需要鼠标可以移动窗体。 + QQtFramelessHelper* h = new QQtFramelessHelper ( this ); + h->addDragWidget ( this ); + + //这是使用QQtTitleBar的标准过程,请参见mainform.ui。 + setWindowIcon ( QIcon ( "logo.ico" ) ); + setWindowTitle ( "This is a main form test form." ); +} + +MainForm::~MainForm() +{ + delete ui; +} diff --git a/test/QQtCustomTitleBarMainFormTest/mainform.h b/test/QQtCustomTitleBarMainFormTest/mainform.h new file mode 100644 index 00000000..9a3da450 --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/mainform.h @@ -0,0 +1,22 @@ +#ifndef MAINFORM_H +#define MAINFORM_H + +#include + +namespace Ui { +class MainForm; +} + +class MainForm : public QWidget +{ + Q_OBJECT + +public: + explicit MainForm(QWidget *parent = 0); + ~MainForm(); + +private: + Ui::MainForm *ui; +}; + +#endif // MAINFORM_H diff --git a/test/QQtCustomTitleBarMainFormTest/mainform.ui b/test/QQtCustomTitleBarMainFormTest/mainform.ui new file mode 100644 index 00000000..100e9f3d --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/mainform.ui @@ -0,0 +1,63 @@ + + + MainForm + + + + 0 + 0 + 567 + 347 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16777215 + 30 + + + + + + + + + + + + MainWindow + QWidget +
mainwindow.h
+ 1 +
+ + QQtTitleBar + QWidget +
qqttitlebar.h
+ 1 +
+
+ + +
diff --git a/test/QQtCustomTitleBarMainFormTest/mainwindow.cpp b/test/QQtCustomTitleBarMainFormTest/mainwindow.cpp new file mode 100644 index 00000000..20bcc768 --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/mainwindow.cpp @@ -0,0 +1,15 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow ( QWidget* parent ) : + QMainWindow ( parent ), + ui ( new Ui::MainWindow ) +{ + ui->setupUi ( this ); + setWindowFlags ( Qt::Widget ); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/test/QQtCustomTitleBarMainFormTest/mainwindow.h b/test/QQtCustomTitleBarMainFormTest/mainwindow.h new file mode 100644 index 00000000..29bb970d --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/mainwindow.h @@ -0,0 +1,22 @@ +#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: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/test/QQtCustomTitleBarMainFormTest/mainwindow.ui b/test/QQtCustomTitleBarMainFormTest/mainwindow.ui new file mode 100644 index 00000000..b1eeaced --- /dev/null +++ b/test/QQtCustomTitleBarMainFormTest/mainwindow.ui @@ -0,0 +1,61 @@ + + + MainWindow + + + + 0 + 0 + 800 + 480 + + + + MainWindow + + + + + + 0 + 0 + 800 + 17 + + + + + 你好 + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + Yes? + + + + + No? + + + + + + + diff --git a/test/QQtOSDFormTest/AppRoot/logo.ico b/test/QQtOSDFormTest/AppRoot/logo.ico new file mode 100644 index 00000000..6f3f15d7 Binary files /dev/null and b/test/QQtOSDFormTest/AppRoot/logo.ico differ diff --git a/test/QQtOSDFormTest/AppRoot/logo.png b/test/QQtOSDFormTest/AppRoot/logo.png new file mode 100644 index 00000000..a4c48998 Binary files /dev/null and b/test/QQtOSDFormTest/AppRoot/logo.png differ diff --git a/test/QQtOSDFormTest/AppRoot/rose.png b/test/QQtOSDFormTest/AppRoot/rose.png new file mode 100644 index 00000000..a76d19ec Binary files /dev/null and b/test/QQtOSDFormTest/AppRoot/rose.png differ diff --git a/test/QQtOSDFormTest/QQtOSDFormTest.pro b/test/QQtOSDFormTest/QQtOSDFormTest.pro new file mode 100644 index 00000000..34cfc4b5 --- /dev/null +++ b/test/QQtOSDFormTest/QQtOSDFormTest.pro @@ -0,0 +1,51 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-07-07T19:03:15 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = QQtOSDFormTest +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 \ + framelessform.cpp \ + mainform.cpp + +HEADERS += \ + mainwindow.h \ + framelessform.h \ + mainform.h + +FORMS += \ + mainwindow.ui \ + framelessform.ui \ + mainform.ui + +CONFIG += mobility +MOBILITY = + + +system("touch main.cpp") +include(../../multi-link/multi-link/add_base_manager.pri) +add_version (1,0,0,0) +add_deploy() +add_dependent_manager(QQt) +add_deploy_config($${PWD}/AppRoot) diff --git a/test/QQtOSDFormTest/framelessform.cpp b/test/QQtOSDFormTest/framelessform.cpp new file mode 100644 index 00000000..f8f86c96 --- /dev/null +++ b/test/QQtOSDFormTest/framelessform.cpp @@ -0,0 +1,17 @@ +#include "framelessform.h" +#include "ui_framelessform.h" +#include + +FramelessForm::FramelessForm ( QWidget* parent ) : + QWidget ( parent ), + ui ( new Ui::FramelessForm ) +{ + ui->setupUi ( this ); + QQtFramelessHelper* h = new QQtFramelessHelper ( this ); + h->addDragWidget ( this ); +} + +FramelessForm::~FramelessForm() +{ + delete ui; +} diff --git a/test/QQtOSDFormTest/framelessform.h b/test/QQtOSDFormTest/framelessform.h new file mode 100644 index 00000000..2778ea9b --- /dev/null +++ b/test/QQtOSDFormTest/framelessform.h @@ -0,0 +1,23 @@ +#ifndef FRAMELESSFORM_H +#define FRAMELESSFORM_H + +#include + +namespace Ui { +class FramelessForm; +} + +//测试framelesshelper,即将废弃。 +class FramelessForm : public QWidget +{ + Q_OBJECT + +public: + explicit FramelessForm ( QWidget* parent = 0 ); + ~FramelessForm(); + +private: + Ui::FramelessForm* ui; +}; + +#endif // FRAMELESSFORM_H diff --git a/test/QQtOSDFormTest/framelessform.ui b/test/QQtOSDFormTest/framelessform.ui new file mode 100644 index 00000000..df6b94a7 --- /dev/null +++ b/test/QQtOSDFormTest/framelessform.ui @@ -0,0 +1,21 @@ + + + + + FramelessForm + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/test/QQtOSDFormTest/main.cpp b/test/QQtOSDFormTest/main.cpp new file mode 100644 index 00000000..e3e40198 --- /dev/null +++ b/test/QQtOSDFormTest/main.cpp @@ -0,0 +1,11 @@ +#include +#include "mainform.h" + +int main ( int argc, char* argv[] ) +{ + QQtApplication a ( argc, argv ); + MainForm w; + w.show(); + + return a.exec(); +} diff --git a/test/QQtOSDFormTest/mainform.cpp b/test/QQtOSDFormTest/mainform.cpp new file mode 100644 index 00000000..4f2bafe3 --- /dev/null +++ b/test/QQtOSDFormTest/mainform.cpp @@ -0,0 +1,26 @@ +#include "mainform.h" +#include "ui_mainform.h" +#include "qqtframelesshelper.h" + +MainForm::MainForm ( QWidget* parent ) : + QQtWidget ( parent ), + ui ( new Ui::MainForm ) +{ + ui->setupUi ( this ); + setAttribute ( Qt::WA_TranslucentBackground, true ); + + //如果需要鼠标可以移动窗体。 + //QQtFramelessHelper* h = new QQtFramelessHelper ( this ); + //h->addDragWidget ( this ); + + //这是使用QQtTitleBar的标准过程,请参见mainform.ui。 + setWindowIcon ( QIcon ( "logo.ico" ) ); + setWindowTitle ( "This is a main form test form." ); + + //setPixmap ( "rose.png" ); +} + +MainForm::~MainForm() +{ + delete ui; +} diff --git a/test/QQtOSDFormTest/mainform.h b/test/QQtOSDFormTest/mainform.h new file mode 100644 index 00000000..ab08240d --- /dev/null +++ b/test/QQtOSDFormTest/mainform.h @@ -0,0 +1,22 @@ +#ifndef MAINFORM_H +#define MAINFORM_H + +#include + +namespace Ui { +class MainForm; +} + +class MainForm : public QQtWidget +{ + Q_OBJECT + +public: + explicit MainForm ( QWidget* parent = 0 ); + ~MainForm(); + +private: + Ui::MainForm* ui; +}; + +#endif // MAINFORM_H diff --git a/test/QQtOSDFormTest/mainform.ui b/test/QQtOSDFormTest/mainform.ui new file mode 100644 index 00000000..64ec53cb --- /dev/null +++ b/test/QQtOSDFormTest/mainform.ui @@ -0,0 +1,63 @@ + + + MainForm + + + + 0 + 0 + 567 + 347 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16777215 + 30 + + + + + + + + + + + + QQtTitleBar + QWidget +
qqttitlebar.h
+ 1 +
+ + QQtOSDFrame + QWidget +
qqtosdframe.h
+ 1 +
+
+ + +
diff --git a/test/QQtOSDFormTest/mainwindow.cpp b/test/QQtOSDFormTest/mainwindow.cpp new file mode 100644 index 00000000..12d07c01 --- /dev/null +++ b/test/QQtOSDFormTest/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/test/QQtOSDFormTest/mainwindow.h b/test/QQtOSDFormTest/mainwindow.h new file mode 100644 index 00000000..29bb970d --- /dev/null +++ b/test/QQtOSDFormTest/mainwindow.h @@ -0,0 +1,22 @@ +#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: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/test/QQtOSDFormTest/mainwindow.ui b/test/QQtOSDFormTest/mainwindow.ui new file mode 100644 index 00000000..b72d0b45 --- /dev/null +++ b/test/QQtOSDFormTest/mainwindow.ui @@ -0,0 +1,21 @@ + + MainWindow + + + + 0 + 0 + 800 + 480 + + + + MainWindow + + + + + + + +