This commit is contained in:
Kolenka 2012-06-03 17:35:59 -07:00
commit ad65bba05f
85 changed files with 25462 additions and 406 deletions

View File

@ -16,6 +16,12 @@ License: BSD
The full text of the BSD license is distributed as in
/usr/share/common-licenses/BSD on Debian systems.
Files: src/qtcurve/*
Copyright: Craig Drummond, 2007 - 2010 craig.p.drummond@gmail.com
License: GPL-2
The full text of the GPL is distributed as in
/usr/share/common-licenses/GPL-2 on Debian systems.
Files: src/calibre/ebooks/chardet/*
Copyright: Copyright (C) 1998-2001 Netscape Communications Corporation
License: LGPL-2.1+

View File

@ -1,9 +1,13 @@
#v2 2011-07-25
# Calibre recipe for Instapaper.com (Stable version)
#
# Homepage: http://khromov.wordpress.com/projects/instapaper-calibre-recipe/
# Code Repository: https://bitbucket.org/khromov/calibre-instapaper
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1299694372(BasicNewsRecipe):
title = u'Instapaper'
__author__ = 'Darko Miletic, Stanislav Khromov'
__author__ = 'Darko Miletic, Stanislav Khromov, Jim Ramsay'
publisher = 'Instapaper.com'
category = 'info, custom, Instapaper'
oldest_article = 365
@ -24,12 +28,14 @@ class AdvancedUserRecipe1299694372(BasicNewsRecipe):
INDEX = u'http://www.instapaper.com'
LOGIN = INDEX + u'/user/login'
feeds = [
(u'Instapaper Unread', u'http://www.instapaper.com/u'),
(u'Instapaper Starred', u'http://www.instapaper.com/starred')
]
#Adds the title tag to the body of the recipe. Use this if your articles miss headings.
add_title_tag = False;
def get_browser(self):
br = BasicNewsRecipe.get_browser()
if self.username is not None:
@ -67,7 +73,10 @@ class AdvancedUserRecipe1299694372(BasicNewsRecipe):
article.title = soup.find('title').contents[0].strip()
def postprocess_html(self, soup, first_fetch):
#adds the title to each story, as it is not always included
if self.add_title_tag:
for link_tag in soup.findAll(attrs={"id" : "story"}):
link_tag.insert(0,'<h1>'+soup.find('title').contents[0].strip()+'</h1>')
#print repr(soup)
return soup

View File

@ -17,5 +17,5 @@ class AdvancedUserRecipe1327062445(BasicNewsRecipe):
remove_tags = [
dict(name='ul', attrs={'id':'ads0'})
]
masthead_url = 'http://www.simrendeogun.com/wp-content/uploads/2011/06/New-Marketing-Magazine-Logo.jpg'
feeds = [(u'My Marketing', u'http://feed43.com/0537744466058428.xml'), (u'My Marketing_', u'http://feed43.com/8126723074604845.xml'), (u'MarketingArena', u'http://feeds.feedburner.com/marketingarena'), (u'Marketing Journal', u'http://feeds.feedburner.com/marketingjournal/jPwA'), (u'Venturini', u'http://robertoventurini.blogspot.com/feeds/posts/default?alt=rss'), (u'Brandforum news', u'http://www.brandforum.it/rss/news'), (u'Brandforum papers', u'http://www.brandforum.it/rss/papers'), (u'minimarketing', u'http://feeds.feedburner.com/minimarketingit'), (u'[4]marketing.biz', u'http://feeds.feedburner.com/4marketing'), (u'Ninja Marketing', u'http://feeds.feedburner.com/NinjaMarketing'), (u'Bloguerrilla', u'http://feeds.feedburner.com/Bloguerrilla'), (u'Nonconvenzionale', u'http://feeds.feedburner.com/nonconvenzionale'), (u'Comunitàzione', u'http://www.comunitazione.it/feed/novita.asp'), (u'Disambiguando', u'http://giovannacosenza.wordpress.com/feed/')]
masthead_url = 'http://www.linkedin-marketing.it/blog/wp-content/uploads/2012/03/pb.jpg'
feeds = [(u'MarketingArena', u'http://feeds.feedburner.com/marketingarena'), (u'My Marketing', u'http://feed43.com/0537744466058428.xml'), (u'My Marketing_', u'http://feed43.com/8126723074604845.xml'), (u'Marketing Journal', u'http://feeds.feedburner.com/marketingjournal/jPwA'), (u'Venturini', u'http://robertoventurini.blogspot.com/feeds/posts/default?alt=rss'), (u'Brandforum news', u'http://www.brandforum.it/rss/news'), (u'Brandforum papers', u'http://www.brandforum.it/rss/papers'), (u'SintBlog', u'http://sint-blog.blogspot.com/feeds/posts/default'), (u'Ninja Marketing', u'http://feeds.feedburner.com/NinjaMarketing'), (u'Bloguerrilla', u'http://feeds.feedburner.com/Bloguerrilla'), (u'Nonconvenzionale', u'http://feeds.feedburner.com/nonconvenzionale'), (u'Disambiguando', u'http://giovannacosenza.wordpress.com/feed/')]

51
recipes/rabble_ca.recipe Normal file
View File

@ -0,0 +1,51 @@
from calibre.web.feeds.news import BasicNewsRecipe
import re
class RabbleCa(BasicNewsRecipe):
title = u'Rabble.ca'
__author__ = 'timtoo'
language = 'en_CA'
oldest_article = 7
max_articles_per_feed = 100
cover_url = 'https://upload.wikimedia.org/wikipedia/en/4/44/Rabble.png'
masthead_url = 'http://rabble.ca/sites/rabble/files/dreamyrabble_logo.jpg'
feeds = [(u'Rabble.ca', u'http://feeds.feedburner.com/rabble-news')]
preprocess_regexps = [
(re.compile(r'<a href="http://rabble.ca/user">.*?to post comments', re.DOTALL|re.IGNORECASE),
lambda match: 'Tags:'),
]
extra_css = """
.print-taxonomy { display: inline }
.print-taxonomy ul { display: inline; margin: 0px }
.print-taxonomy ul li { display: inline; list-style: none }
.field-type-date div { display: inline }
.field-type-link div { display: inline }
.field-type-text div { display: inline }
.field-label { font-style: italic }
"""
def print_version(self, url):
return url.replace('http://rabble.ca/', 'http://rabble.ca/print/')
remove_tags = [
# print version of the web page
dict(name='div', attrs={'class': ['print-logo']}),
dict(name='div', attrs={'class': ['print-site_name']}),
dict(name='hr', attrs={'class': ['print-hr']}),
dict(name='div', attrs={'class': ['print-links']}),
# regular web page in case you need to download them
dict(name='div', attrs={'id': ['header']}),
dict(name='div', attrs={'class': ['container-submenu']}),
dict(name='div', attrs={'id': ['sidebar']}),
dict(name='div', attrs={'id': ['footer']}),
dict(name='div', attrs={'class': ['rabble-nodelinks rabble-nodelinks-top']}),
dict(name='div', attrs={'class': ['rabble-nodelinks rabble-nodelinks-bottom']}),
dict(name='div', attrs={'class': ['tags-issues']}),
dict(name='div', attrs={'class': ['field field-type-text field-field-summary']}),
dict(name='span', attrs={'class': ['print-footnote']}),
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,8 +1,15 @@
" Project wide builtins
let $PYFLAKES_BUILTINS = "_,dynamic_property,__,P,I,lopen,icu_lower,icu_upper,icu_title,ngettext"
" Include directories for C modules
let g:syntastic_c_include_dirs = [ '/usr/include/podofo']
" Include directories for C++ modules
let g:syntastic_cpp_include_dirs = [
\'/usr/include/podofo',
\'/usr/include/qt4/QtCore',
\'/usr/include/qt4/QtGui',
\'/usr/include/qt4',
\'src/qtcurve/common', 'src/qtcurve',
\]
let g:syntastic_c_include_dirs = g:syntastic_cpp_include_dirs
fun! CalibreLog()
" Setup buffers to edit the calibre changelog and version info prior to

View File

@ -8,6 +8,7 @@ __docformat__ = 'restructuredtext en'
import textwrap, os, shlex, subprocess, glob, shutil
from distutils import sysconfig
from multiprocessing import cpu_count
from PyQt4.pyqtconfig import QtGuiModuleMakefile
@ -268,6 +269,7 @@ class Build(Command):
self.obj_dir = os.path.join(os.path.dirname(SRC), 'build', 'objects')
if not os.path.exists(self.obj_dir):
os.makedirs(self.obj_dir)
self.build_style(self.j(self.SRC, 'calibre', 'plugins'))
for ext in extensions:
if opts.only != 'all' and opts.only != ext.name:
continue
@ -362,6 +364,88 @@ class Build(Command):
print "Error while executing: %s\n" % (cmdline)
raise
def build_style(self, dest):
self.info('\n####### Building calibre style', '#'*7)
sdir = self.j(self.SRC, 'qtcurve')
def path(x):
x=self.j(sdir, x)
return ('"%s"'%x).replace(os.sep, '/')
headers = [
"common/colorutils.h",
"common/common.h",
"common/config_file.h",
"style/blurhelper.h",
"style/dialogpixmaps.h",
"style/fixx11h.h",
"style/pixmaps.h",
"style/qtcurve.h",
"style/shortcuthandler.h",
"style/utils.h",
"style/windowmanager.h",
]
sources = [
"common/colorutils.c",
"common/common.c",
"common/config_file.c",
"style/blurhelper.cpp",
"style/qtcurve.cpp",
"style/shortcuthandler.cpp",
"style/utils.cpp",
"style/windowmanager.cpp",
]
if not iswindows and not isosx:
headers.append( "style/shadowhelper.h")
sources.append('style/shadowhelper.cpp')
pro = textwrap.dedent('''
TEMPLATE = lib
CONFIG += qt plugin release
CONFIG -= embed_manifest_dll
VERSION = 1.0.0
DESTDIR = .
TARGET = calibre
QT *= svg
INCLUDEPATH *= {conf} {inc}
win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS
# Force C++ language
*g++*:QMAKE_CFLAGS *= -x c++
*msvc*:QMAKE_CFLAGS *= -TP
*msvc*:QMAKE_CXXFLAGS += /MP
''').format(conf=path(''), inc=path('common'))
if isosx:
pro += '\nCONFIG += x86 x86_64\n'
else:
pro += '\nunix:QT *= dbus\n'
for x in headers:
pro += 'HEADERS += %s\n'%path(x)
for x in sources:
pro += 'SOURCES += %s\n'%path(x)
odir = self.j(self.d(self.SRC), 'build', 'qtcurve')
if not os.path.exists(odir):
os.makedirs(odir)
ocwd = os.getcwdu()
os.chdir(odir)
try:
if not os.path.exists('qtcurve.pro') or (open('qtcurve.pro',
'rb').read() != pro):
with open('qtcurve.pro', 'wb') as f:
f.write(pro)
qmc = [QMAKE, '-o', 'Makefile']
if iswindows:
qmc += ['-spec', 'win32-msvc2008']
self.check_call(qmc + ['qtcurve.pro'])
self.check_call([make]+([] if iswindows else ['-j%d'%(cpu_count()
or 1)]))
src = (glob.glob('*.so') + glob.glob('release/*.dll') +
glob.glob('*.dylib'))
ext = 'pyd' if iswindows else 'so'
shutil.copy2(src[0], self.j(dest, 'calibre_style.'+ext))
finally:
os.chdir(ocwd)
def build_qt_objects(self, ext):
obj_pat = 'release\\*.obj' if iswindows else '*.o'
objects = glob.glob(obj_pat)

View File

@ -67,6 +67,7 @@ class VMInstaller(Command):
INSTALLER_EXT = None
VM = None
VM_NAME = None
VM_CHECK = None
FREEZE_COMMAND = None
FREEZE_TEMPLATE = 'python setup.py {freeze_command}'
SHUTDOWN_CMD = ['sudo', 'poweroff']
@ -117,6 +118,13 @@ class VMInstaller(Command):
def run_vm(self):
pat = '/%s/'%(self.VM_CHECK or self.VM_NAME)
pids= [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
cmdline = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
if 'vmware-vmx' in cmdline and pat in cmdline:
return
self.__p = subprocess.Popen([self.vm])
def start_vm(self, sleep=75):

View File

@ -28,6 +28,7 @@ class Win32(VMInstaller):
INSTALLER_EXT = 'exe'
VM_NAME = 'xp_build'
VM = '/vmware/bin/%s'%VM_NAME
VM_CHECK = 'calibre_windows_xp_home'
FREEZE_COMMAND = 'win32_freeze'
FREEZE_TEMPLATE = 'python -OO setup.py {freeze_command} --no-ice'
INSTALLER_EXT = 'msi'

View File

@ -16,6 +16,7 @@ from setup.installer.windows.wix import WixMixIn
OPENSSL_DIR = r'Q:\openssl'
QT_DIR = 'Q:\\Qt\\4.8.1'
QT_DLLS = ['Core', 'Gui', 'Network', 'Svg', 'WebKit', 'Xml', 'XmlPatterns']
QTCURVE = r'C:\plugins\styles'
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
SW = r'C:\cygwin\home\kovid\sw'
IMAGEMAGICK = os.path.join(SW, 'build', 'ImageMagick-6.7.6',
@ -247,6 +248,7 @@ class Win32Freeze(Command, WixMixIn):
if os.path.exists(tg):
shutil.rmtree(tg)
shutil.copytree(imfd, tg)
for dirpath, dirnames, filenames in os.walk(tdir):
for x in filenames:
if not x.endswith('.dll'):
@ -485,7 +487,8 @@ class Win32Freeze(Command, WixMixIn):
# Add the .pyds from python and calibre to the zip file
for x in (self.plugins_dir, self.dll_dir):
for pyd in os.listdir(x):
if pyd.endswith('.pyd') and pyd != 'sqlite_custom.pyd':
if pyd.endswith('.pyd') and pyd not in {
'sqlite_custom.pyd', 'calibre_style.pyd'}:
# sqlite_custom has to be a file for
# sqlite_load_extension to work
self.add_to_zipfile(zf, pyd, x)

View File

@ -122,9 +122,9 @@ class ANDROID(USBMS):
# LG
0x1004 : {
0x61c5 : [0x100, 0x226, 0x9999],
0x61cc : [0x100],
0x61ce : [0x100],
0x61c5 : [0x100, 0x226, 0x227, 0x9999],
0x61cc : [0x226, 0x227, 0x9999, 0x100],
0x61ce : [0x226, 0x227, 0x9999, 0x100],
0x618e : [0x226, 0x227, 0x9999, 0x100],
0x6205 : [0x226, 0x227, 0x9999, 0x100],
},
@ -165,6 +165,9 @@ class ANDROID(USBMS):
# Lenovo
0x17ef : { 0x7421 : [0x0216] },
# Pantech
0x10a9 : { 0x6050 : [0x227] },
}
EBOOK_DIR_MAIN = ['eBooks/import', 'wordplayer/calibretransfer', 'Books',
'sdcard/ebooks']

View File

@ -298,6 +298,8 @@ class PRST1(USBMS):
cursor.close()
def read_device_books(self, connection, source_id):
from sqlite3 import DatabaseError
sequence_min = self.get_database_min_id(source_id)
sequence_max = sequence_min
sequence_dirty = 0
@ -463,6 +465,8 @@ class PRST1(USBMS):
cursor.close()
def read_device_collections(self, connection, source_id):
from sqlite3 import DatabaseError
sequence_min = self.get_database_min_id(source_id)
sequence_max = sequence_min
sequence_dirty = 0

View File

@ -8,6 +8,7 @@ manner.
import sys, os, re
from threading import RLock
from calibre import prints, as_unicode
from calibre.constants import iswindows, isosx, plugins, islinux, isfreebsd
osx_scanner = win_scanner = linux_scanner = None
@ -53,7 +54,10 @@ class WinPNPScanner(object):
ans = True
try:
win32file.GetDiskFreeSpaceEx(letter+':\\')
except:
except Exception as e:
if debug:
prints('Unable to get free space for drive:', letter)
prints(as_unicode(e))
ans = False
return ans
finally:

View File

@ -8,7 +8,7 @@ from PyQt4.Qt import (QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices,
QFileDialog, QFileIconProvider, QSettings,
QIcon, QApplication, QDialog, QUrl, QFont)
QIcon, QApplication, QDialog, QUrl, QFont, QPalette)
ORG_NAME = 'KovidsBrain'
APP_UID = 'libprs500'
@ -106,6 +106,7 @@ gprefs.defaults['auto_add_path'] = None
gprefs.defaults['auto_add_check_for_duplicates'] = False
gprefs.defaults['blocked_auto_formats'] = []
gprefs.defaults['auto_add_auto_convert'] = True
gprefs.defaults['widget_style'] = 'system'
# }}}
NONE = QVariant() #: Null value to return from the data function of item models
@ -470,6 +471,7 @@ class FileIconProvider(QFileIconProvider):
'djvu' : 'djvu',
'xps' : 'xps',
'oxps' : 'xps',
'docx' : 'docx',
}
def __init__(self):
@ -718,10 +720,10 @@ gui_thread = None
qt_app = None
class Application(QApplication):
def __init__(self, args):
def __init__(self, args, force_calibre_style=False):
self.file_event_hook = None
qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
QApplication.__init__(self, qargs)
self.file_event_hook = None
global gui_thread, qt_app
gui_thread = QThread.currentThread()
self._translator = None
@ -729,6 +731,19 @@ class Application(QApplication):
qt_app = self
self._file_open_paths = []
self._file_open_lock = RLock()
self.setup_styles(force_calibre_style)
def load_calibre_style(self):
# On OS X QtCurve resets the palette, so we preserve it explicitly
orig_pal = QPalette(self.palette())
from calibre.constants import plugins
pi = plugins['progress_indicator'][0]
path = os.path.join(sys.extensions_location, 'calibre_style.'+(
'pyd' if iswindows else 'so'))
pi.load_style(path, 'Calibre')
self.setPalette(orig_pal)
def setup_styles(self, force_calibre_style):
self.original_font = QFont(QApplication.font())
fi = gprefs['font']
if fi is not None:
@ -737,15 +752,18 @@ class Application(QApplication):
if s is not None:
font.setStretch(s)
QApplication.setFont(font)
if force_calibre_style or gprefs['widget_style'] != 'system':
self.load_calibre_style()
else:
st = self.style()
if st is not None:
st = unicode(st.objectName()).lower()
if (islinux or isbsd) and st in ('windows', 'motif', 'cde'):
from PyQt4.Qt import QStyleFactory
styles = set(map(unicode, QStyleFactory.keys()))
if 'Plastique' in styles and os.environ.get('KDE_FULL_SESSION',
False):
self.setStyle('Plastique')
if os.environ.get('KDE_FULL_SESSION', False):
self.load_calibre_style()
elif 'Cleanlooks' in styles:
self.setStyle('Cleanlooks')

View File

@ -116,7 +116,7 @@ class DeleteAction(InterfaceAction):
for action in list(self.delete_menu.actions())[1:]:
action.setEnabled(enabled)
def _get_selected_formats(self, msg, ids, exclude=False):
def _get_selected_formats(self, msg, ids, exclude=False, single=False):
from calibre.gui2.dialogs.select_formats import SelectFormats
c = Counter()
db = self.gui.library_view.model().db
@ -125,7 +125,8 @@ class DeleteAction(InterfaceAction):
if fmts_:
for x in frozenset([x.lower() for x in fmts_.split(',')]):
c[x] += 1
d = SelectFormats(c, msg, parent=self.gui, exclude=exclude)
d = SelectFormats(c, msg, parent=self.gui, exclude=exclude,
single=single)
if d.exec_() != d.Accepted:
return None
return d.selected_formats

View File

@ -8,30 +8,11 @@ __docformat__ = 'restructuredtext en'
import os
from functools import partial
from PyQt4.Qt import QMenu, pyqtSignal
from calibre.utils.config import prefs
from calibre.gui2 import (error_dialog, Dispatcher, gprefs,
choose_dir, warning_dialog, open_local_file)
from calibre.gui2.actions import InterfaceAction
from calibre.ebooks import BOOK_EXTENSIONS
class SaveMenu(QMenu): # {{{
save_fmt = pyqtSignal(object)
def __init__(self, parent):
QMenu.__init__(self, _('Save single format to disk...'), parent)
for ext in sorted(BOOK_EXTENSIONS):
action = self.addAction(ext.upper())
setattr(self, 'do_'+ext, partial(self.do, ext))
action.triggered.connect(
getattr(self, 'do_'+ext))
def do(self, ext, *args):
self.save_fmt.emit(ext)
# }}}
class SaveToDiskAction(InterfaceAction):
@ -54,9 +35,8 @@ class SaveToDiskAction(InterfaceAction):
_('Save only %s format to disk in a single directory')%
prefs['output_format'].upper(),
triggered=partial(self.save_single_fmt_to_single_dir, False))
self.save_sub_menu = SaveMenu(self.gui)
self.save_sub_menu_action = self.save_menu.addMenu(self.save_sub_menu)
self.save_sub_menu.save_fmt.connect(self.save_specific_format_disk)
cm('specific format', _('Save single format to disk...'),
triggered=self.save_specific_format_disk)
def location_selected(self, loc):
enabled = loc == 'library'
@ -74,8 +54,17 @@ class SaveToDiskAction(InterfaceAction):
def save_single_format_to_disk(self, checked):
self.save_to_disk(checked, False, prefs['output_format'])
def save_specific_format_disk(self, fmt):
self.save_to_disk(False, False, fmt)
def save_specific_format_disk(self):
rb = self.gui.iactions['Remove Books']
ids = rb._get_selected_ids(err_title=
_('Cannot save to disk'))
if not ids: return
fmts = rb._get_selected_formats(
_('Choose format to save to disk'), ids,
single=True)
if not fmts:
return
self.save_to_disk(False, False, list(fmts)[0])
def save_to_single_dir(self, checked):
self.save_to_disk(checked, True)

View File

@ -50,6 +50,7 @@ class SelectFormats(QDialog):
def __init__(self, fmt_count, msg, single=False, parent=None, exclude=False):
QDialog.__init__(self, parent)
self._l = QVBoxLayout(self)
self.single_fmt = single
self.setLayout(self._l)
self.setWindowTitle(_('Choose formats'))
self._m = QLabel(msg)
@ -57,6 +58,8 @@ class SelectFormats(QDialog):
self._l.addWidget(self._m)
self.formats = Formats(fmt_count)
self.fview = QListView(self)
self.fview.doubleClicked.connect(self.double_clicked,
type=Qt.QueuedConnection)
if exclude:
self.fview.setStyleSheet('''
QListView { background-color: #FAE7B5}
@ -82,6 +85,11 @@ class SelectFormats(QDialog):
self.selected_formats.add(self.formats.fmt(idx))
QDialog.accept(self, *args)
def double_clicked(self, index):
if self.single_fmt:
self.accept()
if __name__ == '__main__':
from PyQt4.Qt import QApplication
app = QApplication([])

View File

@ -13,7 +13,7 @@ from datetime import datetime
from PyQt4.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton,
QGridLayout, pyqtSignal, QDialogButtonBox, QScrollArea, QFont,
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem,
QSizePolicy, QPalette, QFrame, QSize, QKeySequence, QMenu, QShortcut)
QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut)
from calibre.ebooks.metadata import authors_to_string, string_to_authors
from calibre.gui2 import ResizableDialog, error_dialog, gprefs, pixmap_to_data
@ -45,7 +45,7 @@ class MetadataSingleDialogBase(ResizableDialog):
ResizableDialog.__init__(self, parent)
def setupUi(self, *args): # {{{
self.resize(990, 650)
self.resize(990, 670)
self.download_shortcut = QShortcut(self)
self.download_shortcut.setKey(QKeySequence('Ctrl+D',
@ -57,9 +57,7 @@ class MetadataSingleDialogBase(ResizableDialog):
if sc:
self.download_shortcut.setKey(sc[0])
self.button_box = QDialogButtonBox(
QDialogButtonBox.Ok|QDialogButtonBox.Cancel, Qt.Horizontal,
self)
self.button_box = bb = QDialogButtonBox(self)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.next_button = QPushButton(QIcon(I('forward.png')), _('Next'),
@ -70,9 +68,11 @@ class MetadataSingleDialogBase(ResizableDialog):
self)
self.prev_button.setShortcut(QKeySequence('Alt+Left'))
self.button_box.addButton(self.prev_button, self.button_box.ActionRole)
self.button_box.addButton(self.next_button, self.button_box.ActionRole)
self.button_box.addButton(self.prev_button, bb.ActionRole)
self.button_box.addButton(self.next_button, bb.ActionRole)
self.prev_button.clicked.connect(self.prev_clicked)
bb.setStandardButtons(bb.Ok|bb.Cancel)
bb.button(bb.Ok).setDefault(True)
self.scroll_area = QScrollArea(self)
self.scroll_area.setFrameShape(QScrollArea.NoFrame)
@ -82,13 +82,11 @@ class MetadataSingleDialogBase(ResizableDialog):
self.l = QVBoxLayout(self)
self.setLayout(self.l)
self.l.setMargin(0)
self.l.addWidget(self.scroll_area)
ll = self.button_box_layout = QHBoxLayout()
self.l.addLayout(ll)
ll.addSpacing(10)
ll.addWidget(self.button_box)
ll.addSpacing(10)
self.setWindowIcon(QIcon(I('edit_input.png')))
self.setWindowTitle(BASE_TITLE)
@ -98,7 +96,6 @@ class MetadataSingleDialogBase(ResizableDialog):
if len(self.db.custom_column_label_map):
self.create_custom_metadata_widgets()
self.do_layout()
geom = gprefs.get('metasingle_window_geometry3', None)
if geom is not None:
@ -509,15 +506,14 @@ class MetadataSingleDialogBase(ResizableDialog):
tip = (_('Save changes and edit the metadata of %s')+
' [Alt+Right]')%next_
self.next_button.setToolTip(tip)
self.next_button.setVisible(next_ is not None)
self.next_button.setEnabled(next_ is not None)
if prev is not None:
tip = (_('Save changes and edit the metadata of %s')+
' [Alt+Left]')%prev
self.prev_button.setToolTip(tip)
self.prev_button.setVisible(prev is not None)
self.prev_button.setEnabled(prev is not None)
self(self.db.id(self.row_list[self.current_row]))
def break_cycles(self):
# Break any reference cycles that could prevent python
# from garbage collecting this dialog
@ -623,7 +619,6 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{
self.tabs[0].middle = w = QWidget(self)
w.l = l = QGridLayout()
w.setLayout(w.l)
l.setMargin(0)
self.splitter.addWidget(w)
def create_row2(row, widget, button=None, front_button=None):
row += 1
@ -787,7 +782,6 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{
gb.setLayout(gbl)
sr = QScrollArea(tab0)
sr.setWidgetResizable(True)
sr.setBackgroundRole(QPalette.Base)
sr.setFrameStyle(QFrame.NoFrame)
sr.setWidget(w)
gbl.addWidget(sr)
@ -925,7 +919,6 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{
sr = QScrollArea(gb)
sr.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
sr.setWidgetResizable(True)
sr.setBackgroundRole(QPalette.Base)
sr.setFrameStyle(QFrame.NoFrame)
sr.setWidget(w)
gbl.addWidget(sr)

View File

@ -49,7 +49,9 @@ class RichTextDelegate(QStyledItemDelegate): # {{{
doc = QTextDocument()
if option is not None and option.state & QStyle.State_Selected:
p = option.palette
c = p.color(p.Active, p.HighlightedText)
group = (p.Active if option.state & QStyle.State_Active else
p.Inactive)
c = p.color(group, p.HighlightedText)
c = 'rgb(%d, %d, %d)'%c.getRgb()[:3]
doc.setDefaultStyleSheet(' * { color: %s }'%c)
doc.setHtml(index.data().toString())

View File

@ -101,6 +101,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('gui_layout', config, restart_required=True, choices=
[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
r('widget_style', gprefs, restart_required=True, choices=
[(_('System default'), 'system'), (_('Calibre style'),
'calibre')])
r('cover_flow_queue_length', config, restart_required=True)

View File

@ -28,7 +28,34 @@
<string>Main Interface</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Choose &amp;language (requires restart):</string>
</property>
<property name="buddy">
<cstring>opt_language</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="opt_language">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
<property name="minimumContentsLength">
<number>20</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="opt_systray_icon">
<property name="text">
<string>Enable system &amp;tray icon (needs restart)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>User Interface &amp;layout (needs restart):</string>
@ -38,7 +65,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="opt_gui_layout">
<property name="maximumSize">
<size>
@ -54,34 +81,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Choose &amp;language (requires restart):</string>
</property>
<property name="buddy">
<cstring>opt_language</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="opt_language">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
<property name="minimumContentsLength">
<number>20</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="opt_systray_icon">
<property name="text">
<string>Enable system &amp;tray icon (needs restart)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QCheckBox" name="opt_disable_animations">
<property name="toolTip">
<string>Disable all animations. Useful if you have a slow/old computer.</string>
@ -91,21 +91,21 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QCheckBox" name="opt_disable_tray_notification">
<property name="text">
<string>Disable &amp;notifications in system tray</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QCheckBox" name="opt_show_splash_screen">
<property name="text">
<string>Show &amp;splash screen at startup</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>&amp;Toolbar</string>
@ -140,7 +140,20 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="7" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
@ -161,25 +174,25 @@
</item>
</layout>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QPushButton" name="change_font_button">
<property name="text">
<string>Change &amp;font (needs restart)</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="0" column="0">
<widget class="QLabel" name="label_widget_style">
<property name="text">
<string>User interface &amp;style (needs restart):</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="buddy">
<cstring>opt_widget_style</cstring>
</property>
</spacer>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="opt_widget_style"/>
</item>
</layout>
</widget>

View File

@ -206,7 +206,7 @@ class Preferences(QMainWindow):
self.cw.layout().addWidget(self.stack)
self.bb = QDialogButtonBox(QDialogButtonBox.Close)
self.wizard_button = self.bb.addButton(_('Run welcome wizard'),
self.bb.DestructiveRole)
self.bb.ActionRole)
self.wizard_button.setIcon(QIcon(I('wizard.png')))
self.wizard_button.clicked.connect(self.run_wizard,
type=Qt.QueuedConnection)

View File

@ -1,6 +1,10 @@
#include "QProgressIndicator.h"
#include <QPainter>
#include <QStylePlugin>
#include <QPluginLoader>
#include <QStyle>
#include <QApplication>
QProgressIndicator::QProgressIndicator(QWidget* parent, int size)
: QWidget(parent),
@ -122,3 +126,22 @@ void QProgressIndicator::paintEvent(QPaintEvent * /*event*/)
p.restore();
}
}
int load_style(QString &path, QString &name) {
int ret = 0;
QStyle *s;
QPluginLoader pl(path);
QObject *o = pl.instance();
if (o != 0) {
QStylePlugin *sp = qobject_cast<QStylePlugin *>(o);
if (sp != 0) {
s = sp->create(name);
if (s != 0) {
s->setObjectName(name);
QApplication::setStyle(s);
ret = 1;
}
}
}
return ret;
}

View File

@ -91,3 +91,12 @@ private:
QColor m_color;
};
/* Utility function that can be used to load a QStyle from a Qt plugin. This is
* here so that there is no need to create a separate PyQt plugin just for this
* simple functionality.
* \param path The full path to the DLL containing the plugin
* \param name The name of the style plugin to load
* \return 1 if succeeds 0 otherwise. The objectName of the loaded style is set to name
*/
int load_style(QString &path, QString &name);

View File

@ -6,6 +6,10 @@
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%ModuleHeaderCode
int load_style(QString &path, QString &name);
%End
class QProgressIndicator : QWidget {
%TypeHeaderCode
@ -50,3 +54,6 @@ protected:
virtual void paintEvent(QPaintEvent * event);
};
int load_style(QString &path, QString &name);

View File

@ -418,8 +418,11 @@ class TagsModel(QAbstractItemModel): # {{{
chardict[c][1] = idx
# sort the ranges to facilitate detecting overlap
if len(chardict) == 1 and ' ' in chardict:
# The category could not be partitioned.
collapse_model = 'disable'
else:
ranges = sorted([(v[0], v[1], c) for c,v in chardict.items()])
# Create a list of 'first letters' to use for each item in
# the category. The list is generated using the ranges. Overlaps
# are filled with the character that first occurs.
@ -448,13 +451,19 @@ class TagsModel(QAbstractItemModel): # {{{
else:
d['last'] = data[key][cat_len-1]
name = eval_formatter.safe_format(collapse_template,
d, 'TAG_VIEW', None)
d, '##TAG_VIEW##', None)
if name.startswith('##TAG_VIEW##'):
# Formatter threw an exception. Don't create subnode
node_parent = category
else:
sub_cat = self.create_node(parent=category, data = name,
tooltip = None, temporary=True,
category_icon = category_node.icon,
category_key=category_node.category_key,
icon_map=self.icon_state_map)
sub_cat.tag.is_searchable = False
sub_cat.is_gst = is_gst
node_parent = sub_cat
else: # by 'first letter'
cl = cl_list[idx]
if cl != collapse_letter:
@ -1178,6 +1187,7 @@ class TagsModel(QAbstractItemModel): # {{{
for subnode in tag_item.children:
if subnode.tag.sort:
letters_seen[subnode.tag.sort[0]] = True
if letters_seen:
charclass = ''.join(letters_seen)
if k == 'author_sort':
expr = r'%s:"~(^[%s])|(&\s*[%s])"'%(k, charclass, charclass)
@ -1185,6 +1195,8 @@ class TagsModel(QAbstractItemModel): # {{{
expr = r'series_sort:"~^[%s]"'%(charclass)
else:
expr = r'%s:"~^[%s]"'%(k, charclass)
else:
expr = r'%s:false'%(k)
if node_searches[tag_item.tag.state] == 'true':
ans.append(expr)
else:

View File

@ -388,7 +388,7 @@ class TagBrowserWidget(QWidget): # {{{
type=Qt.QueuedConnection)
parent.alter_tb = l = QPushButton(parent)
l.setText(_('&Alter Tag Browser'))
l.setText(_('Alter Tag Browser'))
l.setIcon(QIcon(I('tags.png')))
l.m = QMenu()
l.setMenu(l.m)

View File

@ -117,6 +117,7 @@ class TagsView(QTreeView): # {{{
QTreeView::item:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
border: 1px solid #bfcde4;
border-radius: 6px;
}
''')

View File

@ -649,7 +649,7 @@ class DocumentView(QWebView): # {{{
def current_page_image(self, overlap=-1):
if overlap < 0:
overlap = self.height()
img = QImage(self.width(), overlap, QImage.Format_ARGB32)
img = QImage(self.width(), overlap, QImage.Format_ARGB32_Premultiplied)
painter = QPainter(img)
self.document.mainFrame().render(painter, QRegion(0, 0, self.width(), overlap))
painter.end()

View File

@ -28,6 +28,7 @@ from calibre.customize.ui import available_input_formats
from calibre.gui2.viewer.dictionary import Lookup
from calibre import as_unicode, force_unicode, isbytestring
from calibre.ptempfile import reset_base_dir
from calibre.utils.zipfile import BadZipfile
vprefs = JSONConfig('viewer')
@ -37,6 +38,11 @@ class Worker(Thread):
try:
Thread.run(self)
self.exception = self.traceback = None
except BadZipfile:
self.exception = _(
'This ebook is corrupted and cannot be opened. If you '
'downloaded it from somewhere, try downloading it again.')
self.traceback = ''
except Exception as err:
self.exception = err
self.traceback = traceback.format_exc()

View File

@ -32,6 +32,7 @@ class TOCView(QTreeView):
QTreeView::item:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
border: 1px solid #bfcde4;
border-radius: 6px;
}
QHeaderView::section {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
@ -69,7 +70,11 @@ class TOCItem(QStandardItem):
if si == self.abspath:
spos = i
break
try:
am = getattr(spine[i], 'anchor_map', {})
except UnboundLocalError:
# Spine was empty?
am = {}
frag = self.fragment if (self.fragment and self.fragment in am) else None
self.starts_at = spos
self.start_anchor = frag

View File

@ -418,9 +418,17 @@ class KindlePage(QWizardPage, KindleUI):
def initializePage(self):
opts = smtp_prefs().parse()
for x in opts.accounts.keys():
accs = []
has_default = False
for x, ac in opts.accounts.iteritems():
default = ac[2]
if x.strip().endswith('@kindle.com'):
self.to_address.setText(x)
accs.append((x, default))
if default: has_default = True
if has_default:
accs = [x for x in accs if x[1]]
if accs:
self.to_address.setText(accs[0])
def x():
t = unicode(self.to_address.text())
if t.strip():

View File

@ -40,7 +40,7 @@ def write_dirtied(db):
def get_parser(usage):
parser = OptionParser(usage)
go = parser.add_option_group('GLOBAL OPTIONS')
go = parser.add_option_group(_('GLOBAL OPTIONS'))
go.add_option('--library-path', '--with-library', default=None, help=_('Path to the calibre library. Default is to use the path stored in the settings.'))
return parser

File diff suppressed because it is too large Load Diff

View File

@ -89,6 +89,11 @@ class OptionParser(_OptionParser):
formatter=CustomHelpFormatter(),
conflict_handler=conflict_handler, **kwds)
self.gui_mode = gui_mode
if False:
# Translatable string from optparse
_("Options")
_("show this help message and exit")
_("show program's version number and exit")
def error(self, msg):
if self.gui_mode:

View File

@ -186,6 +186,12 @@ def main():
args = conn.recv()
try:
mod, func, args, kwargs = args
try:
mod = importlib.import_module(mod)
except ImportError:
# Load plugins incase fork_job() is being used in a plugin
import calibre.customize.ui as u
u
mod = importlib.import_module(mod)
func = getattr(mod, func)
res = {'result':func(*args, **kwargs)}

1
src/qtcurve/AUTHORS Normal file
View File

@ -0,0 +1 @@
Craig Drummond <craig.p.drummond@gmail.com>

340
src/qtcurve/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

View File

@ -0,0 +1,342 @@
/*
This file is taken from kcolorspaces.cpp and kcolorutils.cpp from kdelibs
The code has been modified to work with QColor (Qt3 &Qt4) and GdkColor
*/
/* This file is part of the KDE project
* Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
* Copyright (C) 2007 Olaf Schmidt <ojschmidt@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "common.h"
#ifdef __cplusplus
#include <qglobal.h>
#endif
#if !(defined QT_VERSION && (QT_VERSION >= 0x040000) && !defined QTC_QT_ONLY)
#include <math.h>
#if defined _WIN32 && defined QT_VERSION && (QT_VERSION >= 0x040000)
#include <sys/stat.h>
#include <float.h>
#include <direct.h>
static int isnan(double x)
{
return _isnan(x);
}
#endif
#ifdef __cplusplus
static inline int qtcLimit(double c)
{
return c < 0.0 ? 0 : (c > 255.0 ? 255 : (int)c);
}
#else
static inline int qtcLimit(double c)
{
return c < 0.0
? 0
: c > 65535.0
? 65535
: (int)c;
}
#endif
#ifdef __cplusplus
#if defined QT_VERSION && (QT_VERSION >= 0x040000)
#define FLOAT_COLOR(VAL, COL) (VAL).COL##F()
#define TO_COLOR(R, G, B) QColor::fromRgbF(R, G, B)
#else
#define FLOAT_COLOR(VAL, COL) ((double)(((VAL).COL()*1.0)/255.0))
#define TO_COLOR(R, G, B) QColor(qtcLimit(R*255.0), qtcLimit(G*255.0), qtcLimit(B*255.0))
#endif
#else
#define inline
#define FLOAT_COLOR(VAL, COL) ((double)(((VAL).COL*1.0)/65535.0))
static GdkColor qtcGdkColor(double r, double g, double b)
{
GdkColor col;
col.red=qtcLimit(r*65535);
col.green=qtcLimit(g*65535);
col.blue=qtcLimit(b*65535);
return col;
}
#define TO_COLOR(R, G, B) qtcGdkColor(R, G, B)
#endif
static inline double ColorUtils_normalize(double a)
{
return (a < 1.0 ? (a > 0.0 ? a : 0.0) : 1.0);
}
static inline double ColorUtils_wrap(double a)
{
static double d = 1.0;
double r = fmod(a, d);
return (r < 0.0 ? d + r : (r > 0.0 ? r : 0.0));
}
#define HCY_REC 709 // use 709 for now
#if HCY_REC == 601
static const double yc[3] = { 0.299, 0.587, 0.114 };
#elif HCY_REC == 709
static const double yc[3] = {0.2126, 0.7152, 0.0722};
#else // use Qt values
static const double yc[3] = { 0.34375, 0.5, 0.15625 };
#endif
static inline double ColorUtils_HCY_gamma(double n)
{
return pow(ColorUtils_normalize(n), 2.2);
}
static inline double ColorUtils_HCY_igamma(double n)
{
return pow(ColorUtils_normalize(n), 1.0/2.2);
}
static inline double ColorUtils_HCY_lumag(double r, double g, double b)
{
return r*yc[0] + g*yc[1] + b*yc[2];
}
typedef struct
{
double h, c, y;
} ColorUtils_HCY;
// static ColorUtils_HCY ColorUtils_HCY_fromValues(double h_, double c_, double y_/*, double a_*/)
// {
// h = h_;
// c = c_;
// y = y_;
// // a = a_;
// }
static ColorUtils_HCY ColorUtils_HCY_fromColor(const color *color)
{
ColorUtils_HCY hcy;
double r = ColorUtils_HCY_gamma(FLOAT_COLOR(*color, red));
double g = ColorUtils_HCY_gamma(FLOAT_COLOR(*color, green));
double b = ColorUtils_HCY_gamma(FLOAT_COLOR(*color, blue));
// a = color.alphaF();
// luma component
hcy.y = ColorUtils_HCY_lumag(r, g, b);
// hue component
double p = MAX(MAX(r, g), b);
double n = MIN(MIN(r, g), b);
double d = 6.0 * (p - n);
if (n == p)
hcy.h = 0.0;
else if (r == p)
hcy.h = ((g - b) / d);
else if (g == p)
hcy.h = ((b - r) / d) + (1.0 / 3.0);
else
hcy.h = ((r - g) / d) + (2.0 / 3.0);
// chroma component
if (0.0 == hcy.y || 1.0 == hcy.y)
hcy.c = 0.0;
else
hcy.c = MAX( (hcy.y - n) / hcy.y, (p - hcy.y) / (1 - hcy.y) );
return hcy;
}
static color ColorUtils_HCY_toColor(ColorUtils_HCY *hcy)
{
// start with sane component values
double _h = ColorUtils_wrap(hcy->h);
double _c = ColorUtils_normalize(hcy->c);
double _y = ColorUtils_normalize(hcy->y);
// calculate some needed variables
double _hs = _h * 6.0, th, tm;
if (_hs < 1.0) {
th = _hs;
tm = yc[0] + yc[1] * th;
}
else if (_hs < 2.0) {
th = 2.0 - _hs;
tm = yc[1] + yc[0] * th;
}
else if (_hs < 3.0) {
th = _hs - 2.0;
tm = yc[1] + yc[2] * th;
}
else if (_hs < 4.0) {
th = 4.0 - _hs;
tm = yc[2] + yc[1] * th;
}
else if (_hs < 5.0) {
th = _hs - 4.0;
tm = yc[2] + yc[0] * th;
}
else {
th = 6.0 - _hs;
tm = yc[0] + yc[2] * th;
}
// calculate RGB channels in sorted order
double tn, to, tp;
if (tm >= _y) {
tp = _y + _y * _c * (1.0 - tm) / tm;
to = _y + _y * _c * (th - tm) / tm;
tn = _y - (_y * _c);
}
else {
tp = _y + (1.0 - _y) * _c;
to = _y + (1.0 - _y) * _c * (th - tm) / (1.0 - tm);
tn = _y - (1.0 - _y) * _c * tm / (1.0 - tm);
}
// return RGB channels in appropriate order
if (_hs < 1.0)
return TO_COLOR(ColorUtils_HCY_igamma(tp), ColorUtils_HCY_igamma(to), ColorUtils_HCY_igamma(tn));
else if (_hs < 2.0)
return TO_COLOR(ColorUtils_HCY_igamma(to), ColorUtils_HCY_igamma(tp), ColorUtils_HCY_igamma(tn));
else if (_hs < 3.0)
return TO_COLOR(ColorUtils_HCY_igamma(tn), ColorUtils_HCY_igamma(tp), ColorUtils_HCY_igamma(to));
else if (_hs < 4.0)
return TO_COLOR(ColorUtils_HCY_igamma(tn), ColorUtils_HCY_igamma(to), ColorUtils_HCY_igamma(tp));
else if (_hs < 5.0)
return TO_COLOR(ColorUtils_HCY_igamma(to), ColorUtils_HCY_igamma(tn), ColorUtils_HCY_igamma(tp));
else
return TO_COLOR(ColorUtils_HCY_igamma(tp), ColorUtils_HCY_igamma(tn), ColorUtils_HCY_igamma(to));
}
// #ifndef __cplusplus
static inline double ColorUtils_HCY_luma(const color *color)
{
return ColorUtils_HCY_lumag(ColorUtils_HCY_gamma(FLOAT_COLOR(*color, red)),
ColorUtils_HCY_gamma(FLOAT_COLOR(*color, green)),
ColorUtils_HCY_gamma(FLOAT_COLOR(*color, blue)));
}
static inline double ColorUtils_mixQreal(double a, double b, double bias)
{
return a + (b - a) * bias;
}
double ColorUtils_luma(const color *color)
{
return ColorUtils_HCY_luma(color);
}
static double ColorUtils_contrastRatio(const color *c1, const color *c2)
{
double y1 = ColorUtils_luma(c1), y2 = ColorUtils_luma(c2);
if (y1 > y2)
return (y1 + 0.05) / (y2 + 0.05);
else
return (y2 + 0.05) / (y1 + 0.05);
}
color ColorUtils_lighten(const color *color, double ky, double kc)
{
ColorUtils_HCY c=ColorUtils_HCY_fromColor(color);
c.y = 1.0 - ColorUtils_normalize((1.0 - c.y) * (1.0 - ky));
c.c = 1.0 - ColorUtils_normalize((1.0 - c.c) * kc);
return ColorUtils_HCY_toColor(&c);
}
color ColorUtils_darken(const color *color, double ky, double kc)
{
ColorUtils_HCY c=ColorUtils_HCY_fromColor(color);
c.y = ColorUtils_normalize(c.y * (1.0 - ky));
c.c = ColorUtils_normalize(c.c * kc);
return ColorUtils_HCY_toColor(&c);
}
color ColorUtils_shade(const color *color, double ky, double kc)
{
ColorUtils_HCY c=ColorUtils_HCY_fromColor(color);
c.y = ColorUtils_normalize(c.y + ky);
c.c = ColorUtils_normalize(c.c + kc);
return ColorUtils_HCY_toColor(&c);
}
color ColorUtils_mix(const color *c1, const color *c2, double bias);
static color ColorUtils_tintHelper(const color *base, const color *col, double amount)
{
color mixed=ColorUtils_mix(base, col, pow(amount, 0.3));
ColorUtils_HCY c=ColorUtils_HCY_fromColor(&mixed);
c.y = ColorUtils_mixQreal(ColorUtils_luma(base), c.y, amount);
return ColorUtils_HCY_toColor(&c);
}
color ColorUtils_tint(const color *base, const color *col, double amount)
{
if (amount <= 0.0) return *base;
if (amount >= 1.0) return *col;
if (isnan(amount)) return *base;
double ri = ColorUtils_contrastRatio(base, col);
double rg = 1.0 + ((ri + 1.0) * amount * amount * amount);
double u = 1.0, l = 0.0;
color result;
int i;
for (i = 12 ; i ; --i) {
double a = 0.5 * (l+u);
result = ColorUtils_tintHelper(base, col, a);
double ra = ColorUtils_contrastRatio(base, &result);
if (ra > rg)
u = a;
else
l = a;
}
return result;
}
color ColorUtils_mix(const color *c1, const color *c2, double bias)
{
if (bias <= 0.0) return *c1;
if (bias >= 1.0) return *c2;
if (isnan(bias)) return *c1;
{
double r = ColorUtils_mixQreal(FLOAT_COLOR(*c1, red), FLOAT_COLOR(*c2, red), bias);
double g = ColorUtils_mixQreal(FLOAT_COLOR(*c1, green), FLOAT_COLOR(*c2, green), bias);
double b = ColorUtils_mixQreal(FLOAT_COLOR(*c1, blue), FLOAT_COLOR(*c2, blue), bias);
/*double a = ColorUtils_mixQreal(FLOAT_COLOR(*c1, alpha), FLOAT_COLOR(*c2, alpha), bias);*/
return TO_COLOR(r, g, b);
}
}
// #endif
/* Added!!! */
// static color ColorUtils_shade_qtc(const color *color, double k)
// {
// ColorUtils_HCY c=ColorUtils_HCY_fromColor(color);
// c.y = ColorUtils_normalize(c.y * (k>1.0 ? (k*1.1) : (k<1.0 ? (k*0.9) : k)));
// return ColorUtils_HCY_toColor(&c);
// }
#endif // !(defined QT_VERSION && (QT_VERSION >= 0x040000) && !defined QTC_QT_ONLY)

View File

@ -0,0 +1,11 @@
#ifndef QTC_COLOR_UTILS_H
#define QTC_COLOR_UTILS_H
extern color ColorUtils_lighten(const color *color, double ky, double kc);
extern color ColorUtils_darken(const color *color, double ky, double kc);
extern color ColorUtils_shade(const color *color, double ky, double kc);
extern color ColorUtils_tint(const color *base, const color *col, double amount);
extern color ColorUtils_mix(const color *c1, const color *c2, double bias);
extern double ColorUtils_luma(const color *color);
#endif

728
src/qtcurve/common/common.c Normal file
View File

@ -0,0 +1,728 @@
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include "common.h"
#include "colorutils.h"
#ifdef __cplusplus
#include <qglobal.h>
#else
#include <stdlib.h>
#endif
/* Taken from rgb->hsl routines taken from KColor
Copyright 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
*/
static inline double normalize(double a)
{
return (a < 0.0 ? 0.0 : a > 1.0 ? 1.0 : a);
}
static inline double mix(double a, double b, double k)
{
return a + ( ( b - a ) * k );
}
static inline double wrap(double a, double d)
{
register double r = fmod( a, d );
return ( r < 0.0 ? d + r : ( r > 0.0 ? r : 0.0 ) );
}
static inline double h2c(double h, double m1, double m2)
{
h = wrap( h, 6.0 );
if ( h < 1.0 )
return mix( m1, m2, h );
if ( h < 3.0 )
return m2;
if ( h < 4.0 )
return mix( m1, m2, 4.0 - h );
return m1;
}
static inline void rgbToHsl(double r, double g, double b, double *h, double *s, double *l)
{
double min=MIN(MIN(r, g), b),
max=MAX(MAX(r, g), b);
*l = 0.5 * (max + min);
*s = 0.0;
*h = 0.0;
if (max != min)
{
double delta = max - min;
if ( *l <= 0.5 )
*s = delta / ( max + min );
else
*s = delta / ( 2.0 - max - min );
if ( r == max )
*h = ( g - b ) / delta;
else if ( g == max )
*h = 2.0 + ( b - r ) / delta;
else if ( b == max )
*h = 4.0 + ( r - g ) / delta;
*h /= 6.0;
if ( *h < 0.0 )
(*h) += 1.0;
}
}
static inline void hslToRgb(double h, double s, double l, double *r, double *g, double *b)
{
double m1, m2;
// TODO h2rgb( h, r, g, b );
h *= 6.0;
if ( l <= 0.5 )
m2 = l * ( 1.0 + s );
else
m2 = l + s * ( 1.0 - l );
m1 = 2.0 * l - m2;
*r = h2c( h + 2.0, m1, m2 );
*g = h2c( h, m1, m2 );
*b = h2c( h - 2.0, m1, m2 );
}
void qtcRgbToHsv(double r, double g, double b, double *h, double *s, double *v)
{
double min=MIN(MIN(r, g), b),
max=MAX(MAX(r, g), b),
delta=max - min;
*v=max;
if(max != 0)
*s=delta / max;
else
*s=0;
if (*s==0.0)
*h = 0.0;
else
{
if(r == max)
*h=(g - b) / delta; /* between yellow & magenta */
else if(g == max)
*h=2 + (b - r) / delta; /* between cyan & yellow */
else if(b == max)
*h=4 + (r - g) / delta; /* between magenta & cyan */
*h *= 60; /* degrees */
if(*h < 0)
*h += 360;
}
}
void qtcHsvToRgb(double *r, double *g, double *b, double h, double s, double v)
{
if(0==s)
*r=*g=*b=v;
else
{
int i;
double f,
p;
h /= 60; /* sector 0 to 5 */
i=(int)floor(h);
f=h - i; /* factorial part of h */
p=v * (1 - s);
switch(i)
{
case 0:
*r=v;
*g=v * (1 - s * (1 - f));
*b=p;
break;
case 1:
*r=v * (1 - s * f);
*g=v;
*b=p;
break;
case 2:
*r=p;
*g=v;
*b=v * (1 - s * (1 - f));
break;
case 3:
*r=p;
*g=v * (1 - s * f);
*b=v;
break;
case 4:
*r=v * (1 - s * (1 - f));
*g=p;
*b=v;
break;
/* case 5: */
default:
*r=v;
*g=p;
*b=v * (1 - s * f);
break;
}
}
}
#ifdef __cplusplus
static inline int qtcLimit(double c)
{
return c < 0.0 ? 0 : (c > 255.0 ? 255 : (int)c);
}
#else
static inline int qtcLimit(double c)
{
return c < 0.0
? 0
: c > 65535.0
? 65535
: (int)c;
}
#endif
#ifdef __cplusplus
void qtcShade(const Options *opts, const color &ca, color *cb, double k)
#else
void qtcShade(const Options *opts, const color *ca, color *cb, double k)
#endif
{
if(qtcEqual(k, 1.0))
{
#ifdef __cplusplus
*cb=ca;
#else
cb->red = ca->red;
cb->green = ca->green;
cb->blue = ca->blue;
#endif
}
else
switch(opts->shading)
{
case SHADING_SIMPLE:
{
#ifdef __cplusplus
int v=(int)(255.0*(k-1.0));
cb->setRgb(qtcLimit(ca.red()+v), qtcLimit(ca.green()+v), qtcLimit(ca.blue()+v));
#else
double v=65535.0*(k-1.0);
cb->red = qtcLimit(ca->red+v);
cb->green = qtcLimit(ca->green+v);
cb->blue = qtcLimit(ca->blue+v);
#endif
break;
}
case SHADING_HSL:
{
#ifdef __cplusplus
double r(ca.red()/255.0),
g(ca.green()/255.0),
b(ca.blue()/255.0);
#else
double r=ca->red/65535.0,
g=ca->green/65535.0,
b=ca->blue/65535.0;
#endif
double h, s, l;
rgbToHsl(r, g, b, &h, &s, &l);
l=normalize(l*k);
s=normalize(s*k);
hslToRgb(h, s, l, &r, &g, &b);
#ifdef __cplusplus
cb->setRgb(qtcLimit(r*255.0), qtcLimit(g*255.0), qtcLimit(b*255.0));
#else
cb->red=qtcLimit(r*65535.0);
cb->green=qtcLimit(g*65535.0);
cb->blue=qtcLimit(b*65535.0);
#endif
break;
}
case SHADING_HSV:
{
#ifdef __cplusplus
double r(ca.red()/255.0),
g(ca.green()/255.0),
b(ca.blue()/255.0);
#else
double r=ca->red/65535.0,
g=ca->green/65535.0,
b=ca->blue/65535.0;
#endif
double h, s, v;
qtcRgbToHsv(r, g, b, &h, &s, &v);
v*=k;
if (v > 1.0)
{
s -= v - 1.0;
if (s < 0)
s = 0;
v = 1.0;
}
qtcHsvToRgb(&r, &g, &b, h, s, v);
#ifdef __cplusplus
cb->setRgb(qtcLimit(r*255.0), qtcLimit(g*255.0), qtcLimit(b*255.0));
#else
cb->red=qtcLimit(r*65535.0);
cb->green=qtcLimit(g*65535.0);
cb->blue=qtcLimit(b*65535.0);
#endif
break;
}
case SHADING_HCY:
{
#define HCY_FACTOR 0.15
#if defined QT_VERSION && (QT_VERSION >= 0x040000) && !defined QTC_QT_ONLY
if(k>1.0)
*cb=KColorUtils::lighten(ca, (k*(1+HCY_FACTOR))-1.0, 1.0);
else
*cb=KColorUtils::darken(ca, 1.0-(k*(1-HCY_FACTOR)), 1.0);
#elif defined __cplusplus
if(k>1.0)
*cb=ColorUtils_lighten(&ca, (k*(1+HCY_FACTOR))-1.0, 1.0);
else
*cb=ColorUtils_darken(&ca, 1.0-(k*(1-HCY_FACTOR)), 1.0);
#else
if(k>1.0)
*cb=ColorUtils_lighten(ca, (k*(1+HCY_FACTOR))-1.0, 1.0);
else
*cb=ColorUtils_darken(ca, 1.0-(k*(1-HCY_FACTOR)), 1.0);
#endif
}
}
#if defined __cplusplus && defined QT_VERSION && (QT_VERSION >= 0x040000)
cb->setAlpha(ca.alpha());
#endif
#ifndef __cplusplus
cb->pixel = ca->pixel;
#endif
}
static unsigned char checkBounds(int num)
{
return num < 0 ? 0 :
num > 255 ? 255 :
num;
}
void qtcAdjustPix(unsigned char *data, int numChannels, int w, int h, int stride, int ro, int go, int bo, double shade)
{
int width=w*numChannels,
offset=0,
row,
r=(int)((ro*shade)+0.5),
g=(int)((go*shade)+0.5),
b=(int)((bo*shade)+0.5);
for(row=0; row<h; ++row)
{
int column;
for(column=0; column<width; column+=numChannels)
{
unsigned char source=data[offset+column+1];
#if defined __cplusplus
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
/* ARGB */
data[offset+column+1] = checkBounds(r-source);
data[offset+column+2] = checkBounds(g-source);
data[offset+column+3] = checkBounds(b-source);
#else
/* BGRA */
data[offset+column] = checkBounds(b-source);
data[offset+column+1] = checkBounds(g-source);
data[offset+column+2] = checkBounds(r-source);
#endif
#else
/* GdkPixbuf is RGBA */
data[offset+column] = checkBounds(r-source);
data[offset+column+1] = checkBounds(g-source);
data[offset+column+2] = checkBounds(b-source);
#endif
}
offset+=stride;
}
}
void qtcSetupGradient(Gradient *grad, EGradientBorder border, int numStops, ...)
{
va_list ap;
int i;
grad->border=border;
#ifndef __cplusplus
grad->numStops=numStops;
grad->stops=malloc(sizeof(GradientStop) * numStops);
#endif
va_start(ap, numStops);
for(i=0; i<numStops; ++i)
{
double pos=va_arg(ap, double),
val=va_arg(ap, double);
#ifdef __cplusplus
grad->stops.insert(GradientStop(pos, val));
#else
grad->stops[i].pos=pos;
grad->stops[i].val=val;
grad->stops[i].alpha=1.0;
#endif
}
va_end(ap);
}
const Gradient * qtcGetGradient(EAppearance app, const Options *opts)
{
if(IS_CUSTOM(app))
{
#ifdef __cplusplus
GradientCont::const_iterator grad(opts->customGradient.find(app));
if(grad!=opts->customGradient.end())
return &((*grad).second);
#else
Gradient *grad=opts->customGradient[app-APPEARANCE_CUSTOM1];
if(grad)
return grad;
#endif
app=APPEARANCE_RAISED;
}
{
static Gradient stdGradients[NUM_STD_APP];
static bool init=false;
if(!init)
{
qtcSetupGradient(&stdGradients[APPEARANCE_FLAT-APPEARANCE_FLAT], GB_3D,2,0.0,1.0,1.0,1.0);
qtcSetupGradient(&stdGradients[APPEARANCE_RAISED-APPEARANCE_FLAT], GB_3D_FULL,2,0.0,1.0,1.0,1.0);
qtcSetupGradient(&stdGradients[APPEARANCE_DULL_GLASS-APPEARANCE_FLAT], GB_LIGHT,4,0.0,1.05,0.499,0.984,0.5,0.928,1.0,1.0);
qtcSetupGradient(&stdGradients[APPEARANCE_SHINY_GLASS-APPEARANCE_FLAT], GB_LIGHT,4,0.0,1.2,0.499,0.984,0.5,0.9,1.0,1.06);
qtcSetupGradient(&stdGradients[APPEARANCE_AGUA-APPEARANCE_FLAT], GB_SHINE, 2,0.0,0.6,1.0,1.1);
qtcSetupGradient(&stdGradients[APPEARANCE_SOFT_GRADIENT-APPEARANCE_FLAT], GB_3D,2,0.0,1.04,1.0,0.98);
qtcSetupGradient(&stdGradients[APPEARANCE_GRADIENT-APPEARANCE_FLAT], GB_3D,2,0.0,1.1,1.0,0.94);
qtcSetupGradient(&stdGradients[APPEARANCE_HARSH_GRADIENT-APPEARANCE_FLAT], GB_3D,2,0.0,1.3,1.0,0.925);
qtcSetupGradient(&stdGradients[APPEARANCE_INVERTED-APPEARANCE_FLAT], GB_3D,2,0.0,0.93,1.0,1.04);
qtcSetupGradient(&stdGradients[APPEARANCE_DARK_INVERTED-APPEARANCE_FLAT], GB_NONE,3,0.0,0.8,0.7,0.95,1.0,1.0);
qtcSetupGradient(&stdGradients[APPEARANCE_SPLIT_GRADIENT-APPEARANCE_FLAT], GB_3D,4,0.0,1.06,0.499,1.004,0.5,0.986,1.0,0.92);
qtcSetupGradient(&stdGradients[APPEARANCE_BEVELLED-APPEARANCE_FLAT], GB_3D,4,0.0,1.05,0.1,1.02,0.9,0.985,1.0,0.94);
qtcSetupGradient(&stdGradients[APPEARANCE_LV_BEVELLED-APPEARANCE_FLAT], GB_3D,3,0.0,1.00,0.85,1.0,1.0,0.90);
qtcSetupGradient(&stdGradients[APPEARANCE_AGUA_MOD-APPEARANCE_FLAT], GB_NONE,3,0.0,1.5,0.49,0.85,1.0,1.3);
qtcSetupGradient(&stdGradients[APPEARANCE_LV_AGUA-APPEARANCE_FLAT], GB_NONE,4,0.0,0.98,0.35,0.95,0.4,0.93,1.0,1.15);
init=true;
}
return &stdGradients[app-APPEARANCE_FLAT];
}
return 0L; /* Will never happen! */
}
#ifdef __cplusplus
EAppearance qtcWidgetApp(EWidget w, const Options *opts, bool active)
#else
EAppearance qtcWidgetApp(EWidget w, const Options *opts)
#endif
{
switch(w)
{
case WIDGET_SB_BGND:
return opts->sbarBgndAppearance;
case WIDGET_LISTVIEW_HEADER:
return opts->lvAppearance;
case WIDGET_SB_BUTTON:
case WIDGET_SLIDER:
case WIDGET_SB_SLIDER:
return opts->sliderAppearance;
case WIDGET_FILLED_SLIDER_TROUGH:
return opts->sliderFill;
case WIDGET_TAB_TOP:
case WIDGET_TAB_BOT:
return opts->tabAppearance;
case WIDGET_MENU_ITEM:
return opts->menuitemAppearance;
case WIDGET_PROGRESSBAR:
#ifndef __cplusplus
case WIDGET_ENTRY_PROGRESSBAR:
#endif
return opts->progressAppearance;
case WIDGET_PBAR_TROUGH:
return opts->progressGrooveAppearance;
case WIDGET_SELECTION:
return opts->selectionAppearance;
#ifdef __cplusplus
case WIDGET_DOCK_WIDGET_TITLE:
return opts->dwtAppearance;
case WIDGET_MDI_WINDOW:
case WIDGET_MDI_WINDOW_TITLE:
return active ? opts->titlebarAppearance : opts->inactiveTitlebarAppearance;
case WIDGET_MDI_WINDOW_BUTTON:
return opts->titlebarButtonAppearance;
case WIDGET_DIAL:
return IS_FLAT(opts->appearance) ? APPEARANCE_RAISED : APPEARANCE_SOFT_GRADIENT;
#endif
case WIDGET_TROUGH:
case WIDGET_SLIDER_TROUGH:
return opts->grooveAppearance;
#ifndef __cplusplus
case WIDGET_SPIN_UP:
case WIDGET_SPIN_DOWN:
#endif
case WIDGET_SPIN:
return MODIFY_AGUA(opts->appearance);
case WIDGET_TOOLBAR_BUTTON:
return APPEARANCE_NONE==opts->tbarBtnAppearance ? opts->appearance : opts->tbarBtnAppearance;
default:
break;
}
return opts->appearance;
};
#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000))
#define CAN_EXTRA_ROUND(MOD) \
(IS_EXTRA_ROUND_WIDGET(widget) && \
(IS_SLIDER(widget) || WIDGET_TROUGH==widget || \
( ( (w>(MIN_ROUND_EXTRA_SIZE(widget)+MOD)) || (WIDGET_NO_ETCH_BTN==widget || WIDGET_MENU_BUTTON==widget) ) &&\
(h>(MIN_ROUND_EXTRA_SIZE(widget)+MOD)))))
#define CAN_FULL_ROUND(MOD) (w>(MIN_ROUND_FULL_SIZE+MOD) && h>(MIN_ROUND_FULL_SIZE+MOD))
// **NOTE** MUST KEEP IN SYNC WITH getRadius/RADIUS_ETCH !!!
ERound qtcGetWidgetRound(const Options *opts, int w, int h, EWidget widget)
{
ERound r=opts->round;
if( ((WIDGET_PBAR_TROUGH==widget || WIDGET_PROGRESSBAR==widget) && (opts->square&SQUARE_PROGRESS)) ||
(WIDGET_ENTRY==widget && (opts->square&SQUARE_ENTRY)) ||
(WIDGET_SCROLLVIEW==widget && (opts->square&SQUARE_SCROLLVIEW)) )
return ROUND_NONE;
if((WIDGET_CHECKBOX==widget || WIDGET_FOCUS==widget) && ROUND_NONE!=r)
r=ROUND_SLIGHT;
#if defined __cplusplus && (defined QT_VERSION && (QT_VERSION >= 0x040000))
if((WIDGET_MDI_WINDOW_BUTTON==widget && (opts->titlebarButtons&TITLEBAR_BUTTON_ROUND)) ||
WIDGET_RADIO_BUTTON==widget || WIDGET_DIAL==widget)
return ROUND_MAX;
#endif
#ifndef __cplusplus
if(WIDGET_RADIO_BUTTON==widget)
return ROUND_MAX;
#endif
#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000))
if(WIDGET_SLIDER==widget &&
(SLIDER_ROUND==opts->sliderStyle || SLIDER_ROUND_ROTATED==opts->sliderStyle || SLIDER_CIRCULAR==opts->sliderStyle))
return ROUND_MAX;
#endif
switch(r)
{
case ROUND_MAX:
if(IS_SLIDER(widget) || WIDGET_TROUGH==widget ||
(w>(MIN_ROUND_MAX_WIDTH+2) && h>(MIN_ROUND_MAX_HEIGHT+2) && IS_MAX_ROUND_WIDGET(widget)))
return ROUND_MAX;
case ROUND_EXTRA:
if(CAN_EXTRA_ROUND(2))
return ROUND_EXTRA;
case ROUND_FULL:
if(CAN_FULL_ROUND(2))
return ROUND_FULL;
case ROUND_SLIGHT:
return ROUND_SLIGHT;
case ROUND_NONE:
return ROUND_NONE;
}
return ROUND_NONE;
}
double qtcGetRadius(const Options *opts, int w, int h, EWidget widget, ERadius rad)
{
ERound r=opts->round;
if((WIDGET_CHECKBOX==widget || WIDGET_FOCUS==widget) && ROUND_NONE!=r)
r=ROUND_SLIGHT;
if( ((WIDGET_PBAR_TROUGH==widget || WIDGET_PROGRESSBAR==widget) && (opts->square&SQUARE_PROGRESS)) ||
(WIDGET_ENTRY==widget && (opts->square&SQUARE_ENTRY)) ||
(WIDGET_SCROLLVIEW==widget && (opts->square&SQUARE_SCROLLVIEW)) )
return 0.0;
#if defined __cplusplus && (defined QT_VERSION && (QT_VERSION >= 0x040000))
if((WIDGET_MDI_WINDOW_BUTTON==widget && (opts->titlebarButtons&TITLEBAR_BUTTON_ROUND)) ||
WIDGET_RADIO_BUTTON==widget || WIDGET_DIAL==widget)
return (w>h ? h : w)/2.0;
#endif
#ifndef __cplusplus
if(WIDGET_RADIO_BUTTON==widget)
return (w>h ? h : w)/2.0;
#endif
#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000))
if(WIDGET_SLIDER==widget &&
(SLIDER_ROUND==opts->sliderStyle || SLIDER_ROUND_ROTATED==opts->sliderStyle || SLIDER_CIRCULAR==opts->sliderStyle))
return (w>h ? h : w)/2.0;
#endif
if(RADIUS_EXTERNAL==rad && !opts->fillProgress && (WIDGET_PROGRESSBAR==widget
#ifndef __cplusplus
|| WIDGET_ENTRY_PROGRESSBAR==widget
#endif
))
rad=RADIUS_INTERNAL;
switch(rad)
{
case RADIUS_SELECTION:
switch(r)
{
case ROUND_MAX:
case ROUND_EXTRA:
if(/* (WIDGET_RUBBER_BAND==widget && w>14 && h>14) || */(w>48 && h>48))
return 6.0;
case ROUND_FULL:
// if( /*(WIDGET_RUBBER_BAND==widget && w>11 && h>11) || */(w>48 && h>48))
// return 3.0;
if(w>MIN_ROUND_FULL_SIZE && h>MIN_ROUND_FULL_SIZE)
return 3.0;
case ROUND_SLIGHT:
return 2.0;
case ROUND_NONE:
return 0;
}
case RADIUS_INTERNAL:
switch(r)
{
case ROUND_MAX:
if(IS_SLIDER(widget) || WIDGET_TROUGH==widget)
{
double r=((w>h ? h : w)-(WIDGET_SLIDER==widget ? 1 : 0))/2.0;
return r>MAX_RADIUS_INTERNAL ? MAX_RADIUS_INTERNAL : r;
}
if(w>(MIN_ROUND_MAX_WIDTH-2) && h>(MIN_ROUND_MAX_HEIGHT-2) && IS_MAX_ROUND_WIDGET(widget))
{
double r=((w>h ? h : w)-2.0)/2.0;
return r>9.5 ? 9.5 : r;
}
case ROUND_EXTRA:
if(CAN_EXTRA_ROUND(-2))
return EXTRA_INNER_RADIUS;
case ROUND_FULL:
if(CAN_FULL_ROUND(-2))
return FULL_INNER_RADIUS;
case ROUND_SLIGHT:
return SLIGHT_INNER_RADIUS;
case ROUND_NONE:
return 0;
}
case RADIUS_EXTERNAL:
switch(r)
{
case ROUND_MAX:
if(IS_SLIDER(widget) || WIDGET_TROUGH==widget)
{
double r=((w>h ? h : w)-(WIDGET_SLIDER==widget ? 1 : 0))/2.0;
return r>MAX_RADIUS_EXTERNAL ? MAX_RADIUS_EXTERNAL : r;
}
if(w>MIN_ROUND_MAX_WIDTH && h>MIN_ROUND_MAX_HEIGHT && IS_MAX_ROUND_WIDGET(widget))
{
double r=((w>h ? h : w)-2.0)/2.0;
return r>10.5 ? 10.5 : r;
}
case ROUND_EXTRA:
if(CAN_EXTRA_ROUND(0))
return EXTRA_OUTER_RADIUS;
case ROUND_FULL:
if(CAN_FULL_ROUND(0))
return FULL_OUTER_RADIUS;
case ROUND_SLIGHT:
return SLIGHT_OUTER_RADIUS;
case ROUND_NONE:
return 0;
}
case RADIUS_ETCH:
// **NOTE** MUST KEEP IN SYNC WITH getWidgetRound !!!
switch(r)
{
case ROUND_MAX:
if(IS_SLIDER(widget) || WIDGET_TROUGH==widget)
{
double r=((w>h ? h : w)-(WIDGET_SLIDER==widget ? 1 : 0))/2.0;
return r>MAX_RADIUS_EXTERNAL ? MAX_RADIUS_EXTERNAL : r;
}
if(w>(MIN_ROUND_MAX_WIDTH+2) && h>(MIN_ROUND_MAX_HEIGHT+2) && IS_MAX_ROUND_WIDGET(widget))
{
double r=((w>h ? h : w)-2.0)/2.0;
return r>11.5 ? 11.5 : r;
}
case ROUND_EXTRA:
if(CAN_FULL_ROUND(2))
return EXTRA_ETCH_RADIUS;
case ROUND_FULL:
if(w>(MIN_ROUND_FULL_SIZE+2) && h>(MIN_ROUND_FULL_SIZE+2))
return FULL_ETCH_RADIUS;
case ROUND_SLIGHT:
return SLIGHT_ETCH_RADIUS;
case ROUND_NONE:
return 0;
}
}
return 0;
}
double qtcRingAlpha[3]={0.125, 0.125, 0.5};
void qtcCalcRingAlphas(const color *bgnd)
{
#ifdef __cplusplus
double r=bgnd->red()/255.0,
g=bgnd->green()/255.0,
b=bgnd->blue()/255.0,
#else
double r=bgnd->red/65535.0,
g=bgnd->green/65535.0,
b=bgnd->blue/65535.0,
#endif
h=0,
s=0,
v=0;
qtcRgbToHsv(r, g, b, &h, &s, &v);
qtcRingAlpha[0]=v*0.26;
qtcRingAlpha[1]=v*0.14;
qtcRingAlpha[2]=v*0.55;
}
double qtcShineAlpha(const color *bgnd)
{
#ifdef __cplusplus
double r=bgnd->red()/255.0,
g=bgnd->green()/255.0,
b=bgnd->blue()/255.0,
#else
double r=bgnd->red/65535.0,
g=bgnd->green/65535.0,
b=bgnd->blue/65535.0,
#endif
h=0,
s=0,
v=0;
qtcRgbToHsv(r, g, b, &h, &s, &v);
return v*0.8;
}
#endif // !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000))

1383
src/qtcurve/common/common.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
#ifndef QTC_CONFIG_FILE_H
#define QTC_CONFIG_FILE_H
#include "common.h"
#define MAX_CONFIG_FILENAME_LEN 1024
#define MAX_CONFIG_INPUT_LINE_LEN 256
#if !defined QT_VERSION || QT_VERSION >= 0x040000
#define QTC_MENU_FILE_PREFIX "menubar-"
#define QTC_STATUS_FILE_PREFIX "statusbar-"
#define qtcMenuBarHidden(A) qtcBarHidden((A), QTC_MENU_FILE_PREFIX)
#define qtcSetMenuBarHidden(A, H) qtcSetBarHidden((A), (H), QTC_MENU_FILE_PREFIX)
#define qtcStatusBarHidden(A) qtcBarHidden((A), QTC_STATUS_FILE_PREFIX)
#define qtcSetStatusBarHidden(A, H) qtcSetBarHidden((A), (H), QTC_STATUS_FILE_PREFIX)
#ifdef __cplusplus
extern bool qtcBarHidden(const QString &app, const char *prefix);
extern void qtcSetBarHidden(const QString &app, bool hidden, const char *prefix);
#else // __cplusplus
extern gboolean qtcBarHidden(const char *app, const char *prefix);
extern void qtcSetBarHidden(const char *app, bool hidden, const char *prefix);
#endif // __cplusplus
extern void qtcLoadBgndImage(QtCImage *img);
#endif // !defined QT_VERSION || QT_VERSION >= 0x040000)
extern const char * qtcGetHome();
extern const char *qtcConfDir();
extern void qtcSetRgb(color *col, const char *str);
extern void qtcDefaultSettings(Options *opts);
extern void qtcCheckConfig(Options *opts);
#ifdef __cplusplus
extern bool qtcReadConfig(const QString &file, Options *opts, Options *defOpts=0L, bool checkImages=true);
extern WindowBorders qtcGetWindowBorderSize(bool force=false);
#else
extern bool qtcReadConfig(const char *file, Options *opts, Options *defOpts);
extern WindowBorders qtcGetWindowBorderSize(gboolean force);
#endif
#ifdef CONFIG_WRITE
class KConfig;
extern bool qtcWriteConfig(KConfig *cfg, const Options &opts, const Options &def, bool exportingStyle=false);
#endif
#endif

BIN
src/qtcurve/common/dot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

12
src/qtcurve/config.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
/* #define VERSION "1.5.3" */
#define KDE3PREFIX "/usr"
#define KDE4PREFIX "/usr"
#define QTC_QT_ONLY
/* #undef QTC_OLD_NVIDIA_ARROW_FIX */
#undef QTC_STYLE_SUPPORT
/* #undef QTC_KWIN_MAX_BUTTON_HACK */

View File

@ -0,0 +1,227 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenblurhelper.cpp
// handle regions passed to kwin for blurring
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
//
// Loosely inspired (and largely rewritten) from BeSpin style
// Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "blurhelper.h"
#include <QtCore/QEvent>
#include <QtCore/QVector>
#include <QtGui/QDockWidget>
#include <QtGui/QMenu>
#include <QtGui/QProgressBar>
#include <QtGui/QPushButton>
#include <QtGui/QToolBar>
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "fixx11h.h"
#include <QX11Info>
#endif
namespace QtCurve
{
//___________________________________________________________
BlurHelper::BlurHelper( QObject* parent ):
QObject( parent ),
_enabled( false )
{
#ifdef Q_WS_X11
// create atom
_atom = XInternAtom( QX11Info::display(), "_KDE_NET_WM_BLUR_BEHIND_REGION", False);
#endif
}
//___________________________________________________________
void BlurHelper::registerWidget( QWidget* widget )
{ Utils::addEventFilter(widget, this); }
//___________________________________________________________
void BlurHelper::unregisterWidget( QWidget* widget )
{
widget->removeEventFilter( this );
if( isTransparent( widget ) ) clear( widget );
}
//___________________________________________________________
bool BlurHelper::eventFilter( QObject* object, QEvent* event )
{
// do nothing if not enabled
if( !enabled() ) return false;
switch( event->type() )
{
case QEvent::Hide:
{
QWidget* widget( qobject_cast<QWidget*>( object ) );
if( widget && isOpaque( widget ) )
{
QWidget* window( widget->window() );
if (window && isTransparent(window) && !_pendingWidgets.contains(window) )
{
_pendingWidgets.insert( window, window );
delayedUpdate();
}
}
break;
}
case QEvent::Show:
case QEvent::Resize:
{
// cast to widget and check
QWidget* widget( qobject_cast<QWidget*>( object ) );
if( !widget ) break;
if( isTransparent( widget ) )
{
_pendingWidgets.insert( widget, widget );
delayedUpdate();
} else if( isOpaque( widget ) ) {
QWidget* window( widget->window() );
if( isTransparent( window ) )
{
_pendingWidgets.insert( window, window );
delayedUpdate();
}
}
break;
}
default: break;
}
// never eat events
return false;
}
//___________________________________________________________
QRegion BlurHelper::blurRegion( QWidget* widget ) const
{
if( !widget->isVisible() ) return QRegion();
// get main region
QRegion region = widget->mask().isEmpty() ? widget->rect():widget->mask();
// trim blur region to remove unnecessary areas
trimBlurRegion( widget, widget, region );
return region;
}
//___________________________________________________________
void BlurHelper::trimBlurRegion( QWidget* parent, QWidget* widget, QRegion& region ) const
{
// loop over children
foreach( QObject* childObject, widget->children() )
{
QWidget* child( qobject_cast<QWidget*>( childObject ) );
if( !(child && child->isVisible()) ) continue;
if( isOpaque( child ) )
{
const QPoint offset( child->mapTo( parent, QPoint( 0, 0 ) ) );
if( child->mask().isEmpty() ) region -= child->rect().translated( offset );
else region -= child->mask().translated( offset );
} else { trimBlurRegion( parent, child, region ); }
}
return;
}
//___________________________________________________________
void BlurHelper::update( QWidget* widget ) const
{
#ifdef Q_WS_X11
/*
directly from bespin code. Supposibly prevent playing with some 'pseudo-widgets'
that have winId matching some other -random- window
*/
if( !(widget->testAttribute(Qt::WA_WState_Created) || widget->internalWinId() ))
{ return; }
const QRegion region( blurRegion( widget ) );
if( region.isEmpty() ) {
clear( widget );
} else {
QVector<unsigned long> data;
foreach( const QRect& rect, region.rects() )
{ data << rect.x() << rect.y() << rect.width() << rect.height(); }
XChangeProperty(
QX11Info::display(), widget->winId(), _atom, XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<const unsigned char *>(data.constData()), data.size() );
}
// force update
if( widget->isVisible() )
{ widget->update(); }
#endif
}
//___________________________________________________________
void BlurHelper::clear( QWidget* widget ) const
{
#ifdef Q_WS_X11
XChangeProperty( QX11Info::display(), widget->winId(), _atom, XA_CARDINAL, 32, PropModeReplace, 0, 0 );
#endif
}
}

View File

@ -0,0 +1,188 @@
#ifndef blurhelper_h
#define blurhelper_h
//////////////////////////////////////////////////////////////////////////////
// oxygenblurhelper.h
// handle regions passed to kwin for blurring
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
//
// Loosely inspired (and largely rewritten) from BeSpin style
// Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "utils.h"
#include <QtCore/QObject>
#include <QtCore/QPointer>
#include <QtCore/QHash>
#include <QtCore/QBasicTimer>
#include <QtCore/QTimerEvent>
#include <QtGui/QDockWidget>
#include <QtGui/QMenu>
#include <QtGui/QRegion>
#include <QtGui/QToolBar>
//
#ifdef Q_WS_X11
#include <X11/Xdefs.h>
#endif
namespace QtCurve
{
class BlurHelper: public QObject
{
Q_OBJECT
public:
//! constructor
BlurHelper( QObject* );
//! destructor
virtual ~BlurHelper( void )
{}
//! enable state
void setEnabled( bool value )
{ _enabled = value; }
//! enabled
bool enabled( void ) const
{ return _enabled; }
//! register widget
void registerWidget( QWidget* );
//! register widget
void unregisterWidget( QWidget* );
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
protected:
//! timer event
/*! used to perform delayed blur region update of pending widgets */
virtual void timerEvent( QTimerEvent* event )
{
if( event->timerId() == _timer.timerId() )
{
_timer.stop();
update();
} else QObject::timerEvent( event );
}
//! get list of blur-behind regions matching a given widget
QRegion blurRegion( QWidget* ) const;
//! trim blur region to remove unnecessary areas (recursive)
void trimBlurRegion( QWidget*, QWidget*, QRegion& ) const;
//! update blur region for all pending widgets
/*! a timer is used to allow some buffering of the update requests */
void delayedUpdate( void )
{
if( !_timer.isActive() )
{ _timer.start( 10, this ); }
}
//! update blur region for all pending widgets
void update( void )
{
foreach( const WidgetPointer& widget, _pendingWidgets )
{ if( widget ) update( widget.data() ); }
_pendingWidgets.clear();
}
//! update blur regions for given widget
void update( QWidget* ) const;
//! clear blur regions for given widget
void clear( QWidget* ) const;
//! returns true if a given widget is opaque
bool isOpaque( const QWidget* widget ) const
{
return
(!widget->isWindow()) &&
( (widget->autoFillBackground() && widget->palette().color( widget->backgroundRole() ).alpha() == 0xff ) ||
widget->testAttribute(Qt::WA_OpaquePaintEvent) );
}
//! true if widget is a transparent window
/*! some additional checks are performed to make sure stuff like plasma tooltips
don't get their blur region overwritten */
inline bool isTransparent( const QWidget* widget ) const;
private:
//! enability
bool _enabled;
//! list of widgets for which blur region must be updated
typedef QPointer<QWidget> WidgetPointer;
typedef QHash<QWidget*, WidgetPointer> WidgetSet;
WidgetSet _pendingWidgets;
//! delayed update timer
QBasicTimer _timer;
#ifdef Q_WS_X11
//! blur atom
Atom _atom;
#endif
};
bool BlurHelper::isTransparent( const QWidget* widget ) const
{
return
widget->isWindow() &&
widget->testAttribute( Qt::WA_TranslucentBackground ) &&
// widgets using qgraphicsview
!( widget->graphicsProxyWidget() ||
widget->inherits( "Plasma::Dialog" ) ) &&
// flags and special widgets
( widget->testAttribute( Qt::WA_StyledBackground ) ||
qobject_cast<const QMenu*>( widget ) ||
qobject_cast<const QDockWidget*>( widget ) ||
qobject_cast<const QToolBar*>( widget ) ||
// konsole (thought that should be handled
// internally by the application
widget->inherits( "Konsole::MainWindow" ) ) &&
Utils::hasAlphaChannel( widget );
}
}
#endif

View File

@ -0,0 +1,343 @@
#ifndef __DIALOG_PIXMAPS_H__
#define __DIALOG_PIXMAPS_H__
// Oxygen icons - created with Qt3's qembed...
static const unsigned int dialog_error_png_len = 1527;
static const unsigned char dialog_error_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x08,0x06,0x00,0x00,
0x00,0x73,0x7a,0x7a,0xf4,0x00,0x00,0x00,0x04,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0x08,0x7c,0x08,0x64,0x88,0x00,0x00,0x00,0x09,0x70,0x48,0x59,
0x73,0x00,0x00,0x03,0x76,0x00,0x00,0x03,0x76,0x01,0x7d,0xd5,0x82,0xcc,
0x00,0x00,0x00,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66,0x74,0x77,0x61,
0x72,0x65,0x00,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,
0x65,0x2e,0x6f,0x72,0x67,0x9b,0xee,0x3c,0x1a,0x00,0x00,0x05,0x74,0x49,
0x44,0x41,0x54,0x78,0xda,0xed,0x57,0x4d,0x68,0x54,0x57,0x14,0xfe,0xee,
0x7b,0x93,0x99,0x24,0xa6,0x69,0x13,0x53,0x7f,0xea,0xa4,0x93,0x68,0x6d,
0xab,0x16,0x44,0x4a,0x15,0x17,0xd2,0x85,0x60,0xf7,0x62,0x40,0xa4,0x8a,
0x55,0x54,0x50,0xc4,0x2a,0x8a,0x28,0x62,0x15,0x17,0x8a,0x0b,0xa1,0xdd,
0xb8,0xb0,0x5d,0xb8,0x15,0xbb,0xb1,0x1b,0x75,0x61,0xd5,0x4a,0x4d,0x2b,
0x58,0x0b,0x41,0x29,0xa2,0x26,0xc6,0x9f,0x54,0x13,0x33,0x4e,0x26,0x99,
0x99,0xf7,0xe6,0xdd,0xdb,0xef,0xcc,0x7d,0xc9,0x8b,0x99,0x98,0xa9,0xb4,
0xc5,0x4d,0x2f,0x7c,0x9c,0x7b,0xef,0x7b,0xe7,0x9c,0xef,0x9d,0x7b,0xce,
0x79,0xef,0x29,0x63,0x0c,0x5e,0xe7,0x70,0xf0,0x9a,0x47,0x6c,0xbc,0xcd,
0x83,0x4a,0xb9,0x8d,0x21,0xb9,0x37,0x00,0x85,0x7f,0x38,0x06,0x00,0xf3,
0x0c,0xd0,0x5f,0x19,0x13,0x60,0xcc,0x78,0xe1,0x08,0x7e,0xda,0xb5,0xab,
0x6d,0x52,0x2a,0xf5,0x4d,0x2e,0x9d,0x9e,0xc2,0x7d,0xe5,0x56,0x55,0xc1,
0x11,0xc4,0x62,0x8a,0xc0,0xf0,0x5a,0xb9,0x2e,0x64,0xed,0x50,0x42,0x29,
0x80,0x36,0x74,0x10,0x40,0x17,0x8b,0x30,0x22,0x7d,0x1f,0x01,0xc1,0xb5,
0xc0,0xc8,0xba,0x98,0xcf,0x1b,0xaf,0xaf,0xaf,0xab,0x98,0xc9,0x6c,0xfb,
0xec,0xe4,0xc9,0x1f,0xc6,0x8d,0x40,0x4d,0x32,0xf9,0xf5,0xe4,0xd6,0xd6,
0x69,0x0d,0x0d,0x0d,0x70,0x69,0xe8,0x5f,0x1a,0x8a,0x40,0xe0,0xba,0xea,
0xcf,0xfb,0xf7,0x5b,0x0b,0x9e,0xf7,0x1d,0x80,0x29,0x65,0x04,0x24,0xec,
0x1f,0x6f,0xd8,0x30,0xa5,0x65,0xce,0x1c,0xe4,0x3b,0x3a,0xf0,0x5f,0x8c,
0x86,0x96,0x16,0xfc,0x7e,0xe1,0x42,0xe3,0xf7,0xf4,0x15,0x1e,0x47,0x44,
0x40,0xce,0xfc,0xc9,0xad,0x5b,0x2a,0x18,0x18,0x80,0x5f,0x28,0xfc,0xcd,
0x47,0x8b,0x86,0x41,0xe5,0x51,0x45,0xdb,0xdd,0xed,0xed,0x2a,0xcc,0xaf,
0xa0,0xec,0x08,0xfa,0xee,0xde,0x85,0x9f,0xcb,0xa1,0x40,0x44,0x4e,0x88,
0x68,0x5e,0x4e,0xe2,0x25,0xce,0x4d,0x24,0xa3,0xeb,0xb4,0xdb,0x7b,0xe7,
0x0e,0x12,0xe5,0x55,0x60,0xb3,0xbd,0xe7,0xd1,0x23,0x78,0xbc,0xc9,0xcf,
0xe7,0xa1,0xc6,0x3a,0x57,0x9c,0x55,0x20,0x13,0x68,0x6d,0xef,0x23,0x64,
0xd8,0x04,0x8f,0x48,0x28,0xda,0xed,0x7f,0xf0,0x00,0xb3,0x39,0x1d,0xb7,
0x0f,0x68,0xc2,0x1f,0x1a,0x92,0x8c,0xb5,0xe0,0x51,0x08,0x02,0xc2,0x9d,
0x3c,0x19,0x33,0x77,0xef,0x86,0xc3,0x73,0x94,0x7b,0x02,0x5e,0x1f,0x8d,
0x5c,0x26,0x83,0xb7,0xdb,0xda,0xd0,0xbc,0x65,0x0b,0xbc,0xe1,0x7d,0xab,
0x6f,0x21,0x6b,0xea,0xe9,0x89,0x1a,0x51,0x20,0x18,0x1c,0x14,0x45,0x0b,
0x2a,0x69,0x22,0x46,0xe7,0x2d,0x9b,0x36,0xc1,0x89,0xc7,0xd1,0xfa,0xf9,
0xe7,0x40,0x2a,0x55,0x22,0xa1,0x79,0x8f,0x20,0x9b,0x4e,0x63,0xea,0xaa,
0x55,0x78,0x6b,0xee,0x5c,0x24,0x84,0xe8,0xf6,0xed,0xf0,0x45,0x57,0x10,
0x91,0xb1,0x72,0x22,0x02,0x86,0x08,0x72,0x43,0x44,0x0e,0x9a,0x10,0xe5,
0xaa,0xc6,0x46,0xcc,0xda,0xb6,0x4d,0x6a,0x7f,0xf8,0x2c,0xf0,0x01,0xc9,
0x78,0xc9,0x24,0xfc,0x6c,0x16,0xd9,0xbe,0x3e,0x4c,0x5f,0xb3,0x06,0x4d,
0x0b,0x16,0x60,0x78,0x54,0x37,0x35,0x61,0x16,0xa3,0xe5,0x91,0x64,0x48,
0xc2,0xda,0xa3,0x6d,0x53,0x29,0x02,0xc5,0x6c,0xd6,0x2a,0x90,0xb1,0xa1,
0x1c,0x62,0x5e,0x14,0x69,0xc8,0x8e,0x28,0x1f,0xe6,0xef,0xd8,0x81,0xa1,
0xe6,0x66,0x4c,0x5d,0xb7,0x0e,0xd3,0x16,0x2d,0xc2,0xd8,0x31,0xd8,0xdd,
0x3d,0xf2,0x10,0x26,0xb4,0x27,0xeb,0xa0,0xe2,0x11,0x0c,0x0d,0x8e,0x84,
0xd6,0x10,0x78,0xfe,0x1c,0xd7,0xb7,0x6e,0x85,0x97,0xc9,0x94,0x91,0xf8,
0x64,0xef,0x5e,0x24,0x97,0x2c,0x29,0x73,0xfe,0xf8,0xea,0x55,0xdc,0x3b,
0x72,0x04,0x71,0xe9,0x8c,0xa1,0x1d,0x2d,0xc8,0x57,0x20,0xa0,0xc3,0x1c,
0x10,0xc6,0x20,0x5b,0x43,0x28,0xce,0x27,0x31,0x2a,0xbf,0xae,0x5d,0x8b,
0x42,0x3a,0x5d,0x46,0x62,0xec,0xe8,0xbe,0x78,0x11,0x0f,0x0f,0x1d,0x42,
0xbd,0x31,0xa2,0x2b,0x28,0xd9,0x01,0x41,0x12,0x15,0x92,0x50,0x11,0xd9,
0x01,0x21,0x40,0x58,0x65,0x87,0x70,0xa9,0x3c,0xd5,0xf3,0xf0,0xcb,0xca,
0x95,0xc8,0xf5,0xf7,0xe3,0x65,0xe3,0xde,0xf9,0xf3,0x78,0x7a,0xe0,0x00,
0x9a,0x48,0xcc,0x15,0x3d,0xea,0xc4,0x13,0x09,0xa8,0x20,0x80,0xc7,0x48,
0xf6,0xdd,0xf8,0x8d,0x3e,0x26,0x78,0x1b,0x1a,0x09,0x5f,0x7b,0x3b,0xaa,
0xe3,0x35,0xa8,0xad,0xab,0x43,0x6d,0x4d,0x0d,0x62,0x84,0x5b,0x5d,0x8d,
0x38,0x93,0xb0,0x8e,0x91,0xe8,0xb9,0x76,0x0d,0xad,0xcb,0x96,0x95,0x39,
0x97,0x9a,0xef,0x3a,0x73,0x06,0x29,0xad,0xe1,0x32,0x67,0xa4,0xf4,0x3c,
0x46,0xac,0xbf,0xab,0x0b,0x39,0xee,0x15,0x78,0xdd,0x73,0x0c,0x0c,0x26,
0x20,0x10,0x08,0x06,0x32,0xf0,0x82,0x01,0xa8,0xa7,0x4f,0xc5,0x2a,0x8c,
0x52,0xa5,0xfd,0x5e,0x1a,0xd1,0xac,0xf1,0x99,0x0b,0x17,0x22,0x4d,0xc3,
0x0c,0xff,0x08,0xc4,0xb9,0x60,0xde,0xce,0x9d,0xf8,0x79,0xf9,0x72,0xbc,
0x7f,0xf3,0x26,0x14,0x00,0xcd,0x6b,0x09,0x91,0xbc,0x26,0x73,0xe3,0xa0,
0x42,0x0e,0x50,0xcb,0x55,0xaa,0xc4,0xaa,0x4a,0xc0,0x79,0x9c,0xb2,0x20,
0x1d,0x8e,0xa5,0x37,0x77,0xdf,0x3e,0x68,0xce,0x05,0x01,0xc3,0x5a,0x64,
0x92,0xf9,0xbe,0x2f,0xb2,0xb4,0x76,0xeb,0xeb,0xb1,0xf8,0xf4,0x69,0x74,
0xb2,0x1f,0x08,0x81,0x04,0x1d,0xc7,0x43,0x3b,0x62,0x2f,0x66,0x7d,0x4c,
0x40,0xc0,0x90,0xc0,0x18,0x12,0x45,0x1a,0x89,0x6d,0xdc,0x88,0xd9,0xfb,
0xf7,0x87,0xce,0x23,0xfc,0x78,0xf8,0x30,0x3a,0x2f,0x5d,0x7a,0x61,0xcf,
0x21,0x89,0x05,0xa7,0x4e,0xe1,0xf1,0xbc,0x79,0x30,0xd6,0xb1,0x75,0x2e,
0x79,0xe1,0x28,0xfa,0xa8,0x10,0x01,0xa5,0xec,0xa6,0x2b,0x90,0xb0,0xb1,
0xf5,0x26,0xf7,0xec,0x29,0x73,0x7e,0xf9,0xe0,0x41,0x4c,0x3f,0x76,0x0c,
0xd7,0xd9,0x19,0xbb,0x2e,0x5f,0x2e,0x23,0x91,0x3a,0x7a,0xb4,0x74,0xee,
0xae,0x38,0xa1,0x1d,0x87,0x73,0x8a,0x0a,0x11,0x20,0xa2,0xeb,0x76,0x5e,
0xcb,0x24,0x7a,0xb8,0x79,0x33,0x02,0xcf,0x1b,0x71,0x70,0x9d,0x99,0x3e,
0xf3,0xf8,0x71,0x2c,0xa6,0xc5,0x2f,0x98,0x6c,0xb7,0x57,0xaf,0xc6,0xa3,
0x51,0x24,0xf2,0xd4,0x79,0xb2,0x7e,0x3d,0xde,0x2c,0x7f,0x71,0x55,0x7e,
0x17,0x18,0x45,0x20,0x82,0x4b,0xd4,0x9d,0x3d,0x8b,0x87,0x4c,0x40,0x21,
0x71,0x9b,0x4f,0x9e,0x3a,0x71,0x02,0x1f,0x49,0x74,0x42,0x03,0x6d,0x24,
0xf1,0x84,0x7d,0xe2,0xd9,0x95,0x2b,0xc8,0x77,0x76,0xe2,0xf1,0x8a,0x15,
0x48,0xf6,0xf4,0x40,0x8d,0xd8,0xb1,0x09,0x29,0x1b,0xc1,0x44,0x55,0xa0,
0x15,0x61,0x89,0x10,0xf6,0xfc,0x45,0x26,0xa8,0xdc,0x78,0xee,0x1c,0x7a,
0x96,0x2e,0xc5,0x74,0x3e,0xdd,0x0c,0xae,0xf5,0x98,0xcf,0xf9,0x4f,0x49,
0xa2,0x83,0x6d,0x39,0xc7,0xf0,0xb7,0xf4,0xf6,0xa2,0x28,0x36,0xc2,0x0a,
0xf2,0xad,0x9d,0xb0,0x1a,0xca,0x08,0x44,0x5f,0xae,0xda,0x08,0x01,0xde,
0x4c,0xe9,0x53,0xd9,0x1b,0x4e,0x20,0x2a,0x56,0x53,0xbe,0xc3,0xfe,0x1e,
0xe7,0xbe,0x1f,0x96,0x95,0x43,0xa8,0xb0,0x54,0x85,0xf8,0x6c,0x36,0x1f,
0x5f,0xea,0x9f,0xeb,0x02,0x50,0xd2,0x2f,0x88,0x1d,0xde,0xe3,0x97,0x08,
0x09,0x09,0xeb,0x6b,0xfc,0x08,0x10,0x45,0x1b,0x32,0x9b,0x34,0xe2,0x04,
0x88,0x6a,0x3d,0x7c,0xaa,0xa2,0x3d,0x9a,0xe8,0x1a,0xc2,0xc8,0x85,0xa4,
0x85,0x40,0x9e,0x32,0x47,0x99,0xa3,0x5e,0x61,0x74,0x14,0x5e,0x76,0x04,
0xf2,0xdd,0x1e,0x40,0xe9,0xbc,0xd2,0x4e,0x95,0x74,0x0c,0xeb,0x54,0xa4,
0x25,0x46,0xe9,0x53,0xc6,0x87,0x4b,0xca,0x92,0x8c,0xc8,0x87,0xc4,0x04,
0x85,0x10,0x79,0xeb,0xdc,0x76,0xc1,0x92,0x0d,0x2d,0xca,0xfa,0x99,0x67,
0xf4,0xb8,0xff,0x05,0xeb,0x6a,0x63,0x37,0xe6,0x34,0xe9,0xf9,0x33,0xb2,
0x2e,0x5c,0xed,0x20,0x6e,0xa4,0x89,0x44,0x0d,0x29,0x6c,0x26,0x51,0x69,
0x8d,0xfa,0x26,0xd4,0xe1,0x19,0x0b,0x01,0x3f,0x24,0xe2,0xc9,0x3c,0xdc,
0xcb,0x29,0xca,0x64,0x80,0x8e,0x7e,0xfc,0x71,0xf4,0x41,0xf0,0xe1,0xb8,
0x47,0xd0,0x3c,0xc9,0xd9,0x11,0xab,0x37,0xdf,0x9e,0xcd,0x04,0xef,0x3e,
0xcf,0x16,0x15,0x38,0x6c,0xf2,0x46,0x25,0xa3,0x22,0x8c,0x1d,0x51,0xc6,
0x47,0x73,0xbb,0xcf,0x89,0xeb,0x2a,0xfd,0x5e,0xbf,0xba,0x33,0xa3,0xc6,
0xf9,0xb2,0xec,0xcf,0xe8,0x55,0x7f,0xcd,0xea,0xc7,0xf7,0x8f,0x0c,0x60,
0x5e,0xf5,0xd7,0xec,0xff,0xbf,0xe3,0xbf,0x00,0x0f,0x56,0x81,0xab,0xdc,
0x79,0x68,0x79,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,
0x82
};
/* Generated by qembed */
static const unsigned int dialog_information_png_len = 1636;
static const unsigned char dialog_information_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x08,0x06,0x00,0x00,
0x00,0x73,0x7a,0x7a,0xf4,0x00,0x00,0x00,0x04,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0x08,0x7c,0x08,0x64,0x88,0x00,0x00,0x00,0x09,0x70,0x48,0x59,
0x73,0x00,0x00,0x03,0x76,0x00,0x00,0x03,0x76,0x01,0x7d,0xd5,0x82,0xcc,
0x00,0x00,0x00,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66,0x74,0x77,0x61,
0x72,0x65,0x00,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,
0x65,0x2e,0x6f,0x72,0x67,0x9b,0xee,0x3c,0x1a,0x00,0x00,0x05,0xe1,0x49,
0x44,0x41,0x54,0x78,0xda,0xc5,0x57,0x5b,0x6c,0x54,0x45,0x18,0xfe,0xe6,
0xdc,0x76,0xb7,0xbb,0xdd,0x76,0xb1,0x2d,0xb4,0x05,0xa5,0x11,0xd1,0x8a,
0x82,0x48,0x49,0x04,0x1e,0x00,0xc5,0x48,0x34,0x12,0x89,0x11,0x02,0x3c,
0x60,0x8c,0x06,0xf1,0x12,0xa5,0xf2,0xe0,0x0b,0x62,0x13,0x8d,0x09,0x09,
0x98,0x28,0x31,0xe1,0x92,0x28,0x3e,0x11,0x8c,0xe2,0x2d,0x12,0x2e,0xb1,
0x34,0x62,0x23,0xa1,0x11,0x12,0x2e,0x2a,0x88,0x94,0x3b,0x94,0x16,0xe9,
0xee,0x76,0x77,0xcf,0x6d,0xc6,0x7f,0x7a,0x26,0x29,0xcb,0xee,0x76,0x0b,
0x2f,0x7e,0xc9,0xb7,0x33,0x3b,0x3b,0x73,0xbe,0xef,0xbf,0xe4,0x9c,0xb3,
0x4c,0x08,0x81,0xdb,0x00,0x23,0x6a,0x8a,0x4c,0x51,0x42,0x28,0xf2,0xa1,
0x71,0x64,0x30,0x30,0x02,0x28,0x41,0x93,0x18,0x21,0x56,0x12,0x63,0xc4,
0x0a,0xb5,0xc6,0x88,0x1e,0x31,0x4b,0x4c,0x13,0x93,0xc4,0x0c,0xd1,0x19,
0x89,0x11,0x63,0x04,0x11,0x5b,0x4a,0xb0,0x66,0xeb,0xee,0xa3,0xb3,0x4f,
0x9c,0xbb,0xbe,0x50,0xd3,0xf4,0xc9,0x95,0x15,0x56,0xbc,0x32,0x12,0x0a,
0x6b,0x1a,0x43,0xc6,0x76,0xed,0x54,0xd6,0x4d,0x09,0xc1,0x4f,0x34,0x37,
0x26,0x76,0x2e,0x9f,0xd7,0xbc,0x1f,0x40,0x8f,0x32,0x63,0x13,0x4b,0xa6,
0x79,0xb8,0x12,0x68,0x2a,0xe2,0x9a,0xd6,0x4d,0xed,0x2f,0xf5,0xa5,0x9d,
0x95,0x93,0x9a,0xea,0x6a,0xeb,0x13,0x55,0x30,0x74,0x9d,0xa8,0xc1,0x34,
0x34,0x68,0x60,0xe0,0x22,0xa8,0xc0,0x40,0xce,0x45,0x4f,0x32,0x8d,0x93,
0xe7,0xfb,0xae,0x57,0x47,0xcd,0xcd,0x1f,0xbd,0x38,0x6b,0xab,0x32,0x92,
0x21,0xfa,0x23,0x36,0xa0,0xc4,0x2b,0xd6,0x7f,0x7d,0x70,0xda,0xbe,0xc3,
0xe7,0xb7,0x4c,0xbc,0xbb,0xf6,0xbe,0xa9,0x13,0xc6,0x81,0xfb,0x0c,0x7d,
0x69,0x1b,0xa5,0x3c,0x4b,0x43,0x89,0x98,0x09,0x26,0x38,0x4e,0x5c,0xba,
0x86,0x53,0xe7,0x7a,0xcf,0x3c,0xf1,0x70,0xe3,0xab,0xaf,0x2f,0x98,0x7a,
0x50,0x95,0xc7,0x1f,0x89,0x01,0x46,0x8c,0x2c,0x69,0xfb,0xe6,0xd9,0x8b,
0xc9,0xdc,0xe6,0x39,0x8f,0x4e,0x8c,0x8f,0xab,0x4d,0xe0,0xea,0xbf,0x36,
0x6e,0x07,0x63,0x12,0x16,0xae,0xf6,0x0f,0xe0,0xd7,0x63,0xdd,0xe9,0xc6,
0x78,0xe8,0xb5,0x2d,0xef,0xcc,0xdf,0xa9,0x32,0xc1,0xcb,0x19,0x30,0xe7,
0xbc,0xf5,0xc5,0xd3,0x0e,0x8c,0xaf,0x9e,0x9b,0x3d,0xc5,0xf4,0xb9,0x41,
0x35,0xf6,0x70,0x27,0xa8,0xb0,0x0c,0x44,0xc3,0xc0,0xb7,0x9d,0x27,0xdc,
0xa8,0xc6,0x97,0xfd,0xf0,0xe1,0x0b,0xdf,0x03,0xb0,0x87,0x33,0xc0,0xa6,
0xbd,0xbc,0xb1,0xf9,0x72,0xd2,0x3b,0xb0,0x6c,0xfe,0xcc,0x84,0xa6,0x59,
0x28,0x85,0x09,0xf5,0x95,0x98,0xf7,0xc8,0x18,0x48,0xec,0x3b,0x72,0x05,
0x7f,0x5f,0x4e,0xa1,0x14,0x62,0x11,0xe0,0xcb,0xdd,0x87,0x6e,0x34,0xd5,
0x44,0xe7,0xec,0x59,0xb7,0xf4,0xe8,0xcd,0x59,0xd0,0x70,0x13,0xda,0xda,
0xda,0x18,0x75,0xf9,0xb6,0xc9,0x13,0xc7,0x27,0x98,0x66,0xc2,0xf1,0xfc,
0xa2,0xcc,0x39,0x0e,0x9e,0x9f,0x39,0x16,0x4d,0xa3,0xa3,0x92,0x72,0x2e,
0xd7,0x4a,0xee,0x1f,0xc8,0x09,0xcc,0x98,0xd4,0x54,0xdd,0x75,0xf2,0xf2,
0xe7,0x1d,0x1d,0x1d,0x4a,0xb3,0x88,0x81,0xf7,0xf7,0x64,0x97,0x54,0x56,
0x56,0xb6,0x34,0x37,0x35,0xd2,0x21,0x8f,0x0e,0xf3,0xa2,0x14,0x5c,0xa0,
0x3a,0x3a,0x94,0x1d,0x39,0xe7,0x9c,0x97,0xdc,0x9f,0xca,0x7a,0x68,0xa8,
0x1d,0x85,0x9a,0x44,0xd5,0xd4,0xa7,0x3e,0xe8,0x58,0x5a,0xd4,0x00,0x23,
0x40,0xd3,0xd6,0xce,0x6d,0x79,0x08,0xa9,0x8c,0x0f,0xdb,0x2d,0xcd,0xfe,
0x8c,0x8b,0x03,0xc7,0x2f,0x03,0x0a,0x07,0x8e,0x5d,0x42,0x92,0xd6,0x86,
0x3b,0xd3,0xdb,0xef,0xe0,0x89,0x96,0x07,0x60,0xfb,0x58,0x43,0x4a,0xac,
0xa0,0x07,0xd8,0xf4,0xd5,0x33,0x6a,0x1a,0xea,0x3a,0x9f,0x79,0x7c,0x16,
0x38,0x47,0x59,0xd8,0x94,0xf2,0xa6,0x9a,0x30,0x24,0xce,0x5c,0xcb,0x21,
0x14,0xb2,0x50,0x0e,0xf1,0x88,0x89,0x1f,0x7f,0xe9,0xc2,0xd9,0xd3,0xdd,
0xb3,0xc4,0x6f,0xeb,0x3a,0xf3,0xef,0x84,0x9a,0xbf,0x78,0x74,0x6d,0x1d,
0xd5,0xd2,0xc7,0x70,0x10,0x82,0x03,0x22,0x78,0x0c,0xfc,0x73,0xcd,0x96,
0x21,0x28,0x43,0x1e,0x98,0xc6,0x30,0x1c,0x7a,0x53,0x3e,0xee,0x1f,0xdf,
0x88,0xb3,0xdd,0xe7,0x17,0x03,0xb8,0xc5,0x00,0x63,0xb3,0xe2,0xf1,0x38,
0xa5,0xcb,0x43,0x29,0x70,0x9f,0xe3,0xbb,0x35,0xf3,0x50,0x0c,0x0b,0xda,
0xf6,0x42,0x37,0x75,0x94,0x43,0xac,0x22,0x22,0xb5,0x66,0x16,0x7b,0x16,
0xd4,0x99,0xa6,0x3e,0xd8,0xb5,0xa5,0xe0,0x7b,0x02,0xa5,0x90,0xf3,0x38,
0x4c,0xdd,0x90,0x29,0x22,0x96,0x7e,0x20,0x5a,0xda,0x60,0xe1,0xeb,0xf2,
0x9a,0x90,0x11,0xc0,0x30,0x4a,0xd3,0xc8,0x80,0xcb,0x0b,0xe9,0x11,0x7d,
0x06,0x17,0x0c,0x4f,0xbe,0xb7,0x17,0xb3,0xdf,0xdd,0x55,0xd8,0x13,0x1e,
0x06,0xf7,0x38,0x5c,0x52,0xcd,0xbd,0xbc,0xeb,0x90,0x38,0xc9,0x31,0x00,
0x02,0x77,0x31,0xc2,0xad,0x19,0x60,0x39,0x47,0xc0,0x12,0x3e,0xf2,0x30,
0x78,0x48,0x12,0x44,0x5d,0x7e,0x27,0x01,0xbf,0xd0,0x00,0x17,0x00,0x89,
0x13,0x82,0x51,0x08,0x44,0x2d,0x13,0x61,0x13,0xb8,0x91,0xce,0x12,0x6d,
0x74,0x5d,0x4d,0xe1,0xc6,0x80,0x0d,0x0c,0x9d,0x0f,0x0c,0x08,0x02,0x7b,
0xac,0x35,0x99,0xca,0x66,0xa3,0x31,0x16,0x46,0xa0,0x86,0x40,0x58,0x48,
0x13,0x2c,0x30,0x02,0x22,0xd7,0x48,0xac,0x48,0x6a,0x2d,0x1d,0xe1,0x88,
0x05,0x2e,0x8d,0x50,0x10,0xe9,0xac,0x8d,0xd3,0x17,0xfa,0x71,0xb1,0x37,
0x09,0xf8,0x2e,0x94,0xa8,0x2a,0x91,0x97,0x14,0x84,0xfc,0x0c,0x08,0x71,
0xe3,0x78,0x77,0x4f,0x3d,0x33,0x4c,0xe8,0x8c,0xc1,0xb4,0x2c,0x98,0x66,
0x08,0x3a,0x45,0x61,0x99,0x34,0xa7,0x31,0x12,0x0a,0x41,0x33,0x01,0x3b,
0xcb,0x61,0xdb,0xb6,0x34,0x4e,0x82,0x7c,0x70,0xec,0x3c,0x9d,0x86,0x6f,
0x79,0xa0,0x85,0x40,0x8c,0xd3,0xdc,0x27,0xea,0x06,0x14,0x82,0x75,0x21,
0x7f,0x17,0xfd,0xc5,0x9a,0xf0,0x77,0xf8,0x76,0xb3,0xd0,0x4d,0xc8,0x5e,
0xf3,0xe8,0x23,0x2b,0x37,0xfb,0x44,0xc7,0x03,0x72,0x0c,0xd0,0x01,0x68,
0xf4,0x61,0xbb,0xc8,0x64,0x32,0xf9,0x0d,0x2a,0x4b,0x6a,0x58,0x4a,0x5c,
0x93,0x0b,0x18,0x0a,0x0e,0x4a,0x98,0xe8,0xe5,0x02,0xad,0x82,0x5b,0xb1,
0x27,0xb6,0xc3,0x4e,0x01,0xcc,0x20,0x21,0x59,0x6b,0x23,0x10,0xd3,0x0d,
0xa2,0x79,0xd3,0x68,0x05,0xeb,0xf9,0x50,0x7b,0x2d,0x45,0x33,0xff,0x9c,
0xa6,0xae,0x67,0x84,0x00,0x3b,0x09,0x70,0x6c,0x2f,0x34,0x70,0xef,0xa5,
0x5d,0xc8,0x25,0xfb,0x28,0xd7,0xaa,0xd9,0xf2,0x58,0x70,0xd1,0x02,0x48,
0xd3,0x46,0x9e,0x78,0xe1,0x35,0xa8,0xbc,0x83,0x1a,0x4d,0x17,0x7f,0x2a,
0x30,0x20,0x76,0xec,0xf0,0x21,0xf8,0x27,0xe8,0x3b,0x05,0x84,0x63,0x41,
0x03,0xaa,0x83,0x2a,0x1b,0x41,0x0a,0xed,0x81,0xc1,0xda,0x16,0xc0,0x75,
0x81,0x6c,0x32,0xa8,0xbd,0x66,0xe6,0x9f,0x93,0x34,0x2b,0x80,0xde,0x3f,
0x01,0x21,0x3e,0x95,0x5a,0x45,0xdf,0x07,0xd8,0xa2,0x45,0x3a,0xce,0x8e,
0x3d,0x8f,0xba,0x09,0xf5,0x88,0xd5,0x03,0x3a,0x0b,0x52,0x6a,0x28,0xba,
0x36,0xae,0xaf,0x6f,0xc1,0x70,0x18,0xb5,0x9a,0xca,0x1b,0x8a,0x02,0xbe,
0x03,0x78,0x8a,0xb2,0xfe,0xfd,0x17,0x80,0x2b,0x27,0xaf,0xe0,0x9e,0x0b,
0x63,0x95,0x81,0xa1,0x0c,0xe4,0x65,0x81,0x8b,0x45,0xe8,0x3d,0x65,0x83,
0x71,0x95,0x05,0x22,0x93,0x54,0x11,0x95,0x83,0xaa,0xb9,0xdc,0xaf,0xce,
0x07,0x06,0x7a,0xfe,0x72,0xe0,0xfb,0x8b,0xa4,0x46,0xd9,0x97,0x52,0x36,
0x7d,0xd5,0x4a,0x44,0x2a,0x36,0x22,0xde,0xa0,0xa1,0xbe,0x39,0xf0,0x69,
0x58,0xca,0x25,0x94,0x08,0x51,0x57,0x42,0xdc,0x27,0xba,0x20,0x01,0x65,
0x98,0x0d,0x45,0xde,0x99,0x05,0xaa,0xf7,0x73,0x64,0xb3,0x6f,0x8a,0x43,
0x1b,0x3e,0x1b,0xe9,0x5b,0x31,0x99,0x68,0x7d,0x03,0x86,0xd8,0x80,0x86,
0x29,0x26,0x6a,0x27,0x02,0x0c,0x41,0x17,0xab,0x72,0x0c,0xcd,0x4d,0x12,
0x73,0x55,0xba,0x6d,0x35,0x3a,0x81,0xa9,0xab,0x54,0xf3,0x8b,0x87,0x5d,
0x78,0x68,0x15,0x87,0x3e,0xde,0x58,0xf6,0xb5,0xbc,0xd0,0xc4,0xdb,0x73,
0x98,0xa6,0xed,0x14,0xd1,0xaa,0x6a,0x8c,0x1a,0x0f,0x8c,0x9d,0x1a,0x44,
0xa7,0x9b,0x52,0x7c,0x28,0xdd,0x52,0xcc,0xf7,0xa4,0x91,0x20,0xea,0xfd,
0xd7,0x80,0xaa,0x9f,0xa1,0x65,0x53,0xfd,0xdc,0x15,0x0b,0x45,0xd7,0x86,
0xf6,0xdb,0xff,0x63,0xa2,0xc0,0xe6,0xb6,0x19,0x46,0x2e,0xb9,0x1e,0x3a,
0x5b,0xe1,0xc5,0x46,0x87,0xd0,0x30,0x19,0x70,0xb2,0x40,0xa4,0x0a,0xa8,
0x88,0x07,0x86,0x72,0x69,0x20,0xd3,0x1f,0x64,0xe5,0xc2,0x11,0x98,0xb9,
0x5e,0x87,0x71,0xb1,0xd9,0x31,0x63,0xab,0x44,0xfb,0x5a,0x0f,0x84,0x32,
0x06,0xca,0x83,0xb5,0xac,0x30,0xad,0x70,0x62,0xb9,0x1e,0x62,0xaf,0x70,
0xe0,0x41,0x1f,0x08,0x73,0xcf,0xd7,0x85,0x6c,0x35,0xd3,0xf0,0x75,0xc6,
0x72,0x1a,0xf0,0x07,0x77,0xf8,0x26,0x67,0xe0,0xfa,0x36,0xd1,0xb5,0xc9,
0x85,0x42,0x59,0x03,0x77,0x0a,0xc6,0xe6,0xaa,0x87,0x59,0xfb,0x70,0x51,
0x96,0x37,0xf0,0x7f,0xe2,0x3f,0x0c,0x08,0x36,0xef,0x65,0xe9,0x4f,0x36,
0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
static const unsigned int dialog_warning_png_len = 1354;
static const unsigned char dialog_warning_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x08,0x06,0x00,0x00,
0x00,0x73,0x7a,0x7a,0xf4,0x00,0x00,0x00,0x04,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0x08,0x7c,0x08,0x64,0x88,0x00,0x00,0x00,0x09,0x70,0x48,0x59,
0x73,0x00,0x00,0x03,0x76,0x00,0x00,0x03,0x76,0x01,0x7d,0xd5,0x82,0xcc,
0x00,0x00,0x00,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66,0x74,0x77,0x61,
0x72,0x65,0x00,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,
0x65,0x2e,0x6f,0x72,0x67,0x9b,0xee,0x3c,0x1a,0x00,0x00,0x04,0xc7,0x49,
0x44,0x41,0x54,0x78,0xda,0xd5,0x97,0x5d,0x6c,0x14,0x55,0x14,0xc7,0xff,
0xe7,0xde,0x3b,0x1f,0xfb,0xd5,0xee,0xb6,0x6c,0xbf,0x68,0x2b,0xa4,0x50,
0xa4,0xd0,0x42,0x04,0xa2,0x24,0x04,0x31,0x10,0xa3,0x01,0x4c,0x24,0xd1,
0x48,0x30,0xbc,0x48,0xf4,0xc9,0x44,0x7d,0xd5,0x60,0x88,0x31,0xc6,0x04,
0x13,0x8d,0xe8,0x83,0x2f,0xfa,0xce,0x03,0x3e,0x69,0x82,0x98,0xf0,0xa2,
0x2f,0x86,0x34,0x62,0x00,0xbf,0xa2,0x21,0x5a,0xd0,0xb6,0xd0,0xee,0xee,
0xcc,0x6c,0xe7,0xf3,0x7a,0xa7,0x3b,0x75,0x9a,0xdd,0x54,0x49,0x69,0x25,
0x9e,0xe4,0x97,0x73,0x32,0xf7,0x9e,0x39,0xff,0x73,0x66,0xe7,0x63,0x49,
0x4a,0x89,0x7b,0x69,0x4c,0xf1,0x3f,0x16,0x70,0x96,0xf8,0x3c,0x77,0x61,
0xcb,0xbf,0x04,0x9f,0x52,0x11,0xbd,0xc5,0xe3,0xf0,0x67,0x6b,0x08,0x70,
0x0e,0xfb,0xe4,0xec,0x7f,0x27,0xe0,0x3c,0xe5,0x22,0x9d,0x7f,0x1d,0xb5,
0x9f,0x18,0x03,0x24,0xd8,0xec,0xc7,0x97,0x59,0x9b,0xbf,0x1b,0x3b,0xa4,
0xb3,0xfa,0x97,0xe0,0x22,0x89,0x48,0x63,0x2f,0x06,0x76,0xe7,0xa8,0xe8,
0x78,0x1a,0xa2,0xed,0x30,0x82,0x19,0x7d,0x34,0xb2,0xc4,0x4b,0x00,0xf1,
0xd5,0x17,0x10,0x20,0x27,0x5d,0xf6,0xb2,0x68,0x7f,0x8a,0x60,0x74,0x00,
0x99,0x1e,0x88,0x8e,0x63,0x14,0xd9,0x78,0x05,0x17,0x90,0x5f,0x35,0x01,
0x69,0xf7,0xe2,0xd5,0xd0,0xeb,0xea,0x62,0xbd,0x07,0x01,0xaf,0x3a,0x0f,
0xeb,0x7b,0x0c,0xa1,0x53,0xe8,0x84,0x10,0x27,0xe3,0x3d,0xab,0x27,0xa0,
0x80,0x62,0x54,0xa7,0x13,0x62,0xcd,0x11,0x80,0x73,0xc0,0xaf,0x02,0x81,
0x02,0x21,0x44,0xf7,0x93,0x08,0x1c,0x7a,0x0e,0x40,0x71,0x75,0x04,0x7c,
0x44,0x5a,0x54,0xe3,0x6f,0x4a,0xea,0x2d,0xb1,0xf2,0x1e,0x44,0xaa,0xf8,
0xed,0xe9,0xba,0xc2,0x41,0xa4,0x44,0xf0,0xd2,0x4e,0x48,0x59,0x6a,0x8f,
0x38,0x7f,0x2b,0x9e,0xc2,0xca,0x0b,0xd8,0x82,0x72,0xe4,0xb2,0xa3,0xac,
0x74,0x10,0x90,0x2e,0x1c,0xcb,0x46,0x75,0xca,0x46,0x65,0xd2,0x81,0x6d,
0x39,0x80,0xb4,0xc1,0x8b,0xfb,0x11,0xda,0xec,0x19,0x70,0x94,0x57,0x56,
0xc0,0x25,0xd5,0xbd,0xcf,0xde,0x89,0xf8,0x60,0x81,0xb7,0x8f,0x02,0x51,
0x0d,0x81,0x5b,0x43,0x54,0x57,0x38,0x16,0xfc,0xb9,0x1a,0x10,0x55,0xc1,
0x72,0xeb,0x21,0xd1,0x95,0xf7,0x7d,0xf6,0x5e,0x9c,0xb3,0x72,0x02,0x7c,
0xac,0xf5,0x1d,0x7a,0x82,0x97,0xf6,0x03,0x91,0x35,0x5f,0x8c,0xb3,0xaa,
0x12,0x60,0x21,0x74,0x6a,0xe0,0xbc,0x0a,0xc8,0x98,0x0a,0x78,0xfb,0x2e,
0x25,0x8a,0x0e,0xc1,0x45,0xdf,0xca,0x08,0x38,0x4b,0x7a,0x60,0xb1,0xf7,
0x49,0x1f,0xce,0xf2,0x4c,0x1f,0x10,0x35,0x8a,0x71,0xa1,0x04,0xa8,0xe2,
0x52,0x4d,0x41,0xe8,0x15,0x00,0x35,0x85,0x3a,0x6e,0xe6,0x01,0x31,0x90,
0x09,0x6c,0xf6,0x61,0x9c,0x7b,0x77,0x02,0x88,0x08,0x1d,0xd8,0x10,0xd6,
0xe9,0x51,0xde,0xb9,0x1b,0x20,0x4b,0x91,0x14,0x52,0x45,0x65,0xdd,0x56,
0x58,0x4a,0x40,0x15,0xa0,0x04,0xcc,0x40,0x94,0x86,0x10,0xd8,0x74,0x20,
0xce,0x05,0x11,0x2d,0x5f,0xc0,0x67,0xd0,0xfd,0x80,0x9d,0x41,0x76,0xab,
0xce,0xcd,0x4c,0x5c,0x58,0x51,0x9b,0x47,0x18,0x95,0xf9,0xee,0xa5,0xa3,
0xe2,0x4c,0x05,0x60,0xb5,0x86,0x38,0xe5,0xb9,0xe9,0x02,0xe6,0xda,0x38,
0xf7,0x03,0x5c,0x81,0xb6,0x4c,0x01,0x44,0x68,0xd3,0xb6,0x7b,0x16,0xdf,
0x23,0xca,0x5b,0x00,0xaa,0x34,0x04,0xb0,0x06,0xdc,0xa8,0x82,0x3c,0x0b,
0xe4,0x5b,0xaa,0x60,0xa5,0x71,0x9c,0x27,0xeb,0x34,0x0b,0xad,0xdc,0x0b,
0xbf,0x86,0x3d,0xb8,0xa5,0x6d,0x03,0x96,0x9e,0x82,0xc0,0x52,0xf6,0x09,
0x0c,0xaf,0x1c,0xbc,0xcb,0xf3,0xc3,0x1a,0x17,0x53,0x00,0x74,0x40,0x33,
0x00,0x12,0x8a,0x0c,0x20,0x02,0x98,0xe5,0x1c,0x88,0x6b,0x80,0xae,0x03,
0xb9,0x08,0x80,0x6c,0x20,0x01,0x4e,0x04,0x9a,0x9a,0x10,0xde,0xec,0xc4,
0x19,0xfd,0x73,0xec,0xc5,0xe3,0x70,0xef,0x5c,0xc0,0x29,0x62,0xd8,0x27,
0x1e,0xf6,0x6e,0xb0,0x5d,0xe6,0x7d,0xd3,0xc0,0xdc,0x0f,0x00,0x25,0xf3,
0xa2,0x98,0x38,0xc8,0xc3,0xfb,0x2d,0x0f,0xe9,0xda,0x80,0x53,0x01,0xdc,
0x64,0x2d,0x36,0xd9,0x70,0x5a,0x77,0x37,0xea,0x57,0xe4,0x4e,0xd6,0xc3,
0xf7,0x8a,0x53,0xf4,0x25,0x5e,0x97,0xd1,0x9d,0x09,0x18,0x81,0x51,0xbf,
0x15,0xbe,0xcd,0xda,0x7a,0xb8,0x28,0xfc,0xfe,0x77,0xe1,0xd4,0x47,0xca,
0x57,0x91,0xe9,0x6a,0x74,0x0b,0xae,0x30,0x91,0x58,0x2a,0x40,0x18,0xd3,
0x60,0xa5,0x6e,0xe6,0xcd,0x4e,0x9e,0x16,0x23,0x78,0x08,0x40,0xfd,0x0e,
0x7e,0x03,0xc4,0xc2,0x4e,0x7e,0xd8,0xbb,0x9d,0x1d,0xd3,0x7b,0x5d,0x40,
0x47,0x03,0x23,0xc1,0x4c,0xbc,0x06,0xf4,0x3f,0x5b,0x43,0xff,0xf1,0x5a,
0xb2,0xde,0x84,0xae,0xd0,0x42,0x98,0x43,0x1a,0xbc,0x49,0x1a,0x0d,0xdb,
0xf8,0xa1,0x78,0xb2,0xff,0xfe,0x41,0x72,0x93,0xb2,0xd6,0x17,0x18,0xa7,
0x35,0x1b,0x86,0x73,0x9b,0x7e,0x06,0x58,0xd2,0x21,0x4b,0xa0,0x34,0x76,
0x7e,0xd4,0xc1,0x32,0x12,0xe6,0x3a,0x7f,0xa1,0xeb,0xd8,0xa7,0x44,0xb1,
0x67,0xb0,0xc7,0x07,0x20,0xa7,0xae,0xff,0x94,0xdf,0x8a,0xed,0xcd,0x1f,
0x2d,0xac,0xf9,0x1b,0xcf,0x1f,0x67,0xc7,0xfc,0x4a,0xc7,0x46,0x73,0x5d,
0x15,0xd0,0x16,0x3a,0x49,0x58,0xd4,0xe9,0xcc,0x85,0x1c,0x6e,0x9e,0x2e,
0x62,0xe2,0x8d,0x12,0xac,0x71,0x73,0xa1,0xeb,0x74,0xbf,0x48,0xe0,0x11,
0x32,0xf7,0x13,0xdc,0x49,0x6d,0xa3,0x7f,0x83,0x1d,0x05,0x88,0x2d,0x2d,
0x60,0x10,0x39,0xe7,0xba,0x7c,0x4d,0xdf,0xd8,0x47,0xbc,0x30,0x09,0x08,
0xa4,0x68,0xa9,0x8f,0x8b,0xf9,0xbf,0x0a,0x70,0xc2,0x3c,0xde,0x2f,0x5a,
0x5a,0x98,0x2f,0x9a,0x18,0x35,0x60,0xd9,0xeb,0x30,0xb7,0xae,0x87,0x3a,
0xf7,0x49,0x5c,0x45,0xb6,0x49,0x40,0xda,0xbd,0x3b,0xc1,0x5e,0x08,0x9c,
0x9e,0x41,0x73,0x68,0x32,0x5e,0x69,0x61,0xf1,0x89,0xdb,0x0f,0xd6,0x61,
0x74,0xa9,0xee,0x06,0x42,0x14,0x0e,0xd4,0x81,0x08,0xad,0xc8,0x85,0x58,
0x22,0xb3,0x29,0x80,0x3b,0x6d,0x0e,0xd6,0xaf,0xb1,0xe7,0xe3,0x5a,0xad,
0xbf,0x81,0x8b,0x54,0x9c,0xf9,0x86,0xae,0x19,0xdb,0x1e,0xe8,0xc9,0x6e,
0xbe,0xb4,0xb8,0x60,0x0a,0x6f,0xba,0x1b,0x90,0xf8,0xe8,0x1f,0x08,0x13,
0x54,0x6c,0x5f,0x1b,0x83,0xfb,0xed,0x77,0x7f,0x76,0x3c,0x22,0x87,0xf1,
0xa0,0xac,0xa6,0x13,0x20,0x22,0x70,0x6c,0x73,0xa7,0x8c,0x6e,0x63,0xd0,
0x6e,0x4a,0x4e,0x08,0x14,0x7e,0x82,0xbb,0x88,0xba,0x62,0x2e,0x89,0x3d,
0xb4,0xe2,0xa7,0xb9,0x99,0x21,0x06,0xbf,0x62,0x76,0xa9,0x78,0x73,0xeb,
0x73,0x80,0x21,0xd2,0xbb,0xdb,0x24,0xa8,0x9f,0x20,0x28,0xed,0x34,0x36,
0x6a,0x7e,0xc8,0xa4,0x3e,0x89,0x13,0xd2,0xfd,0xad,0xf9,0x04,0x78,0x59,
0x98,0x1b,0xb2,0x00,0xab,0x47,0xad,0x97,0xe0,0x2a,0xe5,0xe7,0xbe,0xd7,
0xce,0x85,0x9e,0xb9,0xdf,0x9b,0x2e,0x91,0x73,0xf9,0x0f,0xac,0xa4,0xf1,
0x62,0x01,0xc6,0x00,0x97,0x99,0xfe,0x99,0xf3,0xe6,0xa0,0x7f,0x24,0xbe,
0x1d,0x5b,0x9f,0x03,0x5f,0x51,0x01,0xbe,0xd8,0x01,0x4d,0xae,0x45,0xb3,
0x85,0x0a,0x8e,0x74,0xb3,0x5c,0x22,0x66,0x2a,0x0e,0x17,0xaa,0x26,0x31,
0x0b,0x65,0x3c,0x61,0x00,0x37,0x90,0xc7,0x65,0x8c,0x49,0xbb,0x69,0x02,
0x4d,0xef,0x81,0x11,0x10,0x56,0xc3,0xae,0x42,0x36,0xbf,0x0f,0xee,0xf9,
0xdf,0xf3,0xbf,0x00,0xdc,0x19,0x00,0xc3,0x09,0xc5,0x7a,0xd4,0x00,0x00,
0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
#endif

306
src/qtcurve/style/fixx11h.h Normal file
View File

@ -0,0 +1,306 @@
/****************************************************************************
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
****************************************************************************/
//#ifdef don't do this, this file is supposed to be included
//#define multiple times
#include <QtCore/QtGlobal>
#ifdef Q_WS_X11
/* Usage:
If you get compile errors caused by X11 includes (the line
where first error appears contains word like None, Unsorted,
Below, etc.), put #include <fixx11h.h> in the .cpp file
(not .h file!) between the place where X11 headers are
included and the place where the file with compile
error is included (or the place where the compile error
in the .cpp file occurs).
This file remaps X11 #defines to const variables or
inline functions. The side effect may be that these
symbols may now refer to different variables
(e.g. if X11 #defined NoButton, after this file
is included NoButton would no longer be X11's
NoButton, but Qt::NoButton instead). At this time,
there's no conflict known that could cause problems.
The original X11 symbols are still accessible
(e.g. for None) as X::None, XNone, and also still
None, unless name lookup finds different None
first (in the current class, etc.)
Use 'Unsorted', 'Bool' and 'index' as templates.
*/
namespace X
{
// template --->
// Affects: Should be without side effects.
#ifdef Unsorted
#ifndef FIXX11H_Unsorted
#define FIXX11H_Unsorted
const int XUnsorted = Unsorted;
#undef Unsorted
const int Unsorted = XUnsorted;
#endif
#undef Unsorted
#endif
// template <---
// Affects: Should be without side effects.
#ifdef None
#ifndef FIXX11H_None
#define FIXX11H_None
const XID XNone = None;
#undef None
const XID None = XNone;
#endif
#undef None
#endif
// template --->
// Affects: Should be without side effects.
#ifdef Bool
#ifndef FIXX11H_Bool
#define FIXX11H_Bool
#ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */
#undef Bool
#else
typedef Bool XBool;
#undef Bool
typedef XBool Bool;
#endif
#endif
#undef Bool
#define _XTYPEDEF_BOOL
#endif
// template <---
// Affects: Should be without side effects.
#ifdef KeyPress
#ifndef FIXX11H_KeyPress
#define FIXX11H_KeyPress
const int XKeyPress = KeyPress;
#undef KeyPress
const int KeyPress = XKeyPress;
#endif
#undef KeyPress
#endif
// Affects: Should be without side effects.
#ifdef KeyRelease
#ifndef FIXX11H_KeyRelease
#define FIXX11H_KeyRelease
const int XKeyRelease = KeyRelease;
#undef KeyRelease
const int KeyRelease = XKeyRelease;
#endif
#undef KeyRelease
#endif
// Affects: Should be without side effects.
#ifdef Above
#ifndef FIXX11H_Above
#define FIXX11H_Above
const int XAbove = Above;
#undef Above
const int Above = XAbove;
#endif
#undef Above
#endif
// Affects: Should be without side effects.
#ifdef Below
#ifndef FIXX11H_Below
#define FIXX11H_Below
const int XBelow = Below;
#undef Below
const int Below = XBelow;
#endif
#undef Below
#endif
// Affects: Should be without side effects.
#ifdef FocusIn
#ifndef FIXX11H_FocusIn
#define FIXX11H_FocusIn
const int XFocusIn = FocusIn;
#undef FocusIn
const int FocusIn = XFocusIn;
#endif
#undef FocusIn
#endif
// Affects: Should be without side effects.
#ifdef FocusOut
#ifndef FIXX11H_FocusOut
#define FIXX11H_FocusOut
const int XFocusOut = FocusOut;
#undef FocusOut
const int FocusOut = XFocusOut;
#endif
#undef FocusOut
#endif
// Affects: Should be without side effects.
#ifdef Always
#ifndef FIXX11H_Always
#define FIXX11H_Always
const int XAlways = Always;
#undef Always
const int Always = XAlways;
#endif
#undef Always
#endif
// Affects: Should be without side effects.
#ifdef Success
#ifndef FIXX11H_Success
#define FIXX11H_Success
const int XSuccess = Success;
#undef Success
const int Success = XSuccess;
#endif
#undef Success
#endif
// Affects: Should be without side effects.
#ifdef GrayScale
#ifndef FIXX11H_GrayScale
#define FIXX11H_GrayScale
const int XGrayScale = GrayScale;
#undef GrayScale
const int GrayScale = XGrayScale;
#endif
#undef GrayScale
#endif
// Affects: Should be without side effects.
#ifdef Status
#ifndef FIXX11H_Status
#define FIXX11H_Status
typedef Status XStatus;
#undef Status
typedef XStatus Status;
#endif
#undef Status
#endif
// Affects: Should be without side effects.
#ifdef CursorShape
#ifndef FIXX11H_CursorShape
#define FIXX11H_CursorShape
const int XCursorShape = CursorShape;
#undef CursorShape
const int CursorShape = CursorShape;
#endif
#undef CursorShape
#endif
// template --->
// Affects: Should be without side effects.
#ifdef CursorShape
#ifndef FIXX11H_CursorShape
#define FIXX11H_CursorShape
const int XCursorShape = CursorShape;
#undef CursorShape
const int CursorShape = XCursorShape;
#endif
#undef CursorShape
#endif
// template <---
// template --->
// Affects: Should be without side effects.
#ifdef FontChange
#ifndef FIXX11H_FontChange
#define FIXX11H_FontChange
const int XFontChange = FontChange;
#undef FontChange
const int FontChange = XFontChange;
#endif
#undef FontChange
#endif
// template <---
// Affects: Should be without side effects.
#ifdef NormalState
#ifndef FIXX11H_NormalState
#define FIXX11H_NormalState
const int XNormalState = NormalState;
#undef NormalState
const int NormalState = XNormalState;
#endif
#undef NormalState
#endif
// template --->
// Affects: Should be without side effects.
#ifdef index
#ifndef FIXX11H_index
#define FIXX11H_index
inline
const char* Xindex( const char* s, int c )
{
return index( s, c );
}
#undef index
inline
const char* index( const char* s, int c )
{
return Xindex( s, c );
}
#endif
#undef index
#endif
// template <---
#ifdef rindex
// Affects: Should be without side effects.
#ifndef FIXX11H_rindex
#define FIXX11H_rindex
inline
const char* Xrindex( const char* s, int c )
{
return rindex( s, c );
}
#undef rindex
inline
const char* rindex( const char* s, int c )
{
return Xrindex( s, c );
}
#endif
#undef rindex
#endif
}
using namespace X;
#endif

View File

@ -0,0 +1,51 @@
/* Bespin mac-a-like XBar KDE4
Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MAC_MENU_ADAPTOR_H
#define MAC_MENU_ADAPTOR_H
#include <QtDBus/QDBusAbstractAdaptor>
#include "macmenu.h"
namespace Bespin
{
class MacMenuAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.XBarClient")
private:
MacMenu *mm;
public:
MacMenuAdaptor(MacMenu *macMenu) : QDBusAbstractAdaptor(macMenu), mm(macMenu) { }
public slots:
Q_NOREPLY void activate() { mm->activate(); }
Q_NOREPLY void deactivate() { mm->deactivate(); }
Q_NOREPLY void popup(qlonglong key, int idx, int x, int y)
{ mm->popup(key, idx, x, y); }
Q_NOREPLY void hover(qlonglong key, int idx, int x, int y)
{ mm->hover(key, idx, x, y); }
Q_NOREPLY void popDown(qlonglong key) { mm->popDown(key); }
Q_NOREPLY void raise(qlonglong key) { mm->raise(key); }
};
} // namespace
#endif //MAC_MENU_ADAPTOR_H

View File

@ -0,0 +1,502 @@
/* Bespin mac-a-like XBar KDE4
Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QActionEvent>
#include <QApplication>
#include <QtDBus/QDBusConnectionInterface>
#include <QtDBus/QDBusMessage>
#include <QLayout>
#include <QMenuBar>
#include <QWindowStateChangeEvent>
#include "macmenu.h"
#include "macmenu-dbus.h"
#include <QtDebug>
using namespace Bespin;
static MacMenu *instance = 0;
#define MSG(_FNC_) QDBusMessage::createMethodCall( "org.kde.XBar", "/XBar", "org.kde.XBar", _FNC_ )
#define XBAR_SEND( _MSG_ ) QDBusConnection::sessionBus().send( _MSG_ )
bool
FullscreenWatcher::eventFilter(QObject *o, QEvent *ev)
{
QWidget *window = qobject_cast<QWidget*>(o);
if (!(window && ev->type() == QEvent::WindowStateChange))
return false;
if (window->windowState() & Qt::WindowFullScreen)
instance->deactivate(window);
else
instance->activate(window);
return false;
}
static FullscreenWatcher *fullscreenWatcher = 0;
MacMenu::MacMenu() : QObject()
{
usingMacMenu = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.XBar");
service = QString("org.kde.XBar-%1").arg(QCoreApplication::applicationPid());
// register me
QDBusConnection::sessionBus().registerService(service);
QDBusConnection::sessionBus().registerObject("/XBarClient", this);
connect (qApp, SIGNAL(aboutToQuit()), this, SLOT(deactivate()));
}
void
MacMenu::manage(QMenuBar *menu)
{
if (!menu) // ...
return;
// we only accept menus that are placed on a QMainWindow - for the moment, and probably ever
QWidget *dad = menu->parentWidget();
if (!(dad && dad->isWindow() && dad->inherits("QMainWindow") && dad->layout() && dad->layout()->menuBar() == menu))
return;
// if ((dad = dad->parentWidget()) && dad->inherits("QMdiSubWindow"))
// return;
if (!instance)
{
instance = new MacMenu;
/*MacMenuAdaptor *adapt = */new MacMenuAdaptor(instance);
fullscreenWatcher = new FullscreenWatcher;
}
else if (instance->items.contains(menu))
return; // no double adds please!
if (instance->usingMacMenu)
instance->activate(menu);
connect (menu, SIGNAL(destroyed(QObject *)), instance, SLOT(_release(QObject *)));
instance->items.append(menu);
}
void
MacMenu::release(QMenuBar *menu)
{
if (!instance)
return;
instance->_release(menu);
}
bool
MacMenu::isActive()
{
return instance && instance->usingMacMenu;
}
void
MacMenu::_release(QObject *o)
{
XBAR_SEND( MSG("unregisterMenu") << (qlonglong)o );
QMenuBar *menu = qobject_cast<QMenuBar*>(o);
if (!menu) return;
items.removeAll(menu);
menu->removeEventFilter(this);
QWidget *dad = menu->parentWidget();
if (dad && dad->layout())
dad->layout()->setMenuBar(menu);
menu->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
menu->adjustSize();
// menu->updateGeometry();
}
void
MacMenu::activate()
{
MenuList::iterator menu = items.begin();
while (menu != items.end())
{
if (*menu)
{ activate(*menu); ++menu; }
else
{ actions.remove(*menu); menu = items.erase(menu); }
}
usingMacMenu = true;
}
void
MacMenu::activate(QMenuBar *menu)
{
menu->removeEventFilter(this);
// and WOWWWW - no more per window menubars...
menu->setFixedSize(0,0);
//NOTICE i used to set the menu's parent->layout()->setMenuBar(0) to get rid of the free space
// but this leeds to side effects (e.g. kcalc won't come up anymore...)
// so now the stylehint for the free space below checks the menubar height and returns
// a negative value so that final result will be 1 px heigh...
menu->updateGeometry();
// we need to hold a copy of this list to handle action removes
// (as we get the event after the action has been removed from the widget...)
actions[menu] = menu->actions();
// find a nice header
QString title = menu->window()->windowTitle();
const QStringList appArgs = QCoreApplication::arguments();
QString name = appArgs.isEmpty() ? "" : appArgs.at(0).section('/', -1);
if (title.isEmpty())
title = name;
else
{
int i = title.indexOf(name, 0, Qt::CaseInsensitive);
if (i > -1)
title = title.mid(i, name.length());
}
title = title.section(" - ", -1);
if (title.isEmpty())
{
if (!menu->actions().isEmpty())
title = menu->actions().at(0)->text();
if (title.isEmpty())
title = "QApplication";
}
// register the menu via dbus
QStringList entries;
foreach (QAction* action, menu->actions())
if (action->isSeparator())
entries << "<XBAR_SEPARATOR/>";
else
entries << action->text();
XBAR_SEND( MSG("registerMenu") << service << (qlonglong)menu << title << entries );
// TODO cause of now async call, the following should - maybe - attached to the above?!!
if (menu->isActiveWindow())
XBAR_SEND( MSG("requestFocus") << (qlonglong)menu );
// take care of several widget events!
menu->installEventFilter(this);
if (menu->window())
{
menu->window()->removeEventFilter(fullscreenWatcher);
menu->window()->installEventFilter(fullscreenWatcher);
}
}
void
MacMenu::activate(QWidget *window)
{
MenuList::iterator menu = items.begin();
while (menu != items.end())
{
if (*menu)
{
if ((*menu)->window() == window)
{ activate(*menu); return; }
++menu;
}
else
{ actions.remove(*menu); menu = items.erase(menu); }
}
}
void
MacMenu::deactivate()
{
usingMacMenu = false;
MenuList::iterator i = items.begin();
QMenuBar *menu = 0;
while (i != items.end())
{
actions.remove(*i);
if ((menu = *i))
{
deactivate(menu);
++i;
}
else
i = items.erase(i);
}
}
void
MacMenu::deactivate(QMenuBar *menu)
{
menu->removeEventFilter(this);
QWidget *dad = menu->parentWidget();
if (dad && dad->layout())
dad->layout()->setMenuBar(menu);
menu->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
menu->adjustSize();
// menu->updateGeometry();
}
void
MacMenu::deactivate(QWidget *window)
{
MenuList::iterator menu = items.begin();
while (menu != items.end())
{
if (*menu)
{
if ((*menu)->window() == window)
{ deactivate(*menu); return; }
++menu;
}
else
{ actions.remove(*menu); menu = items.erase(menu); }
}
}
QMenuBar *
MacMenu::menuBar(qlonglong key)
{
MenuList::iterator i = items.begin();
QMenuBar *menu;
while (i != items.end())
{
if (!(menu = *i))
{
actions.remove(menu);
i = items.erase(i);
}
else
{
if ((qlonglong)menu == key)
return menu;
else
++i;
}
}
return NULL;
}
void
MacMenu::popup(qlonglong key, int idx, int x, int y)
{
QMenuBar *menu = menuBar(key);
if (!menu) return;
QMenu *pop;
for (int i = 0; i < menu->actions().count(); ++i)
{
if (!(pop = menu->actions().at(i)->menu()))
continue;
if (i == idx) {
if (!pop->isVisible())
{
connect (pop, SIGNAL(aboutToHide()), this, SLOT(menuClosed()));
XBAR_SEND( MSG("setOpenPopup") << idx );
pop->popup(QPoint(x,y));
}
else
{
XBAR_SEND( MSG("setOpenPopup") << -1000 );
pop->hide();
}
}
else
pop->hide();
}
}
void
MacMenu::popDown(qlonglong key)
{
QMenuBar *menu = menuBar(key);
if (!menu) return;
QWidget *pop;
for (int i = 0; i < menu->actions().count(); ++i)
{
if (!(pop = menu->actions().at(i)->menu()))
continue;
disconnect (pop, SIGNAL(aboutToHide()), this, SLOT(menuClosed()));
pop->hide();
// menu->activateWindow();
break;
}
}
static bool inHover = false;
void
MacMenu::hover(qlonglong key, int idx, int x, int y)
{
QMenuBar *menu = menuBar(key);
if (!menu) return;
QWidget *pop;
for (int i = 0; i < menu->actions().count(); ++i)
{
if ((i == idx) || !(pop = menu->actions().at(i)->menu()))
continue;
if (pop->isVisible())
{
inHover = true;
popup(key, idx, x, y); // TODO: this means a useless second pass above...
inHover = false;
break;
}
}
}
static QMenuBar *bar4menu(QMenu *menu)
{
if (!menu->menuAction())
return 0;
if (menu->menuAction()->associatedWidgets().isEmpty())
return 0;
foreach (QWidget *w, menu->menuAction()->associatedWidgets())
if (qobject_cast<QMenuBar*>(w))
return static_cast<QMenuBar *>(w);
return 0;
}
void
MacMenu::menuClosed()
{
QObject * _sender = sender();
if (!_sender)
return;
disconnect (sender(), SIGNAL(aboutToHide()), this, SLOT(menuClosed()));
if (!inHover)
{
XBAR_SEND( MSG("setOpenPopup") << -500 );
if (QMenu *menu = qobject_cast<QMenu*>(_sender))
if (QMenuBar *bar = bar4menu(menu))
bar->activateWindow();
}
}
void
MacMenu::changeAction(QMenuBar *menu, QActionEvent *ev)
{
int idx;
const QString title = ev->action()->isSeparator() ? "<XBAR_SEPARATOR/>" : ev->action()->text();
if (ev->type() == QEvent::ActionAdded)
{
idx = ev->before() ? menu->actions().indexOf(ev->before())-1 : -1;
XBAR_SEND( MSG("addEntry") << (qlonglong)menu << idx << title );
actions[menu].insert(idx, ev->action());
return;
}
if (ev->type() == QEvent::ActionChanged)
{
idx = menu->actions().indexOf(ev->action());
XBAR_SEND( MSG("changeEntry") << (qlonglong)menu << idx << title );
}
else
{ // remove
idx = actions[menu].indexOf(ev->action());
actions[menu].removeAt(idx);
XBAR_SEND( MSG("removeEntry") << (qlonglong)menu << idx );
}
}
void
MacMenu::raise(qlonglong key)
{
if (QMenuBar *menu = menuBar(key))
{
if (QWidget *win = menu->window())
{
win->showNormal();
win->activateWindow();
win->raise();
}
}
}
bool
MacMenu::eventFilter(QObject *o, QEvent *ev)
{
QMenuBar *menu = qobject_cast<QMenuBar*>(o);
if (!menu)
return false;
if (!usingMacMenu)
return false;
QString func;
switch (ev->type())
{
case QEvent::Resize:
// menu->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
if (menu->size() != QSize(0,0))
{
menu->setFixedSize(0,0);
menu->updateGeometry();
}
break;
case QEvent::ActionAdded:
case QEvent::ActionChanged:
case QEvent::ActionRemoved:
changeAction(menu, static_cast<QActionEvent*>(ev));
break;
// case QEvent::ParentChange:
// qDebug() << o << ev;
// return false;
case QEvent::EnabledChange:
if (static_cast<QWidget*>(o)->isEnabled())
XBAR_SEND( MSG("requestFocus") << (qlonglong)menu );
else
XBAR_SEND( MSG("releaseFocus") << (qlonglong)menu );
break;
// TODO: test whether this is the only one and show it? (e.g. what about dialogs...?!)
case QEvent::ApplicationActivate:
// if (items.count() > 1)
// break;
case QEvent::WindowActivate:
XBAR_SEND( MSG("requestFocus") << (qlonglong)menu );
break;
case QEvent::WindowDeactivate:
// if (items.count() == 1)
// break;
case QEvent::WindowBlocked:
case QEvent::ApplicationDeactivate:
XBAR_SEND( MSG("releaseFocus") << (qlonglong)menu );
break;
default:
return false;
// maybe these need to be passed through...?!
// QEvent::GrabKeyboard
// QEvent::GrabMouse
// QEvent::KeyPress
// QEvent::KeyRelease
// QEvent::UngrabKeyboard
// QEvent::UngrabMouse
// --- and what about these ---
// QEvent::MenubarUpdated
// QEvent::ParentChange
// -------------------
}
return false;
}
#undef MSG
#undef XBAR_SEND

View File

@ -0,0 +1,82 @@
/* Bespin mac-a-like XBar KDE4
Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MAC_MENU_H
#define MAC_MENU_H
#include <QMap>
#include <QObject>
#include <QPointer>
class QMenuBar;
class QAction;
class QActionEvent;
namespace Bespin
{
class FullscreenWatcher : public QObject
{
public:
FullscreenWatcher() : QObject() {};
protected:
bool eventFilter(QObject *o, QEvent *ev);
};
class MacMenu : public QObject
{
Q_OBJECT
public:
static void manage(QMenuBar *menu);
static void release(QMenuBar *menu);
static bool isActive();
void popup(qlonglong key, int idx, int x, int y);
void hover(qlonglong key, int idx, int x, int y);
void popDown(qlonglong key);
void raise(qlonglong key);
public slots:
void activate();
void deactivate();
protected:
bool eventFilter(QObject *o, QEvent *ev);
protected:
friend class FullscreenWatcher;
void deactivate(QWidget *window);
void activate(QWidget *window);
private:
Q_DISABLE_COPY(MacMenu)
MacMenu();
void activate(QMenuBar *menu);
void changeAction(QMenuBar *menu, QActionEvent *ev);
void deactivate(QMenuBar *menu);
typedef QPointer<QMenuBar> QMenuBar_p;
typedef QList<QMenuBar_p> MenuList;
MenuList items;
QMenuBar *menuBar(qlonglong key);
QMap< QMenuBar_p, QList<QAction*> > actions;
bool usingMacMenu;
QString service;
private slots:
void menuClosed();
void _release(QObject *);
};
} // namespace
#endif //MAC_MENU_H

View File

@ -0,0 +1,36 @@
#ifndef _QEMBED_1804289383
#define _QEMBED_1804289383
static const unsigned int check_on_png_len = 179;
static const unsigned char check_on_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x09,0x08,0x06,0x00,0x00,
0x00,0xe0,0x91,0x06,0x10,0x00,0x00,0x00,0x7a,0x49,0x44,0x41,0x54,0x18,
0x95,0x75,0xce,0x2d,0x0e,0xc2,0x60,0x10,0x84,0xe1,0x87,0x70,0x00,0x0e,
0x40,0xc2,0x8f,0xe8,0xc1,0xd0,0x08,0xae,0x81,0xc0,0xd5,0x70,0x05,0x2e,
0xc0,0x39,0xa8,0x03,0x89,0x04,0x51,0x09,0x69,0x41,0x60,0xb6,0xc9,0xa6,
0xe1,0x1b,0xb5,0x3b,0xfb,0x66,0x76,0x26,0xca,0x5a,0xe1,0x88,0x59,0x09,
0x58,0xe2,0x8e,0xdb,0x60,0xac,0x51,0x25,0x60,0x8e,0x0b,0xde,0x58,0x0c,
0xe6,0x13,0x1d,0xf6,0xb1,0xef,0xf0,0x45,0x9d,0xa3,0xb7,0xe8,0xf1,0xc1,
0x06,0x2d,0x5e,0xff,0x3a,0x1c,0x02,0xea,0x23,0xe5,0x54,0x2a,0xdb,0x04,
0xd0,0xe5,0x2e,0x63,0x55,0xf1,0xa6,0x19,0x1f,0xa6,0x69,0x6e,0xf1,0xc0,
0x19,0xd7,0x0c,0xfd,0x00,0x7a,0x3f,0x1a,0x54,0x34,0x8d,0x19,0xdc,0x00,
0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
/* Generated by qembed */
static const unsigned int check_x_on_png_len = 154;
static const unsigned char check_x_on_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x09,0x08,0x06,0x00,0x00,
0x00,0xe0,0x91,0x06,0x10,0x00,0x00,0x00,0x61,0x49,0x44,0x41,0x54,0x18,
0x95,0x6d,0x8f,0x41,0x11,0xc0,0x30,0x08,0x04,0xb7,0x83,0x83,0xea,0x88,
0xa0,0x88,0xe9,0xb3,0x1a,0xaa,0x01,0x1d,0xd1,0x50,0x41,0xfd,0x5c,0x12,
0x60,0xca,0xef,0x60,0xe1,0x0e,0x03,0x2e,0xe0,0x01,0x4e,0x60,0xb0,0x6b,
0xf5,0x0f,0xe0,0x0d,0x03,0x07,0x6e,0x01,0x7d,0x36,0x4d,0x17,0x9a,0x74,
0x93,0xee,0x71,0xd1,0x64,0x51,0xc1,0x74,0xd9,0x24,0x2a,0x18,0xad,0x99,
0x50,0xca,0x50,0xac,0x87,0xfd,0x00,0x5e,0x33,0x9a,0xde,0xac,0x16,0x29,
0x63,0xfc,0x6e,0x65,0x28,0x19,0xfd,0x03,0xc4,0xa9,0x14,0xf0,0x37,0xcf,
0xd8,0xd2,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
#endif

13923
src/qtcurve/style/qtcurve.cpp Normal file

File diff suppressed because it is too large Load Diff

379
src/qtcurve/style/qtcurve.h Normal file
View File

@ -0,0 +1,379 @@
#ifndef __QTCURVE_H__
#define __QTCURVE_H__
/*
QtCurve (C) Craig Drummond, 2007 - 2010 craig.p.drummond@gmail.com
----
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License version 2 as published by the Free Software Foundation.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QProgressBar>
#include <QTime>
#include <QPalette>
#include <QMap>
#include <QList>
#include <QSet>
#include <QCache>
#include <QColor>
#include <QStyleOption>
#include <QBitmap>
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
#include <QFormLayout>
#endif
#include <Q_UINT64>
typedef qulonglong QtcKey;
#include "common.h"
#if !defined QTC_QT_ONLY
#include <KDE/KComponentData>
#endif
// #ifdef QTC_KSTYLE
// #include <kstyle.h>
// #define BASE_STYLE KStyle
// #else
#include <QCommonStyle>
#define BASE_STYLE QCommonStyle
// #endif
class QStyleOptionSlider;
class QLabel;
class QMenuBar;
class QScrollBar;
class QDBusInterface;
class QMainWindow;
class QStatusBar;
class QAbstractScrollArea;
namespace QtCurve
{
class WindowManager;
class BlurHelper;
class ShortcutHandler;
#ifdef Q_WS_X11
class ShadowHelper;
#endif
class Style : public QCommonStyle
{
Q_OBJECT
Q_CLASSINFO("X-KDE-CustomElements", "true")
public:
enum BackgroundType
{
BGND_WINDOW,
BGND_DIALOG,
BGND_MENU
};
enum MenuItemType
{
MENU_POPUP,
MENU_BAR,
MENU_COMBO
};
enum CustomElements
{
CE_QtC_KCapacityBar = CE_CustomBase+0x00FFFF00,
CE_QtC_Preview,
CE_QtC_SetOptions
};
enum PreviewType
{
PREVIEW_FALSE,
PREVIEW_MDI,
PREVIEW_WINDOW
};
class PreviewOption : public QStyleOption
{
public:
Options opts;
};
class BgndOption : public QStyleOption
{
public:
EAppearance app;
QPainterPath path;
QRect widgetRect;
};
enum Icon
{
ICN_MIN,
ICN_MAX,
ICN_MENU,
ICN_RESTORE,
ICN_CLOSE,
ICN_UP,
ICN_DOWN,
ICN_RIGHT,
ICN_SHADE,
ICN_UNSHADE
};
#ifdef QTC_STYLE_SUPPORT
Style(const QString &name=QString());
#else
Style();
#endif
~Style();
void init(bool initial);
void freeColor(QSet<QColor *> &freedColors, QColor **cols);
void freeColors();
Options & options() { return opts; }
void polish(QApplication *app);
void polish(QPalette &palette);
void polish(QWidget *widget);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
void polishFormLayout(QFormLayout *layout);
void polishLayout(QLayout *layout);
#endif
void polishScrollArea(QAbstractScrollArea *scrollArea, bool isKFilePlacesView=false) const;
void unpolish(QApplication *app);
void unpolish(QWidget *widget);
bool eventFilter(QObject *object, QEvent *event);
void timerEvent(QTimerEvent *event);
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const;
int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData=0) const;
QPalette standardPalette() const;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
void drawControl(ControlElement control, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
void drawItemTextWithRole(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text,
QPalette::ColorRole textRole) const;
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text,
QPalette::ColorRole textRole = QPalette::NoRole) const;
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
const QPoint &pos, const QWidget *widget) const;
private:
void drawSideBarButton(QPainter *painter, const QRect &r, const QStyleOption *option, const QWidget *widget) const;
void drawHighlight(QPainter *p, const QRect &r, bool horiz, bool inc) const;
void drawFadedLine(QPainter *p, const QRect &r, const QColor &col, bool fadeStart, bool fadeEnd, bool horiz,
double fadeSizeStart=FADE_SIZE, double fadeSizeEnd=FADE_SIZE) const;
void drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int offset, const QColor *cols, int startOffset,
int dark, ELine type) const;
void drawProgressBevelGradient(QPainter *p, const QRect &origRect, const QStyleOption *option, bool horiz,
EAppearance bevApp, const QColor *cols) const;
void drawBevelGradient(const QColor &base, QPainter *p, QRect const &r, const QPainterPath &path,
bool horiz, bool sel, EAppearance bevApp, EWidget w=WIDGET_OTHER, bool useCache=true) const;
void drawBevelGradientReal(const QColor &base, QPainter *p, const QRect &r, const QPainterPath &path,
bool horiz, bool sel, EAppearance bevApp, EWidget w) const;
void drawBevelGradient(const QColor &base, QPainter *p, QRect const &r,
bool horiz, bool sel, EAppearance bevApp, EWidget w=WIDGET_OTHER, bool useCache=true) const
{
drawBevelGradient(base, p, r, QPainterPath(), horiz, sel, bevApp, w, useCache);
}
void drawBevelGradientReal(const QColor &base, QPainter *p, const QRect &r, bool horiz, bool sel,
EAppearance bevApp, EWidget w) const
{
drawBevelGradientReal(base, p, r, QPainterPath(), horiz, sel, bevApp, w);
}
void drawSunkenBevel(QPainter *p, const QRect &r, const QColor &col) const;
void drawLightBevel(QPainter *p, const QRect &r, const QStyleOption *option, const QWidget *widget, int round, const QColor &fill,
const QColor *custom=0, bool doBorder=true, EWidget w=WIDGET_OTHER) const;
void drawLightBevelReal(QPainter *p, const QRect &r, const QStyleOption *option, const QWidget *widget, int round, const QColor &fill,
const QColor *custom, bool doBorder, EWidget w, bool useCache, ERound realRound, bool onToolbar) const;
void drawGlow(QPainter *p, const QRect &r, EWidget w, const QColor *cols=0L) const;
void drawEtch(QPainter *p, const QRect &r, const QWidget *widget, EWidget w, bool raised=false, int round=ROUNDED_ALL) const;
void drawBgndRing(QPainter &painter, int x, int y, int size, int size2, bool isWindow) const;
QPixmap drawStripes(const QColor &color, int opacity) const;
void drawBackground(QPainter *p, const QColor &bgnd, const QRect &r, int opacity, BackgroundType type, EAppearance app,
const QPainterPath &path=QPainterPath()) const;
void drawBackgroundImage(QPainter *p, bool isWindow, const QRect &r) const;
void drawBackground(QPainter *p, const QWidget *widget, BackgroundType type) const;
QPainterPath buildPath(const QRectF &r, EWidget w, int round, double radius) const;
QPainterPath buildPath(const QRect &r, EWidget w, int round, double radius) const;
void buildSplitPath(const QRect &r, int round, double radius, QPainterPath &tl, QPainterPath &br) const;
void drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, int round, const QColor *custom=0,
EWidget w=WIDGET_OTHER, EBorder borderProfile=BORDER_FLAT, bool doBlend=true, int borderVal=STD_BORDER) const;
void drawMdiControl(QPainter *p, const QStyleOptionTitleBar *titleBar, SubControl sc, const QWidget *widget,
ETitleBarButtons btn, const QColor &iconColor, const QColor *btnCols, const QColor *bgndCols,
int adjust, bool activeWindow) const;
void drawDwtControl(QPainter *p, const QFlags<State> &state, const QRect &rect, ETitleBarButtons btn, Icon icon,
const QColor &iconColor, const QColor *btnCols, const QColor *bgndCols) const;
bool drawMdiButton(QPainter *painter, const QRect &r, bool hover, bool sunken, const QColor *cols) const;
void drawMdiIcon(QPainter *painter, const QColor &color, const QColor &bgnd, const QRect &r,
bool hover, bool sunken, Icon iclearcon, bool stdSize, bool drewFrame) const;
void drawIcon(QPainter *painter, const QColor &color, const QRect &r, bool sunken, Icon icon, bool stdSize=true) const;
void drawEntryField(QPainter *p, const QRect &rx, const QWidget *widget, const QStyleOption *option, int round,
bool fill, bool doEtch, EWidget w=WIDGET_ENTRY) const;
void drawMenuItem(QPainter *p, const QRect &r, const QStyleOption *option, MenuItemType type, int round, const QColor *cols) const;
void drawProgress(QPainter *p, const QRect &r, const QStyleOption *option, bool vertical=false, bool reverse=false) const;
void drawArrow(QPainter *p, const QRect &rx, PrimitiveElement pe, QColor col, bool small=false, bool kwin=false) const;
void drawSbSliderHandle(QPainter *p, const QRect &r, const QStyleOption *option, bool slider=false) const;
void drawSliderHandle(QPainter *p, const QRect &r, const QStyleOptionSlider *option) const;
void drawSliderGroove(QPainter *p, const QRect &groove, const QRect &handle, const QStyleOptionSlider *slider, const QWidget *widget) const;
int getOpacity(const QWidget *widget, QPainter *p) const;
void drawMenuOrToolBarBackground(const QWidget *widget, QPainter *p, const QRect &r, const QStyleOption *option, bool menu=true,
bool horiz=true) const;
void drawHandleMarkers(QPainter *p, const QRect &r, const QStyleOption *option, bool tb, ELine handles) const;
void fillTab(QPainter *p, const QRect &r, const QStyleOption *option, const QColor &fill, bool horiz, EWidget tab, bool tabOnly) const;
void colorTab(QPainter *p, const QRect &r, bool horiz, EWidget tab, int round) const;
void shadeColors(const QColor &base, QColor *vals) const;
const QColor * buttonColors(const QStyleOption *option) const;
QColor titlebarIconColor(const QStyleOption *option) const;
const QColor * popupMenuCols(const QStyleOption *option=0L) const;
const QColor * checkRadioColors(const QStyleOption *option) const;
const QColor * sliderColors(const QStyleOption *option) const;
const QColor * backgroundColors(const QColor &col) const;
const QColor * backgroundColors(const QStyleOption *option) const
{ return option ? backgroundColors(option->palette.background().color()) : itsBackgroundCols; }
const QColor * highlightColors(const QColor &col) const;
const QColor * highlightColors(const QStyleOption *option, bool useActive) const
{ return highlightColors(option->palette.brush(useActive ? QPalette::Active : QPalette::Current, QPalette::Highlight).color()); }
const QColor * borderColors(const QStyleOption *option, const QColor *use) const;
const QColor * getSidebarButtons() const;
void setMenuColors(const QColor &bgnd);
void setMenuTextColors(QWidget *widget, bool isMenuBar) const;
const QColor * menuColors(const QStyleOption *option, bool active) const;
bool coloredMdiButtons(bool active, bool mouseOver) const;
const QColor * getMdiColors(const QStyleOption *option, bool active) const;
void readMdiPositions() const;
const QColor & getFill(const QStyleOption *option, const QColor *use, bool cr=false, bool darker=false) const;
const QColor & getTabFill(bool current, bool highlight, const QColor *use) const;
QColor menuStripeCol() const;
QPixmap * getPixmap(const QColor col, EPixmap p, double shade=1.0) const;
int konqMenuBarSize(const QMenuBar *menu) const;
const QColor & checkRadioCol(const QStyleOption *opt) const;
QColor shade(const QColor &a, double k) const;
void shade(const color &ca, color *cb, double k) const;
QColor getLowerEtchCol(const QWidget *widget) const;
int getFrameRound(const QWidget *widget) const;
void unregisterArgbWidget(QWidget *w);
private Q_SLOTS:
void widgetDestroyed(QObject *o);
QIcon standardIconImplementation(StandardPixmap pix, const QStyleOption *option=0, const QWidget *widget=0) const;
int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
Qt::Orientation orientation, const QStyleOption *option,
const QWidget *widget) const;
void kdeGlobalSettingsChange(int type, int);
void borderSizesChanged();
void toggleMenuBar(unsigned int xid);
void toggleStatusBar(unsigned int xid);
void compositingToggled();
private:
void toggleMenuBar(QMainWindow *window);
void toggleStatusBar(QMainWindow *window);
#if !defined QTC_QT_ONLY
void setupKde4();
void setDecorationColors();
void applyKdeSettings(bool pal);
#endif
#ifdef Q_WS_X11
bool isWindowDragWidget(QObject *o);
void emitMenuSize(QWidget *w, unsigned short size, bool force=false);
void emitStatusBarState(QStatusBar *sb);
#endif
private:
mutable Options opts;
QColor itsHighlightCols[TOTAL_SHADES+1],
itsBackgroundCols[TOTAL_SHADES+1],
itsMenubarCols[TOTAL_SHADES+1],
itsFocusCols[TOTAL_SHADES+1],
itsMouseOverCols[TOTAL_SHADES+1],
*itsPopupMenuCols,
*itsSliderCols,
*itsDefBtnCols,
*itsComboBtnCols,
*itsCheckRadioSelCols,
*itsSortedLvColors,
*itsOOMenuCols,
*itsProgressCols,
itsButtonCols[TOTAL_SHADES+1],
itsCheckRadioCol;
bool itsSaveMenuBarStatus,
itsSaveStatusBarStatus,
itsUsePixmapCache,
itsInactiveChangeSelectionColor;
PreviewType itsIsPreview;
mutable QColor *itsSidebarButtonsCols;
mutable QColor *itsActiveMdiColors;
mutable QColor *itsMdiColors;
mutable QColor itsActiveMdiTextColor;
mutable QColor itsMdiTextColor;
mutable QColor itsColoredButtonCols[TOTAL_SHADES+1];
mutable QColor itsColoredBackgroundCols[TOTAL_SHADES+1];
mutable QColor itsColoredHighlightCols[TOTAL_SHADES+1];
mutable QCache<QtcKey, QPixmap> itsPixmapCache;
mutable bool itsActive;
mutable const QWidget *itsSbWidget;
mutable QLabel *itsClickedLabel;
QSet<QProgressBar *> itsProgressBars;
QSet<QWidget *> itsTransparentWidgets;
int itsProgressBarAnimateTimer,
itsAnimateStep;
QTime itsTimer;
mutable QMap<int, QColor *> itsTitleBarButtonsCols;
#ifdef QTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
mutable QMap<QWidget *, QWidget *> itsReparentedDialogs;
#endif
mutable QList<int> itsMdiButtons[2]; // 0=left, 1=right
mutable int itsTitlebarHeight;
// Required for Q3Header hover...
QPoint itsPos;
QWidget *itsHoverWidget;
#ifdef Q_WS_X11
QDBusInterface *itsDBus;
QtCurve::ShadowHelper *itsShadowHelper;
#endif
mutable QScrollBar *itsSViewSBar;
mutable QMap<QWidget *, QSet<QWidget *> > itsSViewContainers;
#if !defined QTC_QT_ONLY
KComponentData itsComponentData;
#endif
QtCurve::WindowManager *itsWindowManager;
QtCurve::BlurHelper *itsBlurHelper;
QtCurve::ShortcutHandler *itsShortcutHandler;
#ifdef QTC_STYLE_SUPPORT
QString itsName;
#endif
};
}
#endif

View File

@ -0,0 +1,10 @@
[Misc]
Name=QtCurve
Comment=Highly configurable style
Comment[zh_CN]=可高度定制的风格
Comment[zh_HK]=可高度定制的樣式
Comment[zh_TW]=可高度定制的樣式
ConfigPage=kstyle_qtcurve_config
[KDE]
WidgetStyle=QtCurve

320
src/qtcurve/style/shadow.h Normal file
View File

@ -0,0 +1,320 @@
#ifndef _QEMBED_1804289383
#define _QEMBED_1804289383
static const unsigned int shadow0_png_len = 243;
static const unsigned char shadow0_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0x36,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,0x2a,0x2a,0x2a,
0x48,0x48,0x24,0x38,0x38,0x38,0x3f,0x3f,0x2a,0x36,0x36,0x36,0x3c,0x3c,
0x3c,0x39,0x39,0x39,0x3a,0x3a,0x31,0x3c,0x3c,0x34,0x39,0x39,0x34,0x3a,
0x36,0x36,0x37,0x37,0x35,0x00,0x32,0xd6,0xf3,0x00,0x00,0x00,0x12,0x74,
0x52,0x4e,0x53,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x09,0x0c,0x0e,
0x11,0x16,0x1a,0x22,0x31,0x46,0x65,0xc3,0x39,0x93,0x78,0x00,0x00,0x00,
0x36,0x49,0x44,0x41,0x54,0x48,0xc7,0x63,0x60,0x18,0x05,0xa3,0x60,0x14,
0x8c,0x82,0x51,0x40,0x03,0xc0,0xc8,0x48,0x96,0x36,0x26,0x86,0xe1,0xab,
0x8d,0x85,0x71,0xd4,0x6f,0x03,0x1a,0x24,0x43,0xc2,0xb6,0xe1,0x1c,0x92,
0x43,0x43,0x1b,0xd3,0x30,0xf6,0xdb,0x9f,0x21,0x50,0x75,0x00,0x00,0xde,
0xc1,0x01,0x63,0xb8,0x00,0x44,0xf1,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,
0x44,0xae,0x42,0x60,0x82
};
/* Generated by qembed */
static const unsigned int shadow1_png_len = 632;
static const unsigned char shadow1_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0xb7,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,0x2a,0x2a,0x2a,
0x48,0x48,0x24,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x33,0x33,0x33,0x2e,0x2e,
0x2e,0x2a,0x2a,0x2a,0x3f,0x3f,0x2a,0x3a,0x3a,0x3a,0x36,0x36,0x36,0x44,
0x33,0x33,0x44,0x44,0x33,0x3f,0x3f,0x3f,0x3c,0x3c,0x3c,0x38,0x38,0x38,
0x35,0x35,0x35,0x3c,0x3c,0x30,0x39,0x39,0x39,0x37,0x37,0x37,0x35,0x35,
0x35,0x33,0x33,0x33,0x3d,0x33,0x33,0x38,0x38,0x38,0x36,0x36,0x36,0x34,
0x34,0x34,0x33,0x33,0x33,0x39,0x39,0x31,0x3d,0x36,0x36,0x3c,0x3c,0x34,
0x38,0x38,0x38,0x3a,0x3a,0x34,0x39,0x39,0x33,0x36,0x36,0x36,0x37,0x37,
0x31,0x3a,0x3a,0x35,0x39,0x39,0x34,0x38,0x38,0x38,0x3a,0x35,0x35,0x37,
0x37,0x37,0x3a,0x35,0x35,0x3a,0x3a,0x36,0x39,0x39,0x35,0x37,0x37,0x37,
0x3a,0x36,0x36,0x37,0x37,0x33,0x36,0x36,0x33,0x38,0x38,0x34,0x39,0x39,
0x33,0x3a,0x37,0x34,0x39,0x36,0x36,0x38,0x38,0x33,0x38,0x38,0x36,0x37,
0x37,0x35,0x39,0x37,0x34,0x39,0x37,0x35,0x00,0x16,0x19,0x9e,0x00,0x00,
0x00,0x3d,0x74,0x52,0x4e,0x53,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0c,0x0d,0x0e,0x0f,0x0f,0x10,0x11,0x12,0x13,
0x15,0x16,0x17,0x18,0x19,0x19,0x1b,0x1c,0x1d,0x1e,0x1f,0x21,0x22,0x24,
0x27,0x28,0x2a,0x2e,0x30,0x31,0x32,0x34,0x37,0x39,0x3d,0x3e,0x40,0x46,
0x4a,0x4b,0x4d,0x50,0x53,0x54,0x5e,0x63,0x65,0x66,0x6e,0x2d,0xaa,0x55,
0x29,0x00,0x00,0x01,0x0f,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0xd1,0xd9,
0x72,0x83,0x20,0x18,0x86,0x61,0x25,0xb1,0x89,0x92,0x88,0x62,0xd5,0xa6,
0x6d,0x6c,0x9b,0xbd,0x5b,0xba,0xef,0xbd,0xff,0xeb,0x2a,0x20,0xa2,0x76,
0x14,0xc1,0x99,0x9c,0xf1,0x9e,0x3f,0xf3,0xfd,0xa2,0x65,0x99,0x4c,0x26,
0x93,0xe9,0x10,0xd9,0xbc,0x9e,0x4c,0x53,0xda,0xb5,0x7a,0x32,0x65,0x68,
0xdb,0xbd,0x20,0x60,0x69,0x43,0x20,0xd2,0x72,0xa0,0x9a,0x3a,0x04,0xa0,
0x19,0x76,0xb0,0x41,0x9e,0xae,0x1b,0xd2,0x6a,0x52,0xc9,0x0d,0x8b,0x4a,
0xa8,0xe2,0x1c,0xda,0x3f,0xa8,0xe0,0x1c,0x1e,0x87,0xb5,0x41,0x09,0x3b,
0xa2,0x95,0xb2,0x3e,0xd8,0xce,0x46,0x24,0x21,0x4b,0xd7,0x75,0xa6,0x3b,
0x26,0x31,0xa9,0xe5,0x5c,0x1a,0x97,0x0d,0xae,0x8d,0x4d,0x27,0x10,0x7a,
0x39,0xd4,0x71,0x88,0x44,0xa8,0x27,0xa0,0x70,0x52,0x16,0x61,0x1c,0x06,
0xc8,0x87,0x1e,0x85,0xc2,0x75,0xce,0xa5,0x69,0x12,0x47,0x38,0x40,0x53,
0x58,0x71,0xd5,0x33,0x9b,0xd9,0x62,0x91,0xcd,0xd2,0x18,0x87,0xc2,0x39,
0xa5,0x93,0xcc,0x5d,0x6f,0x37,0xcb,0x6c,0x96,0x44,0x21,0x9a,0x40,0x97,
0xbb,0xe2,0x4c,0x09,0x7b,0x7a,0xbc,0xdb,0xad,0x2f,0x89,0xc3,0x08,0x32,
0x57,0x3d,0xb3,0x9d,0x7d,0x7f,0xbe,0xed,0x6f,0x57,0xd9,0x29,0xd9,0xf3,
0xd9,0x9f,0x28,0xce,0x94,0xcf,0x9d,0xbf,0xfc,0x7c,0xec,0x6f,0x96,0xf3,
0x93,0x18,0x07,0xf9,0x7f,0x50,0x9b,0xb3,0x5e,0xbf,0x9e,0xef,0x37,0x17,
0x67,0xc9,0x71,0xe8,0xb3,0xcf,0x1b,0xa9,0xb1,0xec,0xf7,0xfd,0x61,0x77,
0x35,0x27,0xcf,0xc9,0x5f,0x93,0xcf,0xc9,0xd8,0x1f,0xae,0x80,0x13,0xce,
0x98,0x27,0x21,0xc2,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,
0x60,0x82
};
static const unsigned int shadow2_png_len = 262;
static const unsigned char shadow2_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0x45,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x13,0x00,
0x00,0x00,0x7f,0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,
0x2a,0x2a,0x2a,0x48,0x48,0x24,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x2e,0x2e,
0x2e,0x3f,0x3f,0x2a,0x44,0x33,0x33,0x3f,0x3f,0x3f,0x35,0x35,0x35,0x35,
0x35,0x35,0x34,0x34,0x34,0x3a,0x3a,0x32,0x37,0x37,0x37,0x37,0x37,0x37,
0x37,0x37,0x34,0x38,0x38,0x36,0x58,0x89,0x9a,0x95,0x00,0x00,0x00,0x17,
0x74,0x52,0x4e,0x53,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0b,0x0c,0x0f,0x10,0x13,0x18,0x1d,0x23,0x33,0x40,0x58,0x71,0xb6,
0x80,0xa9,0xcd,0x00,0x00,0x00,0x35,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,
0xcb,0xa1,0x0d,0x00,0x20,0x14,0xc4,0xd0,0x7e,0x12,0x06,0x60,0xff,0x5d,
0x39,0x1c,0x24,0x04,0x85,0x6e,0x4d,0xd5,0x2b,0x18,0x3d,0x27,0xc2,0x1e,
0x10,0x00,0x26,0x57,0xd5,0xf8,0x4a,0x26,0x93,0xc9,0x64,0x32,0x99,0x4c,
0x26,0x93,0xbd,0x5b,0xd9,0x06,0x15,0x6d,0x40,0x49,0x97,0xb4,0x00,0x00,
0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
static const unsigned int shadow3_png_len = 825;
static const unsigned char shadow3_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0xf3,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x12,0xed,0x7f,
0x7f,0xf6,0x55,0x57,0xa4,0x3f,0x3f,0xfb,0x33,0x33,0xfc,0x2a,0x2b,0x52,
0x48,0x4a,0xb4,0x3f,0x3f,0x7d,0x38,0x3a,0x36,0x33,0x33,0xfe,0x2e,0x2f,
0xcf,0x2a,0x2b,0xa9,0x3f,0x3f,0xa9,0x3a,0x3b,0x9b,0x36,0x37,0x7e,0x44,
0x33,0x65,0x44,0x45,0x65,0x3f,0x3f,0x5e,0x3c,0x3d,0x4a,0x38,0x39,0x37,
0x35,0x35,0x27,0x3f,0x33,0x18,0x3c,0x3c,0xff,0x39,0x39,0xff,0x37,0x37,
0xf3,0x35,0x35,0xe9,0x33,0x33,0xe0,0x3d,0x33,0xe0,0x3a,0x3a,0xd7,0x36,
0x36,0xd1,0x34,0x34,0xca,0x33,0x33,0xc3,0x39,0x31,0xbd,0x39,0x39,0xbd,
0x37,0x37,0xb7,0x3d,0x36,0xb9,0x3c,0x3c,0xac,0x3a,0x3a,0xa7,0x38,0x38,
0xaa,0x3c,0x35,0xa1,0x3a,0x3a,0x9c,0x37,0x37,0x95,0x37,0x37,0x9b,0x36,
0x36,0x97,0x39,0x34,0x90,0x37,0x37,0x8a,0x3b,0x3b,0x87,0x3a,0x3a,0x84,
0x39,0x39,0x82,0x37,0x37,0x82,0x38,0x38,0x7a,0x37,0x37,0x78,0x37,0x37,
0x7d,0x36,0x36,0x7a,0x3b,0x37,0x72,0x39,0x39,0x6f,0x37,0x37,0x6b,0x37,
0x37,0x6f,0x3a,0x36,0x6d,0x39,0x39,0x6c,0x38,0x38,0x69,0x3a,0x36,0x69,
0x38,0x38,0x66,0x37,0x37,0x60,0x39,0x35,0x61,0x39,0x39,0x61,0x39,0x39,
0x5c,0x37,0x37,0x5d,0x39,0x39,0x5d,0x38,0x38,0x5b,0x37,0x37,0x56,0x39,
0x37,0x54,0x37,0x37,0x50,0x38,0x38,0x50,0x3a,0x37,0x50,0x3a,0x38,0x4f,
0x38,0x38,0x4e,0x39,0x36,0x4a,0x37,0x37,0x4b,0x3a,0x37,0x48,0x8a,0x22,
0xb0,0xc3,0x00,0x00,0x00,0x51,0x74,0x52,0x4e,0x53,0x00,0x01,0x02,0x03,
0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0c,0x0d,0x0e,0x0f,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x19,0x1a,0x1c,0x1d,
0x1e,0x1f,0x1f,0x20,0x21,0x22,0x23,0x24,0x26,0x27,0x29,0x29,0x2a,0x2c,
0x2e,0x2f,0x30,0x31,0x33,0x36,0x37,0x37,0x38,0x3c,0x3e,0x40,0x40,0x41,
0x42,0x44,0x46,0x48,0x4a,0x4c,0x4c,0x50,0x52,0x55,0x56,0x58,0x61,0x65,
0x68,0x69,0x6d,0x71,0x74,0x77,0x7b,0x7c,0xdb,0xec,0x46,0x00,0x00,0x01,
0x80,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0x95,0xb1,0x72,0x83,0x30,0x10,
0x44,0xf7,0xf0,0x35,0xf9,0x8a,0x74,0x49,0x97,0x99,0xfc,0xff,0x67,0x25,
0x85,0x0d,0xba,0xdd,0x14,0x48,0x20,0xc0,0x80,0xec,0x99,0x74,0x96,0xc7,
0x2e,0xec,0x7b,0x7e,0xab,0xd3,0x01,0x06,0xbc,0x7f,0xf5,0x3f,0xd7,0xdf,
0xdb,0x30,0x04,0x83,0x20,0x24,0x09,0x82,0x04,0x40,0xc0,0xf4,0x59,0xaf,
0x0e,0xf8,0x10,0x3b,0x98,0x75,0xd6,0x99,0x75,0xb0,0xe9,0x27,0xcb,0xef,
0x7b,0xcb,0xdf,0x3f,0xdf,0xfa,0x08,0xc1,0x60,0x30,0x13,0x00,0x98,0x4c,
0x26,0x1c,0x2d,0xff,0x66,0x62,0x30,0xa0,0xfc,0x9a,0x65,0x47,0xa0,0xf7,
0xe4,0x90,0x52,0x50,0x34,0x58,0x16,0x9d,0xa8,0x00,0x78,0xaf,0x48,0xc3,
0x10,0x5a,0xb9,0xce,0xb1,0x21,0x86,0x08,0x8a,0x82,0x4e,0xa2,0x55,0xd8,
0x95,0x8c,0x48,0x8c,0x18,0x65,0x8d,0x42,0xbf,0x49,0x11,0x91,0x48,0xe8,
0x81,0x94,0xde,0x4b,0x64,0x62,0x12,0xa5,0x07,0xf6,0x96,0x40,0x32,0x28,
0xe6,0xa9,0x68,0x6b,0x8d,0xf7,0x90,0x48,0x11,0x04,0xab,0xfa,0x13,0xd6,
0x43,0x92,0x24,0x0a,0x2c,0xb5,0x0d,0x3a,0x4f,0x80,0x40,0x49,0x12,0xca,
0x00,0x63,0x1a,0xe0,0x3d,0xde,0x05,0x49,0x79,0xea,0x77,0x5c,0xba,0x17,
0x12,0x40,0xe6,0x66,0xe5,0x69,0x4e,0x07,0x91,0xc3,0x69,0xea,0xe5,0x9e,
0xa3,0xc2,0x38,0x43,0x39,0x6f,0xa5,0xda,0x45,0x7d,0x8c,0x35,0x6f,0x4e,
0x9b,0x0b,0x5a,0x3b,0xb6,0xd1,0x37,0x3a,0x27,0xd9,0xf1,0x80,0xba,0xca,
0xd6,0x50,0x07,0x3c,0x3b,0x38,0xcf,0xad,0x2b,0x9e,0xb9,0x95,0xfb,0xf7,
0x9f,0x29,0x64,0xa9,0xd4,0x79,0xbc,0x72,0x00,0x98,0xfe,0x5b,0x59,0xbb,
0xd0,0x08,0x07,0x36,0x94,0xbd,0x95,0xbc,0x4d,0xb6,0x71,0x52,0x96,0xd4,
0x91,0xac,0x74,0xb2,0x44,0x6b,0xa4,0xe0,0xaa,0x0a,0xaa,0xe1,0xd2,0xf9,
0x01,0x2c,0xc1,0x9a,0xd2,0x21,0x36,0x55,0x68,0x99,0x4d,0x87,0x2d,0xa9,
0xaa,0x1a,0xa9,0xa5,0xad,0xe5,0x92,0x59,0xdb,0xb4,0x9e,0xf8,0x23,0xfa,
0x62,0xab,0x12,0xa1,0x81,0x2a,0xd8,0x63,0x50,0x0e,0xb9,0xad,0x6d,0x19,
0xe5,0x6d,0x65,0xd3,0x4c,0xae,0xcb,0x1a,0x3a,0x79,0xd9,0x7e,0xd5,0xf2,
0x00,0xf1,0x67,0xa0,0x0d,0xd6,0xfa,0xa8,0xf2,0x27,0x98,0x0a,0x7b,0x00,
0x79,0xad,0xd7,0xfa,0xd7,0xf5,0x07,0x87,0x35,0x6e,0x77,0xf8,0xc7,0x73,
0x23,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
static const unsigned int shadow4_png_len = 297;
static const unsigned char shadow4_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0x57,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,0x2a,0x2a,0x2a,
0x48,0x48,0x24,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x2e,0x2e,0x2e,0x3f,0x3f,
0x2a,0x3a,0x3a,0x3a,0x36,0x36,0x36,0x44,0x44,0x33,0x3f,0x3f,0x3f,0x38,
0x38,0x38,0x3c,0x3c,0x30,0x39,0x39,0x39,0x3d,0x32,0x32,0x34,0x34,0x34,
0x3c,0x3c,0x34,0x3a,0x3a,0x34,0x3b,0x3b,0x36,0x36,0x36,0x36,0x3a,0x36,
0x36,0x37,0x37,0x34,0x38,0x38,0x35,0x3a,0x37,0x33,0x1e,0xab,0x31,0x76,
0x00,0x00,0x00,0x1d,0x74,0x52,0x4e,0x53,0x00,0x01,0x02,0x03,0x04,0x05,
0x06,0x07,0x08,0x09,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x12,0x15,0x16,0x19,
0x1d,0x22,0x27,0x2f,0x38,0x46,0x52,0x68,0x7b,0xd0,0xa6,0x2f,0x41,0x00,
0x00,0x00,0x40,0x49,0x44,0x41,0x54,0x48,0xc7,0x63,0x60,0xa0,0x27,0x60,
0x14,0x21,0x4b,0x1b,0x0b,0x07,0x79,0xda,0xfe,0x8f,0x6a,0x1b,0xd5,0x36,
0xb8,0xb4,0x31,0x31,0x8c,0x06,0xc9,0x08,0x8a,0x80,0xd1,0xe8,0x1e,0x9a,
0x11,0xc0,0xcc,0x48,0x4f,0x6d,0x64,0x3a,0x92,0xbe,0xda,0x98,0x19,0x86,
0xaf,0xdf,0xc8,0xd4,0x36,0x0a,0x46,0x01,0xcd,0x00,0x00,0xa7,0x1f,0x18,
0x8d,0x3d,0xb2,0x05,0x84,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,
0x42,0x60,0x82
};
static const unsigned int shadow5_png_len = 807;
static const unsigned char shadow5_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0xf3,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,0x2a,0x2a,0x2a,
0x48,0x48,0x24,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x33,0x33,0x33,0x2e,0x2e,
0x2e,0x2a,0x2a,0x2a,0x3f,0x3f,0x2a,0x3a,0x3a,0x3a,0x36,0x36,0x36,0x44,
0x33,0x33,0x44,0x44,0x33,0x3f,0x3f,0x3f,0x3c,0x3c,0x3c,0x38,0x38,0x38,
0x35,0x35,0x35,0x3f,0x33,0x33,0x3c,0x3c,0x30,0x39,0x39,0x39,0x37,0x37,
0x37,0x35,0x35,0x35,0x33,0x33,0x33,0x3d,0x33,0x33,0x3a,0x3a,0x31,0x36,
0x36,0x36,0x34,0x34,0x34,0x33,0x33,0x33,0x39,0x31,0x31,0x39,0x39,0x31,
0x37,0x37,0x2f,0x3d,0x36,0x36,0x3c,0x3c,0x34,0x3a,0x3a,0x33,0x38,0x38,
0x38,0x3c,0x35,0x35,0x3a,0x3a,0x34,0x37,0x37,0x31,0x37,0x37,0x37,0x36,
0x36,0x36,0x39,0x34,0x34,0x37,0x37,0x31,0x3b,0x3b,0x36,0x3a,0x3a,0x35,
0x39,0x39,0x34,0x37,0x37,0x37,0x38,0x38,0x33,0x37,0x37,0x33,0x37,0x37,
0x37,0x36,0x36,0x36,0x3b,0x37,0x33,0x39,0x39,0x35,0x37,0x37,0x33,0x37,
0x37,0x37,0x3a,0x36,0x36,0x39,0x39,0x36,0x38,0x38,0x34,0x3a,0x36,0x36,
0x38,0x38,0x35,0x37,0x37,0x33,0x39,0x35,0x35,0x39,0x39,0x35,0x39,0x39,
0x33,0x37,0x37,0x34,0x39,0x39,0x36,0x38,0x38,0x35,0x37,0x37,0x34,0x39,
0x37,0x34,0x37,0x37,0x35,0x38,0x38,0x35,0x3a,0x37,0x35,0x3a,0x38,0x35,
0x38,0x38,0x36,0x39,0x36,0x34,0x38,0x38,0x36,0x3a,0x37,0x33,0x37,0x71,
0x96,0x1c,0x00,0x00,0x00,0x51,0x74,0x52,0x4e,0x53,0x00,0x01,0x02,0x03,
0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0c,0x0d,0x0e,0x0f,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x19,0x1a,0x1c,0x1d,
0x1e,0x1f,0x1f,0x20,0x21,0x22,0x23,0x24,0x26,0x27,0x29,0x29,0x2a,0x2c,
0x2e,0x2f,0x30,0x31,0x33,0x36,0x37,0x37,0x38,0x3c,0x3e,0x40,0x40,0x41,
0x42,0x44,0x46,0x48,0x4a,0x4c,0x4c,0x50,0x52,0x55,0x56,0x58,0x61,0x65,
0x68,0x69,0x6d,0x71,0x74,0x76,0x7b,0x65,0xc0,0xdd,0x07,0x00,0x00,0x01,
0x6e,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0x95,0x49,0x76,0x83,0x30,0x10,
0x44,0xab,0xaa,0x71,0x86,0xf7,0x92,0x0b,0x64,0x91,0x65,0xee,0x7f,0x95,
0x5c,0x21,0xd7,0x88,0xad,0xca,0x42,0x58,0xb2,0x41,0x08,0x91,0xb5,0x1b,
0x1e,0x63,0x7f,0xaa,0x27,0x80,0x58,0x19,0xcb,0x96,0x04,0x41,0x92,0x10,
0x14,0x8a,0xd3,0xe9,0xf9,0xed,0xe5,0xfd,0xe9,0xfb,0x07,0x42,0xdb,0x58,
0xf8,0x7c,0x26,0x52,0x14,0x09,0x25,0x7f,0x01,0xb1,0xa1,0x96,0x31,0x12,
0x84,0x40,0x92,0x12,0x15,0x11,0xa7,0x08,0xbd,0x7e,0x5e,0xba,0x18,0x31,
0x2f,0x24,0x44,0x31,0x34,0x69,0x8a,0xc0,0xd3,0xc7,0x3e,0x36,0xa7,0x46,
0x51,0x94,0x24,0x01,0x29,0x4d,0x18,0x35,0xc3,0xb0,0x2f,0xbf,0x41,0x07,
0xc7,0xd4,0x66,0x49,0x4a,0x10,0x9c,0x30,0xaa,0x66,0x02,0xa6,0x2f,0xe2,
0x99,0x8e,0xb3,0x86,0x83,0x34,0x6d,0xa4,0x74,0x26,0x52,0xe2,0x68,0x90,
0x60,0x5e,0x4d,0xc3,0x29,0xa5,0xb1,0x06,0xcc,0x4d,0x20,0x08,0xc0,0xde,
0xc9,0xcd,0x34,0xeb,0x71,0x8a,0x14,0x09,0xb6,0xc8,0xbd,0x29,0xc1,0x6d,
0x9c,0xf9,0x8e,0x6d,0x7b,0xea,0x96,0xae,0xf6,0x8c,0x26,0x6c,0x20,0x51,
0x66,0x73,0x26,0xdb,0xd3,0xc5,0xeb,0x68,0x1b,0xd8,0xc3,0x0a,0x75,0x3b,
0x2c,0xe8,0x04,0x59,0x22,0x2d,0x95,0x31,0x40,0xcf,0xa0,0x36,0xd5,0xae,
0x51,0x96,0x5a,0xd4,0x10,0x09,0x07,0x46,0xa2,0x44,0x49,0x8d,0x30,0x6c,
0x6c,0x63,0x0b,0x39,0xde,0x5e,0xf6,0x1e,0x76,0x05,0xe6,0x9d,0x3b,0x95,
0x6c,0x70,0x28,0x09,0x1a,0x06,0x30,0x0d,0xbd,0x31,0xb9,0xe1,0xf9,0x59,
0x86,0xb7,0xd4,0x16,0x72,0x39,0x9f,0x7c,0x68,0xd4,0x34,0x3b,0x58,0xe1,
0x58,0xcb,0xb9,0x89,0xb5,0xb9,0x79,0x5c,0xb6,0xd5,0x9a,0x5c,0xc5,0xf7,
0xb0,0xfb,0x2a,0xd6,0x87,0x6d,0x62,0x0b,0xee,0x0e,0xea,0xa8,0x2d,0xb2,
0x67,0x9d,0x38,0xf4,0xb1,0x25,0x77,0x7b,0x3e,0x80,0xb5,0xdc,0x7b,0xd8,
0xda,0x89,0x23,0x6a,0x4b,0xff,0x65,0x63,0x8e,0x81,0x23,0xd8,0x4a,0x67,
0x10,0x6b,0x7b,0x73,0xe0,0xaf,0xc1,0xf6,0x17,0xe3,0x20,0x37,0x8c,0xad,
0xdd,0x06,0xb1,0xc3,0x95,0x6c,0xfb,0x1e,0xc1,0xfe,0xe3,0xff,0xb0,0x87,
0x1d,0xb5,0x3f,0xf4,0x3b,0x5c,0xd6,0x3e,0xab,0x62,0x7a,0x00,0x00,0x00,
0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
static const unsigned int shadow6_png_len = 260;
static const unsigned char shadow6_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0x45,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,0x2a,0x2a,0x2a,
0x48,0x48,0x24,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x2e,0x2e,0x2e,0x3f,0x3f,
0x2a,0x44,0x33,0x33,0x3f,0x3f,0x3f,0x35,0x35,0x35,0x35,0x35,0x35,0x36,
0x36,0x36,0x34,0x34,0x34,0x3a,0x3a,0x32,0x37,0x37,0x37,0x37,0x37,0x37,
0x37,0x37,0x34,0x38,0x38,0x36,0x84,0xea,0xd7,0xaa,0x00,0x00,0x00,0x17,
0x74,0x52,0x4e,0x53,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x0b,0x0c,0x0f,0x10,0x13,0x18,0x1c,0x1d,0x23,0x33,0x40,0x58,0x71,0xe5,
0xe3,0x45,0xdc,0x00,0x00,0x00,0x33,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,
0xcb,0x21,0x02,0x00,0x30,0x08,0xc3,0xc0,0x86,0xff,0x3f,0x16,0x3d,0x35,
0x87,0xd9,0x14,0x3a,0x11,0xad,0x3a,0xf2,0xc4,0x2c,0x84,0xc0,0x1c,0x05,
0xc0,0xe9,0x54,0x56,0xc9,0x64,0x32,0x99,0x4c,0x26,0x93,0xc9,0x64,0xb2,
0x7f,0x17,0x4b,0xb1,0x02,0x6c,0xc7,0x80,0xd6,0xd0,0x00,0x00,0x00,0x00,
0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
static const unsigned int shadow7_png_len = 591;
static const unsigned char shadow7_png_data[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,
0x44,0x52,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x36,0x08,0x03,0x00,0x00,
0x00,0xbb,0x9b,0x9a,0xef,0x00,0x00,0x00,0x03,0x73,0x42,0x49,0x54,0x08,
0x08,0x08,0xdb,0xe1,0x4f,0xe0,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x89,0x00,0x00,0x0b,0x89,0x01,0x37,0xc9,0xcb,0xad,0x00,
0x00,0x00,0xb7,0x50,0x4c,0x54,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x7f,0x7f,0x55,0x55,0x55,0x3f,0x3f,0x3f,0x33,0x33,0x33,0x2a,0x2a,0x2a,
0x48,0x48,0x24,0x3f,0x3f,0x3f,0x38,0x38,0x38,0x33,0x33,0x33,0x2e,0x2e,
0x2e,0x2a,0x2a,0x2a,0x3f,0x3f,0x2a,0x3a,0x3a,0x3a,0x36,0x36,0x36,0x44,
0x33,0x33,0x44,0x44,0x33,0x3f,0x3f,0x3f,0x3c,0x3c,0x3c,0x38,0x38,0x38,
0x35,0x35,0x35,0x3c,0x3c,0x30,0x39,0x39,0x39,0x37,0x37,0x37,0x35,0x35,
0x35,0x33,0x33,0x33,0x3d,0x33,0x33,0x3a,0x3a,0x31,0x36,0x36,0x36,0x34,
0x34,0x34,0x33,0x33,0x33,0x39,0x39,0x31,0x3d,0x36,0x36,0x3c,0x3c,0x34,
0x38,0x38,0x38,0x3a,0x3a,0x34,0x39,0x39,0x33,0x36,0x36,0x36,0x37,0x37,
0x31,0x3a,0x3a,0x35,0x39,0x39,0x34,0x38,0x38,0x38,0x3a,0x35,0x35,0x37,
0x37,0x37,0x3a,0x35,0x35,0x3a,0x3a,0x36,0x39,0x39,0x35,0x37,0x37,0x37,
0x3a,0x36,0x36,0x37,0x37,0x34,0x37,0x37,0x33,0x39,0x36,0x36,0x39,0x39,
0x33,0x3a,0x37,0x34,0x39,0x36,0x36,0x38,0x38,0x33,0x38,0x38,0x36,0x37,
0x37,0x35,0x39,0x37,0x34,0x39,0x37,0x35,0x69,0x11,0xda,0xe4,0x00,0x00,
0x00,0x3d,0x74,0x52,0x4e,0x53,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0c,0x0d,0x0e,0x0f,0x0f,0x10,0x11,0x12,0x13,
0x15,0x16,0x17,0x18,0x19,0x19,0x1a,0x1c,0x1d,0x1e,0x1f,0x21,0x22,0x24,
0x27,0x28,0x2a,0x2e,0x30,0x31,0x32,0x34,0x37,0x39,0x3d,0x3e,0x40,0x46,
0x49,0x4a,0x4b,0x50,0x53,0x54,0x5e,0x63,0x65,0x66,0x6e,0x1e,0x62,0xb1,
0x6f,0x00,0x00,0x00,0xe6,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0x94,0x41,
0x8e,0x83,0x30,0x10,0x04,0xa7,0xba,0xc7,0x89,0xf2,0xff,0x7f,0xe5,0x1f,
0xbb,0x1f,0x58,0xed,0x6d,0x0f,0x60,0x04,0x84,0x60,0xc7,0xd2,0xde,0xe8,
0x03,0x70,0x98,0x56,0xf5,0xb4,0x2d,0x22,0x2e,0x5d,0xba,0x74,0xe9,0xd2,
0x3f,0x88,0xb1,0x71,0xc6,0x10,0x8c,0xc5,0x62,0x6c,0x17,0xc6,0x0a,0x60,
0x2c,0x1e,0x63,0x45,0xd0,0x6d,0xe2,0x83,0x90,0xbc,0x99,0xe3,0x43,0x17,
0x1d,0x36,0x8e,0xde,0xb4,0x6c,0xbc,0x10,0xe8,0x08,0xc9,0xbe,0xf2,0x55,
0xf7,0xd9,0xd9,0x3f,0xdb,0x70,0x34,0xe6,0x59,0x99,0x7a,0x68,0x6c,0xbe,
0x59,0x55,0xc1,0x09,0x8d,0x4d,0x77,0x2c,0xc3,0x33,0x37,0xdb,0x8b,0x55,
0x17,0x3b,0xea,0xf9,0x62,0x2b,0x57,0x7d,0x42,0x47,0x93,0x15,0x44,0x04,
0x00,0x7a,0x5b,0x09,0xfb,0x03,0x9b,0x21,0x81,0x01,0x4e,0x77,0x5b,0x55,
0x37,0xbb,0x90,0x10,0x82,0x63,0x1a,0x9b,0x88,0x44,0x2c,0x2e,0x61,0xa9,
0x64,0xf3,0x96,0x4c,0x48,0x26,0xa0,0x24,0xbb,0x14,0xa3,0x3c,0x35,0x2c,
0x11,0x83,0x50,0xd8,0xd8,0xf7,0xe2,0xcc,0xc3,0xdd,0xd8,0xf5,0x38,0xfb,
0x2c,0x9c,0x99,0x37,0xdf,0xad,0x6c,0xc1,0xea,0x11,0x80,0x90,0x5c,0x6e,
0x7e,0xe4,0xcf,0x77,0x76,0xfd,0xef,0x08,0x10,0xc2,0xb2,0x8b,0x7e,0x9f,
0xa1,0xb6,0xa1,0x5e,0x91,0xa9,0x4a,0xd9,0x5f,0x11,0x7f,0xe8,0x0a,0x06,
0x53,0xfb,0x2a,0xa1,0x09,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,
0x42,0x60,0x82
};
#endif

View File

@ -0,0 +1,285 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenshadowhelper.h
// handle shadow _pixmaps passed to window manager via X property
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "shadowhelper.h"
#include "shadow.h"
#include "utils.h"
#include <QtGui/QDockWidget>
#include <QtGui/QMenu>
#include <QtGui/QPainter>
#include <QtGui/QToolBar>
#include <QtCore/QEvent>
#ifdef Q_WS_X11
#include <QtGui/QX11Info>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
namespace QtCurve
{
const char* const ShadowHelper::netWMShadowAtomName( "_KDE_NET_WM_SHADOW" );
const char* const ShadowHelper::netWMForceShadowPropertyName( "_KDE_NET_WM_FORCE_SHADOW" );
const char* const ShadowHelper::netWMSkipShadowPropertyName( "_KDE_NET_WM_SKIP_SHADOW" );
//_____________________________________________________
ShadowHelper::ShadowHelper( QObject* parent ):
QObject( parent ),
#ifdef Q_WS_X11
_atom( None )
#endif
{
createPixmapHandles();
}
//_______________________________________________________
ShadowHelper::~ShadowHelper( void )
{
#ifdef Q_WS_X11
for(int i=0; i<numPixmaps; ++i)
XFreePixmap( QX11Info::display(), _pixmaps[i] );
#endif
}
//_______________________________________________________
bool ShadowHelper::registerWidget( QWidget* widget, bool force )
{
// make sure widget is not already registered
if( _widgets.contains( widget ) ) return false;
// check if widget qualifies
if( !( force || acceptWidget( widget ) ) )
{ return false; }
// store in map and add destroy signal connection
Utils::addEventFilter(widget, this);
_widgets.insert( widget, 0 );
/*
need to install shadow directly when widget "created" state is already set
since WinID changed is never called when this is the case
*/
if( widget->testAttribute(Qt::WA_WState_Created) && installX11Shadows( widget ) )
{ _widgets.insert( widget, widget->winId() ); }
connect( widget, SIGNAL( destroyed( QObject* ) ), SLOT( objectDeleted( QObject* ) ) );
return true;
}
//_______________________________________________________
void ShadowHelper::unregisterWidget( QWidget* widget )
{
if( _widgets.remove( widget ) )
{ uninstallX11Shadows( widget ); }
}
//_______________________________________________________
bool ShadowHelper::eventFilter( QObject* object, QEvent* event )
{
// check event type
if( event->type() != QEvent::WinIdChange ) return false;
// cast widget
QWidget* widget( static_cast<QWidget*>( object ) );
// install shadows and update winId
if( installX11Shadows( widget ) )
{ _widgets.insert( widget, widget->winId() ); }
return false;
}
//_______________________________________________________
void ShadowHelper::objectDeleted( QObject* object )
{ _widgets.remove( static_cast<QWidget*>( object ) ); }
//_______________________________________________________
bool ShadowHelper::isMenu( QWidget* widget ) const
{ return qobject_cast<QMenu*>( widget ); }
//_______________________________________________________
bool ShadowHelper::acceptWidget( QWidget* widget ) const
{
if( widget->property( netWMSkipShadowPropertyName ).toBool() ) return false;
if( widget->property( netWMForceShadowPropertyName ).toBool() ) return true;
// menus
if( qobject_cast<QMenu*>( widget ) ) return true;
// combobox dropdown lists
if( widget->inherits( "QComboBoxPrivateContainer" ) ) return true;
// tooltips
if( (widget->inherits( "QTipLabel" ) || (widget->windowFlags() & Qt::WindowType_Mask) == Qt::ToolTip ) &&
!widget->inherits( "Plasma::ToolTip" ) )
{ return true; }
// detached widgets
if( qobject_cast<QToolBar*>( widget ) || qobject_cast<QDockWidget*>( widget ) )
{ return true; }
// reject
return false;
}
//______________________________________________
void ShadowHelper::createPixmapHandles( )
{
/*!
shadow atom and property specification available at
http://community.kde.org/KWin/Shadow
*/
// create atom
#ifdef Q_WS_X11
if( !_atom ) _atom = XInternAtom( QX11Info::display(), netWMShadowAtomName, False);
#endif
_pixmaps[0]=createPixmap(shadow0_png_data, shadow0_png_len);
_pixmaps[1]=createPixmap(shadow1_png_data, shadow1_png_len);
_pixmaps[2]=createPixmap(shadow2_png_data, shadow2_png_len);
_pixmaps[3]=createPixmap(shadow3_png_data, shadow3_png_len);
_pixmaps[4]=createPixmap(shadow4_png_data, shadow4_png_len);
_pixmaps[5]=createPixmap(shadow5_png_data, shadow5_png_len);
_pixmaps[6]=createPixmap(shadow6_png_data, shadow6_png_len);
_pixmaps[7]=createPixmap(shadow7_png_data, shadow7_png_len);
}
//______________________________________________
Qt::HANDLE ShadowHelper::createPixmap( const uchar *buf, int len )
{
QImage source;
source.loadFromData(buf, len);
// do nothing for invalid _pixmaps
if( source.isNull() ) return 0;
_size=source.width();
/*
in some cases, pixmap handle is invalid. This is the case notably
when Qt uses to RasterEngine. In this case, we create an X11 Pixmap
explicitly and draw the source pixmap on it.
*/
#ifdef Q_WS_X11
const int width( source.width() );
const int height( source.height() );
// create X11 pixmap
Pixmap pixmap = XCreatePixmap( QX11Info::display(), QX11Info::appRootWindow(), width, height, 32 );
// create explicitly shared QPixmap from it
QPixmap dest( QPixmap::fromX11Pixmap( pixmap, QPixmap::ExplicitlyShared ) );
// create surface for pixmap
{
QPainter painter( &dest );
painter.setCompositionMode( QPainter::CompositionMode_Source );
painter.drawImage( 0, 0, source );
}
return pixmap;
#else
return 0;
#endif
}
//_______________________________________________________
bool ShadowHelper::installX11Shadows( QWidget* widget )
{
// check widget and shadow
if( !widget ) return false;
#ifdef Q_WS_X11
#ifndef QT_NO_XRENDER
// TODO: also check for NET_WM_SUPPORTED atom, before installing shadow
/*
From bespin code. Supposibly prevent playing with some 'pseudo-widgets'
that have winId matching some other -random- window
*/
if( !(widget->testAttribute(Qt::WA_WState_Created) || widget->internalWinId() ))
{ return false; }
// create data
// add pixmap handles
QVector<unsigned long> data;
for(int i=0; i<numPixmaps; ++i)
{ data.push_back( _pixmaps[i] ); }
// add padding
data << _size -4 << _size -4 << _size -4 << _size -4;
XChangeProperty(
QX11Info::display(), widget->winId(), _atom, XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<const unsigned char *>(data.constData()), data.size() );
return true;
#endif
#endif
return false;
}
//_______________________________________________________
void ShadowHelper::uninstallX11Shadows( QWidget* widget ) const
{
#ifdef Q_WS_X11
if( !( widget && widget->testAttribute(Qt::WA_WState_Created) ) ) return;
XDeleteProperty(QX11Info::display(), widget->winId(), _atom);
#endif
}
//_______________________________________________________
void ShadowHelper::uninstallX11Shadows( WId id ) const
{
#ifdef Q_WS_X11
XDeleteProperty(QX11Info::display(), id, _atom);
#endif
}
}

View File

@ -0,0 +1,126 @@
#ifndef shadowhelper_h
#define shadowhelper_h
//////////////////////////////////////////////////////////////////////////////
// oxygenshadowhelper.h
// handle shadow pixmaps passed to window manager via X property
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtGui/qwindowdefs.h>
#ifdef Q_WS_X11
#include <X11/Xdefs.h>
#endif
class QPixmap;
namespace QtCurve
{
//! handle shadow pixmaps passed to window manager via X property
class ShadowHelper: public QObject
{
Q_OBJECT
public:
//!@name property names
static const char* const netWMShadowAtomName;
static const char* const netWMForceShadowPropertyName;
static const char* const netWMSkipShadowPropertyName;
//! constructor
ShadowHelper( QObject* );
//! destructor
virtual ~ShadowHelper( void );
//! register widget
bool registerWidget( QWidget*, bool force = false );
//! unregister widget
void unregisterWidget( QWidget* );
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
protected Q_SLOTS:
//! unregister widget
void objectDeleted( QObject* );
protected:
//! true if widget is a menu
bool isMenu( QWidget* ) const;
//! accept widget
bool acceptWidget( QWidget* ) const;
// create pixmap handles from tileset
void createPixmapHandles( );
// create pixmap handle from pixmap
Qt::HANDLE createPixmap( const uchar *buf, int len );
//! install shadow X11 property on given widget
/*!
shadow atom and property specification available at
http://community.kde.org/KWin/Shadow
*/
bool installX11Shadows( QWidget* );
//! uninstall shadow X11 property on given widget
void uninstallX11Shadows( QWidget* ) const;
//! uninstall shadow X11 property on given window
void uninstallX11Shadows( WId ) const;
private:
//! set of registered widgets
QMap<QWidget*, WId> _widgets;
//! number of pixmaps
enum { numPixmaps = 8 };
//!@name pixmaps
//@{
Qt::HANDLE _pixmaps[numPixmaps];
//@}
//! shadow size
int _size;
#ifdef Q_WS_X11
//! shadow atom
Atom _atom;
#endif
};
}
#endif

View File

@ -0,0 +1,179 @@
/*
QtCurve (C) Craig Drummond, 2007 - 2010 craig.p.drummond@gmail.com
----
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License version 2 as published by the Free Software Foundation.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "shortcuthandler.h"
#include <QtGui>
namespace QtCurve
{
ShortcutHandler::ShortcutHandler(QObject *parent)
: QObject(parent)
, itsAltDown(false)
{
}
ShortcutHandler::~ShortcutHandler()
{
}
bool ShortcutHandler::hasSeenAlt(const QWidget *widget) const
{
if(widget && !widget->isEnabled())
return false;
if(qobject_cast<const QMenu *>(widget))
return itsOpenMenus.count() && itsOpenMenus.last()==widget;
// {
// const QWidget *w=widget;
//
// while(w)
// {
// if(itsSeenAlt.contains((QWidget *)w))
// return true;
// w=w->parentWidget();
// }
// }
else
return itsOpenMenus.isEmpty() && itsSeenAlt.contains((QWidget *)(widget->window()));
return false;
}
bool ShortcutHandler::showShortcut(const QWidget *widget) const
{
return itsAltDown && hasSeenAlt(widget);
}
void ShortcutHandler::widgetDestroyed(QObject *o)
{
itsUpdated.remove(static_cast<QWidget *>(o));
itsOpenMenus.removeAll(static_cast<QWidget *>(o));
}
void ShortcutHandler::updateWidget(QWidget *w)
{
if(!itsUpdated.contains(w))
{
itsUpdated.insert(w);
w->update();
connect(w, SIGNAL(destroyed(QObject *)), this, SLOT(widgetDestroyed(QObject *)));
}
}
bool ShortcutHandler::eventFilter(QObject *o, QEvent *e)
{
if (!o->isWidgetType())
return QObject::eventFilter(o, e);
QWidget *widget = qobject_cast<QWidget*>(o);
switch(e->type())
{
case QEvent::KeyPress:
if (Qt::Key_Alt==static_cast<QKeyEvent *>(e)->key())
{
itsAltDown = true;
if(qobject_cast<QMenu *>(widget))
{
itsSeenAlt.insert(widget);
updateWidget(widget);
if(widget->parentWidget() && widget->parentWidget()->window())
itsSeenAlt.insert(widget->parentWidget()->window());
}
else
{
widget = widget->window();
itsSeenAlt.insert(widget);
QList<QWidget *> l = qFindChildren<QWidget *>(widget);
for (int pos=0 ; pos < l.size() ; ++pos)
{
QWidget *w = l.at(pos);
if (!(w->isWindow() || !w->isVisible())) // || w->style()->styleHint(QStyle::SH_UnderlineShortcut, 0, w)))
updateWidget(w);
}
QList<QMenuBar *> m = qFindChildren<QMenuBar *>(widget);
for (int i = 0; i < m.size(); ++i)
updateWidget(m.at(i));
}
}
break;
case QEvent::WindowDeactivate:
case QEvent::KeyRelease:
if (QEvent::WindowDeactivate==e->type() || Qt::Key_Alt==static_cast<QKeyEvent*>(e)->key())
{
itsAltDown = false;
QSet<QWidget *>::ConstIterator it(itsUpdated.constBegin()),
end(itsUpdated.constEnd());
for (; it!=end; ++it)
(*it)->update();
if(!itsUpdated.contains(widget))
widget->update();
itsSeenAlt.clear();
itsUpdated.clear();
}
break;
case QEvent::Show:
if(qobject_cast<QMenu *>(widget))
{
QWidget *prev=itsOpenMenus.count() ? itsOpenMenus.last() : 0L;
itsOpenMenus.append(widget);
if(itsAltDown && prev)
prev->update();
connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(widgetDestroyed(QObject *)));
}
break;
case QEvent::Hide:
if(qobject_cast<QMenu *>(widget))
{
itsSeenAlt.remove(widget);
itsUpdated.remove(widget);
itsOpenMenus.removeAll(widget);
if(itsAltDown)
{
if(itsOpenMenus.count())
itsOpenMenus.last()->update();
else if(widget->parentWidget() && widget->parentWidget()->window())
widget->parentWidget()->window()->update();
}
}
break;
case QEvent::Close:
// Reset widget when closing
itsSeenAlt.remove(widget);
itsUpdated.remove(widget);
itsSeenAlt.remove(widget->window());
itsOpenMenus.removeAll(widget);
if(itsAltDown)
{
if(itsOpenMenus.count())
itsOpenMenus.last()->update();
else if(widget->parentWidget() && widget->parentWidget()->window())
widget->parentWidget()->window()->update();
}
break;
default:
break;
}
return QObject::eventFilter(o, e);
}
}

View File

@ -0,0 +1,65 @@
#ifndef __SHORTCUT_HANDLER_H__
#define __SHORTCUT_HANDLER_H__
/*
QtCurve (C) Craig Drummond, 2007 - 2010 craig.p.drummond@gmail.com
----
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License version 2 as published by the Free Software Foundation.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtCore/QObject>
#include <QtCore/QSet>
#include <QtCore/QList>
class QWidget;
namespace QtCurve
{
class ShortcutHandler : public QObject
{
Q_OBJECT
public:
explicit ShortcutHandler(QObject *parent = 0);
virtual ~ShortcutHandler();
bool hasSeenAlt(const QWidget *widget) const;
bool isAltDown() const { return itsAltDown; }
bool showShortcut(const QWidget *widget) const;
private Q_SLOTS:
void widgetDestroyed(QObject *o);
protected:
void updateWidget(QWidget *w);
bool eventFilter(QObject *watched, QEvent *event);
private:
bool itsAltDown;
QSet<QWidget *> itsSeenAlt,
itsUpdated;
QList<QWidget *> itsOpenMenus;
};
}
#endif

View File

@ -0,0 +1,81 @@
/*
QtCurve (C) Craig Drummond, 2007 - 2010 craig.p.drummond@gmail.com
----
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License version 2 as published by the Free Software Foundation.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "utils.h"
#include "config.h"
#include <stdio.h>
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "fixx11h.h"
#include <QX11Info>
#endif
#if defined QTC_QT_ONLY
#undef KDE_IS_VERSION
#define KDE_IS_VERSION(A, B, C) 0
#else
#include <kdeversion.h>
#include <KDE/KWindowSystem>
#endif
namespace QtCurve
{
namespace Utils
{
bool compositingActive()
{
#if defined QTC_QT_ONLY || !KDE_IS_VERSION(4, 4, 0)
#ifdef Q_WS_X11
static bool haveAtom=false;
static Atom atom;
if(!haveAtom)
{
Display *dpy = QX11Info::display();
char string[100];
sprintf(string, "_NET_WM_CM_S%d", DefaultScreen(dpy));
atom = XInternAtom(dpy, string, False);
haveAtom=true;
}
return XGetSelectionOwner(QX11Info::display(), atom) != None;
#else // Q_WS_X11
return false;
#endif // Q_WS_X11
#else // QTC_QT_ONLY
return KWindowSystem::compositingActive();
#endif // QTC_QT_ONLY
}
bool hasAlphaChannel(const QWidget *widget)
{
#ifdef Q_WS_X11
if(compositingActive())
return 32 == (widget ? widget->x11Info().depth() : QX11Info().appDepth()) ;
else
return false;
#else
return compositingActive();
#endif
}
}
}

41
src/qtcurve/style/utils.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef _UTILS_H_
#define _UTILS_H_
/*
QtCurve (C) Craig Drummond, 2007 - 2010 craig.p.drummond@gmail.com
----
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License version 2 as published by the Free Software Foundation.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtGui/QWidget>
namespace QtCurve
{
namespace Utils
{
inline void addEventFilter(QObject *object, QObject *filter)
{
object->removeEventFilter(filter);
object->installEventFilter(filter);
}
extern bool compositingActive();
extern bool hasAlphaChannel(const QWidget *widget);
}
}
#endif

View File

@ -0,0 +1,793 @@
// krazy:excludeall=qclasses
// Copied from oxygenwindowmanager.cpp svnversion: 1139230
//////////////////////////////////////////////////////////////////////////////
// oxygenwindowmanager.cpp
// pass some window mouse press/release/move event actions to window manager
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
//
// Largely inspired from BeSpin style
// Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "windowmanager.h"
#include "qtcurve.h"
#include "common.h"
#include "utils.h"
#include <QtGui/QApplication>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QDockWidget>
#include <QtGui/QGroupBox>
#include <QtGui/QLabel>
#include <QtGui/QListView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QMouseEvent>
#include <QtGui/QStatusBar>
#include <QtGui/QStyle>
#include <QtGui/QStyleOptionGroupBox>
#include <QtGui/QTabBar>
#include <QtGui/QTabWidget>
#include <QtGui/QToolBar>
#include <QtGui/QToolButton>
#include <QtGui/QTreeView>
#include <QtGui/QGraphicsView>
#include <QtCore/QTextStream>
#include <QtGui/QTextDocument>
#ifndef QTC_QT_ONLY
#include <KGlobalSettings>
#endif
#ifdef Q_WS_X11
#include <QX11Info>
#ifdef QTC_QT_ONLY
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "fixx11h.h"
#else
#include <NETRootInfo>
#endif
#endif
namespace QtCurve
{
#if QT_VERSION < 0x040600
QtCPointer & QtCPointer::operator=(QWidget *w)
{
widget_=w;
if(widget_)
Utils::addEventFilter(widget_, this);
return *this;
}
void QtCPointer::clear()
{
if(widget_)
widget_->removeEventFilter(this);
widget_=0L;
}
bool QtCPointer::eventFilter(QObject *o, QEvent *e)
{
if(o==widget_ && QEvent::Destroy==e->type())
widget_=0L;
return false;
}
#endif
//_____________________________________________________________
WindowManager::WindowManager( QObject* parent ):
QObject( parent ),
_enabled( true ),
#ifdef Q_WS_X11
_useWMMoveResize( true ),
#else
_useWMMoveResize( false ),
#endif
_dragMode( WM_DRAG_NONE ),
#ifdef QTC_QT_ONLY
_dragDistance( QApplication::startDragDistance() ),
#else
_dragDistance( KGlobalSettings::dndEventDelay() ),
#endif
_dragDelay( QApplication::startDragTime() ),
_dragAboutToStart( false ),
_dragInProgress( false ),
_locked( false ),
_cursorOverride( false )
{
// install application wise event filter
_appEventFilter = new AppEventFilter( this );
qApp->installEventFilter( _appEventFilter );
}
//_____________________________________________________________
void WindowManager::initialize( int windowDrag, const QStringList &whiteList, const QStringList &blackList )
{
setEnabled( windowDrag );
setDragMode( windowDrag );
//CPD: Why??? setUseWMMoveResize( OxygenStyleConfigData::useWMMoveResize() );
#ifndef QTC_QT_ONLY
setDragDistance( KGlobalSettings::dndEventDelay() );
#endif
setDragDelay( QApplication::startDragTime() );
initializeWhiteList( whiteList );
initializeBlackList( blackList );
}
//_____________________________________________________________
void WindowManager::registerWidget( QWidget* widget )
{
if( isBlackListed( widget ) )
{
/*
also install filter for blacklisted widgets
to be able to catch the relevant events and prevent
the drag to happen
*/
Utils::addEventFilter(widget, this);
} else if( isDragable( widget ) ) {
Utils::addEventFilter(widget, this);
}
}
//_____________________________________________________________
void WindowManager::unregisterWidget( QWidget* widget )
{
if( widget )
{ widget->removeEventFilter( this ); }
}
//_____________________________________________________________
void WindowManager::initializeWhiteList( const QStringList &list )
{
_whiteList.clear();
// add user specified whitelisted classnames
_whiteList.insert( ExceptionId( "MplayerWindow" ) );
_whiteList.insert( ExceptionId( "ViewSliders@kmix" ) );
_whiteList.insert( ExceptionId( "Sidebar_Widget@konqueror" ) );
foreach( const QString& exception, list )
{
ExceptionId id( exception );
if( !id.className().isEmpty() )
{ _whiteList.insert( exception ); }
}
}
//_____________________________________________________________
void WindowManager::initializeBlackList( const QStringList &list )
{
_blackList.clear();
_blackList.insert( ExceptionId( "CustomTrackView@kdenlive" ) );
_blackList.insert( ExceptionId( "MuseScore" ) );
foreach( const QString& exception, list )
{
ExceptionId id( exception );
if( !id.className().isEmpty() )
{ _blackList.insert( exception ); }
}
}
//_____________________________________________________________
bool WindowManager::eventFilter( QObject* object, QEvent* event )
{
if( !enabled() ) return false;
switch ( event->type() )
{
case QEvent::MouseButtonPress:
return mousePressEvent( object, event );
break;
case QEvent::MouseMove:
if ( object == _target.data() ) return mouseMoveEvent( object, event );
break;
case QEvent::MouseButtonRelease:
if ( _target ) return mouseReleaseEvent( object, event );
break;
default:
break;
}
return false;
}
//_____________________________________________________________
void WindowManager::timerEvent( QTimerEvent* event )
{
if( event->timerId() == _dragTimer.timerId() )
{
_dragTimer.stop();
if( _target )
{ startDrag( _target.data(), _globalDragPoint ); }
} else {
return QObject::timerEvent( event );
}
}
//_____________________________________________________________
bool WindowManager::mousePressEvent( QObject* object, QEvent* event )
{
// cast event and check buttons/modifiers
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event );
if( !( mouseEvent->modifiers() == Qt::NoModifier && mouseEvent->button() == Qt::LeftButton ) )
{ return false; }
// check lock
if( isLocked() ) return false;
else setLocked( true );
// cast to widget
QWidget *widget = static_cast<QWidget*>( object );
// check if widget can be dragged from current position
if( isBlackListed( widget ) || !canDrag( widget ) ) return false;
// retrieve widget's child at event position
QPoint position( mouseEvent->pos() );
QWidget* child = widget->childAt( position );
if( !canDrag( widget, child, position ) ) return false;
// save target and drag point
_target = widget;
_dragPoint = position;
_globalDragPoint = mouseEvent->globalPos();
_dragAboutToStart = true;
// send a move event to the current child with same position
// if received, it is caught to actually start the drag
QPoint localPoint( _dragPoint );
if( child ) localPoint = child->mapFrom( widget, localPoint );
else child = widget;
QMouseEvent localMouseEvent( QEvent::MouseMove, localPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier );
qApp->sendEvent( child, &localMouseEvent );
// never eat event
return false;
}
//_____________________________________________________________
bool WindowManager::mouseMoveEvent( QObject* object, QEvent* event )
{
Q_UNUSED( object );
// stop timer
if( _dragTimer.isActive() ) _dragTimer.stop();
// cast event and check drag distance
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event );
if( !_dragInProgress )
{
if( _dragAboutToStart )
{
if( mouseEvent->globalPos() == _globalDragPoint )
{
// start timer,
_dragAboutToStart = false;
if( _dragTimer.isActive() ) _dragTimer.stop();
_dragTimer.start( _dragDelay, this );
} else resetDrag();
} else if( QPoint( mouseEvent->globalPos() - _globalDragPoint ).manhattanLength() >= _dragDistance )
{ _dragTimer.start( 0, this ); }
return true;
} else if( !useWMMoveResize() ) {
// use QWidget::move for the grabbing
/* this works only if the sending object and the target are identical */
QWidget* window( _target.data()->window() );
window->move( window->pos() + mouseEvent->pos() - _dragPoint );
return true;
} else return false;
}
//_____________________________________________________________
bool WindowManager::mouseReleaseEvent( QObject* object, QEvent* event )
{
Q_UNUSED( object );
Q_UNUSED( event );
resetDrag();
return false;
}
//_____________________________________________________________
bool WindowManager::isDragable( QWidget* widget )
{
// check widget
if( !widget ) return false;
// accepted default types
if(
( qobject_cast<QDialog*>( widget ) && widget->isWindow() ) ||
( qobject_cast<QMainWindow*>( widget ) && widget->isWindow() ) ||
qobject_cast<QGroupBox*>( widget ) )
{ return true; }
// more accepted types, provided they are not dock widget titles
if( ( qobject_cast<QMenuBar*>( widget ) ||
qobject_cast<QTabBar*>( widget ) ||
qobject_cast<QStatusBar*>( widget ) ||
qobject_cast<QToolBar*>( widget ) ) &&
!isDockWidgetTitle( widget ) )
{ return true; }
if( widget->inherits( "KScreenSaver" ) && widget->inherits( "KCModule" ) )
{ return true; }
if( isWhiteListed( widget ) )
{ return true; }
// flat toolbuttons
if( QToolButton* toolButton = qobject_cast<QToolButton*>( widget ) )
{ if( toolButton->autoRaise() ) return true; }
// viewports
/*
one needs to check that
1/ the widget parent is a scrollarea
2/ it matches its parent viewport
3/ the parent is not blacklisted
*/
if( QListView* listView = qobject_cast<QListView*>( widget->parentWidget() ) )
{ if( listView->viewport() == widget && !isBlackListed( listView ) ) return true; }
if( QTreeView* treeView = qobject_cast<QTreeView*>( widget->parentWidget() ) )
{ if( treeView->viewport() == widget && !isBlackListed( treeView ) ) return true; }
//if( QGraphicsView* graphicsView = qobject_cast<QGraphicsView*>( widget->parentWidget() ) )
//{ if( graphicsView->viewport() == widget && !isBlackListed( graphicsView ) ) return true; }
/*
catch labels in status bars.
this is because of kstatusbar
who captures buttonPress/release events
*/
if( QLabel* label = qobject_cast<QLabel*>( widget ) )
{
if( label->textInteractionFlags().testFlag( Qt::TextSelectableByMouse ) ) return false;
QWidget* parent = label->parentWidget();
while( parent )
{
if( qobject_cast<QStatusBar*>( parent ) ) return true;
parent = parent->parentWidget();
}
}
return false;
}
//_____________________________________________________________
bool WindowManager::isBlackListed( QWidget* widget )
{
// check against noAnimations propery
QVariant propertyValue( widget->property( "_kde_no_window_grab" ) );
if( propertyValue.isValid() && propertyValue.toBool() ) return true;
// list-based blacklisted widgets
QString appName( qApp->applicationName() );
foreach( const ExceptionId& id, _blackList )
{
if( !id.appName().isEmpty() && id.appName() != appName ) continue;
if( id.className() == "*" && !id.appName().isEmpty() )
{
// if application name matches and all classes are selected
// disable the grabbing entirely
setEnabled( false );
return true;
}
if( widget->inherits( id.className().toLatin1() ) ) return true;
}
return false;
}
//_____________________________________________________________
bool WindowManager::isWhiteListed( QWidget* widget ) const
{
QString appName( qApp->applicationName() );
foreach( const ExceptionId& id, _whiteList )
{
if( !id.appName().isEmpty() && id.appName() != appName ) continue;
if( widget->inherits( id.className().toLatin1() ) ) return true;
}
return false;
}
//_____________________________________________________________
bool WindowManager::canDrag( QWidget* widget )
{
// check if enabled
if( !enabled() ) return false;
// assume isDragable widget is already passed
// check some special cases where drag should not be effective
// check mouse grabber
if( QWidget::mouseGrabber() ) return false;
/*
check cursor shape.
Assume that a changed cursor means that some action is in progress
and should prevent the drag
*/
if( widget->cursor().shape() != Qt::ArrowCursor ) return false;
// accept
return true;
}
//_____________________________________________________________
bool WindowManager::canDrag( QWidget* widget, QWidget* child, const QPoint& position )
{
// retrieve child at given position and check cursor again
if( child && child->cursor().shape() != Qt::ArrowCursor ) return false;
/*
check against children from which drag should never be enabled,
even if mousePress/Move has been passed to the parent
*/
if( child && (
qobject_cast<QComboBox*>(child ) ||
qobject_cast<QProgressBar*>( child ) ) )
{ return false; }
// tool buttons
if( QToolButton* toolButton = qobject_cast<QToolButton*>( widget ) )
{
if( dragMode() < WM_DRAG_ALL && !qobject_cast<QToolBar*>(widget->parentWidget() ) ) return false;
return toolButton->autoRaise() && !toolButton->isEnabled();
}
// check menubar
if( QMenuBar* menuBar = qobject_cast<QMenuBar*>( widget ) )
{
// check if there is an active action
if( menuBar->activeAction() && menuBar->activeAction()->isEnabled() ) return false;
// check if action at position exists and is enabled
if( QAction* action = menuBar->actionAt( position ) )
{
if( action->isSeparator() ) return true;
if( action->isEnabled() ) return false;
}
// return true in all other cases
return true;
}
if(dragMode() < WM_DRAG_MENU_AND_TOOLBAR && qobject_cast<QToolBar*>( widget ))
return false;
/*
in MINIMAL mode, anything that has not been already accepted
and does not come from a toolbar is rejected
*/
if( dragMode() < WM_DRAG_ALL )
{
if( qobject_cast<QToolBar*>( widget ) ) return true;
else return false;
}
/* following checks are relevant only for WD_FULL mode */
// tabbar. Make sure no tab is under the cursor
if( QTabBar* tabBar = qobject_cast<QTabBar*>( widget ) )
{ return tabBar->tabAt( position ) == -1; }
/*
check groupboxes
prevent drag if unchecking grouboxes
*/
if( QGroupBox *groupBox = qobject_cast<QGroupBox*>( widget ) )
{
// non checkable group boxes are always ok
if( !groupBox->isCheckable() ) return true;
// gather options to retrieve checkbox subcontrol rect
QStyleOptionGroupBox opt;
opt.initFrom( groupBox );
if( groupBox->isFlat() ) opt.features |= QStyleOptionFrameV2::Flat;
opt.lineWidth = 1;
opt.midLineWidth = 0;
opt.text = groupBox->title();
opt.textAlignment = groupBox->alignment();
opt.subControls = (QStyle::SC_GroupBoxFrame | QStyle::SC_GroupBoxCheckBox);
if (!groupBox->title().isEmpty()) opt.subControls |= QStyle::SC_GroupBoxLabel;
opt.state |= (groupBox->isChecked() ? QStyle::State_On : QStyle::State_Off);
// check against groupbox checkbox
if( groupBox->style()->subControlRect(QStyle::CC_GroupBox, &opt, QStyle::SC_GroupBoxCheckBox, groupBox ).contains( position ) )
{ return false; }
// check against groupbox label
if( !groupBox->title().isEmpty() && groupBox->style()->subControlRect(QStyle::CC_GroupBox, &opt, QStyle::SC_GroupBoxLabel, groupBox ).contains( position ) )
{ return false; }
return true;
}
// labels
if( QLabel* label = qobject_cast<QLabel*>( widget ) )
{ if( label->textInteractionFlags().testFlag( Qt::TextSelectableByMouse ) ) return false; }
// abstract item views
QAbstractItemView* itemView( NULL );
if(
( itemView = qobject_cast<QListView*>( widget->parentWidget() ) ) ||
( itemView = qobject_cast<QTreeView*>( widget->parentWidget() ) ) )
{
if( widget == itemView->viewport() )
{
// QListView
if( itemView->frameShape() != QFrame::NoFrame ) return false;
else if(
itemView->selectionMode() != QAbstractItemView::NoSelection &&
itemView->selectionMode() != QAbstractItemView::SingleSelection &&
itemView->model() && itemView->model()->rowCount() ) return false;
else if( itemView->model() && itemView->indexAt( position ).isValid() ) return false;
}
} else if( ( itemView = qobject_cast<QAbstractItemView*>( widget->parentWidget() ) ) ) {
if( widget == itemView->viewport() )
{
// QAbstractItemView
if( itemView->frameShape() != QFrame::NoFrame ) return false;
else if( itemView->indexAt( position ).isValid() ) return false;
}
} else if( QGraphicsView* graphicsView = qobject_cast<QGraphicsView*>( widget->parentWidget() ) ) {
if( widget == graphicsView->viewport() )
{
// QGraphicsView
if( graphicsView->frameShape() != QFrame::NoFrame ) return false;
else if( graphicsView->dragMode() != QGraphicsView::NoDrag ) return false;
else if( graphicsView->itemAt( position ) ) return false;
}
}
return true;
}
//____________________________________________________________
void WindowManager::resetDrag( void )
{
if( (!useWMMoveResize() ) && _target && _cursorOverride ) {
qApp->restoreOverrideCursor();
_cursorOverride = false;
}
_target.clear();
if( _dragTimer.isActive() ) _dragTimer.stop();
_dragPoint = QPoint();
_globalDragPoint = QPoint();
_dragAboutToStart = false;
_dragInProgress = false;
}
//____________________________________________________________
void WindowManager::startDrag( QWidget* widget, const QPoint& position )
{
if( !( enabled() && widget ) ) return;
if( QWidget::mouseGrabber() ) return;
// ungrab pointer
if( useWMMoveResize() )
{
#ifdef Q_WS_X11
#ifdef QTC_QT_ONLY
static const Atom constNetMoveResize = XInternAtom(QX11Info::display(), "_NET_WM_MOVERESIZE", False);
//...Taken from bespin...
// stolen... errr "adapted!" from QSizeGrip
QX11Info info;
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = constNetMoveResize;
xev.xclient.display = QX11Info::display();
xev.xclient.window = widget->window()->winId();
xev.xclient.format = 32;
xev.xclient.data.l[0] = position.x();
xev.xclient.data.l[1] = position.y();
xev.xclient.data.l[2] = 8; // NET::Move
xev.xclient.data.l[3] = Button1;
xev.xclient.data.l[4] = 0;
XUngrabPointer(QX11Info::display(), QX11Info::appTime());
XSendEvent(QX11Info::display(), QX11Info::appRootWindow(info.screen()), False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
#else
XUngrabPointer(QX11Info::display(), QX11Info::appTime());
NETRootInfo rootInfo(QX11Info::display(), NET::WMMoveResize);
rootInfo.moveResizeRequest( widget->window()->winId(), position.x(), position.y(), NET::Move);
#endif // QTC_QT_ONLY
#endif
}
if( !useWMMoveResize() )
{
if( !_cursorOverride )
{
qApp->setOverrideCursor( Qt::SizeAllCursor );
_cursorOverride = true;
}
}
_dragInProgress = true;
return;
}
//____________________________________________________________
bool WindowManager::supportWMMoveResize( void ) const
{
#ifdef Q_WS_X11
return true;
#endif
return false;
}
//____________________________________________________________
bool WindowManager::isDockWidgetTitle( const QWidget* widget ) const
{
if( !widget ) return false;
if( const QDockWidget* dockWidget = qobject_cast<const QDockWidget*>( widget->parent() ) )
{
return widget == dockWidget->titleBarWidget();
} else return false;
}
//____________________________________________________________
bool WindowManager::AppEventFilter::eventFilter( QObject* object, QEvent* event )
{
if( event->type() == QEvent::MouseButtonRelease )
{
// stop drag timer
if( _parent->_dragTimer.isActive() )
{ _parent->resetDrag(); }
// unlock
if( _parent->isLocked() )
{ _parent->setLocked( false ); }
}
if( !_parent->enabled() ) return false;
/*
if a drag is in progress, the widget will not receive any event
we trigger on the first MouseMove or MousePress events that are received
by any widget in the application to detect that the drag is finished
*/
if( _parent->useWMMoveResize() && _parent->_dragInProgress && _parent->_target && ( event->type() == QEvent::MouseMove || event->type() == QEvent::MouseButtonPress ) )
{ return appMouseEvent( object, event ); }
return false;
}
//_____________________________________________________________
bool WindowManager::AppEventFilter::appMouseEvent( QObject* object, QEvent* event )
{
Q_UNUSED( object );
// store target window (see later)
QWidget* window( _parent->_target.data()->window() );
/*
post some mouseRelease event to the target, in order to counter balance
the mouse press that triggered the drag. Note that it triggers a resetDrag
*/
QMouseEvent mouseEvent( QEvent::MouseButtonRelease, _parent->_dragPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier );
qApp->sendEvent( _parent->_target.data(), &mouseEvent );
if( event->type() == QEvent::MouseMove )
{
/*
HACK: quickly move the main cursor out of the window and back
this is needed to get the focus right for the window children
the origin of this issue is unknown at the moment
*/
const QPoint cursor = QCursor::pos();
QCursor::setPos(window->mapToGlobal( window->rect().topRight() ) + QPoint(1, 0) );
QCursor::setPos(cursor);
}
return true;
}
}

View File

@ -0,0 +1,325 @@
#ifndef __WINDOW_MANAGER_H__
#define __WINDOW_MANAGER_H__
// Copied from oxygenwindowmanager.h svnversion: 1137195
//////////////////////////////////////////////////////////////////////////////
// oxygenwindowmanager.h
// pass some window mouse press/release/move event actions to window manager
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
//
// Largely inspired from BeSpin style
// Copyright (C) 2007 Thomas Luebking <thomas.luebking@web.de>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <QtCore/QEvent>
#include <QtCore/QBasicTimer>
#include <QtCore/QObject>
#include <QtCore/QSet>
#include <QtCore/QString>
#include <QtCore/QWeakPointer>
#include <QtGui/QWidget>
namespace QtCurve
{
#if QT_VERSION < 0x040600
class QtCPointer : public QObject
{
public:
QtCPointer(QWidget *w=0L) : widget_(w) {}
QtCPointer & operator=(QWidget *w);
operator bool() const { return 0L!=widget_; }
void clear();
bool eventFilter(QObject *, QEvent *);
QWidget *data() { return widget_; }
private:
QWidget *widget_;
};
#endif
class WindowManager: public QObject
{
Q_OBJECT
public:
//! constructor
explicit WindowManager( QObject* );
//! destructor
virtual ~WindowManager( void )
{}
//! initialize
/*! read relevant options from OxygenStyleConfigData */
void initialize( int windowDrag, const QStringList &whiteList=QStringList(), const QStringList &blackList=QStringList() );
//! register widget
void registerWidget( QWidget* );
//! unregister widget
void unregisterWidget( QWidget* );
//! event filter [reimplemented]
virtual bool eventFilter( QObject*, QEvent* );
protected:
//! timer event,
/*! used to start drag if button is pressed for a long enough time */
void timerEvent( QTimerEvent* );
//! mouse press event
bool mousePressEvent( QObject*, QEvent* );
//! mouse move event
bool mouseMoveEvent( QObject*, QEvent* );
//! mouse release event
bool mouseReleaseEvent( QObject*, QEvent* );
//!@name configuration
//@{
//! enable state
bool enabled( void ) const
{ return _enabled; }
//! enable state
void setEnabled( bool value )
{ _enabled = value; }
//! returns true if window manager is used for moving
bool useWMMoveResize( void ) const
{ return supportWMMoveResize() && _useWMMoveResize; }
//! use window manager for moving, when available
void setUseWMMoveResize( bool value )
{ _useWMMoveResize = value; }
//! drag mode
int dragMode( void ) const
{ return _dragMode; }
//! drag mode
void setDragMode( int value )
{ _dragMode = value; }
//! drag distance (pixels)
void setDragDistance( int value )
{ _dragDistance = value; }
//! drag delay (msec)
void setDragDelay( int value )
{ _dragDelay = value; }
//! set list of whiteListed widgets
/*!
white list is read from options and is used to adjust
per-app window dragging issues
*/
void initializeWhiteList( const QStringList &list );
//! set list of blackListed widgets
/*!
black list is read from options and is used to adjust
per-app window dragging issues
*/
void initializeBlackList( const QStringList &list );
//@}
//! returns true if widget is dragable
bool isDragable( QWidget* );
//! returns true if widget is dragable
bool isBlackListed( QWidget* );
//! returns true if widget is dragable
bool isWhiteListed( QWidget* ) const;
//! returns true if drag can be started from current widget
bool canDrag( QWidget* );
//! returns true if drag can be started from current widget and position
/*! child at given position is passed as second argument */
bool canDrag( QWidget*, QWidget*, const QPoint& );
//! reset drag
void resetDrag( void );
//! start drag
void startDrag( QWidget*, const QPoint& );
//! returns true if window manager is used for moving
/*! right now this is true only for X11 */
bool supportWMMoveResize( void ) const;
//! utility function
bool isDockWidgetTitle( const QWidget* ) const;
//!@name lock
//@{
void setLocked( bool value )
{ _locked = value; }
//! lock
bool isLocked( void ) const
{ return _locked; }
//@}
private:
//! enability
bool _enabled;
//! use WM moveResize
bool _useWMMoveResize;
//! drag mode
int _dragMode;
//! drag distance
/*! this is copied from kwin::geometry */
int _dragDistance;
//! drag delay
/*! this is copied from kwin::geometry */
int _dragDelay;
//! wrapper for exception id
class ExceptionId: public QPair<QString, QString>
{
public:
//! constructor
ExceptionId( const QString& value )
{
const QStringList args( value.split( "@" ) );
if( args.isEmpty() ) return;
second = args[0].trimmed();
if( args.size()>1 ) first = args[1].trimmed();
}
const QString& appName( void ) const
{ return first; }
const QString& className( void ) const
{ return second; }
};
//! exception set
typedef QSet<ExceptionId> ExceptionSet;
//! list of white listed special widgets
/*!
it is read from options and is used to adjust
per-app window dragging issues
*/
ExceptionSet _whiteList;
//! list of black listed special widgets
/*!
it is read from options and is used to adjust
per-app window dragging issues
*/
ExceptionSet _blackList;
//! drag point
QPoint _dragPoint;
QPoint _globalDragPoint;
//! drag timer
QBasicTimer _dragTimer;
//! target being dragged
/*! QWeakPointer is used in case the target gets deleted while drag is in progress */
#if QT_VERSION < 0x040600
QtCPointer _target;
#else
QWeakPointer<QWidget> _target;
#endif
//! true if drag is about to start
bool _dragAboutToStart;
//! true if drag is in progress
bool _dragInProgress;
//! true if drag is locked
bool _locked;
//! cursor override
/*! used to keep track of application cursor being overridden when dragging in non-WM mode */
bool _cursorOverride;
//! provide application-wise event filter
/*!
it us used to unlock dragging and make sure event look is properly restored
after a drag has occurred
*/
class AppEventFilter: public QObject
{
public:
//! constructor
AppEventFilter( WindowManager* parent ):
QObject( parent ),
_parent( parent )
{}
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
protected:
//! application-wise event.
/*! needed to catch end of XMoveResize events */
bool appMouseEvent( QObject*, QEvent* );
private:
//! parent
WindowManager* _parent;
};
//! application event filter
AppEventFilter* _appEventFilter;
//! allow access of all private members to the app event filter
friend class AppEventFilter;
};
}
#endif

View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.gui2 import Application
from PyQt4.Qt import (QDialog, QGridLayout, QListWidget, QDialogButtonBox,
QPushButton, QTimer)
app = Application([], force_calibre_style=True)
d = QDialog()
d.l = l = QGridLayout()
d.setLayout(l)
lw = QListWidget()
lw.addItem('Some text guy')
l.addWidget(lw, 0, 0, 2, 1)
bb = QDialogButtonBox()
bb.setStandardButtons(bb.Close)
bb.accepted.connect(d.accept)
bb.rejected.connect(d.reject)
l.addWidget(bb, 2, 0, 1, 2)
b = QPushButton('Normal')
l.addWidget(b, 0, 1, 1, 1)
def print_button_sizes():
for b in d.findChildren(QPushButton):
print (unicode(b.text()), b.height(), b.iconSize())
QTimer.singleShot(5, print_button_sizes)
d.exec_()