Skip to content

Commit

Permalink
Add other gpts
Browse files Browse the repository at this point in the history
  • Loading branch information
cgxxv committed Mar 10, 2024
1 parent d7bbabe commit b0566aa
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 54 deletions.
25 changes: 13 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5)

project(ChatGPT-Qt VERSION 0.1 LANGUAGES CXX)
project(ChatGPTs VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
Expand All @@ -13,43 +13,44 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets WebEngineWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets WebEngineWidgets)

set(PROJECT_SOURCES
main.cpp
test.h test.cpp
src/main.cpp
src/mainwindow.h src/mainwindow.cpp
resource.qrc
src/mainwindow.ui
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(ChatGPT-Qt
qt_add_executable(ChatGPTs
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET ChatGPT-Qt APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# set_property(TARGET ChatGPTs APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(ChatGPT-Qt SHARED
add_library(ChatGPTs SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(ChatGPT-Qt
add_executable(ChatGPTs
${PROJECT_SOURCES}
)
endif()
endif()

target_link_libraries(ChatGPT-Qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WebEngineWidgets)
target_link_libraries(ChatGPTs PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WebEngineWidgets)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ChatGPT-Qt)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ChatGPTs)
endif()
set_target_properties(ChatGPT-Qt PROPERTIES
set_target_properties(ChatGPTs PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
Expand All @@ -58,12 +59,12 @@ set_target_properties(ChatGPT-Qt PROPERTIES
)

include(GNUInstallDirs)
install(TARGETS ChatGPT-Qt
install(TARGETS ChatGPTs
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(ChatGPT-Qt)
qt_finalize_executable(ChatGPTs)
endif()
10 changes: 10 additions & 0 deletions assets/ChatGPT.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/doubao.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/doubao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/doubao.webp
Binary file not shown.
File renamed without changes
File renamed without changes.
Binary file added assets/tongyi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/yiyan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion chatgpt.qrc

This file was deleted.

17 changes: 0 additions & 17 deletions main.cpp

This file was deleted.

7 changes: 5 additions & 2 deletions resource.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<RCC>
<qresource prefix="/">
<file>chatgpt.png</file>
<file>index.html</file>
<file>assets/ChatGPT.svg</file>
<file>assets/doubao.png</file>
<file>assets/gpt.png</file>
<file>assets/tongyi.png</file>
<file>assets/yiyan.png</file>
</qresource>
</RCC>
28 changes: 28 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "mainwindow.h"

#include <QApplication>
#include <QtWebEngineWidgets/QWebEngineView>
#include <QUrl>
#include <QIcon>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setWindowIcon(QIcon(":/assets/gpt.png"));

MainWindow w;
w.resize(1024,768);
w.show();

//https://chat.openai.com
//https://yiyan.baidu.com
//https://tongyi.aliyun.com/qianwen
//https://www.doubao.com

// QWebEngineView view;
// view.setUrl(QUrl("https://chat.openai.com"));
// view.resize(1024, 768);
// view.show();

return a.exec();
}
64 changes: 64 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"

#include <QtWebEngineWidgets/QWebEngineView>
#include <QUrl>
#include <QIcon>

#define CHATGPT_URL "https://chat.openai.com"
#define YIYAN_URL "https://yiyan.baidu.com"
#define TONGYI_URL "https://tongyi.aliyun.com/qianwen"
#define DOUBAO_URL "https://www.doubao.com"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow{parent}
, ui(new Ui::MainWindow)
, view(new QWebEngineView)
{
ui->setupUi(this);
show_web_view(CHATGPT_URL);
setCentralWidget(view);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::show_web_view(QString url)
{
view->load(QUrl(url));
QString script = R"(
document.documentElement.style.overflow = 'hidden';
document.documentElement.style.height = '100vh';
document.documentElement.style.margin = 0;
document.body.style.overflow = 'hidden';
document.body.style.height = '100vh';
document.body.style.margin = 0;
)";

view->page()->runJavaScript(script);
}

void MainWindow::on_actChatGPT_triggered()
{
show_web_view(CHATGPT_URL);
}


void MainWindow::on_actYiyan_triggered()
{
show_web_view(YIYAN_URL);
}


void MainWindow::on_actTongyi_triggered()
{
show_web_view(TONGYI_URL);
}


void MainWindow::on_actDoubao_triggered()
{
show_web_view(DOUBAO_URL);
}
38 changes: 38 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

class QWebEngineView;

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();

private slots:
void on_actChatGPT_triggered();

void on_actYiyan_triggered();

void on_actTongyi_triggered();

void on_actDoubao_triggered();

private:
void show_web_view(QString url);

private:
Ui::MainWindow *ui;
QWebEngineView *view;
};

#endif // MAINWINDOW_H
79 changes: 79 additions & 0 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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>725</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>725</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuSwitch_GPT">
<property name="title">
<string>Switch GPT</string>
</property>
<addaction name="actChatGPT"/>
<addaction name="actYiyan"/>
<addaction name="actTongyi"/>
<addaction name="actDoubao"/>
</widget>
<addaction name="menuSwitch_GPT"/>
</widget>
<action name="actChatGPT">
<property name="icon">
<iconset>
<normaloff>:/assets/ChatGPT.svg</normaloff>:/assets/ChatGPT.svg</iconset>
</property>
<property name="text">
<string>ChatGPT</string>
</property>
</action>
<action name="actYiyan">
<property name="icon">
<iconset>
<normaloff>:/assets/yiyan.png</normaloff>:/assets/yiyan.png</iconset>
</property>
<property name="text">
<string>文心一言</string>
</property>
<property name="iconText">
<string>文心一言</string>
</property>
</action>
<action name="actTongyi">
<property name="icon">
<iconset>
<normaloff>:/assets/tongyi.png</normaloff>:/assets/tongyi.png</iconset>
</property>
<property name="text">
<string>通义千问</string>
</property>
</action>
<action name="actDoubao">
<property name="icon">
<iconset>
<normaloff>:/assets/doubao.png</normaloff>:/assets/doubao.png</iconset>
</property>
<property name="text">
<string>字节豆包</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
5 changes: 0 additions & 5 deletions test.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions test.h

This file was deleted.

0 comments on commit b0566aa

Please sign in to comment.