Skip to content

Commit

Permalink
Added maxWindowHeight to user config
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Sep 23, 2018
1 parent 3bdb11f commit b1cd1a0
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 19 deletions.
22 changes: 15 additions & 7 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<path d="M 7.21875 5.78125 L 5.78125 7.21875 L 14.5625 16 L 5.78125 24.78125 L 7.21875 26.21875 L 16 17.4375 L 24.78125 26.21875 L 26.21875 24.78125 L 17.4375 16 L 26.21875 7.21875 L 24.78125 5.78125 L 16 14.5625 Z "></path>
</g>
</svg>
<h1>App Settings</h1>
<h1 class="setting-section-title">App Settings</h1>
<div class="setting-group">
<div class="setting-title">Info</div>
<div class="setting">
Expand All @@ -65,13 +65,15 @@ <h1>App Settings</h1>
<div class="setting-group">
<div class="setting-title">Update</div>
<div class="setting">
<button v-if="(updateAvailable || noUpdateFound) === false" v-on:click="handleCheckForUpdateButtonClick" class="setting-button">Check for update</button>
<div v-if="updateAvailable">
<div v-if="(updateAvailable || noUpdateFound) === false" class="sub-setting">
<button v-on:click="handleCheckForUpdateButtonClick" class="setting-button">Check for update</button>
<span v-if="errorOnUpdateCheck" class="message text-error">There was an error while checking for updates :(</span>
</div>
<div v-if="updateAvailable" class="sub-setting">
<button v-if="updateAvailable && !downloadingUpdate" v-on:click="handleDownloadUpdateButtonClick" class="setting-button">Download & install update</button>
<button v-if="updateAvailable && downloadingUpdate" class="setting-button">Downloading...</button>
</div>
<div v-if="noUpdateFound">Your are running the latest version</div>
<div v-if="errorOnUpdateCheck">There was an error while checking for updates</div>
</div>
</div>
<div class="setting-group">
Expand All @@ -81,7 +83,7 @@ <h1>App Settings</h1>
</div>
</div>

<h1>User Settings</h1>
<h1 class="setting-section-title">User Settings</h1>
<div class="setting-group">
<div class="setting-title">Allow mouse interaction</div>
<div class="setting">
Expand Down Expand Up @@ -199,9 +201,9 @@ <h1>User Settings</h1>
</g>
</svg>
</div>
<div class="sub-setting">
<div v-if="config.fallbackWebSearches.length !== config.webSearches.length" class="sub-setting">
<select class="setting-select" v-model="configEdit.newFallbackWebSearch">
<option v-for="webSearch in config.webSearches" :value="webSearch.name">{{ webSearch.name }}</option>
<option v-for="webSearch in getUnusedFallbackWebSearches()" :value="webSearch.name">{{ webSearch.name }}</option>
</select>
<svg class="setting-action-icon" v-on:click="settingsActionAddFallbackWebSearch(configEdit.newFallbackWebSearch)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26 26">
<path d="M13.5,3.188C7.805,3.188,3.188,7.805,3.188,13.5S7.805,23.813,13.5,23.813S23.813,19.195,23.813,13.5 S19.195,3.188,13.5,3.188z M19,15h-4v4h-3v-4H8v-3h4V8h3v4h4V15z"></path>
Expand Down Expand Up @@ -263,6 +265,12 @@ <h1>User Settings</h1>
<input class="setting-text-input" type="number" v-model="config.maxSearchResultCount" min="0" v-on:blur="updateUserConfig">
</div>
</div>
<div class="setting-group">
<div class="setting-title">Maximum window height</div>
<div class="setting">
<input class="setting-text-input" type="number" v-model="config.maxWindowHeight" min="config.userInputHeight" v-on:blur="updateUserConfig">
</div>
</div>
<div class="setting-group">
<div class="setting-title">Rescan interval (in seconds)</div>
<div class="setting">
Expand Down
1 change: 1 addition & 0 deletions src/ts/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const defaultConfig: UserConfigOptions = {
hotKey: "alt+space",
logExecution: true,
maxSearchResultCount: 8,
maxWindowHeight: 560,
rescanInterval: 30,
searchEngineThreshold: 0.4,
searchEnvironmentVariables: false,
Expand Down
17 changes: 11 additions & 6 deletions src/ts/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { join } from "path";
import { platform } from "os";
import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray, screen } from "electron";
import { autoUpdater } from "electron-updater";
import { join } from "path";
import { FilePathExecutionArgumentValidator } from "./execution-argument-validators/file-path-execution-argument-validator";
import { ExecutionService } from "./execution-service";
import { FilePathExecutor } from "./executors/file-path-executor";
import { Injector } from "./injector";
import { InputValidationService } from "./input-validation-service";
import { IpcChannels } from "./ipc-channels";
import * as isInDevelopment from "electron-is-dev";
import { platform } from "os";
import { WindowHelpers } from "./helpers/winow-helpers";
import { ExecutionArgumentValidatorExecutorCombinationManager } from "./execution-argument-validator-executor-combination-manager";
import { InputValidatorSearcherCombinationManager } from "./input-validator-searcher-combination-manager";
Expand Down Expand Up @@ -69,7 +69,7 @@ function createMainWindow(): void {
});

mainWindow.loadURL(`file://${__dirname}/../main.html`);
mainWindow.setSize(config.windowWidth, config.userInputHeight);
setWindowHeightToMax();

mainWindow.on("close", quitApp);
mainWindow.on("blur", hideMainWindow);
Expand Down Expand Up @@ -157,12 +157,17 @@ function updateWindowSize(searchResultCount: number): void {
}
}

function setWindowHeightToMax(): void {
mainWindow.setSize(config.windowWidth, config.maxWindowHeight);
}

function showWindow() {
if (!config.alwaysShowOnPrimaryDisplay) {
const mousePosition = screen.getCursorScreenPoint();
const nearestDisplay = screen.getDisplayNearestPoint(mousePosition);
mainWindow.setBounds(nearestDisplay.bounds);
}

resetWindowToDefaultSizeAndPosition();
mainWindow.show();
}
Expand Down Expand Up @@ -205,7 +210,7 @@ function destroyTrayIcon(): void {
}

function resetWindowToDefaultSizeAndPosition(): void {
mainWindow.setSize(config.windowWidth, WindowHelpers.calculateMaxWindowHeight(config.userInputHeight, config.maxSearchResultCount, config.searchResultHeight));
setWindowHeightToMax();
mainWindow.center();
updateWindowSize(0);
}
Expand Down Expand Up @@ -256,7 +261,7 @@ ipcMain.on(IpcChannels.autoComplete, (event: any, executionArgument: string): vo

ipcMain.on(IpcChannels.commandLineExecution, (arg: string): void => {
mainWindow.webContents.send(IpcChannels.commandLineOutput, arg);
updateWindowSize(config.maxSearchResultCount);
setWindowHeightToMax();
});

ipcMain.on(IpcChannels.resetUserInput, (): void => {
Expand All @@ -268,7 +273,7 @@ ipcMain.on(IpcChannels.ueliCheckForUpdates, (): void => {
});

ipcMain.on(IpcChannels.showSettingsFromRenderer, (): void => {
updateWindowSize(config.maxSearchResultCount);
setWindowHeightToMax();
});

ipcMain.on(IpcChannels.hideSettings, (): void => {
Expand Down
7 changes: 7 additions & 0 deletions src/ts/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ const vue = new Vue({
colorTheme: (): string => {
return `./styles/${config.colorTheme}.css`;
},
getUnusedFallbackWebSearches: (): WebSearch[] => {
return config.webSearches.filter((w) => {
return config.fallbackWebSearches.filter((f) => {
return f === w.name;
}).length === 0;
});
},
handleCheckForUpdateButtonClick: (): void => {
ipcRenderer.send(IpcChannels.ueliCheckForUpdates);
vue.downloadingUpdate = true;
Expand Down
1 change: 1 addition & 0 deletions src/ts/user-config/user-config-file-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class UserConfigFileRepository {
}

private enforceDataTypes(config: UserConfigOptions): UserConfigOptions {
config.maxWindowHeight = Number(config.maxWindowHeight);
config.maxSearchResultCount = Number(config.maxSearchResultCount);
config.rescanInterval = Number(config.rescanInterval);
config.searchEngineThreshold = Number(config.searchEngineThreshold);
Expand Down
1 change: 1 addition & 0 deletions src/ts/user-config/user-config-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface UserConfigOptions {
hotKey: string;
logExecution: boolean;
maxSearchResultCount: number;
maxWindowHeight: number;
rescanInterval: number;
searchEngineThreshold: number;
searchEnvironmentVariables: boolean;
Expand Down
29 changes: 23 additions & 6 deletions styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--scrollbar-size: 8px;
--icon-size: 35px;
--transition-speed: 150ms;

--error-color: #e74c3c;
--font-family: "Segoe UI", "Helvetica";
--font-family-mono: "Consolas", "Courier", monospace;
--settings-font-size: 0.85rem;
Expand Down Expand Up @@ -141,6 +141,14 @@ div.settings-container {
font-size: var(--settings-font-size);
}

h1.setting-section-title {
margin-top: 75px;
}

h1.setting-section-title:first-of-type {
margin-top: 15px;
}

div.setting-group {
padding: calc(2* var(--side-padding)) 0;
display: flex;
Expand All @@ -153,7 +161,7 @@ div.setting-group:last-child {
}

div.setting-title {
font-size: var(--settings-font-size):
font-size: var(--settings-font-size);
padding-right: var(--side-padding);
display: flex;
align-items: center;
Expand All @@ -171,6 +179,7 @@ div.sub-setting {
}

input.setting-text-input {
transition: all var(--transition-speed) ease-in-out;
background-color: var(--scrollbar-background-color);
border: 1px solid var(--scrollbar-foreground-color);
outline: none;
Expand Down Expand Up @@ -231,10 +240,6 @@ td > svg {
width: 25px;
}

.text-center {
text-align: center;
}

svg.close-settings-icon {
cursor: pointer;
transition: all var(--transition-speed) ease-in-out;
Expand Down Expand Up @@ -266,6 +271,18 @@ button.setting-button:focus {
outline: none;
}

.text-center {
text-align: center;
}

.text-error {
color: var(--error-color);
}

.message {
padding: 0 5px;
}

::-webkit-scrollbar {
width: var(--scrollbar-size);
height: var(--scrollbar-size);
Expand Down

0 comments on commit b1cd1a0

Please sign in to comment.