Skip to content

Commit

Permalink
Add options to disable file delete and file blacklist dialogs, add ho…
Browse files Browse the repository at this point in the history
…tkey for blacklist
  • Loading branch information
StarrHelixx committed Jun 28, 2023
1 parent fbb3e43 commit 0da4bee
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 168 deletions.
104 changes: 54 additions & 50 deletions src/renderer/components/config/GeneralConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import Config, {CacheSettings, DisplaySettings, GeneralSettings, RemoteSettings}
import Tag from "../../data/Tag";
import LibrarySource from "../../data/LibrarySource";
import PlayerBoolCard from "../configGroups/PlayerBoolCard";
import PlayerBoolCard2 from "../configGroups/PlayerBoolCard2";
import PlayerNumCard from "../configGroups/PlayerNumCard";
import CacheCard from "../configGroups/CacheCard";
import BackupCard from "../configGroups/BackupCard";
import APICard from "../configGroups/APICard";
import ThemeCard from "../configGroups/ThemeCard";
import WatermarkCard from "../configGroups/WatermarkCard";
import Masonry from "@mui/lab/Masonry/Masonry";

export default class GeneralConfig extends React.Component {
readonly props: {
Expand All @@ -35,50 +37,61 @@ export default class GeneralConfig extends React.Component {
render() {
return(
<Grid container spacing={2}>
<Grid item xs={12} sm={6} md={4} lg={3}>
<Card>
<CardContent>
<PlayerBoolCard
displaySettings={this.props.config.displaySettings}
generalSettings={this.props.config.generalSettings}
onPortableOverride={this.props.onPortableOverride.bind(this)}
onUpdateDisplaySettings={this.props.onUpdateDisplaySettings.bind(this)}
onUpdateGeneralSettings={this.props.onUpdateGeneralSettings.bind(this)}/>
</CardContent>
</Card>
</Grid>
<Grid item xs={12}>
<Masonry columns={[1,2,3,4]} spacing={2}>

<Grid item xs={12} sm={4} md={3} lg={2}>
<Card style={{overflow: 'visible'}}>
<CardContent>
<PlayerNumCard
library={this.props.library}
tags={this.props.tags}
settings={this.props.config.displaySettings}
onUpdateSettings={this.props.onUpdateDisplaySettings.bind(this)}/>
</CardContent>
</Card>
</Grid>
<Card>
<CardContent>
<PlayerBoolCard
displaySettings={this.props.config.displaySettings}
onUpdateDisplaySettings={this.props.onUpdateDisplaySettings.bind(this)}/>
</CardContent>
</Card>

<Grid item xs={12} sm={8} md={5} lg={4}>
<Card>
<CardContent>
<CacheCard
config={this.props.config}
onUpdateSettings={this.props.onUpdateCachingSettings.bind(this)}/>
</CardContent>
</Card>
</Grid>
<Card>
<CardContent>
<PlayerBoolCard2
generalSettings={this.props.config.generalSettings}
onPortableOverride={this.props.onPortableOverride.bind(this)}
onUpdateGeneralSettings={this.props.onUpdateGeneralSettings.bind(this)}/>
</CardContent>
</Card>

<Grid item xs={12} sm={4} md={3} lg={3}>
<Card>
<CardContent>
<APICard
settings={this.props.config.remoteSettings}
onUpdateSettings={this.props.onUpdateRemoteSettings.bind(this)}
onUpdateConfig={this.props.onUpdateConfig.bind(this)}/>
</CardContent>
</Card>
<Card style={{overflow: 'visible'}}>
<CardContent>
<PlayerNumCard
library={this.props.library}
tags={this.props.tags}
settings={this.props.config.displaySettings}
onUpdateSettings={this.props.onUpdateDisplaySettings.bind(this)}/>
</CardContent>
</Card>

<Card>
<CardContent>
<CacheCard
config={this.props.config}
onUpdateSettings={this.props.onUpdateCachingSettings.bind(this)}/>
</CardContent>
</Card>

<Card>
<CardContent>
<APICard
settings={this.props.config.remoteSettings}
onUpdateSettings={this.props.onUpdateRemoteSettings.bind(this)}
onUpdateConfig={this.props.onUpdateConfig.bind(this)}/>
</CardContent>
</Card>

<Card>
<CardContent>
<WatermarkCard
settings={this.props.config.generalSettings}
onUpdateSettings={this.props.onUpdateGeneralSettings.bind(this)}/>
</CardContent>
</Card>
</Masonry>
</Grid>

<Grid item xs={12} sm={"auto"}>
Expand All @@ -105,15 +118,6 @@ export default class GeneralConfig extends React.Component {
</Card>
</Grid>

<Grid item xs={12} sm={4} md={3} lg={3}>
<Card>
<CardContent>
<WatermarkCard
settings={this.props.config.generalSettings}
onUpdateSettings={this.props.onUpdateGeneralSettings.bind(this)}/>
</CardContent>
</Card>
</Grid>
</Grid>
);
}
Expand Down
112 changes: 2 additions & 110 deletions src/renderer/components/configGroups/PlayerBoolCard.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import * as React from "react";
import {existsSync} from 'fs';

import {
Button, Collapse, Dialog,
DialogActions,
DialogContent,
DialogContentText,
Divider,
Collapse,
FormControlLabel,
Grid,
Switch,
Tooltip
} from "@mui/material";

import {DisplaySettings, GeneralSettings} from "../../data/Config";
import {portablePath} from "../../data/utils";
import {DisplaySettings} from "../../data/Config";

export default class PlayerBoolCard extends React.Component {
readonly props: {
displaySettings: DisplaySettings,
generalSettings: GeneralSettings,
onPortableOverride(): void,
onUpdateDisplaySettings(fn: (settings: DisplaySettings) => void): void,
onUpdateGeneralSettings(fn: (settings: GeneralSettings) => void): void,
};

readonly state = {
portableDialog: false,
};

render() {
Expand Down Expand Up @@ -119,92 +106,10 @@ export default class PlayerBoolCard extends React.Component {
label="Clone Grid Videos Directly"/>
</Tooltip>
</Grid>
<Grid item xs={12}>
<Divider/>
</Grid>
<Grid item xs={12}>
<Tooltip disableInteractive title={<div>Prioritizing performance will smooth image effects, but may dramatically increase load times.<br/>Prioritizing loading will decrease load times, but may result in jittery effects during playback</div>}>
<FormControlLabel
control={
<Switch checked={this.props.generalSettings.prioritizePerformance}
onChange={this.onGBoolInput.bind(this, 'prioritizePerformance')}/>
}
label={this.props.generalSettings.prioritizePerformance ? "Prioritize Performance" : "Prioritize Loading"}/>
</Tooltip>
</Grid>
<Grid item xs={12}>
<Tooltip disableInteractive title="If disabled, no prompt will appear to confirm Scene deletion">
<FormControlLabel
control={
<Switch checked={this.props.generalSettings.confirmSceneDeletion}
onChange={this.onGBoolInput.bind(this, 'confirmSceneDeletion')}/>
}
label="Confirm Scene Deletion"/>
</Tooltip>
</Grid>
<Grid item xs={12}>
<Tooltip disableInteractive title="Portable Mode will save a copy of your data in the same directory as the FlipFlip executable, as well as the default save path. This needs to be enabled on each machine.">
<FormControlLabel
control={
<Switch checked={this.props.generalSettings.portableMode}
onChange={this.onTogglePortable.bind(this)}/>
}
label="Portable Mode"/>
</Tooltip>
</Grid>
{this.props.generalSettings.portableMode && (
<Grid item xs={12}>
<Tooltip disableInteractive title="If on, data will only be saved in the same directory as the FlipFlip executable, and not at the default save path.">
<FormControlLabel
control={
<Switch checked={this.props.generalSettings.disableLocalSave}
onChange={this.onGBoolInput.bind(this, 'disableLocalSave')}/>
}
label="Disable Local Saves"/>
</Tooltip>
</Grid>
)}
<Dialog
open={this.state.portableDialog}
onClose={this.onToggleDialog.bind(this)}
aria-describedby="portable-description">
<DialogContent>
<DialogContentText id="portable-description">
Do you want to use the local data on this machine or existing portable data?
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.onToggleDialog.bind(this)} color="secondary">
Local data
</Button>
<Button onClick={this.onChoosePortable.bind(this)} color="primary">
Portable data
</Button>
</DialogActions>
</Dialog>
</Grid>
);
}

onTogglePortable(e: MouseEvent) {
const input = (e.target as HTMLInputElement);
const checked = input.checked;
if (checked && existsSync(portablePath)) {
// Ask whether to keep local or keep portable
this.onToggleDialog();
}
this.changeGKey('portableMode', checked);
}

onToggleDialog() {
this.setState({portableDialog: !this.state.portableDialog});
}

onChoosePortable() {
this.props.onPortableOverride();
this.onToggleDialog();
}

onBoolInput(key: string, e: MouseEvent) {
const input = (e.target as HTMLInputElement);
const checked = input.checked;
Expand All @@ -219,19 +124,6 @@ export default class PlayerBoolCard extends React.Component {
this.props.onUpdateDisplaySettings(fn);
}

onGBoolInput(key: string, e: MouseEvent) {
const input = (e.target as HTMLInputElement);
const checked = input.checked;
this.changeGKey(key, checked);
}

changeGKey(key: string, value: any) {
this.gUpdate((s) => s[key] = value);
}

gUpdate(fn: (settings: any) => void) {
this.props.onUpdateGeneralSettings(fn);
}
}

(PlayerBoolCard as any).displayName="PlayerBoolCard";
Loading

0 comments on commit 0da4bee

Please sign in to comment.