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

gui_qt: Add open config folder action #981

Merged
merged 3 commits into from
Nov 18, 2018
Merged
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
13 changes: 13 additions & 0 deletions plover/gui_qt/main_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

from functools import partial
import json
import os
import sys
import subprocess

from PyQt5.QtCore import QCoreApplication, Qt
from PyQt5.QtGui import QCursor, QIcon, QKeySequence
Expand All @@ -11,6 +14,7 @@

from plover import log
from plover.oslayer import wmctrl
from plover.oslayer.config import CONFIG_DIR
from plover.registry import registry
from plover.resource import resource_filename

Expand Down Expand Up @@ -67,6 +71,7 @@ def __init__(self, engine, use_qt_notifications):
'menu_Tools',
'',
'action_Configure',
'action_OpenConfigFolder',
'',
'menu_Help',
'',
Expand Down Expand Up @@ -238,6 +243,14 @@ def on_disable_output(self):
def on_configure(self):
self._configure()

def on_open_config_folder(self):
if sys.platform.startswith('win'):
os.startfile(CONFIG_DIR)
elif sys.platform.startswith('linux'):
subprocess.call(['xdg-open', CONFIG_DIR])
elif sys.platform.startswith('darwin'):
subprocess.call(['open', CONFIG_DIR])

def on_reconnect(self):
self._engine.reset_machine()

Expand Down
30 changes: 30 additions & 0 deletions plover/gui_qt/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<addaction name="action_Reconnect"/>
<addaction name="separator"/>
<addaction name="action_Configure"/>
<addaction name="action_OpenConfigFolder"/>
<addaction name="separator"/>
<addaction name="action_Show"/>
<addaction name="action_Quit"/>
Expand Down Expand Up @@ -236,6 +237,18 @@
<string>Ctrl+,</string>
</property>
</action>
<action name="action_OpenConfigFolder">
<property name="icon">
<iconset resource="resources/resources.qrc">
<normaloff>:/folder.svg</normaloff>:/folder.svg</iconset>
</property>
<property name="text">
<string>Open config &amp;folder</string>
</property>
<property name="toolTip">
<string>Open the configuration folder.</string>
</property>
</action>
<action name="action_About">
<property name="text">
<string>&amp;About</string>
Expand Down Expand Up @@ -333,6 +346,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>action_OpenConfigFolder</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>on_open_config_folder()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>140</x>
<y>57</y>
</hint>
</hints>
</connection>
<connection>
<sender>action_Show</sender>
<signal>triggered()</signal>
Expand Down Expand Up @@ -449,6 +478,7 @@
<slots>
<slot>on_reconnect()</slot>
<slot>on_configure()</slot>
<slot>on_open_config_folder()</slot>
<slot>on_manage_dictionaries()</slot>
<slot>on_quit()</slot>
<slot>on_toggle_output(bool)</slot>
Expand Down
4 changes: 4 additions & 0 deletions plover/gui_qt/resources/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 28 additions & 27 deletions plover/gui_qt/resources/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
<RCC>
<qresource prefix="/">
<file>up.svg</file>
<file>down.svg</file>
<file>tape.svg</file>
<file>save.svg</file>
<file>undo.svg</file>
<file>settings.svg</file>
<file>state-disabled.svg</file>
<file>state-disconnected.svg</file>
<file>state-enabled.svg</file>
<file>reconnect.svg</file>
<file>plover.png</file>
<file>font_selector.svg</file>
<file>lookup.svg</file>
<file>pin.svg</file>
<file>translation_add.svg</file>
<file>trash.svg</file>
<file>add.svg</file>
<file>lightbulb.svg</file>
<file>pencil.svg</file>
<file>remove.svg</file>
<file>dictionary_error.svg</file>
<file>dictionary_favorite.svg</file>
<file>dictionary_normal.svg</file>
<file>dictionary_readonly.svg</file>
<file>dictionary_loading.svg</file>
</qresource>
<qresource prefix="/">
<file>folder.svg</file>
<file>up.svg</file>
<file>down.svg</file>
<file>tape.svg</file>
<file>save.svg</file>
<file>undo.svg</file>
<file>settings.svg</file>
<file>state-disabled.svg</file>
<file>state-disconnected.svg</file>
<file>state-enabled.svg</file>
<file>reconnect.svg</file>
<file>plover.png</file>
<file>font_selector.svg</file>
<file>lookup.svg</file>
<file>pin.svg</file>
<file>translation_add.svg</file>
<file>trash.svg</file>
<file>add.svg</file>
<file>lightbulb.svg</file>
<file>pencil.svg</file>
<file>remove.svg</file>
<file>dictionary_error.svg</file>
<file>dictionary_favorite.svg</file>
<file>dictionary_normal.svg</file>
<file>dictionary_readonly.svg</file>
<file>dictionary_loading.svg</file>
</qresource>
</RCC>