Switch to using Qt Fusion as the calibre style and port calibre specific customizations to it
@ -403,8 +403,6 @@ class Build(Command):
|
|||||||
self.obj_dir = os.path.join(os.path.dirname(SRC), 'build', 'objects')
|
self.obj_dir = os.path.join(os.path.dirname(SRC), 'build', 'objects')
|
||||||
if not os.path.exists(self.obj_dir):
|
if not os.path.exists(self.obj_dir):
|
||||||
os.makedirs(self.obj_dir)
|
os.makedirs(self.obj_dir)
|
||||||
if opts.only in {'all', 'style'}:
|
|
||||||
self.build_style(self.j(self.SRC, 'calibre', 'plugins'))
|
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
if opts.only != 'all' and opts.only != ext.name:
|
if opts.only != 'all' and opts.only != ext.name:
|
||||||
continue
|
continue
|
||||||
@ -500,89 +498,6 @@ class Build(Command):
|
|||||||
print "Error while executing: %s\n" % (cmdline)
|
print "Error while executing: %s\n" % (cmdline)
|
||||||
raise
|
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/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'
|
|
||||||
if not os.path.exists(dest):
|
|
||||||
os.makedirs(dest)
|
|
||||||
shutil.copy2(src[0], self.j(dest, 'calibre_style.'+ext))
|
|
||||||
finally:
|
|
||||||
os.chdir(ocwd)
|
|
||||||
|
|
||||||
def build_sip_files(self, ext, src_dir):
|
def build_sip_files(self, ext, src_dir):
|
||||||
sip_files = ext.sip_files
|
sip_files = ext.sip_files
|
||||||
ext.sip_files = []
|
ext.sip_files = []
|
||||||
|
@ -4,12 +4,11 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import os, sys, Queue, threading, glob
|
import os, sys, Queue, threading, glob
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from PyQt5.Qt import (QFileInfo, QObject, QBuffer, Qt,
|
from PyQt5.Qt import (
|
||||||
QByteArray, QTranslator, QCoreApplication, QThread,
|
QFileInfo, QObject, QBuffer, Qt, QStyle, QByteArray, QTranslator,
|
||||||
QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices,
|
QCoreApplication, QThread, QEvent, QTimer, pyqtSignal, QDateTime,
|
||||||
QFileDialog, QFileIconProvider, QSettings, QColor,
|
QDesktopServices, QFileDialog, QFileIconProvider, QSettings, QIcon,
|
||||||
QIcon, QApplication, QDialog, QUrl, QFont, QPalette,
|
QApplication, QDialog, QUrl, QFont, QFontDatabase, QLocale)
|
||||||
QFontDatabase, QLocale)
|
|
||||||
|
|
||||||
ORG_NAME = 'KovidsBrain'
|
ORG_NAME = 'KovidsBrain'
|
||||||
APP_UID = 'libprs500'
|
APP_UID = 'libprs500'
|
||||||
@ -885,7 +884,11 @@ class Application(QApplication):
|
|||||||
self.pi = plugins['progress_indicator'][0]
|
self.pi = plugins['progress_indicator'][0]
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
self.redirect_notify = True
|
self.redirect_notify = True
|
||||||
|
self.setup_styles(force_calibre_style)
|
||||||
QApplication.__init__(self, qargs)
|
QApplication.__init__(self, qargs)
|
||||||
|
if not self.using_calibre_style and self.style().objectName() == 'fusion':
|
||||||
|
# Since Qt is using the fusion style anyway, specialize it
|
||||||
|
self.load_calibre_style()
|
||||||
dl = QLocale(get_lang())
|
dl = QLocale(get_lang())
|
||||||
if unicode(dl.bcp47Name()) != u'C':
|
if unicode(dl.bcp47Name()) != u'C':
|
||||||
QLocale.setDefault(dl)
|
QLocale.setDefault(dl)
|
||||||
@ -896,7 +899,6 @@ class Application(QApplication):
|
|||||||
qt_app = self
|
qt_app = self
|
||||||
self._file_open_paths = []
|
self._file_open_paths = []
|
||||||
self._file_open_lock = RLock()
|
self._file_open_lock = RLock()
|
||||||
self.setup_styles(force_calibre_style)
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
def notify(self, receiver, event):
|
def notify(self, receiver, event):
|
||||||
if self.redirect_notify:
|
if self.redirect_notify:
|
||||||
@ -915,60 +917,7 @@ class Application(QApplication):
|
|||||||
|
|
||||||
load_builtin_fonts()
|
load_builtin_fonts()
|
||||||
|
|
||||||
def load_calibre_style(self):
|
|
||||||
# On OS X QtCurve resets the palette, so we preserve it explicitly
|
|
||||||
orig_pal = QPalette(self.palette())
|
|
||||||
|
|
||||||
path = os.path.join(sys.extensions_location, 'calibre_style.'+(
|
|
||||||
'pyd' if iswindows else 'so'))
|
|
||||||
if not self.pi.load_style(path, 'Calibre'):
|
|
||||||
prints('Failed to load calibre style')
|
|
||||||
# On OSX, on some machines, colors can be invalid. See https://bugs.launchpad.net/bugs/1014900
|
|
||||||
for role in (orig_pal.Button, orig_pal.Window):
|
|
||||||
c = orig_pal.brush(role).color()
|
|
||||||
if not c.isValid() or not c.toRgb().isValid():
|
|
||||||
orig_pal.setColor(role, QColor(u'lightgray'))
|
|
||||||
|
|
||||||
self.setPalette(orig_pal)
|
|
||||||
style = self.style()
|
|
||||||
icon_map = {}
|
|
||||||
pcache = {}
|
|
||||||
for k, v in {
|
|
||||||
'DialogYesButton': u'ok.png',
|
|
||||||
'DialogNoButton': u'window-close.png',
|
|
||||||
'DialogCloseButton': u'window-close.png',
|
|
||||||
'DialogOkButton': u'ok.png',
|
|
||||||
'DialogCancelButton': u'window-close.png',
|
|
||||||
'DialogHelpButton': u'help.png',
|
|
||||||
'DialogOpenButton': u'document_open.png',
|
|
||||||
'DialogSaveButton': u'save.png',
|
|
||||||
'DialogApplyButton': u'ok.png',
|
|
||||||
'DialogDiscardButton': u'trash.png',
|
|
||||||
'MessageBoxInformation': u'dialog_information.png',
|
|
||||||
'MessageBoxWarning': u'dialog_warning.png',
|
|
||||||
'MessageBoxCritical': u'dialog_error.png',
|
|
||||||
'MessageBoxQuestion': u'dialog_question.png',
|
|
||||||
'BrowserReload': u'view-refresh.png',
|
|
||||||
# These two are used to calculate the sizes for the doc widget
|
|
||||||
# title bar buttons, therefore, they have to exist. The actual
|
|
||||||
# icon is not used.
|
|
||||||
'TitleBarCloseButton': u'window-close.png',
|
|
||||||
'TitleBarNormalButton': u'window-close.png',
|
|
||||||
'DockWidgetCloseButton': u'window-close.png',
|
|
||||||
}.iteritems():
|
|
||||||
if v not in pcache:
|
|
||||||
p = I(v)
|
|
||||||
if isinstance(p, bytes):
|
|
||||||
p = p.decode(filesystem_encoding)
|
|
||||||
# if not os.path.exists(p): raise ValueError(p)
|
|
||||||
pcache[v] = p
|
|
||||||
v = pcache[v]
|
|
||||||
icon_map[type('')(getattr(style, 'SP_'+k))] = v
|
|
||||||
style.setProperty(u'calibre_icon_map', icon_map)
|
|
||||||
self.__icon_map_memory_ = icon_map
|
|
||||||
|
|
||||||
def setup_styles(self, force_calibre_style):
|
def setup_styles(self, force_calibre_style):
|
||||||
self.original_font = QFont(QApplication.font())
|
|
||||||
fi = gprefs['font']
|
fi = gprefs['font']
|
||||||
if fi is not None:
|
if fi is not None:
|
||||||
font = QFont(*(fi[:4]))
|
font = QFont(*(fi[:4]))
|
||||||
@ -989,20 +938,39 @@ class Application(QApplication):
|
|||||||
if not depth_ok:
|
if not depth_ok:
|
||||||
prints('Color depth is less than 32 bits disabling modern look')
|
prints('Color depth is less than 32 bits disabling modern look')
|
||||||
|
|
||||||
if force_calibre_style or (depth_ok and gprefs['ui_style'] !=
|
self.using_calibre_style = force_calibre_style or (depth_ok and gprefs['ui_style'] != 'system')
|
||||||
'system'):
|
if self.using_calibre_style:
|
||||||
self.load_calibre_style()
|
self.load_calibre_style()
|
||||||
else:
|
|
||||||
st = self.style()
|
def load_calibre_style(self):
|
||||||
if st is not None:
|
icon_map = self.__icon_map_memory_ = {}
|
||||||
st = unicode(st.objectName()).lower()
|
pcache = {}
|
||||||
if (islinux or isbsd) and st in ('windows', 'motif', 'cde'):
|
for k, v in {
|
||||||
from PyQt5.Qt import QStyleFactory
|
'DialogYesButton': u'ok.png',
|
||||||
styles = set(map(unicode, QStyleFactory.keys()))
|
'DialogNoButton': u'window-close.png',
|
||||||
if os.environ.get('KDE_FULL_SESSION', False):
|
'DialogCloseButton': u'window-close.png',
|
||||||
self.load_calibre_style()
|
'DialogOkButton': u'ok.png',
|
||||||
elif 'Cleanlooks' in styles:
|
'DialogCancelButton': u'window-close.png',
|
||||||
self.setStyle('Cleanlooks')
|
'DialogHelpButton': u'help.png',
|
||||||
|
'DialogOpenButton': u'document_open.png',
|
||||||
|
'DialogSaveButton': u'save.png',
|
||||||
|
'DialogApplyButton': u'ok.png',
|
||||||
|
'DialogDiscardButton': u'trash.png',
|
||||||
|
'MessageBoxInformation': u'dialog_information.png',
|
||||||
|
'MessageBoxWarning': u'dialog_warning.png',
|
||||||
|
'MessageBoxCritical': u'dialog_error.png',
|
||||||
|
'MessageBoxQuestion': u'dialog_question.png',
|
||||||
|
'BrowserReload': u'view-refresh.png',
|
||||||
|
}.iteritems():
|
||||||
|
if v not in pcache:
|
||||||
|
p = I(v)
|
||||||
|
if isinstance(p, bytes):
|
||||||
|
p = p.decode(filesystem_encoding)
|
||||||
|
# if not os.path.exists(p): raise ValueError(p)
|
||||||
|
pcache[v] = p
|
||||||
|
v = pcache[v]
|
||||||
|
icon_map[getattr(QStyle, 'SP_'+k)] = v
|
||||||
|
self.pi.load_style(icon_map)
|
||||||
|
|
||||||
def _send_file_open_events(self):
|
def _send_file_open_events(self):
|
||||||
with self._file_open_lock:
|
with self._file_open_lock:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include "QProgressIndicator.h"
|
#include "QProgressIndicator.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QtWidgets/QStylePlugin>
|
|
||||||
#include <QPluginLoader>
|
|
||||||
#include <QtWidgets/QStyle>
|
#include <QtWidgets/QStyle>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QStyleFactory>
|
||||||
#include <QtWidgets/QProxyStyle>
|
#include <QtWidgets/QProxyStyle>
|
||||||
|
#include <QStyleOptionToolButton>
|
||||||
|
|
||||||
QProgressIndicator::QProgressIndicator(QWidget* parent, int size)
|
QProgressIndicator::QProgressIndicator(QWidget* parent, int size)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
@ -129,23 +129,86 @@ void QProgressIndicator::paintEvent(QPaintEvent * /*event*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_style(QString &path, QString &name) {
|
class CalibreStyle: public QProxyStyle {
|
||||||
int ret = 0;
|
private:
|
||||||
QStyle *s;
|
QHash<int, QString> icon_map;
|
||||||
QPluginLoader pl(path);
|
|
||||||
QObject *o = pl.instance();
|
public:
|
||||||
if (o != 0) {
|
CalibreStyle(QStyle *base, QHash<int, QString> icmap) : QProxyStyle(base), icon_map(icmap) {
|
||||||
QStylePlugin *sp = qobject_cast<QStylePlugin *>(o);
|
setObjectName(QString("calibre"));
|
||||||
if (sp != 0) {
|
|
||||||
s = sp->create(name);
|
|
||||||
if (s != 0) {
|
|
||||||
s->setObjectName(name);
|
|
||||||
QApplication::setStyle(s);
|
|
||||||
ret = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int styleHint(StyleHint hint, const QStyleOption *option = 0,
|
||||||
|
const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const {
|
||||||
|
switch (hint) {
|
||||||
|
case SH_DialogButtonBox_ButtonsHaveIcons:
|
||||||
|
return 1; // We want icons on dialog button box buttons
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0) const {
|
||||||
|
if (icon_map.contains(standardIcon)) return QIcon(icon_map.value(standardIcon));
|
||||||
|
return QProxyStyle::standardIcon(standardIcon, option, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0) const {
|
||||||
|
switch (metric) {
|
||||||
|
case PM_TabBarTabVSpace:
|
||||||
|
return 8; // Make tab bars a little narrower, the value for the Fusion style is 12
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QProxyStyle::pixelMetric(metric, option, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawComplexControl(ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget = 0) const {
|
||||||
|
const QStyleOptionToolButton *toolbutton = NULL;
|
||||||
|
switch (control) {
|
||||||
|
case CC_ToolButton:
|
||||||
|
// We do not want an arrow if the toolbutton has an instant popup
|
||||||
|
toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option);
|
||||||
|
if (toolbutton && toolbutton->features & QStyleOptionToolButton::HasMenu & ~QStyleOptionToolButton::PopupDelay) {
|
||||||
|
QStyleOptionToolButton opt = QStyleOptionToolButton(*toolbutton);
|
||||||
|
opt.features = toolbutton->features & ~QStyleOptionToolButton::HasMenu;
|
||||||
|
return QProxyStyle::drawComplexControl(control, &opt, painter, widget);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawPrimitive(PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0) const {
|
||||||
|
const QStyleOptionViewItem *vopt = NULL;
|
||||||
|
switch (element) {
|
||||||
|
case PE_PanelItemViewItem:
|
||||||
|
// Highlight the current, selected item with a different background in an item view if the highlight current item property is set
|
||||||
|
if (option->state & QStyle::State_HasFocus && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) && widget && widget->property("highlight_current_item").toBool()) {
|
||||||
|
QColor color = vopt->palette.color(QPalette::Normal, QPalette::Highlight);
|
||||||
|
QStyleOptionViewItem opt = QStyleOptionViewItem(*vopt);
|
||||||
|
if (color.lightness() > 128)
|
||||||
|
color = color.darker(widget->property("highlight_current_item").toInt());
|
||||||
|
else
|
||||||
|
color = color.lighter(125);
|
||||||
|
opt.palette.setColor(QPalette::Highlight, color);
|
||||||
|
return QProxyStyle::drawPrimitive(element, &opt, painter, widget);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int load_style(QHash<int,QString> icon_map) {
|
||||||
|
QStyle *base_style = QStyleFactory::create(QString("Fusion"));
|
||||||
|
QApplication::setStyle(new CalibreStyle(base_style, icon_map));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool do_notify(QObject *receiver, QEvent *event) {
|
bool do_notify(QObject *receiver, QEvent *event) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QProgressIndicator
|
\class QProgressIndicator
|
||||||
@ -98,7 +99,7 @@ private:
|
|||||||
* \param name The name of the style plugin to load
|
* \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
|
* \return 1 if succeeds 0 otherwise. The objectName of the loaded style is set to name
|
||||||
*/
|
*/
|
||||||
int load_style(QString &path, QString &name);
|
int load_style(QHash<int,QString> icon_map);
|
||||||
|
|
||||||
bool do_notify(QObject *receiver, QEvent *event);
|
bool do_notify(QObject *receiver, QEvent *event);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
%Import QtWidgets/QtWidgetsmod.sip
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
%ModuleHeaderCode
|
%ModuleHeaderCode
|
||||||
int load_style(QString &path, QString &name);
|
int load_style(QHash<int,QString> icon_map);
|
||||||
bool do_notify(QObject *receiver, QEvent *event);
|
bool do_notify(QObject *receiver, QEvent *event);
|
||||||
void set_no_activate_on_click(QWidget *widget);
|
void set_no_activate_on_click(QWidget *widget);
|
||||||
void set_touch_menu_style(QWidget *widget, int margin);
|
void set_touch_menu_style(QWidget *widget, int margin);
|
||||||
@ -57,7 +57,7 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int load_style(QString &path, QString &name);
|
int load_style(QHash<int,QString> icon_map);
|
||||||
|
|
||||||
bool do_notify(QObject *receiver, QEvent *event);
|
bool do_notify(QObject *receiver, QEvent *event);
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Craig Drummond <craig.p.drummond@gmail.com>
|
|
@ -1,340 +0,0 @@
|
|||||||
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.
|
|
Before Width: | Height: | Size: 179 B |
Before Width: | Height: | Size: 154 B |
@ -1,342 +0,0 @@
|
|||||||
/*
|
|
||||||
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)
|
|
@ -1,11 +0,0 @@
|
|||||||
#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
|
|
@ -1,728 +0,0 @@
|
|||||||
#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))
|
|
@ -1,49 +0,0 @@
|
|||||||
#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
|
|
Before Width: | Height: | Size: 130 B |
Before Width: | Height: | Size: 419 B |
Before Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 632 B |
Before Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 825 B |
Before Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 591 B |
Before Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 199 B |
@ -1,12 +0,0 @@
|
|||||||
#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 */
|
|
||||||
|
|
||||||
|
|
@ -1,232 +0,0 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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(); }
|
|
||||||
|
|
||||||
#else
|
|
||||||
Q_UNUSED(widget);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//___________________________________________________________
|
|
||||||
void BlurHelper::clear( QWidget* widget ) const
|
|
||||||
{
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
XChangeProperty( QX11Info::display(), widget->winId(), _atom, XA_CARDINAL, 32, PropModeReplace, 0, 0 );
|
|
||||||
#else
|
|
||||||
Q_UNUSED(widget);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,188 +0,0 @@
|
|||||||
#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
|
|
@ -1,306 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
|
|
||||||
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
|
|
@ -1,51 +0,0 @@
|
|||||||
/* 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
|
|
@ -1,502 +0,0 @@
|
|||||||
/* 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
|
|
@ -1,82 +0,0 @@
|
|||||||
/* 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
|
|
@ -1,36 +0,0 @@
|
|||||||
#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
|
|
@ -1,383 +0,0 @@
|
|||||||
#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;
|
|
||||||
virtual bool event(QEvent *event);
|
|
||||||
|
|
||||||
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;
|
|
||||||
QHash<int,QString> calibre_icon_map;
|
|
||||||
int calibre_item_view_focus;
|
|
||||||
bool is_kde_session;
|
|
||||||
|
|
||||||
// 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
|
|
@ -1,10 +0,0 @@
|
|||||||
[Misc]
|
|
||||||
Name=QtCurve
|
|
||||||
Comment=Highly configurable style
|
|
||||||
Comment[zh_CN]=可高度定制的风格
|
|
||||||
Comment[zh_HK]=可高度定制的樣式
|
|
||||||
Comment[zh_TW]=可高度定制的樣式
|
|
||||||
ConfigPage=kstyle_qtcurve_config
|
|
||||||
[KDE]
|
|
||||||
WidgetStyle=QtCurve
|
|
||||||
|
|
@ -1,320 +0,0 @@
|
|||||||
#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
|
|
@ -1,285 +0,0 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
#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
|
|
@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
#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
|
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
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
|
|
||||||
Q_UNUSED(widget);
|
|
||||||
return compositingActive();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
#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
|
|
@ -1,795 +0,0 @@
|
|||||||
// 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
|
|
||||||
#else
|
|
||||||
Q_UNUSED(position);
|
|
||||||
#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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,325 +0,0 @@
|
|||||||
#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
|
|
@ -1,39 +0,0 @@
|
|||||||
#!/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, QIcon)
|
|
||||||
|
|
||||||
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)
|
|
||||||
b = bb.addButton('Action', bb.ActionRole)
|
|
||||||
b.setIcon(QIcon(I('wizard.png')))
|
|
||||||
l.addWidget(bb, 2, 0, 1, 2)
|
|
||||||
bb.button(bb.Close).setDefault(True)
|
|
||||||
|
|
||||||
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_()
|
|
||||||
|
|