Skip to content

Commit

Permalink
Add about window
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Jul 28, 2023
1 parent 4aef1f6 commit 98ded48
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Chie
</h1>

An extensible desktop app for large language models like ChatGPT and New Bing.
An extensible desktop app for large language models like ChatGPT and Bing Chat.
It works on macOS, Linux and Windows, and uses native UI on each platform.

* [Introduce the Chie app (with screenshots)](https://chie.app/posts/introduce-the-chie-app/)
Expand Down
File renamed without changes.
File renamed without changes.
Binary file removed assets/build/icon.png
Binary file not shown.
Binary file removed assets/build/icon_dev.png
Binary file not shown.
Binary file added assets/icons/icon-dev@2x.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/icons/icon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"build": {
"appId": "org.chie.chie",
"productName": "Chie",
"copyright": "Copyright © 2023 Cheng Zhao",
"copyright": "Copyright © 2023 Cheng. All rights reserved.",
"unpackDir": "assets/icons",
"ignore": [
"assets/build"
],
"entitlements": "assets/build/entitlements.plist",
"icons": {
"mac": "assets/build/icon_dev.icns",
"win": "assets/build/icon_dev.ico"
"mac": "assets/build/icon-dev.icns",
"win": "assets/build/icon-dev.ico"
}
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/gui-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gui from 'gui';

import AboutWindow from './view/about-window';
import ChatService from './model/chat-service';
import ChatView from './view/chat-view';
import DashboardWindow from './view/dashboard-window';
Expand Down Expand Up @@ -93,6 +94,7 @@ function guiMain() {
config.initFromFileSync();

// Register named windows.
windowManager.registerNamedWindow('about', AboutWindow);
windowManager.registerNamedWindow('dashboard', DashboardWindow);
windowManager.registerNamedWindow('settings', SettingsWindow);
windowManager.registerNamedWindow('newAssistant', NewAssistantWindow);
Expand Down
44 changes: 44 additions & 0 deletions src/view/about-window.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import fs from 'node:fs';
import gui from 'gui';
import path from 'node:path';

import BaseWindow from '../view/base-window';
import basicStyle from '../view/basic-style';

export default class AboutWindow extends BaseWindow {
constructor() {
super();

const packageJson = require('../../package.json');
let iconPath = path.join(__dirname, '../../assets/icons/icon');
if (packageJson.version.endsWith('-dev'))
iconPath += '-dev';
const icon = gui.Image.createFromPath(fs.realpathSync(iconPath + '@2x.png'));

const imageView = gui.GifPlayer.create();
imageView.setImage(icon);
this.contentView.addChildView(imageView);
const title = gui.Label.create(packageJson.build.productName);
title.setFont(gui.Font.default().derive(1, 'bold', 'normal'));
this.contentView.addChildView(title);
const smallFont = gui.Font.default().derive(-3, 'normal', 'normal');
const version = gui.Label.create(`Version ${packageJson.version}`);
version.setFont(smallFont);
this.contentView.addChildView(version);
const copyright = gui.Label.create(packageJson.build.copyright);
copyright.setFont(smallFont);
this.contentView.addChildView(copyright);

this.contentView.setStyle({
alignItems: 'center',
padding: basicStyle.padding,
gap: basicStyle.padding / 2,
});
this.resizeToFitContentView();
this.window.setResizable(false);
}

saveState() {
return null; // do not remember state
}
}
12 changes: 10 additions & 2 deletions src/view/app-menu-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import BaseMenuBar from './base-menu-bar';

export default class AppMenuBar extends BaseMenuBar {
constructor() {
const name = require('../../package.json').build.productName;

const template = [
// The main menu.
{
label: require('../../package.json').build.productName,
label: name,
submenu: [
{ role: 'about' },
{
label: `About ${name}`,
onClick: () => {
const windowManager = require('../controller/window-manager').default;
windowManager.showNamedWindow('about');
},
},
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hide-others' },
Expand Down

0 comments on commit 98ded48

Please sign in to comment.