Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Oct 24, 2011
0 parents commit 718a092
Show file tree
Hide file tree
Showing 41 changed files with 2,817 additions and 0 deletions.
347 changes: 347 additions & 0 deletions COPYING

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,4 @@
include data/qnotero.desktop
recursive-include resources
recursive-exclude *.pyc
recursive-include ~*
17 changes: 17 additions & 0 deletions data/qnotero.desktop
@@ -0,0 +1,17 @@
[Desktop Entry]
Name=Qnotero
Comment=Quick access to your Zotero references
TryExec=qnotero
Exec=qnotero
Icon=accessories-dictionary
Type=Application
X-GNOME-DocPath=
X-GNOME-Bugzilla-Bugzilla=
X-GNOME-Bugzilla-Product=
X-GNOME-Bugzilla-Component=
X-GNOME-Bugzilla-Version=
Categories=GNOME;GTK;Utility;
StartupNotify=false
X-Ubuntu-Gettext-Domain=qnotero
Name[en_US]=Qnotero

Binary file added dist/qnotero-0.45-pre1.tar.gz
Binary file not shown.
Empty file added libqnotero/__init__.py
Empty file.
Empty file added libqnotero/_themes/__init__.py
Empty file.
133 changes: 133 additions & 0 deletions libqnotero/_themes/default.py
@@ -0,0 +1,133 @@
"""
This file is part of qnotero.
qnotero is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qnotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qnotero. If not, see <http://www.gnu.org/licenses/>.
"""

import sys
import os
import os.path
from PyQt4.QtGui import QIcon, QPixmap, QLabel
from PyQt4.QtCore import Qt

class Default:

"""The default Qnotero theme"""

def __init__(self, qnotero):

"""
Constructor
qnotero -- a Qnotero instance
"""

self.qnotero = qnotero
if os.path.exists(os.path.join("/usr/share/qnotero/resources/", \
self.themeFolder())):
self.themeFolder = os.path.join("/usr/share/qnotero/resources/", \
self.themeFolder())
else:
self.themeFolder = os.path.join(os.path.dirname(sys.argv[0]), \
"resources", self.themeFolder())
self.setStyleSheet()
self.qnotero.setWindowFlags(Qt.Popup)
self.qnotero.ui.listWidgetResults.setHorizontalScrollBarPolicy( \
Qt.ScrollBarAlwaysOff)
self.qnotero.ui.listWidgetResults.setVerticalScrollBarPolicy( \
Qt.ScrollBarAlwaysOff)

def icon(self, iconName):

"""
Retrieves an icon from the theme
Arguments:
iconName -- the name of the icon
Returns:
A QIcon
"""

return QIcon(os.path.join(self.themeFolder, iconName) + ".png")

def iconWidget(self, iconName):

"""
Return a QLabel with an icon
Arguments:
iconName -- the name of the icon
Returns:
A QLabel
"""

l = QLabel()
l.setPixmap(self.pixmap(iconName))
return l

def lineHeight(self):

"""
Determines the line height of the results
Returns:
A float (e.g., 1.1) for the line height
"""

return 1.1

def pixmap(self, pixmapName):

"""
Retrieves an icon (as QPixmap) from the theme
Arguments:
pixmapName -- the name of the icon
Returns:
A QPixmap
"""

return QPixmap(os.path.join(self.themeFolder, pixmapName) + ".png")

def roundness(self):

"""
Determines the roundness of various widgets
Returns:
A roundness as a radius in pixels
"""

return 10

def setStyleSheet(self):

"""Applies a stylesheet to Qnotero"""

self.qnotero.setStyleSheet(open(os.path.join( \
self.themeFolder, "stylesheet.qss")).read())

def themeFolder(self):

"""
Determines the name of the folder containing the theme resources
Returns:
The name of the theme folder
"""

return "default"
34 changes: 34 additions & 0 deletions libqnotero/_themes/elementary.py
@@ -0,0 +1,34 @@
"""
This file is part of qnotero.
qnotero is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qnotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qnotero. If not, see <http://www.gnu.org/licenses/>.
"""

from libqnotero._themes.default import Default

class Elementary(Default):

"""The Elementary Qnotero theme"""

def __init__(self, qnotero):

Default.__init__(self, qnotero)

def themeFolder(self):

return "elementary"

def roundness(self):

return 0
85 changes: 85 additions & 0 deletions libqnotero/config.py
@@ -0,0 +1,85 @@
"""
This file is part of qnotero.
qnotero is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qnotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qnotero. If not, see <http://www.gnu.org/licenses/>.
"""

config = {
"cfgVer" : 0,
"zoteroPath" : "",
"theme" : "Default",
"pdfReader" : "xdg-open",
"minQueryLength" : 3,
"attachToSysTray" : True,
"noteProvider" : "gnote",
"firstRun" : True,
}

def getConfig(setting):

"""
Retrieve a setting
Returns:
A setting or False if the setting does not exist
"""

return config[setting]

def setConfig(setting, value):

"""
Set a setting
Arguments:
setting -- the setting name
value -- the setting value
"""

config[setting] = value
config["cfgVer"] += 1

def restoreConfig(settings):

"""
Restore settings from a QSetting
Arguments:
settings -- a QSetting
"""

for setting, default in config.items():
if type(default) == bool:
value = settings.value(setting, default).toBool()
elif type(default) == str:
try:
value = str(settings.value(setting, default).toString())
except:
value = default
elif type(default) == int:
value = settings.value(setting, default).toInt()[0]
setConfig(setting, value)

def saveConfig(settings):

"""
Save settings to a QSetting
Arguments:
setting -- a QSetting
"""

for setting, value in config.items():
settings.setValue(setting, value)

0 comments on commit 718a092

Please sign in to comment.