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

mac minor updates #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ dist/*
*.exe
*.swp
*.DS_Store
*.pyc
20 changes: 19 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys

from PyQt5.QtGui import QIcon
from PyQt5.QtGui import QIcon, QPalette, QColor
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import Qt

from src.gui.main_window import MainWindow
from src.helpers.pyinstaller_helper import PyInstallerHelper
Expand All @@ -15,6 +16,23 @@
myApp = QApplication(sys.argv)
myApp.setQuitOnLastWindowClosed(True)

myApp.setStyle('Fusion')
palette = QPalette()
palette.setColor(QPalette.Window, QColor(53,53,53))
palette.setColor(QPalette.WindowText, Qt.white)
palette.setColor(QPalette.Base, QColor(15,15,15))
palette.setColor(QPalette.AlternateBase, QColor(53,53,53))
palette.setColor(QPalette.ToolTipBase, Qt.white)
palette.setColor(QPalette.ToolTipText, Qt.white)
palette.setColor(QPalette.Text, Qt.white)
palette.setColor(QPalette.Button, QColor(53,53,53))
palette.setColor(QPalette.ButtonText, Qt.white)
palette.setColor(QPalette.BrightText, Qt.red)

palette.setColor(QPalette.Highlight, QColor(142,45,197).lighter())
palette.setColor(QPalette.HighlightedText, Qt.black)
myApp.setPalette(palette)

path = PyInstallerHelper.resource_path("icons\\main.png")

icon = QIcon(path)
Expand Down
14 changes: 12 additions & 2 deletions src/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def __init__(self):
if geometry:
self.localFilesTreeView.header().restoreState(geometry)

self._pref_port_found = False

self._connection_scanner = ConnectionScanner()
self._connection = None
self._root_dir = Settings().root_dir
Expand Down Expand Up @@ -115,6 +117,7 @@ def connection_changed(self):
def refresh_ports(self):
# Cache value of last selected connection because it might change when manipulating combobox
last_selected_connection = self.lastSelectedConnection
local_pref_port_found = False

self._connection_scanner.scan_connections(with_wifi=True)
self.connectionComboBox.clear()
Expand All @@ -128,11 +131,18 @@ def refresh_ports(self):
for i, port in enumerate(self._connection_scanner.port_list):
self.connectionComboBox.addItem(port)
if pref_port and port.upper() == pref_port.upper():
local_pref_port_found = True
selected_port_idx = i

# Override preferred port if user made selection and this port is still available
if last_selected_connection and last_selected_connection in self._connection_scanner.port_list:
selected_port_idx = self._connection_scanner.port_list.index(last_selected_connection)
# unless pref port was just found for the FIRST time
if (self._pref_port_found):
if last_selected_connection and last_selected_connection in self._connection_scanner.port_list:
selected_port_idx = self._connection_scanner.port_list.index(last_selected_connection)

if (local_pref_port_found):
self._pref_port_found = True;

# Set current port
self.connectionComboBox.setCurrentIndex(selected_port_idx if selected_port_idx >= 0 else 0)
self.connectButton.setEnabled(True)
Expand Down