######################################################################################################################
# Copyright (C) 2017 - 2019 Spine project consortium
# This file is part of Spine Toolbox.
# Spine Toolbox is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
# any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################################################################
"""
Application constants and style sheets
:author: P. Savolainen (VTT)
:date: 2.1.2018
"""
import sys
import os
[docs]REQUIRED_SPINEDB_API_VERSION = "0.0.36"
# SPINE GREEN HTML: #99cc33 RGBa: 153, 204, 51, 255
# SPINE BLUE HTML: #004ac2 RGBa: 0, 74, 194, 255
# Invalid characters for directory names
# NOTE: "." is actually valid in a directory name but this is
# to prevent the user from creating directories like /..../
[docs]INVALID_CHARS = ["<", ">", ":", "\"", "/", "\\", "|", "?", "*", "."]
# Invalid characters for file names
[docs]INVALID_FILENAME_CHARS = ["<", ">", ":", "\"", "/", "\\", "|", "?", "*"]
# Paths to application, configuration file, default project and work dirs, and documentation index page
if getattr(sys, "frozen", False):
[docs] APPLICATION_PATH = os.path.realpath(os.path.dirname(sys.executable))
DEFAULT_PROJECT_DIR = os.path.abspath(os.path.join(APPLICATION_PATH, "projects"))
DEFAULT_WORK_DIR = os.path.abspath(os.path.join(APPLICATION_PATH, "work"))
DOCUMENTATION_PATH = os.path.abspath(os.path.join(APPLICATION_PATH, "docs", "html"))
else:
APPLICATION_PATH = os.path.realpath(os.path.dirname(__file__))
DEFAULT_PROJECT_DIR = os.path.abspath(os.path.join(APPLICATION_PATH, os.path.pardir, "projects"))
DEFAULT_WORK_DIR = os.path.abspath(os.path.join(APPLICATION_PATH, os.path.pardir, "work"))
DOCUMENTATION_PATH = os.path.abspath(os.path.join(APPLICATION_PATH, os.path.pardir, "docs", "build", "html"))
# Tool output directory name
# GAMS
if sys.platform != "win32":
[docs] GAMS_EXECUTABLE = "gams"
GAMSIDE_EXECUTABLE = "gamside"
else:
GAMS_EXECUTABLE = "gams.exe"
GAMSIDE_EXECUTABLE = "gamside.exe"
# Julia
if sys.platform != "win32":
[docs] JULIA_EXECUTABLE = "julia"
else:
JULIA_EXECUTABLE = "julia.exe"
# Python
if sys.platform != "win32":
[docs] PYTHON_EXECUTABLE = "python3"
else:
PYTHON_EXECUTABLE = "python.exe"
# Tool types
# Required and optional keywords for Tool template definition files
[docs]REQUIRED_KEYS = ['name', 'tooltype', 'includes']
[docs]OPTIONAL_KEYS = [
'description',
'short_name',
'inputfiles',
'inputfiles_opt',
'outputfiles',
'cmdline_args',
'execute_in_work',
]
[docs]LIST_REQUIRED_KEYS = ['includes', 'inputfiles', 'inputfiles_opt', 'outputfiles'] # These should be lists
# Julia REPL constants
[docs]JL_REPL_TIME_TO_DEAD = 5.0
[docs]JL_REPL_RESTART_LIMIT = 3
# Stylesheets
[docs]STATUSBAR_SS = (
"QStatusBar{" "background-color: #EBEBE0;" "border-width: 1px;" "border-color: gray;" "border-style: groove;}"
)
[docs]SETTINGS_SS = (
"#SettingsForm{background-color: ghostwhite;}"
"QLabel{color: black;}"
"QLineEdit{font-size: 11px;}"
"QGroupBox{border: 2px solid gray; "
"background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #80B0FF, stop: 1 #e6efff);"
"border-radius: 5px;"
"margin-top: 0.5em;}"
"QGroupBox:title{border-radius: 2px; "
"background-color: ghostwhite;"
"subcontrol-origin: margin;"
"subcontrol-position: top center;"
"padding-top: 0px;"
"padding-bottom: 0px;"
"padding-right: 3px;"
"padding-left: 3px;}"
"QCheckBox{outline-style: dashed; outline-width: 1px; outline-color: white;}"
"QPushButton{background-color: #505F69; border: 1px solid #29353d; color: #F0F0F0; border-radius: 4px; padding: 3px; outline: none;}"
"QPushButton:disabled {background-color: #32414B; border: 1px solid #29353d; color: #787878; border-radius: 4px; padding: 3px;}"
"QPushButton::menu-indicator {subcontrol-origin: padding; subcontrol-position: bottom right; bottom: 4px;}"
"QPushButton:focus{background-color: #637683; border: 1px solid #148CD2;}"
"QPushButton:hover{border: 1px solid #148CD2; color: #F0F0F0;}"
"QPushButton:pressed{background-color: #19232D; border: 1px solid #19232D;}"
)
# NOTE: border-style property needs to be set for QToolBar so the lineargradient works on GNOME desktop environment
# (known Qt issue)
"background: qlineargradient(x1: 1, y1: 1, x2: 0, y2: 0, stop: 0 #cce0ff, stop: 1 #66a1ff);"
"padding: 3px;"
"border-style: solid;}"
"QToolButton{background-color: white;"
"border-width: 1px;"
"border-style: inset;"
"border-color: darkslategray;"
"border-radius: 2px;}"
"QLabel{color:black;"
"padding: 3px;}"
)
"border-style: inset;}"
"QToolButton{border-style: outset;}"
)
[docs]TEXTBROWSER_SS = (
"QTextBrowser {background-color: #19232D; border: 1px solid #32414B; color: #F0F0F0; border-radius: 2px;}"
"QTextBrowser:hover,"
"QTextBrowser:selected,"
"QTextBrowser:pressed {border: 1px solid #668599;}"
)
# ToolboxUI stylesheet. A lot of widgets inherit this sheet.
[docs]MAINWINDOW_SS = (
"QMainWindow::separator{width: 3px; background-color: lightgray; border: 1px solid white;}"
"QPushButton{background-color: #505F69; border: 1px solid #29353d; color: #F0F0F0; "
"border-radius: 4px; padding: 3px; outline: none; min-width: 75px;}"
"QPushButton:disabled {background-color: #32414B; border: 1px solid #29353d; color: #787878; border-radius: 4px; padding: 3px;}"
"QPushButton::menu-indicator {subcontrol-origin: padding; subcontrol-position: bottom right; bottom: 4px;}"
"QPushButton:focus{background-color: #637683; border: 1px solid #148CD2;}"
"QPushButton:hover{border: 1px solid #148CD2; color: #F0F0F0;}"
"QPushButton:pressed{background-color: #19232D; border: 1px solid #19232D;}"
"QToolButton:focus{border-color: black; border-width: 1px; border-style: ridge;}"
"QToolButton:pressed{background-color: #f2f2f2;}"
"QToolButton::menu-indicator{width: 0px;}"
"QCheckBox{padding: 2px; spacing: 10px; outline-style: dashed; outline-width: 1px; outline-color: black;}"
"QComboBox:focus{border-color: black; border-width: 1px; border-style: ridge;}"
"QLineEdit:focus{border-color: black; border-width: 1px; border-style: ridge;}"
"QTextEdit:focus{border-color: black; border-width: 1px; border-style: ridge;}"
"QTreeView:focus{border-color: darkslategray; border-width: 2px; border-style: ridge;}"
)