修复导航栏问题

master
Mike Solar 2023-08-03 16:16:02 +08:00
parent 6fa68053bb
commit 4220083ac3
9 changed files with 1393 additions and 1325 deletions

Binary file not shown.

View File

@ -11,6 +11,7 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButto
this->url = buttonStruct.url;
this->logo=buttonStruct.image;
this->logo_cover = buttonStruct.image_cover;
this->background_color = buttonStruct.background_color;
QString style = "background-color:";
style += buttonStruct.background_color;
style += ";border:none;";

View File

@ -51,6 +51,7 @@ protected:
private:
QColor text_color;
QColor text_cover_color;
QString background_color;
QList<MyButton *> *buttons;
QImage *logo;
QImage *logo_cover;

View File

@ -9,15 +9,15 @@
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Source Files\Translation Files">
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Translation Files">
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QtLastBackgroundBuild>2023-08-01T03:05:45.8140795Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-08-03T08:03:42.8435391Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QtLastBackgroundBuild>2023-08-01T03:05:46.4588999Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-08-03T08:03:43.2818738Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -18,6 +18,23 @@
#pragma comment(lib, "Qt5Svg.lib")
#endif
QString url_param;
void ConvertImageToTransparent(QImage &img)
{
img = img.convertToFormat(QImage::Format_ARGB32);
union myrgb
{
uint rgba;
uchar rgba_bits[4];
};
myrgb* mybits = (myrgb*)img.bits();
int len = img.width()*img.height();
while (len--> 0)
{
mybits->rgba_bits[3] = (mybits->rgba == 0xFFFFFFFF) ? 0 : 255;
mybits++;
}
}
NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) :
QWidget(parent), ui(new Ui::NavBar) {
ui->setupUi(this);
@ -118,6 +135,7 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
timer.stop();
buffer = new QByteArray;
delete request_logo;
reply->close();
if (downloadSuccess == true) {
*buffer = reply->readAll();
logo = new QImage();
@ -137,10 +155,17 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
break;
}
*buffer = reply->readAll();
QSvgRenderer *render_image = new QSvgRenderer(*buffer);
QImage *image = new QImage(200, 200, QImage::Format_ARGB32);
QPainter painter_image(image);
painter_image.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
painter_image.fillRect(rect(), Qt::transparent); // 填充透明色
painter_image.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值
render_image->render(&painter_image);
buffer->clear();
reply->close();
QUrl url_image_cover(button.img_cover);
QNetworkRequest *request_image_cover = new QNetworkRequest(url_image_cover);
@ -151,11 +176,19 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
if (!downloadSuccess) {
break;
}
eventLoop.exec();
*buffer = reply->readAll();
qDebug() << *buffer;
QSvgRenderer *render_image_cover = new QSvgRenderer(*buffer);
QImage *image_cover = new QImage(200, 200, QImage::Format_ARGB32);
QPainter painter_image_cover(image_cover);
painter_image_cover.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
painter_image_cover.fillRect(rect(), Qt::transparent); // 填充透明色
painter_image_cover.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值
render_image_cover->render(&painter_image_cover);
buffer->clear();
reply->close();
ButtonStruct buttonStruct;
buttonStruct.image = image;
buttonStruct.image_cover = image_cover;

View File

@ -31,8 +31,24 @@
#endif
#pragma comment(lib,"comsuppw.lib")
//读取注册表获取MachineUUID
bool IsWin11AndLater()
{
//Windows 10 从内部版本 10240 开始,以内部版本 19044 结束。Windows 11 从内部版本 22000 开始,那么:
//Environment.OSVersion.Version.Build >= 22000;
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW);
OSVERSIONINFOEXW osInfo;
*(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
if (NULL != RtlGetVersion)
{
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
RtlGetVersion(&osInfo);
return (osInfo.dwMajorVersion >= 10 && osInfo.dwBuildNumber >= 22000);
}
return false;
}
RequestBodyBase::RequestBodyBase(){
wchar_t unix_time[65]={0};
wsprintf(unix_time,L"%ld",std::time(0));
@ -72,36 +88,50 @@ RequestBodyBase::RequestBodyBase(){
}
//获取操作系统版本
this->os="Windows";
OSVERSIONINFOEX os;
OSVERSIONINFOEXW os;
os.dwOSVersionInfoSize=sizeof(os);
GetVersionEx((OSVERSIONINFO *)&os);
switch(os.dwMajorVersion){//主版本号
case 5: //不兼容Windows 2000因此5.x一定是Windows XP
os_version="Windows XP";
break;
case 6:
switch(os.dwMinorVersion){ //次版本号
case 0:
os_version="Windows Vista or Windows Server 2008";
break;
case 1:
os_version="Windows 7 or Windows Server 2008 R2";
break;
case 2:
os_version="Windows 8 or Windows Server 2012";
break;
case 3:
os_version="Windows 8.1 or Windows Server 2012 R2";
break;
default:
os_version="Unknown";
}
case 10: //这几个系统都是10.0
os_version="Windows 10, Windows 11, Windows Server 2016 or Windows Server 2019";
break;
default:
os_version="Unknown";
}
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW);
*(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
if (RtlGetVersion != nullptr) {
RtlGetVersion(&os);
switch (os.dwMajorVersion) {//主版本号
case 5: //不兼容Windows 2000因此5.x一定是Windows XP
os_version = "Windows XP";
break;
case 6:
switch (os.dwMinorVersion) { //次版本号
case 0:
os_version = "Windows Vista or Windows Server 2008";
break;
case 1:
os_version = "Windows 7 or Windows Server 2008 R2";
break;
case 2:
os_version = "Windows 8 or Windows Server 2012";
break;
case 3:
os_version = "Windows 8.1 or Windows Server 2012 R2";
break;
default:
os_version = "Unknown";
}
case 10: //这几个系统都是10.0
if (IsWin11AndLater()) {
os_version = "Windows 11 or Windows Server 2022";
}
else {
os_version = "Windows 10, Windows Server 2016 or Windows Server 2019";
}
break;
default:
os_version = "Unknown";
}
}
else {
os_version = "Unknown";
}
this->release = RELEASE;
this->version = VERSION;
//读取MachineGUID并取MD5作为device_id

View File

@ -110,4 +110,7 @@ inline QString getMachineGUID() {
return guid;
}
class SoftwareRequest :public RequestBodyBase {
};
#endif //OFFICEASSISTANT_NETIO_H