Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Preview
  • Loading branch information
MarioCrane authored Sep 14, 2020
1 parent 971a04d commit e57e6c2
Show file tree
Hide file tree
Showing 29 changed files with 39,279 additions and 0 deletions.
Binary file added LeaguePrank/LeaguePrank.ico
Binary file not shown.
57 changes: 57 additions & 0 deletions LeaguePrank/LeaguePrank.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
QT += core gui #concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked 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 it uses 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 += \
cefview.cpp \
lockfilereader.cpp \
main.cpp \
mainwindow.cpp

HEADERS += \
Methods.h \
cefview.h \
lockfilereader.h \
mainwindow.h \
processinfo.h

FORMS += \
mainwindow.ui

# ================= LIB & Include =================
win32: LIBS += -L$$PWD/../QCefView/lib/ -lQCefView -llibcef
win32: LIBS += -luser32

INCLUDEPATH += $$PWD/../QCefView/include
DEPENDPATH += $$PWD/../QCefView/include
# ================= LIB & Include =================

# ==================== Resource ====================
RC_ICONS = LeaguePrank.ico

VERSION = 1.0.0

QMAKE_TARGET_PRODUCT = League Prank
QMAKE_TARGET_COMPANY = Studio
QMAKE_TARGET_DESCRIPTION = League Prank
QMAKE_TARGET_COPYRIGHT = 2020 Studio. All Rights Reserved.

QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"
# ==================== Resource ====================
# ====================== Flags =====================
QMAKE_CXXFLAGS_RELEASE += -O2 # Release -O2
# ====================== Flags =====================
24 changes: 24 additions & 0 deletions LeaguePrank/Methods.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef METHODS_H
#define METHODS_H

#include <QString>

/* Application */
const QString APPLICATION_NAME = "League Prank";
const QString APPLICATION_VERSION = "1.0.0";

/* Profile */
const QString PROFILE_READ = "LCUreadProfile"; // 读取配置文件并发送给H5
const QString PROFILE_WRITE = "LCUwriteProfile"; // 保存配置文件

/* Path List */
const QString PATH_LIST_GET = "LCUgetPathList";
const QString PATH_LIST_SET = "LCUsetPathList";

/* Open link */
const QString OPEN_URL = "LCUopenUrl";

/* About Qt */
const QString ABOUT_QT = "LCUaboutQt";

#endif // METHODS_H
93 changes: 93 additions & 0 deletions LeaguePrank/cefview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include "cefview.h"
#include <windows.h>
#include <QMessageBox>
#include <QColor>

CefView::CefView(const QString &url, QWidget *parent)
: QCefView(url, parent)
{
}

CefView::~CefView()
{
}

void CefView::changeColor()
{
qsrand(::GetTickCount());
QColor color(qrand());

QCefEvent event("colorChangedEvent");
event.setStringProperty("color", color.name());
broadcastEvent("colorChange", event);
}

void CefView::sendEvent(const QString &name, const QString &key, const QString &value)
{
QCefEvent event("event");
event.setStringProperty(key.toLatin1(), value);
broadcastEvent(name.toLatin1(), event);
}

void CefView::onQCefUrlRequest(const QString &url)
{
QString title("QCef Url Request");
QString text = QString("Current Thread: QT_UI\r\n"
"Url: %1")
.arg(url);

//QMessageBox::information(this->window(), title, text);
}

void CefView::onQCefQueryRequest(const QCefQuery &query)
{
QString title("QCef Query Request");
QString text = QString("Current Thread: QT_UI\r\n"
"Query: %1\r\n"
"Response: %2")
.arg(query.reqeust())
.arg(query.response());

//QMessageBox::information(this->window(), title, text);

QString response = query.reqeust().toUpper();
query.setResponseResult(true, response);
responseQCefQuery(query);
}

void CefView::onInvokeMethodNotify(int browserId, int frameId, const QString &method, const QVariantList &arguments)
{
Q_UNUSED(browserId)
Q_UNUSED(frameId)
//Q_UNUSED(arguments)

#if 0
if (0 == method.compare("onDragAreaMouseDown")) {
HWND hWnd = ::GetAncestor((HWND)getCefWinId(), GA_ROOT);

// get current mouse cursor position
POINT pt;
::GetCursorPos(&pt);

// in case the mouse is being captured, try to release it
::ReleaseCapture();

// simulate that the mouse left button is down on the title area
::SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, POINTTOPOINTS(pt));
return;
}
QString title("QCef InvokeMethod Notify");
QString text = QString("Current Thread: QT_UI\r\n"
"Method: %1\r\n"
"Arguments: %2")
.arg(method).arg(arguments.first().toString());
QMessageBox::information(this->window(), title, text);
#endif

if (arguments.isEmpty()) {
emit invokeMethod(method, "");
} else {
// 只获取第一个参数,也可将QVariantList传递过去由MainWindow进行控制
emit invokeMethod(method, arguments.first().toString());
}
}
29 changes: 29 additions & 0 deletions LeaguePrank/cefview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef CEFVIEW_H
#define CEFVIEW_H

#include <QCefView.h>

class CefView : public QCefView
{
Q_OBJECT
public:
CefView(const QString& url, QWidget *parent);
~CefView();

void changeColor();
void sendEvent(const QString &name, const QString &key, const QString &value);

signals:
void invokeMethod(QString method, QString argument);

protected:
virtual void onQCefUrlRequest(const QString& url) override;
virtual void onQCefQueryRequest(const QCefQuery& query) override;
virtual void onInvokeMethodNotify(int browserId, int frameId,
const QString& method,
const QVariantList& arguments) override;

private:
};

#endif // CEFVIEW_H
Binary file added LeaguePrank/lockfilereader.cpp
Binary file not shown.
Binary file added LeaguePrank/lockfilereader.h
Binary file not shown.
17 changes: 17 additions & 0 deletions LeaguePrank/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "mainwindow.h"

#include <QApplication>
#include "Methods.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setDesktopFileName(APPLICATION_NAME);
a.setApplicationName(APPLICATION_NAME);
//a.setApplicationDisplayName(APPLICATION_NAME);
a.setApplicationVersion(APPLICATION_VERSION);

MainWindow w;
w.show();
return a.exec();
}
Binary file added LeaguePrank/mainwindow.cpp
Binary file not shown.
45 changes: 45 additions & 0 deletions LeaguePrank/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

/* File */
#include <QDir>
#include <QFile>

/**/
#include "cefview.h"
#include "lockfilereader.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();

private slots:
void on_btn_send_clicked();
void onInvokeMethod(QString method, QString argument);

private:
void sendGamePathList();
void readProfile();
void saveProfile(const QString &profile);

private:
Ui::MainWindow *ui;

QDir m_appDir;
QString m_homePageUrl;

CefView *m_cefView;
LockFileReader *m_lockFileReader;
QFile m_profile;
};
#endif // MAINWINDOW_H
96 changes: 96 additions & 0 deletions LeaguePrank/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>863</width>
<height>641</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true"/>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>debug</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lbl_event">
<property name="text">
<string>event:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_event"/>
</item>
<item>
<widget class="QLabel" name="lbl_key">
<property name="text">
<string>key:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_key"/>
</item>
<item>
<widget class="QPushButton" name="btn_send">
<property name="text">
<string>send</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="edit_value"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Binary file added LeaguePrank/processinfo.h
Binary file not shown.
Loading

0 comments on commit e57e6c2

Please sign in to comment.