Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/electron-31.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sircharlo authored Jun 22, 2024
2 parents e1e5b76 + b308529 commit 2c0c2a2
Show file tree
Hide file tree
Showing 26 changed files with 990 additions and 205 deletions.
4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ updates:
- package-ecosystem: 'github-actions' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'daily'
interval: 'weekly'
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
# Disable rebasing for npm pull requests
rebase-strategy: "disabled"
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Build/release

on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:

jobs:
Expand Down Expand Up @@ -32,14 +30,14 @@ jobs:
- run: yarn install && yarn global add @quasar/cli

- name: Build and publish Electron app
if: "!startsWith(github.head_ref, 'dependabot/')"
if: "!startsWith(github.ref, 'refs/tags/v')"
run: yarn quasar build -m electron -P always
env:
GITHUB_TOKEN: ${{ github.token }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

- name: Build Electron app
if: "startsWith(github.head_ref, 'dependabot/')"
if: "startsWith(github.ref, 'refs/tags/v')"
run: yarn quasar build -m electron
env:
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -50,3 +48,4 @@ jobs:
# with:
# github_token: ${{ secrets.github_token }}
# release: ${{ startsWith(github.ref, 'refs/tags/v') }}

41 changes: 28 additions & 13 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
pull_request_rules:
- name: Automatic merge for trusted authors and dependabot
#- name: Automatic merge for trusted authors and dependabot
# conditions:
# - or:
# - author=mtdvlpr
# - author=sircharlo
# - and:
# - author=dependabot[bot]
# - or:
# - title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
# - title~=^chore\(deps\). bump [^\s]+ from ([\d]+)\..+ to \1\.
# - title~=^chore\(deps-dev\). bump [^\s]+ from ([\d]+)\..+ to \1\.
# actions:
# update:
# merge:
# method: squash
- name: Automatically merge Dependabot PRs
conditions:
- or:
- author=mtdvlpr
- author=sircharlo
- and:
- author=dependabot[bot]
- or:
- title~=^Bump [^\s]+ from ([\d]+)\..+ to \1\.
- title~=^chore\(deps\). bump [^\s]+ from ([\d]+)\..+ to \1\.
- title~=^chore\(deps-dev\). bump [^\s]+ from ([\d]+)\..+ to \1\.
- author = dependabot[bot]
actions:
update:
merge:
method: squash
#merge:
queue:

queue_rules:
# If you have other queues defined, add this at the end so it is processed last
- name: dep-update
batch_size: 10
# Wait for up to 30 minutes for the batch to fill up
batch_max_wait_time: 30 min
queue_conditions:
- author = dependabot[bot]
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"akamaihd",
"alllangs",
"axios",
"ayfm",
"AYFM",
"cctv",
Expand All @@ -13,6 +14,7 @@
"flac",
"fontawesome",
"formkit",
"guids",
"icns",
"intlify",
"ionicons",
Expand All @@ -31,6 +33,7 @@
"myapp",
"nodir",
"nsis",
"objt",
"overscan",
"panzoom",
"Panzoom",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mmm-v2",
"version": "24.6.2",
"version": "24.6.3",
"description": "A cross platform app to download and present media (pictures and videos) for congregation meetings of Jehovah’s Witnesses in any language. Features include recurring and custom media management, congregation sync, and media presentation tools for hybrid, in-person or fully remote Zoom meetings.",
"productName": "Meeting Media Manager v2",
"author": "Olivier Savignac",
Expand Down
2 changes: 1 addition & 1 deletion quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = configure(function (/* ctx */) {
target: {
// browser: ['esnext', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
browser: ['esnext'],
node: 'node20',
node: 'node22',
},
vitePlugins: [
[
Expand Down
45 changes: 38 additions & 7 deletions src-electron/electron-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
* }
*/

import { BrowserWindow, app, dialog, screen } from '@electron/remote';
import {
BrowserWindow,
app,
dialog,
globalShortcut,
screen,
} from '@electron/remote';
import * as sqlite3 from 'better-sqlite3';
import decompress from 'decompress';
import { contextBridge } from 'electron';
Expand Down Expand Up @@ -87,12 +93,18 @@ const moveMediaWindow = ({
const mediaWindow = getMediaWindow();
if (!mediaWindow || !mainWindow) return;
if (targetScreen === undefined || windowedMode === undefined) {
const screenPreferences = JSON.parse(
localStorage.getItem('screenPreferences') ?? '{}',
) as ScreenPreferences;
console.log('screenPreferences', screenPreferences);
targetScreen = screenPreferences.preferredScreenNumber;
windowedMode = screenPreferences.preferWindowed;
try {
const screenPreferences = JSON.parse(
window.localStorage
.getItem('screenPreferences')
?.replace('__q_objt|', '') ?? '{}', // This is a hack, we need to replace the string __q_objt| with an empty string due to Quasar's implementation of LocalStorage
) as ScreenPreferences;
console.log('screenPreferences', screenPreferences);
targetScreen = screenPreferences.preferredScreenNumber;
windowedMode = screenPreferences.preferWindowed;
} catch (err) {
console.error(err);
}
}
const getWindowScreen = (window: Electron.BrowserWindow) => {
const windowDisplay = screen.getDisplayMatching(window.getBounds());
Expand Down Expand Up @@ -204,6 +216,23 @@ const toggleMediaWindow = (action: string) => {
}
};

const registerShortcut = (keySequence: string, callback: () => void) => {
if (!keySequence) return;
console.log('registering shortcut', keySequence, callback);
const ret = globalShortcut.register(keySequence, callback);
if (!ret) {
console.log('registration failed');
}
console.log(globalShortcut.isRegistered(keySequence));
};

const unregisterShortcut = (keySequence: string) => {
if (!keySequence) return;
console.log('unregistering shortcut', keySequence);
if (globalShortcut.isRegistered(keySequence))
globalShortcut.unregister(keySequence);
};

contextBridge.exposeInMainWorld('electronApi', {
convert,
decompress,
Expand Down Expand Up @@ -253,6 +282,7 @@ contextBridge.exposeInMainWorld('electronApi', {
});
},
path,
registerShortcut,
setAutoStartAtLogin: (value: boolean) => {
app.setLoginItemSettings({
openAtLogin: value,
Expand All @@ -265,4 +295,5 @@ contextBridge.exposeInMainWorld('electronApi', {
}
},
toggleMediaWindow,
unregisterShortcut,
});
113 changes: 113 additions & 0 deletions src/components/form-inputs/ShortcutInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<template>
<q-btn-group push v-if="localValue">
<q-btn
:color="'blue-' + (8 + index)"
:key="keyboardKey"
:label="keyboardKey"
@click="shortcutPicker = true"
v-for="(keyboardKey, index) in localValue.split('+')"
/>
</q-btn-group>
<q-btn
:label="$t('enter-key-combination')"
@click="shortcutPicker = true"
color="primary"
outline
v-else
/>
<q-dialog
@hide="stopListening()"
@show="startListening()"
persistent
v-model="shortcutPicker"
>
<q-card style="min-width: 350px">
<q-card-section>
<div class="text-h6">Enter a key combination</div>
</q-card-section>

<q-card-section
:class="'q-pt-none ' + (localValue.length > 0 ? 'text-center' : '')"
>
<template v-if="localValue.length > 0">
<q-chip
:key="key"
class="glossy text-center text-uppercase"
color="primary"
size="lg"
square
text-color="white"
v-for="key in localValue.split('+')"
>{{ key }}</q-chip
>
</template>
<p v-else>{{ $t('no-key-combination') }}</p>
</q-card-section>

<q-card-actions align="right" class="text-primary">
<q-btn
:label="$t('clear')"
@click="localValue = ''"
color="negative"
flat
v-close-popup
/>
<q-btn :label="$t('confirm')" flat v-close-popup />
</q-card-actions>
</q-card>
</q-dialog>
</template>

<script setup lang="ts">
import {
getCurrentShortcuts,
registerCustomShortcut,
unregisterShortcut,
} from 'src/helpers/keyboardShortcuts';
import { SettingsValues } from 'src/types/settings';
import { ref, watch } from 'vue';
// Define props and emits
const props = defineProps<{
modelValue: string;
shortcutName: keyof SettingsValues;
}>();
const emit = defineEmits(['update:modelValue']);
// Setup component
const localValue = ref(props.modelValue);
watch(localValue, (newValue, oldValue) => {
if (!getCurrentShortcuts().includes(newValue)) {
emit('update:modelValue', newValue);
unregisterShortcut(oldValue);
registerCustomShortcut(props.shortcutName, newValue);
}
});
watch(
() => props.modelValue,
(newValue) => {
localValue.value = newValue;
},
);
const handleKeyPress = (event: KeyboardEvent) => {
const { altKey, ctrlKey, key, metaKey, shiftKey } = event;
const keys = [];
if (ctrlKey) keys.push('Ctrl');
if (shiftKey) keys.push('Shift');
if (altKey) keys.push('Alt');
if (metaKey) keys.push('Meta');
if (key.length < 3 && keys.length > 0) {
keys.push(key);
localValue.value = keys.join('+');
}
};
const startListening = () => window.addEventListener('keydown', handleKeyPress);
const stopListening = () =>
window.removeEventListener('keydown', handleKeyPress);
const shortcutPicker = ref(false);
</script>
33 changes: 17 additions & 16 deletions src/components/media/MediaDisplayButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
screen.mainWindow
? 'mdi-monitor-dashboard'
: screenPreferences.preferredScreenNumber === index
? 'mdi-monitor-shimmer'
: 'mdi-monitor'
? 'mdi-monitor-shimmer'
: 'mdi-monitor'
"
:text-color="
screenList.length < 2 ||
Expand Down Expand Up @@ -126,27 +126,20 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { electronApi } from 'src/helpers/electron-api';
import { showMediaWindow } from 'src/helpers/mediaPlayback';
import { useAppSettingsStore } from 'src/stores/app-settings';
import { useCurrentStateStore } from 'src/stores/current-state';
import { onMounted, onUnmounted, ref, watch } from 'vue';
const { getAllScreens, moveMediaWindow, toggleMediaWindow } =
electronApi;
const { getAllScreens, moveMediaWindow } = electronApi;
defineProps<{
disabled?: boolean;
}>();
const currentState = useCurrentStateStore();
const { currentSettings, mediaPlayer } = storeToRefs(currentState);
const mediaDisplayPopup = ref();
const showMediaWindow = (state: boolean) => {
mediaPlayer.value.windowVisible = state;
toggleMediaWindow(state ? 'show' : 'hide');
};
const mediaDisplayPopup = ref()
const appSettings = useAppSettingsStore();
const { screenPreferences } = storeToRefs(appSettings);
const screenList = ref(getAllScreens());
Expand Down Expand Up @@ -178,13 +171,21 @@ watch(
);
const targetScreenListener = (event: CustomEventInit) => {
console.log('targetScreen-update', event.detail);
screenPreferences.value.preferredScreenNumber = event.detail;
try {
console.log('targetScreen-update', event.detail);
screenPreferences.value.preferredScreenNumber = event.detail;
} catch (error) {
console.error(error);
}
};
const windowedModeListener = (event: CustomEventInit) => {
console.log('windowedMode-update', event.detail);
screenPreferences.value.preferWindowed = event.detail;
try {
console.log('windowedMode-update', event.detail);
screenPreferences.value.preferWindowed = event.detail;
} catch (error) {
console.error(error);
}
};
onMounted(() => {
Expand Down
Loading

0 comments on commit 2c0c2a2

Please sign in to comment.