mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
Prevent selecting Kindle as output directory (#990)
* merge conflicts * fix * call it is * fix imports
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
import itertools
|
||||
from pathlib import Path
|
||||
from PySide6.QtCore import (QSize, QUrl, Qt, Signal, QIODeviceBase, QEvent, QThread, QSettings)
|
||||
from PySide6.QtGui import (QColor, QIcon, QPixmap, QDesktopServices)
|
||||
@@ -490,13 +492,24 @@ class SystemTrayIcon(QSystemTrayIcon):
|
||||
class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
def selectDefaultOutputFolder(self):
|
||||
dname = QFileDialog.getExistingDirectory(MW, 'Select default output folder', self.defaultOutputFolder)
|
||||
if self.is_directory_on_kindle(dname):
|
||||
return
|
||||
if dname != '':
|
||||
if sys.platform.startswith('win'):
|
||||
dname = dname.replace('/', '\\')
|
||||
GUI.defaultOutputFolder = dname
|
||||
|
||||
def is_directory_on_kindle(self, dname):
|
||||
path = Path(dname)
|
||||
for parent in itertools.chain([path], path.parents):
|
||||
if parent.name == 'documents' and parent.parent.joinpath('system').joinpath('thumbnails').is_dir():
|
||||
self.addMessage("Cannot select Kindle as output directory", 'error')
|
||||
return True
|
||||
|
||||
def selectOutputFolder(self):
|
||||
dname = QFileDialog.getExistingDirectory(MW, 'Select output directory', self.lastPath)
|
||||
if self.is_directory_on_kindle(dname):
|
||||
return
|
||||
if dname != '':
|
||||
if sys.platform.startswith('win'):
|
||||
dname = dname.replace('/', '\\')
|
||||
|
||||
Reference in New Issue
Block a user