Skip to content

Commit

Permalink
Fix issue #14
Browse files Browse the repository at this point in the history
Added a global setting to allow users to disable the custom titlebar if
the want
  • Loading branch information
amanharwara committed Mar 16, 2019
1 parent e0f4f82 commit 71c9499
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 72 deletions.
19 changes: 12 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ if (!singleInstanceLock) {
value: true,
name: 'Exit Prompt',
description: 'If this setting is enabled, the app will prompt you everytime you close the app. Disabling this will disable the prompt.'
},
customTitlebar: {
value: true,
name: 'Custom Titlebar',
description: 'If you are having any issues with the custom titlebar, you can disable it using this setting. NOTE: This setting requires you to restart the whole app for changes to apply.'
}
}
});
Expand All @@ -86,7 +91,7 @@ if (!singleInstanceLock) {
app.on('ready', () => {
mainWindow = new BrowserWindow({
title: `Altus ${app.getVersion()}`,
frame: false,
frame: !settings.get('customTitlebar.value'),
titleBarStyle: 'hidden',
backgroundColor: '#282C34',
icon: './build/icon.ico',
Expand Down Expand Up @@ -290,7 +295,7 @@ function createWindow(id) {
} else {
aboutWindow = new BrowserWindow({
title: `About Altus`,
frame: false,
frame: !settings.get('customTitlebar.value'),
backgroundColor: '#282C34',
titleBarStyle: 'hidden',
width: 500,
Expand Down Expand Up @@ -320,7 +325,7 @@ function createWindow(id) {
} else {
settingsWindow = new BrowserWindow({
title: `Settings`,
frame: false,
frame: !settings.get('customTitlebar.value'),
backgroundColor: '#282C34',
titleBarStyle: 'hidden',
width: 400,
Expand Down Expand Up @@ -352,7 +357,7 @@ function createWindow(id) {
} else {
customCSSWindow = new BrowserWindow({
title: `Custom CSS for WhatsApp`,
frame: false,
frame: !settings.get('customTitlebar.value'),
backgroundColor: '#282C34',
titleBarStyle: 'hidden',
parent: mainWindow,
Expand Down Expand Up @@ -382,7 +387,7 @@ function createWindow(id) {
} else {
themeCustomizerWindow = new BrowserWindow({
title: `Customize Theme`,
frame: false,
frame: !settings.get('customTitlebar.value'),
backgroundColor: '#282C34',
titleBarStyle: 'hidden',
parent: mainWindow,
Expand Down Expand Up @@ -412,7 +417,7 @@ function createWindow(id) {
} else {
themeManagerWindow = new BrowserWindow({
title: `Manage Themes`,
frame: false,
frame: !settings.get('customTitlebar.value'),
backgroundColor: '#282C34',
titleBarStyle: 'hidden',
parent: mainWindow,
Expand Down Expand Up @@ -454,4 +459,4 @@ function confirmExit() {
return;
}
});
}
}
29 changes: 17 additions & 12 deletions src/windows/about/js/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ const {
const {
ipcRenderer
} = require('electron');
const Store = require('electron-store');

// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
});
let settings = new Store({name:'settings'});

document.querySelector('.altus-version').innerText = app.getVersion();
if (settings.get('customTitlebar.value') === true) {
// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
});

// Setting title explicitly
mainTitlebar.updateTitle(`About Altus`)
}

// Setting title explicitly
mainTitlebar.updateTitle(`About Altus`)
document.querySelector('.altus-version').innerText = app.getVersion();
28 changes: 17 additions & 11 deletions src/windows/customCSS/js/customCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ const {
ipcRenderer
} = require('electron');

// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
let settings = new Store({
name: 'settings'
});

if (settings.get('customTitlebar.value') === true){
// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
});

// Setting title explicitly
mainTitlebar.updateTitle(`Custom CSS for WhatsApp`);
}

let themes = new Store({
name: 'themes'
});
Expand Down Expand Up @@ -57,6 +66,3 @@ document.getElementById('themenameinput').addEventListener('focus', () => {
document.getElementById('customcssarea').addEventListener('focus', () => {
document.getElementById('customcssarea').parentElement.classList.remove('error');
});

// Setting title explicitly
mainTitlebar.updateTitle(`Custom CSS for WhatsApp`);
22 changes: 13 additions & 9 deletions src/windows/main/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ const Store = require('electron-store');
const generateId = require('uuid/v4');
const HTML = require('../assets/js/elementCodes.js');

// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
itemBackgroundColor: customTitlebar.Color.fromHex('#3d444e'),
});
let settings = new Store({name: 'settings'});

if (settings.get('customTitlebar.value') === true) {
// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
itemBackgroundColor: customTitlebar.Color.fromHex('#3d444e'),
});

// Setting title explicitly
mainTitlebar.updateTitle(`Altus ${app.getVersion()}`);
}

let tabs = new Store({
name: 'tabs',
Expand Down Expand Up @@ -307,6 +314,3 @@ function addNewInstance(instance) {
}

ipcRenderer.on('new-themes-added', e => window.location.reload(true));

// Setting title explicitly
mainTitlebar.updateTitle(`Altus ${app.getVersion()}`);
28 changes: 16 additions & 12 deletions src/windows/settings/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ const settings = new Store({
name: 'settings'
});

// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
});
if (settings.get('customTitlebar.value') === true) {
// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
});

// Setting title explicitly
mainTitlebar.updateTitle(`Settings`);
// Setting title explicitly
mainTitlebar.updateTitle(`Settings`);
}

// Load Settings
for (setting of settings) {
Expand Down Expand Up @@ -75,7 +77,9 @@ document.querySelector('#save-button').addEventListener('click', () => {
settings.set('trayIcon.value', document.querySelector('#trayIconButton').innerText == "Enabled" ? true : false);

settings.set('showExitPrompt.value', document.querySelector('#showExitPromptButton').innerText == "Enabled" ? true : false);

settings.set('customTitlebar.value', document.querySelector('#customTitlebarButton').innerText == "Enabled" ? true : false);

ipcRenderer.send('settings-changed', true);
BrowserWindow.getFocusedWindow().close();
});
});
29 changes: 18 additions & 11 deletions src/windows/themeCustomizer/js/themeCustomizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ const {
} = require('electron').remote;
const ClipboardJS = require('clipboard');
let cssClipboard = new ClipboardJS('#copy-css-button');
const Store = require('electron-store');

// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
const settings = new Store({
name: 'settings'
});

// Setting title explicitly
mainTitlebar.updateTitle(`Theme Customizer`);
if (settings.get('customTitlebar.value') === true) {
// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
});

// Setting title explicitly
mainTitlebar.updateTitle(`Theme Customizer`);
}

document.querySelectorAll('.color-input').forEach((e, i) => {
switch (i) {
Expand Down Expand Up @@ -141,4 +148,4 @@ cssClipboard.on('success', () => {
copyButton.innerHTML = '<i class="copy icon"></i> Copy CSS';
copyButton.disabled = false;
}, 500);
});
});
27 changes: 17 additions & 10 deletions src/windows/themeManager/js/themeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ const {
} = require('electron');
const Store = require('electron-store');
// Create main window titlebar
const mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
let mainTitlebar;

const settings = new Store({
name: 'settings'
});

if (settings.get('customTitlebar.value') === true) {
mainTitlebar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#21252B'),
icon: '../assets/icons/icon.ico',
menu: process.platform === 'darwin' ? Menu.getApplicationMenu() : new Menu(),
minimizable: false,
maximizable: false,
closeable: true
})
// Setting title explicitly
mainTitlebar.updateTitle(`Theme Manager`);
}

const themes = new Store({
name: 'themes'
});
Expand Down Expand Up @@ -66,6 +76,3 @@ document.getElementById('save-button').addEventListener('click', () => {
});

document.getElementById('reload-button').addEventListener('click', () => window.location.reload());

// Setting title explicitly
mainTitlebar.updateTitle(`Theme Manager`);

0 comments on commit 71c9499

Please sign in to comment.