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 f882b2b
Show file tree
Hide file tree
Showing 13 changed files with 63 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
45 changes: 45 additions & 0 deletions src/view/about-window.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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);
this.window.setMinimizable(false);
}

saveState() {
return null; // do not remember state
}
}
2 changes: 1 addition & 1 deletion src/view/app-menu-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class AppMenuBar extends BaseMenuBar {
{
label: require('../../package.json').build.productName,
submenu: [
{ role: 'about' },
BaseMenuBar.aboutMenuItem,
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hide-others' },
Expand Down
7 changes: 7 additions & 0 deletions src/view/base-menu-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import windowManager from '../controller/window-manager';
import {BaseViewType} from '../view/base-view';

export default class BaseMenuBar extends SignalsOwner {
static aboutMenuItem = {
label: `About ${require('../../package.json').build.productName}`,
onClick: () => {
const windowManager = require('../controller/window-manager').default;
windowManager.showNamedWindow('about');
},
};
static fileMenuItems = [
{ type: 'separator' },
{
Expand Down
5 changes: 4 additions & 1 deletion src/view/window-menu-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default class WindowMenuBar extends BaseMenuBar {
// File menu.
{
label: 'File',
submenu: BaseMenuBar.fileMenuItems,
submenu: [
BaseMenuBar.aboutMenuItem,
...BaseMenuBar.fileMenuItems,
],
},
];
super(template);
Expand Down

0 comments on commit f882b2b

Please sign in to comment.