Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
591a2a52
Commit
591a2a52
authored
Aug 25, 2021
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some methods for HttpDlg
parent
0ab1dd7a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
93 additions
and
143 deletions
+93
-143
HttpDlg.cpp
jlib/qt/View/HttpDlg.cpp
+39
-9
HttpDlg.h
jlib/qt/View/HttpDlg.h
+9
-3
jlibqt.qrc
jlib/qt/jlibqt.qrc
+1
-0
qt.rc
jlib/qt/qt.rc
+0
-60
qt.vcxproj
jlib/qt/qt.vcxproj
+5
-6
qt.vcxproj.filters
jlib/qt/qt.vcxproj.filters
+1
-9
resource1.h
jlib/qt/resource1.h
+0
-14
main.cpp
test/qt_test/main.cpp
+14
-3
qt_test.cpp
test/qt_test/qt_test.cpp
+15
-15
qt_test.vcxproj
test/qt_test/qt_test.vcxproj
+3
-7
qt_test.vcxproj.filters
test/qt_test/qt_test.vcxproj.filters
+0
-17
test.sln
test/test.sln
+6
-0
No files found.
jlib/qt/View/HttpDlg.cpp
View file @
591a2a52
...
...
@@ -11,22 +11,24 @@ using namespace jlib::qt;
//namespace HBVideoPlatform {
//namespace common {
HttpDlg
::
HttpDlg
(
QWidget
*
parent
,
HttpDlgGif
gif
,
int
timeout
)
HttpDlg
::
HttpDlg
(
QWidget
*
parent
,
int
timeout
,
HttpDlgGif
gif
)
:
QDialog
(
parent
)
,
gif_
(
gif
)
,
time_out_sec_
(
timeout
)
,
gif_
(
gif
)
{
setWindowModality
(
Qt
::
WindowModal
);
setWindowFlags
(
Qt
::
FramelessWindowHint
);
setWindowFlags
(
Qt
::
FramelessWindowHint
|
Qt
::
SubWindow
);
if
(
!
parent
)
{
setAttribute
(
Qt
::
WA_TranslucentBackground
);
}
if
(
gif
==
HttpDlgGif
::
Spinner1s_200px
)
{
/*if (gif == HttpDlgGif::Spinner1s_200px_gray
) {
setFixedSize(200, 200);
} else {
setFixedSize(630, 637);
}
}*/
setFixedSize
(
200
,
200
);
label_
=
new
QLabel
(
this
);
label_
->
resize
(
width
(),
height
());
...
...
@@ -92,13 +94,41 @@ void HttpDlg::post(const QNetworkRequest & request, const QByteArray & data)
run
();
}
void
HttpDlg
::
put
(
const
QNetworkRequest
&
request
,
const
QByteArray
&
data
)
{
if
(
connection_
)
{
disconnect
(
connection_
);
}
connection_
=
connect
(
mgr
,
&
QNetworkAccessManager
::
finished
,
this
,
&
HttpDlg
::
onFinished
);
reply_
=
mgr
->
put
(
request
,
data
);
run
();
}
void
HttpDlg
::
patch
(
const
QNetworkRequest
&
request
,
const
QByteArray
&
data
)
{
if
(
connection_
)
{
disconnect
(
connection_
);
}
connection_
=
connect
(
mgr
,
&
QNetworkAccessManager
::
finished
,
this
,
&
HttpDlg
::
onFinished
);
reply_
=
mgr
->
sendCustomRequest
(
request
,
"PATCH"
,
data
);
run
();
}
void
HttpDlg
::
deleteResource
(
const
QNetworkRequest
&
request
)
{
if
(
connection_
)
{
disconnect
(
connection_
);
}
connection_
=
connect
(
mgr
,
&
QNetworkAccessManager
::
finished
,
this
,
&
HttpDlg
::
onFinished
);
reply_
=
mgr
->
deleteResource
(
request
);
run
();
}
QString
HttpDlg
::
getGifPath
()
{
switch
(
gif_
)
{
case
HttpDlg
:
:
HttpDlgGif
::
Spinner1s_200px
:
return
":/jlibqt/Resources/Spinner-1s-200px.gif"
;
break
;
default
:
break
;
case
HttpDlg
:
:
HttpDlgGif
::
Spinner1s_200px_gray
:
return
":/jlibqt/Resources/Spinner-1s-200px_gray.gif"
;
case
HttpDlg
:
:
HttpDlgGif
::
Spinner1s_200px_blue
:
return
":/jlibqt/Resources/Spinner-1s-200px.gif"
;
}
return
QString
();
}
...
...
jlib/qt/View/HttpDlg.h
View file @
591a2a52
...
...
@@ -20,11 +20,12 @@ class HttpDlg : public QDialog
public
:
enum
class
HttpDlgGif
{
Spinner1s_200px
,
Spinner1s_200px_gray
,
Spinner1s_200px_blue
,
};
HttpDlg
(
QWidget
*
parent
=
nullptr
,
HttpDlgGif
gif
=
HttpDlgGif
::
Spinner1s_200px
,
int
timeOut
=
10
);
HttpDlg
(
QWidget
*
parent
=
nullptr
,
int
timeOut
=
10
,
HttpDlgGif
gif
=
HttpDlgGif
::
Spinner1s_200px_gray
);
~
HttpDlg
();
void
get
(
const
QUrl
&
url
);
...
...
@@ -32,6 +33,11 @@ public:
void
post
(
const
QUrl
&
url
);
void
post
(
const
QNetworkRequest
&
request
);
void
post
(
const
QNetworkRequest
&
request
,
const
QByteArray
&
data
);
void
put
(
const
QNetworkRequest
&
request
,
const
QByteArray
&
data
=
{});
void
patch
(
const
QNetworkRequest
&
request
,
const
QByteArray
&
data
=
{});
void
deleteResource
(
const
QNetworkRequest
&
request
);
std
::
error_code
get_result
()
const
{
return
result_
;
}
Json
::
Value
getRoot
()
const
{
return
root_
;
}
...
...
@@ -100,7 +106,7 @@ private:
QLabel
*
label_
=
{};
QLabel
*
elapse_
=
{};
HttpDlgGif
gif_
=
HttpDlgGif
::
Spinner1s_200px
;
HttpDlgGif
gif_
=
HttpDlgGif
::
Spinner1s_200px
_gray
;
QElapsedTimer
timer_
=
{};
};
...
...
jlib/qt/qt.qrc
→
jlib/qt/
jlib
qt.qrc
View file @
591a2a52
<RCC>
<qresource prefix="/jlibqt">
<file>Resources/Spinner-1s-200px.gif</file>
<file>Resources/Spinner-1s-200px_gray.gif</file>
</qresource>
</RCC>
jlib/qt/qt.rc
deleted
100644 → 0
View file @
0ab1dd7a
// Microsoft Visual C++ generated resource script.
//
#include "resource1.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Ӣ() resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 4, 2
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource1.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Ӣ() resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
jlib/qt/qt.vcxproj
View file @
591a2a52
...
...
@@ -55,7 +55,7 @@
</PropertyGroup>
<PropertyGroup
Label=
"QtSettings"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<QtInstall>
5.9.8
</QtInstall>
<QtModules>
core;gui;widgets
</QtModules>
<QtModules>
core;gui;
network;
widgets
</QtModules>
</PropertyGroup>
<ImportGroup
Condition=
"Exists('$(QtMsBuild)\qt.props')"
>
<Import
Project=
"$(QtMsBuild)\qt.props"
/>
...
...
@@ -76,6 +76,9 @@
<OutputFile>
$(OutDir)\$(ProjectName).lib
</OutputFile>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>
%(AdditionalDependencies)
</AdditionalDependencies>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
...
...
@@ -112,7 +115,6 @@
<ItemGroup>
<ClInclude
Include=
"Model\HttpDlgErrorCode.h"
/>
<ClInclude
Include=
"resource.h"
/>
<ClInclude
Include=
"resource1.h"
/>
<ClInclude
Include=
"Util\QRunGuard.h"
/>
<QtMoc
Include=
"View\HttpDlg.h"
/>
<QtMoc
Include=
"View\ProgressDialog.h"
/>
...
...
@@ -139,10 +141,7 @@
<QtUic
Include=
"View\ProgressDialog.ui"
/>
</ItemGroup>
<ItemGroup>
<ResourceCompile
Include=
"qt.rc"
/>
</ItemGroup>
<ItemGroup>
<QtRcc
Include=
"qt.qrc"
/>
<QtRcc
Include=
"jlibqt.qrc"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Condition=
"Exists('$(QtMsBuild)\qt.targets')"
>
...
...
jlib/qt/qt.vcxproj.filters
View file @
591a2a52
...
...
@@ -115,9 +115,6 @@
<ClInclude
Include=
"Util\QRunGuard.h"
>
<Filter>
Util
</Filter>
</ClInclude>
<ClInclude
Include=
"resource1.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"Model\HttpDlgErrorCode.h"
>
<Filter>
Model
</Filter>
</ClInclude>
...
...
@@ -165,12 +162,7 @@
</QtUic>
</ItemGroup>
<ItemGroup>
<ResourceCompile
Include=
"qt.rc"
>
<Filter>
Resource Files
</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<QtRcc
Include=
"qt.qrc"
>
<QtRcc
Include=
"jlibqt.qrc"
>
<Filter>
Resource Files
</Filter>
</QtRcc>
</ItemGroup>
...
...
jlib/qt/resource1.h
deleted
100644 → 0
View file @
0ab1dd7a
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by qt.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
test/qt_test/main.cpp
View file @
591a2a52
...
...
@@ -3,15 +3,26 @@
//#include "../../jlib/log2.h"
#include "../../jlib/qt/QtDebug.h"
#include "../../jlib/qt/monitor.h"
#include "../../jlib/qt/View/HttpDlg.h"
using
namespace
jlib
::
qt
;
int
main
(
int
argc
,
char
*
argv
[])
{
QApplication
a
(
argc
,
argv
);
//jlib::init_logger(L"qt_test");
jlib
::
qt
::
test_monitor
();
//jlib::qt::test_monitor();
//qt_test w;
//w.show();
Q_INIT_RESOURCE
(
jlibqt
);
HttpDlg
dlg
(
nullptr
,
10
);
QString
url
=
"https://local.hb3344.com/api/test/version"
;
dlg
.
get
(
url
);
qt_test
w
;
w
.
show
();
return
a
.
exec
();
}
test/qt_test/qt_test.cpp
View file @
591a2a52
...
...
@@ -2,21 +2,21 @@
#include <qlayout.h>
#include "../../jlib/log2.h"
#include "qt/ErrorCode.h"
#include "qt/QtDebug.h"
#include "qt/QtDebugOutput.h"
#include "qt/QtPathHelper.h"
#include "qt/QtStylesheet.h"
#include "qt/QtUtils.h"
#include "qt/Ctrl/ThreadCtrl.h"
#include "qt/Model/ThreadModel.h"
#include "
qt/View/BgColorBtn
.h"
#include "
qt/View/HttpDlg
.h"
#include "
qt/View/HttpDlgErrorCode
.h"
#include "qt/View/IconBtn.h"
#include "qt/View/LoadingView.h"
#include "
qt/View/PageTitle
.h"
#include "qt/View/RndButton.h"
#include "
../../jlib/
qt/ErrorCode.h"
#include "
../../jlib/
qt/QtDebug.h"
#include "
../../jlib/
qt/QtDebugOutput.h"
#include "
../../jlib/
qt/QtPathHelper.h"
#include "
../../jlib/
qt/QtStylesheet.h"
#include "
../../jlib/
qt/QtUtils.h"
#include "
../../jlib/
qt/Ctrl/ThreadCtrl.h"
#include "
../../jlib/
qt/Model/ThreadModel.h"
#include "
../../jlib/qt/Model/HttpDlgErrorCode
.h"
#include "
../../jlib/qt/View/BgColorBtn
.h"
#include "
../../jlib/qt/View/HttpDlg
.h"
#include "
../../jlib/
qt/View/IconBtn.h"
#include "
../../jlib/
qt/View/LoadingView.h"
#include "
../../jlib/qt/View/TitleBar
.h"
#include "
../../jlib/
qt/View/RndButton.h"
using
namespace
jlib
::
qt
;
...
...
test/qt_test/qt_test.vcxproj
View file @
591a2a52
...
...
@@ -67,12 +67,14 @@
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
<RuntimeLibrary>
MultiThreadedDebugDLL
</RuntimeLibrary>
<TreatWChar_tAsBuiltInType>
true
</TreatWChar_tAsBuiltInType>
<AdditionalIncludeDirectories>
$(DEVLIBS)\jlib;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
$(DEVLIBS)\jlib;
$(DEVLIBS)\json\jsoncpp-1.9.4-install\include;
%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<OutputFile>
$(OutDir)\$(ProjectName).exe
</OutputFile>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<AdditionalDependencies>
jlibqt.lib;$(DEVLIBS)\json\jsoncpp-1.9.4-install\bin\Debug\jsoncpp.lib;%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalLibraryDirectories>
$(OutDir);%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
...
...
@@ -89,9 +91,6 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_reader.cpp"
/>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_value.cpp"
/>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_writer.cpp"
/>
<ClCompile
Include=
"main.cpp"
/>
<ClCompile
Include=
"qt_test.cpp"
/>
</ItemGroup>
...
...
@@ -104,9 +103,6 @@
<ItemGroup>
<QtRcc
Include=
"qt_test.qrc"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Condition=
"Exists('$(QtMsBuild)\qt.targets')"
>
<Import
Project=
"$(QtMsBuild)\qt.targets"
/>
...
...
test/qt_test/qt_test.vcxproj.filters
View file @
591a2a52
...
...
@@ -23,9 +23,6 @@
<Extensions>
qrc;*
</Extensions>
<ParseFiles>
false
</ParseFiles>
</Filter>
<Filter
Include=
"jsoncpp"
>
<UniqueIdentifier>
{0ea00850-28a6-45f9-af68-6c656c3572f1}
</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"main.cpp"
>
...
...
@@ -34,15 +31,6 @@
<ClCompile
Include=
"qt_test.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_reader.cpp"
>
<Filter>
jsoncpp
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_value.cpp"
>
<Filter>
jsoncpp
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_writer.cpp"
>
<Filter>
jsoncpp
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc
Include=
"qt_test.h"
>
...
...
@@ -59,9 +47,4 @@
<Filter>
Resource Files
</Filter>
</QtRcc>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json.h"
>
<Filter>
jsoncpp
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
test/test.sln
View file @
591a2a52
...
...
@@ -373,6 +373,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjinfo", "libjinfo\libjin
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjinfomt", "libjinfomt\libjinfomt.vcxproj", "{E8551DB0-274F-493A-88AF-7383E47F49FA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{BCF77277-B4F8-49CF-B213-D8086F3BCEFD}"
ProjectSection(SolutionItems) = preProject
..\jlib\misc\sudoku.h = ..\jlib\misc\sudoku.h
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
...
...
@@ -1218,6 +1223,7 @@ Global
{0E83FBE2-4696-41AD-9A5F-55B1401AB77C} = {0E6598D3-602D-4552-97F7-DC5AB458D553}
{441E6793-7CDA-4D51-81BD-7A38520F1C1D} = {729A65CE-3F07-4C2E-ACDC-F9EEC6477F2A}
{E8551DB0-274F-493A-88AF-7383E47F49FA} = {729A65CE-3F07-4C2E-ACDC-F9EEC6477F2A}
{BCF77277-B4F8-49CF-B213-D8086F3BCEFD} = {42703978-A988-403D-9723-E35527FA8A07}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A8EBEA58-739C-4DED-99C0-239779F57D5D}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment