|
@@ -17,8 +17,8 @@
|
|
|
#include "httpapi.h"
|
|
|
#include "qresource.h"
|
|
|
|
|
|
-#include <windows.h>
|
|
|
-#include <tlhelp32.h>
|
|
|
+//#include <windows.h>
|
|
|
+//#include <tlhelp32.h>
|
|
|
#include <stdio.h>
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
Home::Home(QWidget *parent) :
|
|
@@ -32,7 +32,7 @@ Home::Home(QWidget *parent) :
|
|
|
captureScreen();
|
|
|
});
|
|
|
myTimer->start(10000);
|
|
|
-
|
|
|
+ setWindowTitle(tr("智能工时管家"));
|
|
|
//set ui data
|
|
|
webWidget = new QWebEngineView(this);
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(false);
|
|
@@ -50,79 +50,9 @@ Home::Home(QWidget *parent) :
|
|
|
qs->beginGroup("user");
|
|
|
QString id = qs->value("id").toString();
|
|
|
qDebug() << "id=="<<id<<", phone="<<qs->value("name").toString();
|
|
|
- QString str = "http://118.190.47.230:9092/#/desktop/" + id;
|
|
|
+ QString str = "http://47.100.37.243:9092/#/desktop/" + id;
|
|
|
loadNavigate(str);
|
|
|
|
|
|
-
|
|
|
- HANDLE hCurrentCursor = GetForegroundWindow();
|
|
|
- qDebug()<<hCurrentCursor<<endl;
|
|
|
-// EnumWindows(StaticEnumWindowsProc,reinterpret_cast<LPARAM>(this));
|
|
|
- PROCESSENTRY32 pe32;
|
|
|
- //再使用这个结构体前先定义它的大小
|
|
|
- pe32.dwSize=sizeof(pe32);
|
|
|
- //给系统内的所有进程拍一个快照
|
|
|
- HANDLE hProcessSnap=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
|
|
- if (hProcessSnap==INVALID_HANDLE_VALUE)
|
|
|
- {
|
|
|
- printf("Create ToolHelp32Snaphhot调用失败!\n");
|
|
|
-
|
|
|
- }
|
|
|
- BOOL bMore=::Process32First(hProcessSnap,&pe32);
|
|
|
-
|
|
|
- ::CloseHandle(hProcessSnap);
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-BOOL Home::StaticEnumWindowsProc(HWND hwnd, LPARAM lParam)
|
|
|
-{
|
|
|
- //窗口是否可视
|
|
|
- if (!::IsWindowVisible(hwnd))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- //窗口是否可激活
|
|
|
- if (!::IsWindowEnabled(hwnd))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- //确定给定窗口是否是最小化(图标化)的窗口。
|
|
|
- //if(IsIconic(hwnd))
|
|
|
- // return TRUE;
|
|
|
-
|
|
|
- //窗口是否具有父窗口?
|
|
|
- HWND hParent = (HWND)GetWindowLong(hwnd, -8);
|
|
|
- //父窗口是否可激活?
|
|
|
- //据 Spy++ 观察,如“运行”对话框等被应列入列表的程序有一个隐藏的,具有 WS_DISABLED 的父窗口
|
|
|
- if (IsWindowEnabled(hParent))
|
|
|
- return TRUE;
|
|
|
- //父窗口是否可视?
|
|
|
- if (IsWindowVisible(hParent))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- LONG gwl_style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
- if ((gwl_style & WS_POPUP) && !(gwl_style & WS_CAPTION))
|
|
|
- return TRUE;
|
|
|
-
|
|
|
- CHAR caption[256];
|
|
|
- memset(caption, 0, sizeof(caption));
|
|
|
- ::GetWindowTextA(hwnd, caption, 255);
|
|
|
-
|
|
|
- if (strcmp(caption, ""))
|
|
|
- {
|
|
|
- if (GetClassLong(hwnd, -14))
|
|
|
- {
|
|
|
- HICON hIcon =(HICON)GetClassLong(hwnd, -14);
|
|
|
- if(hIcon)
|
|
|
- {
|
|
|
-// handleIcon.push_back(hIcon);
|
|
|
-// handleWindow.push_back(hwnd);
|
|
|
- qDebug()<<"hIcon="<<hIcon<<", title="<<GetClassLong(hwnd, -8);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- qDebug() <<"title=="<< caption;
|
|
|
- }
|
|
|
-
|
|
|
- return TRUE;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -210,20 +140,49 @@ void Home::captureScreen() {
|
|
|
textPart2.setBody(indate.toUtf8());
|
|
|
multiPart->append(textPart2);
|
|
|
|
|
|
+
|
|
|
QString processList = getProcessList();
|
|
|
-// qDebug() << processList ;
|
|
|
+ qDebug() << processList;
|
|
|
QHttpPart textPart3;
|
|
|
textPart3.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"processList\""));
|
|
|
textPart3.setBody(processList.toUtf8());
|
|
|
multiPart->append(textPart3);
|
|
|
|
|
|
+ //add os infomation
|
|
|
+ QString osType = "";
|
|
|
+ #if defined(Q_OS_WIN)
|
|
|
+ osType = "Q_OS_WIN";
|
|
|
+ #endif
|
|
|
+ #if defined(Q_OS_MAC)
|
|
|
+ osType = "Q_OS_MAC";
|
|
|
+ #endif
|
|
|
+ #if defined(Q_OS_LINUX)
|
|
|
+ osType = "Q_OS_LINUX";
|
|
|
+ #endif
|
|
|
+ qDebug() << "osType=="<<osType;
|
|
|
+ QHttpPart textPart4;
|
|
|
+ textPart4.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"osType\""));
|
|
|
+ textPart4.setBody(osType.toUtf8());
|
|
|
+ multiPart->append(textPart4);
|
|
|
+
|
|
|
QNetworkAccessManager *m_pNetWorkManager = new QNetworkAccessManager();
|
|
|
m_pNetWorkManager->post(request, multiPart);
|
|
|
}
|
|
|
|
|
|
QString Home::getProcessList() {
|
|
|
QProcess process;
|
|
|
+ #ifdef Q_OS_WIN
|
|
|
+ qDebug() <<"This is Windows platform";
|
|
|
process.start("tasklist.exe");
|
|
|
+ #endif
|
|
|
+ #ifdef Q_OS_MAC
|
|
|
+ qDebug() <<"This is Mac platform, run ps aux";
|
|
|
+ process.start("ps aux");
|
|
|
+ #endif
|
|
|
+ #ifdef Q_OS_LINUX
|
|
|
+ qDebug() <<"This is Linux platform, run ps aux";
|
|
|
+ process.start("ps aux");
|
|
|
+ #endif
|
|
|
if(process.waitForFinished())
|
|
|
{
|
|
|
QByteArray result = process.readAll();
|
|
@@ -244,7 +203,7 @@ void Home::closeEvent ( QCloseEvent * e )
|
|
|
{
|
|
|
if( QMessageBox::question(this,
|
|
|
tr("退出"),
|
|
|
- tr("您确定要退出吗?"),
|
|
|
+ tr("退出软件将无法统计到您的工时,影响绩效,您确定要退出吗?"),
|
|
|
QMessageBox::Yes, QMessageBox::No )
|
|
|
== QMessageBox::Yes){
|
|
|
e->accept();//不会将事件传递给组件的父组件
|