Skip to content

Commit

Permalink
fixed browser drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
YourBoyRory committed Dec 16, 2024
1 parent 69ca6a8 commit dbfbf30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
23 changes: 12 additions & 11 deletions FrameWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from io import BytesIO
from PIL import Image
import requests
import json
import sys
import os
Expand All @@ -19,9 +20,9 @@ def __init__(self, parent):
self.displayingImage = False
self.current_zoom = 0.4 # start zoom
self.minZoom = 0.1
self.maxZoom = 3.0
self.maxZoom = 3.0
self.setAcceptDrops(True)

def wheelEvent(self, event: QWheelEvent):
# Get the wheel delta (positive for scrolling up, negative for scrolling down)
angle_delta = event.angleDelta().y()
Expand All @@ -33,18 +34,18 @@ def wheelEvent(self, event: QWheelEvent):
else:
# Zoom out
zoom = max(self.current_zoom / factor, self.minZoom)

self.parent.view_slider.setValue(int(zoom * 100))
event.accept() # Mark the event as handled

def setZoom(self, zoom):
if self.displayingImage:
self.resetTransform()
self.scale(zoom , zoom)
#print(zoom)
self.current_zoom = zoom


def loadImage(self, pixmap):
self.displayingImage = True
self.setZoom(self.current_zoom)
Expand Down Expand Up @@ -93,14 +94,14 @@ def dropEvent(self, event):
self.parent.dropEvent(event)

class PaintingEditor(QWidget):

def __init__(self, parent):
super().__init__(parent)

# This is very OOP thus its ok and cool
self.parent = parent
self.packConrols = self.parent.packConrols

init_silder_value = 500
self.view_size = int(100 + (init_silder_value / 500) * 300)

Expand All @@ -113,7 +114,7 @@ def __init__(self, parent):
self.lock = True
self.updating = False
self.backgroundColor = "#000000"

PaintingEditor_Layout = QVBoxLayout()
combine_OptionsViewport = QHBoxLayout()
"""Options Pane"""
Expand Down Expand Up @@ -256,7 +257,7 @@ def reset(self):
self.view_size = 400

def view_slider_changed(self):
zoom = self.view_slider.value() / 100
zoom = self.view_slider.value() / 100
self.viewPort.setZoom(zoom)

def setButtonEnabled(self, value):
Expand Down
14 changes: 6 additions & 8 deletions PaintingStudio.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import json
import sys
import requests
from pathlib import Path
from PyQt5.QtCore import Qt, QUrl, QSize, QTimer, QStringListModel, pyqtSignal
from PyQt5.QtGui import QPixmap, QImage, QIcon, QColor, QFont
Expand All @@ -28,11 +27,11 @@ def __init__(self):
# generated stuff
self.setWindowTitle("Minecraft Painting Studio")
self.setGeometry(100, 100, 1000, 600)


"""Menu Bar"""
menubar = self.menuBar()

#File Menu
file_menu = menubar.addMenu('File')
new_pack_action = QAction('New Pack', self)
Expand All @@ -44,7 +43,7 @@ def __init__(self):
self.save_draft_action = QAction('Save Draft', self)
self.save_draft_action.triggered.connect(self.saveToFile)
file_menu.addAction(self.save_draft_action)

# Help Menu
help_menu = menubar.addMenu('Help')
help_action = QAction('Help', self)
Expand All @@ -53,7 +52,7 @@ def __init__(self):

""" Left Bar """
self.packConrols = PackControls(self)

"""Center Widget"""
self.paintingEditor = PaintingEditor(self)

Expand All @@ -75,7 +74,7 @@ def prog_help(self):
def newPack(self):
# Create and show the input dialog
dialog = InputDialog(self)

# Check if the dialog was accepted
if dialog.exec_() == QDialog.Accepted:
title, description, number, icon = dialog.get_data()
Expand Down Expand Up @@ -154,7 +153,6 @@ def set_theme(app):
except:
pass
current_style = app.style().objectName()
desktop = ""
if desktop == "" or current_style == "windowsvista":
desktop = "windows"
try:
Expand Down

0 comments on commit dbfbf30

Please sign in to comment.