Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose the language in Preferences #163

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 51 additions & 43 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
![Linux Show Player Logo](https://raw.githubusercontent.com/wiki/FrancescoCeruti/linux-show-player/media/site_logo.png)
<h3 align="center"> Sound player designed for stage productions</h3>
<h3 align="center"> Cue player designed for stage productions</h3>

<p align="center">
<a href="https://github.com/FrancescoCeruti/linux-show-player/blob/master/LICENSE"><img alt="License: GPL" src="https://img.shields.io/badge/license-GPL-blue.svg"></a>
<a href="https://github.com/FrancescoCeruti/linux-show-player/releases/latest"><img src="https://img.shields.io/github/release/FrancescoCeruti/linux-show-player.svg?maxAge=2592000" alt="GitHub release" /></a>
<a href="https://github.com/FrancescoCeruti/linux-show-player/releases"><img src="https://img.shields.io/github/downloads/FrancescoCeruti/linux-show-player/total.svg?maxAge=2592000" alt="Github All Releases" /></a>
<a href="https://landscape.io/github/FrancescoCeruti/linux-show-player/master"><img src="https://landscape.io/github/FrancescoCeruti/linux-show-player/master/landscape.svg?style=flat" alt="Code Health" /></a>
<a href="https://www.codacy.com/app/ceppofrancy/linux-show-player?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FrancescoCeruti/linux-show-player&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/bef08c3ae14e4953962b7e4bc82a0c03" alt="Code Health" /></a>
<a href="https://gitter.im/linux-show-player/linux-show-player"><img src="https://img.shields.io/gitter/room/nwjs/nw.js.svg?maxAge=2592000" alt="Gitter" /></a>
<a href="https://github.com/ambv/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"></a>
<a href="https://saythanks.io/to/FrancescoCeruti"><img src="https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg" alt="Say Thanks!"></a>
Expand Down Expand Up @@ -37,11 +37,11 @@ Tested on the following systems *(it should work on newer versions)*:

### Usage

Use the installed launcher from the menu (for the package installation), or
Use the installed launcher from the menu, or:

$ linux-show-player # Launch the program
$ linux-show-player -l [debug/warning/info] # Launch with different log options
$ linux-show-player -f <file/path> # Open a saved session
$ linux-show-player --locale <locale> # Launch using the given locale

*User documentation downloaded under the GitHub release page or [viewed online](http://linux-show-player-users.readthedocs.io/en/latest/index.html)*
User documentation can be downloaded under the GitHub release page or [viewed online](http://linux-show-player-users.readthedocs.io/en/latest/index.html)
13 changes: 8 additions & 5 deletions lisp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@
__email__ = "ceppofrancy@gmail.com"
__url__ = "https://github.com/FrancescoCeruti/linux-show-player"
__license__ = "GPLv3"
__version__ = "0.6.0.dev0"
__version_info__ = (0, 6, 0, "dev0")
__version__ = ".".join(map(str, __version_info__))

# The version passed follows <major>.<minor>
app_dirs = AppDirs(
"LinuxShowPlayer", version="{}.{}".format(*__version_info__[0:2])
)

# Application wide "constants"
APP_DIR = path.dirname(__file__)

# The version passed follows <major>.<minor>
USER_DIRS = AppDirs("LinuxShowPlayer", version=".".join(__version__.split(".")[0:2]))

DEFAULT_APP_CONFIG = path.join(APP_DIR, "default.json")
USER_APP_CONFIG = path.join(USER_DIRS.user_config_dir, "lisp.json")
USER_APP_CONFIG = path.join(app_dirs.user_config_dir, "lisp.json")

I18N_PATH = path.join(APP_DIR, "i18n", "qm")

Expand Down
24 changes: 11 additions & 13 deletions lisp/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
from lisp.ui.layoutselect import LayoutSelect
from lisp.ui.mainwindow import MainWindow
from lisp.ui.settings.app_configuration import AppConfigurationDialog
from lisp.ui.settings.app_pages.general import AppGeneral
from lisp.ui.settings.app_pages.cue import CueAppSettings
from lisp.ui.settings.app_pages.general import AppGeneral
from lisp.ui.settings.app_pages.layouts import LayoutsSettings
from lisp.ui.settings.app_pages.plugins import PluginsSettings
from lisp.ui.settings.cue_pages.cue_appearance import Appearance
Expand Down Expand Up @@ -118,27 +118,25 @@ def start(self, session_file=""):
def finalize(self):
self._delete_session()

self.__main_window = None
self.__cue_model = None
self.__main_window = None

def _new_session_dialog(self):
"""Show the layout-selection dialog"""
try:
# Prompt the user for a new layout
dialog = LayoutSelect(parent=self.window)
if dialog.exec_() == QDialog.Accepted:
# If a valid file is selected load it, otherwise load the layout
if exists(dialog.filepath):
self._load_from_file(dialog.filepath)
dialog = LayoutSelect(self, parent=self.window)
if dialog.exec() == QDialog.Accepted:
# If a file is selected load it, otherwise load the layout
if dialog.sessionPath:
self._load_from_file(dialog.sessionPath)
else:
self._new_session(dialog.selected())
else:
if self.__session is None:
# If the user close the dialog, and no layout exists
# the application is closed
self.finalize()
qApp.quit()
exit(0)
except Exception:
logger.critical(
translate("ApplicationError", "Startup error"), exc_info=True
Expand All @@ -149,7 +147,7 @@ def _new_session(self, layout):
self._delete_session()

self.__session = Session(layout(application=self))
self.__main_window.set_session(self.__session)
self.__main_window.setSession(self.__session)

self.session_created.emit(self.__session)

Expand All @@ -167,7 +165,7 @@ def _save_to_file(self, session_file):
self.session.session_file = session_file

# Save session path
self.conf.set("session.last_path", dirname(session_file))
self.conf.set("session.last_dir", dirname(session_file))
self.conf.write()

# Add the cues
Expand All @@ -193,7 +191,7 @@ def _save_to_file(self, session_file):
file.write(json.dumps(session_dict, sort_keys=True, indent=4))

MainActionsHandler.set_saved()
self.__main_window.update_window_title()
self.__main_window.updateWindowTitle()

def _load_from_file(self, session_file):
""" Load a saved session from file """
Expand Down Expand Up @@ -226,7 +224,7 @@ def _load_from_file(self, session_file):
)

MainActionsHandler.set_saved()
self.__main_window.update_window_title()
self.__main_window.updateWindowTitle()
except Exception:
logger.exception(
translate(
Expand Down
10 changes: 3 additions & 7 deletions lisp/core/actions_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@ class ActionsHandler:
UNDO_ACTION_STR = translate("Actions", "Undo: {}")
REDO_ACTION_STR = translate("Actions", "Redo: {}")

def __init__(self, stack_size=-1):
def __init__(self, stack_size=None):
super().__init__()

self.action_done = Signal()
self.action_undone = Signal()
self.action_redone = Signal()

self._undo = deque()
self._redo = deque()

if stack_size > 0:
self._undo.maxlen = stack_size
self._redo.maxlen = stack_size
self._undo = deque(maxlen=stack_size)
self._redo = deque(maxlen=stack_size)

self._saved_action = None

Expand Down
5 changes: 2 additions & 3 deletions lisp/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def get(self, path, default=_UNSET):
return node[key]
except (KeyError, TypeError):
if default is not _UNSET:
logger.warning(
logger.info(
translate(
"ConfigurationWarning",
"ConfigurationInfo",
'Invalid path "{}", return default.',
).format(path)
)
Expand Down Expand Up @@ -252,7 +252,6 @@ def _read_json(path):
return json.load(f)


# TODO: we should remove this in favor of a non-singleton
class AppConfig(JSONFileConfiguration, metaclass=ABCSingleton):
"""Provide access to the application configuration (singleton)"""

Expand Down
2 changes: 1 addition & 1 deletion lisp/core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def locked(*args, **kwargs):


def locked_method(target=None, *, blocking=True, timeout=-1):
"""Decorator. Make a *method* synchronized.
"""Decorator. Make a *method* "synchronized".

Only one thread at time can access the decorated method.

Expand Down
2 changes: 1 addition & 1 deletion lisp/core/fade_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Python porting of qtractor fade functions
## This file is part of Linux Show Player
# This file is part of Linux Show Player
#
# Copyright 2016 Francesco Ceruti <ceppofrancy@gmail.com>
#
Expand Down
17 changes: 11 additions & 6 deletions lisp/core/memento_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Linux Show Player. If not, see <http://www.gnu.org/licenses/>.

from contextlib import contextmanager

from lisp.core.actions_handler import MainActionsHandler
from lisp.core.memento_model_actions import (
AddItemAction,
Expand Down Expand Up @@ -55,18 +57,21 @@ def _item_removed(self, item):
if not self._locked:
self._handler.do_action(self._remove_action(self, self.model, item))

def _model_reset(self):
"""Reset cannot be reverted"""

@contextmanager
def lock(self):
self._locked = True

def unlock(self):
self._locked = False

def _model_reset(self):
"""Reset cannot be reverted"""
try:
yield self
finally:
self._locked = False


class MementoModelAdapter(MementoModel):
"""Extension of the MementoModel that use a ModelAdapter as a base-model"""
"""Extension of the MementoModel that can handle ModelAdapter(s)."""

def __init__(self, model_adapter, handler=None):
super().__init__(model_adapter, handler)
Expand Down
10 changes: 2 additions & 8 deletions lisp/core/memento_model_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ def do(self):
pass

def undo(self):
try:
self._m_model.lock()
with self._m_model.lock():
self.__undo__()
finally:
self._m_model.unlock()

def redo(self):
try:
self._m_model.lock()
with self._m_model.lock():
self.__redo__()
finally:
self._m_model.unlock()

@abstractmethod
def __undo__(self):
Expand Down
1 change: 1 addition & 0 deletions lisp/core/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Plugin:
Config = DummyConfiguration()

def __init__(self, app):
""":type app: lisp.application.Application"""
self.__app = app

@property
Expand Down
Loading