mozDefrag/mozDefrag.py

105 lines
3.5 KiB
Python
Raw Normal View History

2017-09-28 23:41:34 +00:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
2017-10-04 19:42:08 +00:00
mozDefrag
2017-09-29 16:37:03 +00:00
Description : defrag Firefox/Thunderbird's sqlite databases for users/profiles
2017-09-28 23:41:34 +00:00
Author : Francois Beckers
Licence : GPL3
"""
import os
import sys
import mozDefragMainWindow
import mozDefragAboutWindow
import res_pics_rc
2017-09-28 23:41:34 +00:00
from libMozDefrag import *
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
2017-10-23 20:37:19 +00:00
__appVer__ = "0.1.1 alpha"
__appDir__ = "/opt/mozdefrag/"
2017-09-28 23:41:34 +00:00
class Ui_mozDefragAboutWindow(QtWidgets.QMainWindow, # --- About -------------
mozDefragAboutWindow.Ui_AboutWindow):
def __init__(self, parent=None):
super(Ui_mozDefragAboutWindow, self).__init__(parent)
self.setupUi(self)
self.connectActions()
self.setWindowTitle("About mozDefrag " + __appVer__)
def connectActions(self):
self.closeButton.clicked.connect(self.close)
class Ui_mozDefragMainWindow(QtWidgets.QMainWindow, # --- Main ---------------
mozDefragMainWindow.Ui_MainWindow):
def __init__(self, parent=None):
super(Ui_mozDefragMainWindow, self).__init__(parent)
self.setupUi(self)
self.connectActions()
def connectActions(self):
self.aboutButton.clicked.connect(self.showMozDefragAboutWindow)
self.defragAllButton.clicked.connect(self.performDefrag)
def showMozDefragAboutWindow(self):
self.child_win = Ui_mozDefragAboutWindow(self)
self.child_win.show()
def performDefrag(self):
if self.checkBoxFirefox.isChecked():
if not mozFirefoxIsRunning():
mozDefragFirefox()
self.logTextEdit.append("> Firefox defrag done")
else:
self.logTextEdit.append("> Close Firefox and try again")
if self.checkBoxFirefoxTrunk.isChecked():
if not mozFirefoxTrunkIsRunning():
mozDefragFirefoxTrunk()
self.logTextEdit.append("> Firefox Nightly defrag done")
else:
self.logTextEdit.append("> Close Firefox Nightly and try again")
2017-09-28 23:41:34 +00:00
if self.checkBoxThunderbird.isChecked():
if not mozThunderbirdIsRunning():
mozDefragThunderbird()
self.logTextEdit.append("> Thunderbird defrag done")
else:
self.logTextEdit.append("> Close Thunderbird and try again")
def main(self):
self.show()
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/pic/icon.svg"),
2017-09-28 23:41:34 +00:00
QtGui.QIcon.Normal,
QtGui.QIcon.Off)
self.setWindowIcon(icon)
self.setWindowTitle("mozDefrag " + __appVer__)
if mozFirefoxIsInstalled():
self.checkBoxFirefox.setEnabled(True)
self.checkBoxFirefox.setChecked(True)
else:
self.checkBoxFirefox.setDisabled(True)
if mozFirefoxTrunkIsInstalled():
self.checkBoxFirefoxTrunk.setEnabled(True)
self.checkBoxFirefoxTrunk.setChecked(True)
else:
self.checkBoxFirefoxTrunk.setDisabled(True)
2017-09-28 23:41:34 +00:00
if mozThunderbirdIsInstalled():
self.checkBoxThunderbird.setEnabled(True)
self.checkBoxThunderbird.setChecked(True)
else:
self.checkBoxThunderbird.setDisabled(True)
if __name__ == '__main__': # --- app init ------------------------------------
app = QtWidgets.QApplication(sys.argv)
mainWindow = Ui_mozDefragMainWindow()
mainWindow.main()
app.exec_()