Added file explorer
This commit is contained in:
1
gui/modules/explorer/__init__.py
Normal file
1
gui/modules/explorer/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .handlers import *
|
||||
61
gui/modules/explorer/handlers.py
Normal file
61
gui/modules/explorer/handlers.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from gui.gui import Ui_MainWindow
|
||||
from modules.config import PathsConfig
|
||||
from modules.player.player import Player
|
||||
from PyQt5.QtWidgets import QFileDialog
|
||||
import os
|
||||
|
||||
|
||||
def register_handlers(ui: Ui_MainWindow, p: Player):
|
||||
ui.first_browser_parent_dir_box.textChanged.connect(
|
||||
lambda: (
|
||||
ui.folders_browser_treeview_first.setRootIndex(
|
||||
ui.dir_model_first.index(ui.first_browser_parent_dir_box.text())
|
||||
),
|
||||
PathsConfig.update("first_browser_path", ui.first_browser_parent_dir_box.text())
|
||||
)
|
||||
)
|
||||
|
||||
ui.second_browser_parent_dir_box.textChanged.connect(
|
||||
lambda: (
|
||||
ui.folders_browser_treeview_second.setRootIndex(
|
||||
ui.dir_model_second.index(ui.second_browser_parent_dir_box.text())
|
||||
),
|
||||
PathsConfig.update("second_browser_path", ui.second_browser_parent_dir_box.text())
|
||||
)
|
||||
)
|
||||
|
||||
ui.files_browser_listwidget_first.itemDoubleClicked.connect(
|
||||
lambda: (
|
||||
p.set_media(
|
||||
os.path.join(
|
||||
ui.dir_model_first.filePath(ui.first_index),
|
||||
ui.files_browser_listwidget_first.currentItem().text()
|
||||
)
|
||||
),
|
||||
p.play(ui)
|
||||
)
|
||||
)
|
||||
|
||||
ui.files_browser_listwidget_second.itemDoubleClicked.connect(
|
||||
lambda: (
|
||||
p.set_media(
|
||||
os.path.join(
|
||||
ui.dir_model_second.filePath(ui.second_index),
|
||||
ui.files_browser_listwidget_second.currentItem().text()
|
||||
)
|
||||
),
|
||||
p.play(ui)
|
||||
)
|
||||
)
|
||||
|
||||
ui.first_browser_parent_dir_button.clicked.connect(
|
||||
lambda: ui.first_browser_parent_dir_box.setText(
|
||||
QFileDialog.getExistingDirectory(caption="Select root directory for first browser")
|
||||
)
|
||||
)
|
||||
|
||||
ui.second_browser_parent_dir_button.clicked.connect(
|
||||
lambda: ui.second_browser_parent_dir_box.setText(
|
||||
QFileDialog.getExistingDirectory(caption="Select root directory for second browser")
|
||||
)
|
||||
)
|
||||
64
gui/modules/explorer/initialize.py
Normal file
64
gui/modules/explorer/initialize.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from gui.gui import Ui_MainWindow
|
||||
from PyQt5 import QtWidgets, QtCore
|
||||
from modules.config import PathsConfig
|
||||
from gui.modules.core import popup
|
||||
import os
|
||||
|
||||
|
||||
def fill_paths(ui: Ui_MainWindow):
|
||||
ui.first_browser_parent_dir_box.setText(PathsConfig.get().first_browser_path)
|
||||
ui.second_browser_parent_dir_box.setText(PathsConfig.get().second_browser_path)
|
||||
|
||||
|
||||
def first_clicked(ui: Ui_MainWindow, index):
|
||||
ui.first_index = index
|
||||
ui.files_browser_listwidget_first.clear()
|
||||
try:
|
||||
ui.files_browser_listwidget_first.addItems(
|
||||
[f for f in os.listdir(ui.dir_model_first.filePath(index))
|
||||
if os.path.isfile(os.path.join(ui.dir_model_first.filePath(index), f))]
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
popup.popup("Error", "Cannot access files in this folder")
|
||||
|
||||
|
||||
def second_clicked(ui: Ui_MainWindow, index):
|
||||
ui.second_index = index
|
||||
ui.files_browser_listwidget_second.clear()
|
||||
try:
|
||||
ui.files_browser_listwidget_second.addItems(
|
||||
[f for f in os.listdir(ui.dir_model_second.filePath(index))
|
||||
if os.path.isfile(os.path.join(ui.dir_model_second.filePath(index), f))]
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
popup.popup("Error", "Cannot access files in this folder")
|
||||
|
||||
|
||||
def init_explorer(ui: Ui_MainWindow):
|
||||
fill_paths(ui)
|
||||
|
||||
ui.dir_model_first = QtWidgets.QFileSystemModel()
|
||||
ui.dir_model_first.setFilter(QtCore.QDir.Filter.NoDotAndDotDot | QtCore.QDir.Filter.AllDirs)
|
||||
ui.dir_model_first.setRootPath("")
|
||||
ui.folders_browser_treeview_first.setModel(ui.dir_model_first)
|
||||
ui.folders_browser_treeview_first.setRootIndex(ui.dir_model_first.index(ui.first_browser_parent_dir_box.text()))
|
||||
|
||||
ui.folders_browser_treeview_first.clicked[QtCore.QModelIndex].connect(lambda idx: first_clicked(ui, idx))
|
||||
|
||||
ui.folders_browser_treeview_first.setHeaderHidden(True)
|
||||
for i in range(1, 4):
|
||||
ui.folders_browser_treeview_first.hideColumn(i)
|
||||
|
||||
ui.dir_model_second = QtWidgets.QFileSystemModel()
|
||||
ui.dir_model_second.setFilter(QtCore.QDir.Filter.NoDotAndDotDot | QtCore.QDir.Filter.AllDirs)
|
||||
ui.dir_model_second.setRootPath("")
|
||||
ui.folders_browser_treeview_second.setModel(ui.dir_model_second)
|
||||
ui.folders_browser_treeview_second.setRootIndex(ui.dir_model_second.index(ui.second_browser_parent_dir_box.text()))
|
||||
|
||||
ui.folders_browser_treeview_second.clicked[QtCore.QModelIndex].connect(lambda idx: second_clicked(ui, idx))
|
||||
|
||||
ui.folders_browser_treeview_second.setHeaderHidden(True)
|
||||
for i in range(1, 4):
|
||||
ui.folders_browser_treeview_second.hideColumn(i)
|
||||
@@ -5,6 +5,7 @@ from gui.modules import pads
|
||||
from gui.modules import player
|
||||
from gui.modules import settings
|
||||
from gui.modules import restreammic
|
||||
from gui.modules import explorer
|
||||
from modules.player.player import Player
|
||||
from modules.restream.restream import Restreamer
|
||||
|
||||
@@ -15,3 +16,4 @@ def register_handlers(ui: Ui_MainWindow, MainWindow: QMainWindow, p: Player, rs:
|
||||
player.register_handlers(ui, p)
|
||||
settings.register_handlers(ui)
|
||||
restreammic.register_handlers(ui, MainWindow, rs)
|
||||
explorer.register_handlers(ui, p)
|
||||
|
||||
@@ -8,6 +8,7 @@ from PyQt5 import QtCore
|
||||
from modules.config import Config
|
||||
from modules.player.player import Player
|
||||
from modules.restream.restream import Restreamer
|
||||
from gui.modules.explorer import initialize
|
||||
|
||||
|
||||
def on_load(ui: Ui_MainWindow, MainWindow: QMainWindow):
|
||||
@@ -26,6 +27,8 @@ def on_load(ui: Ui_MainWindow, MainWindow: QMainWindow):
|
||||
p = Player(ui)
|
||||
rs = Restreamer()
|
||||
|
||||
initialize.init_explorer(ui)
|
||||
|
||||
(lambda: rs.restart(ui) if ui.restream_micro_checkbox.isChecked() else rs.stop())()
|
||||
|
||||
register.register_handlers(ui, MainWindow, p, rs)
|
||||
|
||||
@@ -8,7 +8,6 @@ QWidget {
|
||||
font: 10pt "Segoe UI";
|
||||
}
|
||||
|
||||
|
||||
QScrollBar:vertical,
|
||||
QScrollBar:horizontal {
|
||||
border: none;
|
||||
@@ -17,28 +16,24 @@ QScrollBar:horizontal {
|
||||
margin: 15px 0 15px 0;
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical,
|
||||
QScrollBar::handle:horizontal {
|
||||
background-color: rgba(139, 139, 139, 0);
|
||||
min-height: 30px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical:hover,
|
||||
QScrollBar::handle:vertical:pressed,
|
||||
QScrollBar::handle:horizontal:hover,
|
||||
QScrollBar::handle:horizontal:pressed {
|
||||
background-color: rgba(149, 149, 149, 0);
|
||||
}
|
||||
|
||||
QScrollBar::sub-line:vertical,
|
||||
QScrollBar::add-line:vertical,
|
||||
QScrollBar::up-arrow:vertical,
|
||||
QScrollBar::down-arrow:vertical {
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical,
|
||||
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical,
|
||||
QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal,
|
||||
@@ -46,7 +41,6 @@ QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
|
||||
background: none;
|
||||
}
|
||||
|
||||
|
||||
QPushButton {
|
||||
color: white;
|
||||
border-width: 1px;
|
||||
@@ -67,7 +61,6 @@ QPushButton:disabled {
|
||||
border-color: rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
|
||||
QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit {
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
@@ -77,8 +70,7 @@ QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit {
|
||||
font: 10pt "Segoe UI";
|
||||
}
|
||||
|
||||
|
||||
QListWidget {
|
||||
QListWidget, QListView, QTreeView {
|
||||
border-width: 1px;
|
||||
border-radius: 15px;
|
||||
border-style: solid;
|
||||
@@ -87,17 +79,24 @@ QListWidget {
|
||||
background-color: rgba(100, 100, 100, 0);
|
||||
font: 10pt "Segoe UI";
|
||||
}
|
||||
QListWidget:item {
|
||||
QListWidget:item, QListView:item, QTreeView:item {
|
||||
background-color: rgba(36, 36, 36, 0);
|
||||
selection-color: white;
|
||||
}
|
||||
QListWidget:item:hover {
|
||||
QListWidget:item:hover, QListView:item:hover, QTreeView:item:hover {
|
||||
background-color: rgba(50, 50, 50, 0);
|
||||
}
|
||||
QListWidget:item:selected {
|
||||
QListWidget:item:selected, QListView:item:selected, QTreeView:item:selected {
|
||||
background-color: rgba(119, 119, 119, 1);
|
||||
}
|
||||
|
||||
QTreeView::branch:has-children:closed {
|
||||
image: url(":/img/img/down.svg");
|
||||
}
|
||||
|
||||
QTreeView::branch:has-children:open {
|
||||
image: url(":/img/img/up.svg");
|
||||
}
|
||||
|
||||
QComboBox
|
||||
{
|
||||
@@ -108,33 +107,28 @@ QComboBox
|
||||
background-color: rgba(44, 45, 46, 0);
|
||||
color: white;
|
||||
}
|
||||
|
||||
QComboBox::disabled
|
||||
{
|
||||
background-color: rgba(67, 67, 67, 0);
|
||||
color: #656565;
|
||||
color: rgba(101, 101, 101, 1);;
|
||||
border-color: rgba(67, 67, 67);
|
||||
}
|
||||
|
||||
QComboBox:hover
|
||||
{
|
||||
background-color: rgba(50, 50, 50, 0);
|
||||
}
|
||||
|
||||
QComboBox:on
|
||||
{
|
||||
background-color: rgba(67, 67, 67, 0);
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView
|
||||
{
|
||||
background-color: rgba(67, 67, 67, 0);
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
selection-background-color: rgba(119, 119, 119, 0);
|
||||
selection-color: white;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
QComboBox::drop-down
|
||||
{
|
||||
subcontrol-origin: padding;
|
||||
@@ -142,11 +136,10 @@ QComboBox::drop-down
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
|
||||
QTabBar::tab
|
||||
{
|
||||
background-color: rgba(44, 45, 46, 0);
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
@@ -154,26 +147,23 @@ QTabBar::tab
|
||||
border-color: rgba(48, 48, 48);
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
QTabBar::tab:disabled
|
||||
{
|
||||
background-color: rgba(101, 101, 101, 0);
|
||||
color: #656565;
|
||||
color: rgba(101, 101, 101, 1);;
|
||||
}
|
||||
|
||||
QTabWidget::pane
|
||||
{
|
||||
background-color: rgba(160, 160, 160, 0);
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
border: 3px solid;
|
||||
border-radius: 15px;
|
||||
border-color: rgba(28, 28, 28);
|
||||
}
|
||||
|
||||
QTabBar::tab:selected
|
||||
{
|
||||
background-color: rgba(38, 39, 40, 0);
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
@@ -181,83 +171,68 @@ QTabBar::tab:selected
|
||||
border-color: rgba(48, 48, 48);
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
QTabBar::tab:selected:disabled
|
||||
{
|
||||
background-color: rgba(64, 64, 64, 0);
|
||||
color: #656565;
|
||||
color: rgba(101, 101, 101, 1);
|
||||
}
|
||||
|
||||
QTabBar::tab:!selected
|
||||
{
|
||||
background-color: rgba(38, 38, 38, 0);
|
||||
}
|
||||
|
||||
QTabBar::tab:!selected:hover
|
||||
{
|
||||
background-color: rgba(50, 50, 50, 0);
|
||||
}
|
||||
|
||||
QTabBar::tab:top:!selected
|
||||
{
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
QTabBar::tab:bottom:!selected
|
||||
{
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
QTabBar::tab:top, QTabBar::tab:bottom
|
||||
{
|
||||
min-width: 8ex;
|
||||
margin-right: -1px;
|
||||
padding: 5px 10px 5px 10px;
|
||||
}
|
||||
|
||||
QTabBar::tab:top:selected
|
||||
{
|
||||
border-bottom-color: none;
|
||||
}
|
||||
|
||||
QTabBar::tab:bottom:selected
|
||||
{
|
||||
border-top-color: none;
|
||||
}
|
||||
|
||||
QTabBar::tab:top:last, QTabBar::tab:bottom:last,
|
||||
QTabBar::tab:top:only-one, QTabBar::tab:bottom:only-one
|
||||
{
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
QTabBar::tab:left:!selected
|
||||
{
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
QTabBar::tab:right:!selected
|
||||
{
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
QTabBar::tab:left, QTabBar::tab:right
|
||||
{
|
||||
min-height: 8ex;
|
||||
margin-bottom: -1px;
|
||||
padding: 10px 5px 10px 5px;
|
||||
}
|
||||
|
||||
QTabBar::tab:left:selected
|
||||
{
|
||||
border-left-color: none;
|
||||
}
|
||||
|
||||
QTabBar::tab:right:selected
|
||||
{
|
||||
border-right-color: none;
|
||||
}
|
||||
|
||||
QTabBar::tab:left:last, QTabBar::tab:right:last,
|
||||
QTabBar::tab:left:only-one, QTabBar::tab:right:only-one
|
||||
{
|
||||
@@ -336,21 +311,22 @@ QListWidget:item:selected {
|
||||
|
||||
centralwidget_g = """
|
||||
QWidget {
|
||||
background-color: rgb(30, 30, 30);
|
||||
color: rgb(255, 255, 255);
|
||||
background-color: #1e1e1e;
|
||||
color: white;
|
||||
font: 10pt "Segoe UI";
|
||||
}
|
||||
|
||||
QScrollBar:vertical,
|
||||
QScrollBar:horizontal {
|
||||
border: none;
|
||||
background: rgb(30, 30, 30);
|
||||
background: #1e1e1e;
|
||||
width: 10px;
|
||||
margin: 15px 0 15px 0;
|
||||
border-radius: 0px;
|
||||
}
|
||||
QScrollBar::handle:vertical,
|
||||
QScrollBar::handle:horizontal {
|
||||
background-color: rgb(139, 139, 139);
|
||||
background-color: #8b8b8b;
|
||||
min-height: 30px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
@@ -358,7 +334,7 @@ QScrollBar::handle:vertical:hover,
|
||||
QScrollBar::handle:vertical:pressed,
|
||||
QScrollBar::handle:horizontal:hover,
|
||||
QScrollBar::handle:horizontal:pressed {
|
||||
background-color: rgb(149, 149, 149);
|
||||
background-color: #959595;
|
||||
}
|
||||
QScrollBar::sub-line:vertical,
|
||||
QScrollBar::add-line:vertical,
|
||||
@@ -372,6 +348,7 @@ QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal,
|
||||
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
|
||||
background: none;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
color: white;
|
||||
border-width: 1px;
|
||||
@@ -391,6 +368,7 @@ QPushButton:disabled {
|
||||
background-color: #434343;
|
||||
border-color: #0000;
|
||||
}
|
||||
|
||||
QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit {
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
@@ -399,7 +377,8 @@ QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit {
|
||||
background-color: #242424;
|
||||
font: 10pt "Segoe UI";
|
||||
}
|
||||
QListWidget {
|
||||
|
||||
QListWidget, QListView, QTreeView {
|
||||
border-width: 1px;
|
||||
border-radius: 15px;
|
||||
border-style: solid;
|
||||
@@ -408,16 +387,25 @@ QListWidget {
|
||||
background-color: #242424;
|
||||
font: 10pt "Segoe UI";
|
||||
}
|
||||
QListWidget:item {
|
||||
QListWidget:item, QListView:item, QTreeView:item {
|
||||
background-color: #242424;
|
||||
selection-color: white;
|
||||
}
|
||||
QListWidget:item:hover {
|
||||
QListWidget:item:hover, QListView:item:hover, QTreeView:item:hover {
|
||||
background-color: #323232;
|
||||
}
|
||||
QListWidget:item:selected {
|
||||
QListWidget:item:selected, QListView:item:selected, QTreeView:item:selected {
|
||||
background-color: #777777;
|
||||
}
|
||||
|
||||
QTreeView::branch:has-children:closed {
|
||||
image: url(":/img/img/down.svg");
|
||||
}
|
||||
|
||||
QTreeView::branch:has-children:open {
|
||||
image: url(":/img/img/up.svg");
|
||||
}
|
||||
|
||||
QComboBox
|
||||
{
|
||||
border-width: 1px;
|
||||
@@ -425,7 +413,7 @@ QComboBox
|
||||
border-style: solid;
|
||||
border-color: #303030;
|
||||
background-color: #2c2d2e;
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
}
|
||||
QComboBox::disabled
|
||||
{
|
||||
@@ -444,7 +432,7 @@ QComboBox:on
|
||||
QComboBox QAbstractItemView
|
||||
{
|
||||
background-color: #434343;
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
selection-background-color: #777777;
|
||||
selection-color: white;
|
||||
outline: 0;
|
||||
@@ -455,10 +443,11 @@ QComboBox::drop-down
|
||||
subcontrol-position: top right;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
QTabBar::tab
|
||||
{
|
||||
background-color: #2c2d2e;
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
@@ -474,7 +463,7 @@ QTabBar::tab:disabled
|
||||
QTabWidget::pane
|
||||
{
|
||||
background-color: #a0a0a0;
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
border: 3px solid;
|
||||
border-radius: 15px;
|
||||
border-color: #1c1c1c;
|
||||
@@ -482,7 +471,7 @@ QTabWidget::pane
|
||||
QTabBar::tab:selected
|
||||
{
|
||||
background-color: #262728;
|
||||
color: #ffffff;
|
||||
color: white;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
@@ -618,7 +607,7 @@ QListWidget:item {
|
||||
padding-left: 12px;
|
||||
height: 60px;
|
||||
background-color: #191919;
|
||||
selection-color: rgba(255, 255, 255);
|
||||
selection-color: white;
|
||||
}
|
||||
QListWidget:item:hover {
|
||||
background-color: #323232;
|
||||
|
||||
Reference in New Issue
Block a user