Add .gitignore and requirements.txt files

This commit is contained in:
2024-07-11 23:03:30 +02:00
parent 4295b59e21
commit 51cdb5164c
9 changed files with 168 additions and 0 deletions

146
app.py Normal file
View File

@ -0,0 +1,146 @@
import sys
from PyQt5.QtWidgets import (
QApplication, QWidget, QVBoxLayout, QHBoxLayout,
QLineEdit, QPushButton, QListWidget, QTextEdit, QComboBox, QMessageBox, QSpacerItem, QSizePolicy
)
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import Qt
from PyQt5.QtSvg import QSvgWidget
class URLManager(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('tabRemember - URL Manager')
self.setGeometry(100, 100, 340, 500)
# Set the application icon
self.setWindowIcon(QIcon('assets/logo.png'))
self.layout = QVBoxLayout()
# URL input and settings button layout
self.url_layout = QHBoxLayout()
self.url_input = QLineEdit()
self.url_input.setPlaceholderText("URL")
self.url_layout.addWidget(self.url_input)
# Settings button
self.settings_button = QPushButton()
self.settings_button.setFixedHeight(self.url_input.sizeHint().height())
self.settings_button.setFixedWidth(self.url_input.sizeHint().height())
self.url_layout.addWidget(self.settings_button)
# Info button
self.info_button = QPushButton()
self.info_button.setFixedHeight(self.url_input.sizeHint().height())
self.info_button.setFixedWidth(self.url_input.sizeHint().height())
self.url_layout.addWidget(self.info_button)
self.layout.addLayout(self.url_layout)
# Update icons based on the color mode
self.update_icon_color()
# Description/Thoughts input
self.description_input = QTextEdit()
self.description_input.setPlaceholderText("Enter Description or Thoughts")
self.description_input.setMaximumHeight(100) # Limit height to approximately 5 lines
self.layout.addWidget(self.description_input)
# Add URL button
self.add_button = QPushButton("Add URL")
self.add_button.clicked.connect(self.add_url)
self.layout.addWidget(self.add_button)
# Add space between the Add URL button and URL list
self.layout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Fixed))
# Group selection and search input
self.group_search_layout = QHBoxLayout()
self.group_combobox = QComboBox()
self.group_combobox.addItem("Default")
self.group_search_layout.addWidget(self.group_combobox)
self.search_input = QLineEdit()
self.search_input.setPlaceholderText("Search ...")
self.group_search_layout.addWidget(self.search_input)
self.layout.addLayout(self.group_search_layout)
# Ensure the dropdown and search input are of equal width
self.group_combobox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.search_input.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
# URL list
self.url_list = QListWidget()
self.layout.addWidget(self.url_list)
self.setLayout(self.layout)
self.urls = {}
def update_icon_color(self):
# Heuristic to check if the application is in dark mode
palette = self.palette()
if palette.color(palette.Window).value() < 128:
settings_icon_path = 'assets/cogwheel_dark.svg'
info_icon_path = 'assets/info_dark.svg'
else:
settings_icon_path = 'assets/cogwheel_light.svg'
info_icon_path = 'assets/info_light.svg'
self.settings_button.setIcon(QIcon(settings_icon_path))
self.info_button.setIcon(QIcon(info_icon_path))
def add_url(self):
url = self.url_input.text()
description = self.description_input.toPlainText()
group = self.group_combobox.currentText()
if url:
self.url_list.addItem(f"{group}: {url}")
if group not in self.urls:
self.urls[group] = []
self.urls[group].append({'url': url, 'description': description})
self.url_input.clear()
self.description_input.clear()
def update_url(self):
selected_item = self.url_list.currentItem()
if selected_item:
group, url = selected_item.text().split(": ", 1)
new_url = self.url_input.text()
new_description = self.description_input.toPlainText()
selected_item.setText(f"{group}: {new_url}")
for item in self.urls[group]:
if item['url'] == url:
item['url'] = new_url
item['description'] = new_description
break
self.url_input.clear()
self.description_input.clear()
def delete_url(self):
selected_item = self.url_list.currentItem()
if selected_item:
group, url = selected_item.text().split(": ", 1)
self.url_list.takeItem(self.url_list.row(selected_item))
for item in self.urls[group]:
if item['url'] == url:
self.urls[group].remove(item)
break
def search_url(self):
search_term = self.search_input.text()
if search_term:
search_engine = "https://www.google.com/search?q="
search_url = search_engine + search_term
QMessageBox.information(self, "Search", f"Searching for: {search_term}\nURL: {search_url}")
self.search_input.clear()
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setWindowIcon(QIcon('assets/logo.png')) # Set the application icon using PNG for compatibility
window = URLManager()
window.show()
sys.exit(app.exec_())