Skip to content

Commit

Permalink
Added option to make user input persistent (Fixes oliverschwendener#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed May 23, 2019
1 parent 0d79883 commit 322cb77
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 6 deletions.
2 changes: 1 addition & 1 deletion main.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div id="app">
<user-styles :appearance="config.appearanceOptions" :colortheme="config.colorThemeOptions"></user-styles>
<user-input :appearance="config.appearanceOptions" :translations="translations"></user-input>
<user-input :config="config" :translations="translations"></user-input>
<search-results :appearance="config.appearanceOptions"></search-results>
</div>
<script src="./bundle/renderer.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/common/config/default-general-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const defaultGeneralOptions: GeneralOptions = {
},
language: Language.English,
logExecution: true,
persistentUserInput: false,
rememberWindowPosition: false,
rescanEnabled: true,
rescanIntervalInSeconds: 300,
Expand Down
1 change: 1 addition & 0 deletions src/common/config/general-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface GeneralOptions {
hotKey: GlobalHotKey;
language: Language;
logExecution: boolean;
persistentUserInput: boolean;
rememberWindowPosition: boolean;
rescanEnabled: boolean;
rescanIntervalInSeconds: number;
Expand Down
1 change: 1 addition & 0 deletions src/common/ipc-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum IpcChannels {
openSettingsWindow = "open-settings-window",
configUpdated = "config-updated",
appearanceOptionsUpdated = "user-styles-updated",
generalOptionsUpdated = "general-options-updated",
languageUpdated = "language-updated",
colorThemeOptionsUpdated = "color-theme-updated",
ueliCommandExecuted = "ueli-command-executed",
Expand Down
4 changes: 4 additions & 0 deletions src/common/translation/english-translation-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const englishTranslationSet: TranslationSet = {
generalSettings: "General",
generalSettingsLanguage: "Language",
generalSettingsLogExecution: "Log execution",
generalSettingsPersistentUserInput: "Peristent user input",
generalSettingsAutostartApp: "Autostart app on system startup",
generalSettingsShowTrayIcon: "Show tray icon",
generalSettingsClearCachesOnExit: "Clear caches on quit",
Expand Down Expand Up @@ -267,6 +268,9 @@ export const englishTranslationSet: TranslationSet = {
commandlinePrefix: "Prefix",
commandlineSettingsDescription: "This plugin enables you to quickly execute commandline commands.",

simpleFolderSearch: "Simple folder search",
simpleFolderSearchDescription: "This plugin enables you to quickly search for files or folders",

cancel: "Cancel",
save: "Save",
add: "Add",
Expand Down
4 changes: 4 additions & 0 deletions src/common/translation/german-translation-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const germanTranslationSet: TranslationSet = {
generalSettings: "Allgemein",
generalSettingsLanguage: "Sprache",
generalSettingsLogExecution: "Ausführungen loggen",
generalSettingsPersistentUserInput: "Persistente Benutzereingabe",
generalSettingsAutostartApp: "App bei Systemstart starten",
generalSettingsShowTrayIcon: "Symbol im Systemtray anzeigen",
generalSettingsClearCachesOnExit: "Zwischenspeicher beim Beenden löschen",
Expand Down Expand Up @@ -267,6 +268,9 @@ export const germanTranslationSet: TranslationSet = {
commandlinePrefix: "Präfix",
commandlineSettingsDescription: "Dieses Plugin erlaubt es dir schnell Kommandozeilenbefehle auszuführen.",

simpleFolderSearch: "Einfache Ordnersuche",
simpleFolderSearchDescription: "Dieses Plugin erlaubt es dir, schnell Dateien und Ordner zu finden.",

cancel: "Abbrechen",
save: "Speichern",
add: "Hinzufügen",
Expand Down
4 changes: 4 additions & 0 deletions src/common/translation/translation-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface TranslationSet {
generalSettings: string;
generalSettingsLanguage: string;
generalSettingsLogExecution: string;
generalSettingsPersistentUserInput: string;
generalSettingsAutostartApp: string;
generalSettingsShowTrayIcon: string;
generalSettingsClearCachesOnExit: string;
Expand Down Expand Up @@ -264,6 +265,9 @@ export interface TranslationSet {
commandlinePrefix: string;
commandlineSettingsDescription: string;

simpleFolderSearch: string;
simpleFolderSearchDescription: string;

cancel: string;
save: string;
add: string;
Expand Down
4 changes: 4 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ function updateConfig(updatedConfig: UserConfigOptions, needsIndexRefresh: boole
mainWindow.webContents.send(IpcChannels.colorThemeOptionsUpdated, updatedConfig.colorThemeOptions);
}

if (JSON.stringify(updatedConfig.generalOptions) !== JSON.stringify(config.generalOptions)) {
mainWindow.webContents.send(IpcChannels.generalOptionsUpdated, updatedConfig.generalOptions);
}

config = updatedConfig;

updateTrayIcon(updatedConfig);
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import { workflowEditingModal } from "./settings/modals/workflow-editing-modal-c
import { commandlineSettingsComponent } from "./settings/commandline-settings-component";
import { tagsEditingComponent } from "./settings/tags-editing-component";
import { TranslationSet } from "../common/translation/translation-set";
import { simpleFolderSearchSettingsComponent } from "./settings/simple-folder-search-settings-component";
import { GeneralOptions } from "../common/config/general-options";

Vue.component("user-input", userInputComponent);
Vue.component("search-results", searchResultsComponent);
Expand Down Expand Up @@ -82,6 +84,7 @@ Vue.component("currency-converter-settings", currencyConverterSettingsComponent)
Vue.component("workflow-settings", workflowSettingsComponent);
Vue.component("workflow-editing-modal", workflowEditingModal);
Vue.component("commandline-settings", commandlineSettingsComponent);
Vue.component("simple-folder-search-settings", simpleFolderSearchSettingsComponent);

const initialConfig = new ElectronStoreConfigRepository(cloneDeep(defaultUserConfigOptions)).getConfig();

Expand Down Expand Up @@ -148,6 +151,10 @@ const app = new Vue({
vueEventDispatcher.$emit(VueEventChannels.appearanceOptionsUpdated, updatedAppearanceOptions);
});

ipcRenderer.on(IpcChannels.generalOptionsUpdated, (event: Electron.Event, updatedGeneralOptions: GeneralOptions) => {
vueEventDispatcher.$emit(VueEventChannels.generalOptionsUpdated, updatedGeneralOptions);
});

ipcRenderer.on(IpcChannels.languageUpdated, (event: Electron.Event, updatedTranslationSet: TranslationSet) => {
this.translations = updatedTranslationSet;
});
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/settings/general-settings-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ export const generalSettingsComponent = Vue.extend({
</div>
</div>
<div class="settings__option">
<div class="settings__option-name">{{ translations.generalSettingsPersistentUserInput }}</div>
<div class="settings__option-content">
<div class="field has-addons has-addons-right vertical-center">
<div class="control">
<input id="persistentUserInput" type="checkbox" name="persistentUserInput" class="switch is-rounded is-success" checked="checked" v-model="config.generalOptions.persistentUserInput" @change="updateConfig">
<label for="persistentUserInput"></label>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
21 changes: 16 additions & 5 deletions src/renderer/user-input-component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { vueEventDispatcher } from "./vue-event-dispatcher";
import { VueEventChannels } from "./vue-event-channels";
import Vue from "vue";
import { AppearanceOptions } from "../common/config/appearance-options";
import { showLoaderDelay } from "./renderer-helpers";
import { UserConfigOptions } from "../common/config/user-config-options";
import { AppearanceOptions } from "../common/config/appearance-options";
import { GeneralOptions } from "../common/config/general-options";

export const userInputComponent = Vue.extend({
data() {
Expand Down Expand Up @@ -63,12 +65,15 @@ export const userInputComponent = Vue.extend({
}
},
},
props: ["appearance", "translations"],
props: ["config", "translations"],
mounted() {
this.setFocusOnInput();

vueEventDispatcher.$on(VueEventChannels.mainWindowHasBeenHidden, () => {
this.resetUserInput();
const config: UserConfigOptions = this.config;
if (!config.generalOptions.persistentUserInput) {
this.resetUserInput();
}
});

vueEventDispatcher.$on(VueEventChannels.mainWindowHasBeenShown, () => {
Expand Down Expand Up @@ -108,12 +113,18 @@ export const userInputComponent = Vue.extend({
});

vueEventDispatcher.$on(VueEventChannels.appearanceOptionsUpdated, (updatedAppearanceOptions: AppearanceOptions) => {
this.appearance = updatedAppearanceOptions;
const config: UserConfigOptions = this.config;
config.appearanceOptions = updatedAppearanceOptions;
});

vueEventDispatcher.$on(VueEventChannels.generalOptionsUpdated, (updatedGeneralOptions: GeneralOptions) => {
const config: UserConfigOptions = this.config;
config.generalOptions = updatedGeneralOptions;
});
},
template: `
<div class="user-input">
<div v-if="appearance.showSearchIcon" class="user-input__search-icon-container">
<div v-if="config.appearanceOptions.showSearchIcon" class="user-input__search-icon-container">
<svg v-if="loadingVisible" class="user-input__search-icon spinning" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
<path style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;block-progression:tb;isolation:auto;mix-blend-mode:normal" d="M 25.005859 2.0019531 C 15.493404 2.0019531 7.3305415 7.7905748 3.8339844 16.039062 A 1.0001 1.0001 0 0 0 3.7675781 16.173828 C 3.6837741 16.37569 3.616691 16.580251 3.5390625 16.783203 C 3.434058 17.057243 3.3232142 17.328448 3.2285156 17.607422 C 3.0554711 18.116722 2.8997334 18.628986 2.7636719 19.142578 A 1.0001 1.0001 0 0 0 2.7597656 19.158203 C 2.751634 19.189254 2.7404267 19.218898 2.7324219 19.25 A 1.0004882 1.0004882 0 0 0 4.6699219 19.75 C 4.6736431 19.735542 4.6778894 19.721477 4.6816406 19.707031 C 4.8102764 19.211645 4.9618398 18.726577 5.125 18.246094 C 5.2112418 17.992456 5.311639 17.740453 5.4082031 17.488281 C 8.4305276 9.6077363 16.048971 4.0019531 25.005859 4.0019531 C 36.614403 4.0019531 46.003906 13.391456 46.003906 25 A 1.0001 1.0001 0 1 0 48.003906 25 C 48.003906 12.310544 37.695315 2.0019531 25.005859 2.0019531 z M 2.7089844 24.091797 L 2.0644531 24.714844 L 2.0078125 25.0625 L 2.0234375 26.003906 L 2.0253906 26.033203 L 2.0273438 26.060547 L 2.1191406 27.308594 L 2.1210938 27.337891 L 2.125 27.365234 L 2.2890625 28.603516 L 2.2929688 28.630859 L 2.2988281 28.658203 L 2.5292969 29.882812 L 2.5351562 29.910156 L 2.5429688 29.9375 L 2.7890625 30.929688 L 3.3730469 31.611328 L 4.2675781 31.550781 L 4.7539062 30.798828 L 4.7304688 30.447266 L 4.4882812 29.474609 L 4.2714844 28.341797 L 4.2695312 28.324219 L 4.1132812 27.134766 L 4.0234375 25.929688 L 4.0214844 25.912109 L 4.0078125 25.029297 L 3.59375 24.234375 L 2.7089844 24.091797 z M 6.0527344 34.955078 L 5.2089844 35.261719 L 4.9492188 36.119141 L 5.0703125 36.449219 L 5.4257812 37.064453 L 5.4414062 37.089844 L 5.4550781 37.113281 L 6.1386719 38.152344 L 6.1542969 38.175781 L 6.171875 38.199219 L 6.9140625 39.201172 L 6.9296875 39.224609 L 6.9492188 39.246094 L 7.7480469 40.207031 L 7.7675781 40.228516 L 7.7871094 40.25 L 8.6445312 41.167969 L 9.484375 41.478516 L 10.236328 40.992188 L 10.296875 40.097656 L 10.105469 39.802734 L 9.2597656 38.898438 L 9.2480469 38.884766 L 8.5019531 37.986328 L 7.8105469 37.054688 L 7.1582031 36.064453 L 7.1523438 36.052734 L 6.8007812 35.447266 L 6.0527344 34.955078 z M 40.388672 39.710938 A 1.0001 1.0001 0 0 0 39.699219 40.005859 C 39.471328 40.228983 39.23943 40.446477 39.001953 40.658203 A 1.0001 1.0001 0 1 0 40.332031 42.150391 C 40.592554 41.918117 40.847547 41.680423 41.097656 41.435547 A 1.0001 1.0001 0 0 0 40.388672 39.710938 z M 13.808594 42.970703 A 1.0001 1.0001 0 0 0 13.373047 44.839844 C 14.263676 45.360422 15.200023 45.829005 16.179688 46.236328 A 1.000376 1.000376 0 0 0 16.234375 46.255859 C 16.540377 46.38268 16.847719 46.503491 17.15625 46.615234 A 1.0001 1.0001 0 1 0 17.835938 44.734375 C 17.538788 44.626754 17.243239 44.511418 16.949219 44.388672 A 1.0001 1.0001 0 0 0 16.947266 44.388672 C 16.05093 44.015995 15.196185 43.588703 14.382812 43.113281 A 1.0001 1.0001 0 0 0 13.808594 42.970703 z M 34.226562 43.947266 L 33.884766 44.027344 L 32.857422 44.472656 L 32.84375 44.478516 L 31.941406 44.802734 L 31.324219 45.453125 L 31.474609 46.335938 L 32.273438 46.744141 L 32.619141 46.685547 L 33.535156 46.355469 L 33.564453 46.34375 L 33.59375 46.332031 L 34.677734 45.863281 L 35.253906 45.175781 L 35.048828 44.304688 L 34.226562 43.947266 z M 25.902344 45.96875 L 25.404297 45.998047 L 23.849609 45.970703 L 23.849609 45.992188 L 23.0625 46.300781 L 22.826172 47.164062 L 23.376953 47.871094 L 23.716797 47.964844 L 23.744141 47.966797 L 23.78125 47.970703 L 23.818359 47.970703 L 25.427734 47.998047 L 25.464844 47.998047 L 25.501953 47.996094 L 26.017578 47.966797 L 26.794922 47.519531 L 26.902344 46.630859 L 26.253906 46.011719 L 25.902344 45.96875 z" font-weight="400" font-family="sans-serif" white-space="normal" overflow="visible"></path>
</svg>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/vue-event-channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum VueEventChannels {
loadingStarted = "loading-started",
loadingCompleted = "loading-completed",
appearanceOptionsUpdated = "user-styles-udpated",
generalOptionsUpdated = "general-options-updated",
colorThemeOptionsUpdated = "color-theme-options-updated",
openShortcutEditingModal = "add-new-shortcut-button-clicked",
shortcutEdited = "shortcut-edited",
Expand Down

0 comments on commit 322cb77

Please sign in to comment.