1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

update gif test

This commit is contained in:
tianduanrui 2018-01-22 20:00:51 +08:00
parent 639f086896
commit 2d73a98139
19 changed files with 207 additions and 42 deletions

View File

@ -52,7 +52,7 @@ defineReplace(deploy_app_on_linux) {
return ($$command) return ($$command)
} }
defineReplace(deploy_app_for_android) { defineReplace(deploy_app_on_android) {
#need QQT_BUILD_PWD #need QQT_BUILD_PWD
command = command =
@ -106,7 +106,7 @@ contains(CONFIG, deploy_app) {
} else: contains(QKIT_PRIVATE, macOS) { } else: contains(QKIT_PRIVATE, macOS) {
QMAKE_POST_LINK += $$deploy_app_on_mac() QMAKE_POST_LINK += $$deploy_app_on_mac()
} else: contains(QKIT_PRIVATE, ANDROID||ANDROIDX86) { } else: contains(QKIT_PRIVATE, ANDROID||ANDROIDX86) {
QMAKE_POST_LINK += $$deploy_app_on_android() #QMAKE_POST_LINK += $$deploy_app_on_android()
} else { } else {
QMAKE_POST_LINK += $$deploy_app_on_linux() QMAKE_POST_LINK += $$deploy_app_on_linux()
} }

View File

@ -62,6 +62,8 @@ contains(CONFIG, app_copy_config) {
QMAKE_POST_LINK += $$copy_config("$${APP_CONFIG_PWD}\\*") QMAKE_POST_LINK += $$copy_config("$${APP_CONFIG_PWD}\\*")
} else: contains(QKIT_PRIVATE, macOS) { } else: contains(QKIT_PRIVATE, macOS) {
QMAKE_POST_LINK += $$copy_config_on_mac("$${APP_CONFIG_PWD}/*") QMAKE_POST_LINK += $$copy_config_on_mac("$${APP_CONFIG_PWD}/*")
} else: contains(QKIT_PRIVATE, ANDROID||ANDROIDX86) {
#QMAKE_POST_LINK += $$deploy_app_on_android()
} else { } else {
QMAKE_POST_LINK += $$copy_config("$${APP_CONFIG_PWD}/*") QMAKE_POST_LINK += $$copy_config("$${APP_CONFIG_PWD}/*")
} }

View File

@ -8,6 +8,8 @@ QQtGifLabel::QQtGifLabel ( QWidget* parent ) : QQtLabel ( parent )
void QQtGifLabel::setGifFile ( QString gifFile ) void QQtGifLabel::setGifFile ( QString gifFile )
{ {
m_movie->stop();
m_movie->setFileName ( gifFile ); m_movie->setFileName ( gifFile );
m_movie->start(); m_movie->start();
} }

View File

@ -11,6 +11,8 @@ QQtGifWidget::QQtGifWidget ( QWidget* parent ) : QQtWidget ( parent )
void QQtGifWidget::setGifFile ( QString gifFile ) void QQtGifWidget::setGifFile ( QString gifFile )
{ {
m_movie->stop();
m_movie->setFileName ( gifFile ); m_movie->setFileName ( gifFile );
m_movie->start(); m_movie->start();
m_frameTimer->setInterval ( m_movie->speed() ); m_frameTimer->setInterval ( m_movie->speed() );

View File

@ -117,6 +117,7 @@ enum
#define CONFIG_PATH "./conf" #define CONFIG_PATH "./conf"
#define LOG_PATH "./log" #define LOG_PATH "./log"
#define AV_PATH "./res" #define AV_PATH "./res"
#define SKIN_PATH "./skin"
#define TABLE_LIBRARY "Library" #define TABLE_LIBRARY "Library"
#define TABLE_METHOD "Method" #define TABLE_METHOD "Method"

View File

@ -17,85 +17,92 @@ tagBtnIconTable::tagBtnIconTable()
pixmap[BTN_DISABLE] = "./skin/default/bt_bt_disable.png"; pixmap[BTN_DISABLE] = "./skin/default/bt_bt_disable.png";
} }
QString tagBtnIconTable::pixMap(int index) QString tagBtnIconTable::pixMap ( int index )
{ {
if (index < 0 || index + 1 > BTN_MAX) if ( index < 0 || index + 1 > BTN_MAX )
return pixmap[BTN_NORMAL]; return pixmap[BTN_NORMAL];
return pixmap[index]; return pixmap[index];
} }
void tagBtnIconTable::setPixMap(int index, QString pix) void tagBtnIconTable::setPixMap ( int index, QString pix )
{ {
if (index < 0 || index + 1 > BTN_MAX) if ( index < 0 || index + 1 > BTN_MAX )
return; return;
pixmap[index] = pix; pixmap[index] = pix;
} }
void tagBtnIconTable::initNormal(QString normal, QString press) void tagBtnIconTable::initNormal ( QString normal, QString press )
{ {
if (!normal.isEmpty()) if ( !normal.isEmpty() )
pixmap[BTN_NORMAL] = normal; pixmap[BTN_NORMAL] = normal;
if (!press.isEmpty()) if ( !press.isEmpty() )
pixmap[BTN_PRESS] = press; pixmap[BTN_PRESS] = press;
} }
void tagBtnIconTable::initCheck(QString uncheck, QString check) void tagBtnIconTable::initCheck ( QString uncheck, QString check )
{ {
if (!uncheck.isEmpty()) if ( !uncheck.isEmpty() )
pixmap[BTN_UNCHECK] = uncheck; pixmap[BTN_UNCHECK] = uncheck;
if (!check.isEmpty()) if ( !check.isEmpty() )
pixmap[BTN_CHECK] = check; pixmap[BTN_CHECK] = check;
} }
void tagBtnIconTable::initOther(QString hover, QString disable) void tagBtnIconTable::initOther ( QString hover, QString disable )
{ {
if (!hover.isEmpty()) if ( !hover.isEmpty() )
pixmap[BTN_HOVER] = hover; pixmap[BTN_HOVER] = hover;
if (!disable.isEmpty()) if ( !disable.isEmpty() )
pixmap[BTN_DISABLE] = disable; pixmap[BTN_DISABLE] = disable;
} }
QString& tagBtnIconTable::operator [](int index) QString& tagBtnIconTable::operator [] ( int index )
{ {
if (index < 0 || index >= BTN_MAX) if ( index < 0 || index >= BTN_MAX )
return pixmap[0]; return pixmap[0];
return pixmap[index]; return pixmap[index];
} }
const QString& tagBtnIconTable::operator[](int index) const const QString& tagBtnIconTable::operator[] ( int index ) const
{ {
if (index < 0 || index >= BTN_MAX) if ( index < 0 || index >= BTN_MAX )
return pixmap[0]; return pixmap[0];
return pixmap[index]; return pixmap[index];
} }
void moveCenter(QWidget* w) void moveCenter ( QWidget* w )
{ {
int x1 = 0, y1 = 0; int x1 = 0, y1 = 0;
x1 = (QApplication::desktop()->availableGeometry().width() x1 = ( QApplication::desktop()->availableGeometry().width()
- w->width()) / 2; - w->width() ) / 2;
y1 = (QApplication::desktop()->availableGeometry().height() y1 = ( QApplication::desktop()->availableGeometry().height()
- w->height()) / 2; - w->height() ) / 2;
w->move(x1, y1); w->move ( x1, y1 );
return; return;
} }
void moveRight(QWidget* w) void moveRight ( QWidget* w )
{ {
w->move((QApplication::desktop()->width() - w->width()), 0); w->move ( ( QApplication::desktop()->width() - w->width() ), 0 );
} }
void moveFull ( QWidget* w )
{
QRect rect0 = QApplication::desktop()->availableGeometry();
w->setGeometry ( rect0 );
w->move ( rect0.left(), rect0.top() );
}

View File

@ -41,19 +41,19 @@ typedef struct QQTSHARED_EXPORT tagBtnIconTable
QString pixmap[BTN_MAX]; QString pixmap[BTN_MAX];
tagBtnIconTable(); tagBtnIconTable();
QString pixMap(int index); QString pixMap ( int index );
void setPixMap(int index, QString pix); void setPixMap ( int index, QString pix );
void initNormal(QString normal, QString press); void initNormal ( QString normal, QString press );
void initCheck(QString uncheck, QString check); void initCheck ( QString uncheck, QString check );
void initOther(QString hover, QString disable); void initOther ( QString hover, QString disable );
const QString& operator[](int index) const; const QString& operator[] ( int index ) const;
QString& operator [](int index); QString& operator [] ( int index );
} TBtnIconTable; } TBtnIconTable;
QQTSHARED_EXPORT void moveCenter(QWidget* w); QQTSHARED_EXPORT void moveCenter ( QWidget* w );
QQTSHARED_EXPORT void moveRight ( QWidget* w );
QQTSHARED_EXPORT void moveRight(QWidget* w); QQTSHARED_EXPORT void moveFull ( QWidget* w );

View File

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.example.giftest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="GifTest" android:icon="@drawable/icon">
<activity android:configChanges="navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="测试Gif图片" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="giftest"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,25 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.9</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
not be edited manually. -->
<array name="bundled_libs">
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="bundled_in_lib">
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
</array>
<array name="bundled_in_assets">
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
</array>
</resources>

View File

@ -33,9 +33,6 @@ HEADERS += \
FORMS += \ FORMS += \
giftestdialog.ui giftestdialog.ui
CONFIG += mobility
MOBILITY =
#促使qqt_deploy_config配置执行没有这个变量不执行 #促使qqt_deploy_config配置执行没有这个变量不执行
APP_CONFIG_PWD = $${PWD}/AppRoot APP_CONFIG_PWD = $${PWD}/AppRoot
win32 { win32 {
@ -45,3 +42,15 @@ win32 {
#促使编译源代码qmake pri配置里面的QMAKE_XX_LINK命令就会执行 #促使编译源代码qmake pri配置里面的QMAKE_XX_LINK命令就会执行
system("touch main.cpp") system("touch main.cpp")
include(../../src/app_base_manager.pri) include(../../src/app_base_manager.pri)
contains(QKIT_PRIVATE, ANDROID||ANDROIDX86) {
CONFIG += mobility
MOBILITY =
DISTFILES += \
$${PWD}/android/AndroidManifest.xml
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
}
RESOURCES += \
giftest.qrc

6
test/giftest/giftest.qrc Normal file
View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>AppRoot/waiting.gif</file>
<file>AppRoot/yun.png</file>
</qresource>
</RCC>

View File

@ -1,14 +1,43 @@
#include "giftestdialog.h" #include "giftestdialog.h"
#include "ui_giftestdialog.h" #include "ui_giftestdialog.h"
#if defined (__ANDROID__) || defined (__ANDROIDX86__)
#define res(file) QString("%1/%2").arg("://AppRoot").arg(file)
#else
#define res(file) QString("%1/%2").arg(".").arg(file)
#endif
GifTestDialog::GifTestDialog ( QWidget* parent ) : GifTestDialog::GifTestDialog ( QWidget* parent ) :
QDialog ( parent ), QDialog ( parent ),
ui ( new Ui::GifTestDialog ) ui ( new Ui::GifTestDialog )
{ {
ui->setupUi ( this ); ui->setupUi ( this );
//使用res函数以前代码量如此巨大。
#if defined (__ANDROID__) || defined (__ANDROIDX86__)
#if 0
//如果apk文件被删除了呢
ui->labelGif->setGifFile ( "assets:/waiting.gif" );
ui->widgetGif->setGifFile ( "assets:/waiting.gif" );
ui->widgetQQt->setPixmap ( "assets:/yun.png" );
#else
ui->labelGif->setGifFile ( "://AppRoot/waiting.gif" );
ui->widgetGif->setGifFile ( "://AppRoot/waiting.gif" );
ui->widgetQQt->setPixmap ( "://AppRoot/yun.png" );
#endif
#else
//不兼容android....
ui->labelGif->setGifFile ( "./waiting.gif" ); ui->labelGif->setGifFile ( "./waiting.gif" );
ui->widgetGif->setGifFile ( "./waiting.gif" ); ui->widgetGif->setGifFile ( "./waiting.gif" );
ui->widgetQQt->setPixmap ( "./yun.png" ); ui->widgetQQt->setPixmap ( "./yun.png" );
#endif
//使用了res函数以后 代码得到了极大简化
pline() << res ( "waiting.gif" );
ui->labelGif->setGifFile ( res ( "waiting.gif" ) );
ui->widgetGif->setGifFile ( res ( "waiting.gif" ) );
ui->widgetQQt->setPixmap ( res ( "yun.png" ) );
pline() << QMovie::supportedFormats(); pline() << QMovie::supportedFormats();
} }

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>948</width> <width>698</width>
<height>650</height> <height>330</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

View File

@ -1,5 +1,7 @@
#include "giftestdialog.h" #include "giftestdialog.h"
#include <qqtapplication.h> #include <qqtapplication.h>
#include "qqtcore.h"
#include "qqtwidgets.h"
int main ( int argc, char* argv[] ) int main ( int argc, char* argv[] )
{ {
@ -8,6 +10,7 @@ int main ( int argc, char* argv[] )
GifTestDialog w; GifTestDialog w;
w.show(); w.show();
moveFull ( &w );
return a.exec(); return a.exec();
} }