From 02827071cb0a68ab99e7bb97ebeaea40875e0e2b Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 15:35:06 +0100 Subject: [PATCH 1/8] enlarged home icon size --- launcher/res/qml/Breadcrumbs.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/res/qml/Breadcrumbs.qml b/launcher/res/qml/Breadcrumbs.qml index 0ed1adc..7e21f92 100644 --- a/launcher/res/qml/Breadcrumbs.qml +++ b/launcher/res/qml/Breadcrumbs.qml @@ -13,7 +13,7 @@ Item { ToolButton { contentItem: AwesomeIcon { name: "home" - size: 12 + size: 20 } height: parent.height From 2a15344deb392f1d6c9b4438e35a302e07ce5405 Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 15:35:29 +0100 Subject: [PATCH 2/8] added footer button --- launcher/res/qml/main.qml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/launcher/res/qml/main.qml b/launcher/res/qml/main.qml index 8172b91..d3821ac 100644 --- a/launcher/res/qml/main.qml +++ b/launcher/res/qml/main.qml @@ -101,7 +101,18 @@ ApplicationWindow { } } - footer: MyToolBar { } + footer: MyToolBar { + MyButton { + + id: launchExplorerButton + implicitWidth: parent.height + implicitHeight: parent.height + icon: "folder-open" + Layout.alignment: Qt.AlignLeft + + onClicked: controller.launch_explorer() + } + } /** Main Layout * ____________________ From 7f156778c3d49c888cee5bbed37782ba3dfa3cc2 Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 15:35:54 +0100 Subject: [PATCH 3/8] added launch_explorer method --- launcher/control.py | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/launcher/control.py b/launcher/control.py index bd2a981..7bd1fa1 100644 --- a/launcher/control.py +++ b/launcher/control.py @@ -147,17 +147,6 @@ def launch(self, name): # TODO(marcus): These shouldn't be necessary # once the templates are used. # ---------------------------------------------------------------------- - template_rootpath = template_private.split("{silo}")[0] - template_assetpath = template_private.split("{asset}")[0] + "{asset}" - template_taskpath = template_private.split("{task}")[0] + "{task}" - - silospath = template_rootpath.format(**frame["environment"]) - assetpath = template_assetpath.format(**frame["environment"]) - taskpath = template_taskpath.format(**frame["environment"]) - - frame["environment"]["silospath"] = silospath - frame["environment"]["assetpath"] = assetpath - frame["environment"]["taskpath"] = taskpath frame["environment"]["workdir"] = workdir # ---------------------------------------------------------------------- @@ -314,6 +303,35 @@ def run(self): return process + @Slot() + def launch_explorer(self): + """Initial draft of this method is subject to change and might + migrate to""" + # Todo: find a cleaner way, with .toml file for example + + print(">>> Explorer ...") + + # Get the current environment + frame = self.current_frame() + frame["environment"]["root"] = self._root + + # When we are outside of any project, do nothing + config = frame.get("config", None) + if config is None: + print(">>> No project found in configuration") + return + + template = config['template']['work'] + path = lib.partial_format(template, frame["environment"]) + + # Keep only the part of the path that was formatted + path = os.path.normpath(path.split("{", 1)[0]) + + print(">>>", path) + if os.path.exists(path): + import subprocess + subprocess.Popen(r'explorer /select, "{}"'.format(path)) + def current_frame(self): """Shorthand for the current frame""" try: From b1a0cbeb2d40a5a02f0979248bba356d6e64286b Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 15:36:13 +0100 Subject: [PATCH 4/8] added partial_format function --- launcher/lib.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/launcher/lib.py b/launcher/lib.py index 5afee97..09bd588 100644 --- a/launcher/lib.py +++ b/launcher/lib.py @@ -1,6 +1,7 @@ import os import sys import subprocess +import string from avalon.vendor import six from PyQt5 import QtCore @@ -10,6 +11,11 @@ self._current_task = None +class FormatDict(dict): + def __missing__(self, key): + return "{" + key + "}" + + def resource(*path): path = os.path.join(self._path, "res", *path) return path.replace("\\", "/") @@ -186,3 +192,11 @@ def launch(executable, args=None, environment=None, cwd=None): def stream(stream): for line in iter(stream.readline, ""): yield line + + +def partial_format(s, mapping): + + formatter = string.Formatter() + mapping = FormatDict(**mapping) + + return formatter.vformat(s, (), mapping) From 4c9dfbe52d3a565236da0a48d0287dd7f77f0150 Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 16:01:23 +0100 Subject: [PATCH 5/8] downsize home icon by 2 px --- launcher/res/qml/Breadcrumbs.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/res/qml/Breadcrumbs.qml b/launcher/res/qml/Breadcrumbs.qml index 7e21f92..c2a3f67 100644 --- a/launcher/res/qml/Breadcrumbs.qml +++ b/launcher/res/qml/Breadcrumbs.qml @@ -13,7 +13,7 @@ Item { ToolButton { contentItem: AwesomeIcon { name: "home" - size: 20 + size: 18 } height: parent.height From 1c488131e46f9cf0978eabddf1dfcf028ec6b3ed Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 16:02:07 +0100 Subject: [PATCH 6/8] open folder instead of select, cosmetics --- launcher/control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/control.py b/launcher/control.py index 7bd1fa1..bd3a079 100644 --- a/launcher/control.py +++ b/launcher/control.py @@ -306,7 +306,7 @@ def run(self): @Slot() def launch_explorer(self): """Initial draft of this method is subject to change and might - migrate to""" + migrate to another module""" # Todo: find a cleaner way, with .toml file for example print(">>> Explorer ...") @@ -330,7 +330,7 @@ def launch_explorer(self): print(">>>", path) if os.path.exists(path): import subprocess - subprocess.Popen(r'explorer /select, "{}"'.format(path)) + subprocess.Popen(r'explorer "{}"'.format(path)) def current_frame(self): """Shorthand for the current frame""" From 287304b487804f5af38c0dd72ae0022ab690e97d Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 16:02:24 +0100 Subject: [PATCH 7/8] moved button to right top --- launcher/res/qml/main.qml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/launcher/res/qml/main.qml b/launcher/res/qml/main.qml index d3821ac..a51f8d3 100644 --- a/launcher/res/qml/main.qml +++ b/launcher/res/qml/main.qml @@ -74,6 +74,21 @@ ApplicationWindow { model: controller.breadcrumbs } + /** Open explorer in set context based on template + */ + MyButton { + + id: launchExplorerButton + implicitWidth: parent.height + implicitHeight: parent.height + icon: "folder-open" + Layout.alignment: Qt.AlignLeft + + onClicked: controller.launch_explorer() + + opacity: 0.4 + } + /** Toggle Terminal on/off */ MyButton { @@ -101,18 +116,7 @@ ApplicationWindow { } } - footer: MyToolBar { - MyButton { - - id: launchExplorerButton - implicitWidth: parent.height - implicitHeight: parent.height - icon: "folder-open" - Layout.alignment: Qt.AlignLeft - - onClicked: controller.launch_explorer() - } - } + footer: MyToolBar { } /** Main Layout * ____________________ From a9a05aa2324758193ed35655442a3a97ea733d93 Mon Sep 17 00:00:00 2001 From: aardschok Date: Fri, 10 Nov 2017 16:14:06 +0100 Subject: [PATCH 8/8] created nicer prints --- launcher/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/control.py b/launcher/control.py index bd3a079..b102f27 100644 --- a/launcher/control.py +++ b/launcher/control.py @@ -309,7 +309,7 @@ def launch_explorer(self): migrate to another module""" # Todo: find a cleaner way, with .toml file for example - print(">>> Explorer ...") + print("Openiing Explorer") # Get the current environment frame = self.current_frame() @@ -318,7 +318,7 @@ def launch_explorer(self): # When we are outside of any project, do nothing config = frame.get("config", None) if config is None: - print(">>> No project found in configuration") + print("No project found in configuration") return template = config['template']['work'] @@ -327,7 +327,7 @@ def launch_explorer(self): # Keep only the part of the path that was formatted path = os.path.normpath(path.split("{", 1)[0]) - print(">>>", path) + print(path) if os.path.exists(path): import subprocess subprocess.Popen(r'explorer "{}"'.format(path))