Skip to content

Commit

Permalink
Merge pull request #19 from Project-Fungus/fix-menus
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadiguibou authored Dec 22, 2023
2 parents a40c733 + 2d30351 commit 0e37035
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 32 deletions.
Binary file modified img/help-view.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 modified img/open-files-view.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 modified img/project-pairs-view.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 modified img/warnings-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"name": "fungus-gui",
"author": "Louis Hildebrand <[email protected]>",
"contributors": [
"Louis Hildebrand",
"Gabriel Lacroix"
],
"version": "1.0.0",
"description": "A frontend to the FUNGUS plagiarism detection tool.",
"keywords": [
Expand Down
135 changes: 107 additions & 28 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ app.whenReady().then(() => {
createWindow();

app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0)
createWindow();
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
ipcMain.handle("dialog:showOpenDialog", async (event, options) => {
const browserWindow = BrowserWindow.fromWebContents(event.sender);
const result = await dialog.showOpenDialog(browserWindow, options);
const noInput = result.canceled
const noInput =
result.canceled
|| !result.filePaths
|| result.filePaths.length <= 0;
return noInput ? null : result.filePaths[0];
Expand All @@ -30,72 +30,151 @@ app.whenReady().then(() => {
});

app.on("window-all-closed", () => {
if (process.platform !== "darwin")
app.quit();
if (process.platform !== "darwin") app.quit();
});

function createWindow() {
const window = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, "preload.js"),
// Allow the preload script to read local files
sandbox: false
sandbox: false,
},
show: false
show: false,
});
window.maximize();
window.loadFile(path.join(__dirname, "renderer/index.html"));
window.show();
}

function createApplicationMenu() {
const isMac = process.platform === "darwin";

const menu = Menu.buildFromTemplate([
// { role: 'appMenu' }
...(isMac
? [
{
label: app.name,
submenu: [
{ role: "about" },
{ type: "separator" },
{ role: "services" },
{ type: "separator" },
{ role: "hide" },
{ role: "hideOthers" },
{ role: "unhide" },
{ type: "separator" },
{ role: "quit" },
],
},
]
: []),
// { role: 'fileMenu' }
{
label: "&File",
submenu: [
{
label: "Open",
label: isMac ? "Open..." : "Open",
accelerator: "CmdOrCtrl+O",
click: (_, browserWindow) => {
browserWindow.webContents.send("show-open-files-view");
}
},
},
{ role: "quit" }
]
isMac ? { role: "close" } : { role: "quit" },
],
},
// { role: 'editMenu' }
{
label: "&View",
label: "&Edit",
submenu: [
{ role: "undo" },
{ role: "redo" },
{ type: "separator" },
{ role: "cut" },
{ role: "copy" },
{ role: "paste" },
...(isMac
? [
{ role: "pasteAndMatchStyle" },
{ role: "delete" },
{ role: "selectAll" },
{ type: "separator" },
{
label: "Speech",
submenu: [
{ role: "startSpeaking" },
{ role: "stopSpeaking" }
],
},
]
: [
{ role: "delete" },
{ type: "separator" },
{ role: "selectAll" }
]),
],
},
// { role: 'viewMenu' }
{
label: "View",
submenu: [
{
label: "Matches",
accelerator: "CmdOrCtrl+M",
accelerator: "CmdOrCtrl+Shift+M",
click: (_, browserWindow) => {
browserWindow.webContents
.send("show-project-pairs-view");
}
browserWindow.webContents.send(
"show-project-pairs-view"
);
},
},
{
label: "Warnings",
accelerator: "CmdOrCtrl+W",
accelerator: "CmdOrCtrl+Shift+W",
click: (_, browserWindow) => {
browserWindow.webContents.send("show-warnings-view");
}
},
},
{ type: "separator" },
{ role: "zoomIn", accelerator: "CmdOrCtrl+=" },
{ role: "zoomOut" },
{ role: "reload" },
{ role: "forceReload" },
{ role: "toggleDevTools" },
{ type: "separator" },
{ role: "resetZoom" },
{ role: "togglefullscreen" },
{ role: "zoomIn" },
{ role: "zoomOut" },
{ type: "separator" },
{ role: "toggleDevTools" },
]
{ role: "togglefullscreen" },
],
},
// { role: 'windowMenu' }
{
label: "Window",
submenu: [
{ role: "minimize" },
{ role: "zoom" },
...(isMac
? [
{ type: "separator" },
{ role: "front" },
{ type: "separator" },
{ role: "window" },
]
: [{ role: "close" }]),
],
},
{
label: "&Help",
click: (_, browserWindow) => {
browserWindow.webContents.send("show-help-view");
}
}
role: "help",
submenu: [
{
label: "Get Help?",
click: (_, browserWindow) => {
browserWindow.webContents.send("show-help-view");
},
accelerator: isMac ? "Cmd+?" : "Alt+H"
},
],
},
]);
Menu.setApplicationMenu(menu);
}
11 changes: 7 additions & 4 deletions src/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ <h3>By verdict:</h3>
<h2>Using FUNGUS</h2>
<h3>Opening Files</h3>
<img src="../../img/open-files-view.png" />
<p><i>Access this page by pressing Ctrl+O (Cmd+O on Mac), or through the menu via File &gt; Open.</i>
<p><i>Access this page by pressing Ctrl+O (Cmd+O on macOS), or through the menu via File &gt; Open.</i>
</p>
<p>To start viewing the output of FUNGUS, you must specify the following three files:</p>
<ol>
Expand All @@ -155,7 +155,8 @@ <h3>Opening Files</h3>
</ol>
<h3>Examining Matches</h3>
<img src="../../img/project-pairs-view.png" />
<p><i>Access this page by pressing Ctrl+M (Cmd+M on MaC), or through the menu via View &gt; Matches.</i>
<p><i>Access this page by pressing Ctrl+Shift+M (Cmd+Shift+M on macOS), or through the menu via View &gt;
Matches.</i>
<ol>
<li>
<b>Project pairs.</b>
Expand All @@ -182,11 +183,13 @@ <h3>Examining Matches</h3>
</ol>
<h3>Examining Warnings</h3>
<img src="../../img/warnings-view.png" />
<p><i>Access this page by pressing Ctrl+W (Cmd+W on MaC), or through the menu via View &gt; Warnings.</i>
<p><i>Access this page by pressing Ctrl+Shift+W (Cmd+Shift+W on macOS), or through the menu via View &gt;
Warnings.</i>
</p>
<h3>Getting Help</h3>
<img src="../../img/help-view.png" />
<p><i>Access this page by pressing Alt+H, or through the menu by pressing the Help button.</i></p>
<p><i>Access this page by pressing Alt+H (Cmd+? on macOS), or through the menu by pressing the Help
button.</i></p>
</div>
</main>
</body>
Expand Down

0 comments on commit 0e37035

Please sign in to comment.