1
0
Fork 0
mirror of https://github.com/mwalbeck/nextcloud-breeze-dark.git synced 2025-04-08 06:50:11 +00:00

Allow Breeze Dark theming of the login page to be disabled when the theme is enabled by default, fix ()

This commit is contained in:
Magnus Walbeck 2020-11-07 18:26:05 +01:00 committed by GitHub
parent 90ea3a5447
commit e832a708c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 21 deletions

View file

@ -9,6 +9,7 @@
- Add weather_status app icon and notes app icon
- [#173](https://github.com/mwalbeck/nextcloud-breeze-dark/issues/173) Add support for Forms
- Add icon-view-list icon for Calendar
- [#155](https://github.com/mwalbeck/nextcloud-breeze-dark/issues/155) Allow Breeze Dark theming of the login page to be disabled.
### Fixed

View file

@ -136,6 +136,11 @@
}
}
// Breeze Dark settings
.breezedark-admin p {
margin-top: 1em;
}
/* Tooltips ----------------------------------------------------------------- */
.tooltip,

View file

@ -23,9 +23,19 @@
*/
window.addEventListener("DOMContentLoaded", function () {
$("#breezedark-enabled").change(function () {
$("#breezedark-theme-enabled").change(function () {
$.post(OC.generateUrl("apps/breezedark/settings/admin"), {
theme_enabled: this.checked ? 1 : 0,
theme_login_page: $("#breezedark-theme-login-page").prop("checked") ? 1 : 0,
});
$("#breezedark-theme-login-page").prop("disabled", !$("#breezedark-theme-enabled").prop("checked"))
});
$("#breezedark-theme-login-page").change(function () {
$.post(OC.generateUrl("apps/breezedark/settings/admin"), {
theme_login_page: this.checked ? 1 : 0,
theme_enabled: $("#breezedark-theme-enabled").prop("checked") ? 1 : 0,
});
});
});

View file

@ -27,8 +27,6 @@
namespace OCA\BreezeDark\AppInfo;
use OCP\AppFramework\App;
use OCP\IConfig;
use OCP\IUserSession;
use OCP\Util;
class Application extends App {
@ -42,35 +40,41 @@ class Application extends App {
/** @var IConfig */
private $config;
/** @var IUserSession */
private $userSession;
/** @var IUser */
private $user;
public function __construct() {
parent::__construct(self::APP_NAME);
$this->appName = self::APP_NAME;
$this->config = \OC::$server->getConfig();
$this->userSession = \OC::$server->getUserSession();
$this->appName = self::APP_NAME;
$this->config = \OC::$server->getConfig();
$this->user = \OC::$server->getUserSession()->getUser();
}
/**
* Check if the theme should be applied
*/
public function doTheming() {
$user = $this->userSession->getUser();
$default = $this->config->getAppValue($this->appName, "theme_enabled", "0");
$loginPage = $this->config->getAppValue($this->appName, "theme_login_page", "1");
if (!is_null($user) AND $this->config->getUserValue($user->getUID(), $this->appName, "theme_enabled", $default)) {
$this->addStyling();
} else if (is_null($user) AND $default) {
$this->addStyling();
if (!is_null($this->user) AND $this->config->getUserValue($this->user->getUID(), $this->appName, "theme_enabled", $default)) {
$this->addStyling("0"); // A logged in user won't see the login page, so there is not need to load the styling
} else if (is_null($this->user) AND $default) {
$this->addStyling($loginPage);
}
}
/**
* Add stylesheets to the nextcloud
* Add stylesheet(s) to nextcloud
*
* @param string $loginPage
*/
public function addStyling() {
Util::addStyle($this->appName, 'guest');
public function addStyling($loginPage) {
Util::addStyle($this->appName, 'server');
// If the styling for the login page is wanted, load the stylesheet.
if ($loginPage) {
Util::addStyle($this->appName, 'guest');
}
}
}

View file

@ -79,5 +79,11 @@ class SettingsController extends Controller {
} else {
$this->config->setAppValue($this->appName, "theme_enabled", "0");
}
if ($this->request->getParam("theme_login_page")) {
$this->config->setAppValue($this->appName, "theme_login_page", "1");
} else {
$this->config->setAppValue($this->appName, "theme_login_page", "0");
}
}
}

View file

@ -53,8 +53,10 @@ class Admin implements ISettings {
*/
public function getForm() {
$themeEnabled = $this->config->getAppValue($this->appName, 'theme_enabled', "0");
$themeLoginPage = $this->config->getAppValue($this->appName, 'theme_login_page', "1");
return new TemplateResponse('breezedark', 'admin', [
"themeEnabled" => $themeEnabled
"themeEnabled" => $themeEnabled,
"themeLoginPage" => $themeLoginPage
]);
}

View file

@ -27,10 +27,13 @@
script('breezedark', 'settings-admin');
?>
<div id="breezedark" class="section">
<div id="breezedark" class="breezedark-admin section">
<h2><?php p($l->t("Breeze Dark")); ?></h2>
<p><?php p($l->t("A Dark theme based on Breeze Dark by the KDE project. Please refresh the page for changes to take effect.")); ?></p>
<p><?php p($l->t("This setting will enable the theme by default, for any unauthenticated users and users who haven't set a preference.")); ?></p>
<input type="checkbox" class="checkbox" id="breezedark-enabled" <?php p($themeEnabled ? "checked" : ""); ?>>
<label for="breezedark-enabled"><?php p($l->t("Enable Breeze Dark theme by default")); ?></label>
<input type="checkbox" class="checkbox" id="breezedark-theme-enabled" <?php p($themeEnabled ? "checked" : ""); ?>>
<label for="breezedark-theme-enabled"><?php p($l->t("Enable Breeze Dark theme by default")); ?></label>
<p><?php p($l->t("This setting will allow you to choose if the login page should be themed when the theme is enabled by default")); ?></p>
<input type="checkbox" class="checkbox" id="breezedark-theme-login-page" <?php p($themeEnabled ? "" : "disabled");?> <?php p($themeLoginPage ? "checked" : "");?>>
<label for="breezedark-theme-login-page"><?php p($l->t("Theme the login page")); ?></label>
</div>

View file

@ -27,7 +27,7 @@
script('breezedark', 'settings-personal');
?>
<div id="breezedark" class="section">
<div id="breezedark" class="breezedark-personal section">
<h2><?php p($l->t("Breeze Dark")); ?></h2>
<p><?php p($l->t("A Breeze Dark theme for Nextcloud.")); ?></p>
<div class="preview-list">