-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
181 lines (148 loc) · 5.34 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import glob, os, re, sip, time,sys
from dbus.service import method
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
from PyKDE4.kio import KFile, KFileDialog, KIO
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import uic
from necroposter import necroposter
import dirs_ui
class dirsWidget(QWidget,dirs_ui.Ui_Widget):
def __init__(self,parent):
QWidget.__init__(self, parent)
self.setupUi(self)
self.kcfg_url.setMode(KFile.Directory)
class PreferencesDialog(KConfigDialog):
def __init__(self, parent, name, preferences):
KConfigDialog.__init__(self, parent, name, preferences)
self.page = dirsWidget(self)
self.addPage(self.page, i18n("Storage setup"), 'media-dirs')
class Preferences(KConfigSkeleton):
def __init__(self):
KConfigSkeleton.__init__(self)
self.setCurrentGroup("Storage")
self.url = QString()
#self.dirs.append('/mnt/storage/Anime')
#self.dirs.append('/mnt/large/Anime')
self.dirs = self.addItemString("url",self.url)
self.readConfig()
def url(self):
return self.dirs.property().toString()
class necroMediaMainWindow(KXmlGuiWindow):
def __init__(self):
KXmlGuiWindow.__init__(self)
#KMainWindow.__init__(self, *args)
self.ui=uic.loadUi("nm.ui", self)
#self.setupGUI()
self.setWindowTitle("NecroMedia")
self.mainlist=[]
self.setupActions()
#self.addMenu()
self.readdirs()
self.populateList()
self.connect(self.ui.main_lw, SIGNAL("itemClicked(QListWidgetItem *)"),
self.refresh_info)
self.config=Preferences()
self.setupGUI() #after setup actions
#self.showSettings()
def setupActions(self):
KStandardAction.preferences(self.showSettings, self.actionCollection())
KStandardAction.quit(app.quit, self.actionCollection())
def addMenu(self):
helpMenu = KHelpMenu(self, KCmdLineArgs.aboutData())
self.menuBar().addMenu(helpMenu.menu())
#helpMenu.action(KHelpMenu.menuReportBug).setIcon(
# KIcon('tools-report-bug'))
#helpMenu.action(KHelpMenu.menuAboutApp).setIcon(self._appIcon)
whatsThis = helpMenu.action(KHelpMenu.menuWhatsThis)
# TODO not added by default,
# currently added to the wrong
# place
helpMenu.menu().addAction(whatsThis)
return
#create menu
self.file = KMenu(self)
#self.file.addAction(self.configureAction)
#self.file.addAction(self.updateAction)
self.file.addAction(self.quitAction)
self.help = KMenu(self)
self.help.addAction(self.helpAction)
#create menu bar
self.menuBar = KMenuBar(self)
self.menuBar.addMenu(self.file)
self.menuBar.addMenu(self.help)
def populateList(self):
for f in self.mainlist:
self.ui.main_lw.addItem(f)
def readdirs(self):
dir='/home/non7top/anime'
d=QDir(dir)
#d.setFilter(QDir.NoDotAndDotDot)
#flist=QStringList()
self.list=[]
flist=d.entryList()
k=0
while k < flist.count():
f=flist[k]
if f not in ('.', '..'):
lentry={}
lentry['path']=os.path.join(dir,str(f))
self.list.append(lentry)
self.mainlist.append(f)
k+=1
def refresh_info(self, item):
id=self.ui.main_lw.row(item)
path = self.list[id]['path']
homepath=os.path.join(path,'.anime')
idfile=os.path.join(homepath,'id')
'''read id'''
if os.path.exists(idfile):
wa_id=int(open(idfile,'r').read().strip())
print wa_id
else:
print "no cache"
return
np=necroposter(str(wa_id), homepath)
self.ui.lb_title.setText(np.get_title())
print np.fnames['studio_full']
cover=QPixmap()
if cover.load(np.fnames['cover_full']):
self.ui.lb_cover.setPixmap(cover)
def showSettings(self):
if(KConfigDialog.showDialog("settings")):
return
dialog = PreferencesDialog(self, "settings", self.config)
dialog.show()
def about():
appName = "necromedia"
catalog = ""
programName = ki18n("Necro Media")
version = "0.1"
description = ki18n("Anime collection manager")
license = KAboutData.License_GPL
copyright = ki18n("(c) 2009 Vladimir V. Berezhnoy")
text = ki18n("Very very long description")
homePage = "http://needsthinki.ng"
bugEmail = "[email protected]"
aboutData = KAboutData(appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
aboutData.addAuthor(ki18n("Vladimir V. Berezhnoy"), ki18n("Developer"),
"http://a.ru")
return aboutData
def main():
aboutdata = KAboutData(about())
KCmdLineArgs.init(sys.argv, aboutdata)
global app
app = KApplication(1)
#icon = KIcon("klxdvdrip.png")
app.mainWindow=necroMediaMainWindow()
#app.mainWindow.setWindowIcon(icon)
app.mainWindow.show()
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
app.exec_()
def quit(self):
KApplication.quit(self)
if __name__=="__main__":
main()