skulpture-0.2.4/0000755000175000001440000000000011333667520012443 5ustar pepousersskulpture-0.2.4/README.html0000600000175000001440000000461111333641652014256 0ustar pepousers Skulpture

Skulpture

About Skulpture

Skulpture is a GUI style addon for KDE programs. It features a classical three-dimensional artwork with shadows and smooth gradients to enhance the visual experience.

Skulpture has been designed to be light and easy on eyes; many distracting borders or graphical elements have been removed or replaced by simpler artwork.

You can set Skulpture as the KDE default style with the "System Settings" program. Skulpture includes a style for applications, color schemes, and a theme for the KDE window manager. For a matching Plasma style, install the Atelier theme.

Skulpture can also be used with Qt programs. To do so, use the command line option "-style Skulpture" when invoking the Qt program. Additionally, you can set this style as the Qt default style with the "qtconfig" program.

Version Information

This is version 0.2.4 of Skulpture, released on 08-Feb-2010. See NEWS for a summary of changes relative to the previous version, and NOTES for additional information for this version. Some features are still missing; see BUGS for details.

To find out if a newer version of Skulpture is available, please visit the Skulpture homepage.

Legal

Skulpture is Copyright 2007-2010 Christoph Feck. See AUTHORS for ways to contact him.

Skulpture is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

Skulpture 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 COPYING for more details.

skulpture-0.2.4/README0000600000175000001440000000337211333641316013313 0ustar pepousers=== Skulpture === *** About Skulpture *** Skulpture is a GUI style addon for KDE programs. It features a classical three-dimensional artwork with shadows and smooth gradients to enhance the visual experience. Skulpture has been designed to be light and easy on eyes; many distracting borders or graphical elements have been removed or replaced by simpler artwork. You can set Skulpture as the KDE default style with the "System Settings" program. Skulpture includes a style for applications, color schemes, and a theme for the KDE window manager. For a matching Plasma style, install the Atelier theme. Skulpture can also be used with Qt programs. To do so, use the command line option "-style Skulpture" when invoking the Qt program. Additionally, you can set this style as the Qt default style with the "qtconfig" program. *** Version Information *** This is version 0.2.4 of Skulpture, released on 08-Feb-2010. See NEWS for a summary of changes relative to the previous version, and NOTES for additional information for this version. Some features are still missing; see BUGS for details. To find out if a newer version of Skulpture is available, please visit the Skulpture homepage at http://skulpture.maxiom.de/ *** Legal *** Skulpture is Copyright 2007-2010 Christoph Feck. See AUTHORS for ways to contact him. Skulpture is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Skulpture 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 COPYING for more details. skulpture-0.2.4/CMakeLists.txt0000600000175000001440000000347611127453455015206 0ustar pepousersproject (skulpture) cmake_minimum_required (VERSION 2.4) find_package (KDE4) add_definitions (-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_KEYWORDS -DQT_STRICT_ITERATORS -DQT_NO_DYNAMIC_CAST) configure_file (config.h.cmake ${CMAKE_BINARY_DIR}/config.h) if (KDE4_FOUND) include (KDE4Defaults) include (MacroLibrary) add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) include_directories (${KDE4_INCLUDES} ${CMAKE_BINARY_DIR}) # find_package (KDE4Workspace QUIET) set (KDE4WORKSPACE_FOUND OFF) if (KDE4WORKSPACE_FOUND) message (STATUS "Found KDE4Workspace") include_directories (${KDE4WORKSPACE_INCLUDE_DIR}) set (BUILD_KWIN_CLIENT ON) else (KDE4WORKSPACE_FOUND) message (STATUS "Looking for kwinglobals.h") find_file (KWINGLOBALS_H kwinglobals.h ${KDE4_INCLUDES}) if (KWINGLOBALS_H) message (STATUS "Looking for kwinglobals.h - found") set (BUILD_KWIN_CLIENT ON) else (KWINGLOBALS_H) message (STATUS "Looking for kwinglobals.h - not found.") endif (KWINGLOBALS_H) endif (KDE4WORKSPACE_FOUND) else (KDE4_FOUND) set (QT_MIN_VERSION "4.1.0") find_package (Qt4 REQUIRED) include (UseQt4) set (CMAKE_INCLUDE_CURRENT_DIR ON) include_directories (${CMAKE_BINARY_DIR}) endif (KDE4_FOUND) add_subdirectory (src) if (KDE4_FOUND) macro_optional_add_subdirectory (color-schemes) macro_optional_add_subdirectory (desktoptheme) if (BUILD_KWIN_CLIENT) add_subdirectory (kwin-client) else (BUILD_KWIN_CLIENT) message ("WARNING: *** KWin headers not found, building without Skulpture window decoration ***") endif (BUILD_KWIN_CLIENT) else (KDE4_FOUND) message ("WARNING: *** KDE4 not found, building a Qt-only version of Skulpture ***") endif (KDE4_FOUND) skulpture-0.2.4/NEWS0000600000175000001440000002512411333575642013141 0ustar pepousersNew in 0.2.4: Bugfixes: * fixed possible crash when destroying MDI windows * fixed possible crash when destroying menus * fixed Tab key handling in Konversation * fixed detection of default font (KDE 4.4) * fixed menu item rectangle and input handler (Qt 4.6) * fixed text rendering in vertical ProgressBar * fixed frame in "east" TabWidget (Qt 4.6) * fixed workaround for KIntNumInput size bug (KDE 4.4) * fixed MDI window title placement with RTL layouts * fixed ToolBar icon size to respect KDE setting (KDE 4.4) * fixed single click mode to respect KDE setting (KDE 4.4) * fixed vertical centering regressions (Qt 4.6.1) * fixed vertical alignment of labels in FormLayout (Qt 4.6.2) * fixed flashing of ScrollBar in PlacesPanel * fixed widget flags in KWin window decoration client * fixed menubar margin for improved full-screen usability * fixed "Alternate Background" color in Skulpture color schemes * fixed build warnings (KDE 4.3) * fixed build failure with Qt 4.1 New in 0.2.3: Bugfixes: * fixed ToolButton with menu (Qt 4.5) * fixed detection of Dolphin InformationPanel (KDE 4.3) * fixed rendering of transparent gradients (Qt 4.5) * fixed black frame in KRunner LineEdit * fixed MDI title shadow with raster graphics system (Qt 4.5.0 bug) * fixed ButtonMargin pixel metric regression * fixed menus not working after hovering menu titles * fixed focus rendering on menu titles * fixed corner buttons on document mode TabBar (Qt 4.5) * fixed shortcut underlines in preview (KDE 4.3) * fixed Esc key clearing preview window * fixed corner buttons on "south" TabWidget (Konversation) * fixed eliding of tabs in small TabBar * fixed disabled ToolButton in inactive windows * fixed "south" document mode tabs (Konsole 4.3) * fixed Dial tickmarks (Qt 4.6) * fixed right shadow on frameless spinbox * fixed a few build warnings New in 0.2.2: New Style Configuration Options: * added option to change text cursor width (Qt 4.4) * added option to change submenu delay * added "KDE Style" to ScrollBar arrow placement options New KWin Decoration Configuration Options: * added option to change title bar height and symbol sizes * added option to center title bar on full window width * added option to configure pixel-exact border sizes Bugfixes: * fixed arrow placement configuration in non english locales * fixed submenus appearing only when not moving the mouse (Qt bug) * fixed cursor indication to follow mouse on hover in LineEdit * fixed wrong color role on non-raised ToolButton/ToolBox labels * fixed keyboard focus indicator for view items * fixed double frame in KMail (KDE 4.2) * fixed build with KDE 4.0 New in 0.2.1: New Style Configuration Options: * added option to change TabBar size * added option to change Slider and minimum ScrollBar length * added option to change ScrollBar arrow placement * added option to make PlacesPanel transparent New KWin Decoration Configuration Options: * added option to adjust vertical text shift * added option to change horizontal text alignment * added option to disable inactive frame coloring Bugfixes: * fixed possible crash when destroying TextEdit widgets * fixed Slider to have the specified pixel size * fixed large icons to only use standard sizes * fixed KLineEdit's clear button not respecting font size * fixed preview window to respect KDE UI standards * fixed clipped text on ToolButton with text under icon * fixed memory leak in ToolBar handle * fixed hover feedback of icon in KWin window decoration client * fixed tabs with icons (Qt 4.5) * fixed user installation script to not fail when installing twice New in 0.2.0: New Configuration Options (requires KDE 4): * added option to respect "Disabled" colors from System Settings * added option to adjust vertical text shift * added option to change ScrollBar, Slider, and menu sizes * added option to change widget margins and spacing * added option to change password character * added option to disable icon in KWin window decoration client Visual Improvements: * improved appearance of CheckBox, RadioButton, and ProgressBar * implemented rendering of Qt 3 support elements * implemented rendering of KMenu titles (KDE 4.1) * unified appearance of SpinBox and ComboBox * made small visual improvements to other elements Bugfixes: * fixed slow cursor movement in large TextEdit fields * fixed hover feedback of selected CheckBox * fixed CheckBox and RadioButton in dark color schemes * fixed NoButtons/PlusMinus SpinBox button modes * fixed ScrollBar slider covering both arrows at the same time * fixed layout and rendering with non-zero global strut * fixed tree expanders not respecting font size * fixed frameless SpinBox and ComboBox * fixed wrong usage of color roles in various places * fixed missing icons in MenuBar * fixed missing etching of disabled texts in menus * fixed check indicators covering menu icons * fixed missing separator texts in menus * fixed frames and shadows in more widgets * fixed HMTLView frame * fixed wrong frame in ComboBox popup menu * fixed missing shadow for views in menus * fixed missing shadow in sunken ScrollArea * fixed shadow in KColorSelector * fixed Restore decoration button to not look identical to Maximize * fixed vertical alignment of labels in FormLayout (Qt 4.4) * fixed password character to fall back to ASCII symbol * fixed LineEdit focus highlight in Arora (Qt 4 demo browser) * fixed user installation script to find KDE4 on Kubuntu * fixed build failure if KWin headers are not found * fixed memory leak Other Changes: * improved support for custom Qt style sheets * improved user installation script with build log file generation * refactored code to only depend on QCommonStyle * backported to Qt 4.2 for LSB 4.0 conformant systems * added a Skulpture web log New in 0.1.3: * fixed black background on transparent buttons * fixed black background on LineEdit with certain style sheets * some other small fixes and improvements: * fixed title bar Help button to not depend on font shape * fixed MDI window shadows to not expand outside of MDI area * fixed title bar caption and buttons in vertical docks * fixed Menu icon column without icons (Qt 4.5) * improved arrows in MenuBar and ToolBar extender * added support for ToolButton with menu arrow in vertical ToolBar * improved ToolButton with menu arrow * fixed rendering of vertical tabs * improved scroll buttons in TabBar * fixed TabWidget corner buttons (KTorrent) * fixed wrong font on dragged item view header section * removed dash pattern from selection rubberband * fixed ScrollBar size to not depend on content font size New in 0.1.2: * initial work on title bar decoration buttons (KWin, MDI, docks) * fixed custom KWin button placement * fixed crash in styled ItemView (Qt 4.4) * some other small fixes and improvements: * fixed size and disabled state for check indicators in MenuItem * fixed menu stripe in RTL layouts * improved size of submenu arrow * added clipping of window caption * added support for remaining KWin buttons (see NOTES) * fixed MDI window title bar to use KWin colors (see NOTES) * added mouse over highlight to flat PushButton * fixed arrow position on menu PushButton * implemented rendering of KLineEdit's clear button * implemented rendering of ToolBox (Marble, Kalzium) * implemented rendering of ToolBar handles * fixed item highlight border on Table without grid * initial work on color schemes (Skulpture in different flavors) New in 0.1.1: * fixed missing check indicator in checked MenuItem with icon * fixed initial green title bar in KWin decoration (again) * some other small fixes and improvements: * fixed TabWidget without tabs * fixed shadow in editable ComboBox with icon * fixed separator line in Dolphin information panel * fixed MenuBar height in Konqueror * removed frame from TabWidget corner buttons * restored normal size of ComboBox in ToolBar New in 0.1.0: * improved support for KDE color schemes * added preview to configuration page (KDE4) * added support for Qt 4.4.0 * many other small fixes and improvements: * implemented rendering of dock titles * implemented rendering of tree lines and expanders * implemented rendering of resize grip * implemented rendering of view item backgrounds (Qt 4.4) * added button-like highlight of menu items * added shadows to MDI windows * added a slight shadow to Slider handles * added automatic cursor size depending on font width * added current line highlight to PlainTextEdit (Qt 4.4) * added mouse over hightlight to clickable header sections * fixed frames and shadows in more widgets * fixed rendering of TabBar background in Konquerer * fixed rendering of "south" tabs (Konsole, docks) * fixed corner rendering in scroll areas * fixed wrong palette on Qt 4.4 * fixed initial green title bar in KWin decoration (Qt 4.4) * fixed background in KDE font selection preview * improved some layouting values (ComboBox, MDI buttons) * added RSS feed to Skulpture website New in 0.0.4: * initial work on KWin window decoration client (KDE4) * fixed rendering of Slider with tickmarks * fixed bogus frames and shadows * improved appearance of arrows * some other small fixes and improvements New in 0.0.3: * fixed margins of SpinBox and ComboBox on Qt 4.3.1 * improved rendering of Dial and TabBar * some other small fixes and improvements * renamed to Skulpture (old name: Skandale) New in 0.0.2: * initial work on ComboBox, SpinBox, ScrollBar, and Slider * initial work on Window (MDI), FocusFrame, and ToolButton * made Dial useable * fixed crash in TextEdit * fixed rendering of wide PushButton and non-editable ComboBox New in 0.0.1: * imagery for RadioButton and CheckBox * more flat PushButton, with improved visual feedback * improved HeaderView * initial work on TabBar and Dial * highlight current line in TextEdit (same as in LineEdit) skulpture-0.2.4/INSTALL0000600000175000001440000000117611333642147013467 0ustar pepousers=== Installing Skulpture === *** Installation *** Installation from source requires CMake. To install, type the following at the shell prompt within the "skulpture-0.2.4" directory, including the dot. Note that you are prompted for the root password during installation. sh install.sh You should restart the system after installation, so that KWin sees the freshly installed style. *** Deinstallation *** To uninstall, type the following at the shell prompt within the directory from which you installed. If you deleted that directory, just install it again. Again, you are prompted for the root password. sh uninstall.sh skulpture-0.2.4/src/0000700000175000001440000000000011333667520013220 5ustar pepousersskulpture-0.2.4/src/CMakeLists.txt0000600000175000001440000000126411067742764015775 0ustar pepousersproject (kstyle-skulpture) set (skulpture_SOURCES skulpture.cpp) #if (KDE4_FOUND) # kde4_add_plugin (skulpture ${skulpture_SOURCES}) # target_link_libraries (skulpture ${KDE4_KDEUI_LIBS}) # install (TARGETS skulpture DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/styles) #else (KDE4_FOUND) qt4_automoc (${skulpture_SOURCES}) add_library (skulpture SHARED ${skulpture_SOURCES}) target_link_libraries (skulpture ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) install (TARGETS skulpture LIBRARY DESTINATION ${QT_PLUGINS_DIR}/styles) #endif (KDE4_FOUND) if (KDE4_FOUND) install (FILES skulpture.themerc DESTINATION ${DATA_INSTALL_DIR}/kstyle/themes) add_subdirectory (config) endif (KDE4_FOUND) skulpture-0.2.4/src/.directory0000600000175000001440000000004710773730665015240 0ustar pepousers[Dolphin] Timestamp=2008,3,30,17,28,53 skulpture-0.2.4/src/config/0000700000175000001440000000000011333667520014465 5ustar pepousersskulpture-0.2.4/src/config/sk_dialog.ui0000600000175000001440000007417111161735514016772 0ustar pepousers SkulptureStyleDialog QFrame::StyledPanel QFrame::Sunken 0 General Style Options Hide shortcut underlines true Appearance false Use selection color for checked indicators Make disabled widgets transparent true 0 0 Text shift: 0 0 -9 9 (only applies to default font) Qt::Horizontal QSizePolicy::Expanding 40 20 Qt::Vertical 20 0 Layout false Many applications, especially KDE dialogs, ignore the style's spacing and margin values. Setting this option tries to force the values on all applications. Force spacing and margin values on all layouts Sizes Widgets: (default) pixels -1 -1 Push buttons: (default) pixels -1 -1 Tool buttons: (default) pixels -1 -1 Tab bars: (default) pixels -1 -1 Spacing and Margins Horizontal: (default) pixels -1 -1 Vertical: (default) pixels -1 -1 Labels: (default) pixels -1 -1 Groups: (default) pixels -1 -1 Dialogs: (default) pixels -1 -1 Menus Sizes Menu bar: (default) pixels -1 -1 Menu items: (default) pixels -1 -1 false Appearance Use icon column for check indicators Use selection color for selected items Usability Submenu delay: ms 2000 50 100 Qt::Vertical 20 27 Sliders Scroll Bar Arrow Position Vertical arrows: Covered Bottom Bottom/Top KDE Style Top None Horizontal arrows: Covered Right Right/Left KDE Style Left None Sizes Slider thickness: Scroll bar thickness: (default) pixels -1 2 -1 Length: (default) pixels -1 -1 (default) pixels -1 2 -1 Length: (default) pixels -1 -1 Qt::Vertical 0 0 Miscellaneous Progress Bars Animate progress bars true Text Fields (default) pixels 1 8.000000000000000 Cursor width: true * Password character: Places Panel Use transparent places panel false Buttons Roundness: 9 Qt::Horizontal Gradient: -50 50 Qt::Horizontal Qt::Vertical 20 0 KTabWidget QTabWidget
KDE/KTabWidget
1
KComboBox QComboBox
KDE/KComboBox
skulpture-0.2.4/src/config/sk_preview1.ui0000600000175000001440000004611611333366247017277 0ustar pepousers SkulpturePreview1 Qt::Horizontal Show Disabled true false false Group Check Box true Radio Button true Radio Button Qt::Vertical QSizePolicy::MinimumExpanding 20 0 Push Button false 0 0 0 272 210 Widgets Text Line Edit LineEdit (empty) true Combo Box Element 100 70 70 100 70 Qt::Horizontal 0 0 50 50 50 50 100 70 true Qt::Vertical QSizePolicy::MinimumExpanding 20 0 Qt::Horizontal 70 0 0 272 210 Text <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Skulpture</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;"><span style=" font-weight:400;">Version 0.2.4</span></p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://skulpture.maxiom.de/"><span style=" text-decoration: underline; color:#0057ae;">http://skulpture.maxiom.de/</span></a></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Copyright © 2007-2010 Christoph Feck</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></td></tr></table></body></html> 0 0 272 210 Tree Column 1 Column 2 Element (expandable) Element Line 1 Element Line 2 Element Line 3 Element (not expandable) 0 0 272 210 Table Column 1 Column 2 Column 3 Column 4 KLineEdit QLineEdit
KDE/KLineEdit
KTextEdit QTextEdit
KDE/KTextEdit
KComboBox QComboBox
KDE/KComboBox
KTabWidget QTabWidget
KDE/KTabWidget
dial valueChanged(int) progressBar setValue(int) 375 126 337 219 dial valueChanged(int) lcdNumber display(int) 374 131 287 133 dial valueChanged(int) spinBox setValue(int) 375 111 302 106 spinBox valueChanged(int) progressBar setValue(int) 245 110 308 220 spinBox valueChanged(int) lcdNumber display(int) 339 121 339 139 spinBox valueChanged(int) dial setValue(int) 236 108 379 122 horizontalSlider valueChanged(int) progressBar setValue(int) 323 79 380 223 horizontalSlider valueChanged(int) lcdNumber display(int) 359 82 256 136 horizontalSlider valueChanged(int) spinBox setValue(int) 285 78 260 107 horizontalSlider valueChanged(int) dial setValue(int) 300 80 380 123 pushButton_2 toggled(bool) groupBox setDisabled(bool) 106 24 104 43 pushButton_2 toggled(bool) Text setDisabled(bool) 117 26 137 40 pushButton_2 toggled(bool) comboBox setDisabled(bool) 83 25 93 191 pushButton_2 toggled(bool) pushButton setDisabled(bool) 66 23 80 225 dial valueChanged(int) horizontalSlider setValue(int) 376 135 374 83 spinBox valueChanged(int) horizontalSlider setValue(int) 216 108 225 83
skulpture-0.2.4/src/config/sk_preview2.ui0000600000175000001440000001270711333366225017273 0ustar pepousers SkulpturePreview2 0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:16px; margin-bottom:16px; margin-left:16px; margin-right:16px;"> <tr> <td style="border: none;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Skulpture</span></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;"><span style=" font-weight:400;">Version 0.2.4</span></p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://skulpture.maxiom.de/"><span style=" text-decoration: underline; color:#0057ae;">http://skulpture.maxiom.de/</span></a></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Copyright © 2007-2010 Christoph Feck</span></p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-size:10pt;">This is a demonstration window only</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></td></tr></table></body></html> true KXmlGuiWindow QMainWindow
KDE/KXmlGuiWindow
skulpture-0.2.4/src/config/CMakeLists.txt0000600000175000001440000000100711115155423017215 0ustar pepousersset (kstyle_skulpture_config_SOURCES sk_config.cpp) kde4_add_ui_files (kstyle_skulpture_config_SOURCES sk_dialog.ui sk_preview1.ui sk_preview2.ui) kde4_add_plugin (kstyle_skulpture_config ${kstyle_skulpture_config_SOURCES}) target_link_libraries (kstyle_skulpture_config ${KDE4_KDEUI_LIBS}) install (FILES skulpture.png DESTINATION ${DATA_INSTALL_DIR}/skulpture/pics) install( FILES skulptureui.rc DESTINATION ${DATA_INSTALL_DIR}/skulpture) install (TARGETS kstyle_skulpture_config DESTINATION ${PLUGIN_INSTALL_DIR}) skulpture-0.2.4/src/config/configmanager.h0000600000175000001440000002152711123603732017437 0ustar pepousers/* * configmanager.h - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef CONFIGMANAGER_H #define CONFIGMANAGER_H 1 /*-----------------------------------------------------------------------*/ #include #include #include #include #include #include #include class ConfigManager { public: ConfigManager() { /* */ } ~ConfigManager() { /* */ } public: void addWidgets(QWidget *parent) { typedef QList WidgetList; WidgetList widgets = parent->findChildren(QRegExp(QLatin1String("^cm_"))); for (WidgetList::const_iterator i = widgets.constBegin(); i != widgets.constEnd(); ++i) { QWidget *widget = *i; if (widget->isEnabled()) { items.append(ConfigItem(widget, QVariant())); items.last().configDefault = items.last().value(); } } } void connectConfigChanged(QObject *receiver, const char slot[]) const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { item->connectValueChanged(receiver, slot); } } void save(QSettings &settings) const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { QVariant value = item->value(); if (!value.isNull()) { if (value == item->configDefault) { settings.remove(item->configLabel()); } else { settings.setValue(item->configLabel(), item->value()); } } } } void load(const QSettings &settings) const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { item->setValue(((ConfigItem) *item).configSaved = settings.value(item->configLabel(), item->configDefault)); } } bool hasChanged() const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { if (item->configSaved != item->value()) { return true; } } return false; } void defaults() const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { item->setValue(item->configDefault); } } private: class ConfigItem { public: ConfigItem(QWidget *widget, const QVariant &def = QVariant()) : configWidget(widget), configDefault(def) { /* */ } public: void setValue(const QVariant &value) const; QVariant value() const; void connectValueChanged(QObject *receiver, const char slot[]) const; QString configLabel() const; QString comboLabel(int index) const; public: QWidget *configWidget; QVariant configDefault; QVariant configSaved; }; private: typedef QList ItemList; private: ItemList items; }; void ConfigManager::ConfigItem::setValue(const QVariant &value) const { if (QCheckBox *widget = qobject_cast(configWidget)) { widget->setChecked(value.toBool()); } else if (QSpinBox *widget = qobject_cast(configWidget)) { widget->setValue(value.toInt()); } else if (QDoubleSpinBox *widget = qobject_cast(configWidget)) { widget->setValue(value.toDouble()); } else if (QAbstractSlider *widget = qobject_cast(configWidget)) { widget->setValue(value.toInt()); } else if (QLineEdit *widget = qobject_cast(configWidget)) { widget->setText(value.toString()); } else if (QComboBox *widget = qobject_cast(configWidget)) { int index; if (widget->isEditable()) { index = widget->findText(value.toString()); if (index < 0) { if (widget->isEditable()) { widget->addItem(value.toString()); index = widget->findText(value.toString()); } else { return; } } } else { index = 0; for (int i = widget->count(); --i >= 0; ) { if (value.toString() == comboLabel(i)) { index = i; break; } } } widget->setCurrentIndex(index); } } QVariant ConfigManager::ConfigItem::value() const { if (QCheckBox *widget = qobject_cast(configWidget)) { return widget->isChecked(); } else if (QSpinBox *widget = qobject_cast(configWidget)) { return widget->value(); } else if (QDoubleSpinBox *widget = qobject_cast(configWidget)) { return widget->value(); } else if (QAbstractSlider *widget = qobject_cast(configWidget)) { return widget->value(); } else if (QLineEdit *widget = qobject_cast(configWidget)) { return widget->text(); } else if (QComboBox *widget = qobject_cast(configWidget)) { if (widget->isEditable()) { return widget->currentText(); } else { return comboLabel(widget->currentIndex()); } } return QVariant(); } void ConfigManager::ConfigItem::connectValueChanged(QObject *receiver, const char slot[]) const { if (QCheckBox *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(toggled(bool)), receiver, slot); } else if (QSpinBox *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(valueChanged(int)), receiver, slot); } else if (QDoubleSpinBox *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(valueChanged(double)), receiver, slot); } else if (QAbstractSlider *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(valueChanged(int)), receiver, slot); } else if (QLineEdit *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(textChanged(QString)), receiver, slot); } else if (QComboBox *widget = qobject_cast(configWidget)) { if (widget->isEditable()) { QObject::connect(widget, SIGNAL(editTextChanged(QString)), receiver, slot); } else { QObject::connect(widget, SIGNAL(currentIndexChanged(int)), receiver, slot); } } } QString ConfigManager::ConfigItem::configLabel() const { QString cmName = configWidget->objectName().mid(3); if (QComboBox *widget = qobject_cast(configWidget)) { if (!widget->isEditable()) { int index = -1; for (int i = widget->count(); --i >= 0;) { index = cmName.lastIndexOf(QChar('_', 0), index - 1); } cmName = cmName.left(index); } } return cmName.replace(QChar('_', 0), QChar('/', 0)); } QString ConfigManager::ConfigItem::comboLabel(int index) const { QString cmName = configWidget->objectName().mid(3); int scanIndex = -1; int lastIndex = -1; // avoid warning for (int i = qobject_cast(configWidget)->count() - index; --i >= 0; ) { lastIndex = scanIndex; scanIndex = cmName.lastIndexOf(QChar('_', 0), scanIndex - 1); } ++scanIndex; if (lastIndex == -1) { cmName = cmName.mid(scanIndex); } else { cmName = cmName.mid(scanIndex, lastIndex - scanIndex); } return cmName; } /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/src/config/skulptureui.rc0000644000175000001440000000036611115100410017400 0ustar pepousers Go ToolBar skulpture-0.2.4/src/config/sk_config.cpp0000600000175000001440000003537311333366417017151 0ustar pepousers/* * sk_config.cpp - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "sk_config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*-----------------------------------------------------------------------*/ extern "C" KDE_EXPORT QWidget* allocate_kstyle_config(QWidget* parent) { return new SkulptureStyleConfig(parent); } /*-----------------------------------------------------------------------*/ #include "ui_sk_preview1.h" class Preview1Window : public QDialog, private Ui::SkulpturePreview1 { public: explicit Preview1Window(QWidget *parent = 0); public: virtual void closeEvent(QCloseEvent *e); QLayout *dialogLayout() const { return verticalLayout_9; } private: void init(); }; Preview1Window::Preview1Window(QWidget *parent) : QDialog(parent) { init(); } void Preview1Window::closeEvent(QCloseEvent *e) { e->ignore(); } void Preview1Window::init() { setWindowFlags(Qt::Widget); setupUi(this); } /*-----------------------------------------------------------------------*/ #include "ui_sk_preview2.h" class Preview2Window : public KXmlGuiWindow, private Ui::SkulpturePreview2 { public: explicit Preview2Window(QWidget *parent, const KComponentData &componentData); public: virtual void closeEvent(QCloseEvent *e); private: void init(const KComponentData &componentData); }; Preview2Window::Preview2Window(QWidget *parent, const KComponentData &componentData) : KXmlGuiWindow(parent) { init(componentData); } void Preview2Window::closeEvent(QCloseEvent *e) { e->ignore(); } static const KStandardAction::StandardAction standardAction[] = { KStandardAction::New, KStandardAction::Open, KStandardAction::OpenRecent, KStandardAction::Save, KStandardAction::SaveAs, KStandardAction::Revert, KStandardAction::Close, // Print, PrintPreview, Mail, KStandardAction::Quit, // KStandardAction::Undo, KStandardAction::Redo, KStandardAction::Cut, KStandardAction::Copy, KStandardAction::Paste, // SelectAll, Deselect, KStandardAction::Find, KStandardAction::FindNext, KStandardAction::FindPrev, KStandardAction::Replace, // ActualSize, FitToPage, FitToWidth, FitToHeight, ZoomIn, ZoomOut, Zoom, Redisplay, KStandardAction::Up, KStandardAction::Back, KStandardAction::Forward, KStandardAction::Home, // Prior, Next, Goto, GotoPage, GotoLine, // FirstPage, LastPage, DocumentBack, DocumentForward, // AddBookmark, EditBookmarks, Spelling, KStandardAction::ShowMenubar, KStandardAction::ShowToolbar, KStandardAction::ShowStatusbar, /*SaveOptions, */ KStandardAction::KeyBindings, /*Preferences, */ KStandardAction::ConfigureToolbars, // Help, HelpContents, WhatsThis, ReportBug, AboutApp, AboutKDE, // TipofDay, ConfigureNotifications, FullScreen, Clear, // PasteText, SwitchApplicationLanguage, KStandardAction::ActionNone }; void Preview2Window::init(const KComponentData &componentData) { setWindowFlags(Qt::Widget); setupUi(this); setHelpMenuEnabled(false); setComponentData(componentData); for (uint i = 0; i < sizeof(standardAction) / sizeof(standardAction[0]); ++i) { if (standardAction[i] != KStandardAction::ActionNone) { actionCollection()->addAction(standardAction[i]); } } createGUI(); //menuBar()->removeAction(menuBar()->actions().last()); KHelpMenu *helpMenu = new KHelpMenu(this, componentData.aboutData(), false); menuBar()->addMenu((QMenu *) helpMenu->menu()); statusBar()->setSizeGripEnabled(true); //setToolButtonStyle(Qt::ToolButtonIconOnly); } /*-----------------------------------------------------------------------*/ void SkulptureStyleConfig::subWindowActivated(QMdiSubWindow *window) { if (window) { QWidget *parent = window->parentWidget(); if (parent) { const QList children = parent->children(); Q_FOREACH (QObject *child, children) { QWidget *widget = qobject_cast(child); if (widget) { widget->setWindowTitle(QLatin1String(child == window ? "Active Window" : "Inactive Window")); } } } } } void SkulptureStyleConfig::updatePreview() { QStyle *style = QStyleFactory::create(QLatin1String("skulpture")); if (style) { int index = style->metaObject()->indexOfMethod("skulpturePrivateMethod(SkulpturePrivateMethod,void*)"); if (index >= 0) { QUuid uuid = QUuid::createUuid(); QDir tempDir = QDir::temp(); // ### we may add a way to avoid the file completely. QString fileName = QLatin1String("skulpture-temp-settings-") + uuid.toString() + QLatin1String(".ini"); QString absFileName = tempDir.absoluteFilePath(fileName); { QSettings s(absFileName, QSettings::IniFormat); configManager.save(s); // make visible in other process s.sync(); } SkMethodDataSetSettingsFileName data; data.version = 1; data.fileName = absFileName; int result; int id = SkulptureStyle::SPM_SetSettingsFileName; void *dat = &data; void *param[] = {&result, &id, &dat}; style->qt_metacall(QMetaObject::InvokeMetaMethod, index, param); tempDir.remove(fileName); int margin = style->pixelMetric(QStyle::PM_DefaultTopLevelMargin); dialogLayout->setContentsMargins(margin, margin, margin, margin); QList windows = mdiArea->findChildren(); Q_FOREACH (QMdiSubWindow *window, windows) { window->setFocusPolicy(Qt::FocusPolicy(window->focusPolicy() & ~Qt::TabFocus)); QList widgets = window->widget()->findChildren(); Q_FOREACH (QWidget *widget, widgets) { // TODO: only update widgets that have changes in settings widget->setStyle(style); if (widget->inherits("QTextEdit") || (widget->parentWidget() && widget->parentWidget()->inherits("QTextEdit"))) { widget->setFocusPolicy(Qt::ClickFocus); } else { widget->setFocusPolicy(Qt::FocusPolicy(widget->focusPolicy() & ~Qt::TabFocus)); } } } } } if (oldStyle) { delete oldStyle; } oldStyle = style; } /*-----------------------------------------------------------------------*/ SkulptureStyleConfig::SkulptureStyleConfig(QWidget *parent) : QWidget(parent), oldStyle(0) { init(); } enum PreviewPosition { PP_Auto, PP_Hidden, PP_InTab, PP_Left, PP_Top, PP_Right, PP_Bottom }; void SkulptureStyleConfig::init() { aboutData = new KAboutData("skulpture", 0, ki18n("Sculpture"), "0.2.4", ki18n("Three-dimensional classical artwork."), #if KDE_IS_VERSION(4,1,0) KAboutData::License_GPL_V3, #else KAboutData::License_GPL, #endif ki18n("(c) 2007-2010, Christoph Feck"), KLocalizedString(), "http://skulpture.maxiom.de/", "christoph@maxiom.de"); KComponentData tempComponentData(aboutData); aboutData->addAuthor(ki18n("Christoph Feck"), ki18n("Developer"), "christoph@maxiom.de", "http://kdepepo.wordpress.com/"); QString imageFileName = KStandardDirs::locate("appdata", QLatin1String("pics/skulpture.png"), tempComponentData); aboutData->setProgramLogo(QImage(imageFileName)); componentData = new KComponentData(aboutData); KGlobal::locale()->insertCatalog(QLatin1String("kstyle_skulpture_config")); setupUi(this); QList children = tabWidget->findChildren(); Q_FOREACH (QWidget *child, children) { if (!(child->isEnabled())) { child->hide(); } } QSize availableSize = QApplication::desktop()->availableGeometry(this).size(); QSettings s(QSettings::IniFormat, QSettings::UserScope, QLatin1String("SkulptureStyle"), QLatin1String("")); QString previewPositionText = s.value(QLatin1String("ConfigDialog/PreviewPosition"), QLatin1String("auto")).toString().toLower(); PreviewPosition previewPosition = PP_Auto; switch (previewPositionText.at(0).unicode()) { case 'a': default: previewPosition = PP_Auto; break; case 'l': previewPosition = PP_Left; break; case 't': previewPosition = PP_Top; break; case 'b': previewPosition = PP_Bottom; break; case 'r': previewPosition = PP_Right; break; case 'c': // center case 'i': previewPosition = PP_InTab; break; case 'n': // none case 'h': previewPosition = PP_Hidden; break; } if (previewPosition == PP_Auto) { if (availableSize.height() < 700) { if (availableSize.width() < 800) { previewPosition = PP_InTab; } else { previewPosition = PP_Left; } } else { previewPosition = PP_Top; } } switch (previewPosition) { case PP_Left: mdiArea->setMinimumSize(QSize(qMin(570, availableSize.width() - 400), 290)); vboxLayout->setDirection(QBoxLayout::LeftToRight); break; case PP_Top: mdiArea->setMinimumSize(QSize(570, 290)); break; case PP_Right: mdiArea->setMinimumSize(QSize(qMin(570, availableSize.width() - 400), 290)); vboxLayout->setDirection(QBoxLayout::RightToLeft); break; case PP_Bottom: mdiArea->setMinimumSize(QSize(570, 290)); vboxLayout->setDirection(QBoxLayout::BottomToTop); break; case PP_InTab: tabWidget->addTab(mdiArea, QLatin1String("Preview")); break; case PP_Hidden: mdiArea->hide(); break; case PP_Auto: // avoid warning break; } mdiArea->setBackground(QColor(120, 120, 150)); tabWidget->setCurrentIndex(0); // KConfig wm(QLatin1String("kwinskulpturerc"), KConfig::FullConfig); // KConfigGroup group = wm.group("WM"); // QColor activeBackground; // QString c = group.readEntry("activeBackground"); // qDebug() << "activeBackground = " << c; connect(this, SIGNAL(changed(bool)), this, SLOT(updatePreview())); connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subWindowActivated(QMdiSubWindow *))); configManager.addWidgets(this); configManager.load(s); if (cm_General_TextShift->value() > 0) { cm_General_TextShift->setPrefix(QLatin1String("+")); } else { cm_General_TextShift->setPrefix(QString()); } #if 1 #if 1 QMdiSubWindow *previewwindow2 = new QMdiSubWindow(mdiArea); // previewwindow2->setObjectName(QLatin1String("SkulpturePreviewWindow")); // previewwindow2->setProperty("sk_kwin_activeBackground", previewwindow2->setStyle(QStyleFactory::create(QLatin1String("skulpture"))); previewWindow = new Preview2Window(previewwindow2, *componentData); previewwindow2->setWidget(previewWindow); previewwindow2->setGeometry(107, 7, 450, 265); #endif #if 1 QMdiSubWindow *previewwindow1 = new QMdiSubWindow(mdiArea); // previewwindow1->setObjectName(QLatin1String("SkulpturePreviewWindow")); previewwindow1->setStyle(QStyleFactory::create(QLatin1String("skulpture"))); Preview1Window *preview = new Preview1Window(previewwindow1); previewwindow1->setWidget(preview); previewwindow1->setGeometry(7, 35, 450, 245); dialogLayout = preview->dialogLayout(); #endif updatePreview(); #else mdiArea->hide(); #endif KAcceleratorManager::manage(this); configManager.connectConfigChanged(this, SLOT(updateChanged())); } void SkulptureStyleConfig::showEvent(QShowEvent *) { cm_General_TextShift->setFocus(Qt::ActiveWindowFocusReason); } QSize SkulptureStyleConfig::sizeHint() const { return QSize(570, 0); } SkulptureStyleConfig::~SkulptureStyleConfig() { KGlobal::locale()->removeCatalog(QLatin1String("kstyle_skulpture_config")); if (previewWindow) { previewWindow->hide(); previewWindow->setParent(0); #if KDE_IS_VERSION(4,1,1) KGlobal::setAllowQuit(false); delete previewWindow; KGlobal::setAllowQuit(true); #else // ### replacement code for older KDE versions? //KGlobal::ref(); delete previewWindow; //KGlobal::deref(); #endif } delete componentData; delete aboutData; } /*-----------------------------------------------------------------------*/ void SkulptureStyleConfig::save() { QSettings s(QSettings::IniFormat, QSettings::UserScope, QLatin1String("SkulptureStyle"), QLatin1String("")); configManager.save(s); } void SkulptureStyleConfig::defaults() { configManager.defaults(); } void SkulptureStyleConfig::updateChanged() { if (cm_General_TextShift->value() > 0) { cm_General_TextShift->setPrefix(QLatin1String("+")); } else { cm_General_TextShift->setPrefix(QString()); } Q_EMIT changed(configManager.hasChanged()); } /*-----------------------------------------------------------------------*/ #include "sk_config.moc" skulpture-0.2.4/src/config/skulpture.png0000644000175000001440000000025611115155316017237 0ustar pepousersPNG  IHDR@@PLTEϫܕ*TIDATXA Q+GZDqH= p P$Z-0 j] oV hQE`IENDB`skulpture-0.2.4/src/config/sk_config.h0000600000175000001440000000503311163031264016572 0ustar pepousers/* * sk_config.h - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef SKULPTURE_CONFIG_H #define SKULPTURE_CONFIG_H 1 /*-----------------------------------------------------------------------*/ #include #include "ui_sk_dialog.h" #include "configmanager.h" class QSettings; class QMdiSubWindow; class KXmlGuiWindow; class KAboutData; class KComponentData; class SkulptureStyleConfig : public QWidget, private Ui::SkulptureStyleDialog { Q_OBJECT public: explicit SkulptureStyleConfig(QWidget* parent = 0); virtual ~SkulptureStyleConfig(); virtual QSize sizeHint() const; Q_SIGNALS: void changed(bool); public Q_SLOTS: void save(); void defaults(); protected Q_SLOTS: void updateChanged(); void updatePreview(); private Q_SLOTS: void subWindowActivated(QMdiSubWindow *window); protected: void showEvent(QShowEvent *); private: void init(); private: ConfigManager configManager; QLayout *dialogLayout; KXmlGuiWindow *previewWindow; KAboutData *aboutData; KComponentData *componentData; QStyle *oldStyle; }; /*-----------------------------------------------------------------------*/ #include struct SkMethodData { int version; }; struct SkMethodDataSetSettingsFileName : public SkMethodData { // in version 1 QString fileName; }; class SkulptureStyle : public QStyle { Q_OBJECT public: // internal, reserved for future use enum SkulpturePrivateMethod { SPM_SupportedMethods = 0, SPM_SetSettingsFileName = 1 }; public Q_SLOTS: int skulpturePrivateMethod(SkulpturePrivateMethod /*id*/, void */*data*/ = 0) { return 0; } }; /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/src/skulpture.cpp0000644000175000001440000141413711333667520016007 0ustar pepousers/* * Skulpture - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2007-2010 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ // ### This file is a mess #include "skulpture_p.h" #include #include #include #include #include #include #include #include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*-----------------------------------------------------------------------*/ #include class SkulptureStylePlugin : public QStylePlugin { public: QStringList keys() const { return QStringList(QLatin1String("Skulpture")); } QStyle *create(const QString &key) { if (key.toLower() == QLatin1String("skulpture")) { return new SkulptureStyle; } return 0; } }; Q_EXPORT_PLUGIN2(skulpture, SkulptureStylePlugin) /*-----------------------------------------------------------------------*/ SkulptureStyle::SkulptureStyle() : d(new Private) { d->q = this; } SkulptureStyle::~SkulptureStyle() { delete d; } /*-----------------------------------------------------------------------*/ void SkulptureStyle::polish(QApplication *application) { // ParentStyle::polish(application); // return; #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) QString recursionCheck = QLatin1String("\n/* -skulpture-recursion-check- */\n"); if (!d->styleSheetFileName.isEmpty()) { QString oldStyle = application->styleSheet(); if (!oldStyle.contains(recursionCheck)) { QFile file(d->styleSheetFileName); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); QString newStyle = stream.readAll(); application->setStyleSheet(newStyle + recursionCheck + oldStyle); } } } #endif ParentStyle::polish(application); application->installEventFilter(d->shortcut_handler); #if 0 QPalette palette; polish(palette); application->setPalette(palette); #endif // if (application->inherits("KApplication")) { // qDebug() << "KApplication is a" << application->metaObject()->className() << "(" << "object name:" << application->objectName() << ")"; // } // QFontMetrics fm = QFontMetrics(QFont()); // printf("h:%d, s:%d, xh:%d, xb:%d, Xb:%d, Xyb: %d\n", fm.height(), fm.lineSpacing(), fm.xHeight(), fm.boundingRect(QChar('x', 0)).height(), fm.boundingRect(QChar('X', 0)).height(), fm.boundingRect(QLatin1String("Xy")).height()); } void SkulptureStyle::unpolish(QApplication *application) { application->removeEventFilter(d->shortcut_handler); ParentStyle::unpolish(application); } /*-----------------------------------------------------------------------*/ enum SidebarViewMode { DefaultSidebar, TransparentSidebar }; static void polishSidebarView(QAbstractItemView *view, SidebarViewMode viewMode) { QWidget *viewport = view->viewport(); QPalette palette = view->palette(); if (viewMode == TransparentSidebar) { if (viewport->autoFillBackground()) { viewport->setAutoFillBackground(false); QPalette::ColorRole textRole = viewport->foregroundRole(); if (textRole != QPalette::WindowText) { palette.setBrush(QPalette::Active, textRole, palette.brush(QPalette::Active, QPalette::WindowText)); palette.setBrush(QPalette::Inactive, textRole, palette.brush(QPalette::Inactive, QPalette::WindowText)); palette.setBrush(QPalette::Disabled, textRole, palette.brush(QPalette::Disabled, QPalette::WindowText)); viewport->setPalette(palette); } } view->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); } else { if (viewport->autoFillBackground()) { palette.setBrush(QPalette::Active, QPalette::Window, palette.brush(QPalette::Active, QPalette::Base)); palette.setBrush(QPalette::Inactive, QPalette::Window, palette.brush(QPalette::Inactive, QPalette::Base)); palette.setBrush(QPalette::Disabled, QPalette::Window, palette.brush(QPalette::Disabled, QPalette::Base)); } else { viewport->setAutoFillBackground(true); } view->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); viewport->setPalette(palette); } } /*-----------------------------------------------------------------------*/ #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) static WidgetShadow *findShadow(QWidget *widget) { QWidget *parent = widget->parentWidget(); if (parent) { QList shadows = parent->findChildren(); Q_FOREACH (WidgetShadow *shadow, shadows) { if (shadow->widget() == widget) { return shadow; } } } return 0; } #endif void SkulptureStyle::polish(QWidget *widget) { // ParentStyle::polish(widget); // return; #if 1 //printf("polishing a \"%s\" (which is a \"%s\")\n", widget->metaObject()->className(), widget->metaObject()->superClass()->className()); #if 0 QPalette palette = widget->palette(); polish(palette); widget->setPalette(palette); #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (QMdiArea *area = qobject_cast(widget)) { area->installEventFilter(d); } if (qobject_cast(widget)) { WidgetShadow *shadow = findShadow(widget); if (!shadow) { widget->installEventFilter(d); if (widget->parentWidget()) { WidgetShadow *shadow = new WidgetShadow(widget->parentWidget()); shadow->setWidget(widget); shadow->updateZOrder(); shadow->show(); } } } #endif #if 1 if (QLCDNumber *lcd = qobject_cast(widget)) { QPalette palette; palette.setColor(QPalette::Base, QColor(220, 230, 210)); palette.setColor(QPalette::WindowText, QColor(60, 60, 60)); // lcd->setPalette(palette); // lcd->installEventFilter(d); // lcd->setContentsMargins(8, 8, 8, 8); lcd->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); lcd->setSegmentStyle(QLCDNumber::Flat); } #endif #if 1 if (QDialog *dialog = qobject_cast(widget)) { dialog->installEventFilter(d); } #endif #if 0 if (QMainWindow *window = qobject_cast(widget)) { window->setBackgroundRole(QPalette::Dark); } if (QDockWidget *dock = qobject_cast(widget)) { dock->installEventFilter(d); } if (QStatusBar *bar = qobject_cast(widget)) { bar->installEventFilter(d); } #endif if (QToolBox *toolBox = qobject_cast(widget)) { toolBox->setBackgroundRole(QPalette::Window); // toolBox->setContentsMargins(2, 2, 2, 2); // toolBox->installEventFilter(d); toolBox->layout()->setSpacing(0); } if (widget->inherits("KTitleWidget")) { // widget->setMaximumHeight(0); #if 0 QPalette palette = widget->palette(); palette.setColor(QPalette::Base, palette.color(QPalette::Window)); palette.setColor(QPalette::Text, palette.color(QPalette::WindowText)); widget->setPalette(palette); #endif } if (qobject_cast(widget)) { widget->installEventFilter(d); widget->setAttribute(Qt::WA_OpaquePaintEvent, false); } if (QFrame *frame = qobject_cast(widget)) { switch (frame->frameShape()) { case QFrame::Panel: case QFrame::WinPanel: case QFrame::Box: frame->setFrameShape(QFrame::StyledPanel); break; case QFrame::HLine: case QFrame::VLine: frame->setEnabled(false); break; default: break; } if (frame->frameShadow() == QFrame::Plain && frame->backgroundRole() == QPalette::Base) { if (frame->parentWidget() && frame->parentWidget()->inherits("KTitleWidget")) { frame->setBackgroundRole(QPalette::Window); } } #if 1 if (!strcmp(widget->metaObject()->className(), "QListWidget") && widget->parentWidget() && !strcmp(widget->parentWidget()->metaObject()->className(), "Sidebar")) { //(static_cast(widget))->setFrameStyle(QFrame::Plain | QFrame::StyledPanel); (static_cast(widget))->setFrameStyle(QFrame::NoFrame); } if (!strcmp(widget->metaObject()->className(), "Kontact::Navigator")) { // (static_cast(widget))->viewport()->setBackgroundRole(QPalette::Base); // (static_cast(widget))->viewport()->setAutoFillBackground(true); (static_cast(widget))->setFrameStyle(QFrame::Plain | QFrame::StyledPanel); // polishSidebarView(static_cast(widget), d->transparentPlacesPanel ? TransparentSidebar : DefaultSidebar); } if (widget->inherits("SidebarTreeView")) { polishSidebarView(static_cast(widget), DefaultSidebar); } if (widget->inherits("KHTMLView")) { // QPalette palette = widget->palette(); // palette.setColor(QPalette::Window, palette.color(QPalette::Base)); // ((QAbstractScrollArea *) widget)->viewport()->setPalette(palette); // printf("frame style is 0x%08x\n", ((QFrame *) widget)->frameStyle()); if (d->expensiveShadows) { ((QFrame *) widget)->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); } } #endif #if 1 if (widget->inherits("KFilePlacesView")) { polishSidebarView(static_cast(widget), d->transparentPlacesPanel ? TransparentSidebar : DefaultSidebar); } #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) if (widget->inherits("QPlainTextEdit")) { QPlainTextEdit *edit = static_cast(widget); // QPalette palette = edit->palette(); // palette.setColor(QPalette::Window, QColor(245, 245, 245)); // edit->setPalette(palette); // edit->viewport()->setPalette(palette); edit->setBackgroundVisible(false); edit->viewport()->installEventFilter(d); edit->installEventFilter(d); widget->setAttribute(Qt::WA_Hover, true); } #endif #if 1 if (QTextEdit *edit = qobject_cast(widget)) { #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) if (!qstrcmp(widget->metaObject()->className(), "SampleEdit")) { QWidget *bg = new QWidget(widget); bg->lower(); bg->setObjectName(QLatin1String("sample_background")); bg->setGeometry(2, 2, widget->width() - 4, widget->height() - 4); bg->setAutoFillBackground(true); bg->show(); } else #endif { d->mapper.setMapping(edit, edit); connect(edit, SIGNAL(textChanged()), &d->mapper, SLOT(map())); connect(&d->mapper, SIGNAL(mapped(QWidget *)), d, SLOT(textEditSourceChanged(QWidget *))); d->updateTextEditMargins(edit); } edit->viewport()->installEventFilter(d); edit->installEventFilter(d); widget->setAttribute(Qt::WA_Hover, true); if (qstrcmp(widget->metaObject()->className(), "IRCInput")) { if (!d->allowTabulations) { edit->setTabChangesFocus(true); } } #if 0 if (QTextBrowser *browser = qobject_cast(widget)) { connect(browser, SIGNAL(sourceChanged()), &d->mapper, SLOT(map())); } #endif } #endif } #if 0 if (QComboBox *combo = qobject_cast(widget)) { if (!combo->isEditable()) { combo->setBackgroundRole(QPalette::Button); combo->setForegroundRole(QPalette::ButtonText); } } if (qobject_cast(widget) || qobject_cast(widget)) { widget->setBackgroundRole(QPalette::Window); widget->setForegroundRole(QPalette::WindowText); } #endif if (qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget)) { widget->setAttribute(Qt::WA_Hover, true); } #if 0 if (d->allowScrollBarSliderToCoverArrows && qobject_cast(widget)) { widget->installEventFilter(d); } #endif #if 0 if (widget->inherits("Q3ProgressBar")) { widget->installEventFilter(d); if (widget->isVisible()) { d->setAnimated(widget, true); } } #endif if (QProgressBar *pbar = qobject_cast(widget)) { pbar->installEventFilter(d); if (pbar->isVisible() && !widget->inherits("StatusBarSpaceInfo")) { d->setAnimated(pbar, true); } } #if 1 if (qobject_cast(widget)) { widget->installEventFilter(d); } if (QToolBar *toolbar = qobject_cast(widget)) { QFont font; font.setPointSizeF(font.pointSizeF() / (1.19)); QList children = toolbar->findChildren(); Q_FOREACH (QToolButton *child, children) { if (!child->icon().isNull()) { child->setFont(font); } } connect(toolbar, SIGNAL(orientationChanged(Qt::Orientation)), d, SLOT(updateToolBarOrientation(Qt::Orientation))); toolbar->setBackgroundRole(QPalette::Window); } if (widget->inherits("Q3ToolBar")) { widget->setBackgroundRole(QPalette::Window); } #endif #if 0 // FIXME does not work if (QMenu *menu = qobject_cast(widget)) { #if 1 QFont font; QFont oldfont; oldfont.setPointSizeF(oldfont.pointSizeF() * 1.0001); font.setPointSizeF(font.pointSizeF() / (1.19 /* * 1.19*/)); font.setBold(true); menu->setFont(font); /* QAction *action = menu->menuAction(); action->setFont(oldfont); QList children = action->findChildren(); Q_FOREACH (QAction *child, children) { child->setFont(oldfont); }*/ #else menu->setStyleSheet(QLatin1String("font-size: 6.5")/*.arg(menu->font().pointSizeF() / (1.19 * 1.19))*/); #endif } #endif #if 0 // FIXME does not work if (QGroupBox *group = qobject_cast(widget)) { QFont oldfont; #if 0 if (group->testAttribute(Qt::WA_SetFont)) { QFont oldfont = group->fontInfo(); } #endif QFont font = oldfont; font.setPointSizeF(font.pointSizeF() * 1.19); font.setBold(true); group->setFont(font); QList children = group->findChildren(); Q_FOREACH (QWidget *child, children) { if (1 || !(child->testAttribute(Qt::WA_SetFont))) { printf("reset\n"); child->setFont(oldfont); } } } #endif #if 1 if (widget->inherits("Q3Header")) { QFont font; font.setPointSizeF(font.pointSizeF() / (1.19 /* 1.19*/)); font.setBold(true); widget->setFont(font); } #endif if (QAbstractScrollArea *area = qobject_cast(widget)) { if (QAbstractItemView *iv = qobject_cast(widget)) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) // ### Qt issue // iv->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); // iv->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); // QApplication::setWheelScrollLines(64); iv = iv; #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) iv->viewport()->setAttribute(Qt::WA_Hover); if (QTreeView *tree = qobject_cast(widget)) { iv->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); if (tree->uniformRowHeights()) { iv->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); } } else if (QListView *list = qobject_cast(widget)) { if (list->uniformItemSizes()) { iv->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); iv->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); } } else if (qobject_cast(widget)) { iv->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); iv->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); } #endif #if 1 if (QHeaderView *header = qobject_cast(widget)) { QFont font; font.setPointSizeF(font.pointSizeF() / (1.19 /* 1.19*/)); font.setBold(true); header->setFont(font); // FIXME workaround for Qt 4.3 header->headerDataChanged(header->orientation(), 0, 0); header->updateGeometry(); } #endif } if (area->frameStyle() == (QFrame::StyledPanel | QFrame::Sunken)) { d->installFrameShadow(area); } } if (d->expensiveShadows) { if (widget->inherits("Konsole::TerminalDisplay") || widget->inherits("KTextEditor::View") || widget->inherits("KHTMLView")) { // ((QFrame *) widget)->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); d->installFrameShadow(widget); } } #if 0 if (widget->inherits("KTextEditor::View")) { QWidget *parent = widget->parentWidget(); if (parent) { QFrame *frame = new QFrame(parent); if (frame) { frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); widget->setParent(frame); } } } #endif #if 1 if (widget->inherits("KCharSelectTable")) { QPalette palette; widget->setPalette(palette); } #endif #if 1 if (widget->inherits("KFadeWidgetEffect")) { widget->installEventFilter(d); } #endif if (widget->inherits("Q3ScrollView")) { QFrame *frame = qobject_cast(widget); if (frame && frame->frameStyle() == (QFrame::StyledPanel | QFrame::Sunken)) { d->installFrameShadow(widget); } } #endif #if 0 if (QTabWidget *tab = qobject_cast(widget)) { if (QToolButton *button = qobject_cast(tab->cornerWidget(Qt::TopRightCorner))) { button->setAutoRaise(true); } if (QToolButton *button = qobject_cast(tab->cornerWidget(Qt::TopLeftCorner))) { button->setAutoRaise(true); } } #endif #if 1 if (QToolButton *button = qobject_cast(widget)) { if (qobject_cast(button->parentWidget())) { button->setAutoRaise(true); } } #endif if (!qstrcmp(widget->metaObject()->className(), "QToolBoxButton")) { widget->setAttribute(Qt::WA_Hover, true); } if (!qstrcmp(widget->metaObject()->className(), "KLineEditButton")) { widget->installEventFilter(d); widget->setAttribute(Qt::WA_Hover, true); } if (qobject_cast(widget)) { widget->unsetCursor(); widget->installEventFilter(d); widget->setMouseTracking(true); } if (QLayout *layout = widget->layout()) { // explicitely check public layout classes, QMainWindowLayout doesn't work here if (qobject_cast(layout) #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) || qobject_cast(layout) #endif || qobject_cast(layout) || qobject_cast(layout)) { d->polishLayout(layout); } } if (!qstrcmp(widget->metaObject()->className(), "InfoSidebarPage") || !qstrcmp(widget->metaObject()->className(), "InformationPanel")) { widget->installEventFilter(d); } #if 0//(QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) if (widget->inherits("KTabWidget") && widget->property("closeButtonEnabled").toBool()) { widget->setProperty("tabsClosable", true); widget->setProperty("closeButtonEnabled", false); connect(widget, SIGNAL(tabCloseRequested(int)), widget, SIGNAL(closeRequest(int))); } if (widget->inherits("KTabBar")) { widget->setProperty("tabsClosable", true); connect(widget, SIGNAL(tabCloseRequested(int)), widget, SIGNAL(closeRequest(int))); } #endif if (d->visualizeLayouts) { widget->installEventFilter(d); } ParentStyle::polish(widget); } void SkulptureStyle::unpolish(QWidget *widget) { ParentStyle::unpolish(widget); if (d->visualizeLayouts) { widget->removeEventFilter(d); } // return; if (qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) // || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget)) { widget->setAttribute(Qt::WA_Hover, false); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (qobject_cast(widget)) { widget->removeEventFilter(d); } if (QMdiSubWindow *win = qobject_cast(widget)) { win->removeEventFilter(d); WidgetShadow *shadow = findShadow(win); if (shadow) { shadow->hide(); shadow->setParent(0); shadow->deleteLater(); } } #endif #if 1 if (QDialog *dialog = qobject_cast(widget)) { dialog->removeEventFilter(d); } #endif #if 0 if (QLCDNumber *lcd = qobject_cast(widget)) { lcd->removeEventFilter(d); } if (QToolBox *toolBox = qobject_cast(widget)) { toolBox->removeEventFilter(d); } if (QDockWidget *dock = qobject_cast(widget)) { dock->removeEventFilter(d); } if (QStatusBar *status = qobject_cast(widget)) { status->removeEventFilter(d); } #endif #if 0 if (/*d->allowScrollBarSliderToCoverArrows &&*/ qobject_cast(widget)) { widget->installEventFilter(d); } #endif if (QProgressBar *pbar = qobject_cast(widget)) { pbar->removeEventFilter(d); d->setAnimated(pbar, false); return; } if (QAbstractScrollArea *area = qobject_cast(widget)) { area->removeEventFilter(d); if (/*QAbstractItemView *iv =*/qobject_cast(widget)) { #if 1 if (QHeaderView *header = qobject_cast(widget)) { QFont font; // font.setPointSizeF(font.pointSizeF() / (1.19 * 1.19)); // font.setBold(true); header->setFont(font); // FIXME workaround for Qt 4.3 header->headerDataChanged(header->orientation(), 0, 0); header->updateGeometry(); } #endif } /* if (QMdiArea *area = qobject_cast(widget)) { area->viewport()->removeEventFilter(d); } */ d->removeFrameShadow(area); } if (d->expensiveShadows) { if (widget->inherits("Konsole::TerminalDisplay") || widget->inherits("KTextEditor::View") || widget->inherits("KHTMLView")) { widget->removeEventFilter(d); d->removeFrameShadow(widget); } } if (widget->inherits("Q3ScrollView")) { widget->removeEventFilter(d); d->removeFrameShadow(widget); } #if 1 if (widget->inherits("KFadeWidgetEffect")) { widget->removeEventFilter(d); } #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) if (widget->inherits("QPlainTextEdit")) { QPlainTextEdit *edit = static_cast(widget); edit->viewport()->removeEventFilter(d); edit->removeEventFilter(d); } #endif if (qobject_cast(widget)) { widget->removeEventFilter(d); widget->setAttribute(Qt::WA_OpaquePaintEvent, true); } if (QTextEdit *edit = qobject_cast(widget)) { #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) if (!qstrcmp(widget->metaObject()->className(), "SampleEdit")) { QList children = widget->children(); Q_FOREACH (QObject *child, children) { if (child->objectName() == QLatin1String("sample_background")) { child->setParent(0); child->deleteLater(); } } } else #endif { d->mapper.removeMappings(edit); } edit->viewport()->removeEventFilter(d); edit->removeEventFilter(d); } if (QToolBar *toolbar = qobject_cast(widget)) { QFont font; // font.setPointSizeF(font.pointSizeF() / (1.19)); QList children = toolbar->findChildren(); Q_FOREACH (QToolButton *child, children) { if (!child->icon().isNull()) { child->setFont(font); } } disconnect(toolbar, SIGNAL(orientationChanged(Qt::Orientation)), d, SLOT(updateToolBarOrientation(Qt::Orientation))); } if (!qstrcmp(widget->metaObject()->className(), "KLineEditButton")) { widget->removeEventFilter(d); } if (qobject_cast(widget)) { widget->setMouseTracking(false); widget->removeEventFilter(d); widget->setCursor(Qt::IBeamCursor); } if (!d->postEventWidgets.isEmpty()) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) d->postEventWidgets.removeOne(widget); #else d->postEventWidgets.removeAll(widget); #endif } if ((QWidget *) d->oldEdit == widget) { d->oldEdit = 0; } if (!qstrcmp(widget->metaObject()->className(), "InfoSidebarPage") || !qstrcmp(widget->metaObject()->className(), "InformationPanel")) { widget->removeEventFilter(d); } if (qobject_cast(widget)) { widget->removeEventFilter(d); } } /*-----------------------------------------------------------------------*/ extern void lineEditMouseMoved(QLineEdit *lineEdit, QMouseEvent *event); void SkulptureStyle::Private::processPostEventWidgets() { QWidget *widget; while (!postEventWidgets.isEmpty() && (widget = postEventWidgets.takeFirst())) { if (QTextEdit *edit = qobject_cast(widget)) { handleCursor(edit); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) else if (QPlainTextEdit *edit = qobject_cast(widget)) { handleCursor(edit); } #endif } } void SkulptureStyle::Private::addPostEventWidget(QWidget *widget) { if (qobject_cast(widget) #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) || qobject_cast(widget) #endif ) { if (!postEventWidgets.contains(widget)) { bool signal = postEventWidgets.isEmpty(); postEventWidgets.append(widget); if (signal) { QTimer::singleShot(0, this, SLOT(processPostEventWidgets())); } } } } static void visualizeLayoutSpacing(QLayout *layout, QPainter *painter) { layout->activate(); QColor color; int spacing = -1; #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) if (QFormLayout *formLayout = qobject_cast(layout)) { spacing = formLayout->spacing(); } else #endif if (QGridLayout *gridLayout = qobject_cast(layout)) { spacing = gridLayout->spacing(); } else if (QBoxLayout *boxLayout = qobject_cast(layout)) { spacing = boxLayout->spacing(); } else { spacing = layout->spacing(); } if (spacing == 0) { color = Qt::green; } else if (spacing > 0) { color = Qt::red; } if (color.isValid()) { color.setAlpha(30); painter->fillRect(layout->geometry(), color); } else { painter->setPen(QColor(0, 150, 0, 50)); painter->drawRect(layout->geometry().adjusted(0, 0, -1, -1)); } if (qobject_cast(layout)) { painter->setPen(QColor(200, 0, 0, 150)); painter->drawRect(layout->geometry().adjusted(0, 0, -1, -1)); } for (int i = 0; i < layout->count(); ++i) { if (QLayout *childLayout = layout->itemAt(i)->layout()) { visualizeLayoutSpacing(childLayout, painter); } } } bool SkulptureStyle::Private::eventFilter(QObject *watched, QEvent *event) { #if 0 // can't happen, because widgets are the only ones to install it if (!watched->isWidgetType()) { return QObject::eventFilter(watched, event); } #endif QWidget *widget = reinterpret_cast(watched); #if 0 if (event->type() != QEvent::UpdateRequest && event->type() != QEvent::Paint) { qDebug() << "handling" << event->type() << "for object" << widget->objectName() << "which is a" << widget->metaObject()->className() << " which is a" << widget->metaObject()->superClass()->className(); } #endif #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) if (QMenu *menu = qobject_cast(widget)) { if (runtimeQtVersion() < QT_VERSION_CHECK(4, 6, 0)) { return menuEventFilter(menu, event); } } #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (qobject_cast(widget)) { WidgetShadow *shadow = findShadow(widget); switch (event->type()) { case QEvent::Move: case QEvent::Resize: if (shadow) { shadow->updateGeometry(); } break; case QEvent::ZOrderChange: if (shadow) { shadow->updateZOrder(); } break; case QEvent::Hide: case QEvent::Destroy: if (shadow) { shadow->setParent(0); shadow->hide(); shadow->deleteLater(); } break; case QEvent::Show: if (!shadow) { if (widget->parentWidget()) { shadow = new WidgetShadow(widget->parentWidget()); shadow->setWidget(widget); shadow->updateZOrder(); } } else { shadow->updateZOrder(); } default: break; } } #endif if (event->type() == QEvent::Hide || event->type() == QEvent::Destroy) { if (!postEventWidgets.isEmpty()) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) postEventWidgets.removeOne(widget); #else postEventWidgets.removeAll(widget); #endif } if ((QWidget *) oldEdit == widget) { oldEdit = 0; } } else if (event->type() != QEvent::Paint) { addPostEventWidget(widget); if (QWidget *parent = widget->parentWidget()) { addPostEventWidget(parent); if ((parent = parent->parentWidget())) { addPostEventWidget(parent); } } } switch (event->type()) { case QEvent::Paint: #if 1 // highlight current line in QTextEdit / QPlainTextEdit if (widget->objectName() == QLatin1String("qt_scrollarea_viewport")) { if (QTextEdit *edit = qobject_cast(widget->parent())) { #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) if (!qstrcmp(edit->metaObject()->className(), "SampleEdit")) { QList children = edit->children(); Q_FOREACH (QObject *child, children) { if (child->objectName() == QLatin1String("sample_background")) { QWidget *bg = qobject_cast(child); if (bg) { QPalette palette = edit->palette(); palette.setColor(QPalette::Window, palette.color(QPalette::Base)); bg->setPalette(palette); } } } } #endif // updateTextEditMargins(edit); paintCursorLine(edit); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) else if (widget->parent()->inherits("QPlainTextEdit")) { paintCursorLine(static_cast(widget->parent())); } #endif } #endif #if 1 if (visualizeLayouts) { if (!widget->font().isCopyOf(QApplication::font())) { if (widget->font() == QApplication::font()) { QPainter painter(widget); painter.fillRect(widget->rect(), QColor(255, 0, 0, 200)); } } if (!widget->palette().isCopyOf(QApplication::palette())) { if (true/*widget->palette() == QApplication::palette()*/) { QPainter painter(widget); painter.fillRect(widget->rect(), QColor(0, 200, 255, 200)); } } #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) if (!widget->styleSheet().isEmpty()) { QPainter painter(widget); painter.fillRect(widget->rect(), QColor(255, 0, 255, 100)); } #endif if (QLayout *layout = widget->layout()) { if (!(qobject_cast(widget))) { // explicitely check public layout classes, QMainWindowLayout doesn't work here if (qobject_cast(layout) #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) || qobject_cast(layout) #endif || qobject_cast(layout) || qobject_cast(layout)) { QPainter painter(widget); visualizeLayoutSpacing(layout, &painter); } } } } #endif #if 0 if (QDialog *dialog = qobject_cast(widget)) { QPainter painter(dialog); QRect r = dialog->rect(); QLinearGradient dialogGradient1(r.topLeft(), r.bottomRight()); dialogGradient1.setColorAt(0.0, QColor(255, 255, 255, 30)); dialogGradient1.setColorAt(1.0, QColor(0, 0, 0, 10)); // painter.fillRect(r, dialogGradient1); QRadialGradient dialogGradient2(r.left() + r.width() / 2, r.top(), r.height()); dialogGradient2.setColorAt(0.0, QColor(255, 255, 225, 160)); dialogGradient2.setColorAt(1.0, QColor(0, 0, 0, 0)); // painter.fillRect(r, dialogGradient2); QLinearGradient dialogGradient3(r.topLeft(), r.bottomLeft()); dialogGradient3.setColorAt(0.0, QColor(255, 255, 255, 30)); dialogGradient3.setColorAt(1.0, QColor(0, 0, 0, 20)); painter.fillRect(r, dialogGradient3); paintThinFrame(&painter, dialog->rect().adjusted(0, 0, 0, 0), dialog->palette(), 60, -20); paintThinFrame(&painter, dialog->rect().adjusted(1, 1, -1, -1), dialog->palette(), -20, 60); } #endif #if 0 if (QStatusBar *status = qobject_cast(widget)) { QPainter painter(status); paintThinFrame(&painter, status->rect(), status->palette(), -20, 60); } if (QToolBox *toolBox = qobject_cast(widget)) { QPainter painter(toolBox); paintThinFrame(&painter, toolBox->rect(), toolBox->palette(), 60, -20); paintThinFrame(&painter, toolBox->rect().adjusted(1, 1, -1, -1), toolBox->palette(), -60, 140); } if (QLCDNumber *lcd = qobject_cast(watched)) { // TODO nicer digits, antialiased, slight italics } if (QDockWidget *dock = qobject_cast(widget)) { // ### rendering a frame around dock widgets does not work, because // the subwidgets are placed at the edges. } #endif if (!qstrcmp(widget->metaObject()->className(), "InfoSidebarPage") || !qstrcmp(widget->metaObject()->className(), "InformationPanel")) { QPainter painter(widget); paintThinFrame(&painter, widget->rect().adjusted(0, 0, 0, 0), widget->palette(), 60, -20); paintThinFrame(&painter, widget->rect().adjusted(1, 1, -1, -1), widget->palette(), -20, 60); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (!qstrcmp(widget->metaObject()->className(), "KLineEditButton")) { QPainter painter(widget); QStyleOption option; option.initFrom(widget); QIcon::Mode iconMode = QIcon::Normal; if (option.state & QStyle::State_Enabled && option.state & QStyle::State_MouseOver) { //iconMode = QIcon::Active; // painter.fillRect(widget->rect(), Qt::red); } else { //iconMode = QIcon::Disabled; painter.setOpacity(0.2); } QRect r = QRect(widget->rect().center() - QPoint(6, 5), QSize(12, 12)); painter.drawPixmap(r, q->standardIcon(QStyle::SP_TitleBarCloseButton, &option, widget).pixmap(12, 12, iconMode)); event->accept(); return true; } if (widget->inherits("KFadeWidgetEffect")) { // widget->hide(); event->accept(); // widget->removeEventFilter(this); return true; } break; #endif case QEvent::MouseMove: if (QLineEdit *lineEdit = qobject_cast(watched)) { lineEditMouseMoved(lineEdit, static_cast(event)); } break; case QEvent::Show: if (QProgressBar *pbar = qobject_cast(watched)) { if (!widget->inherits("StatusBarSpaceInfo")) { setAnimated(pbar, true); } } /* fall through */ case QEvent::Move: case QEvent::Resize: if (QTextEdit *edit = qobject_cast(widget)) { #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) if (!qstrcmp(widget->metaObject()->className(), "SampleEdit")) { QList children = widget->children(); Q_FOREACH (QObject *child, children) { if (child->objectName() == QLatin1String("sample_background")) { QWidget *bg = qobject_cast(child); if (bg) { bg->setGeometry(2, 2, widget->width() - 4, widget->height() - 4); } } } } else #endif { textEditSourceChanged(edit); } } #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) else if (qobject_cast(widget)) { QList shadows = widget->findChildren(); Q_FOREACH (WidgetShadow *shadow, shadows) { shadow->updateGeometry(); } } #endif if (qobject_cast(widget) || widget->inherits("Q3ScrollView") #if 1 || widget->inherits("Konsole::TerminalDisplay") || widget->inherits("KTextEditor::View") || widget->inherits("KHTMLView") #endif ) { updateFrameShadow(widget); } break; case QEvent::Destroy: case QEvent::Hide: setAnimated(reinterpret_cast(watched), false); break; #if 0 case QEvent::MouseButtonRelease: if (allowScrollBarSliderToCoverArrows && qobject_cast(widget)) { widget->update(); } break; #endif default: break; } return QObject::eventFilter(watched, event); } /*-----------------------------------------------------------------------*/ #define SkulptureDrawFunction(function, selectortype, optiontype, array) \ \ void SkulptureStyle::function(selectortype element, const optiontype *option, QPainter *painter, const QWidget *widget) const \ { \ if (uint(element) < array_elements(array)) { \ const Private::DrawElementEntry *entry = &array[element]; \ if (entry->func && option && (!entry->type || option->type == entry->type)) { \ entry->func(painter, option, widget, this); \ return; \ } \ } \ ParentStyle::function(element, option, painter, widget); \ } SkulptureDrawFunction(drawPrimitive, PrimitiveElement, QStyleOption, d->draw_primitive_entry) SkulptureDrawFunction(drawControl, ControlElement, QStyleOption, d->draw_element_entry) //SkulptureDrawFunction(drawComplexControl, ComplexControl, QStyleOptionComplex, d->draw_complex_entry) /*-----------------------------------------------------------------------*/ #include "skulpture.moc" /* * skulpture_animations.cpp * */ #include "skulpture_p.h" #include #include /*-----------------------------------------------------------------------*/ void SkulptureStyle::Private::setAnimated(QWidget *widget, bool animated) { if (!widget) { return; } animations.removeAll(widget); if (animated && animateProgressBars) { animations.prepend(widget); if (!timer) { timer = startTimer(60); } } else { if (animations.isEmpty()) { if (timer) { killTimer(timer); timer = 0; } } } } bool SkulptureStyle::Private::isAnimated(QWidget *widget) { if (!widget || !timer) { return false; } return animations.contains(widget); } void SkulptureStyle::Private::timerEvent(QTimerEvent *event) { if (event->timerId() == timer) { Q_FOREACH (QWidget *widget, animations) { // FIXME: move this logic to progressbar QProgressBar *bar = qobject_cast(widget); if (bar) { if (bar->minimum() >= bar->maximum() || bar->value() < bar->maximum()) { bar->update(); } } else { widget->update(); } } } event->ignore(); } /* * skulpture_arrows.cpp * */ #include "skulpture_p.h" #include "sk_factory.h" #include /*-----------------------------------------------------------------------*/ #define awf 0.8 /* width of inner arrow 0 ... 1 */ #define ahf 0.2 /* position of inner arrow, -1 ... 1 */ #define spf 0.2 /* position of spin plus/minus edges */ #define swf 0.8 /* width of spin plus/minus sign */ #define shf 1.0 /* height of spin plus/minus sign */ static const ShapeFactory::Code arrowShapeDescription[] = { Pmove(-1, 1), Pline(-awf, 1), Pline(0, ahf), Pline(awf, 1), Pline(1, 1), Pline(0, -1), Pend }; static const ShapeFactory::Code spinPlusDescription[] = { Pmove(-swf, spf), Pline(-spf, spf), Pline(-spf, shf), Pline(spf, shf), Pline(spf, spf), Pline(swf, spf), Pline(swf, -spf), Pline(spf, -spf), Pline(spf, -shf), Pline(-spf, -shf), Pline(-spf, -spf), Pline(-swf, -spf), Pend }; static const ShapeFactory::Code spinMinusDescription[] = { Pmove(-swf, spf), Pline(swf, spf), Pline(swf, -spf), Pline(-swf, -spf), Pend }; static const ShapeFactory::Code sortIndicatorShapeDescription[] = { Pmove(-1, 1), Pline(1, 1), Pline(0, -1), Pend }; /*-----------------------------------------------------------------------*/ static inline QPainterPath arrowPath(const QStyleOption *option, Qt::ArrowType arrow, bool spin) { qreal var[ShapeFactory::MaxVar + 1]; var[1] = 0.01 * arrow; var[2] = spin ? 1.0 : 0.0; var[3] = option->fontMetrics.height(); var[4] = 0.0; QPainterPath shape = ShapeFactory::createShape( spin && arrow == Qt::LeftArrow ? spinMinusDescription : spin && arrow == Qt::RightArrow ? spinPlusDescription : arrowShapeDescription, var); if (var[4] != 0.0) { shape.setFillRule(Qt::WindingFill); } qreal h = 2.0 + var[3] * (spin ? 2.0 : 3.0) / 9.0; qreal w = 2.0 + var[3] / 3.0; h /= 2; w /= 2; if (arrow == Qt::DownArrow || arrow == Qt::RightArrow) { h = -h; } bool horiz = !spin && (arrow == Qt::LeftArrow || arrow == Qt::RightArrow); QMatrix arrowMatrix(horiz ? 0 : w, horiz ? w : 0, horiz ? h : 0 , horiz ? 0 : h, 0, 0); return arrowMatrix.map(shape); } void paintScrollArrow(QPainter *painter, const QStyleOption *option, Qt::ArrowType arrow, bool spin) { painter->save(); // FIXME: combine translations with path matrix painter->translate(option->rect.center()); #if 1 painter->setRenderHint(QPainter::Antialiasing, true); #else painter->setRenderHint(QPainter::Antialiasing, false); #endif if (painter->renderHints() & QPainter::Antialiasing) { painter->translate(0.5, 0.5); } #if 1 switch (arrow) { case Qt::UpArrow: painter->translate(0, -0.5); break; case Qt::DownArrow: painter->translate(0, 0.5); break; case Qt::LeftArrow: if (!spin) { painter->translate(-0.5, 0); } break; case Qt::RightArrow: if (!spin) { painter->translate(0.5, 0); } break; case Qt::NoArrow: break; } #endif painter->setPen(Qt::NoPen); QColor color = option->palette.color(spin ? (option->state & QStyle::State_Enabled ? QPalette::WindowText : QPalette::Text) : QPalette::ButtonText); if ((option->state & QStyle::State_MouseOver) && option->state & QStyle::State_Enabled /* && !(option->state & QStyle::State_Sunken)*/) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) color = option->palette.color(QPalette::Highlight).darker(200); #else color = option->palette.color(QPalette::Highlight).dark(200); #endif // painter->setPen(QPen(Qt::white, 1.0)); } else { // painter->setPen(QPen(Qt::white, 0.5)); } color.setAlpha((179 * color.alpha()) >> 8); painter->setBrush(color); painter->drawPath(arrowPath(option, arrow, spin)); painter->restore(); } void paintIndicatorArrowDown(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::DownArrow, false); } void paintIndicatorArrowLeft(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::LeftArrow, false); } void paintIndicatorArrowRight(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::RightArrow, false); } void paintIndicatorArrowUp(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::UpArrow, false); } /* * skulpture_buttons.cpp * */ #include "skulpture_p.h" #include #include static QPainterPath button_path(const QRectF &rect, qreal k) { k *= 0.1; const qreal tlh_edge = 6.0 * k; const qreal tlv_edge = 6.0 * k; const qreal tlh_control = 4.0 * k; const qreal tlv_control = 4.0 * k; const qreal blh_edge = 6.0 * k; const qreal blv_edge = 6.0 * k; const qreal blh_control = 4.0 * k; const qreal blv_control = 4.0 * k; const qreal trh_edge = 6.0 * k; const qreal trv_edge = 6.0 * k; const qreal trh_control = 4.0 * k; const qreal trv_control = 4.0 * k; const qreal brh_edge = 6.0 * k; const qreal brv_edge = 6.0 * k; const qreal brh_control = 4.0 * k; const qreal brv_control = 4.0 * k; QPainterPath path; path.moveTo(rect.left() + tlh_edge, rect.top()); path.lineTo(rect.right() - trh_edge, rect.top()); path.cubicTo(rect.right() - trh_edge + trh_control, rect.top(), rect.right(), rect.top() + trv_edge - trv_control, rect.right(), rect.top() + trv_edge); path.lineTo(rect.right(), rect.bottom() - brv_edge); path.cubicTo(rect.right(), rect.bottom() - brv_edge + brv_control, rect.right() - brh_edge + brh_control, rect.bottom(), rect.right() - brh_edge, rect.bottom()); path.lineTo(rect.left() + blh_edge, rect.bottom()); path.cubicTo(rect.left() + blh_edge - blh_control, rect.bottom(), rect.left(), rect.bottom() - blv_edge + blv_control, rect.left(), rect.bottom() - blv_edge); path.lineTo(rect.left(), rect.top() + tlv_edge); path.cubicTo(rect.left(), rect.top() + tlv_edge - tlv_control, rect.left() + tlh_edge - tlh_control, rect.top(), rect.left() + tlh_edge, rect.top()); return path; } static QBrush button_gradient(const QRectF &rect, const QColor &color, const QStyleOptionButton *option) { Q_UNUSED(option); qreal ch = color.hueF(); qreal cs = color.saturationF() * 1.0; qreal cv = color.valueF() * 1.0; int ca = color.alpha(); QColor col; if (rect.height() > 64) { return QColor(color); } QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); col.setHsvF(ch, cs, qMax(0.0, cv - 0.02)); col.setAlpha(ca); gradient.setColorAt(0.0, col); col.setHsvF(ch, cs, qMin(1.0, cv + 0.03)); col.setAlpha(ca); gradient.setColorAt(1.0, col); return gradient; } void paintButtonPanel(QPainter *painter, const QStyleOptionButton *option, QPalette::ColorRole bgrole) { const QRectF &c_rect = option->rect; const qreal t = 1.0; QRectF rect = c_rect; bool frame = true; if (option->features & QStyleOptionButton::Flat && !(option->state & QStyle::State_Sunken)) { frame = false; } painter->setPen(Qt::NoPen); if ((option->features & QStyleOptionButton::DefaultButton) && (option->state & QStyle::State_Enabled)) { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 1.3), blend_color(QColor(0, 0, 0, 10), option->palette.color(QPalette::Highlight).lighter(110), 0.2), blend_color(QColor(0, 0, 0, 15), option->palette.color(QPalette::Highlight).lighter(110), 0.2))); } else { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 1.3), shaded_color(option->palette.color(QPalette::Window), -10), shaded_color(option->palette.color(QPalette::Window), -15))); } painter->drawPath(button_path(rect, 1.5)); rect.adjust(t, t, -t, -t); QBrush bgbrush = option->palette.brush(option->state & QStyle::State_Enabled ? (bgrole == QPalette::NoRole ? QPalette::Button : bgrole) : QPalette::Button); if (bgbrush.style() == Qt::SolidPattern && bgbrush.color().alpha() == 0) { QColor color = option->palette.color(QPalette::Window); color.setAlpha(0); bgbrush = color; } if (frame) { if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Sunken || option->state & QStyle::State_On) { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 1.1), shaded_color(option->palette.color(QPalette::Window), -35), shaded_color(option->palette.color(QPalette::Window), -75))); } else { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 1.1), shaded_color(option->palette.color(QPalette::Window), -75), shaded_color(option->palette.color(QPalette::Window), -45))); } } else { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 1.1), shaded_color(option->palette.color(QPalette::Window), -35), shaded_color(option->palette.color(QPalette::Window), -35))); } painter->drawPath(button_path(rect, 1.3)); rect.adjust(t, t, -t, -t); if (bgbrush.style() == Qt::SolidPattern) { QColor bgcolor = bgbrush.color(); if (option->state & QStyle::State_On) { bgcolor = blend_color(bgcolor, option->palette.color(QPalette::Highlight), 0.2); bgbrush = button_gradient(rect, bgcolor, option); } if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Sunken) { bgcolor = bgcolor.lighter(102); } else if (option->state & QStyle::State_MouseOver) { bgcolor = bgcolor.lighter(104); } bgbrush = button_gradient(rect, bgcolor, option); } painter->setBrush(bgbrush); // painter->setBrush(option->palette.color(QPalette::Button)); painter->drawPath(button_path(rect, 1.1)); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Sunken || option->state & QStyle::State_On) { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 0.9), shaded_color(bgcolor, -10), shaded_color(bgcolor, -20))); } else { painter->setBrush(path_edge_gradient(rect, option, button_path(rect, 0.9), shaded_color(bgcolor, -20), shaded_color(bgcolor, 160))); } painter->drawPath(button_path(rect, 1.1)); } } painter->setBrush(bgbrush); } else { QColor bgcolor = option->palette.color(QPalette::Window); if (option->state & QStyle::State_MouseOver) { bgcolor = bgcolor.lighter(104); } if (option->state & QStyle::State_On) { bgcolor = blend_color(bgcolor, option->palette.color(QPalette::Highlight), 0.2); } painter->setBrush(bgcolor); } rect.adjust(t, t, -t, -t); painter->save(); // make transparent buttons appear transparent painter->setCompositionMode(QPainter::CompositionMode_DestinationOut); painter->setBrush(Qt::black); painter->drawPath(button_path(rect, 0.9)); painter->restore(); painter->drawPath(button_path(rect, 0.9)); } void paintPushButtonBevel(QPainter *painter, const QStyleOptionButton *option, const QWidget *widget, const QStyle *style) { QStyleOptionButton opt = *option; opt.features &= ~(QStyleOptionButton::HasMenu); ((QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_PushButtonBevel, &opt, painter, widget); if (option->features & QStyleOptionButton::Flat) { if (!(option->state & (QStyle::State_Sunken | QStyle::State_On))) { if (option->state & QStyle::State_MouseOver) { painter->fillRect(option->rect.adjusted(2, 2, -2, -2), QColor(255, 255, 255, 60)); } } } if (option->features & QStyleOptionButton::HasMenu) { int size = style->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, widget); opt.palette.setColor(QPalette::WindowText, opt.palette.color(widget ? widget->foregroundRole() : QPalette::ButtonText)); opt.state &= ~(QStyle::State_MouseOver); if (option->direction == Qt::LeftToRight) { opt.rect = QRect(option->rect.right() - size - 2, option->rect.top(), size, option->rect.height()); } else { opt.rect = QRect(option->rect.left() + 4, option->rect.top(), size, option->rect.height()); } if (option->state & (QStyle::State_Sunken | QStyle::State_On)) { opt.rect.translate(style->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &opt, widget), style->pixelMetric(QStyle::PM_ButtonShiftVertical, &opt, widget)); } style->drawPrimitive(QStyle::PE_IndicatorArrowDown, &opt, painter, widget); } } /* * skulpture_cache.cpp * */ #include "skulpture_p.h" #include #include #include #include #include "sk_factory.h" #include // FIXME #if (QT_VERSION < QT_VERSION_CHECK(4, 3, 0)) #define cacheKey serialNumber #endif /*-----------------------------------------------------------------------*/ static const bool UsePixmapCache = true; /*-----------------------------------------------------------------------*/ /* * paint a pushbutton to painter * */ extern void paintButtonPanel(QPainter *painter, const QStyleOptionButton *option, QPalette::ColorRole bgrole); static const int button_edge_size = 16; static const int button_inner_width = 32; void paintCommandButtonPanel(QPainter *painter, const QStyleOptionButton *option, const QWidget *widget) { Q_UNUSED(widget); QPalette::ColorRole bgrole = /*widget ? widget->backgroundRole() : */QPalette::Button; bool useCache = UsePixmapCache; QString pixmapName; QPixmap pixmap; QRect r = option->rect; r.setWidth(button_inner_width + 2 * button_edge_size); if (/*option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ r.height() > 64) { useCache = false; } if (useCache) { uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_Sunken | QStyle::State_HasFocus); uint features = uint(option->features) & (QStyleOptionButton::Flat | QStyleOptionButton::DefaultButton); if (!(state & QStyle::State_Enabled)) { state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus); } pixmapName.sprintf("scp-cbp-%x-%x-%x-%x-%llx-%x", features, uint(bgrole), state, option->direction, option->palette.cacheKey(), r.height()); } if (!useCache || !QPixmapCache::find(pixmapName, pixmap)) { pixmap = QPixmap(r.size()); pixmap.fill(Qt::transparent); // pixmap.fill(Qt::red); QPainter p(&pixmap); QStyleOptionButton but = *option; but.rect = QRect(QPoint(0, 0), r.size()); // ### neither Clear nor Source works? // p.setCompositionMode(QPainter::CompositionMode_Clear); // p.setCompositionMode(QPainter::CompositionMode_Source); // p.fillRect(but.rect, Qt::transparent); // p.setCompositionMode(QPainter::CompositionMode_SourceOver); p.setFont(painter->font()); p.setRenderHint(QPainter::Antialiasing, true); paintButtonPanel(&p, &but, bgrole); p.end(); if (useCache) { QPixmapCache::insert(pixmapName, pixmap); // qDebug() << "inserted into cache:" << pixmapName; } } int rem; if (option->rect.width() == r.width()) { rem = r.width(); } else { int side = qMin(option->rect.width() / 2, button_inner_width + button_edge_size); painter->drawPixmap(r.topLeft(), pixmap, QRect(0, 0, side, r.height())); int midw = option->rect.width() - 2 * side; rem = option->rect.width() - side; r.translate(side, 0); while (midw > 0) { int w = qMin(button_inner_width, midw); rem -= w; painter->drawPixmap(r.topLeft(), pixmap, QRect(button_edge_size, 0, w, r.height())); r.translate(w, 0); midw -= button_inner_width; } } painter->drawPixmap(r.topLeft(), pixmap, QRect(r.width() - rem, 0, rem, r.height())); } /*-----------------------------------------------------------------------*/ void paintPanelButtonTool(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style) { Q_UNUSED(style); QStyleOptionButton button; if (widget && !qstrcmp(widget->metaObject()->className(), "QDockWidgetTitleButton")) { if (!(option->state & QStyle::State_MouseOver) && !(option->state & QStyle::State_On)) return; } button.QStyleOption::operator=(*option); button.features = QStyleOptionButton::None; if (!(button.state & QStyle::State_Enabled) && (option->state & QStyle::State_AutoRaise)) { return; } // ### don't know if tool buttons should have that big frame... button.rect.adjust(-1, -1, 1, 1); // FIXME bgrole? paintCommandButtonPanel(painter, &button, 0); } /*-----------------------------------------------------------------------*/ static void paintIndicatorCached(QPainter *painter, const QStyleOption *option, void (*paintIndicator)(QPainter *painter, const QStyleOption *option), bool useCache, const QString &pixmapName) { QPixmap pixmap; if (!useCache || !QPixmapCache::find(pixmapName, pixmap)) { pixmap = QPixmap(option->rect.size()); #if 1 pixmap.fill(Qt::transparent); // pixmap.fill(Qt::red); #else pixmap.fill(option->palette.color(QPalette::Window)); #endif QPainter p(&pixmap); QStyleOption opt = *option; opt.rect = QRect(QPoint(0, 0), option->rect.size()); // p.setCompositionMode(QPainter::CompositionMode_Clear); // p.setCompositionMode(QPainter::CompositionMode_Source); // p.fillRect(opt.rect, Qt::transparent); // p.setCompositionMode(QPainter::CompositionMode_SourceOver); p.setFont(painter->font()); p.setRenderHint(QPainter::Antialiasing, true); paintIndicator(&p, &opt); p.end(); if (useCache) { QPixmapCache::insert(pixmapName, pixmap); // qDebug() << "inserted into cache:" << pixmapName; } } painter->drawPixmap(option->rect, pixmap); } static void paintIndicatorShape(QPainter *painter, const QStyleOption *option, qreal scale, const QPainterPath &shapePath) { // configuration const QPalette::ColorRole indicatorRole = QPalette::Text; if (option->state & QStyle::State_Sunken || option->state & QStyle::State_On || option->state & QStyle::State_MouseOver) { painter->save(); painter->setPen(Qt::NoPen); painter->translate(QRectF(option->rect).center()); painter->setRenderHint(QPainter::Antialiasing, true); QColor color; if ((option->state & QStyle::State_MouseOver || option->state & QStyle::State_Sunken) && option->state & QStyle::State_Enabled) { color = option->palette.color(QPalette::Highlight); if (!(option->state & QStyle::State_Sunken) && !(option->state & QStyle::State_On)) { color.setAlpha(80); } } else if (!(option->state & QStyle::State_Sunken) && option->state & QStyle::State_On) { color = option->palette.color(indicatorRole); color.setAlpha(80); } if (color.isValid()) { painter->setBrush(color); QMatrix matrix(scale, 0, 0, scale, 0, 0); painter->drawPath(matrix.map(shapePath)); } if (!(option->state & QStyle::State_Sunken) && option->state & QStyle::State_On) { painter->setBrush(option->palette.brush(indicatorRole)); QMatrix matrix(scale - 1, 0, 0, scale - 1, 0, 0); painter->drawPath(matrix.map(shapePath)); } painter->restore(); } } /*-----------------------------------------------------------------------*/ #define csx 0.35 #define csc 0.2 // cross static const ShapeFactory::Code checkShapeDescription1[] = { Pmove(-1 + csc, -1), Pline(0, -csx), Pline(1 - csc, -1), Pline(1, -1 + csc), Pline(csx, 0), Pline(1, 1 - csc), Pline(1 - csc, 1), Pline(0, csx), Pline(-1 + csc, 1), Pline(-1, 1 - csc), Pline(-csx, 0), Pline(-1, -1 + csc), Pend }; // checkmark static const ShapeFactory::Code checkShapeDescription2[] = { Pmove(1 - csc, -1), Pline(1, -1 + csc), Pline(csx, 1), Pline(-csx, 1), Pline(-1, csc), Pline(-1 + csc, 0), Pline(0, 1 - 2 * csx), Pend }; static void paintCheckBox(QPainter *painter, const QStyleOption *option) { if (option->state & QStyle::State_NoChange) { paintThinFrame(painter, option->rect, option->palette, 30, -10); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -50, -60); paintThinFrame(painter, option->rect.adjusted(2, 2, -2, -2), option->palette, 0, 60); QColor color = option->palette.color(QPalette::Window); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Sunken) { color = color.darker(110); } else if (option->state & QStyle::State_MouseOver) { color = color.lighter(106); } } else { color = color.darker(106); } painter->fillRect(option->rect.adjusted(3, 3, -3, -3), color); } else { QColor color = option->palette.color(QPalette::Base); if (!(option->state & QStyle::State_On) && !(option->state & QStyle::State_Enabled)) { color = option->palette.color(QPalette::Window); } else if (option->state & QStyle::State_MouseOver) { color = color.lighter(105); } painter->fillRect(option->rect.adjusted(2, 2, -2, -2), color); paintRecessedFrame(painter, option->rect, option->palette, RF_Small); if (!(option->state & QStyle::State_Sunken)) { if (option->state & QStyle::State_Enabled) { paintThinFrame(painter, option->rect.adjusted(2, 2, -2, -2), option->palette, 140, 200); } else { paintThinFrame(painter, option->rect.adjusted(2, 2, -2, -2), option->palette, 180, 180); } } const ShapeFactory::Description description = checkShapeDescription1; const qreal scale = (option->rect.width() - 4) * 0.35; paintIndicatorShape(painter, option, scale, ShapeFactory::createShape(description)); } } void paintIndicatorCheckBox(QPainter *painter, const QStyleOptionButton *option) { bool useCache = UsePixmapCache; QString pixmapName; if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ option->rect.width() * option->rect.height() > 4096) { useCache = false; } if (useCache) { uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_NoChange | QStyle::State_MouseOver | QStyle::State_Sunken | QStyle::State_HasFocus); if (!(state & QStyle::State_Enabled)) { state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus); } state &= ~(QStyle::State_HasFocus); pixmapName.sprintf("scp-icb-%x-%x-%llx-%x-%x", state, option->direction, option->palette.cacheKey(), option->rect.width(), option->rect.height()); } paintIndicatorCached(painter, option, paintCheckBox, useCache, pixmapName); } /*-----------------------------------------------------------------------*/ static void paintThinBevel(QPainter *painter, const QPainterPath &path, const QColor &dark, const QColor &light, qreal lightAngle = M_PI / 4) { QMatrix scaleUp; scaleUp.scale(10, 10); QList bevel = path.toSubpathPolygons(scaleUp); Q_FOREACH (QPolygonF polygon, bevel) { for (int i = 0; i < polygon.size() - 1; ++i) { QLineF line(polygon.at(i) / 10, polygon.at(i + 1) / 10); line.setLength(line.length() + 0.20); painter->setPen(QPen(blend_color(light, dark, sin(atan2(polygon.at(i + 1).y() - polygon.at(i).y(), polygon.at(i + 1).x() - polygon.at(i).x()) - lightAngle) / 2 + 0.5), 1.0, Qt::SolidLine, Qt::FlatCap)); painter->drawLine(line); } } } static void paintThinBevel(QPainter *painter, const QPainterPath &path, const QPalette &palette, int dark, int light, qreal lightAngle = M_PI / 4) { paintThinBevel(painter, path, shaded_color(palette.color(QPalette::Window), dark), shaded_color(palette.color(QPalette::Window), light), lightAngle); } static inline QPainterPath radioShape(const QRectF rect) { QPainterPath path; path.addEllipse(rect); return path; } static void paintRadioButton(QPainter *painter, const QStyleOption *option) { const qreal lightAngle = option->direction == Qt::LeftToRight ? M_PI / 4 : 3 * M_PI / 4; QColor color = option->palette.color(QPalette::Base); if (!(option->state & QStyle::State_On) && !(option->state & QStyle::State_Enabled)) { color = option->palette.color(QPalette::Window); } else if (option->state & QStyle::State_MouseOver) { color = color.lighter(105); } painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->setPen(Qt::NoPen); painter->setBrush(color); painter->drawPath(radioShape(QRectF(option->rect).adjusted(2, 2, -2, -2))); paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(0.5, 0.5, -0.5, -0.5)), option->palette, 39, -26, lightAngle); paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(1.5, 1.5, -1.5, -1.5)), option->palette, -26, -91, lightAngle); paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(2.5, 2.5, -2.5, -2.5)), QColor(0, 0, 0, 15), QColor(0, 0, 0, 30), lightAngle); paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(3.5, 3.5, -3.5, -3.5)), QColor(0, 0, 0, 8), QColor(0, 0, 0, 15), lightAngle); paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(4.5, 4.5, -4.5, -4.5)), QColor(0, 0, 0, 4), QColor(0, 0, 0, 8), lightAngle); if (!(option->state & QStyle::State_Sunken)) { if (option->state & QStyle::State_Enabled) { paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(2.5, 2.5, -2.5, -2.5)), option->palette, 140, 300, lightAngle); } else { paintThinBevel(painter, radioShape(QRectF(option->rect).adjusted(2.5, 2.5, -2.5, -2.5)), option->palette, 180, 180, lightAngle); } } painter->restore(); const qreal scale = (option->rect.width() - 4) * 0.35; QPainterPath circlePath; const qreal radius = 0.7; circlePath.addEllipse(QRectF(-radius, -radius, 2 * radius, 2 * radius)); paintIndicatorShape(painter, option, scale, circlePath); } void paintIndicatorRadioButton(QPainter *painter, const QStyleOptionButton *option) { bool useCache = UsePixmapCache; QString pixmapName; if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ option->rect.width() * option->rect.height() > 4096) { useCache = false; } if (useCache) { uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_Sunken | QStyle::State_HasFocus); if (!(state & QStyle::State_Enabled)) { state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus); } state &= ~(QStyle::State_HasFocus); pixmapName.sprintf("scp-irb-%x-%x-%llx-%x-%x", state, option->direction, option->palette.cacheKey(), option->rect.width(), option->rect.height()); } paintIndicatorCached(painter, option, paintRadioButton, useCache, pixmapName); } /*-----------------------------------------------------------------------*/ void paintIndicatorMenuCheckMark(QPainter *painter, const QStyleOptionMenuItem *option, const QWidget *widget, const QStyle *style) { QStyleOptionButton buttonOption; buttonOption.QStyleOption::operator=(*option); // buttonOption.rect.adjust(-2, -2, 2, 2); // qDebug("here!"); // printf("state 0x%08x\n", uint(buttonOption.state)); if (option->state & QStyle::State_Enabled) { if (buttonOption.state & QStyle::State_On) { buttonOption.state |= QStyle::State_Sunken; } } else { buttonOption.state &= ~QStyle::State_Sunken; } if (option->state & QStyle::State_Selected) { buttonOption.state |= QStyle::State_MouseOver; } else { buttonOption.state &= ~QStyle::State_MouseOver; } if (option->checked) { buttonOption.state |= QStyle::State_On; } else { buttonOption.state &= ~QStyle::State_On; } if (widget) { buttonOption.palette = widget->palette(); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Active) { buttonOption.palette.setCurrentColorGroup(QPalette::Active); } else { buttonOption.palette.setCurrentColorGroup(QPalette::Inactive); } } else { buttonOption.palette.setCurrentColorGroup(QPalette::Disabled); } } if (option->checkType == QStyleOptionMenuItem::Exclusive) { QSize size(style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, option, widget), style->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight, option, widget)); buttonOption.rect = QRect(option->rect.x() + ((option->rect.width() - size.width()) >> 1), option->rect.y() + ((option->rect.height() - size.height()) >> 1), size.width(), size.height()); paintIndicatorRadioButton(painter, &buttonOption); } else { QSize size(style->pixelMetric(QStyle::PM_IndicatorWidth, option, widget), style->pixelMetric(QStyle::PM_IndicatorHeight, option, widget)); buttonOption.rect = QRect(option->rect.x() + ((option->rect.width() - size.width()) >> 1), option->rect.y() + ((option->rect.height() - size.height()) >> 1), size.width(), size.height()); paintIndicatorCheckBox(painter, &buttonOption); } } void paintQ3CheckListIndicator(QPainter *painter, const QStyleOptionQ3ListView *option, const QWidget *widget, const QStyle *style) { if (!option->items.isEmpty()) { QStyleOptionButton buttonOption; buttonOption.QStyleOption::operator=(*option); QSize size(style->pixelMetric(QStyle::PM_IndicatorWidth, option, widget), style->pixelMetric(QStyle::PM_IndicatorHeight, option, widget)); buttonOption.rect = QRect(option->rect.center() - QPoint(size.width() / 2, size.height() / 2), size); // buttonOption.rect.adjust(0, -1, 0, -1); paintIndicatorCheckBox(painter, &buttonOption); } } void paintQ3CheckListExclusiveIndicator(QPainter *painter, const QStyleOptionQ3ListView *option, const QWidget *widget, const QStyle *style) { if (!option->items.isEmpty()) { QStyleOptionButton buttonOption; buttonOption.QStyleOption::operator=(*option); QSize size(style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, option, widget), style->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight, option, widget)); buttonOption.rect = QRect(option->rect.center() - QPoint(size.width() / 2, size.height() / 2), size); // buttonOption.rect.adjust(0, -1, 0, -1); paintIndicatorRadioButton(painter, &buttonOption); } } void paintIndicatorItemViewItemCheck(QPainter *painter, const QStyleOption *option) { QStyleOptionButton buttonOption; buttonOption.QStyleOption::operator=(*option); buttonOption.state &= ~QStyle::State_MouseOver; paintIndicatorCheckBox(painter, &buttonOption); } /*-----------------------------------------------------------------------*/ static void paintGrip(QPainter *painter, const QStyleOption *option) { // painter->fillRect(option->rect, Qt::red); int d = qMin(option->rect.width(), option->rect.height()); // good values are 3 (very small), 4 (small), 5 (good), 7 (large), 9 (huge) // int d = 5; QRectF rect(QRectF(option->rect).center() - QPointF(d / 2.0, d / 2.0), QSizeF(d, d)); const qreal angle = option->direction == Qt::LeftToRight ? 135.0 : 45.0; // const qreal angle = 90; QColor color; qreal opacity = 0.9; painter->save(); painter->setPen(Qt::NoPen); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Sunken) { color = option->palette.color(QPalette::Highlight).darker(110); } else { color = option->palette.color(QPalette::Button); } } else { color = option->palette.color(QPalette::Button); opacity = 0.5; } QConicalGradient gradient1(rect.center(), angle); gradient1.setColorAt(0.0, shaded_color(color, -110)); gradient1.setColorAt(0.25, shaded_color(color, -30)); gradient1.setColorAt(0.5, shaded_color(color, 180)); gradient1.setColorAt(0.75, shaded_color(color, -30)); gradient1.setColorAt(1.0, shaded_color(color, -110)); painter->setBrush(color); painter->drawEllipse(rect); painter->setBrush(gradient1); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) // ### merge opacity into color painter->setOpacity(opacity); #endif painter->drawEllipse(rect); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) painter->setOpacity(1.0); if (d > 2) { QConicalGradient gradient2(rect.center(), angle); gradient2.setColorAt(0.0, shaded_color(color, -40)); gradient2.setColorAt(0.25, shaded_color(color, 0)); gradient2.setColorAt(0.5, shaded_color(color, 210)); gradient2.setColorAt(0.75, shaded_color(color, 0)); gradient2.setColorAt(1.0, shaded_color(color, -40)); rect.adjust(1, 1, -1, -1); painter->setBrush(color); painter->drawEllipse(rect); painter->setBrush(gradient2); painter->setOpacity(opacity); painter->drawEllipse(rect); painter->setOpacity(1.0); if (d > 8) { QConicalGradient gradient3(rect.center(), angle); gradient3.setColorAt(0.0, shaded_color(color, -10)); gradient3.setColorAt(0.25, shaded_color(color, 0)); gradient3.setColorAt(0.5, shaded_color(color, 180)); gradient3.setColorAt(0.75, shaded_color(color, 0)); gradient3.setColorAt(1.0, shaded_color(color, -10)); rect.adjust(2, 2, -2, -2); painter->setBrush(color); painter->drawEllipse(rect); painter->setBrush(gradient3); painter->setOpacity(opacity); painter->drawEllipse(rect); painter->setOpacity(1.0); } } #endif painter->restore(); } void paintCachedGrip(QPainter *painter, const QStyleOption *option, QPalette::ColorRole /*bgrole*/) { bool useCache = UsePixmapCache; QString pixmapName; if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ option->rect.width() * option->rect.height() > 4096) { useCache = false; } if (useCache) { uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_Sunken | QStyle::State_HasFocus); if (!(state & QStyle::State_Enabled)) { state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus); } state &= ~(QStyle::State_HasFocus); QByteArray colorName = option->palette.color(QPalette::Button).name().toAscii(); pixmapName.sprintf("scp-isg-%x-%x-%s-%x-%x", state, option->direction, colorName.constData(), option->rect.width(), option->rect.height()); } paintIndicatorCached(painter, option, paintGrip, useCache, pixmapName); } /*-----------------------------------------------------------------------*/ void paintDialBase(QPainter *painter, const QStyleOption *option) { // painter->fillRect(option->rect, Qt::red); // painter->save(); // painter->setRenderHint(QPainter::Antialiasing, true); int d = qMin(option->rect.width(), option->rect.height()); /* if (d > 20 && option->notchTarget > 0) { d += -1; } */ QRectF r((option->rect.width() - d) / 2.0, (option->rect.height() - d) / 2.0, d, d); const qreal angle = option->direction == Qt::LeftToRight ? 135.0 : 45.0; // const qreal angle = 90; painter->setPen(Qt::NoPen); QColor border_color = option->palette.color(QPalette::Window); #if 0 { QRadialGradient depth_gradient(r.center(), d / 2); // depth_gradient.setColorAt(0.0, QColor(0, 0, 0, 255)); depth_gradient.setColorAt(0.5, QColor(0, 0, 0, 255)); depth_gradient.setColorAt(1.0, QColor(0, 0, 0, 0)); painter->setBrush(depth_gradient); painter->drawEllipse(r); } #endif #if 1 if (option->state & QStyle::State_HasFocus && option->state & QStyle::State_KeyboardFocusChange) { painter->setBrush(option->palette.color(QPalette::Highlight).darker(180)); r.adjust(1, 1, -1, -1); painter->drawEllipse(r); painter->setBrush(border_color); r.adjust(1, 1, -1, -1); painter->drawEllipse(r); r.adjust(1, 1, -1, -1); } else { painter->setBrush(border_color); r.adjust(1, 1, -1, -1); painter->drawEllipse(r); r.adjust(1, 1, -1, -1); QConicalGradient border_gradient(r.center(), angle); if (!(option->state & QStyle::State_Enabled)) { border_color = border_color.lighter(120); } border_gradient.setColorAt(0.0, border_color.darker(180)); border_gradient.setColorAt(0.3, border_color.darker(130)); border_gradient.setColorAt(0.5, border_color.darker(170)); border_gradient.setColorAt(0.7, border_color.darker(130)); border_gradient.setColorAt(1.0, border_color.darker(180)); painter->setBrush(border_gradient); // painter->setBrush(Qt::blue); painter->drawEllipse(r); r.adjust(1, 1, -1, -1); } d -= 6; QColor dial_color; if (option->state & QStyle::State_Enabled) { dial_color = option->palette.color(QPalette::Button).lighter(101); if (option->state & QStyle::State_MouseOver) { dial_color = dial_color.lighter(103); } } else { dial_color = option->palette.color(QPalette::Window); } qreal t = option->state & QStyle::State_Enabled ? 2.0 : 1.5; if (1) { // ###: work around Qt 4.3.0 bug? (this works for 4.3.1) QConicalGradient border_gradient(r.center(), angle); border_gradient.setColorAt(0.0, dial_color.lighter(120)); border_gradient.setColorAt(0.2, dial_color); border_gradient.setColorAt(0.5, dial_color.darker(130)); border_gradient.setColorAt(0.8, dial_color); border_gradient.setColorAt(1.0, dial_color.lighter(120)); painter->setPen(QPen(border_gradient, t)); } else { painter->setPen(QPen(Qt::red, t)); } #if 0 QLinearGradient dial_gradient(r.topLeft(), r.bottomLeft()); dial_gradient.setColorAt(0.0, dial_color.darker(105)); dial_gradient.setColorAt(0.5, dial_color.lighter(102)); dial_gradient.setColorAt(1.0, dial_color.lighter(105)); #elif 1 QLinearGradient dial_gradient(option->direction == Qt::LeftToRight ? r.topLeft() : r.topRight(), option->direction == Qt::LeftToRight ? r.bottomRight() : r.bottomLeft()); // QLinearGradient dial_gradient(r.topLeft(), r.bottomLeft()); if (true || option->state & QStyle::State_Enabled) { #if 1 dial_gradient.setColorAt(0.0, dial_color.darker(106)); dial_gradient.setColorAt(1.0, dial_color.lighter(104)); #else dial_gradient.setColorAt(0.0, dial_color.lighter(101)); dial_gradient.setColorAt(0.5, dial_color.darker(103)); dial_gradient.setColorAt(1.0, dial_color.lighter(104)); #endif } else { dial_gradient.setColorAt(0.0, dial_color); dial_gradient.setColorAt(1.0, dial_color); } #elif 0 QConicalGradient dial_gradient(r.center(), angle); dial_gradient.setColorAt(0.0, dial_color.lighter(102)); dial_gradient.setColorAt(0.5, dial_color.darker(103)); dial_gradient.setColorAt(1.0, dial_color.lighter(102)); #else QBrush dial_gradient(dial_color); #endif painter->setBrush(dial_gradient); t = t / 2; painter->drawEllipse(r.adjusted(t, t, -t, -t)); // painter->setPen(Qt::NoPen); // painter->setBrush(dial_color); // painter->drawEllipse(r.adjusted(d / 4, d / 4, - d / 4, - d / 4)); #if 0 QLinearGradient border2_gradient(r.topLeft(), r.bottomRight()); border2_gradient.setColorAt(1.0, dial_color.darker(425)); border2_gradient.setColorAt(0.9, dial_color); border2_gradient.setColorAt(0.0, dial_color.darker(400)); painter->setPen(QPen(border2_gradient, 1.3)); painter->setBrush(Qt::NoBrush); painter->drawEllipse(r.adjusted(0.3, 0.3, -0.3, -0.3)); #endif // painter->restore(); #endif } void paintCachedDialBase(QPainter *painter, const QStyleOptionSlider *option) { bool useCache = UsePixmapCache; QString pixmapName; QRect r = option->rect; int d = qMin(r.width(), r.height()); if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ d > 128) { useCache = false; } if (useCache) { uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_KeyboardFocusChange | QStyle::State_HasFocus); if (!(state & QStyle::State_Enabled)) { state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange); } // state &= ~(QStyle::State_HasFocus); pixmapName.sprintf("scp-qdb-%x-%x-%llx-%x", state, option->direction, option->palette.cacheKey(), d); } paintIndicatorCached(painter, option, paintDialBase, useCache, pixmapName); } void paintIndicatorDial(QPainter *painter, const QStyleOptionSlider *option) { int d = qMin(option->rect.width(), option->rect.height()); QRect rect(option->rect.center() - QPoint((d - 1) / 2, (d - 1) / 2), QSize(d, d)); QStyleOptionSlider opt; opt.QStyleOption::operator=(*option); opt.rect = rect; paintCachedDialBase(painter, &opt); } /*-----------------------------------------------------------------------*/ void paintBranchChildren(QPainter *painter, const QStyleOption *option) { painter->setBrush(option->palette.color(QPalette::Text)); painter->setPen(Qt::NoPen); const qreal r = qMin(option->rect.width() * 0.5, option->fontMetrics.height() * 0.15); const QPointF center = QRectF(option->rect).center(); painter->drawEllipse(QRectF(center.x() - r, center.y() - r, 2 * r, 2 * r)); } void paintCachedIndicatorBranchChildren(QPainter *painter, const QStyleOption *option) { bool useCache = UsePixmapCache; QString pixmapName; QRect r = option->rect; int d = qMin(r.width(), r.height()); if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ d > 64) { useCache = false; } if (useCache) { uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_Open); // if (!(state & QStyle::State_Enabled)) { // state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange); // } // state &= ~(QStyle::State_HasFocus); pixmapName.sprintf("scp-qibc-%x-%x-%llx-%x", state, option->direction, option->palette.cacheKey(), d); } paintIndicatorCached(painter, option, paintBranchChildren, useCache, pixmapName); } /* * skulpture_color.cpp * */ #include "skulpture_p.h" #include /*-----------------------------------------------------------------------*/ QColor shaded_color(const QColor &color, int shade) { #if 1 const qreal contrast = 1.0; int r, g, b; color.getRgb(&r, &g, &b); int gray = qGray(r, g, b); gray = qMax(r, qMax(g, b)); gray = (r + b + g + 3 * gray) / 6; if (color.alpha() == 0) { gray = 200; } if (shade < 0) { qreal k = 220.0 / 255.0 * shade; k *= contrast; int a = 255; if (gray > 0) { a = int(k * 255 / (0 - gray)); if (a < 0) a = 0; if (a > 255) a = 255; } return QColor(0, 0, 0, a); } else { qreal k = (255 - 220.0) / (255.0) * shade; k *= contrast; int a = 255; if (gray < 255) { a = int(k * 255 / (255 - gray)); if (a < 0) a = 0; if (a > 255) a = 255; } return QColor(255, 255, 255, a); } #else if (shade < 0) { return QColor(0, 0, 0, -shade); } else { return QColor(255, 255, 255, shade); } #endif } QColor blend_color(const QColor &c0, const QColor &c1, qreal blend) { #if 0 // more exact, but probably slower QColor c; blend = qMin(1.0, qMax(0.0, blend)); c.setRgbF( c0.redF() * (1.0 - blend) + c1.redF() * blend, c0.greenF() * (1.0 - blend) + c1.greenF() * blend, c0.blueF() * (1.0 - blend) + c1.blueF() * blend, c0.alphaF() * (1.0 - blend) + c1.alphaF() * blend ); return c; #else int b = int(0.5 + 256.0 * blend); b = qMin(256, qMax(0, b)); QRgb rgba0 = c0.rgba(); QRgb rgba1 = c1.rgba(); return QColor( qRed(rgba0) + (((qRed(rgba1) - qRed(rgba0)) * b) >> 8), qGreen(rgba0) + (((qGreen(rgba1) - qGreen(rgba0)) * b) >> 8), qBlue(rgba0) + (((qBlue(rgba1) - qBlue(rgba0)) * b) >> 8), qAlpha(rgba0) + (((qAlpha(rgba1) - qAlpha(rgba0)) * b) >> 8) ); #endif } /*-----------------------------------------------------------------------*/ enum ColorScheme { NormalColorScheme, // allow 3D effects DarkColorScheme, // too dark, no 3D effects BrightColorScheme // too bright, no 3D effects }; ColorScheme guessColorScheme(const QPalette &palette, QPalette::ColorGroup colorGroup = QPalette::Active, QPalette::ColorRole colorRole = QPalette::Window) { const QColor windowColor = palette.color(colorGroup, colorRole); int r, g, b; windowColor.getRgb(&r, &g, &b); int brightness = qGray(r, g, b); if (brightness > 230) { return BrightColorScheme; } else if (brightness < 40) { return DarkColorScheme; } return NormalColorScheme; } static void computeAlternateBase(QPalette &palette, QPalette::ColorGroup colorGroup) { switch (guessColorScheme(palette, colorGroup, QPalette::Base)) { case DarkColorScheme: palette.setColor(colorGroup, QPalette::AlternateBase, palette.color(colorGroup, QPalette::Base).lighter(103)); break; case BrightColorScheme: case NormalColorScheme: palette.setColor(colorGroup, QPalette::AlternateBase, palette.color(colorGroup, QPalette::Base).darker(103)); break; } } static void copyColorGroup(QPalette &palette, QPalette::ColorGroup fromColorGroup, QPalette::ColorGroup toColorGroup) { for (int role = int(QPalette::WindowText); role <= int(QPalette::LinkVisited); ++role) { QPalette::ColorRole colorRole = QPalette::ColorRole(role); palette.setColor(toColorGroup, colorRole, palette.color(fromColorGroup, colorRole)); } } static void computeColorGroups(QPalette &palette, bool kdeMode = false, bool makeDisabledWidgetsTransparent = true) { // ### Is this used by pre-Qt 4.5 for HLine / VLine ? palette.setColor(QPalette::Disabled, QPalette::Dark, shaded_color(palette.color(QPalette::Active, QPalette::Window), -20)); palette.setColor(QPalette::Disabled, QPalette::Light, shaded_color(palette.color(QPalette::Active, QPalette::Window), 60)); if (!kdeMode) { // compute remaining colors in Active group computeAlternateBase(palette, QPalette::Active); // copy Active group to Inactive group copyColorGroup(palette, QPalette::Active, QPalette::Inactive); // compute remaining colors in Inactive group computeAlternateBase(palette, QPalette::Inactive); } if (!kdeMode || makeDisabledWidgetsTransparent) { // create Disabled group QColor disabledBackgroundColor = palette.color(QPalette::Active, QPalette::Window); QColor disabledForegroundColor; switch (guessColorScheme(palette, QPalette::Active, QPalette::Window)) { case DarkColorScheme: disabledForegroundColor = palette.color(QPalette::Active, QPalette::Window).lighter(125); break; case BrightColorScheme: case NormalColorScheme: disabledForegroundColor = palette.color(QPalette::Active, QPalette::Window).darker(125); break; } palette.setColor(QPalette::Disabled, QPalette::Window, disabledBackgroundColor); palette.setColor(QPalette::Disabled, QPalette::WindowText, disabledForegroundColor); palette.setColor(QPalette::Disabled, QPalette::Base, disabledBackgroundColor); palette.setColor(QPalette::Disabled, QPalette::Text, disabledForegroundColor); palette.setColor(QPalette::Disabled, QPalette::Link, disabledForegroundColor); palette.setColor(QPalette::Disabled, QPalette::LinkVisited, disabledForegroundColor); palette.setColor(QPalette::Disabled, QPalette::Button, disabledBackgroundColor); palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledForegroundColor); palette.setColor(QPalette::Disabled, QPalette::Highlight, disabledForegroundColor); palette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledBackgroundColor); computeAlternateBase(palette, QPalette::Disabled); } } QPalette SkulptureStyle::standardPalette() const { QPalette palette(QColor(205, 205, 205)); palette.setColor(QPalette::Active, QPalette::Base, QColor(229, 229, 229)); palette.setColor(QPalette::Active, QPalette::Text, QColor(0, 0, 0)); palette.setColor(QPalette::Active, QPalette::Link, QColor(80, 40, 120)); palette.setColor(QPalette::Active, QPalette::LinkVisited, QColor(80, 50, 80)); palette.setColor(QPalette::Active, QPalette::Highlight, QColor(114, 174, 211)); palette.setColor(QPalette::Active, QPalette::HighlightedText, QColor(0, 0, 0)); palette.setColor(QPalette::Active, QPalette::Window, QColor(200, 200, 200)); palette.setColor(QPalette::Active, QPalette::WindowText, QColor(0, 0, 0)); // palette.setColor(QPalette::Active, QPalette::Button, QColor(205, 205, 205)); palette.setColor(QPalette::Active, QPalette::ButtonText, QColor(0, 0, 0)); palette.setColor(QPalette::Active, QPalette::Shadow, QColor(0, 0, 0)); palette.setColor(QPalette::Active, QPalette::BrightText, QColor(240, 240, 240)); #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) palette.setColor(QPalette::Inactive, QPalette::ToolTipBase, QColor(240, 230, 190)); palette.setColor(QPalette::Inactive, QPalette::ToolTipText, QColor(0, 0, 0)); #endif computeColorGroups(palette); return palette; } void SkulptureStyle::polish(QPalette &palette) { ParentStyle::polish(palette); computeColorGroups(palette, qApp->inherits("KApplication"), d->makeDisabledWidgetsTransparent); } /* * skulpture_combobox.cpp * */ #include "skulpture_p.h" #include #include /*-----------------------------------------------------------------------*/ extern void paintComplexControlArea(QPainter *painter, const QStyleOption *option); void paintComboBox(QPainter *painter, const QStyleOptionComboBox *option, const QWidget *widget, const QStyle *style) { QStyleOptionComboBox opt = *option; const bool buttonMode = false; //!option->editable; QRect rect = style->subControlRect(QStyle::CC_ComboBox, option, QStyle::SC_ComboBoxArrow, widget); if (option->subControls & (QStyle::SC_ComboBoxFrame | QStyle::SC_ComboBoxEditField)) { if (buttonMode) { QStyleOptionButton buttonOption; buttonOption.QStyleOption::operator=(opt); if (buttonOption.state & QStyle::State_On) { buttonOption.state |= QStyle::State_Sunken; } else { buttonOption.state &= ~QStyle::State_Sunken; } buttonOption.state &= ~QStyle::State_On; // separator position opt.rect = rect; if (option->direction == Qt::LeftToRight) { opt.rect.setWidth(1); } else { opt.rect.setLeft(rect.left() + rect.width() - 1); } if (option->frame) { style->drawPrimitive(QStyle::PE_PanelButtonCommand, &buttonOption, painter, widget); QColor color = option->palette.color(QPalette::Button); if (!(opt.state & QStyle::State_On)) { opt.rect.translate(option->direction == Qt::LeftToRight ? -1 : 1, 0); } painter->fillRect(opt.rect, shaded_color(color, option->state & QStyle::State_Enabled ? -30 : -15)); if (option->state & QStyle::State_Enabled) { opt.rect.translate(option->direction == Qt::LeftToRight ? 1 : -1, 0); painter->fillRect(opt.rect, shaded_color(color, 80)); } } else { QColor bg = option->palette.color(QPalette::Button); painter->fillRect(option->rect, bg); painter->fillRect(opt.rect, shaded_color(bg, -15)); } } else { int fw = option->frame ? style->pixelMetric(QStyle::PM_ComboBoxFrameWidth, option, widget) : 0; QColor color = option->palette.color(QPalette::Base); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_HasFocus && option->editable) { color = blend_color(color, option->palette.color(QPalette::Highlight), 0.15); } else if (option->state & QStyle::State_MouseOver /*&& !option->editable*/) { color = color.lighter(103); } } QRect edit = style->subControlRect(QStyle::CC_ComboBox, option, QStyle::SC_ComboBoxFrame, widget).adjusted(fw, fw, -fw, -fw); painter->fillRect(edit, color); if (false && option->state & QStyle::State_Enabled && option->rect.height() <= 64) { QLinearGradient panelGradient(option->rect.topLeft(), option->rect.bottomLeft()); if (color.valueF() > 0.9) { panelGradient.setColorAt(0.0, shaded_color(color, -20)); } panelGradient.setColorAt(0.6, shaded_color(color, 0)); panelGradient.setColorAt(1.0, shaded_color(color, 10)); painter->fillRect(edit, panelGradient); } opt.rect = rect; if (!(option->activeSubControls & QStyle::SC_ComboBoxArrow)) { opt.state &= ~QStyle::State_MouseOver; } paintComplexControlArea(painter, &opt); if (option->subControls & QStyle::SC_ComboBoxFrame && option->frame) { QStyleOptionFrame frameOpt; frameOpt.QStyleOption::operator=(*option); frameOpt.rect = style->subControlRect(QStyle::CC_ComboBox, option, QStyle::SC_ComboBoxFrame, widget); frameOpt.state |= QStyle::State_Sunken; frameOpt.lineWidth = fw; frameOpt.midLineWidth = 0; style->drawPrimitive(QStyle::PE_FrameLineEdit, &frameOpt, painter, widget); } } } // arrow if (option->subControls & (QStyle::SC_ComboBoxArrow)) { opt.rect = rect; opt.state &= /*QStyle::State_MouseOver |*/ QStyle::State_Enabled; if (buttonMode) { opt.state &= ~QStyle::State_MouseOver; if (option->state & QStyle::State_On) { int sx = style->pixelMetric(QStyle::PM_ButtonShiftHorizontal, option, widget); int sy = style->pixelMetric(QStyle::PM_ButtonShiftVertical, option, widget); opt.rect.adjust(sx, sy, sx, sy); } } else { opt.palette.setColor(QPalette::ButtonText, opt.palette.color(option->state & QStyle::State_Enabled ? QPalette::WindowText : QPalette::Text)); } style->drawPrimitive(QStyle::PE_IndicatorArrowDown, &opt, painter, widget); } // focus frame if ((option->state & QStyle::State_HasFocus) && !option->editable) { QStyleOptionFocusRect focus; focus.QStyleOption::operator=(*option); focus.rect = style->subElementRect(QStyle::SE_ComboBoxFocusRect, option, widget); focus.state |= QStyle::State_FocusAtBorder; focus.backgroundColor = option->palette.color(buttonMode ? QPalette::Button : QPalette::Base); style->drawPrimitive(QStyle::PE_FrameFocusRect, &focus, painter, widget); } } void paintComboBoxLabel(QPainter *painter, const QStyleOptionComboBox *option, const QWidget *widget, const QStyle *style) { QStyleOptionComboBox opt = *option; const bool buttonMode = false; //!option->editable; if (!buttonMode) { opt.palette.setColor(QPalette::Base, QColor(0, 0, 0, 0)); } else { painter->save(); painter->setPen(opt.palette.color(QPalette::ButtonText)); if (opt.state & QStyle::State_On) { int sx = style->pixelMetric(QStyle::PM_ButtonShiftHorizontal, option, widget); int sy = style->pixelMetric(QStyle::PM_ButtonShiftVertical, option, widget); opt.rect.adjust(sx, sy, sx, sy); } } ((const QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_ComboBoxLabel, &opt, painter, widget); if (buttonMode) { painter->restore(); } } /*-----------------------------------------------------------------------*/ QRect subControlRectComboBox(const QStyleOptionComboBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { int fw = option->frame ? style->pixelMetric(QStyle::PM_ComboBoxFrameWidth, option, widget) : 0; int bw = style->pixelMetric(QStyle::PM_ScrollBarExtent, option, widget); if (option->editable) bw = qMax(bw, qApp->globalStrut().width()); QRect rect; switch (subControl) { case QStyle::SC_ComboBoxArrow: rect = QRect(option->rect.right() - bw - fw + 1, option->rect.top() + fw, bw, option->rect.height() - 2 * fw); break; case QStyle::SC_ComboBoxEditField: { if (option->editable) { rect = option->rect.adjusted(fw, fw, -fw - bw, -fw); } else { rect = option->rect.adjusted(fw + 4, fw, -fw - bw - 4, -fw); } break; } case QStyle::SC_ComboBoxFrame: default: // avoid warning rect = option->rect; break; } return style->visualRect(option->direction, option->rect, rect); } QRect subElementRectComboBoxFocusRect(const QStyleOptionComboBox *option, const QWidget *widget, const QStyle *style) { int fw = option->frame ? (option->editable ? style->pixelMetric(QStyle::PM_ComboBoxFrameWidth, option, widget) : 4) : 2; int bw = true || option->editable ? qMax(style->pixelMetric(QStyle::PM_ScrollBarExtent, option, widget), qApp->globalStrut().width()) : 0; return style->visualRect(option->direction, option->rect, option->rect.adjusted(fw, fw, -fw - bw, -fw)); } /* * skulpture_complex.cpp * */ #include "skulpture_p.h" /*-----------------------------------------------------------------------*/ extern QRect subControlRectSpinBox(const QStyleOptionSpinBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style); extern QRect subControlRectScrollBar(const QStyleOptionSlider *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style, ArrowPlacementMode horizontalArrowMode, ArrowPlacementMode verticalArrowMode); extern QRect subControlRectSlider(const QStyleOptionSlider *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style); extern QRect subControlRectToolButton(const QStyleOptionToolButton *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style); extern QRect subControlRectComboBox(const QStyleOptionComboBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style); extern QRect subControlRectGroupBox(const QStyleOptionGroupBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style); extern QRect subControlRectTitleBar(const QStyleOptionTitleBar *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style); /*-----------------------------------------------------------------------*/ #define SC_CASE(cc, so) \ case CC_## cc: \ if (option->type == QStyleOption::SO_## so) { \ return subControlRect ## cc((const QStyleOption ## so *) option, subControl, widget, this); \ } \ break QRect SkulptureStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const { switch (control) { SC_CASE(SpinBox, SpinBox); SC_CASE(ComboBox, ComboBox); case CC_ScrollBar: if (option && option && option->type == QStyleOption::SO_Slider) { return subControlRectScrollBar((const QStyleOptionSlider *) option, subControl, widget, this, d->horizontalArrowMode, d->verticalArrowMode); } break; SC_CASE(Slider, Slider); SC_CASE(TitleBar, TitleBar); case CC_Q3ListView: break; SC_CASE(ToolButton, ToolButton); case CC_Dial: break; //#if (QT_VERSION >= QT_VERSION_CHECK(4, 1, 0)) SC_CASE(GroupBox, GroupBox); //#endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) case CC_MdiControls: break; #endif case CC_CustomBase: // avoid warning break; } return ParentStyle::subControlRect(control, option, subControl, widget); } /*-----------------------------------------------------------------------*/ extern QStyle::SubControl hitTestComplexControlScrollBar(const QStyleOptionSlider *option, const QPoint &position, const QWidget *widget, const QStyle *style, ArrowPlacementMode horizontalArrowMode, ArrowPlacementMode verticalArrowMode); /*-----------------------------------------------------------------------*/ #define HIT_CASE(cc, so) \ case CC_## cc: \ if (option->type == QStyleOption::SO_## so) { \ return hitTestComplexControl ## cc((const QStyleOption ## so *) option, position, widget, this); \ } \ break QStyle::SubControl SkulptureStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget) const { switch (control) { case CC_ScrollBar: if (option->type == QStyleOption::SO_Slider) { return hitTestComplexControlScrollBar((const QStyleOptionSlider *) option, position, widget, this, d->horizontalArrowMode, d->verticalArrowMode); } break; default: break; } return ParentStyle::hitTestComplexControl(control, option, position, widget); } /*-----------------------------------------------------------------------*/ extern void paintSpinBox(QPainter *painter, const QStyleOptionSpinBox *option, const QWidget *widget, const QStyle *style); extern void paintComboBox(QPainter *painter, const QStyleOptionComboBox *option, const QWidget *widget, const QStyle *style); extern void paintScrollBar(QPainter *painter, const QStyleOptionSlider *option, const QWidget *widget, const QStyle *style, ArrowPlacementMode horizontalArrowMode, ArrowPlacementMode verticalArrowMode); extern void paintSlider(QPainter *painter, const QStyleOptionSlider *option, const QWidget *widget, const QStyle *style); extern void paintToolButton(QPainter *painter, const QStyleOptionToolButton *option, const QWidget *widget, const QStyle *style); extern void paintTitleBar(QPainter *painter, const QStyleOptionTitleBar *option, const QWidget *widget, const QStyle *style); extern void paintQ3ListView(QPainter *painter, const QStyleOptionQ3ListView *option, const QWidget *widget, const QStyle *style); extern void paintDial(QPainter *painter, const QStyleOptionSlider *option, const QWidget *widget, const QStyle *style); //extern void paintGroupBox(QPainter *painter, const QStyleOptionGroupBox *option, const QWidget *widget, const QStyle *style); //extern void paintMdiControls(QPainter *painter, const QStyleOptionComplex *option, const QWidget *widget, const QStyle *style); /*-----------------------------------------------------------------------*/ #define CC_CASE(cc, so) \ case CC_## cc: \ if (option->type == QStyleOption::SO_## so) { \ paint ## cc(painter, (const QStyleOption ## so *) option, widget, this); \ return; \ } \ break void SkulptureStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { CC_CASE(SpinBox, SpinBox); CC_CASE(ComboBox, ComboBox); case CC_ScrollBar: if (option->type == QStyleOption::SO_Slider) { paintScrollBar(painter, (const QStyleOptionSlider *) option, widget, this, d->horizontalArrowMode, d->verticalArrowMode); return; } break; CC_CASE(Slider, Slider); CC_CASE(ToolButton, ToolButton); CC_CASE(TitleBar, TitleBar); CC_CASE(Q3ListView, Q3ListView); CC_CASE(Dial, Slider); //#if (QT_VERSION >= QT_VERSION_CHECK(4, 1, 0)) case CC_GroupBox: break; //#endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) case CC_MdiControls: break; #endif case CC_CustomBase: // avoid warning break; } ParentStyle::drawComplexControl(control, option, painter, widget); } /* * skulpture_dial.cpp * */ #include "skulpture_p.h" #include #include #include /*-----------------------------------------------------------------------*/ extern void paintIndicatorDial(QPainter *painter, const QStyleOptionSlider *option); extern void paintCachedGrip(QPainter *painter, const QStyleOption *option, QPalette::ColorRole bgrole); void paintDial(QPainter *painter, const QStyleOptionSlider *option, const QWidget *widget, const QStyle *style) { int d = qMin(option->rect.width() & ~1, option->rect.height() & ~1); QStyleOptionSlider opt = *option; const QAbstractSlider *slider; // always highlight knob if pressed (even if mouse is not over knob) if ((option->state & QStyle::State_HasFocus) && (slider = qobject_cast(widget))) { if (slider->isSliderDown()) { opt.state |= QStyle::State_MouseOver; } } // tickmarks opt.palette.setColor(QPalette::Inactive, QPalette::WindowText, QColor(120, 120, 120, 255)); opt.palette.setColor(QPalette::Active, QPalette::WindowText, QColor(120, 120, 120, 255)); opt.state &= ~QStyle::State_HasFocus; opt.rect.setWidth(opt.rect.width() & ~1); opt.rect.setHeight(opt.rect.height() & ~1); ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_Dial, &opt, painter, widget); #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) opt.rect.setWidth((opt.rect.width() & ~1) - 1); opt.rect.setHeight((opt.rect.height() & ~1) - 1); opt.rect.translate(1, 1); #else if (runtimeQtVersion() >= QT_VERSION_CHECK(4, 6, 0)) { opt.rect.setWidth((opt.rect.width() & ~1) - 1); opt.rect.setHeight((opt.rect.height() & ~1) - 1); opt.rect.translate(1, 1); } #endif // focus rectangle if (option->state & QStyle::State_HasFocus) { QStyleOptionFocusRect focus; opt.state |= QStyle::State_HasFocus; focus.QStyleOption::operator=(opt); focus.rect.adjust(-1, -1, 1, 1); style->drawPrimitive(QStyle::PE_FrameFocusRect, &focus, painter, widget); } opt.palette = option->palette; // dial base if (d <= 256) { paintIndicatorDial(painter, &opt); } else { // large dials are slow to render, do not render them } // dial knob d -= 6; int gripSize = (option->fontMetrics.height() / 4) * 2 - 1; opt.rect.setSize(QSize(gripSize, gripSize)); opt.rect.moveCenter(option->rect.center()); // angle calculation from qcommonstyle.cpp (c) Trolltech 1992-2007, ASA. qreal angle; int sliderPosition = option->upsideDown ? option->sliderPosition : (option->maximum - option->sliderPosition); int range = option->maximum - option->minimum; if (!range) { angle = M_PI / 2; } else if (option->dialWrapping) { angle = M_PI * 1.5 - (sliderPosition - option->minimum) * 2 * M_PI / range; } else { angle = (M_PI * 8 - (sliderPosition - option->minimum) * 10 * M_PI / range) / 6; } qreal rr = d / 2.0 - gripSize - 2; opt.rect.translate(int(0.5 + rr * cos(angle)), int(0.5 - rr * sin(angle))); paintCachedGrip(painter, &opt, option->state & QStyle::State_Enabled ? QPalette::Button : QPalette::Window); } /* * skulpture_dock.cpp * */ #include "skulpture_p.h" #include #include /*-----------------------------------------------------------------------*/ void paintFrameDockWidget(QPainter *painter, const QStyleOptionFrame *option) { paintThinFrame(painter, option->rect, option->palette, -60, 160); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -20, 60); } void paintDockWidgetTitle(QPainter *painter, const QStyleOptionDockWidget *option, const QWidget *widget, const QStyle *style) { const QDockWidget *dock = qobject_cast(widget); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) const bool vertical = dock && (dock->features() & QDockWidget::DockWidgetVerticalTitleBar); #else const bool vertical = false; #endif const bool floating = dock && dock->isFloating(); QRect r = option->rect; if (floating) { if (vertical) { r.adjust(-3, 3, 0, -3); } else { r.adjust(3, -3, -3, 0); } // painter->fillRect(r.adjusted(1, 1, -1, -1), QColor(30, 40, 80)); } QColor color = option->palette.color(QPalette::Window); paintThinFrame(painter, r, option->palette, 40, -20); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -20, 80); QLinearGradient gradient(r.topLeft(), vertical ? r.topRight() : r.bottomLeft()); gradient.setColorAt(0.0, shaded_color(color, 50)); gradient.setColorAt(0.2, shaded_color(color, 30)); gradient.setColorAt(0.5, shaded_color(color, 0)); gradient.setColorAt(0.51, shaded_color(color, -10)); gradient.setColorAt(1.0, shaded_color(color, -20)); painter->fillRect(r.adjusted(1, 1, -1, -1), gradient); #if 0 QRadialGradient dialogGradient2(r.left() + r.width() / 2, r.top(), r.height()); dialogGradient2.setColorAt(0.0, QColor(255, 255, 255, 50)); dialogGradient2.setColorAt(1.0, QColor(0, 0, 0, 0)); painter->save(); painter->translate(r.center()); painter->scale(r.width() / 2.0 / r.height(), 1); painter->translate(-r.center()); painter->fillRect(r.adjusted(1, 1, -1, -1), dialogGradient2); painter->restore(); #endif QFont font = painter->font(); font.setBold(true); font.setPointSizeF(font.pointSizeF() / 1.19); painter->save(); painter->setFont(font); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) r = style->subElementRect(QStyle::SE_DockWidgetTitleBarText, option, widget); #else // FIXME r = option->rect; #endif // ### fix for Plastique centering if (vertical && option->rect.height() & 1) { if (!floating) { r.adjust(0, 1, 0, 1); } else { r.adjust(0, -1, 0, -1); } } if (floating) { if (vertical) { r.adjust(-1, 12, 3, -10); } else { r.adjust(2, 3, -3, -7); } } else { if (vertical) { r.adjust(0, 8, 4, -8); } else { r.adjust(0, 5, 0, -7); } } if (vertical) { QMatrix mat; QPointF c = r.center(); mat.translate(c.x(), c.y()); mat.rotate(-90); mat.translate(-c.x(), -c.y()); r = mat.mapRect(r); painter->setMatrix(mat, true); } // painter->fillRect(r, Qt::red); painter->setClipRect(r); style->drawItemText(painter, r, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic, option->palette, true, option->title, QPalette::WindowText); painter->restore(); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) QRect subElementRectDockWidget(QStyle::SubElement element, const QStyleOptionDockWidget *option, const QWidget *widget, const QStyle *style) { switch (element) { case QStyle::SE_DockWidgetCloseButton: case QStyle::SE_DockWidgetFloatButton: { const QDockWidget *dock = qobject_cast(widget); bool floating = option->floatable && dock && dock->isFloating(); bool vertical = dock && (dock->features() & QDockWidget::DockWidgetVerticalTitleBar); QRect r = ((QCommonStyle *) style)->QCommonStyle::subElementRect(element, option, widget); if (!vertical) { if (floating) { if (option->direction == Qt::LeftToRight) { return r.adjusted(-6, 0, -6, 0); } else { return r.adjusted(6, 0, 6, 0); } } else { if (option->direction == Qt::LeftToRight) { return r.adjusted(-3, 1, -3, 1); } else { return r.adjusted(3, 1, 3, 1); } } } else { if (floating) { return r.adjusted(0, 6, 0, 6); } else { return r.adjusted(1, 3, 1, 3); } } } case QStyle::SE_DockWidgetTitleBarText: return ((QCommonStyle *) style)->QCommonStyle::subElementRect(element, option, widget).adjusted(4, -3, -4, 5); case QStyle::SE_DockWidgetIcon: return ((QCommonStyle *) style)->QCommonStyle::subElementRect(element, option, widget).adjusted(4, -3, 4, 5); default: // avoid warning return option->rect; } } #endif /* * skulpture_factory.cpp * */ #include "skulpture_p.h" #include "sk_factory.h" /*-----------------------------------------------------------------------*/ bool AbstractFactory::evalCondition() { Code code = *p++; if (code < Or) { qreal v1 = evalValue(); qreal v2 = evalValue(); switch (code) { case EQ: return qAbs(v1 - v2) < 1.0e-9; case NE: return qAbs(v1 - v2) >= 1.0e-9; case LT: return v1 < v2; case GE: return v1 >= v2; case GT: return v1 > v2; case LE: return v1 <= v2; default: break; } } else { switch (code) { case OptionState: return opt && (opt->state & (1 << *p++)); case OptionRTL: return opt && (opt->direction != Qt::LeftToRight); case OptionVersion: return opt && (opt->version >= *p++); case OptionType: return opt && (!*p || opt->type == *p++); case OptionComplex: return opt && ((!*p && opt->type >= QStyleOption::SO_Complex) || (opt->type == QStyleOption::SO_Complex + *p++)); case FactoryVersion: return version() >= *p++; case Not: return !evalCondition(); case Or: if (evalCondition()) { skipCondition(); return true; } else { return evalCondition(); } case And: if (!evalCondition()) { skipCondition(); return false; } else { return evalCondition(); } default: break; } } return false; } void AbstractFactory::skipCondition() { Code code = *p++; if (code < Or) { skipValue(); skipValue(); } else { skipCondition(); skipCondition(); } } /*-----------------------------------------------------------------------*/ qreal AbstractFactory::evalValue() { Code code = *p++; if (code >= MinVal && code <= MaxVal) { return code * 0.01; } else if (code >= GetVar + MinVar && code <= GetVar + MaxVar) { return var[code - GetVar]; } else if (code >= Add && code <= Max) { qreal v1 = evalValue(); qreal v2 = evalValue(); switch (code) { case Add: return v1 + v2; case Sub: return v1 - v2; case Mul: return v1 * v2; case Div: return v2 != 0 ? v1 / v2 : 0; case Min: return qMin(v1, v2); case Max: return qMax(v1, v2); } } else if (code == Mix) { qreal v = evalValue(); return v * evalValue() + (1 - v) * evalValue(); } else if (code == Cond) { if (evalCondition()) { qreal v = evalValue(); skipValue(); return v; } else { skipValue(); return evalValue(); } } return 0; } void AbstractFactory::skipValue() { Code code = *p++; if (code >= MinVal && code <= MaxVal) { return; } else if (code >= GetVar + MinVar && code <= GetVar + MaxVar) { return; } else if (code >= Add && code <= Max) { skipValue(); skipValue(); return; } else if (code == Mix) { skipValue(); skipValue(); skipValue(); return; } else if (code == Cond) { skipCondition(); skipValue(); skipValue(); return; } } /*-----------------------------------------------------------------------*/ QColor AbstractFactory::evalColor() { Code code = *p++; switch (code) { case RGB: { const quint8 *c = (const quint8 *) p; p += 3; return QColor(c[0], c[1], c[2]); } case RGBA: { const quint8 *c = (const quint8 *) p; p += 4; return QColor(c[0], c[1], c[2], c[3]); } case RGBAf: { qreal v[4]; for (int n = 0; n < 4; ++n) { v[n] = qMin(qMax(qreal(0), evalValue()), qreal(1)); } return QColor::fromRgbF(v[0], v[1], v[2], v[3]); } case Blend: { QColor color0 = evalColor(); QColor color1 = evalColor(); return blend_color(color0, color1, evalValue()); } case Palette: { if (opt) { return opt->palette.color(QPalette::ColorRole(*p++)); } break; } case Shade: { QColor color = evalColor(); return shaded_color(color, int(evalValue() * 200)); } case Darker: { QColor color = evalColor(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) return color.darker(*p++); #else return color.dark(*p++); #endif } case Lighter: { QColor color = evalColor(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) return color.lighter(*p++); #else return color.light(*p++); #endif } default: break; } return QColor(); } void AbstractFactory::skipColor() { Code code = *p++; switch (code) { case RGB: { p += 3; return; } case RGBA: { p += 4; return; } case RGBAf: { for (int n = 0; n < 4; ++n) { skipValue(); } return; } case Blend: { skipColor(); skipColor(); skipValue(); return; } case Palette: { ++p; return; } case Shade: { skipColor(); skipValue(); return; } case Darker: case Lighter: { skipColor(); p++; return; } default: break; } } /*-----------------------------------------------------------------------*/ void AbstractFactory::executeCode(Code code) { if (code >= SetVar + MinVar && code <= SetVar + MaxVar) { var[code - SetVar] = evalValue(); } else switch (code) { case Begin: { while (*p != End) { Code code = *p++; executeCode(code); } ++p; return; } case While: { const Code *loop_p = p; int counter = 100; // prevent infinite loop while (evalCondition() && --counter >= 0) { Code code = *p++; executeCode(code); p = loop_p; } Code code = *p++; skipCode(code); return; } case If: { if (evalCondition()) { Code code = *p++; executeCode(code); if (*p == Else) { ++p; Code code = *p++; skipCode(code); } } else { Code code = *p++; skipCode(code); if (*p == Else) { ++p; Code code = *p++; executeCode(code); } } return; } } } void AbstractFactory::skipCode(Code code) { if (code >= SetVar + MinVar && code <= SetVar + MaxVar) { skipValue(); } else switch (code) { case Begin: { while (*p != End) { Code code = *p++; skipCode(code); } ++p; return; } case While: { skipCondition(); Code code = *p++; skipCode(code); return; } case If: { skipCondition(); Code code = *p++; skipCode(code); if (*p == Else) { ++p; Code code = *p++; skipCode(code); } return; } } } /*-----------------------------------------------------------------------*/ void AbstractFactory::create() { if (p != 0) { while (*p != End) { Code code = *p++; executeCode(code); } } } /* * skulpture_frames.cpp * */ #include "skulpture_p.h" #include #include #include #include #include #include #include #include #include #include #include /*-----------------------------------------------------------------------*/ static void paintThinFrame(QPainter *painter, const QRect &rect, const QBrush &brush1, const QBrush &brush2) { painter->fillRect(QRect(rect.left() + 1, rect.top(), rect.width() - 1, 1), brush2); painter->fillRect(QRect(rect.left(), rect.top(), 1, rect.height()), brush2); painter->fillRect(QRect(rect.left(), rect.bottom(), rect.width() - 1, 1), brush1); painter->fillRect(QRect(rect.right(), rect.top(), 1, rect.height()), brush1); } static const QBrush shaded_brush(const QPalette &palette, int shade, QPalette::ColorRole bgrole) { return (shaded_color(palette.color(bgrole), shade)); } /*-----------------------------------------------------------------------*/ /** * paintThinFrame - paint a single pixel wide frame * * Paints a frame _inside_ the specified rectangle, using * a single pixel wide pen. The frame is rendered by darkening * or brightening the pixels in that area; no specific color * can be selected. * * dark and light specify how dark or bright the frame should * be rendered. They are either negative (meaning darkening), * or positive (meaning brigthening). * * TODO: * dark and light are arbitrary values; they need adjustment. * */ void paintThinFrame(QPainter *painter, const QRect &rect, const QPalette &palette, int dark, int light, QPalette::ColorRole bgrole) { paintThinFrame(painter, rect, shaded_brush(palette, dark, bgrole), shaded_brush(palette, light, bgrole)); } void paintRecessedFrame(QPainter *painter, const QRect &rect, const QPalette &palette, enum RecessedFrame rf, QPalette::ColorRole bgrole) { paintThinFrame(painter, rect, palette, 30, -20, bgrole); paintThinFrame(painter, rect.adjusted(1, 1, -1, -1), palette, -20, -70, bgrole); paintRecessedFrameShadow(painter, rect.adjusted(2, 2, -2, -2), rf); } /*-----------------------------------------------------------------------*/ void paintFrameGroupBox(QPainter *painter, const QStyleOptionFrame *option) { QRect r = option->rect; r.setHeight(/*r.height() +*/ 2); paintThinFrame(painter, r, option->palette, 60, -20); // paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -20, 60); } static inline bool is_popup_menu(const QWidget *widget) { if (widget) { Qt::WindowFlags flags = widget->windowFlags(); Qt::WindowType type = Qt::WindowType(int(flags & Qt::WindowType_Mask)); if ((type & Qt::Window) && (flags & Qt::FramelessWindowHint || type == Qt::Popup)) { return true; } } return false; } void paintStyledFrame(QPainter *painter, const QStyleOptionFrame *option, const QWidget *widget, const QStyle */*style*/) { QPalette::ColorRole bgrole = widget ? widget->backgroundRole() : QPalette::Window; if (option->state & QStyle::State_Sunken) { if (qobject_cast(widget) && widget->parentWidget() && widget->parentWidget()->inherits("KFontRequester")) { paintThinFrame(painter, option->rect, option->palette, 60, -20); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -20, 60); QLinearGradient panelGradient(option->rect.topLeft(), option->rect.bottomLeft()); panelGradient.setColorAt(0.6, QColor(255, 255, 255, 0)); panelGradient.setColorAt(1.0, shaded_color(option->palette.color(QPalette::Window), 70)); painter->fillRect(option->rect.adjusted(2, 2, -2, -2), panelGradient); } else { /* if (option->palette.color(QPalette::Base) == QColor(220, 230, 210)) { painter->fillRect(option->rect.adjusted(2, 2, -2, -2), option->palette.color(QPalette::Base)); paintRecessedFrame(painter, option->rect, option->palette, RF_Small); } else*/ { RecessedFrame rf = RF_Large; if (!(option->state & QStyle::State_Enabled) || (widget && (!widget->isEnabled() || qobject_cast(widget)))) { rf = RF_Small; } if (qobject_cast(widget) || (widget && widget->inherits("Q3ScrollView"))) { const QList children = widget->children(); Q_FOREACH (QObject *child, children) { if (qobject_cast(child)) { rf = RF_None; break; } } } paintRecessedFrame(painter, option->rect, option->palette, rf); } } } else if (option->state & QStyle::State_Raised) { QRect r = option->rect; if (option->lineWidth == 0) { paintThinFrame(painter, r, option->palette, -20, 60); } else { paintThinFrame(painter, r, option->palette, -10, -20); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -40, 80, bgrole); // painter->fillRect(option->rect, Qt::red); } } else { // Plain if (qobject_cast(widget) && widget->parentWidget() && widget->parentWidget()->inherits("KTitleWidget")) { QRect r = option->rect; bgrole = QPalette::Window; // bgrole = QPalette::Base; #if 1 QColor bgcolor = option->palette.color(bgrole); #else QColor bgcolor = QColor(230, 230, 230); #endif // painter->fillRect(r.adjusted(1, 1, -1, -1), bgcolor); paintThinFrame(painter, r, option->palette, -10, -20); // painter->fillRect(r.adjusted(1, 1, -1, -1), QColor(200, 190, 160)); // painter->fillRect(r.adjusted(1, 1, -1, -1), QColor(240, 240, 240)); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -30, 80, bgrole); QLinearGradient gradient(r.topLeft(), r.bottomLeft()); gradient.setColorAt(0.0, shaded_color(bgcolor, 90)); gradient.setColorAt(0.2, shaded_color(bgcolor, 60)); gradient.setColorAt(0.5, shaded_color(bgcolor, 0)); gradient.setColorAt(0.51, shaded_color(bgcolor, -10)); gradient.setColorAt(1.0, shaded_color(bgcolor, -20)); painter->fillRect(r.adjusted(1, 1, -1, -1), gradient); #if 0 QRadialGradient dialogGradient2(r.left() + r.width() / 2, r.top(), r.height()); dialogGradient2.setColorAt(0.0, QColor(255, 255, 255, 50)); dialogGradient2.setColorAt(1.0, QColor(0, 0, 0, 0)); painter->save(); painter->translate(r.center()); painter->scale(r.width() / 2.0 / r.height(), 1); painter->translate(-r.center()); painter->fillRect(r.adjusted(1, 1, -1, -1), dialogGradient2); painter->restore(); #endif } else if (is_popup_menu(widget)) { QRect r = option->rect; paintThinFrame(painter, r, option->palette, -60, 160); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -20, 60, bgrole); } else { QRect r = option->rect; paintThinFrame(painter, r, option->palette, 60, -20); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -20, 60, bgrole); } } } void paintFrameLineEdit(QPainter *painter, const QStyleOptionFrame *option) { paintRecessedFrame(painter, option->rect, option->palette, RF_Small); } class LineEditHack : public QLineEdit { public: QRect cursorRectHack() const { #if QT_VERSION >= QT_VERSION_CHECK(4, 4, 0) return cursorRect(); #else return inputMethodQuery(Qt::ImMicroFocus).toRect(); #endif } }; static QRect getCursorRect(const QWidget *widget) { if (const QLineEdit *lineEdit = qobject_cast(widget)) { const LineEditHack *lineEditHack = reinterpret_cast(lineEdit); /*if (lineEdit->cursorPosition() != lineEdit->text().length())*/ { return lineEditHack->cursorRectHack(); } } return QRect(); } void lineEditMouseMoved(QLineEdit *lineEdit, QMouseEvent *event) { if (!lineEdit->hasFocus()) { QAbstractSpinBox *spinBox = qobject_cast(lineEdit->parentWidget()); int oldCursorPosition = lineEdit->cursorPosition(); int newCursorPosition = lineEdit->cursorPositionAt(event->pos()); if (spinBox && lineEdit->text() == spinBox->specialValueText()) { // newCursorPosition = lineEdit->text().length(); } else { if (QSpinBox *spinBox = qobject_cast(lineEdit->parentWidget())) { newCursorPosition = qBound(spinBox->prefix().length(), newCursorPosition, lineEdit->text().length() - spinBox->suffix().length()); } else if (QDoubleSpinBox *spinBox = qobject_cast(lineEdit->parentWidget())) { newCursorPosition = qBound(spinBox->prefix().length(), newCursorPosition, lineEdit->text().length() - spinBox->suffix().length()); } } if (oldCursorPosition != newCursorPosition) { lineEdit->update(getCursorRect(lineEdit).adjusted(-4, -16, 4, 16)); lineEdit->setCursorPosition(newCursorPosition); lineEdit->update(getCursorRect(lineEdit).adjusted(-4, -16, 4, 16)); } } } void paintPanelLineEdit(QPainter *painter, const QStyleOptionFrame *option, const QWidget *widget, const QStyle *style) { QPalette::ColorRole bgrole = widget ? widget->backgroundRole() : QPalette::Window; bool focus = (option->state & QStyle::State_HasFocus) && !(option->state & QStyle::State_ReadOnly); int fw = option->lineWidth; if (option->palette.brush(bgrole).style() == Qt::SolidPattern) { QRect cursorRect; QColor color = option->palette.color(bgrole); // printf("style=%d, bgrole=%d, panel color: r=%d, g=%d, b=%d, a=%d\n", option->palette.brush(bgrole).style(), bgrole, color.red(), color.green(), color.blue(), color.alpha()); if (focus && color.alpha() > 0) { color = blend_color(color, option->palette.color(QPalette::Highlight), 0.15); } else { focus = false; #if 1 if (option->state & QStyle::State_MouseOver && option->state & QStyle::State_Enabled && !(option->state & QStyle::State_ReadOnly)) { color = color.lighter(103); cursorRect = getCursorRect(widget); } else if (widget) { QWidget *box = widget->parentWidget(); if (qobject_cast(box) || qobject_cast(box)) { if (box->underMouse() && option->state & QStyle::State_Enabled) { QAbstractSpinBox *spinBox = qobject_cast(box); if (!spinBox || !spinBox->isReadOnly()) { color = color.lighter(103); } } } } #endif } painter->fillRect(option->rect.adjusted(fw, fw, -fw, -fw), color); if (false && option->state & QStyle::State_Enabled && option->rect.height() <= 64) { QLinearGradient panelGradient(option->rect.topLeft(), option->rect.bottomLeft()); if (color.valueF() > 0.9) { panelGradient.setColorAt(0.0, shaded_color(color, -20)); } panelGradient.setColorAt(0.6, shaded_color(color, 0)); panelGradient.setColorAt(1.0, shaded_color(color, 10)); painter->fillRect(option->rect.adjusted(fw, fw, -fw, -fw), panelGradient); } if (!cursorRect.isEmpty()) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) QRect cursor = style->subElementRect(QStyle::SE_LineEditContents, option, widget).adjusted(0, 2, 0, -3); #else QRect cursor = option->rect.adjusted(0, fw + 2, 0, -fw - 3); #endif if (cursor.height() != option->fontMetrics.height() - 1) { cursor.adjust(0, 1, 0, 0); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) int cursorWidth = style->pixelMetric(QStyle::PM_TextCursorWidth, option, widget); #else int cursorWidth = style->pixelMetric((QStyle::PixelMetric)((int) QStyle::PM_CustomBase + 1), option, widget); #endif cursor.setLeft(cursorRect.center().x() + 1 - (cursorWidth >> 1)); cursor.setWidth(cursorWidth); cursor.setTop(cursor.top() + ((cursor.height() - option->fontMetrics.height() + 2) >> 1)); cursor.setHeight(cursorRect.height() - 2); QColor color = option->palette.color(QPalette::Text); color.setAlpha(60); painter->fillRect(cursor, color); painter->fillRect(QRect(cursor.left() - cursorWidth, cursor.top() - 1, cursorWidth, 1), color); painter->fillRect(QRect(cursor.left() + cursorWidth, cursor.top() - 1, cursorWidth, 1), color); painter->fillRect(QRect(cursor.left() - cursorWidth, cursor.bottom() + 1, cursorWidth, 1), color); painter->fillRect(QRect(cursor.left() + cursorWidth, cursor.bottom() + 1, cursorWidth, 1), color); } } if (focus && option->state & QStyle::State_KeyboardFocusChange) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) QColor color = option->palette.color(QPalette::Highlight).darker(120); #else QColor color = option->palette.color(QPalette::Highlight).dark(120); #endif color.setAlpha(120); QRect r = option->rect.adjusted(fw + 2, fw + 2, -fw - 2, -fw - 2); r.setTop(r.top() + r.height() - 1); painter->fillRect(r, color); } if (fw) { if (option->state & QStyle::State_ReadOnly && !(option->state & QStyle::State_Enabled)) { paintThinFrame(painter, option->rect, option->palette, 60, -20); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -20, 60); } else { paintRecessedFrame(painter, option->rect, option->palette, option->rect.height() <= 64 ? RF_Small : RF_Small); } } else if (widget && widget->parent() && (qobject_cast(widget->parent()) || qobject_cast(widget->parent()))) { if (option->palette.brush(bgrole).style() != Qt::SolidPattern) { /* Fix Qt stylesheet demo */ return; } // we need to adjust shadows to the real frame, not that of the line edit int left = widget->geometry().left(), right = widget->geometry().right(); QComboBox *combo = qobject_cast(widget->parent()); int parentFrameWidth; if (combo) { if (!combo->hasFrame()) { return; } parentFrameWidth = style->pixelMetric(QStyle::PM_ComboBoxFrameWidth, option, widget); } else { QAbstractSpinBox *spin = qobject_cast(widget->parent()); if (spin && !spin->hasFrame()) { return; } parentFrameWidth = style->pixelMetric(QStyle::PM_SpinBoxFrameWidth, option, widget); } paintRecessedFrameShadow(painter, option->rect.adjusted(parentFrameWidth - left, 0, widget->parentWidget()->geometry().width() - right - parentFrameWidth - 1, 0), option->rect.height() <= 64 ? RF_Small : RF_Small); } } void paintFrameFocusRect(QPainter *painter, const QStyleOptionFocusRect *option, const QWidget *widget) { if (!(option->state & QStyle::State_KeyboardFocusChange)) { return; } if (option->state & QStyle::State_Item) { if (widget && widget->window() && !widget->window()->testAttribute(Qt::WA_KeyboardFocusChange)) { return; } } QColor color = option->palette.color(QPalette::Highlight); color.setAlpha(20); painter->fillRect(option->rect, color); // painter->fillRect(option->rect.adjusted(1, 1, -1, -1), color); painter->fillRect(option->rect.adjusted(2, 2, -2, -2), color); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) color = color.darker(120); #else color = color.dark(120); #endif color.setAlpha(230); painter->fillRect(option->rect.adjusted(0, option->rect.height() - 1, 0, 0), color); } //#if (QT_VERSION >= QT_VERSION_CHECK(4, 1, 0)) QRect subControlRectGroupBox(const QStyleOptionGroupBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { switch (subControl) { case QStyle::SC_GroupBoxContents: return option->rect.adjusted(0, option->fontMetrics.height(), 0, 0); case QStyle::SC_GroupBoxCheckBox: case QStyle::SC_GroupBoxLabel: { if (!(option->features & QStyleOptionFrameV2::Flat)) { int x = option->direction == Qt::LeftToRight ? -8 : 8; int y = (subControl == QStyle::SC_GroupBoxCheckBox) ? 0 : 1; return ((const QCommonStyle *) style)->QCommonStyle::subControlRect(QStyle::CC_GroupBox, option, subControl, widget).adjusted(x, y, x, y); } break; } default: break; } return ((const QCommonStyle *) style)->QCommonStyle::subControlRect(QStyle::CC_GroupBox, option, subControl, widget); } //#endif /*-----------------------------------------------------------------------*/ QGradient path_edge_gradient(const QRectF &rect, const QStyleOption *option, const QPainterPath &path, const QColor &color2, const QColor &color1) { QPointF c = rect.center(); QColor color[8]; if (/*true ||*/ option->direction == Qt::LeftToRight) { color[0] = blend_color(QColor(255, 255, 255, 255), color1, 0.5); color[1] = color1; color[2] = blend_color(color1, color2, 0.5); color[3] = color2; // color[3] = color1; color[4] = blend_color(QColor(0, 0, 0, 255), color2, 0.5); color[5] = color2; color[6] = blend_color(color2, color1, 0.5); color[7] = color1; // color[7] = color2; } else { color[2] = blend_color(QColor(255, 255, 255, 255), color1, 0.5); color[1] = color1; color[0] = blend_color(color1, color2, 0.5); color[7] = color2; // color[7] = color1; color[6] = blend_color(QColor(0, 0, 0, 255), color2, 0.5); color[5] = color2; color[4] = blend_color(color2, color1, 0.5); color[3] = color1; // color[3] = color2; } QConicalGradient gradient(c, 0); Q_UNUSED(path); qreal angle; qreal d = 1; QRectF r = rect.adjusted(1, 1, -1, -1); { QRectF rect = r; gradient.setColorAt(0.0, color[3]); angle = atan2(rect.top() + d - c.y(), rect.right() - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[3]); angle = atan2(rect.top() - c.y(), rect.right() - d - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[5]); angle = atan2(rect.top() - c.y(), rect.left() + d - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[5]); angle = atan2(rect.top() + d - c.y(), rect.left() - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[7]); angle = atan2(rect.bottom() - d - c.y(), rect.left() - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[7]); angle = atan2(rect.bottom() - c.y(), rect.left() + d - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[1]); angle = atan2(rect.bottom() - c.y(), rect.right() - d - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[1]); angle = atan2(rect.bottom() - d - c.y(), rect.right() - c.x()); if (angle < 0) angle += M_PI * 2.0; gradient.setColorAt(angle / 2.0 / M_PI, color[3]); gradient.setColorAt(1.0, color[3]); } return gradient; } /* * skulpture_gradients.cpp * */ #include "skulpture_p.h" #include "sk_factory.h" /*-----------------------------------------------------------------------*/ /** * GradientFactory - create a QGradient from a description * * The gradient description is a bytecode stream that allows simple arithmetic, * conditionals, and looping. * */ /*-----------------------------------------------------------------------*/ void GradientFactory::executeCode(Code code) { qreal v; switch (code) { case ColorAt: v = evalValue(); gradient.setColorAt(v, evalColor()); break; default: AbstractFactory::executeCode(code); break; } } void GradientFactory::skipCode(Code code) { switch (code) { case ColorAt: skipValue(); skipColor(); break; default: AbstractFactory::skipCode(code); break; } } /*-----------------------------------------------------------------------*/ QGradient GradientFactory::createGradient(GradientFactory::Description description, qreal var[]) { GradientFactory factory; factory.setDescription(description); for (int n = MinVar; n <= MaxVar; ++n) { factory.setVar(n, var[n]); } factory.create(); for (int n = MinVar; n <= MaxVar; ++n) { var[n] = factory.getVar(n); } return factory.getGradient(); } QGradient GradientFactory::createGradient(GradientFactory::Description description) { GradientFactory factory; factory.setDescription(description); factory.create(); return factory.getGradient(); } /* * skulpture_header.cpp * */ #include "skulpture_p.h" #include "sk_factory.h" #include #include /*-----------------------------------------------------------------------*/ void paintHeaderEmptyArea(QPainter *painter, const QStyleOption *option) { if (option->state & QStyle::State_Enabled) { painter->fillRect(option->rect, option->palette.color(QPalette::Window).lighter(107)); } else { painter->fillRect(option->rect, option->palette.color(QPalette::Window).darker(104)); } if (option->state & QStyle::State_Horizontal) { paintThinFrame(painter, option->rect.adjusted(0, -2, 32000, -1), option->palette, -20, 60); // painter->fillRect(option->rect.adjusted(0, option->rect.height() - 1, 0, 0), QColor(255, 255, 255, 160)); } else { paintThinFrame(painter, option->rect.adjusted(-2, 0, -1, 32000), option->palette, -20, 60); // painter->fillRect(option->rect.adjusted(option->rect.width() - 1, 0, 0, 0), QColor(255, 255, 255, 160)); } } static bool isHeaderEnabled(const QStyleOptionHeader *option, const QWidget *widget) { bool enabled = true; if (!(option->state & QStyle::State_Enabled)) { enabled = false; if (widget && widget->inherits("Q3Header")) { enabled = widget->isEnabled(); } } return enabled; } void paintHeaderSection(QPainter *painter, const QStyleOptionHeader *option, const QWidget *widget, const QStyle *style) { Q_UNUSED(style); if (!(option->state & (QStyle::State_Raised | QStyle::State_Sunken))) { painter->fillRect(option->rect, option->palette.color(QPalette::Window).darker(104)); paintRecessedFrame(painter, option->rect.adjusted(-9, -9, 3, 3), option->palette, RF_Small); painter->fillRect(QRect(option->rect.right(), option->rect.bottom(), 1, 1), option->palette.color(QPalette::Window)); } else { if (isHeaderEnabled(option, widget)) { bool hover = false; const QHeaderView *view = qobject_cast(widget); if (view && (view->isClickable() || view->isMovable())) { hover = option->state & QStyle::State_MouseOver; } painter->fillRect(option->rect, option->palette.color(QPalette::Base).darker(hover ? 104 : (option->state & QStyle::State_On ? 120 : 106))); } else { painter->fillRect(option->rect, option->palette.color(QPalette::Window).darker(104)); } if (true || !(option->state & QStyle::State_On)) { if (option->orientation == Qt::Horizontal) { const QHeaderView *view = qobject_cast(widget); if (view && view->rect().right() == option->rect.right()) { paintThinFrame(painter, option->rect.adjusted(0, -2, 1, -1), option->palette, -20, 60); } else { paintThinFrame(painter, option->rect.adjusted(0, -2, 0, -1), option->palette, -20, 60); } } else { if (option->direction == Qt::LeftToRight) { paintThinFrame(painter, option->rect.adjusted(-2, 0, -1, 0), option->palette, -20, 60); } else { paintThinFrame(painter, option->rect.adjusted(1, 0, 2, 0), option->palette, -20, 60); } } } #if 0 if (option->orientation == Qt::Horizontal) { painter->fillRect(option->rect.adjusted(0, option->rect.height() - 1, 0, 0), QColor(255, 255, 255, 160)); } else { painter->fillRect(option->rect.adjusted(option->rect.width() - 1, 0, 0, 0), QColor(255, 255, 255, 160)); } #endif } } void paintHeaderLabel(QPainter *painter, const QStyleOptionHeader *option, const QWidget *widget, const QStyle *style) { QStyleOptionHeader opt = *option; if (isHeaderEnabled(option, widget)) { opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::Text)); } else { opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::WindowText)); } painter->save(); if (widget) { painter->setFont(widget->font()); } ((QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_HeaderLabel, &opt, painter, widget); painter->restore(); } static const ShapeFactory::Code headerSortIndicatorShapeDescription[] = { Pmove(-1, 1), Pline(1, 1), Pline(0, -1), Pend }; void paintHeaderSortIndicator(QPainter *painter, const QStyleOptionHeader *option) { int h = option->fontMetrics.height() / 2 + 2; int w = option->fontMetrics.height() / 4 + 2; QPainterPath path; h /= 2; w /= 2; if (option->sortIndicator == QStyleOptionHeader::SortDown) { h = -h; } painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->translate(option->rect.center()); painter->translate(0.5, 1.5); painter->setPen(Qt::NoPen); QColor color = option->palette.color(option->state & QStyle::State_Enabled ? QPalette::Text : QPalette::WindowText); color.setAlphaF(0.6 * color.alphaF()); painter->setBrush(color); QMatrix matrix(w, 0, 0, h, 0, 0); painter->drawPath(matrix.map(ShapeFactory::createShape(headerSortIndicatorShapeDescription))); painter->restore(); } /* * skulpture_icons.cpp * */ #include "skulpture_p.h" #include "sk_factory.h" #include #include #include #include #include #include /*-----------------------------------------------------------------------*/ QPixmap SkulptureStyle::standardPixmap(QStyle::StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const { return ParentStyle::standardPixmap(standardPixmap, option, widget); } /*-----------------------------------------------------------------------*/ /** * decorationShape - get shape for window decoration button * * The coordinate system is -1 ... 1 for each dimension, with * (0, 0) being at the center, and positive coordinates pointing * down and to the right. * */ static const ShapeFactory::Code titleBarMenuButtonDescription[] = { Pmove(0, 0.6), Pline(0.6, 0), Pline(0, -0.6), Pline(-0.6, 0), Pend }; static const ShapeFactory::Code titleBarCloseButtonDescription[] = { #define kx3 0.3 Pmove(-1, -1), Pline(0, -kx3), Pline(1, -1), Pline(kx3, 0), Pline(1, 1), Pline(0, kx3), Pline(-1, 1), Pline(-kx3, 0), Pend }; static const ShapeFactory::Code titleBarShadeButtonDescription[] = { Pmove(-1, -0.4), Pline(0, -0.6), Pline(1, -0.4), Pline(0, -1), Pend }; static const ShapeFactory::Code titleBarUnshadeButtonDescription[] = { Pmove(-1, -1), Pline(0, -0.8), Pline(1, -1), Pline(0, -0.4), Pend }; static const ShapeFactory::Code titleBarMinButtonDescription[] = { Pmove(-1, 0.4), Pline(0, 0.6), Pline(1, 0.4), Pline(0, 1), Pend }; static const ShapeFactory::Code titleBarMaxButtonDescription[] = { #define kx1 0.8 #define kx2 0.55 Pmove(0, -1), Pline(1, 0), Pline(0, 1), Pline(-1, 0), Pclose, Pmove(0, -kx2), Pline(-kx1, 0), Pline(0, kx2), Pline(kx1, 0), Pend, }; static const ShapeFactory::Code titleBarNormalButtonDescription[] = { Pmove(0, -1), Pline(1, 0), Pline(0, 1), Pline(-1, 0), Pclose, Pmove(0, -kx1), Pline(-kx2, 0), Pline(0, kx1), Pline(kx2, 0), Pend, }; static const ShapeFactory::Code titleBarHelpButtonDescription[] = { Pmove(0.0305, 0.513), Pline(-0.0539, 0.513), Pline(0.0117, 0.227), Pline(0.22, -0.0859), Pline(0.38, -0.323), Pline(0.417, -0.491), Pline(0.279, -0.767), Pline(-0.0609, -0.87), Pline(-0.342, -0.814), Pline(-0.445, -0.692), Pline(-0.383, -0.568), Pline(-0.321, -0.456), Pline(-0.368, -0.373), Pline(-0.483, -0.339), Pline(-0.64, -0.396), Pline(-0.71, -0.555), Pline(-0.512, -0.827), Pline(0.0281, -0.947), Pline(0.649, -0.783), Pline(0.797, -0.516), Pline(0.73, -0.31), Pline(0.476, -0.0625), Pline(0.111, 0.255), Pclose, Pmove(0.00234, 0.681), Pline(0.165, 0.726), Pline(0.232, 0.834), Pline(0.164, 0.943), Pline(0.00234, 0.988), Pline(-0.158, 0.943), Pline(-0.225, 0.834), Pline(-0.158, 0.726), Pend }; static const ShapeFactory::Code titleBarStickyButtonDescription[] = { Pmove(0, -1), Pline(0.2, -0.2), Pline(1, 0), Pline(0.2, 0.2), Pline(0, 1), Pline(-0.2, 0.2), Pline(-1, 0), Pline(-0.2, -0.2), Pend }; static const ShapeFactory::Code titleBarUnstickyButtonDescription[] = { Pmove(0, -0.2), Pline(1, 0), Pline(0, 0.2), Pline(-1, 0), Pend }; static const ShapeFactory::Code titleBarAboveButtonDescription[] = { Pmove(0, -0.2), Pline(1, 0), Pline(0, 0.2), Pline(-1, 0), Pclose, Pmove(-1, -0.4), Pline(0, -0.6), Pline(1, -0.4), Pline(0, -1), Pend }; static const ShapeFactory::Code titleBarBelowButtonDescription[] = { Pmove(0, -0.2), Pline(1, 0), Pline(0, 0.2), Pline(-1, 0), Pclose, Pmove(-1, 0.4), Pline(0, 0.6), Pline(1, 0.4), Pline(0, 1), Pend }; static const ShapeFactory::Code titleBarUnaboveButtonDescription[] = { Pmove(0, -0.2), Pline(1, 0), Pline(0, 0.2), Pline(-1, 0), Pclose, Pmove(-1, -1), Pline(0, -0.8), Pline(1, -1), Pline(0, -0.4), Pend }; static const ShapeFactory::Code titleBarUnbelowButtonDescription[] = { Pmove(0, -0.2), Pline(1, 0), Pline(0, 0.2), Pline(-1, 0), Pclose, Pmove(-1, 1), Pline(0, 0.8), Pline(1, 1), Pline(0, 0.4), Pend }; static const ShapeFactory::Code toolBarHorizontalExtensionButtonDescription[] = { Pmove(-1, -1), Pline(0, 0), Pline(-1, 1), Pline(-0.5, 0), Pclose, Pmove(0, -1), Pline(1, 0), Pline(0, 1), Pline(0.5, 0), Pend }; static const ShapeFactory::Code toolBarVerticalExtensionButtonDescription[] = { Pmove(-1, -1), Pline(0, -0.5), Pline(1, -1), Pline(0, 0), Pclose, Pmove(-1, 0), Pline(0, 0.5), Pline(1, 0), Pline(0, 1), Pend }; static const ShapeFactory::Code * const titleBarButtonDescriptions[] = { titleBarMenuButtonDescription, titleBarMinButtonDescription, titleBarMaxButtonDescription, titleBarCloseButtonDescription, titleBarNormalButtonDescription, titleBarShadeButtonDescription, titleBarUnshadeButtonDescription, titleBarHelpButtonDescription }; static const ShapeFactory::Code * const titleBarCustomDescriptions[] = { 0, // CustomBase intentionally left blank titleBarStickyButtonDescription, titleBarUnstickyButtonDescription, 0, // this used to be titleBarIconDescription titleBarAboveButtonDescription, titleBarBelowButtonDescription, titleBarUnaboveButtonDescription, titleBarUnbelowButtonDescription }; QIcon SkulptureStyle::standardIconImplementation(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const { const ShapeFactory::Code *code = 0; int numStates = 1; int size = 10; if (standardIcon > QStyle::SP_CustomBase) { if (standardIcon - QStyle::SP_CustomBase < sizeof(titleBarCustomDescriptions) / sizeof(titleBarCustomDescriptions[0])) { code = titleBarCustomDescriptions[standardIcon - QStyle::SP_CustomBase]; numStates = 3; } } else if (/*standardIcon >= QStyle::SP_TitleBarMenuButton && */standardIcon <= QStyle::SP_TitleBarContextHelpButton) { code = titleBarButtonDescriptions[standardIcon - QStyle::SP_TitleBarMenuButton]; numStates = 3; } else { switch (standardIcon) { case QStyle::SP_ToolBarHorizontalExtensionButton: code = toolBarHorizontalExtensionButtonDescription; numStates = 2; size = 8; break; case QStyle::SP_ToolBarVerticalExtensionButton: code = toolBarVerticalExtensionButtonDescription; numStates = 2; size = 8; break; default: break; } } if (code) { QIcon icon; bool dock = qobject_cast(widget) != 0; if (dock) { size = 14; numStates = 2; } qreal s = size / 2.0; if (numStates == 3) { if (widget && !qstrcmp(widget->metaObject()->className(), "KLineEditButton")) { s = qMin(22, widget->fontMetrics().height()) * 0.25; size += 2; } else if (widget && !qstrcmp(widget->metaObject()->className(), "CloseButton")) { s = qMin(20, widget->fontMetrics().height()) * 0.25; } else { size += 4; if (option) { s = qMin(22, option->fontMetrics.height()) * 0.3; } } } for (int state = 0; state < numStates; ++state) { QImage image(size, size, QImage::Format_ARGB32); image.fill(0); QPainter painter(&image); painter.setRenderHint(QPainter::Antialiasing, true); painter.translate(size / 2.0, size / 2.0); if (dock) { painter.scale(s - 2, s - 2); } else { painter.scale(s, s); } painter.setPen(Qt::NoPen); QPalette palette; if (option) { palette = option->palette; } QPalette::ColorRole role = QPalette::Text; QColor shapeColor; if (numStates == 2) { if (state == 0) { role = QPalette::WindowText; } else { role = QPalette::ButtonText; } shapeColor = palette.color(role); } else if (numStates == 3) { if (state == 1) { QColor glowColor = palette.color(role); if (standardIcon == QStyle::SP_TitleBarCloseButton) { glowColor = QColor(255, 0, 0, 100); } else { glowColor.setAlpha(50); } painter.fillRect(QRectF(-1.5, -1.5, 3, 3), glowColor); QPainterPath path = ShapeFactory::createShape(code); shapeColor = palette.color(role); // painter.setPen(QPen(shapeColor, 0.3)); painter.drawRect(QRectF(-1.5, -1.5, 3, 3)); painter.setPen(Qt::NoPen); painter.setBrush(shapeColor); painter.drawPath(path); } else { shapeColor = palette.color(role); } } QColor shadowColor = option ? option->palette.color(QPalette::Shadow) : Qt::black; shadowColor.setAlpha(25); painter.translate(1 / s, 1 / s); painter.setBrush(shadowColor); painter.drawPath(ShapeFactory::createShape(code)); painter.translate(-1 / s, -1 / s); painter.setBrush(shapeColor); painter.drawPath(ShapeFactory::createShape(code)); painter.end(); QIcon::Mode iconMode; switch (state) { case 1: iconMode = QIcon::Active; break; case 2: #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) iconMode = QIcon::Selected; #else iconMode = QIcon::Normal; #endif break; default: iconMode = QIcon::Normal; break; } icon.addPixmap(QPixmap::fromImage(image), iconMode); } return icon; } return ParentStyle::standardIconImplementation(standardIcon, option, widget); } QPixmap SkulptureStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const { return ParentStyle::generatedIconPixmap(iconMode, pixmap, option); } QRect SkulptureStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap & pixmap) const { return ParentStyle::itemPixmapRect(rectangle, alignment, pixmap); } void SkulptureStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const { ParentStyle::drawItemPixmap(painter, rectangle, alignment, pixmap); } /* * skulpture_layout.cpp * */ #include "skulpture_p.h" #include #include #include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) #include #include #include #endif /*-----------------------------------------------------------------------*/ int SkulptureStyle::Private::verticalTextShift(const QFontMetrics &fontMetrics) { if (fontMetrics.xHeight() == qApp->fontMetrics().xHeight() && fontMetrics.ascent() == qApp->fontMetrics().ascent() && fontMetrics.descent() == qApp->fontMetrics().descent() && fontMetrics.leading() == qApp->fontMetrics().leading()) { return textShift; } return 0; } static QFontMetrics styledFontMetrics(const QStyleOption *option, const QWidget *widget) { if (option) { return option->fontMetrics; } else if (widget) { return widget->fontMetrics(); } return qApp->fontMetrics(); } int SkulptureStyle::Private::textLineHeight(const QStyleOption *option, const QWidget *widget) { QFontMetrics fm = styledFontMetrics(option, widget); return fm.height() + (verticalTextShift(fm) & 1); } static int fontHeight(const QStyleOption *option, const QWidget *widget) { return styledFontMetrics(option, widget).height(); } /*-----------------------------------------------------------------------*/ int SkulptureStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { switch (metric) { /* entries are stricly sorted in Qt order for future lookup table */ case PM_ButtonMargin: return 2 * d->pushButtonSize; case PM_ButtonDefaultIndicator: return 0; case PM_MenuButtonIndicator: return fontHeight(option, widget); case PM_ButtonShiftHorizontal: { Qt::LayoutDirection direction; if (option) { direction = option->direction; } else if (widget) { direction = widget->layoutDirection(); } else { direction = QApplication::layoutDirection(); } return direction == Qt::LeftToRight ? 1 : -1; } case PM_ButtonShiftVertical: return 1; case PM_DefaultFrameWidth: return 2; // 3 for command buttons case PM_SpinBoxFrameWidth: return 2; case PM_ComboBoxFrameWidth: return 2; // 3 for non-editable combobox (in button mode) case PM_MaximumDragDistance: return -1; case PM_ScrollBarExtent: { if (d->scrollBarSize > 0) { return d->scrollBarSize; } // do not depend on widget font size int extent = ((fontHeight(0, 0) >> 1) & ~1) + 9; #if 0 if (option && (option->state & QStyle::State_Horizontal)) { return (qMax(extent, qApp->globalStrut().height()) & ~1) + 1; } else { return (qMax(extent, qApp->globalStrut().width()) & ~1) + 1; } #else return extent; #endif } case PM_ScrollBarSliderMin: { if (d->scrollBarLength > 0) { return d->scrollBarLength; } return fontHeight(0, 0) + 1; } case PM_SliderThickness: case PM_SliderControlThickness: { if (d->sliderSize > 0) { return d->sliderSize + 4; } int thickness = (fontHeight(option, widget) & ~1) + 5; if (option && !(option->state & QStyle::State_Horizontal)) { return (qMax(thickness, qApp->globalStrut().width()) & ~1) + 1; } else { return (qMax(thickness, qApp->globalStrut().height()) & ~1) + 1; } } case PM_SliderLength: { if (d->sliderLength > 0) { return d->sliderLength; } int length = (fontHeight(option, widget)) + 6; if (option && !(option->state & QStyle::State_Horizontal)) { return qMax(length, qApp->globalStrut().height()); } else { return qMax(length, qApp->globalStrut().width()); } } case PM_SliderTickmarkOffset: { if (const QStyleOptionSlider *sliderOption = qstyleoption_cast(option)) { if (sliderOption->tickPosition == QSlider::TicksAbove) { return 5; } else if (sliderOption->tickPosition == QSlider::TicksBothSides) { return 5; } else if (sliderOption->tickPosition == QSlider::TicksBelow) { return 0; } } return 0; } case PM_SliderSpaceAvailable: { return QCommonStyle::pixelMetric(metric, option, widget); } case PM_DockWidgetSeparatorExtent: return ((qMax(fontHeight(option, widget), 16) >> 1) & ~1) - 1; case PM_DockWidgetHandleExtent: return 8; case PM_DockWidgetFrameWidth: return 2; case PM_TabBarTabOverlap: return 2; case PM_TabBarTabHSpace: return 2 * d->tabBarSize + (fontHeight(option, widget) & ~1); case PM_TabBarTabVSpace: return 0; case PM_TabBarBaseHeight: return 2; case PM_TabBarBaseOverlap: return 2; case PM_ProgressBarChunkWidth: return fontHeight(option, widget) >> 1; case PM_SplitterWidth: return ((qMax(fontHeight(option, widget), 16) >> 1) & ~1) - 1; case PM_TitleBarHeight: return d->textLineHeight(option, widget) + 4; case PM_MenuScrollerHeight: return (fontHeight(option, widget) >> 1) + 2; #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) case PM_MenuHMargin: return 1; case PM_MenuVMargin: return 1; case PM_MenuPanelWidth: return 1; #else case PM_MenuHMargin: return runtimeQtVersion() < QT_VERSION_CHECK(4, 4, 0) ? 0 : 1; // ### anything other than 0 messes Qt's menu positioning code ... case PM_MenuVMargin: return runtimeQtVersion() < QT_VERSION_CHECK(4, 4, 0) ? 0 : 1; case PM_MenuPanelWidth: return runtimeQtVersion() < QT_VERSION_CHECK(4, 4, 0) ? 2 : 1; #endif case PM_MenuTearoffHeight: return (fontHeight(option, widget) >> 1) + 2; case PM_MenuDesktopFrameWidth: return 0; case PM_MenuBarPanelWidth: return 0; case PM_MenuBarItemSpacing: return 0; case PM_MenuBarVMargin: return 0; case PM_MenuBarHMargin: return 0; case PM_IndicatorWidth: case PM_IndicatorHeight: case PM_ExclusiveIndicatorWidth: case PM_ExclusiveIndicatorHeight: case PM_CheckListButtonSize: case PM_CheckListControllerSize: { // do not use strut width, because label is usually wide enough return qMax(d->textLineHeight(option, widget), QApplication::globalStrut().height()); } case PM_DialogButtonsSeparator: return 6; case PM_DialogButtonsButtonWidth: return 64; case PM_DialogButtonsButtonHeight: return 16; #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) case PM_MdiSubWindowFrameWidth: return 3; case PM_MdiSubWindowMinimizedWidth: return fontHeight(option, widget) * 12; #else case PM_MDIFrameWidth: return 3; case PM_MDIMinimizedWidth: return fontHeight(option, widget) * 12; #endif case PM_HeaderMargin: return 3; case PM_HeaderMarkSize: return 5; case PM_HeaderGripMargin: return 4; case PM_TabBarTabShiftHorizontal: return 0; case PM_TabBarTabShiftVertical: return 0; case PM_TabBarScrollButtonWidth: return (fontHeight(option, widget) & ~1) + 1; case PM_ToolBarFrameWidth: return 1; case PM_ToolBarHandleExtent: return 9; case PM_ToolBarItemSpacing: return 2; case PM_ToolBarItemMargin: return 0; case PM_ToolBarSeparatorExtent: return 4; case PM_ToolBarExtensionExtent: return 12; case PM_SpinBoxSliderHeight: return 2; case PM_DefaultTopLevelMargin: { if (d->dialogMargins >= 0) { return d->dialogMargins; } return (fontHeight(option, widget) >> 1); } case PM_DefaultChildMargin: { if (d->widgetMargins >= 0) { return d->widgetMargins; } return (fontHeight(option, widget) >> 1); } case PM_DefaultLayoutSpacing: { if (d->verticalSpacing >= 0) { return d->verticalSpacing; } return ((fontHeight(option, widget) * 3) >> 3); } case PM_ToolBarIconSize: if (runtimeQtVersion() >= QT_VERSION_CHECK(4, 6, 0)) { break; } return pixelMetric(PM_SmallIconSize, option, widget); case PM_ListViewIconSize: return pixelMetric(PM_SmallIconSize, option, widget); case PM_IconViewIconSize: return pixelMetric(PM_LargeIconSize, option, widget); case PM_SmallIconSize: { int iconSize = d->textLineHeight(option, widget); return iconSize; } case PM_LargeIconSize: { const bool hasSvgIcons = false; int iconSize = 2 * fontHeight(option, widget); if (!hasSvgIcons) { if (iconSize < 28) { return 22; } else if (iconSize < 40) { return 32; } else if (iconSize < 56) { return 48; } else if (iconSize < 96) { return 64; } } return iconSize; } case PM_FocusFrameVMargin: return 2; case PM_FocusFrameHMargin: return 2; case PM_ToolTipLabelFrameWidth: return 1; case PM_CheckBoxLabelSpacing: { if (d->labelSpacing >= 0) { return d->labelSpacing; } return (fontHeight(option, widget) >> 1) - 2; } case PM_TabBarIconSize: return pixelMetric(PM_SmallIconSize, option, widget); case PM_SizeGripSize: return 13; // ### make this variable case PM_DockWidgetTitleMargin: return 2; #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) case PM_MessageBoxIconSize: return pixelMetric(PM_LargeIconSize, option, widget); case PM_ButtonIconSize: return pixelMetric(PM_SmallIconSize, option, widget); #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) case PM_DockWidgetTitleBarButtonMargin: return 0; case PM_RadioButtonLabelSpacing: { if (d->labelSpacing >= 0) { return d->labelSpacing; } return (fontHeight(option, widget) >> 1) - 2; } case PM_LayoutLeftMargin: case PM_LayoutTopMargin: case PM_LayoutRightMargin: case PM_LayoutBottomMargin: { PixelMetric metric = QStyle::PM_DefaultChildMargin; if ((option && (option->state & QStyle::State_Window)) || (widget && widget->isWindow())) { metric = QStyle::PM_DefaultTopLevelMargin; } return pixelMetric(metric, option, widget); } case PM_LayoutHorizontalSpacing: case PM_LayoutVerticalSpacing: { return -1; } #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) case PM_TabBar_ScrollButtonOverlap: return 0; case PM_TextCursorWidth: { if (d->textCursorWidth > 0) { return qMax(1, int(d->textCursorWidth + 0.5)); } return qMax(1, (fontHeight(option, widget) + 8) / 12); } #else // used for TextCursorWidth in Qt < 4.4 case PM_CustomBase + 1: { if (d->textCursorWidth > 0) { return qMax(1, int(d->textCursorWidth + 0.5)); } return qMax(1, (fontHeight(option, widget) + 8) / 12); } #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) case PM_TabCloseIndicatorWidth: case PM_TabCloseIndicatorHeight: { return (fontHeight(option, widget) & ~1); } case PM_ScrollView_ScrollBarSpacing: return 0; case PM_SubMenuOverlap: return -2; #endif case PM_CustomBase: // avoid warning break; } return ParentStyle::pixelMetric(metric, option, widget); } /*-----------------------------------------------------------------------*/ #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) int SkulptureStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const { Q_UNUSED(control2); if (orientation == Qt::Horizontal) { if (control1 == QSizePolicy::Label) { if (d->labelSpacing >= 0) { return d->labelSpacing + 2; } return fontHeight(option, widget) >> 1; } if (d->horizontalSpacing >= 0) { return d->horizontalSpacing; } return fontHeight(option, widget) >> 1; } if (control1 & (QSizePolicy::CheckBox | QSizePolicy::RadioButton) && control2 & (QSizePolicy::CheckBox | QSizePolicy::RadioButton)) { if (d->verticalSpacing >= 0) { return qMax(0, d->verticalSpacing - 2); } return pixelMetric(PM_DefaultLayoutSpacing, option, widget) - 2; } if (d->verticalSpacing >= 0) { return d->verticalSpacing; } return pixelMetric(PM_DefaultLayoutSpacing, option, widget); } #endif /*-----------------------------------------------------------------------*/ extern QSize sizeFromContentsToolButton(const QStyleOptionToolButton *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int toolButtonSize); extern QSize sizeFromContentsMenuItem(const QStyleOptionMenuItem *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int menuItemSize, int textLineHeight); /*-----------------------------------------------------------------------*/ static inline QSize sizeFromContentsPushButton(const QStyleOptionButton *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int pushButtonSize, int textLineHeight) { Q_UNUSED(style); // width int w = contentsSize.width() + (fontHeight(option, widget) & ~1); if (!option->text.isEmpty()) { w += 6 + 2 * pushButtonSize; const int sizeBase = qMin(64, 4 * fontHeight(option, widget)); const int sizeIncrement = qMin(32, qMin(sizeBase, qMax(1, 2 * pushButtonSize))); if (w < sizeBase) { w = sizeBase; } else { w = ((w - sizeBase + sizeIncrement - 1) / sizeIncrement) * sizeIncrement + sizeBase; } } // height int h = qMax(contentsSize.height(), textLineHeight); h += 2 * pushButtonSize + 4; return QSize(w, h); } static inline QSize sizeFromContentsComboBox(const QStyleOptionComboBox *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int widgetSize, int textLineHeight) { // if (contentsSize.height() > 16) { // fh = contentsSize.height() - 2; // } return ((const QCommonStyle *) style)->QCommonStyle::sizeFromContents(QStyle::CT_ComboBox, option, QSize(contentsSize.width(), textLineHeight + 2 * widgetSize), widget); } static inline QSize sizeFromContentsLineEdit(const QStyleOptionFrame *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int widgetSize, int textLineHeight) { Q_UNUSED(widget); Q_UNUSED(style); int fw = option->lineWidth; int fh = textLineHeight; // if (contentsSize.height() > 14) { // fh = contentsSize.height() - 4; // } return QSize(contentsSize.width() + 6 + 2 * fw, fh + 2 * (widgetSize + fw)); } static inline QSize sizeFromContentsSpinBox(const QStyleOptionSpinBox *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style) { Q_UNUSED(option); Q_UNUSED(widget); Q_UNUSED(style); return contentsSize + QSize(4, 0); } static inline QSize sizeFromContentsGroupBox(const QStyleOptionGroupBox *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style) { Q_UNUSED(widget); Q_UNUSED(style); if (!(option->features & QStyleOptionFrameV2::Flat)) { return contentsSize + QSize(fontHeight(option, widget) & ~1, 0); } return contentsSize; } static inline QSize sizeFromContentsTabBarTab(const QStyleOptionTab *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int tabBarSize, int textShift) { Q_UNUSED(widget); Q_UNUSED(style); if (int(option->shape) & 2) { return (contentsSize + QSize(4 + 2 * tabBarSize, 0)).expandedTo(QApplication::globalStrut()); } if (!option->icon.isNull()) { textShift = 0; } return (contentsSize + QSize(0, 2 + 2 * tabBarSize + (textShift & 1))).expandedTo(QApplication::globalStrut()); } static inline QSize sizeFromContentsProgressBar(const QStyleOptionProgressBar *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int widgetSize, int textShift) { Q_UNUSED(widget); Q_UNUSED(style); if (option->version >= 2 && ((const QStyleOptionProgressBarV2 *) option)->orientation == Qt::Vertical) { return contentsSize + QSize(2 * widgetSize, 6); } return contentsSize + QSize(6, (textShift & 1) + 2 * widgetSize - 6); } /*-----------------------------------------------------------------------*/ #define CT_CASE(ct, so) \ case CT_## ct: \ if (option && option->type == QStyleOption::SO_## so) { \ return sizeFromContents ## ct((const QStyleOption ## so *) option, contentsSize, widget, this); \ } \ break QSize SkulptureStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const { switch (type) { case CT_PushButton: if (option && option->type == QStyleOption::SO_Button) { return sizeFromContentsPushButton((const QStyleOptionButton *) option, contentsSize, widget, this, d->pushButtonSize, d->textLineHeight(option, widget)); } break; case CT_CheckBox: case CT_RadioButton: return ParentStyle::sizeFromContents(type, option, contentsSize, widget) + QSize(0, 2 * d->widgetSize - 4); break; case CT_ToolButton: if (option && option->type == QStyleOption::SO_ToolButton) { return sizeFromContentsToolButton((const QStyleOptionToolButton *) option, contentsSize, widget, this, d->toolButtonSize); } break; case CT_ComboBox: if (option && option->type == QStyleOption::SO_ComboBox) { return sizeFromContentsComboBox((const QStyleOptionComboBox *) option, contentsSize, widget, this, d->widgetSize, d->textLineHeight(option, widget)); } break; case CT_Splitter: case CT_Q3DockWindow: return contentsSize; case CT_ProgressBar: if (option && option->type == QStyleOption::SO_ProgressBar) { return sizeFromContentsProgressBar((const QStyleOptionProgressBar *) option, contentsSize, widget, this, d->widgetSize, d->verticalTextShift(styledFontMetrics(option, widget))); } break; case CT_MenuItem: if (option && option->type == QStyleOption::SO_MenuItem) { return sizeFromContentsMenuItem((const QStyleOptionMenuItem *) option, contentsSize, widget, this, 2 * d->menuItemSize, d->textLineHeight(option, widget)); } break; case CT_MenuBarItem: { int h = 2 * (d->menuBarSize >= 0 ? d->menuBarSize : 3) + d->textLineHeight(option, widget); return QSize(contentsSize.width() + 2 + (((fontHeight(option, widget) * 7) >> 3) & ~1), h).expandedTo(qApp->globalStrut()); } case CT_MenuBar: return contentsSize; case CT_Menu: return contentsSize; case CT_TabBarTab: if (option && option->type == QStyleOption::SO_Tab) { return sizeFromContentsTabBarTab((const QStyleOptionTab *) option, contentsSize, widget, this, d->tabBarSize, d->verticalTextShift(styledFontMetrics(option, widget))); } break; case CT_Slider: case CT_ScrollBar: case CT_Q3Header: return contentsSize; case CT_LineEdit: if (option && option->type == QStyleOption::SO_Frame) { return sizeFromContentsLineEdit((const QStyleOptionFrame *) option, contentsSize, widget, this, d->widgetSize, d->textLineHeight(option, widget)); } break; CT_CASE(SpinBox, SpinBox); case CT_SizeGrip: return contentsSize; case CT_TabWidget: return contentsSize + QSize(4, 4); case CT_DialogButtons: return contentsSize; case CT_HeaderSection: break; //#if (QT_VERSION >= QT_VERSION_CHECK(4, 1, 0)) CT_CASE(GroupBox, GroupBox); //#endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) case CT_MdiControls: break; #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) case CT_ItemViewItem: break; #endif case CT_CustomBase: // avoid warning break; } return ParentStyle::sizeFromContents(type, option, contentsSize, widget); } /*-----------------------------------------------------------------------*/ extern QRect subElementRectDockWidget(QStyle::SubElement element, const QStyleOptionDockWidget *option, const QWidget *widget, const QStyle *style); extern QRect subElementRectComboBoxFocusRect(const QStyleOptionComboBox *option, const QWidget *widget, const QStyle *style); /*-----------------------------------------------------------------------*/ #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) static inline QRect subElementRectFrameContents(const QStyleOption *option, const QWidget *widget, const QStyle *style) { Q_UNUSED(style); if (widget && widget->inherits("KHTMLView")) { QWidget *window; // case 1: the parent widget is a QFrame, and already has a sunken frame // do not show any frame (KMail mail view, Kopete chat view) if (QFrame *frame = qobject_cast(widget->parentWidget())) { if (frame->frameShape() == QFrame::StyledPanel) { // ### fix Kopete frame // frame->setFrameShadow(QFrame::Sunken); return option->rect; } } else if ((window = widget->window()) && window->inherits("KonqMainWindow")) { // case 2: the html view covers the full width of window: // do not show side frames (Konqueror) return option->rect.adjusted(0, 2, 0, -2); } else { // case 3: detect KMail 4.2 while ((widget = widget->parentWidget())) { if (widget->inherits("KMReaderWin")) { return option->rect; } } } } return option->rect.adjusted(2, 2, -2, -2); } static inline QRect subElementRectLineEditContents(const QStyleOptionFrame *option, const QWidget *widget, const QStyle *style, int textShift) { Q_UNUSED(widget); Q_UNUSED(style); int fw = option->lineWidth; int adjust = 0; /// TODO replace with runtime version check #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 1)) if (textShift & 1) { adjust = -1; textShift &= ~1; } #else // ### can the 4.6.1 code be used on < 4.6.1 ??? if (textShift & 1 && !(option->rect.height() & 1)) { textShift += 1; } #endif return option->rect.adjusted(fw + 2, fw + ((-textShift) >> 1), -fw - 2, -fw + ((-textShift) >> 1) + adjust); } #endif /*-----------------------------------------------------------------------*/ QRect SkulptureStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const { switch (element) { case SE_PushButtonContents: case SE_PushButtonFocusRect: case SE_CheckBoxIndicator: case SE_CheckBoxContents: case SE_CheckBoxFocusRect: case SE_CheckBoxClickRect: case SE_RadioButtonIndicator: case SE_RadioButtonContents: case SE_RadioButtonFocusRect: case SE_RadioButtonClickRect: break; case SE_ComboBoxFocusRect: if (option->type == QStyleOption::SO_ComboBox) { return subElementRectComboBoxFocusRect((const QStyleOptionComboBox *) option, widget, this); } break; case SE_SliderFocusRect: case SE_Q3DockWindowHandleRect: break; case SE_ProgressBarGroove: case SE_ProgressBarContents: case SE_ProgressBarLabel: return option->rect; case SE_DialogButtonAccept: case SE_DialogButtonReject: case SE_DialogButtonApply: case SE_DialogButtonHelp: case SE_DialogButtonAll: case SE_DialogButtonAbort: case SE_DialogButtonIgnore: case SE_DialogButtonRetry: case SE_DialogButtonCustom: break; case SE_ToolBoxTabContents: return option->rect.adjusted(11, 0, -6, 0); case SE_HeaderLabel: case SE_HeaderArrow: break; case SE_TabWidgetTabBar: case SE_TabWidgetTabPane: case SE_TabWidgetTabContents: break; case SE_TabWidgetLeftCorner: case SE_TabWidgetRightCorner: if (option->type == QStyleOption::SO_TabWidgetFrame) { if (((const QStyleOptionTabWidgetFrame *) option)->lineWidth == 0) { break; } if ((((const QStyleOptionTabWidgetFrame *) option)->shape & 3) == 1) { return QCommonStyle::subElementRect(element, option, widget).adjusted(1, -1, -1, -1); } } return QCommonStyle::subElementRect(element, option, widget).adjusted(1, 1, -1, 1); #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) case SE_ItemViewItemCheckIndicator: #else case SE_ViewItemCheckIndicator: #endif break; case SE_TabBarTearIndicator: case SE_TreeViewDisclosureItem: break; #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) case SE_LineEditContents: if (option->type == QStyleOption::SO_Frame) { return subElementRectLineEditContents((const QStyleOptionFrame *) option, widget, this, d->textShift); } break; case SE_FrameContents: return subElementRectFrameContents(option, widget, this); #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) case SE_DockWidgetCloseButton: case SE_DockWidgetFloatButton: case SE_DockWidgetTitleBarText: case SE_DockWidgetIcon: if (option->type == QStyleOption::SO_DockWidget) { return subElementRectDockWidget(element, (const QStyleOptionDockWidget *) option, widget, this); } break; case SE_CheckBoxLayoutItem: case SE_ComboBoxLayoutItem: case SE_DateTimeEditLayoutItem: break; case SE_DialogButtonBoxLayoutItem: break; case SE_LabelLayoutItem: case SE_ProgressBarLayoutItem: case SE_PushButtonLayoutItem: case SE_RadioButtonLayoutItem: case SE_SliderLayoutItem: case SE_SpinBoxLayoutItem: case SE_ToolButtonLayoutItem: break; case SE_FrameLayoutItem: case SE_GroupBoxLayoutItem: case SE_TabWidgetLayoutItem: break; #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) case SE_ItemViewItemDecoration: case SE_ItemViewItemText: case SE_ItemViewItemFocusRect: break; #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) case SE_TabBarTabLeftButton: case SE_TabBarTabRightButton: case SE_TabBarTabText: break; case SE_ShapedFrameContents: break; #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) case SE_ToolBarHandle: break; #endif case SE_CustomBase: // avoid warning break; } return ParentStyle::subElementRect(element, option, widget); } /*-----------------------------------------------------------------------*/ #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) void SkulptureStyle::Private::polishFormLayout(QFormLayout *layout) { if (layout->labelAlignment() & Qt::AlignVCenter) { return; } int addedHeight = -1; for (int row = 0; row < layout->rowCount(); ++row) { QLayoutItem *labelItem = layout->itemAt(row, QFormLayout::LabelRole); if (!labelItem) { continue; } QLayoutItem *fieldItem = layout->itemAt(row, QFormLayout::FieldRole); if (!fieldItem) { continue; } QWidget *label = labelItem->widget(); if (!label) { continue; } int labelHeight; if (addedHeight < 0) { #if 0 // fixed value in Qt static const int verticalMargin = 1; QStyleOptionFrame option; option.initFrom(label); option.lineWidth = label->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, label); option.midLineWidth = 0; option.rect = QRect(0, 0, 10, fontHeight(option, label) + 2 * verticalMargin); // label should be aligned centered to LineEdit, so use its size addedHeight = label->style()->sizeFromContents(QStyle::CT_LineEdit, &option, option.rect.size(), label).height() - fontHeight(option, height); #else addedHeight = 4 + 2 * widgetSize; #endif } if (qobject_cast(label)) { labelHeight = label->sizeHint().height() + addedHeight; } else if (qobject_cast(label)) { labelHeight = label->sizeHint().height(); } else { continue; } int fieldHeight = fieldItem->sizeHint().height(); if (runtimeQtVersion() < QT_VERSION_CHECK(4, 6, 0)) { // work around KIntNumInput::sizeHint() bug if (fieldItem->widget() && fieldItem->widget()->inherits("KIntNumInput")) { fieldHeight -= 2; fieldItem->widget()->setMaximumHeight(fieldHeight); } } /* for large fields, we don't center */ if (fieldHeight <= 2 * fontHeight(0, label) + addedHeight) { if (fieldHeight > labelHeight) { labelHeight = fieldHeight; } } else { if (verticalTextShift(label->fontMetrics()) & 1) { labelHeight += 1; } } if (qobject_cast(label)) { label->setMinimumHeight(labelHeight); } else { #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 2)) if (runtimeQtVersion() >= QT_VERSION_CHECK(4, 6, 2)) { label->setMinimumHeight((labelHeight * 4 + 6) / 7); } else { // QFormLayout determines label size as height * 5 / 4, so revert that label->setMinimumHeight((labelHeight * 4 + 4) / 5); } #else label->setMinimumHeight((labelHeight * 4 + 6) / 7); #endif } } } #endif void SkulptureStyle::Private::polishLayout(QLayout *layout) { if (forceSpacingAndMargins) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) if (QFormLayout *formLayout = qobject_cast(layout)) { if (formLayout->spacing() >= 2) { formLayout->setSpacing(-1); } } else #endif if (QGridLayout *gridLayout = qobject_cast(layout)) { if (gridLayout->spacing() >= 2) { gridLayout->setSpacing(-1); } } else if (QBoxLayout *boxLayout = qobject_cast(layout)) { if (boxLayout->spacing() >= 2) { boxLayout->setSpacing(-1); } } else { if (layout->spacing() >= 2) { layout->setSpacing(-1); } } if (layout->margin() >= 4) { layout->setMargin(-1); } } #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) if (QFormLayout *formLayout = qobject_cast(layout)) { polishFormLayout(formLayout); } #endif // recurse into layouts for (int i = 0; i < layout->count(); ++i) { QLayoutItem *item = layout->itemAt(i); if (QLayout *layout = item->layout()) { polishLayout(layout); } } } /* * skulpture_mdi.cpp * */ #include "skulpture_p.h" #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) #include #endif #include #include /*-----------------------------------------------------------------------*/ QRect subControlRectTitleBar(const QStyleOptionTitleBar *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { QRect r = ((const QCommonStyle *) style)->QCommonStyle::subControlRect(QStyle::CC_TitleBar, option, subControl, widget); if (subControl != QStyle::SC_TitleBarSysMenu) { return r.adjusted(option->direction == Qt::LeftToRight ? -2 : 2, -2, option->direction == Qt::LeftToRight ? -3 : 3, -3); } else { return r.adjusted(0, -1, 0, -1); } } /*-----------------------------------------------------------------------*/ void paintFrameWindow(QPainter *painter, const QStyleOptionFrame *option) { // painter->fillRect(option->rect, option->palette.color(QPalette::Window)); #if 0 paintThinFrame(painter, option->rect.adjusted(0, 0, 0, 0), option->palette, -60, 160); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -20, 60); #else paintThinFrame(painter, option->rect.adjusted(0, 0, 0, 0), option->palette, -90, 355); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -40, 100); #endif // paintThinFrame(painter, option->rect.adjusted(4, 7 + option->fontMetrics.height(), -4, -4), option->palette, 60, -20); #if 0 painter->setPen(Qt::red); painter->setBrush(Qt::NoBrush); painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); #endif } static void getTitleBarPalette(QPalette &palette) { QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); if (settings.contains(QLatin1String("KWinPalette/activeBackground"))) { palette.setColor(QPalette::Window, QColor(settings.value(QLatin1String("KWinPalette/inactiveBackground")).toString())); palette.setColor(QPalette::WindowText, QColor(settings.value(QLatin1String("KWinPalette/inactiveForeground")).toString())); palette.setColor(QPalette::Highlight, QColor(settings.value(QLatin1String("KWinPalette/activeBackground")).toString())); palette.setColor(QPalette::HighlightedText, QColor(settings.value(QLatin1String("KWinPalette/activeForeground")).toString())); } else { palette.setColor(QPalette::Window, QColor(0, 0, 0, 20)); palette.setColor(QPalette::WindowText, QColor(0, 0, 0, 255)); QColor barColor = palette.color(QPalette::Highlight); barColor.setHsvF(barColor.hueF(), barColor.saturationF() * 0.9, 0.25); palette.setColor(QPalette::Highlight, barColor); palette.setColor(QPalette::HighlightedText, QColor(255, 255, 255, 240)); } } void paintTitleBar(QPainter *painter, const QStyleOptionTitleBar *option, const QWidget *widget, const QStyle *style) { QColor barColor; QColor textColor; painter->save(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) qreal opacity = painter->opacity(); #endif QPalette palette = option->palette; #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (qobject_cast(widget)) { if (widget->objectName() != QLatin1String("SkulpturePreviewWindow")) { getTitleBarPalette(palette); } } #endif if (option->state & QStyle::State_Active) { barColor = palette.color(QPalette::Highlight); textColor = palette.color(QPalette::HighlightedText); } else { barColor = palette.color(QPalette::Window); textColor = palette.color(QPalette::WindowText); } QLinearGradient barGradient(option->rect.topLeft() + QPoint(-1, -1), option->rect.bottomLeft() + QPoint(-1, -2)); // barGradient.setColorAt(0.0, option->palette.color(QPalette::Window)); // barGradient.setColorAt(0.3, barColor); // barGradient.setColorAt(0.7, barColor); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) barGradient.setColorAt(0.0, barColor.darker(105)); barGradient.setColorAt(1.0, barColor.lighter(120)); #else barGradient.setColorAt(0.0, barColor.dark(105)); barGradient.setColorAt(1.0, barColor.light(120)); #endif // barGradient.setColorAt(1.0, option->palette.color(QPalette::Window)); // painter->fillRect(option->rect.adjusted(-1, -1, 1, -2), barGradient); // painter->fillRect(option->rect.adjusted(-1, -1, 1, -2), barColor); #if 1 { QRect r = option->rect.adjusted(-4, -7, 4, 0); QRect lr = r.adjusted(6, 2, -6/* - 55*/, -1); // QRect lr = r.adjusted(6, 2, -70, -1); if (true || option->state & QStyle::State_Active) { painter->fillRect(lr, barColor); } QStyleOptionTitleBar buttons = *option; // buttons.subControls &= ~QStyle::SC_TitleBarLabel; buttons.subControls = QStyle::SC_TitleBarSysMenu; buttons.rect.adjust(3, -2, -4, -1); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) painter->setOpacity(option->state & QStyle::State_Active ? opacity : 0.7 * opacity); #endif ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_TitleBar, &buttons, painter, widget); buttons = *option; #if 0 buttons.subControls &= ~(QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu); ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_TitleBar, &buttons, painter, widget); #else QStyleOption opt = *option; QIcon icon; for (int i = 1; i <= 7; ++i) { QStyle::SubControl sc = (QStyle::SubControl) (1 << i); if (option->subControls & sc & ~(QStyle::SC_TitleBarContextHelpButton)) { QRect rect = style->subControlRect(QStyle::CC_TitleBar, option, sc, widget); QIcon::Mode iconMode = QIcon::Normal; if (option->activeSubControls & sc) { iconMode = QIcon::Active; } opt.palette.setColor(QPalette::Text, textColor); icon = style->standardIcon((QStyle::StandardPixmap)(QStyle::SP_TitleBarMenuButton + i), &opt, widget); icon.paint(painter, rect, Qt::AlignCenter, iconMode); } } #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) painter->setOpacity(opacity); #endif #if 0 QRect buttonRect = option->rect.adjusted(300, 1, -90, -6); paintThinFrame(painter, buttonRect, option->palette, -180, 40); paintThinFrame(painter, buttonRect.adjusted(-1, -1, 1, 1), option->palette, 40, -180); #endif { QLinearGradient labelGradient(lr.topLeft(), lr.bottomLeft()); #if 0 labelGradient.setColorAt(0.0, QColor(0, 0, 0, 50)); labelGradient.setColorAt(0.5, QColor(0, 0, 0, 0)); labelGradient.setColorAt(0.55, QColor(0, 0, 0, 20)); labelGradient.setColorAt(1.0, QColor(0, 0, 0, 0)); #elif 1 labelGradient.setColorAt(0.0, QColor(255, 255, 255, 10)); labelGradient.setColorAt(0.5, QColor(255, 255, 255, 40)); labelGradient.setColorAt(0.55, QColor(255, 255, 255, 0)); labelGradient.setColorAt(1.0, QColor(255, 255, 255, 20)); #else labelGradient.setColorAt(0.0, QColor(0, 0, 0, 30)); labelGradient.setColorAt(1.0, QColor(255, 255, 255, 60)); #endif painter->fillRect(lr, labelGradient); } QLinearGradient barGradient(r.topLeft(), r.bottomLeft()); barGradient.setColorAt(0.0, QColor(255, 255, 255, 200)); barGradient.setColorAt(0.2, QColor(255, 255, 255, 80)); barGradient.setColorAt(0.5, QColor(255, 255, 255, 30)); barGradient.setColorAt(1.0, QColor(255, 255, 255, 0)); painter->fillRect(r, barGradient); #if 0 QRadialGradient dialogGradient2(r.left() + r.width() / 2, r.top(), r.height()); dialogGradient2.setColorAt(0.0, QColor(255, 255, 225, 70)); dialogGradient2.setColorAt(1.0, QColor(0, 0, 0, 0)); painter->save(); painter->translate(r.center()); painter->scale(r.width() / 2.0 / r.height(), 1); painter->translate(-r.center()); painter->fillRect(r.adjusted(1, 1, -1, -1), dialogGradient2); painter->restore(); #endif paintThinFrame(painter, lr, option->palette, -30, 90); paintThinFrame(painter, lr.adjusted(-1, -1, 1, 1), option->palette, 90, -30); } #endif #if 0 // paintThinFrame(painter, option->rect.adjusted(0, 0, 0, -1), option->palette, -30, 80); paintThinFrame(painter, option->rect.adjusted(-1, -1, 1, 0), option->palette, 80, -30); painter->fillRect(option->rect.adjusted(0, 0, 0, -1), barColor); // FIXME: adjust rect for new shadow // paintRecessedFrameShadow(painter, option->rect.adjusted(-1, -1, 1, 0), RF_Large); { QRect labelRect = option->rect.adjusted(20, 0, -250, 0); painter->fillRect(labelRect, option->palette.color(QPalette::Window)); paintThinFrame(painter, labelRect.adjusted(0, 0, 0, 1), option->palette, -30, 80); } #endif if (option->subControls & QStyle::SC_TitleBarLabel) { QRect labelRect; #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (qobject_cast(widget)) { QFont font = painter->font(); font.setBold(true); if (option->direction == Qt::LeftToRight) { labelRect = option->rect.adjusted(option->fontMetrics.height() + 10, -1, -2, -3); } else { labelRect = option->rect.adjusted(1, -1, -option->fontMetrics.height() - 11, -3); } // font.setPointSizeF(10); painter->setFont(font); } else #endif { labelRect = style->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, widget); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) painter->setOpacity(opacity); #endif painter->setPen(QColor(0, 0, 0, 25)); style->drawItemText(painter, labelRect.adjusted(1, 1, 1, 1), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, option->palette, true, option->text, QPalette::NoRole); //painter->drawText(labelRect.adjusted(1, 1, 1, 1), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, option->text); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) painter->setOpacity(option->state & QStyle::State_Active ? opacity : 0.7 * opacity); #endif painter->setPen(textColor); style->drawItemText(painter, labelRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, option->palette, true, option->text, QPalette::NoRole); //painter->drawText(labelRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, option->text); } /* if (!option->icon.isNull()) { labelRect.setWidth(16); labelRect.setHeight(16); painter->drawPixmap(labelRect.adjusted(0, -1, 0, -1), option->icon.pixmap(QSize(16, 16))); } */ painter->restore(); } int getWindowFrameMask(QStyleHintReturnMask *mask, const QStyleOptionTitleBar *option, const QWidget *widget) { Q_UNUSED(widget); mask->region = option->rect; // TODO get total dimensions of workspace and don't use masks on corners /*if (option->rect.topLeft() != QPoint(0, 0))*/ { // mask->region -= QRect(option->rect.topLeft(), QSize(1, 1)); } // mask->region -= QRect(option->rect.topRight(), QSize(1, 1)); // mask->region -= QRect(option->rect.bottomLeft(), QSize(1, 1)); // mask->region -= QRect(option->rect.bottomRight(), QSize(1, 1)); // try new style // mask->region -= QRect(option->rect.topLeft(), QSize(6, 1)); // mask->region -= QRect(option->rect.topRight() - QPoint(5, 0), QSize(6, 1)); return 1; } /* * skulpture_menu.cpp * */ #include "skulpture_p.h" #include #include #include #include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) #include #endif /*-----------------------------------------------------------------------*/ void paintFrameMenu(QPainter *painter, const QStyleOptionFrame *option) { paintThinFrame(painter, option->rect, option->palette, -60, 160); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -20, 60); } void paintPanelMenuBar(QPainter *painter, const QStyleOptionFrame *option) { Q_UNUSED(painter); Q_UNUSED(option); // paintThinFrame(painter, option->rect, option->palette, -20, 60); // painter->fillRect(option->rect.adjusted(1, 1, -1, -1), option->palette.color(QPalette::Window)); } void paintMenuBarEmptyArea(QPainter *painter, const QStyleOption *option) { Q_UNUSED(painter); Q_UNUSED(option); // painter->fillRect(option->rect, option->palette.color(QPalette::Window)); } /*-----------------------------------------------------------------------*/ extern void paintCommandButtonPanel(QPainter *painter, const QStyleOptionButton *option, const QWidget *widget); void paintMenuBarItem(QPainter *painter, const QStyleOptionMenuItem *option, const QWidget *widget, const QStyle *style) { QStyleOptionMenuItem opt = *option; if (option->state & QStyle::State_Selected || option->state & QStyle::State_MouseOver) { QStyleOptionButton button; button.QStyleOption::operator=(*option); button.features = QStyleOptionButton::None; button.state |= QStyle::State_MouseOver; painter->save(); painter->setClipRect(button.rect.adjusted(1, 1, -1, -1)); // call without widget to get QPalette::Button background paintCommandButtonPanel(painter, &button, 0); painter->restore(); } else { opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::WindowText)); } opt.state &= ~QStyle::State_Sunken; ((QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_MenuBarItem, &opt, painter, widget); } /*-----------------------------------------------------------------------*/ enum MenuMode { ButtonMenu, ItemViewMenu, }; enum CheckColumnMode { UseIconColumn, ShowCheckColumn, NoCheckColumn }; enum IconColumnMode { ForceIconColumn, ShowIconColumn, HideIconColumn }; enum SeparatorMode { TextSeparator, IconSeparator, ItemSeparator }; enum SelectionMode { TextSelection, IconSelection, ItemSelection }; /*-----------------------------------------------------------------------*/ QSize sizeFromContentsMenuItem(const QStyleOptionMenuItem *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int menuItemSize, int textLineHeight) { if (option->menuItemType == QStyleOptionMenuItem::Separator) { if (option->text.isEmpty()) { return QSize(4, 4); } // ### width? return QSize(4, QFontMetrics(option->font).height() + 8); } int w = contentsSize.width(), h = contentsSize.height(); // always make room for icon column const int iconMargin = 4; int iconWidth; if (option->maxIconWidth) { iconWidth = option->maxIconWidth - 4 + 2 * iconMargin; } else { iconWidth = style->pixelMetric(QStyle::PM_SmallIconSize, option, widget) + 2 * iconMargin; } w += iconWidth; // add size for check column const int checkMargin = 4; if (option->checkType != QStyleOptionMenuItem::NotCheckable) { w += style->pixelMetric(QStyle::PM_IndicatorWidth, option, widget) + checkMargin; } // submenu arrow and spacing w += option->fontMetrics.height() + 4; if (option->menuItemType == QStyleOptionMenuItem::SubMenu || option->text.indexOf(QChar('\t', 0)) >= 0) { w += option->fontMetrics.height(); } if (h < textLineHeight) { h = textLineHeight; } h += menuItemSize; return QSize(w, qMax(h, qApp->globalStrut().height())); } /*-----------------------------------------------------------------------*/ inline QRect remainingHorizontalVisualRect(const QRect &rect, const QStyleOption *option, int width) { return rect.adjusted(option->direction == Qt::LeftToRight ? width : 0, 0, option->direction != Qt::LeftToRight ? -width : 0, 0); } inline QRect horizontalVisualRect(const QRect &rect, const QStyleOption *option, int width) { QRect res = rect; if (option->direction != Qt::LeftToRight) { res.setLeft(rect.left() + rect.width() - width); } else { res.setWidth(width); } return res; } inline QRect rightHorizontalVisualRect(const QRect &rect, const QStyleOption *option, int width) { QRect res = rect; if (option->direction != Qt::LeftToRight) { res.setWidth(width); } else { res.setLeft(rect.left() + rect.width() - width); } return res; } /*-----------------------------------------------------------------------*/ void paintMenuItem(QPainter *painter, const QStyleOptionMenuItem *option, const QWidget *widget, const QStyle *style) { // configuration const MenuMode menuMode = ButtonMenu; const CheckColumnMode checkColumnMode = option->maxIconWidth ? (/*option->menuHasCheckableItems ? UseIconColumn :*/ NoCheckColumn) : NoCheckColumn; const bool showUncheckedIndicator = true; const bool showShortcut = true; const IconColumnMode iconColumnMode = checkColumnMode == UseIconColumn && option->menuHasCheckableItems ? ForceIconColumn : option->maxIconWidth ? ShowIconColumn : ShowIconColumn; const SeparatorMode separatorMode = TextSeparator; const SelectionMode selectionMode = ItemSelection; // layout // ### make margins configurable const int checkMargin = 4; const int iconMargin = 4; const int checkSize = option->menuHasCheckableItems ? qMax(style->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, option, widget), style->pixelMetric(QStyle::PM_IndicatorWidth, option, widget)) : 0; const int iconSize = style->pixelMetric(QStyle::PM_SmallIconSize, option, widget); const int checkColumnWidth = checkSize + 2 * checkMargin; // FIXME qMax(checkSize, iconSize) for useIconColum const int iconColumnWidth = iconColumnMode == HideIconColumn ? 0 : option->maxIconWidth ? option->maxIconWidth - 4 + 2 * iconMargin : iconSize + 2 * iconMargin; #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) // Qt 4.x has a bug where the option->rect is one pixel too wide const QRect itemRect = runtimeQtVersion() < QT_VERSION_CHECK(4, 6, 0) ? option->rect.adjusted(0, 0, -1, 0) : option->rect; #else const QRect itemRect = option->rect; #endif QRect iconRect = horizontalVisualRect(itemRect, option, iconColumnWidth); QRect textRect = remainingHorizontalVisualRect(itemRect, option, iconColumnWidth); // background color QPalette::ColorRole menuBackgroundRole; QPalette::ColorRole menuForegroundRole; QBrush menuBackground; QBrush iconBackground; switch (menuMode) { case ButtonMenu: menuBackgroundRole = QPalette::Window; menuForegroundRole = QPalette::WindowText; iconBackground = QColor(0, 0, 0, 10); break; case ItemViewMenu: menuBackgroundRole = QPalette::Base; menuForegroundRole = QPalette::Text; iconBackground = option->palette.brush(QPalette::Active, QPalette::Window); break; } // background menuBackground = option->palette.brush(QPalette::Active, menuBackgroundRole); painter->fillRect(textRect, menuBackground); if (!iconRect.isEmpty()) { if (!iconBackground.isOpaque()) { painter->fillRect(iconRect, menuBackground); } } painter->fillRect(iconRect, iconBackground); // painter->fillRect(iconRect.adjusted(2, 2, -2, -2), QColor(0, 255, 0, 120)); // separator if (option->menuItemType == QStyleOptionMenuItem::Separator) { QRect separatorRect; switch (separatorMode) { case IconSeparator: separatorRect = iconRect; break; case TextSeparator: separatorRect = textRect; break; case ItemSeparator: separatorRect = itemRect; break; } // ### make separator margins configurable separatorRect.adjust(0, 1, 0, -1); if (option->text.isEmpty()) { paintThinFrame(painter, separatorRect, option->palette, 60, -20); } else { const int textFlags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip | Qt::TextSingleLine; QColor bgcolor = menuBackground.color(); paintThinFrame(painter, separatorRect, option->palette, -10, -20); paintThinFrame(painter, separatorRect.adjusted(1, 1, -1, -1), option->palette, -30, 80, menuBackgroundRole); QLinearGradient gradient(separatorRect.topLeft(), separatorRect.bottomLeft()); gradient.setColorAt(0.0, shaded_color(bgcolor, 90)); gradient.setColorAt(0.2, shaded_color(bgcolor, 60)); gradient.setColorAt(0.5, shaded_color(bgcolor, 0)); gradient.setColorAt(0.51, shaded_color(bgcolor, -10)); gradient.setColorAt(1.0, shaded_color(bgcolor, -20)); painter->fillRect(separatorRect.adjusted(1, 1, -1, -1), gradient); // ### margins separatorRect = remainingHorizontalVisualRect(separatorRect, option, 8); style->drawItemText(painter, separatorRect, textFlags, option->palette, true, option->text, menuForegroundRole); } return; } // selection background painter->save(); if (option->state & QStyle::State_Selected) { QRect selectionRect; switch (selectionMode) { case IconSelection: selectionRect = iconRect; break; case TextSelection: selectionRect = textRect; break; case ItemSelection: selectionRect = itemRect; break; } switch (menuMode) { case ButtonMenu: { QStyleOptionButton button; button.QStyleOption::operator=(*option); button.features = QStyleOptionButton::None; button.state |= QStyle::State_MouseOver; button.rect = selectionRect.adjusted(-1, -1, 1, 1); paintCommandButtonPanel(painter, &button, 0); menuForegroundRole = QPalette::ButtonText; break; } case ItemViewMenu: { QColor color = option->palette.color(QPalette::Active, QPalette::Highlight); color.setAlpha(option->state & QStyle::State_Enabled ? 180 : 40); painter->fillRect(selectionRect, color); if (option->state & QStyle::State_Enabled) { paintThinFrame(painter, selectionRect, option->palette, -20, -20); } menuForegroundRole = QPalette::HighlightedText; break; } } painter->setPen(option->palette.color(QPalette::Active, menuForegroundRole)); } // arrow if (option->menuItemType == QStyleOptionMenuItem::SubMenu) { const int arrowWidth = option->fontMetrics.height(); const QRect arrowRect = rightHorizontalVisualRect(textRect, option, arrowWidth); QStyleOptionMenuItem opt = *option; opt.rect = arrowRect; QFont font = painter->font(); font.setPointSizeF(font.pointSizeF() / 1.19); opt.fontMetrics = QFontMetrics(font); opt.state &= QStyle::State_Enabled; opt.palette.setColor(QPalette::ButtonText, option->palette.color(option->state & QStyle::State_Enabled ? QPalette::Active : QPalette::Disabled, menuForegroundRole)); style->drawPrimitive((option->direction == Qt::RightToLeft) ? QStyle::PE_IndicatorArrowLeft : QStyle::PE_IndicatorArrowRight, &opt, painter, widget); } // check if (option->checkType != QStyleOptionMenuItem::NotCheckable) { QRect checkRect; switch (checkColumnMode) { case UseIconColumn: checkRect = iconRect; if (option->checked) { // when using the icon colum, we do not show an icon for checked items iconRect = QRect(); } break; case NoCheckColumn: case ShowCheckColumn: checkRect = horizontalVisualRect(textRect, option, checkColumnWidth); textRect = remainingHorizontalVisualRect(textRect, option, checkColumnWidth - checkMargin); break; } // painter->fillRect(checkRect.adjusted(2, 2, -2, -2), QColor(0, 0, 255, 120)); if (option->checked || option->state & QStyle::State_Selected || (showUncheckedIndicator && option->checkType == QStyleOptionMenuItem::NonExclusive)) { QStyleOptionMenuItem opt = *option; opt.rect = checkRect; style->drawPrimitive(QStyle::PE_IndicatorMenuCheckMark, &opt, painter, widget); } } else if (checkColumnMode == ShowCheckColumn) { textRect = remainingHorizontalVisualRect(textRect, option, checkColumnWidth - checkMargin); } // painter->fillRect(textRect.adjusted(2, 2, -2, -2), QColor(255, 0, 0, 120)); // text if (!option->text.isEmpty()) { const int shortcutPos = option->text.indexOf(QChar('\t', 0)); int textFlags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!style->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) { textFlags |= Qt::TextHideMnemonic; } if (showShortcut && shortcutPos >= 0) { const int shortcutWidth = option->tabWidth + option->fontMetrics.height() - 2; const QRect shortcutRect = rightHorizontalVisualRect(textRect, option, shortcutWidth); // painter->fillRect(shortcutRect, QColor(255, 220, 0, 120)); style->drawItemText(painter, shortcutRect, textFlags, option->palette, option->state & QStyle::State_Enabled, option->text.mid(shortcutPos + 1), menuForegroundRole); } QFont font = option->font; if (option->menuItemType == QStyleOptionMenuItem::DefaultItem) { font.setBold(true); } painter->setFont(font); // ### textMargin textRect = remainingHorizontalVisualRect(textRect, option, 4); style->drawItemText(painter, textRect, textFlags, option->palette, option->state & QStyle::State_Enabled, option->text.left(shortcutPos), menuForegroundRole); } // icon if (iconColumnMode != HideIconColumn && !option->icon.isNull() && !iconRect.isEmpty()) { QIcon::Mode mode; if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Selected) { mode = QIcon::Active; } else { mode = QIcon::Normal; } } else { mode = QIcon::Disabled; } iconRect = QRect((iconRect.left() + iconRect.right() + 2 - iconSize) >> 1, (iconRect.top() + iconRect.bottom() + 2 - iconSize) >> 1, iconSize, iconSize); option->icon.paint(painter, iconRect, Qt::AlignCenter, mode, QIcon::Off); } painter->restore(); } /*-----------------------------------------------------------------------*/ void paintMenuTitle(QPainter *painter, const QStyleOptionToolButton *option, const QWidget *widget, const QStyle *style) { const QPalette::ColorRole bgrole = QPalette::Window; QColor bgcolor = option->palette.color(bgrole); QStyleOptionToolButton opt = *option; opt.state &= ~(QStyle::State_Sunken | QStyle::State_On | QStyle::State_Selected | QStyle::State_HasFocus); #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) if (runtimeQtVersion() < QT_VERSION_CHECK(4, 6, 0)) { // Qt 4.x has a bug where the option->rect is one pixel too wide opt.rect.adjust(0, 0, -1, 0); } #endif opt.palette.setColor(QPalette::ButtonText, option->palette.color(QPalette::WindowText)); paintThinFrame(painter, opt.rect, option->palette, -10, -20); paintThinFrame(painter, opt.rect.adjusted(1, 1, -1, -1), opt.palette, -30, 80, bgrole); QLinearGradient gradient(opt.rect.topLeft(), opt.rect.bottomLeft()); gradient.setColorAt(0.0, shaded_color(bgcolor, 90)); gradient.setColorAt(0.2, shaded_color(bgcolor, 60)); gradient.setColorAt(0.5, shaded_color(bgcolor, 0)); gradient.setColorAt(0.51, shaded_color(bgcolor, -10)); gradient.setColorAt(1.0, shaded_color(bgcolor, -20)); painter->fillRect(opt.rect.adjusted(1, 1, -1, -1), gradient); ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_ToolButton, &opt, painter, widget); } /*-----------------------------------------------------------------------*/ #if (QT_VERSION < QT_VERSION_CHECK(4, 6, 0)) bool SkulptureStyle::Private::menuEventFilter(QMenu *menu, QEvent *event) { QHash::iterator i = menuHash.begin(); while (i != menuHash.end()) { if (!i->menu) { i = menuHash.erase(i); } else { ++i; } } i = menuHash.find(menu); MenuInfo *menuInfo = i != menuHash.end() ? &(*i) : 0; if (event->type() == QEvent::Hide || event->type() == QEvent::Destroy) { if (menuInfo) { menuHash.erase(i); } menuInfo = 0; } else { QPoint eventPos; bool moveEvent = false; if (event->type() == QEvent::TabletMove) { QTabletEvent *tabletEvent = (QTabletEvent *) event; eventPos = tabletEvent->pos(); moveEvent = true; } else if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = (QMouseEvent *) event; eventPos = mouseEvent->pos(); moveEvent = true; } QAction *menuAction = 0; QAction *action = 0; if (moveEvent && menu->rect().contains(eventPos)) { action = menu->actionAt(eventPos); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) if (QWidgetAction * widgetAction = qobject_cast(action)) { if (!widgetAction->defaultWidget()) { if (action->menu()) { menuAction = action; } } } else #endif if (action && action->menu()) { menuAction = action; } } if (menuAction && !menuInfo) { MenuInfo info; info.menu = menu; info.delayTimer = 0; info.lastPos = eventPos; info.eventCount = 0; i = menuHash.insert(menu, info); menuInfo = &(*i); } if (menuInfo) { if (event->type() == QEvent::Enter) { menuInfo->lastSubMenuAction = 0; menuInfo->eventCount = 0; } else if (event->type() == QEvent::Leave) { menuInfo->lastSubMenuAction = 0; menuInfo->eventCount = 0; } else if (moveEvent) { if (action != menuAction) { menuInfo->lastSubMenuAction = 0; menuInfo->eventCount = 0; } if (menu->rect().contains(eventPos)) { if (menuAction) { QAction *last = menuInfo->lastSubMenuAction; menuInfo->lastSubMenuAction = menuAction; if (last && last == menuAction) { if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = (QMouseEvent *) event; ++menuInfo->eventCount; if (menuInfo->eventCount > 2 && mouseEvent->buttons() == Qt::NoButton) { event->accept(); return true; } } } else { menuInfo->eventCount = 0; } } } else { menuInfo->lastSubMenuAction = 0; menuInfo->eventCount = 0; } } } } return false; } #endif /* * skulpture_misc.cpp * */ #include "skulpture_p.h" #include #include /*-----------------------------------------------------------------------*/ extern void paintPanelButtonTool(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style); #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) #if 0 void paintPanelPlacesViewItem(QPainter *painter, const QStyleOptionViewItemV4 *option, const QWidget *widget, const QStyle *style) { QStyleOption opt = *option; if (opt.state & QStyle::State_Selected) { opt.state |= QStyle::State_On; } else if (!(opt.state & QStyle::State_MouseOver)) { // draw nothing return; } paintPanelButtonTool(painter, &opt, 0, style); } #endif void paintPanelItemViewItem(QPainter *painter, const QStyleOptionViewItemV4 *option, const QWidget *widget, const QStyle *style) { Q_UNUSED(style); #if 0 if (widget && widget->inherits("KFilePlacesView")) { paintPanelPlacesViewItem(painter, option, widget, style); return; } #endif QColor color = option->palette.color(QPalette::Highlight); const bool mouse = option->state & QStyle::State_MouseOver && option->state & QStyle::State_Enabled; const QTableView *table = qobject_cast(widget); const bool largePanel = option->rect.height() > 7 + option->fontMetrics.height() && !table; QRect panelRect; if (largePanel) { if (option->version >= 4) { switch (option->viewItemPosition) { case QStyleOptionViewItemV4::Beginning: panelRect = option->rect.adjusted(1, 1, 0, 0); break; case QStyleOptionViewItemV4::End: panelRect = option->rect.adjusted(0, 1, -1, 0); break; case QStyleOptionViewItemV4::Middle: panelRect = option->rect.adjusted(0, 1, 0, 0); break; case QStyleOptionViewItemV4::Invalid: case QStyleOptionViewItemV4::OnlyOne: panelRect = option->rect.adjusted(1, 1, -1, 0); break; } } else { panelRect = option->rect.adjusted(1, 1, -1, 0); } } else { panelRect = option->rect; } if (option->version >= 2 && option->features & QStyleOptionViewItemV2::Alternate) { painter->fillRect(panelRect, option->palette.color(QPalette::AlternateBase)); } else { painter->fillRect(panelRect, option->backgroundBrush); } if (option->state & QStyle::State_Selected) { if (mouse) { color = color.lighter(110); } } else if (mouse) { color.setAlpha(40); } else { return; } painter->save(); // ### work around KDE widgets that turn on antialiasing painter->setRenderHint(QPainter::Antialiasing, false); painter->setBrush(Qt::NoBrush); // QColor shine(255, 255, 255, panelRect.height() > 20 ? 25 : 10); QColor shadow(0, 0, 0, largePanel ? 50 : 20); painter->setPen(shadow); // painter->setPen(QPen(color.darker(panelRect.height() > 20 ? 150 : 120), 1)); painter->fillRect(panelRect, color); if (table && table->showGrid()) { painter->restore(); return; } if (option->version >= 4) { switch (option->viewItemPosition) { case QStyleOptionViewItemV4::Beginning: painter->drawLine(panelRect.topLeft() + QPoint(0, 1), panelRect.bottomLeft() - QPoint(0, 1)); painter->drawLine(panelRect.topLeft(), panelRect.topRight()); painter->drawLine(panelRect.bottomLeft(), panelRect.bottomRight()); break; case QStyleOptionViewItemV4::End: painter->drawLine(panelRect.topRight() + QPoint(0, 1), panelRect.bottomRight() - QPoint(0, 1)); painter->drawLine(panelRect.topLeft(), panelRect.topRight()); painter->drawLine(panelRect.bottomLeft(), panelRect.bottomRight()); break; case QStyleOptionViewItemV4::Middle: painter->drawLine(panelRect.topLeft(), panelRect.topRight()); painter->drawLine(panelRect.bottomLeft(), panelRect.bottomRight()); break; case QStyleOptionViewItemV4::Invalid: case QStyleOptionViewItemV4::OnlyOne: painter->drawRect(panelRect.adjusted(0, 0, -1, -1)); break; } } else { painter->drawRect(panelRect.adjusted(0, 0, -1, -1)); } painter->restore(); } #endif /*-----------------------------------------------------------------------*/ extern void paintCachedIndicatorBranchChildren(QPainter *painter, const QStyleOption *option); void paintIndicatorBranch(QPainter *painter, const QStyleOption *option) { QPoint center = option->rect.center() + (option->direction == Qt::LeftToRight ? QPoint(2, 0) : QPoint(-1, 0)); if (option->state & (QStyle::State_Item | QStyle::State_Sibling)) { QColor lineColor = option->palette.color(QPalette::Text); lineColor.setAlpha(50); painter->fillRect(QRect(center.x(), option->rect.y(), 1, center.y() - option->rect.y()), lineColor); if (option->state & QStyle::State_Sibling) { painter->fillRect(QRect(center.x(), center.y(), 1, option->rect.bottom() - center.y() + 1), lineColor); } if (option->state & QStyle::State_Item) { if (option->direction == Qt::LeftToRight) { painter->fillRect(QRect(center.x() + 1, center.y(), option->rect.right() - center.x(), 1), lineColor); } else { painter->fillRect(QRect(option->rect.left(), center.y(), center.x() - option->rect.left(), 1), lineColor); } if (!(option->state & QStyle::State_Sibling)) { lineColor.setAlpha(25); painter->fillRect(QRect(center.x(), center.y(), 1, 1), lineColor); } } } if (option->state & QStyle::State_Children && !(option->state & QStyle::State_Open)) { QStyleOption opt = *option; static const int d = 9; opt.rect = QRect(center.x() - d / 2, center.y() - d / 2, d, d); paintCachedIndicatorBranchChildren(painter, &opt); } } /*-----------------------------------------------------------------------*/ void paintQ3ListView(QPainter *painter, const QStyleOptionQ3ListView *option, const QWidget *widget, const QStyle *style) { Q_UNUSED(widget); Q_UNUSED(style); if (option->subControls & QStyle::SC_Q3ListView) { painter->fillRect(option->rect, option->viewportPalette.brush(option->viewportBGRole)); } if (option->subControls & QStyle::SC_Q3ListViewBranch) { QStyleOption opt = *((QStyleOption *) option); int y = option->rect.y(); for (int i = 1; i < option->items.size(); ++i) { QStyleOptionQ3ListViewItem item = option->items.at(i); if (y + item.totalHeight > 0 && y < option->rect.height()) { opt.state = QStyle::State_Item; if (i + 1 < option->items.size()) { opt.state |= QStyle::State_Sibling; } if (item.features & QStyleOptionQ3ListViewItem::Expandable || (item.childCount > 0 && item.height > 0)) { opt.state |= QStyle::State_Children | (item.state & QStyle::State_Open); } opt.rect = QRect(option->rect.left(), y, option->rect.width(), item.height); paintIndicatorBranch(painter, &opt); if (opt.state & QStyle::State_Sibling && item.height < item.totalHeight) { opt.state = QStyle::State_Sibling; opt.rect = QRect(option->rect.left(), y + item.height, option->rect.width(), item.totalHeight - item.height); paintIndicatorBranch(painter, &opt); } } y += item.totalHeight; } } } /*-----------------------------------------------------------------------*/ void paintSizeGrip(QPainter *painter, const QStyleOption *option) { Qt::Corner corner = Qt::BottomRightCorner; #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) if (option->type == QStyleOption::SO_SizeGrip) { const QStyleOptionSizeGrip *sizegrip = static_cast(option); corner = sizegrip->corner; } #endif QRect r; switch (corner) { case Qt::TopLeftCorner: r = option->rect.adjusted(0, 0, 2, 2); break; case Qt::TopRightCorner: r = option->rect.adjusted(-2, 0, 0, 2); break; case Qt::BottomLeftCorner: r = option->rect.adjusted(0, -2, 2, 0); break; case Qt::BottomRightCorner: r = option->rect.adjusted(-2, -2, 0, 0); break; } paintThinFrame(painter, r, option->palette, 60, -20); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -20, 60); switch (corner) { case Qt::TopRightCorner: // for Kickoff 4.1 painter->save(); painter->setPen(QPen(shaded_color(option->palette.color(QPalette::Window), 60), 1.0)); painter->drawLine(r.topLeft(), r.bottomRight()); painter->setPen(QPen(shaded_color(option->palette.color(QPalette::Window), -20), 1.0)); painter->drawLine(r.topLeft() + QPoint(1, -1), r.bottomRight() + QPoint(1, -1)); painter->restore(); break; case Qt::BottomRightCorner: painter->save(); painter->setPen(QPen(shaded_color(option->palette.color(QPalette::Window), -20), 1.0)); painter->drawLine(r.topRight(), r.bottomLeft()); painter->setPen(QPen(shaded_color(option->palette.color(QPalette::Window), 60), 1.0)); painter->drawLine(r.topRight() + QPoint(1, 1), r.bottomLeft() + QPoint(1, 1)); painter->restore(); break; case Qt::TopLeftCorner: // TODO break; case Qt::BottomLeftCorner: // TODO break; } } /*-----------------------------------------------------------------------*/ extern void paintCommandButtonPanel(QPainter *painter, const QStyleOptionButton *option, const QWidget *widget); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) void paintToolBoxTabShape(QPainter *painter, const QStyleOptionToolBoxV2 *option) #else void paintToolBoxTabShape(QPainter *painter, const QStyleOptionToolBox *option) #endif { QRect r = option->rect; if (option->state & QStyle::State_Selected) { QColor color = option->palette.color(QPalette::Window); paintThinFrame(painter, r, option->palette, 40, -20); paintThinFrame(painter, r.adjusted(1, 1, -1, -1), option->palette, -20, 80); QLinearGradient gradient(r.topLeft(), r.bottomLeft()); gradient.setColorAt(0.0, shaded_color(color, 50)); gradient.setColorAt(0.2, shaded_color(color, 30)); gradient.setColorAt(0.5, shaded_color(color, 0)); gradient.setColorAt(0.51, shaded_color(color, -10)); gradient.setColorAt(1.0, shaded_color(color, -20)); painter->fillRect(r.adjusted(1, 1, -1, -1), gradient); } else if (option->state & (QStyle::State_Sunken | QStyle::State_MouseOver)) { QStyleOptionButton button; button.QStyleOption::operator=(*option); button.features = QStyleOptionButton::None; button.rect.adjust(-1, -1, 1, 1); // ### needs QPalette::Window ? paintCommandButtonPanel(painter, &button, 0); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) } else if (option->version >= 2 && option->selectedPosition == QStyleOptionToolBoxV2::PreviousIsSelected) { r.setHeight(2); paintThinFrame(painter, r, option->palette, 60, -20); #endif } else { // r.setHeight(2); // painter->fillRect(r, option->palette.color(QPalette::Window)); } QStyleOption indicator; indicator = *option; indicator.rect.setSize(QSize(11, 11)); indicator.rect.translate(0, (option->rect.height() - 11) >> 1); indicator.state = QStyle::State_Children; if (option->state & QStyle::State_Selected) { indicator.state |= QStyle::State_Open; } paintIndicatorBranch(painter, &indicator); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) void paintToolBoxTabLabel(QPainter *painter, const QStyleOptionToolBox *option, const QWidget *widget, const QStyle *style) { QStyleOptionToolBoxV2 opt; if (option->version >= 2) { opt = *((const QStyleOptionToolBoxV2 *) option); } else { opt = *option; } if ((option->state & QStyle::State_Selected) || !(option->state & (QStyle::State_Sunken | QStyle::State_MouseOver))) { opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::WindowText)); } ((QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_ToolBoxTabLabel, &opt, painter, widget); } #endif /*-----------------------------------------------------------------------*/ extern void paintCachedGrip(QPainter *painter, const QStyleOption *option, QPalette::ColorRole bgrole); void paintSplitter(QPainter *painter, const QStyleOption *option) { if (option->state & QStyle::State_Enabled && option->state & QStyle::State_MouseOver) { painter->fillRect(option->rect, QColor(255, 255, 255, 60)); } int d = 5; QRect rect(QRect(option->rect).center() - QPoint(d / 2, d / 2), QSize(d, d)); QStyleOption iOption = *option; iOption.rect = rect; iOption.palette.setCurrentColorGroup(QPalette::Disabled); // iOption.state &= ~QStyle::State_Enabled; iOption.palette.setColor(QPalette::Button, iOption.palette.color(QPalette::Window)); paintCachedGrip(painter, &iOption, QPalette::Window); } /*-----------------------------------------------------------------------*/ void paintRubberBand(QPainter *painter, const QStyleOptionRubberBand *option) { painter->save(); if (true || option->shape == QRubberBand::Rectangle) { QColor color = option->palette.color(QPalette::Highlight); color.setAlphaF(0.2 * color.alphaF()); painter->fillRect(option->rect, color); color = option->palette.color(QPalette::Highlight); color.setAlphaF(0.8 * color.alphaF()); painter->setPen(QPen(color /*, 1.0, Qt::DotLine*/)); painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); } else { // painter->fillRect(option->rect, Qt::green); } painter->restore(); } int getRubberBandMask(QStyleHintReturnMask *mask, const QStyleOption *option, const QWidget *widget) { static const int rubber_width = 4; int r = rubber_width; Q_UNUSED(widget); mask->region = option->rect; if (option->rect.width() > 2 * r && option->rect.height() > 2 * r) { mask->region -= option->rect.adjusted(r, r, -r, -r); } return 1; } /* * skulpture_progressbar.cpp * */ #include "skulpture_p.h" #include #include #include #include #if 0 #define FG_ROLE_PROGRESS QPalette::WindowText #define BG_ROLE_PROGRESS QPalette::Window #elif 1 #define FG_ROLE_PROGRESS QPalette::Text #define BG_ROLE_PROGRESS QPalette::Base #else #define FG_ROLE_PROGRESS QPalette::QPalette::Highlight #define BG_ROLE_PROGRESS QPalette::Base #endif #define FG_ROLE_CHUNK QPalette::HighlightedText #define BG_ROLE_CHUNK QPalette::Highlight /*-----------------------------------------------------------------------*/ static bool isPasswordStrengthIndicator(const QWidget *widget) { return widget && widget->parentWidget() && widget->parentWidget()->parentWidget() && widget->parentWidget()->parentWidget()->inherits("KNewPasswordDialog"); } static bool isDiskSpaceIndicator(const QWidget *widget) { return false && widget && widget->inherits("StatusBarSpaceInfo"); } /*-----------------------------------------------------------------------*/ static bool progressBarContentsCentered(const QStyleOptionProgressBarV2 *option, const QWidget *widget) { const bool vertical = option->version >= 2 && option->orientation == Qt::Vertical; if (vertical) { return false; } if (isPasswordStrengthIndicator(widget) || isDiskSpaceIndicator(widget)) { return false; } return true; } static QRect progressBarContentsRect(const QStyleOptionProgressBarV2 *option, bool contentsCentered) { // configuration options const int border = 2; QRect contentsRect = option->rect.adjusted(border, border, -border, -border); if (option->minimum < option->maximum) { if (option->progress > option->minimum) { if (option->progress < option->maximum) { // progress qreal progress = qreal(option->progress - option->minimum) / (option->maximum - option->minimum); if (option->version >= 2 && option->orientation == Qt::Vertical) { if (contentsCentered) { int adjustment = int((contentsRect.height() / 2) * (1 - progress)); contentsRect.adjust(0, adjustment, 0, -adjustment); } else { int contentsHeight = qMax(1, int(contentsRect.height() * progress + 0.5)); if (option->version >= 2 && option->invertedAppearance) { contentsRect.setHeight(contentsHeight); } else { contentsRect.setTop(contentsRect.top() + contentsRect.height() - contentsHeight); } } } else { if (contentsCentered) { int adjustment = int((contentsRect.width() / 2) * (1 - progress)); contentsRect.adjust(adjustment, 0, -adjustment, 0); } else { int contentsWidth = qMax(1, int(contentsRect.width() * progress + 0.5)); if ((option->version >= 2 && option->invertedAppearance) ^ (option->direction != Qt::LeftToRight)) { contentsRect.setLeft(contentsRect.left() + contentsRect.width() - contentsWidth); } else { contentsRect.setWidth(contentsWidth); } } } } else { // finished } } else { // starting contentsRect = QRect(); } } else if (option->minimum == option->maximum) { // busy indicator } else { // invalid values contentsRect = QRect(); } return contentsRect; } /*-----------------------------------------------------------------------*/ void paintProgressBarGroove(QPainter *painter, const QStyleOptionProgressBar *option) { painter->fillRect(option->rect.adjusted(2, 2, -2, -2), option->palette.brush(BG_ROLE_PROGRESS)); } void paintProgressBarLabel(QPainter *painter, const QStyleOptionProgressBarV2 *option, const QWidget *widget, const QStyle *style) { if (!option->textVisible || option->text.isEmpty()) { return; } const bool vertical = option->version >= 2 && option->orientation == Qt::Vertical; Qt::Alignment alignment = option->textAlignment; if (vertical) { if (!(alignment & (Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter))) { alignment |= Qt::AlignVCenter; } alignment &= ~(Qt::AlignLeft | Qt::AlignRight); alignment |= Qt::AlignHCenter; } else { if (!(alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter))) { alignment |= Qt::AlignHCenter; } alignment &= ~(Qt::AlignTop | Qt::AlignBottom); alignment |= Qt::AlignVCenter; } // FIXME currently forces centering if (true) { alignment &= ~(Qt::AlignLeft | Qt::AlignRight); alignment &= ~(Qt::AlignTop | Qt::AlignBottom); alignment |= Qt::AlignCenter; } const bool contentsCentered = progressBarContentsCentered(option, widget); const QRect contentsRect = progressBarContentsRect(option, contentsCentered); QMatrix mat; if (vertical) { QPointF c = QRectF(option->rect).center(); mat.translate(c.x(), c.y()); mat.rotate(option->bottomToTop ? -90 : 90); mat.translate(-c.x(), -c.y()); } QRect r = mat.mapRect(option->rect).adjusted(6, 2, -6, -2); painter->save(); painter->setClipRegion(contentsRect); painter->setMatrix(mat, true); style->drawItemText(painter, r, alignment, option->palette, true, option->text, FG_ROLE_CHUNK); painter->restore(); painter->save(); QRegion region = option->rect; region -= contentsRect; painter->setClipRegion(region); painter->setMatrix(mat, true); style->drawItemText(painter, r, alignment, option->palette, option->state & QStyle::State_Enabled, option->text, FG_ROLE_PROGRESS); painter->restore(); } /*-----------------------------------------------------------------------*/ enum AnimationMode { NoAnimation, FloatAnimation, LiquidAnimation }; static QColor progressBarFillColor(const QStyleOptionProgressBarV2 *option, const QWidget *widget) { QColor fillColor = option->palette.color(BG_ROLE_CHUNK); if (isPasswordStrengthIndicator(widget)) { int p = option->minimum < option->maximum ? 100 * (option->progress - option->minimum) / (option->maximum - option->minimum) : 0; fillColor.setHsv(p * 85 / 100, 200, 240 - p); } else if (isDiskSpaceIndicator(widget)) { int p = option->minimum < option->maximum ? 100 * (option->progress - option->minimum) / (option->maximum - option->minimum) : 0; if (p < 75) p = 100; else p = (100 - p) * 4; fillColor.setHsv(p * 85 / 100, 200, 240 - p); } return fillColor; } void paintProgressBarContents(QPainter *painter, const QStyleOptionProgressBarV2 *option, const QWidget *widget, const QStyle *style) { // configuration const bool busyIndicator = option->minimum == option->maximum; const bool vertical = option->version >= 2 && option->orientation == Qt::Vertical; const AnimationMode animationMode = busyIndicator ? FloatAnimation : vertical ? LiquidAnimation : FloatAnimation; const int chunkWidth = 4 * qMax(1, style->pixelMetric(QStyle::PM_ProgressBarChunkWidth, option, widget)); const bool reverseAnimation = busyIndicator; const int animationSpeed = (busyIndicator ? 1000 : 1000) * (reverseAnimation ? -1 : 1); const int floatAlpha = busyIndicator ? 100 : 255; const bool contentsCentered = progressBarContentsCentered(option, widget); const QRect contentsRect = progressBarContentsRect(option, contentsCentered); const int cornerSmoothing = 0; const int centerSmoothing = busyIndicator ? 100 : 0; const int borderSmoothing = 0; const bool contentsFrame = false; const int gradientSharpness = 0; const int gradientRatio = 50; const int gradientAngle = 0; // contents if (!contentsRect.isEmpty()) { QColor fillColor = progressBarFillColor(option, widget); qreal rounding = -1; if (!busyIndicator && option->progress < option->maximum) { rounding = contentsCentered ? 0.6 : 0.5; } switch (animationMode) { case NoAnimation: { painter->fillRect(contentsRect, fillColor); break; } case FloatAnimation: { QColor floatColor; if (option->palette.color(FG_ROLE_CHUNK).value() > fillColor.value()) { floatColor = fillColor.lighter(105); } else { floatColor = fillColor.darker(105); } floatColor.setAlpha(floatAlpha); int m = QTime(0, 0).msecsTo(QTime::currentTime()) / (animationSpeed / chunkWidth); QPoint startPoint = contentsCentered ? contentsRect.topLeft() : contentsRect.center(); startPoint += vertical ? QPoint(0, chunkWidth - 1 - m % chunkWidth) : QPoint(m % chunkWidth, 0); QLinearGradient fillGradient(startPoint, startPoint + (vertical ? QPoint(0, chunkWidth) : QPoint(chunkWidth, qRound(chunkWidth * sin(gradientAngle * M_PI / 180))))); fillGradient.setSpread(QGradient::RepeatSpread); const qreal delta = gradientRatio * gradientSharpness * 0.000049999; fillGradient.setColorAt(0.0, fillColor); fillGradient.setColorAt(0.0 + delta, fillColor); fillGradient.setColorAt(gradientRatio / 100.0 - delta, floatColor); fillGradient.setColorAt(gradientRatio / 100.0 + delta, floatColor); fillGradient.setColorAt(gradientRatio / 50.0 - delta, fillColor); fillGradient.setColorAt(1.0, fillColor); if (contentsCentered) { painter->save(); if (vertical) { painter->setClipRect(QRect(contentsRect.x(), contentsRect.y() + (contentsRect.height() >> 1), contentsRect.width(), contentsRect.height() - (contentsRect.height() >> 1))); } else { painter->setClipRect(QRect(contentsRect.x(), contentsRect.y(), contentsRect.width() >> 1, contentsRect.height())); } painter->translate(QRectF(contentsRect).center()); painter->scale(vertical ? 1 : -1, vertical ? -1 : 1); painter->translate(-QRectF(contentsRect).center()); painter->fillRect(contentsRect, fillGradient); painter->restore(); painter->save(); if (vertical) { painter->setClipRect(QRect(contentsRect.x(), contentsRect.y(), contentsRect.width(), contentsRect.height() >> 1)); } else { painter->setClipRect(QRect(contentsRect.x() + (contentsRect.width() >> 1), contentsRect.y(), contentsRect.width() - (contentsRect.width() >> 1), contentsRect.height())); } painter->fillRect(contentsRect, fillGradient); painter->restore(); } else { painter->fillRect(contentsRect, fillGradient); } if (contentsCentered && centerSmoothing > 0) { QColor centerColor = fillColor; const int contentsSize = vertical ? contentsRect.height() : contentsRect.width(); const int centerSize = qMin(3 * chunkWidth, contentsSize >> 1); const int delta = (contentsSize - centerSize) >> 1; const QRect centerRect = vertical ? contentsRect.adjusted(0, delta, 0, -delta) : contentsRect.adjusted(delta, 0, -delta, 0); QLinearGradient centerGradient(centerRect.topLeft(), vertical ? centerRect.bottomLeft() : centerRect.topRight()); // ### work around Qt 4.5 bug QColor transparentCenterColor = centerColor; transparentCenterColor.setAlpha(0); centerGradient.setColorAt(0.0, transparentCenterColor); centerGradient.setColorAt(0.4, centerColor); centerGradient.setColorAt(0.6, centerColor); centerGradient.setColorAt(1.0, transparentCenterColor); painter->fillRect(centerRect, centerGradient); } break; } case LiquidAnimation: { painter->fillRect(contentsRect, fillColor); if (rounding >= 0) { int m = QTime(0, 0).msecsTo(QTime::currentTime()); rounding = (sin(m / 100.0) + 1) / 2; } } } if (rounding >= 0) { QLinearGradient lineGradient(contentsRect.topLeft(), vertical ? contentsRect.topRight() : contentsRect.bottomLeft()); QColor innerColor = blend_color(option->palette.color(BG_ROLE_PROGRESS), fillColor, rounding); QColor outerColor = blend_color(fillColor, option->palette.color(BG_ROLE_PROGRESS), rounding); lineGradient.setColorAt(0.0, outerColor); lineGradient.setColorAt(0.5, innerColor); lineGradient.setColorAt(1.0, outerColor); if (contentsCentered || (option->version >= 2 && option->invertedAppearance)) { if (vertical) { painter->fillRect(QRect(contentsRect.x(), contentsRect.bottom(), contentsRect.width(), 1), lineGradient); } else { painter->fillRect(QRect(contentsRect.left(), contentsRect.y(), 1, contentsRect.height()), lineGradient); } } if (contentsCentered || !(option->version >= 2 && option->invertedAppearance)) { if (vertical) { painter->fillRect(QRect(contentsRect.x(), contentsRect.top(), contentsRect.width(), 1), lineGradient); } else { painter->fillRect(QRect(contentsRect.right(), contentsRect.y(), 1, contentsRect.height()), lineGradient); } } } if (cornerSmoothing > 0) { painter->save(); QColor color = option->palette.color(BG_ROLE_PROGRESS); color.setAlpha(cornerSmoothing); painter->setPen(color); painter->drawPoint(contentsRect.left(), contentsRect.top()); painter->drawPoint(contentsRect.left(), contentsRect.bottom()); painter->drawPoint(contentsRect.right(), contentsRect.top()); painter->drawPoint(contentsRect.right(), contentsRect.bottom()); painter->restore(); } if (borderSmoothing > 0) { painter->save(); QColor frameColor = option->palette.color(BG_ROLE_PROGRESS); frameColor.setAlpha(borderSmoothing); painter->setPen(frameColor); painter->drawRect(contentsRect.adjusted(0, 0, -1, -1)); painter->restore(); } if (contentsFrame) { paintThinFrame(painter, contentsRect, option->palette, -20, 60, BG_ROLE_CHUNK); } } // overlay gradient QLinearGradient glassyGradient(option->rect.topLeft(), vertical ? option->rect.topRight() : option->rect.bottomLeft()); glassyGradient.setColorAt(0.0, QColor(255, 255, 255, 0)); glassyGradient.setColorAt(0.47, QColor(0, 0, 0, 2)); glassyGradient.setColorAt(0.475, QColor(0, 0, 0, 21)); glassyGradient.setColorAt(1.0, QColor(255, 255, 255, 0)); painter->fillRect(option->rect.adjusted(2, 2, -2, -2), glassyGradient); paintRecessedFrame(painter, option->rect, option->palette, RF_Small); } /* * skulpture_scrollbar.cpp * */ #include "skulpture_p.h" #include #include #include #include /*-----------------------------------------------------------------------*/ extern void paintScrollArrow(QPainter *painter, const QStyleOption *option, Qt::ArrowType arrow, bool spin); void paintScrollArea(QPainter *painter, const QStyleOption *option) { QColor color = option->palette.color(QPalette::Disabled, QPalette::Window); if (option->state & QStyle::State_Enabled || option->type != QStyleOption::SO_Slider) { #if 0 if (option->state & QStyle::State_Sunken) { color = color.lighter(107); } else { color = color.darker(107); } #elif 0 color = option->palette.color(QPalette::Base); #elif 1 if (option->state & QStyle::State_Sunken) { color = color.darker(107); } else { // ### if (false && option->state & QStyle::State_MouseOver) { color = color.lighter(110); } else { color = color.lighter(107); } } #endif } painter->fillRect(option->rect, color); // painter->fillRect(option->rect, Qt::red); } void paintScrollAreaCorner(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle */*style*/) { QStyleOption opt; opt = *option; opt.type = QStyleOption::SO_Default; if (qobject_cast(widget)) { // ### work around bug in Qt 4.5 if (option->rect.y() + option->rect.height() > widget->rect().height() || option->rect.x() + option->rect.width() > widget->rect().width()) { return; } opt.type = QStyleOption::SO_Slider; opt.state &= ~QStyle::State_Enabled; if (widget->isEnabled()) { opt.state |= QStyle::State_Enabled; } } paintScrollArea(painter, &opt); } extern void paintSliderGroove(QPainter *painter, QRect &rect, const QStyleOptionSlider *option); void paintScrollBarPage(QPainter *painter, const QStyleOptionSlider *option) { const bool paintGroove = true; paintScrollArea(painter, option); if (paintGroove) { QRect rect = option->rect.adjusted(1, 1, -1, -1); paintSliderGroove(painter, rect, option); } } void paintScrollBarAddLine(QPainter *painter, const QStyleOptionSlider *option) { paintScrollArea(painter, option); // paintThinFrame(painter, option->rect, option->palette, -40, 120); if (option->minimum != option->maximum) { QStyleOptionSlider opt = *option; opt.fontMetrics = QApplication::fontMetrics(); opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::WindowText)); paintScrollArrow(painter, &opt, option->orientation == Qt::Horizontal ? (option->direction == Qt::LeftToRight ? Qt::RightArrow : Qt::LeftArrow) : Qt::DownArrow, false); } } void paintScrollBarSubLine(QPainter *painter, const QStyleOptionSlider *option) { paintScrollArea(painter, option); // paintThinFrame(painter, option->rect, option->palette, -40, 120); if (option->minimum != option->maximum) { QStyleOptionSlider opt = *option; opt.fontMetrics = QApplication::fontMetrics(); opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::WindowText)); paintScrollArrow(painter, &opt, option->orientation == Qt::Horizontal ? (option->direction == Qt::LeftToRight ? Qt::LeftArrow : Qt::RightArrow) : Qt::UpArrow, false); } } void paintScrollBarFirst(QPainter *painter, const QStyleOptionSlider *option) { paintScrollBarSubLine(painter, option); if (option->minimum != option->maximum) { painter->fillRect(option->rect.adjusted(2, 2, -2, -2), option->palette.color(QPalette::WindowText)); } } void paintScrollBarLast(QPainter *painter, const QStyleOptionSlider *option) { paintScrollBarAddLine(painter, option); if (option->minimum != option->maximum) { painter->fillRect(option->rect.adjusted(2, 2, -2, -2), option->palette.color(QPalette::WindowText)); } } /*-----------------------------------------------------------------------*/ class ComplexControlLayout { public: struct SubControlItem { QStyle::SubControl subControl; QStyle::ControlElement controlElement; char layoutSpec; }; protected: ComplexControlLayout(const SubControlItem *controlItem, uint controlCount, const QStyleOptionComplex *opt, const QWidget *w = 0, const QStyle *s = 0) : subControlItem(controlItem), subControlCount(controlCount), option(opt), widget(w), style(s), layoutCount(0) { /* */ } ~ComplexControlLayout() { } public: QStyle::SubControl hitTestComplexControl(const QPoint &position) const; QRect subControlRect(QStyle::SubControl subControl) const; void paintComplexControl(QPainter *painter) const; protected: struct LayoutItem { QStyle::SubControl subControl; QRect rect; }; protected: void addLayoutItem(QStyle::SubControl subControl, const QRect &rect); protected: static const uint maxLayoutCount = 16; protected: const SubControlItem * const subControlItem; const uint subControlCount; const QStyleOptionComplex * const option; const QWidget * const widget; const QStyle * const style; uint layoutCount; LayoutItem layoutItem[maxLayoutCount]; }; /*-----------------------------------------------------------------------*/ void ComplexControlLayout::addLayoutItem(QStyle::SubControl subControl, const QRect &rect) { if (layoutCount < maxLayoutCount) { layoutItem[layoutCount].subControl = subControl; layoutItem[layoutCount].rect = style->visualRect(option->direction, option->rect, rect); ++layoutCount; } } QStyle::SubControl ComplexControlLayout::hitTestComplexControl(const QPoint &position) const { for (uint i = 0; i < subControlCount; ++i) { for (uint j = 0; j < layoutCount; ++j) { if (layoutItem[j].subControl == subControlItem[i].subControl) { if (layoutItem[j].rect.contains(position)) { return layoutItem[j].subControl; } } } } return QStyle::SC_None; } QRect ComplexControlLayout::subControlRect(QStyle::SubControl subControl) const { QRect rect; for (uint i = 0; i < layoutCount; ++i) { if (layoutItem[i].subControl == subControl) { rect |= layoutItem[i].rect; } } return rect; } void ComplexControlLayout::paintComplexControl(QPainter *painter) const { for (int i = subControlCount; --i >= 0; ) { if (subControlItem[i].controlElement != QStyle::CE_CustomBase && option->subControls & subControlItem[i].subControl) { for (uint j = 0; j < layoutCount; ++j) { if (layoutItem[j].subControl == subControlItem[i].subControl) { QStyleOptionSlider opt = *static_cast(ComplexControlLayout::option); opt.rect = layoutItem[j].rect; if (!(option->activeSubControls & subControlItem[i].subControl)) { opt.state &= ~(QStyle::State_Sunken | QStyle::State_MouseOver); } style->drawControl(subControlItem[i].controlElement, &opt, painter, widget); } } } } } /*-----------------------------------------------------------------------*/ static const ComplexControlLayout::SubControlItem scrollBarSubControlItem[] = { /* hitTest in forward order, paint in reverse order */ { QStyle::SC_ScrollBarSlider, QStyle::CE_ScrollBarSlider, '*' }, { QStyle::SC_ScrollBarAddLine, QStyle::CE_ScrollBarAddLine, '>' }, { QStyle::SC_ScrollBarSubLine, QStyle::CE_ScrollBarSubLine, '<' }, { QStyle::SC_ScrollBarFirst, QStyle::CE_ScrollBarFirst, '[' }, { QStyle::SC_ScrollBarLast, QStyle::CE_ScrollBarLast, ']' }, { QStyle::SC_ScrollBarAddPage, QStyle::CE_ScrollBarAddPage, ')' }, { QStyle::SC_ScrollBarSubPage, QStyle::CE_ScrollBarSubPage, '(' }, { QStyle::SC_ScrollBarGroove, QStyle::CE_CustomBase, '#' } }; class ScrollBarLayout : public ComplexControlLayout { public: ScrollBarLayout(const QStyleOptionSlider *opt, const QWidget *w = 0, const QStyle *s = 0) : ComplexControlLayout(scrollBarSubControlItem, array_elements(scrollBarSubControlItem), opt, w, s) { /* */ } ~ScrollBarLayout() { } public: void initLayout(const char *layoutSpec); void initLayout(ArrowPlacementMode placementMode); protected: void addLayoutItem(const char layoutSpec, int pos, int size); }; /*-----------------------------------------------------------------------*/ void ScrollBarLayout::addLayoutItem(char c, int pos, int size) { const QStyleOptionSlider *option = static_cast(ComplexControlLayout::option); if (size > 0) { for (uint i = 0; i < subControlCount; ++i) { if (subControlItem[i].layoutSpec == c) { QRect rect; if (option->orientation == Qt::Horizontal) { rect = QRect(option->rect.left() + pos, option->rect.top(), size, option->rect.height()); } else { rect = QRect(option->rect.left(), option->rect.top() + pos, option->rect.width(), size); } ComplexControlLayout::addLayoutItem(subControlItem[i].subControl, rect); return; } } } } void ScrollBarLayout::initLayout(ArrowPlacementMode placementMode) { static const char *layoutSpec[] = { "(*)", // NoArrowsMode "(<*>)", // SkulptureMode "<(*)>", // WindowsMode "<(*)<>", // KDEMode "(*)<>", // PlatinumMode "<>(*)" // NextMode }; initLayout(layoutSpec[uint(placementMode)]); } void ScrollBarLayout::initLayout(const char *layoutSpec) { const QStyleOptionSlider *option = static_cast(ComplexControlLayout::option); uint range = option->maximum - option->minimum; int pos = option->orientation == Qt::Horizontal ? option->rect.left() : option->rect.top(); int maxSize = option->orientation == Qt::Horizontal ? option->rect.width() : option->rect.height(); int endPos = pos + maxSize; int groovePos = pos, grooveSize = maxSize; int pagePos = pos, pageSize = maxSize; int buttonSize = style->pixelMetric(QStyle::PM_ScrollBarExtent, option, widget); buttonSize = qMin(maxSize >> 1, buttonSize); if (qstrcmp(layoutSpec, "(*)")) { if (!qstrcmp(layoutSpec, "<(*)<>")) { if (maxSize < 4 * buttonSize) { layoutSpec = "<(*)>"; } } if (maxSize < 3 * buttonSize) { layoutSpec = "(<*>)"; } } if (layoutSpec && range != 0) { // layout items before slider const char *p = layoutSpec; char c; while ((c = *p)) { if (c == '*') { pagePos = pos; break; } else if (c == '(') { groovePos = pos; } else { addLayoutItem(c, pos, buttonSize); pos += buttonSize; } ++p; } // layout items after slider while (*p) { ++p; } --p; pos = endPos; while (p >= layoutSpec) { c = *p; if (c == '*') { pageSize = pos - pagePos; break; } else if (c == ')') { grooveSize = pos - groovePos; } else { pos -= buttonSize; addLayoutItem(c, pos, buttonSize); } --p; } } if (layoutCount > maxLayoutCount - 4) { layoutCount = maxLayoutCount - 4; } if (range != 0) { int sliderSize = (qint64(option->pageStep) * grooveSize) / (range + option->pageStep); int sliderMin = style->pixelMetric(QStyle::PM_ScrollBarSliderMin, option, widget); if (sliderMin > grooveSize >> 1) { sliderMin = grooveSize >> 1; if (sliderSize > sliderMin) { sliderSize = sliderMin; } } if (sliderSize < sliderMin || range > INT_MAX / 2) { sliderSize = sliderMin; } if (grooveSize != pageSize) { if (sliderSize > grooveSize - buttonSize) { sliderSize = grooveSize - buttonSize; } } int sliderPos = groovePos + style->sliderPositionFromValue(option->minimum, option->maximum, option->sliderPosition, grooveSize - sliderSize, option->upsideDown); addLayoutItem('(', pagePos, sliderPos - pagePos); addLayoutItem(')', sliderPos + sliderSize, (pagePos + pageSize) - (sliderPos + sliderSize)); addLayoutItem('*', sliderPos, sliderSize); } else { addLayoutItem('*', groovePos, grooveSize); } addLayoutItem('#', groovePos, grooveSize); } /*-----------------------------------------------------------------------*/ extern void paintCachedGrip(QPainter *painter, const QStyleOption *option, QPalette::ColorRole bgrole = QPalette::Window); extern void paintSliderHandle(QPainter *painter, const QRect &rect, const QStyleOptionSlider *option); void paintScrollBarSlider(QPainter *painter, const QStyleOptionSlider *option) { if (option->minimum == option->maximum) { paintScrollArea(painter, option); } else { paintSliderHandle(painter, option->rect, option); } } /*-----------------------------------------------------------------------*/ void paintScrollBar(QPainter *painter, const QStyleOptionSlider *option, const QWidget *widget, const QStyle *style, ArrowPlacementMode horizontalArrowMode, ArrowPlacementMode verticalArrowMode) { // paint scrollbar ScrollBarLayout layout(option, widget, style); layout.initLayout(option->orientation == Qt::Horizontal ? horizontalArrowMode : verticalArrowMode); layout.paintComplexControl(painter); // get frame this scrollbar is in QFrame *frame = 0; if (widget && widget->parentWidget()) { QWidget *container = widget->parentWidget(); if (container->inherits("Q3ListView")) { if (option->orientation == Qt::Vertical) { frame = qobject_cast(container); } } else if (container->inherits("Q3Table")) { frame = qobject_cast(container); } else if (container->parentWidget()) { frame = qobject_cast(container->parentWidget()); } } // paint shadow if (frame && frame->frameStyle() == (QFrame::StyledPanel | QFrame::Sunken)) { QRect rect = option->rect; if (option->orientation == Qt::Vertical) { if (option->direction == Qt::LeftToRight) { rect.adjust(-3, 0, 1, 0); } else { rect.adjust(-1, 0, 2, 0); } // ### temporary hack to detect corner widget if (widget->height() == frame->height() - 4) { rect.adjust(0, -1, 0, 1); } else { rect.adjust(0, -1, 0, 4); } } else { rect.adjust(0, -3, 0, 1); // ### temporary hack to detect corner widget if (widget->width() == frame->width() - 4) { rect.adjust(-1, 0, 1, 0); } else { if (option->direction == Qt::LeftToRight) { rect.adjust(-1, 0, 4, 0); } else { rect.adjust(-4, 0, 1, 0); } } } paintRecessedFrameShadow(painter, rect.adjusted(1, 1, -1, -1), RF_Small); } } QRect subControlRectScrollBar(const QStyleOptionSlider *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style, ArrowPlacementMode horizontalArrowMode, ArrowPlacementMode verticalArrowMode) { ScrollBarLayout layout(option, widget, style); layout.initLayout(option->orientation == Qt::Horizontal ? horizontalArrowMode : verticalArrowMode); return layout.subControlRect(subControl); } QStyle::SubControl hitTestComplexControlScrollBar(const QStyleOptionSlider *option, const QPoint &position, const QWidget *widget, const QStyle *style, ArrowPlacementMode horizontalArrowMode, ArrowPlacementMode verticalArrowMode) { ScrollBarLayout layout(option, widget, style); layout.initLayout(option->orientation == Qt::Horizontal ? horizontalArrowMode : verticalArrowMode); return layout.hitTestComplexControl(position); } /* * skulpture_shadows.cpp * */ #include "skulpture_p.h" #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) #include #endif #include #include #include #include /*-----------------------------------------------------------------------*/ /** * FrameShadow - overlay a shadow inside a frame * * This class is used to give the impression of sunken * frames that cast shadows over the contents inside. * * To create the shadow, call installFrameShadow() * on the sunken QFrame that you want the shadow * to be added to. * * Side-effects: * * Adds transparent widgets to the frame, which may * affect performance. * */ FrameShadow::FrameShadow(QWidget *parent) : QWidget(parent) { init(); } FrameShadow::FrameShadow(ShadowArea area, QWidget *parent) : QWidget(parent) { init(); area_ = area; } FrameShadow::~FrameShadow() { /* */ } /*-----------------------------------------------------------------------*/ void SkulptureStyle::Private::installFrameShadow(QWidget *widget) { // printf("adding shadow to %s\n", widget->metaObject()->className()); widget->installEventFilter(this); removeFrameShadow(widget); for (int i = 0; i < 4; ++i) { FrameShadow *shadow = new FrameShadow(FrameShadow::ShadowArea(i)); shadow->hide(); shadow->setParent(widget); shadow->updateGeometry(); shadow->show(); } } void SkulptureStyle::Private::removeFrameShadow(QWidget *widget) { const QList shadows = widget->children(); Q_FOREACH (QObject *child, shadows) { FrameShadow *shadow; if ((shadow = qobject_cast(child))) { shadow->hide(); shadow->setParent(0); shadow->deleteLater(); } } } void SkulptureStyle::Private::updateFrameShadow(QWidget *widget) { const QList shadows = widget->children(); Q_FOREACH (QObject *child, shadows) { FrameShadow *shadow; if ((shadow = qobject_cast(child))) { if (shadow->isVisible()) { shadow->updateGeometry(); } } } } /*-----------------------------------------------------------------------*/ #define SHADOW_SIZE_TOP 4 #define SHADOW_SIZE_BOTTOM 2 #define SHADOW_SIZE_LEFT 4 #define SHADOW_SIZE_RIGHT 4 void FrameShadow::updateGeometry() { QWidget *widget = parentWidget(); QRect cr = widget->contentsRect(); // printf("cr-top: %d in class %s\n", cr.top(), widget->metaObject()->className()); switch (shadowArea()) { case FrameShadow::Top: cr.setHeight(SHADOW_SIZE_TOP); break; case FrameShadow::Left: cr.setWidth(SHADOW_SIZE_LEFT); cr.adjust(0, SHADOW_SIZE_TOP, 0, -SHADOW_SIZE_BOTTOM); break; case FrameShadow::Bottom: cr.setTop(cr.bottom() - SHADOW_SIZE_BOTTOM + 1); break; case FrameShadow::Right: cr.setLeft(cr.right() - SHADOW_SIZE_RIGHT + 1); cr.adjust(0, SHADOW_SIZE_TOP, 0, -SHADOW_SIZE_BOTTOM); break; } setGeometry(cr); } /*-----------------------------------------------------------------------*/ bool FrameShadow::event(QEvent *e) { if (e->type() == QEvent::Paint) { return QWidget::event(e); } QWidget *viewport = 0; if (parentWidget()) { if (QAbstractScrollArea *widget = qobject_cast(parentWidget())) { viewport = widget->viewport(); } else if (parentWidget()->inherits("Q3ScrollView")) { // FIXME: get viewport? needs Qt3Support linkage! viewport = 0; } else { viewport = 0; } } if (!viewport) { return false; } #if 1 switch (e->type()) { case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave: case QEvent::Drop: { setAcceptDrops(viewport->acceptDrops()); QObject *o = viewport; return o->event(e); } break; case QEvent::Enter: setCursor(viewport->cursor()); setAcceptDrops(viewport->acceptDrops()); break; case QEvent::ContextMenu: { QContextMenuEvent *me = reinterpret_cast(e); QContextMenuEvent *ne = new QContextMenuEvent(me->reason(), parentWidget()->mapFromGlobal(me->globalPos()), me->globalPos()); QApplication::sendEvent(viewport, ne); e->accept(); return true; } break; case QEvent::MouseButtonPress: releaseMouse(); case QEvent::MouseMove: case QEvent::MouseButtonRelease: { QMouseEvent *me = reinterpret_cast(e); QMouseEvent *ne = new QMouseEvent(e->type(), parentWidget()->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers()); QApplication::sendEvent(viewport, ne); e->accept(); return true; } break; case QEvent::Paint: return QWidget::event(e); default: break; } e->ignore(); return false; #else return QWidget::event(e); #endif } /*-----------------------------------------------------------------------*/ void FrameShadow::paintEvent(QPaintEvent *) { // this fixes shadows in frames that change frameStyle() after polish() if (QFrame *frame = qobject_cast(parentWidget())) { if (frame->frameStyle() != (QFrame::StyledPanel | QFrame::Sunken)) { return; } } QPainter painter(this); QWidget *parent = parentWidget(); QRect r = parent->contentsRect(); r.translate(mapFromParent(QPoint(0, 0))); // painter.fillRect(QRect(-100, -100, 1000, 1000), Qt::red); paintRecessedFrameShadow(&painter, r, RF_Large); } /*-----------------------------------------------------------------------*/ void FrameShadow::init() { // setAttribute(Qt::WA_NoSystemBackground, true); // setAttribute(Qt::WA_NoBackground, true); setAttribute(Qt::WA_OpaquePaintEvent, false); setFocusPolicy(Qt::NoFocus); // TODO: check if this is private setAttribute(Qt::WA_TransparentForMouseEvents, true); setContextMenuPolicy(Qt::NoContextMenu); QWidget *viewport; if (parentWidget()) { if (QAbstractScrollArea *widget = qobject_cast(parentWidget())) { setAcceptDrops(true); viewport = widget->viewport(); } else if (parentWidget()->inherits("Q3ScrollView")) { // FIXME: get viewport? needs Qt3Support linkage! viewport = parentWidget(); } else { viewport = 0; } if (viewport) { setCursor(viewport->cursor()); } } } /*-----------------------------------------------------------------------*/ void paintRecessedFrameShadow(QPainter *painter, const QRect &rect, enum RecessedFrame rf) { if (rf == RF_None) return; #if 1 int c1 = (rf == RF_Small) ? 10 : 10; int c2 = (rf == RF_Small) ? 24 : 36; #else int c1 = 0; int c2 = 0; #endif #if 0 c1 += c1 >> 1; c2 += c2 >> 1; int intensityTop = c2; int intensityLeft = c2; int intensityBottom = c1; int intensityRight = c1; #endif QRect r = rect; while (c1 > 3 || c2 > 3) { QBrush brush1(QColor(0, 0, 0, c1)); QBrush brush2(QColor(0, 0, 0, c2)); painter->fillRect(QRect(rect.left(), r.top(), rect.width(), 1), brush2); painter->fillRect(QRect(r.left(), rect.top(), 1, rect.height()), brush2); painter->fillRect(QRect(rect.left(), r.bottom(), rect.width(), 1), brush1); painter->fillRect(QRect(r.right(), rect.top(), 1, rect.height()), brush1); c1 >>= 1; c2 >>= 1; // c1 = int(c1 * 0.7); c2 = int(c2 * 0.7); r.adjust(1, 1, -1, -1); } } /*-----------------------------------------------------------------------*/ /** * WidgetShadow - add a drop shadow to a widget * * This class renders a shadow below a widget, such * as a QMdiSubWindow. * */ WidgetShadow::WidgetShadow(QWidget *parent) : QWidget(parent) { init(); } /*-----------------------------------------------------------------------*/ void WidgetShadow::init() { setObjectName(QLatin1String("WidgetShadow")); // setAttribute(Qt::WA_NoSystemBackground, true); // setAttribute(Qt::WA_NoBackground, true); setAttribute(Qt::WA_OpaquePaintEvent, false); // setAutoFillBackground(false); setFocusPolicy(Qt::NoFocus); // TODO: check if this is private setAttribute(Qt::WA_TransparentForMouseEvents, true); // setContextMenuPolicy(Qt::NoContextMenu); widget_ = 0; } /*-----------------------------------------------------------------------*/ bool WidgetShadow::event(QEvent *e) { switch (e->type()) { case QEvent::Paint: if (widget_) { QRect r(- 10, - 5, widget_->frameGeometry().width() + 20, widget_->frameGeometry().height() + 15); r.translate(qMin(widget_->x(), 10), qMin(widget_->y(), 5)); QPainter p(this); QRegion region(r); region -= QRect(r.adjusted(10, 5, -10, -10)); p.setClipRegion(region); #if 0 for (int i = 0; i < 10; ++i) { int k = 9 - i; p.fillRect(r.adjusted(k, i, -k, -i), QColor(0, 0, 0, i)); p.fillRect(r.adjusted(i, k, -i, -k), QColor(0, 0, 0, i)); } #else for (int i = 0; i < 10; ++i) { p.fillRect(r, QColor(0, 0, 0, 2 + i)); r.adjust(1, 1, -1, -1); } #endif e->ignore(); return (true); } default: break; } return QWidget::event(e); } void WidgetShadow::updateGeometry() { if (widget_) { if (widget_->isHidden()) { hide(); } else { QWidget *parent = parentWidget(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (parent && !qobject_cast(parent) && qobject_cast(parent->parentWidget())) { parent = parent->parentWidget(); } #endif if (parent) { QRect geo(widget_->x() - 10, widget_->y() - 5, widget_->frameGeometry().width() + 20, widget_->frameGeometry().height() + 15); setGeometry(geo & parent->rect()); } show(); } } } void WidgetShadow::updateZOrder() { if (widget_) { if (widget_->isHidden()) { hide(); } else { stackUnder(widget_); QWidget *parent = parentWidget(); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (parent && !qobject_cast(parent) && qobject_cast(parent->parentWidget())) { parent = parent->parentWidget(); } #endif if (parent) { QRect geo(widget_->x() - 10, widget_->y() - 5, widget_->frameGeometry().width() + 20, widget_->frameGeometry().height() + 15); setGeometry(geo & parent->rect()); } show(); } } } /* * skulpture_shapes.cpp * */ #include "skulpture_p.h" #include "sk_factory.h" /*-----------------------------------------------------------------------*/ /** * ShapeFactory - create a QPainterPath from a description * * The shape description is a bytecode stream that allows simple arithmetic, * conditionals, and looping. * * Syntax is as follows: * Description: Instruction* End * Instruction: Close | Move X Y | Line X Y | Quad X1 Y1 X2 Y2 | Cubic X1 Y1 X2 Y2 X3 Y3 * Instruction: Nop | SetVar X | Begin Instruction* End | While Condition Instruction | If Condition Instruction1 [ Else Instruction2 ] * Condition: Not Condition | And Condition1 Condition2 | Or Condition1 Condition2 | EQ X Y | NE X Y | LT X Y | GE X Y | GT X Y | LE X Y * Expression: Number | GetVar | Add X Y | Sub X Y | Mul X Y | Div X Y | Min X Y | Max X Y | Mix V X Y | Cond Condition X Y * * TODO * * Mod, MultiLine, DoWhile, Integer/Float, Switch, Exp, Sin, Cos, Tan, Atan, Atan2, Pi * Colors, Gradients, Functions (Call/Ret), Frames, Text * */ /*-----------------------------------------------------------------------*/ void ShapeFactory::executeCode(Code code) { qreal v[6]; switch (code) { case Move: case Line: v[0] = evalValue(); v[1] = evalValue(); if (code == Move) { path.moveTo(v[0], v[1]); } else { path.lineTo(v[0], v[1]); } break; case Close: path.closeSubpath(); break; case Quad: case Cubic: { for (int n = 0; n < (code == Quad ? 4 : 6); ++n) { v[n] = evalValue(); } if (code == Quad) { path.quadTo(v[0], v[1], v[2], v[3]); } else { path.cubicTo(v[0], v[1], v[2], v[3], v[4], v[5]); } break; } default: AbstractFactory::executeCode(code); break; } } void ShapeFactory::skipCode(Code code) { switch (code) { case Move: case Line: skipValue(); skipValue(); break; case Close: break; case Quad: case Cubic: { for (int n = 0; n < (code == Quad ? 4 : 6); ++n) { skipValue(); } break; } default: AbstractFactory::skipCode(code); break; } } /*-----------------------------------------------------------------------*/ QPainterPath ShapeFactory::createShape(ShapeFactory::Description description, qreal var[]) { ShapeFactory factory; factory.setDescription(description); for (int n = MinVar; n <= MaxVar; ++n) { factory.setVar(n, var[n]); } factory.create(); for (int n = MinVar; n <= MaxVar; ++n) { var[n] = factory.getVar(n); } return factory.getPath(); } QPainterPath ShapeFactory::createShape(ShapeFactory::Description description) { ShapeFactory factory; factory.setDescription(description); factory.create(); return factory.getPath(); } /* * skulpture_shortcuts.cpp * */ #include "skulpture_p.h" #include #include #include #include #include #include #include #include #include #include #include /*-----------------------------------------------------------------------*/ /** * Class to manage the applications keyboard shortcuts * * It acts as an eventfilter for the application, and does the following: * * * the shortcuts are only underlined when the Alt key is pressed, and * the underline is removed once it is released. * * on many widgets the focus frame is not displayed if the focus was * received using the mouse. It is, however, still displayed if * you use the Tab key. * * Additionally, this class is responsible for blanking the mouse pointer: * * * when the tablet pen leaves proximity * * Any other keyboard shortcut and focus issues should also be handled here. * */ /*-----------------------------------------------------------------------*/ bool ShortcutHandler::underlineShortcut(const QWidget *widget) const { if (widget && widget->isEnabled()) { if (alt_pressed.contains(widget->window())) { return true; } if (qobject_cast(widget)) { if (widget->hasFocus()) { return true; } QList children = qFindChildren(widget); Q_FOREACH (QWidget *child, children) { if (child->hasFocus()) { return true; } } } if (qobject_cast(widget)) { return true; } } return false; } static inline bool hasShortcut(QWidget *widget) { if (qobject_cast(widget) // && (qobject_cast(widget))->text.contains(QChar('&', 0)) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) // || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) // && (qobject_cast(widget))->isCheckable() || qobject_cast(widget)) { return true; } return false; } static inline void updateShortcuts(QWidget *widget) { QList children = qFindChildren(widget); Q_FOREACH (QWidget *child, children) { if (child->isVisible() && hasShortcut(child)) { child->update(); } } } bool ShortcutHandler::eventFilter(QObject *watched, QEvent *event) { if (!watched->isWidgetType()) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) switch (event->type()) { case QEvent::TabletEnterProximity: if (tabletCursorState != TabletCursor) { if (tabletCursorState != DefaultCursor) { QApplication::restoreOverrideCursor(); } tabletCursorState = DefaultCursor; } break; case QEvent::TabletLeaveProximity: if (tabletCursorState != BlankCursor) { if (tabletCursorState != DefaultCursor) { QApplication::restoreOverrideCursor(); } QApplication::setOverrideCursor(Qt::BlankCursor); tabletCursorState = BlankCursor; } break; default: break; } #endif return QObject::eventFilter(watched, event); } QWidget *widget = reinterpret_cast(watched); switch (event->type()) { case QEvent::MouseMove: if (tabletCursorState != DefaultCursor) { QApplication::restoreOverrideCursor(); tabletCursorState = DefaultCursor; } break; case QEvent::FocusIn: { Qt::FocusReason reason = ((QFocusEvent *) event)->reason(); if (reason != Qt::TabFocusReason && reason != Qt::BacktabFocusReason) { QWidget *window = widget->window(); window->setAttribute(Qt::WA_KeyboardFocusChange, false); } } break; case QEvent::KeyPress: if (((QKeyEvent *) event)->key() == Qt::Key_Alt) { QWidget *window = widget->window(); if (!alt_pressed.contains(window)) { alt_pressed.append(window); window->installEventFilter(this); updateShortcuts(window); } } break; case QEvent::Close: if (widget->isWindow()) { alt_pressed.removeAll(widget); widget->removeEventFilter(this); } break; case QEvent::WindowDeactivate: if (widget->isWindow()) { alt_pressed.removeAll(widget); widget->removeEventFilter(this); updateShortcuts(widget); } break; case QEvent::KeyRelease: if (((QKeyEvent *) event)->key() == Qt::Key_Alt) { QWidget *window = widget->window(); if (alt_pressed.contains(window)) { alt_pressed.removeAll(window); window->removeEventFilter(this); updateShortcuts(window); } } break; default: break; } return QObject::eventFilter(watched, event); } /*-----------------------------------------------------------------------*/ ShortcutHandler::ShortcutHandler(QObject *parent) : QObject(parent), tabletCursorState(DefaultCursor) { init(); } ShortcutHandler::~ShortcutHandler() { if (tabletCursorState != DefaultCursor) { tabletCursorState = DefaultCursor; QApplication::restoreOverrideCursor(); } } /* * skulpture_slider.cpp * */ #include "skulpture_p.h" #include #include /*-----------------------------------------------------------------------*/ void paintSliderGroove(QPainter *painter, QRect &rect, const QStyleOptionSlider *option) { if (option->orientation == Qt::Horizontal) { int d = rect.height() / 2; rect.adjust(0, d, 0, -d); } else { int d = rect.width() / 2; rect.adjust(d, 0, -d, 0); } QColor color = option->palette.color(QPalette::Window); if (option->state & QStyle::State_Enabled) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) color = color.darker(120); #else color = color.dark(120); #endif painter->fillRect(rect, color); paintThinFrame(painter, rect.adjusted(-1, -1, 1, 1), option->palette, -30, -90); } else { painter->fillRect(rect, color); paintThinFrame(painter, rect.adjusted(-1, -1, 1, 1), option->palette, -20, -60); } } void paintSliderHandle(QPainter *painter, const QRect &rect, const QStyleOptionSlider *option) { // shadow painter->fillRect(rect.adjusted(2, 2, 2, 2), QColor(0, 0, 0, 5)); painter->fillRect(rect.adjusted(1, 1, 1, 1), QColor(0, 0, 0, 8)); // slider color QColor color = option->palette.color(QPalette::Button); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_Sunken) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) color = color.lighter(102); #else color = color.light(102); #endif } else if (option->state & QStyle::State_MouseOver) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) color = color.lighter(104); #else color = color.light(104); #endif } } else { color = option->palette.color(QPalette::Window); } painter->fillRect(rect, color); #if 1 // slider gradient if ((option->state & QStyle::State_Enabled) && !(option->state & QStyle::State_Sunken)) { QLinearGradient gradient(rect.topLeft(), option->orientation == Qt::Horizontal ? rect.bottomLeft() : rect.topRight()); #if 1 // SkandaleStyle 0.0.2 gradient.setColorAt(0.0, shaded_color(color, 40)); gradient.setColorAt(0.5, shaded_color(color, 0)); gradient.setColorAt(1.0, shaded_color(color, 70)); #else // glassy gradient.setColorAt(0.0, shaded_color(color, 40)); gradient.setColorAt(0.4, shaded_color(color, -5)); gradient.setColorAt(0.405, shaded_color(color, -15)); gradient.setColorAt(1.0, shaded_color(color, 70)); #endif painter->fillRect(rect, gradient); } #endif // slider frame paintThinFrame(painter, rect, option->palette, -70, -20, QPalette::Button); paintThinFrame(painter, rect.adjusted(1, 1, -1, -1), option->palette, -30, 130, QPalette::Button); } /*-----------------------------------------------------------------------*/ void paintSlider(QPainter *painter, const QStyleOptionSlider *option, const QWidget *widget, const QStyle *style) { // groove if (option->subControls & QStyle::SC_SliderGroove) { // painter->fillRect(option->rect, option->palette.color(QPalette::Window).darker(105)); // paintThinFrame(painter, option->rect, option->palette, 130, -30); #if 0 int handlesize = style->pixelMetric(QStyle::PM_SliderLength, option, widget); int e = handlesize / 2 - 1; #else int e = 1; #endif #if 0 QRect rect = option->rect; // QRect rect = style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderGroove, widget); if (option->orientation == Qt::Horizontal) { rect.adjust(e, 0, -e, 0); } else { rect.adjust(0, e, 0, -e); } paintSliderGroove(painter, rect, option); #else QRect rect = style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderGroove, widget); //QRect rect = option->rect; QRect handle_rect = style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderHandle, widget); QStyleOptionSlider aOption = *option; aOption.palette.setColor(QPalette::Window, aOption.palette.color(QPalette::Highlight)); if (option->orientation == Qt::Horizontal) { handle_rect.adjust(0, 2, 0, -2); rect.adjust(e, 0, -e, 0); rect.setWidth(handle_rect.left() - rect.left() - 1); if (rect.width() > -3) { paintSliderGroove(painter, rect, option->upsideDown ? option : &aOption); } rect.setLeft(handle_rect.right() + 2); rect.setWidth(option->rect.right() - handle_rect.right() - 1 - e); if (rect.width() > -3) { paintSliderGroove(painter, rect, option->upsideDown ? &aOption : option); } } else { handle_rect.adjust(2, 0, -2, 0); rect.adjust(0, e, 0, -e); rect.setHeight(handle_rect.top() - rect.top() - 1); if (rect.height() > -3) { paintSliderGroove(painter, rect, option->upsideDown ? option : &aOption); } rect.setTop(handle_rect.bottom() + 2); rect.setHeight(option->rect.bottom() - handle_rect.bottom() - e); if (rect.height() > -3) { paintSliderGroove(painter, rect, option->upsideDown ? &aOption : option); } } #endif } #if 1 // tickmarks if (option->subControls & QStyle::SC_SliderTickmarks) { QStyleOptionSlider slider = *option; slider.subControls = QStyle::SC_SliderTickmarks; // ### for now, just use common tickmarks QPalette palette = slider.palette; QColor col = palette.color(QPalette::WindowText); col.setAlpha(51); palette.setColor(QPalette::WindowText, col); slider.palette = palette; if (option->orientation == Qt::Horizontal) { slider.rect.adjust(-1, 0, -1, 0); } else { slider.rect.adjust(0, -1, 0, -1); } ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_Slider, &slider, painter, widget); slider.rect = option->rect; palette.setColor(QPalette::WindowText, QColor(255, 255, 255, 77)); slider.palette = palette; ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_Slider, &slider, painter, widget); } #endif // focus rect if (option->state & QStyle::State_HasFocus) { QStyleOptionFocusRect focus; focus.QStyleOption::operator=(*option); focus.rect = style->subElementRect(QStyle::SE_SliderFocusRect, option, widget); focus.state |= QStyle::State_FocusAtBorder; style->drawPrimitive(QStyle::PE_FrameFocusRect, &focus, painter, widget); } // handle if (option->subControls & QStyle::SC_SliderHandle) { QStyleOptionSlider aOption = *option; if (!(option->activeSubControls & QStyle::SC_SliderHandle)) { aOption.state &= ~QStyle::State_MouseOver; aOption.state &= ~QStyle::State_Sunken; } QRect rect = style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderHandle, widget); if (option->orientation == Qt::Horizontal) { rect.adjust(0, 2, 0, -2); } else { rect.adjust(2, 0, -2, 0); } #if 0 if (option->orientation == Qt::Horizontal) { rect.setTop(option->rect.top()); rect.setHeight(option->rect.height()); // rect.adjust(0, 1, 0, -1); } else { rect.setLeft(option->rect.left()); rect.setWidth(option->rect.width()); // rect.adjust(1, 0, -1, 0); } #endif // rect.adjust(0, 0, -1, -1); paintSliderHandle(painter, rect, &aOption); // rect.adjust(0, 0, 1, 1); // paintThinFrame(painter, rect.adjusted(1, 1, 1, 1), option->palette, -20, 0); #if 0 // grip const int o = 5; const int s = 6; if (option->orientation == Qt::Horizontal) { int d = (rect.width() - 2) / 2; rect.adjust(d, 0, -d, 0); rect.translate(-s, 0); } else { int d = (rect.height() - 2) / 2; rect.adjust(0, d, 0, -d); rect.translate(0, -s); } for (int k = -1; k < 2; ++k) { if (option->orientation == Qt::Horizontal) { painter->fillRect(rect.adjusted(0, o, 0, -o), QColor(0, 0, 0, 30)); painter->fillRect(rect.adjusted(1, o, 1, -o), QColor(255, 255, 255, 80)); rect.translate(s, 0); } else { painter->fillRect(rect.adjusted(o, 0, -o, 0), QColor(0, 0, 0, 30)); painter->fillRect(rect.adjusted(o, 1, -o, 1), QColor(255, 255, 255, 80)); rect.translate(0, s); } } #endif } #if 0 painter->fillRect(style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderGroove, widget), QColor(0, 0, 0, 70)); if (option->subControls & QStyle::SC_SliderGroove) { painter->fillRect(style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderGroove, widget), QColor(255, 0, 0, 70)); } if (option->subControls & QStyle::SC_SliderHandle) { painter->fillRect(style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderHandle, widget), QColor(0, 100, 255, 70)); } if (option->subControls & QStyle::SC_SliderTickmarks) { painter->fillRect(style->subControlRect(QStyle::CC_Slider, option, QStyle::SC_SliderTickmarks, widget), QColor(0, 255, 0, 170)); } #endif } /*-----------------------------------------------------------------------*/ QRect subControlRectSlider(const QStyleOptionSlider *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { QRect rect = ((QCommonStyle *) style)->QCommonStyle::subControlRect(QStyle::CC_Slider, option, subControl, widget); switch (subControl) { case QStyle::SC_SliderGroove: case QStyle::SC_SliderTickmarks: case QStyle::SC_SliderHandle: default: break; } return rect; #if 0 /* option->orientation option->tickPosition: QSlider::TicksAbove | QSlider::TicksBelow option->state option->tickInterval */ switch (subControl) { case SC_SliderGrove: case SC_SliderTickmarks: case SC_SliderHandle: } #endif } /* * skulpture_spinbox.cpp * */ #include "skulpture_p.h" #include #include #include /*-----------------------------------------------------------------------*/ extern void paintScrollArrow(QPainter *painter, const QStyleOption *option, Qt::ArrowType arrow, bool spin); void paintIndicatorSpinDown(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::DownArrow, true); } void paintIndicatorSpinUp(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::UpArrow, true); } void paintIndicatorSpinMinus(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::LeftArrow, true); } void paintIndicatorSpinPlus(QPainter *painter, const QStyleOption *option) { paintScrollArrow(painter, option, Qt::RightArrow, true); } /*-----------------------------------------------------------------------*/ QRect subControlRectSpinBox(const QStyleOptionSpinBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { int fw = option->frame ? style->pixelMetric(QStyle::PM_SpinBoxFrameWidth, option, widget) : 0; int bw; #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (option->buttonSymbols == QAbstractSpinBox::NoButtons) { bw = 0; } else #endif { bw = qMax(style->pixelMetric(QStyle::PM_ScrollBarExtent, option, widget), qApp->globalStrut().width()); } bool strutMode = qApp->globalStrut().height() > (option->rect.height() >> 1); QRect rect; switch (subControl) { case QStyle::SC_SpinBoxUp: case QStyle::SC_SpinBoxDown: { int h = option->rect.height() - 2 * fw; int t = option->rect.top() + fw; int l = option->rect.right() - bw - fw + 1; if (strutMode) { if (subControl == QStyle::SC_SpinBoxUp) { l -= bw; } } else { if (subControl == QStyle::SC_SpinBoxDown) { t += (h >> 1); } h = (h + 1) >> 1; } rect = QRect(l, t, bw, h); break; } case QStyle::SC_SpinBoxEditField: { if (strutMode) { bw *= 2; } rect = option->rect.adjusted(fw, fw, -fw - bw, -fw); break; } case QStyle::SC_SpinBoxFrame: default: // avoid warning rect = option->rect; break; } return style->visualRect(option->direction, option->rect, rect); } /*-----------------------------------------------------------------------*/ void paintComplexControlArea(QPainter *painter, const QStyleOption *option) { // configuration const bool paintBackground = true; const bool paintSeparator = true; // background QColor color; if (paintBackground && option->state & QStyle::State_Enabled) { color = option->palette.color(QPalette::Window); // ### should arrow areas have hover highlight? if (false && option->state & QStyle::State_MouseOver) { #if QT_VERSION >= QT_VERSION_CHECK(4, 3, 0) color = color.lighter(110); #else color = color.light(110); #endif } else { #if QT_VERSION >= QT_VERSION_CHECK(4, 3, 0) color = color.lighter(107); #else color = color.light(107); #endif } } else { color = option->palette.color(QPalette::Base); } painter->fillRect(option->rect, color); // separator if (paintSeparator) { QRect rect = option->rect; if (option->direction == Qt::LeftToRight) { rect.setWidth(1); } else { rect.setLeft(rect.left() + rect.width() - 1); } painter->fillRect(rect, shaded_color(option->palette.color(QPalette::Window), -5)); } } static void paintSpinBoxUpDown(QPainter *painter, const QStyleOptionSpinBox *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { QStyleOption opt; opt.QStyleOption::operator=(*option); opt.rect = style->subControlRect(QStyle::CC_SpinBox, option, subControl, widget); if (!(option->activeSubControls & subControl)) { opt.state &= ~(QStyle::State_Sunken | QStyle::State_On | QStyle::State_MouseOver); } // button background paintComplexControlArea(painter, &opt); // button symbol QStyle::PrimitiveElement pe; if (!(option->stepEnabled & (subControl == QStyle::SC_SpinBoxUp ? QAbstractSpinBox::StepUpEnabled : QAbstractSpinBox::StepDownEnabled))) { opt.state &= ~(QStyle::State_Enabled | QStyle::State_MouseOver); opt.palette.setCurrentColorGroup(QPalette::Disabled); } // micro adjustments if (subControl == QStyle::SC_SpinBoxUp) { opt.rect.translate(0, 1); } else if (opt.rect.height() & 1) { opt.rect.translate(0, -1); } switch (option->buttonSymbols) { case QAbstractSpinBox::PlusMinus: pe = subControl == QStyle::SC_SpinBoxUp ? QStyle::PE_IndicatorSpinPlus : QStyle::PE_IndicatorSpinMinus; break; default: pe = subControl == QStyle::SC_SpinBoxUp ? QStyle::PE_IndicatorSpinUp : QStyle::PE_IndicatorSpinDown; break; } style->drawPrimitive(pe, &opt, painter, widget); } void paintSpinBox(QPainter *painter, const QStyleOptionSpinBox *option, const QWidget *widget, const QStyle *style) { // up/down controls #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (option->buttonSymbols != QAbstractSpinBox::NoButtons) #endif { for (uint sc = QStyle::SC_SpinBoxUp; sc != QStyle::SC_SpinBoxFrame; sc <<= 1) { if (option->subControls & sc) { paintSpinBoxUpDown(painter, option, (QStyle::SubControl) sc, widget, style); } } } // frame if (option->frame && (option->subControls & QStyle::SC_SpinBoxFrame)) { QStyleOptionFrame frameOpt; frameOpt.QStyleOption::operator=(*option); frameOpt.rect = style->subControlRect(QStyle::CC_SpinBox, option, QStyle::SC_SpinBoxFrame, widget); frameOpt.state |= QStyle::State_Sunken; frameOpt.lineWidth = style->pixelMetric(QStyle::PM_SpinBoxFrameWidth, &frameOpt, widget); frameOpt.midLineWidth = 0; style->drawPrimitive(QStyle::PE_FrameLineEdit, &frameOpt, painter, widget); } } /* * skulpture_tabs.cpp * */ #include "skulpture_p.h" #include #include /*-----------------------------------------------------------------------*/ enum Pos { North, South, West, East }; static inline Pos tabPos(QTabBar::Shape shape) { return Pos(int(shape) & 3); } static inline bool isVertical(QTabBar::Shape shape) { return (int(shape) & 2); } struct Affinity { int x1, y1, x2, y2; }; static inline void tabAffinity(QTabBar::Shape shape, Affinity &affinity, int amount) { affinity.x1 = affinity.y1 = affinity.x2 = affinity.y2 = 0; switch (tabPos(shape)) { case North: affinity.y1 = amount; break; case South: affinity.y2 = -amount; break; case West: affinity.x1 = amount; break; case East: affinity.x2 = -amount; break; } } /*-----------------------------------------------------------------------*/ #if 0 enum TabState { TS_New, TS_Removed, TS_Inactive, TS_HoverAnim, TS_Hover, TS_ActiveAnim, TS_Active, TS_Moved, TS_LabelChanged // text, icon or color changed TS_StateChanged // disabled changed }; class TabAnim { qreal pos; qreal speed; int color; }; class Tab { public: TabState state; TabAnim anim; #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) QStyleOptionTabV3 oldOption; #else QStyleOptionTabV2 oldOption; #endif }; /*-----------------------------------------------------------------------*/ class TabBarState { public: TabBarState() : active_tab(0), hover_tab(0) { } public: QList tabs; Tab *active_tab; Tab *hover_tab; int hover_x; int hover_y; int hover_counter; }; const TabBarState *SkulpturePrivate::tabBarState(const QWidget *widget) { if (qobject_cast(widget)) { if ((int i = tabBarStates.indexOf(widget))) { return tabBarStates.at(i); } // add state if not found TabBarState *state = new TabBarState; if (state) { } } return 0; } #endif /*-----------------------------------------------------------------------*/ static void paintTabBase(QPainter *painter, const QRect &r, const QStyleOption *option, QTabBar::Shape shape) { QRect rect = r; #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) if (!isVertical(shape) && option->version >= QStyleOptionTabBarBaseV2::Version) { if (((const QStyleOptionTabBarBaseV2 *) option)->documentMode) { rect.adjust(-10, 0, 10, 0); } } #endif if (true /*option->state & QStyle::State_Enabled*/) { QLinearGradient tabGradient(rect.topLeft(), isVertical(shape) ? rect.topRight() : rect.bottomLeft()); tabGradient.setColorAt(0.0, option->palette.color(QPalette::Window).darker(118)); tabGradient.setColorAt(1.0, option->palette.color(QPalette::Window).darker(105)); painter->fillRect(rect.adjusted(1, 1, -1, -1), tabGradient); } else { painter->fillRect(rect.adjusted(1, 1, -1, -1), option->palette.color(QPalette::Window).darker(106)); } paintThinFrame(painter, rect.adjusted(1, 1, -1, -1), option->palette, -20, -40); paintRecessedFrameShadow(painter, rect.adjusted(2, 2, -2, -2), RF_Small); } void paintFrameTabBarBase(QPainter *painter, const QStyleOptionTabBarBase *option, const QWidget *widget) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) if (option->version >= QStyleOptionTabBarBaseV2::Version) { if (((const QStyleOptionTabBarBaseV2 *) option)->documentMode) { QRect r = option->rect; if (tabPos(option->shape) == North && r.top() > 0) { r.setTop(0); } else if (tabPos(option->shape) == South && qobject_cast(widget) && widget->rect().bottom() != r.bottom()) { r.setBottom(widget->rect().bottom()); } else { return; } painter->save(); painter->setClipRect(r); paintTabBase(painter, r, option, option->shape); paintThinFrame(painter, r.adjusted(-10, 0, 10, 0), option->palette, 60, -20); painter->restore(); return; } } #else Q_UNUSED(widget); #endif // ### remove clipping painter->save(); QRect r = option->rect; #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) r = r.united(option->tabBarRect); #else r = r.unite(option->tabBarRect); #endif QRegion region(r); region -= option->tabBarRect; painter->setClipRegion(region); paintTabBase(painter, r, option, option->shape); QRect rect = r; #if 0 Affinity affinity; tabAffinity(option->shape, affinity, 1); rect.adjust(affinity.x2, affinity.y2, affinity.x1, affinity.y1); #endif paintThinFrame(painter, rect, option->palette, 60, -20); painter->restore(); } void paintTabWidgetFrame(QPainter *painter, const QStyleOptionTabWidgetFrame *option, const QWidget *widget) { Q_UNUSED(widget); QRect base = option->rect; int s = (isVertical(option->shape) ? option->tabBarSize.width() : option->tabBarSize.height()); if (s < 2) s = 2; if (isVertical(option->shape)) { base.setWidth(s); } else { base.setHeight(s); } const int overlap = 2; switch (tabPos(option->shape)) { case North: base.translate(0, -(s - overlap)); break; case West: base.translate(-(s - overlap), 0); break; case South: base.translate(0, option->rect.height() - overlap); break; case East: base.translate(option->rect.width() - overlap, 0); break; } if (s != 2) { paintTabBase(painter, base, option, option->shape); } Affinity affinity; tabAffinity(option->shape, affinity, -(s - overlap)); // painter->save(); // painter->setClipRect(base); paintThinFrame(painter, option->rect.adjusted(affinity.x1, affinity.y1, affinity.x2, affinity.y2), option->palette, 60, -20); paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -40, 160); #if 1 painter->save(); painter->setPen(QPen(QColor(0, 0, 0, 20), 1)); painter->drawLine(option->rect.x() + 1, option->rect.bottom(), option->rect.right() - 1, option->rect.bottom()); painter->drawLine(option->rect.right(), option->rect.top() + 1, option->rect.right(), option->rect.bottom()); painter->restore(); #endif #if 0 QRect r = option->rect.adjusted(2, 2, -2, -2); painter->fillRect(r, option->palette.color(QPalette::Window)); QLinearGradient gradient(r.topLeft(), r.bottomLeft()); gradient.setColorAt(0.0, QColor(255, 255, 255, 0)); gradient.setColorAt(1.0, QColor(0, 0, 0, 20)); painter->fillRect(r, gradient); #endif // painter->restore(); } /*-----------------------------------------------------------------------*/ #define TAB_SHIFT 1 void paintTabBarTabShape(QPainter *painter, const QStyleOptionTab *option, const QWidget *widget, const QStyle *style) { Q_UNUSED(style); const QColor tabBackgroundColor = option->palette.color(QPalette::Active, QPalette::Window); bool mouse = (option->state & QStyle::State_MouseOver) && !(option->state & QStyle::State_Selected) && (option->state & QStyle::State_Enabled); QRect c_rect = option->rect; bool konq = false; if (widget && widget->parentWidget()) { if (!qstrcmp(widget->metaObject()->className(), "KTabBar") && !qstrcmp(widget->parentWidget()->metaObject()->className(), "KonqFrameTabs")) { konq = true; #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) if (option->version >= QStyleOptionTabV3::Version) { if (((const QStyleOptionTabV3 *) option)->documentMode) { konq = false; } } #endif } } if (konq || (widget && !(qobject_cast(widget->parentWidget())))) { // ### remove clipping painter->save(); painter->setClipRect(option->rect); QRect rect = widget->rect(); if (konq) { rect.adjust(-10, 0, 10, 0); } paintTabBase(painter, rect, option, option->shape); #if 0 Affinity affinity; tabAffinity(option->shape, affinity, 1); rect.adjust(affinity.x2, affinity.y2, affinity.x1, affinity.y1); #endif paintThinFrame(painter, rect, option->palette, 60, -20); painter->restore(); } switch (tabPos(option->shape)) { case North: c_rect.adjust(1, 1, -2, 0); if (option->position != QStyleOptionTab::Beginning && option->position != QStyleOptionTab::OnlyOneTab) { c_rect.adjust(-1, 0, 0, 0); } if (option->state & QStyle::State_Selected) { painter->fillRect(c_rect.adjusted(0, 0, -1, 0), tabBackgroundColor); if (option->state & QStyle::State_Enabled) { QLinearGradient gradient(c_rect.topLeft(), c_rect.bottomLeft()); #if 0 QColor c = option->palette.color(QPalette::Highlight); gradient.setColorAt(0.0, c); gradient.setColorAt(0.2, QColor(255, 255, 255, 20)); gradient.setColorAt(1.0, QColor(255, 255, 255, 0)); #else gradient.setColorAt(0.0, shaded_color(tabBackgroundColor, 20)); gradient.setColorAt(1.0, shaded_color(tabBackgroundColor, 0)); #endif painter->fillRect(c_rect.adjusted(0, 0, -1, 0), gradient); } // ### flat tabs: 50->20, 180->80 // painter->fillRect(c_rect, QColor(255, 0, 0, 100)); Affinity affinity; tabAffinity(option->shape, affinity, 1); paintThinFrame(painter, c_rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1), option->palette, -50, 180); // shadows painter->fillRect(QRect(c_rect.right() + 1, c_rect.top(), 1, c_rect.height()), QColor(0, 0, 0, 25)); painter->fillRect(QRect(c_rect.right() + 2, c_rect.top(), 1, c_rect.height()), QColor(0, 0, 0, 10)); } else { // ### install clip painter->save(); Affinity affinity; tabAffinity(option->shape, affinity, -1); painter->setClipRect(option->rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1)); painter->fillRect(c_rect.adjusted(1, mouse ? 1 : 2, -1, -1), mouse ? tabBackgroundColor.darker(104) : tabBackgroundColor.darker(108)); paintThinFrame(painter, c_rect.adjusted(1, mouse ? 1 : 2, -1, 1), option->palette, -40, 90); // shadows painter->fillRect(QRect(c_rect.right(), c_rect.top() + 3, 1, c_rect.height() - 4), QColor(0, 0, 0, 15)); painter->fillRect(QRect(c_rect.right() + 1, c_rect.top() + 3, 1, c_rect.height() - 4), QColor(0, 0, 0, 5)); painter->restore(); // shadow below base painter->fillRect(QRect(c_rect.left() + 1, c_rect.bottom() - 1, c_rect.width() - 2, 1), QColor(0, 0, 0, 10)); painter->fillRect(QRect(c_rect.left() + 1, c_rect.bottom() - 2, c_rect.width() - 2, 1), QColor(0, 0, 0, 4)); } break; case South: c_rect.adjust(1, 0, -2, -1); if (option->position != QStyleOptionTab::Beginning && option->position != QStyleOptionTab::OnlyOneTab) { c_rect.adjust(-1, 0, 0, 0); } if (option->state & QStyle::State_Selected) { painter->fillRect(c_rect.adjusted(0, 0, -1, 0), tabBackgroundColor); if (option->state & QStyle::State_Enabled) { QLinearGradient gradient(c_rect.topLeft(), c_rect.bottomLeft()); gradient.setColorAt(0.0, shaded_color(tabBackgroundColor, 0)); gradient.setColorAt(1.0, shaded_color(tabBackgroundColor, -5)); painter->fillRect(c_rect.adjusted(0, 0, -1, 0), gradient); } Affinity affinity; tabAffinity(option->shape, affinity, 1); paintThinFrame(painter, c_rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1), option->palette, -50, 180); //paintThinFrame(painter, c_rect.adjusted(0, -1, 0, 0), option->palette, -50, 180); // shadows painter->fillRect(QRect(c_rect.right() + 1, c_rect.top() + 1, 1, c_rect.height() - 1), QColor(0, 0, 0, 25)); painter->fillRect(QRect(c_rect.right() + 2, c_rect.top() + 1, 1, c_rect.height() - 1), QColor(0, 0, 0, 10)); painter->fillRect(QRect(c_rect.left() + 1, c_rect.bottom() + 1, c_rect.width(), 1), QColor(0, 0, 0, 20)); } else { // ### install clip painter->save(); Affinity affinity; tabAffinity(option->shape, affinity, -1); painter->setClipRect(option->rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1)); painter->fillRect(c_rect.adjusted(1, 1, -1, mouse ? -1 : -2), mouse ? tabBackgroundColor.darker(104) : tabBackgroundColor.darker(108)); paintThinFrame(painter, c_rect.adjusted(1, -1, -1, mouse ? -1 : -2), option->palette, -40, 90); // shadows painter->fillRect(QRect(c_rect.right(), c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 15)); painter->fillRect(QRect(c_rect.right() + 1, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 5)); if (!mouse) { painter->fillRect(QRect(c_rect.left() + 2, c_rect.bottom() - 1, c_rect.width() - 3, 1), QColor(0, 0, 0, 10)); } painter->restore(); // shadow below base painter->fillRect(QRect(c_rect.left() + 1, c_rect.top() + 1, c_rect.width() - 2, 1), QColor(0, 0, 0, 30)); painter->fillRect(QRect(c_rect.left() + 1, c_rect.top() + 2, c_rect.width() - 2, 1), QColor(0, 0, 0, 15)); painter->fillRect(QRect(c_rect.left() + 1, c_rect.top() + 3, c_rect.width() - 2, 1), QColor(0, 0, 0, 8)); painter->fillRect(QRect(c_rect.left() + 1, c_rect.top() + 4, c_rect.width() - 2, 1), QColor(0, 0, 0, 4)); } break; case West: c_rect.adjust(1, 1, 0, -2); if (option->state & QStyle::State_Selected) { painter->fillRect(c_rect.adjusted(0, 0, 0, -1), tabBackgroundColor); if (option->state & QStyle::State_Enabled) { QLinearGradient gradient(c_rect.topLeft(), c_rect.topRight()); gradient.setColorAt(0.0, shaded_color(tabBackgroundColor, 20)); gradient.setColorAt(1.0, shaded_color(tabBackgroundColor, 0)); painter->fillRect(c_rect.adjusted(0, 0, 0, -1), gradient); } Affinity affinity; tabAffinity(option->shape, affinity, 1); paintThinFrame(painter, c_rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1), option->palette, -50, 180); // shadows painter->fillRect(QRect(c_rect.left(), c_rect.bottom() + 1, c_rect.width(), 1), QColor(0, 0, 0, 25)); painter->fillRect(QRect(c_rect.left(), c_rect.bottom() + 2, c_rect.width(), 1), QColor(0, 0, 0, 10)); } else { // ### install clip painter->save(); Affinity affinity; tabAffinity(option->shape, affinity, -1); painter->setClipRect(option->rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1)); painter->fillRect(c_rect.adjusted(mouse ? 1 : 2, 1, 1, -1), mouse ? tabBackgroundColor.darker(104) : tabBackgroundColor.darker(108)); paintThinFrame(painter, c_rect.adjusted(mouse ? 1 : 2, 1, 1, -1), option->palette, -40, 90); // shadows painter->fillRect(QRect(c_rect.left() + 2, c_rect.bottom() + 0, c_rect.width() - 3, 1), QColor(0, 0, 0, 15)); painter->fillRect(QRect(c_rect.left() + 2, c_rect.bottom() + 1, c_rect.width() - 3, 1), QColor(0, 0, 0, 5)); painter->restore(); // shadow below base painter->fillRect(QRect(c_rect.right() - 1, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 10)); painter->fillRect(QRect(c_rect.right() - 2, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 4)); } break; case East: c_rect.adjust(0, 1, -1, -2); if (option->state & QStyle::State_Selected) { painter->fillRect(c_rect.adjusted(0, 0, 0, -1), tabBackgroundColor); if (option->state & QStyle::State_Enabled) { QLinearGradient gradient(c_rect.topLeft(), c_rect.topRight()); gradient.setColorAt(0.0, shaded_color(tabBackgroundColor, 0)); gradient.setColorAt(1.0, shaded_color(tabBackgroundColor, 10)); painter->fillRect(c_rect.adjusted(0, 0, 0, -1), gradient); } Affinity affinity; tabAffinity(option->shape, affinity, 1); paintThinFrame(painter, c_rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1), option->palette, -50, 180); // shadows painter->fillRect(QRect(c_rect.left(), c_rect.bottom() + 1, c_rect.width(), 1), QColor(0, 0, 0, 25)); painter->fillRect(QRect(c_rect.left(), c_rect.bottom() + 2, c_rect.width(), 1), QColor(0, 0, 0, 10)); painter->fillRect(QRect(c_rect.right() + 1, c_rect.top() + 1, 1, c_rect.height()), QColor(0, 0, 0, 20)); } else { // ### install clip painter->save(); Affinity affinity; tabAffinity(option->shape, affinity, -1); painter->setClipRect(option->rect.adjusted(affinity.x2, affinity.y2, affinity.x1, affinity.y1)); painter->fillRect(c_rect.adjusted(-2, 1, mouse ? -1 : -2, -1), mouse ? tabBackgroundColor.darker(104) : tabBackgroundColor.darker(108)); paintThinFrame(painter, c_rect.adjusted(-2, 1, mouse ? -1 : -2, -1), option->palette, -40, 90); // shadows painter->fillRect(QRect(c_rect.left() + 1, c_rect.bottom() + 0, c_rect.width() - 3, 1), QColor(0, 0, 0, 15)); painter->fillRect(QRect(c_rect.left() + 1, c_rect.bottom() + 1, c_rect.width() - 3, 1), QColor(0, 0, 0, 5)); painter->restore(); // shadow below base painter->fillRect(QRect(c_rect.left() + 1, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 20)); painter->fillRect(QRect(c_rect.left() + 2, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 10)); painter->fillRect(QRect(c_rect.left() + 3, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 5)); // painter->fillRect(QRect(c_rect.left() + 4, c_rect.top() + 1, 1, c_rect.height() - 2), QColor(0, 0, 0, 4)); } break; } } #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) void paintIndicatorTabClose(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style) { int offset = 0; QTabBar::Shape shape = QTabBar::RoundedNorth; if (widget) { if (QTabBar *tabbar = qobject_cast(widget->parentWidget())) { offset = TAB_SHIFT; shape = tabbar->shape(); for (int i = 0; i < tabbar->count(); ++i) { if (tabbar->tabRect(i).contains(widget->mapToParent(QPoint(1, 1)))) { if (i == tabbar->currentIndex()) { offset = 0; } else if (tabbar->tabRect(i).contains(tabbar->mapFromGlobal(QCursor::pos()))) { offset = 0; } break; } } if (false /*tabPos(shape) == East || tabPos(shape) == South*/) { offset += 1; } } } QIcon::Mode iconMode = QIcon::Normal; painter->save(); if (option->state & QStyle::State_Enabled) { if (option->state & QStyle::State_MouseOver || option->state & QStyle::State_Sunken) { // paintThinFrame(painter, option->rect, option->palette, 90, -30); iconMode = QIcon::Active; //painter->fillRect(option->rect.adjusted(1, 1, -1, -1), QColor(220, 0, 0)); if (!(option->state & QStyle::State_Sunken)) { // paintThinFrame(painter, option->rect.adjusted(1, 1, -1, -1), option->palette, -60, 180); } else { //iconMode = QIcon::Selected; } } else { painter->setOpacity(0.7); } } else { //iconMode = QIcon::Disabled; painter->setOpacity(0.7); } QRect r = QRect(option->rect.center() - QPoint(option->state & QStyle::State_Sunken ? 3 : 4, option->state & QStyle::State_Sunken ? 3 : 4), QSize(10, 10)); if (offset) { Affinity affinity; tabAffinity(shape, affinity, offset); r.translate(affinity.x1 + affinity.x2, affinity.y1 + affinity.y2); } painter->drawPixmap(r, style->standardIcon(QStyle::SP_TitleBarCloseButton, option, widget).pixmap(10, 10, iconMode)); painter->restore(); } #endif void paintTabBarTabLabel(QPainter *painter, const QStyleOptionTab *option, const QWidget *widget, const QStyle *style) { // bool mouse = (option->state & QStyle::State_MouseOver) && !(option->state & QStyle::State_Selected) && (option->state & QStyle::State_Enabled); // painter->save(); #if 0 if (!(option->state & QStyle::State_Selected)) { if (mouse) { painter->setOpacity(0.7); } else { painter->setOpacity(0.5); } } else { painter->setOpacity(0.8); } // QFont font(painter->font()); // font.setBold(true); // painter->setFont(font); #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) QStyleOptionTabV3 opt; #else QStyleOptionTabV2 opt; #endif int offset = TAB_SHIFT; if (option->state & QStyle::State_Selected || (option->state & QStyle::State_MouseOver && option->state & QStyle::State_Enabled)) { offset = 0; } if (option->version > 1) { opt = *((QStyleOptionTabV2 *) option); } else { opt = *option; } Affinity affinity; tabAffinity(option->shape, affinity, offset); opt.rect.translate(affinity.x1 + affinity.x2, affinity.y1 + affinity.y2); switch (tabPos(option->shape)) { case North: opt.rect.adjust(-2, 1, -1, 1); break; case South: opt.rect.adjust(-2, 0, -1, 0); break; case West: case East: painter->save(); QMatrix mat; if (tabPos(option->shape) == West) { opt.rect.adjust(3, 0, 3, 0); } else { opt.rect.adjust(-1, 0, -1, 0); } QPointF c = opt.rect.center(); mat.translate(c.x(), c.y()); mat.rotate(tabPos(option->shape) == West ? -90 : 90); mat.translate(-c.x(), -c.y()); opt.rect = mat.mapRect(opt.rect); painter->setMatrix(mat, true); opt.shape = (QTabBar::Shape) 0; break; } ((QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_TabBarTabLabel, &opt, painter, widget); if (isVertical(option->shape)) { painter->restore(); } } /* * skulpture_text.cpp * */ #include "skulpture_p.h" #include #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) #include #endif #include #include #include #include #include /*-----------------------------------------------------------------------*/ void SkulptureStyle::Private::removeCursorLine(QAbstractScrollArea *edit) { Q_UNUSED (edit); if (oldEdit) { oldEdit->viewport()->update(QRect(0, oldCursorTop, oldCursorWidth, oldCursorHeight)); oldEdit = 0; } } void SkulptureStyle::Private::updateCursorLine(QAbstractScrollArea *edit, const QRect &cursorRect) { const int highlightMargin = qMin(2, widgetSize); QRect cursorLine = cursorRect; cursorLine.setLeft(0); cursorLine.setWidth(edit->viewport()->width()); cursorLine.adjust(0, -highlightMargin, 0, highlightMargin); if (edit != oldEdit || cursorLine.top() != oldCursorTop || cursorLine.width() != oldCursorWidth || cursorLine.height() != oldCursorHeight || edit->viewport()->height() != oldHeight) { removeCursorLine(edit); oldEdit = edit; oldCursorTop = cursorLine.top(); oldCursorWidth = cursorLine.width(); oldCursorHeight = cursorLine.height(); oldHeight = edit->viewport()->height(); edit->viewport()->update(cursorLine); } } void SkulptureStyle::Private::paintCursorLine(QAbstractScrollArea *edit) { if (edit == oldEdit) { QRect cursorLine = QRect(0, oldCursorTop, oldCursorWidth, oldCursorHeight); QPainter painter(edit->viewport()); QPalette palette = edit->palette(); QColor color = palette.color(QPalette::Highlight); color.setAlpha(40); painter.fillRect(cursorLine, color); if (edit->window()->testAttribute(Qt::WA_KeyboardFocusChange)) { #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) color = palette.color(QPalette::Highlight).darker(120); #else color = palette.color(QPalette::Highlight).dark(120); #endif color.setAlpha(120); painter.fillRect(cursorLine.adjusted(0, cursorLine.height() - 3, 0, -2), color); } } } #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) void SkulptureStyle::Private::handleCursor(QPlainTextEdit *edit) { if (edit->hasFocus() && !edit->isReadOnly()) { QStyleOption option; option.initFrom(edit); int cursorWidth = q->SkulptureStyle::pixelMetric(PM_TextCursorWidth, &option, edit); if (edit->cursorWidth() != cursorWidth) { edit->setCursorWidth(cursorWidth); } updateCursorLine(edit, edit->cursorRect()); } else { if (edit == oldEdit) { removeCursorLine(edit); } } } #endif void SkulptureStyle::Private::handleCursor(QTextEdit *edit) { if (edit->hasFocus() && !edit->isReadOnly()) { QStyleOption option; option.initFrom(edit); #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) int cursorWidth = q->SkulptureStyle::pixelMetric(PM_TextCursorWidth, &option, edit); #else int cursorWidth = q->SkulptureStyle::pixelMetric((QStyle::PixelMetric)((int) PM_CustomBase + 1), &option, edit); #endif if (edit->cursorWidth() != cursorWidth) { edit->setCursorWidth(cursorWidth); } #endif updateCursorLine(edit, edit->cursorRect()); } else { if (edit == oldEdit) { removeCursorLine(edit); } } } /*-----------------------------------------------------------------------*/ void SkulptureStyle::Private::updateTextEditMargins(QTextEdit *edit) { int margin = 1 + edit->fontMetrics().height() / 5; if (margin > 4) margin = 4; if (qobject_cast(edit)) { margin = edit->fontMetrics().height(); if (margin < 4 || edit->height() < 4 * edit->fontMetrics().height()) { margin = 4; } } if (margin < 2 || edit->height() < 2 * edit->fontMetrics().height()) { margin = 2; } QTextDocument *doc = edit->document(); // printf("doc: %p\n", doc); if (!doc) return; if (doc->isEmpty()) { // create valid root frame QTextCursor cursor(doc); } QTextFrame *root = doc->rootFrame(); // printf("root: %p\n", root); if (!root) return; QTextFrameFormat format = root->frameFormat(); if (!format.isValid()) return; if (format.margin() == 2.0 && margin != 2) { // printf("set margin %d\n", margin); // ### crash on setText(), disable signals disconnect(edit, SIGNAL(textChanged()), &mapper, SLOT(map())); doc->blockSignals(true); format.setMargin(margin); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) if (margin < 12) { format.setTopMargin(widgetSize - ((textShift + 1) >> 1)); format.setBottomMargin(widgetSize + ((textShift + 1) >> 1)); } #endif root->setFrameFormat(format); // edit->insertPlainText(QLatin1String("")); // edit->update(); doc->blockSignals(false); connect(edit, SIGNAL(textChanged()), &mapper, SLOT(map())); // clear undo buffer bool undo = edit->isUndoRedoEnabled(); edit->setUndoRedoEnabled(false); doc->setModified(false); // emit doc->contentsChanged(); edit->setUndoRedoEnabled(undo); // force relayout edit->resize(edit->size() + QSize(-1, 0)); edit->resize(edit->size() + QSize(1, 0)); } } void SkulptureStyle::Private::textEditSourceChanged(QWidget *widget) { if (QTextEdit *edit = qobject_cast(widget)) { updateTextEditMargins(edit); } } /*-----------------------------------------------------------------------*/ QRect SkulptureStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const { Q_UNUSED(enabled); return ParentStyle::itemTextRect(metrics, rectangle, alignment, true, text); } void SkulptureStyle::drawItemText(QPainter * painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const { int textShift = 0; if (!(alignment & (Qt::AlignTop | Qt::AlignBottom))) { textShift = d->verticalTextShift(painter->fontMetrics()); if (runtimeQtVersion() >= QT_VERSION_CHECK(4, 6, 1)) { if (textShift & 1 && ((painter->fontMetrics().height() ^ rectangle.height()) & 1)) { textShift -= 1; } } else { if (textShift & 1 && !(rectangle.height() & 1)) { textShift += 1; } } } ParentStyle::drawItemText(painter, textShift == 0 || textShift == -1 ? rectangle : rectangle.adjusted(0, (-textShift) >> 1, 0, (-textShift) >> 1), alignment, palette, enabled, text, textRole); } /* * skulpture_toolbar.cpp * */ #include "skulpture_p.h" #include #include #include #include /*-----------------------------------------------------------------------*/ #define PAINT_SEPARATOR 0 /*-----------------------------------------------------------------------*/ extern void paintCachedGrip(QPainter *painter, const QStyleOption *option, QPalette::ColorRole bgrole); void paintToolBarSeparator(QPainter *painter, const QStyleOptionToolBar *option) { #if 0 int d = 3; QRect rect(QRect(option->rect).center() - QPoint(d / 2, d / 2), QSize(d, d)); QStyleOption iOption; iOption.QStyleOption::operator=(*option); if (option->state & QStyle::State_Horizontal) { iOption.rect = rect.adjusted(1, 0, 1, 0); } else { iOption.rect = rect.adjusted(0, 1, 0, 1); } iOption.palette.setCurrentColorGroup(QPalette::Disabled); // iOption.state &= ~QStyle::State_Enabled; iOption.palette.setColor(QPalette::Button, iOption.palette.color(QPalette::Window)); paintCachedGrip(painter, &iOption, QPalette::Window); #else #if PAINT_SEPARATOR QRect rect = option->rect; if (option->state & QStyle::State_Horizontal) { // rect.adjust(2, 3, -2, -3); rect.adjust(2, -1, -2, 1); } else { // rect.adjust(3, 2, -3, -2); rect.adjust(-1, 2, 1, -2); } paintThinFrame(painter, rect, option->palette, 60, -20); #else Q_UNUSED(painter); Q_UNUSED(option); #endif #endif } /*-----------------------------------------------------------------------*/ void paintToolBarHandle(QPainter *painter, const QStyleOptionToolBar *option) { #if 1 int d = 5; QRect rect(QRect(option->rect).center() - QPoint(d / 2, d / 2), QSize(d, d)); QStyleOption iOption; iOption.QStyleOption::operator=(*option); iOption.rect = rect; iOption.palette.setCurrentColorGroup(QPalette::Disabled); // iOption.state &= ~QStyle::State_Enabled; iOption.palette.setColor(QPalette::Button, iOption.palette.color(QPalette::Window)); paintCachedGrip(painter, &iOption, QPalette::Window); #else QRect rect = option->rect; if (option->state & QStyle::State_Horizontal) { rect.adjust(2, 2, -2, -2); #if PAINT_SEPARATOR rect.adjust(0, 1, 0, 1); #endif } else { rect.adjust(2, 2, -2, -2); #if PAINT_SEPARATOR rect.adjust(1, 0, 1, 0); #endif } paintThinFrame(painter, rect.adjusted(-1, -1, 1, 1), option->palette, 60, -20); paintThinFrame(painter, rect, option->palette, -30, 80); #endif } /*-----------------------------------------------------------------------*/ void paintPanelToolBar(QPainter *painter, const QStyleOptionToolBar *option) { #if 0 QLinearGradient gradient(option->rect.topLeft(), option->rect.bottomLeft()); gradient.setColorAt(0.0, option->palette.color(QPalette::Window).lighter(105)); gradient.setColorAt(1.0, option->palette.color(QPalette::Window)); painter->fillRect(option->rect, gradient); QRect r; // r = option->rect; // r.setTop(r.top() + r.height() - 1); // painter->fillRect(r, option->palette.color(QPalette::Window).darker(105)); r = option->rect; r.setHeight(1); painter->fillRect(r, option->palette.color(QPalette::Window).darker(105)); // painter->fillRect(option->rect, option->palette.color(QPalette::Window)); // paintThinFrame(painter, option->rect, option->palette, -20, 60); #endif #if PAINT_SEPARATOR QRect r = option->rect; if (option->state & QStyle::State_Horizontal) { r.setHeight(2); } else { r.setWidth(2); } paintThinFrame(painter, r, option->palette, 60, -20); #else Q_UNUSED(painter); Q_UNUSED(option); #if 0 if (option->state & QStyle::State_Horizontal) { paintThinFrame(painter, option->rect.adjusted(-1, 0, 1, 0), option->palette, 80, -30); painter->fillRect(option->rect.adjusted(0, 1, 0, -1), QColor(200, 210, 230)); QLinearGradient toolBarGradient(option->rect.topLeft(), option->rect.bottomLeft()); toolBarGradient.setColorAt(0.0, QColor(0, 0, 0, 30)); toolBarGradient.setColorAt(0.05, QColor(0, 0, 0, 0)); #if 0 toolBarGradient.setColorAt(0.5, QColor(0, 0, 0, 10)); toolBarGradient.setColorAt(0.51, QColor(0, 0, 0, 30)); #endif toolBarGradient.setColorAt(0.8, QColor(0, 0, 0, 20)); toolBarGradient.setColorAt(1.0, QColor(0, 0, 0, 0)); painter->fillRect(option->rect.adjusted(0, 1, 0, -1), toolBarGradient); } else { paintThinFrame(painter, option->rect.adjusted(0, -1, 0, 1), option->palette, 80, -30); } #else // painter->fillRect(option->rect, QColor(0, 0, 0, 10)); #endif #endif } /*-----------------------------------------------------------------------*/ static inline bool inVerticalToolBar(const QStyleOption *option, const QWidget *widget) { // ### option->state does not reflect orientation Q_UNUSED(option); bool verticalBar = false; if (widget && widget->parentWidget()) { const QToolBar *toolBar = qobject_cast(widget->parentWidget()); // printf("toolbar: %p\n", toolBar); if (toolBar && toolBar->orientation() == Qt::Vertical) { verticalBar = true; } } return verticalBar; } /*-----------------------------------------------------------------------*/ // FIXME #if (QT_VERSION < QT_VERSION_CHECK(4, 3, 0)) #define HasMenu Menu #endif extern void paintMenuTitle(QPainter *painter, const QStyleOptionToolButton *option, const QWidget *widget, const QStyle *style); void paintToolButton(QPainter *painter, const QStyleOptionToolButton *option, const QWidget *widget, const QStyle *style) { if (widget) { QTabBar *bar = qobject_cast(widget->parentWidget()); if (bar) { // tabbar scroll button QStyleOptionToolButton opt = *option; if (int(bar->shape()) & 2) { opt.rect.adjust(4, 0, -4, -1); } else { opt.rect.adjust(0, 4, 0, -3); } painter->save(); painter->setClipRect(opt.rect); painter->fillRect(opt.rect, option->palette.color(QPalette::Window)); ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_ToolButton, &opt, painter, widget); painter->restore(); return; } else if (widget->objectName() == QLatin1String("qt_menubar_ext_button") || widget->objectName() == QLatin1String("qt_toolbar_ext_button")) { QStyleOptionToolButton opt = *option; /* do not render menu arrow, because extension buttons already have an arrow */ opt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu); ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_ToolButton, &opt, painter, widget); return; } else { const QToolButton *button = qobject_cast(widget); if (button && button->isDown() && button->toolButtonStyle() == Qt::ToolButtonTextBesideIcon) { if (widget->parentWidget() && widget->parentWidget()->inherits("KMenu")) { paintMenuTitle(painter, option, widget, style); return; } } } } if (option->features & QStyleOptionToolButton::HasMenu) { if (option->features & QStyleOptionToolButton::Menu) { if (option->subControls & QStyle::SC_ToolButton) { painter->save(); QStyleOptionToolButton opt = *option; opt.rect = style->subControlRect(QStyle::CC_ToolButton, option, QStyle::SC_ToolButton, widget); // opt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::Arrow); opt.arrowType = Qt::NoArrow; opt.features = 0; opt.subControls &= ~(QStyle::SC_ToolButtonMenu); opt.activeSubControls &= ~(QStyle::SC_ToolButtonMenu); if (opt.state & QStyle::State_Sunken) { opt.state |= QStyle::State_MouseOver; } if (inVerticalToolBar(option, widget)) { painter->setClipRect(opt.rect.adjusted(0, 0, 0, -1)); } else { painter->setClipRect(opt.rect.adjusted(option->direction == Qt::LeftToRight ? 0 : 1, 0, option->direction == Qt::LeftToRight ? -1 : 0, 0)); } ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_ToolButton, &opt, painter, widget); painter->restore(); } if (option->subControls & QStyle::SC_ToolButtonMenu) { painter->save(); QStyleOptionToolButton opt = *option; opt.rect = style->subControlRect(QStyle::CC_ToolButton, option, QStyle::SC_ToolButtonMenu, widget); QStyle::State state = option->state; state &= ~(QStyle::State_Sunken | QStyle::State_Raised); if (!(state & QStyle::State_AutoRaise) || (state & QStyle::State_MouseOver)) { state |= QStyle::State_Raised; } #if (QT_VERSION < QT_VERSION_CHECK(4, 5, 0)) if (runtimeQtVersion() < QT_VERSION_CHECK(4, 5, 0)) { if (option->activeSubControls & QStyle::SC_ToolButtonMenu) { state |= QStyle::State_Sunken; } } else #endif { if (option->state & QStyle::State_Sunken) { state |= QStyle::State_Sunken; } else { if (!(option->activeSubControls & QStyle::SC_ToolButtonMenu)) { state &= ~QStyle::State_MouseOver; } } } opt.state = state; if (inVerticalToolBar(option, widget)) { painter->setClipRect(opt.rect.adjusted(0, 1, 0, 0)); } else { painter->setClipRect(opt.rect.adjusted(option->direction == Qt::LeftToRight ? 1 : 0, 0, option->direction == Qt::LeftToRight ? 0 : -1, 0)); } if (state & (QStyle::State_Sunken | QStyle::State_On | QStyle::State_Raised)) { style->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, painter, widget); } painter->restore(); QRect r; if (inVerticalToolBar(option, widget)) { if (option->direction == Qt::LeftToRight) { r = QRect(opt.rect.right() - 9, opt.rect.top(), 7, opt.rect.height()); } else { r = QRect(3, opt.rect.top(), 7, opt.rect.height()); } } else { r = QRect(opt.rect.left(), opt.rect.bottom() - 9, opt.rect.width(), 7); } if (option->state & QStyle::State_Sunken) { if (option->direction == Qt::LeftToRight) { r.adjust(1, 1, 1, 1); } else { r.adjust(-1, 1, -1, 1); } } QFont font; font.setPixelSize(9); opt.fontMetrics = QFontMetrics(font); opt.rect = r; style->drawPrimitive(inVerticalToolBar(option, widget) ? QStyle::PE_IndicatorArrowRight : QStyle::PE_IndicatorArrowDown, &opt, painter, widget); } // painter->fillRect(opt.rect.adjusted(3, 3, -3, -3), Qt::red); } else { QStyleOptionToolButton opt = *option; opt.features &= ~QStyleOptionToolButton::HasMenu; ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_ToolButton, &opt, painter, widget); QRect r; if (option->direction == Qt::LeftToRight) { r = QRect(option->rect.right() - 6, option->rect.bottom() - 6, 5, 5); if (option->state & QStyle::State_Sunken) { r.adjust(1, 1, 1, 1); } } else { r = QRect(2, option->rect.bottom() - 6, 5, 5); if (option->state & QStyle::State_Sunken) { r.adjust(-1, 1, -1, 1); } } QFont font; font.setPixelSize(7); opt.fontMetrics = QFontMetrics(font); opt.rect = r; style->drawPrimitive(inVerticalToolBar(option, widget) ? QStyle::PE_IndicatorArrowRight : QStyle::PE_IndicatorArrowDown, &opt, painter, widget); } } else { ((QCommonStyle *) style)->QCommonStyle::drawComplexControl(QStyle::CC_ToolButton, option, painter, widget); } } void paintToolButtonLabel(QPainter *painter, const QStyleOptionToolButton *option, const QWidget *widget, const QStyle *style) { QStyleOptionToolButton opt = *option; if (option->state & QStyle::State_AutoRaise) { if (!(option->state & QStyle::State_Enabled) || !(option->state & QStyle::State_MouseOver)) { opt.palette.setColor(QPalette::ButtonText, opt.palette.color(QPalette::WindowText)); } } ((QCommonStyle *) style)->QCommonStyle::drawControl(QStyle::CE_ToolButtonLabel, &opt, painter, widget); } /*-----------------------------------------------------------------------*/ QRect subControlRectToolButton(const QStyleOptionToolButton *option, QStyle::SubControl subControl, const QWidget *widget, const QStyle *style) { QRect r = option->rect; if (option->features & QStyleOptionToolButton::Menu) { int pm = style->pixelMetric(QStyle::PM_MenuButtonIndicator, option, widget) - 2; bool verticalBar = inVerticalToolBar(option, widget); switch (subControl) { case QStyle::SC_ToolButton: if (verticalBar) { r.adjust(0, 0, 0, -pm); } else { r.adjust(0, 0, -pm, 0); } break; case QStyle::SC_ToolButtonMenu: if (verticalBar) { r.adjust(0, r.height() - pm - 2, 0, 0); } else { r.adjust(r.width() - pm - 2, 0, 0, 0); } break; default: break; } return style->visualRect(option->direction, option->rect, r); } return ((QCommonStyle *) style)->QCommonStyle::subControlRect(QStyle::CC_ToolButton, option, subControl, widget); } QSize sizeFromContentsToolButton(const QStyleOptionToolButton *option, const QSize &contentsSize, const QWidget *widget, const QStyle *style, int toolButtonSize) { QSize size = contentsSize + QSize(4, 4); if (toolButtonSize >= 0) { if (option->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { size += QSize(toolButtonSize, qMax(2, toolButtonSize)); } else { size += QSize(toolButtonSize, toolButtonSize); } } else { size += QSize(4, 4); } if (widget && !qstrcmp(widget->metaObject()->className(), "KAnimatedButton")) { return contentsSize + QSize(4, 4); } if (widget && !qstrcmp(widget->metaObject()->className(), "QtColorButton")) { return contentsSize + QSize(12, 12); } if (option->features & QStyleOptionToolButton::Menu) { int pm = style->pixelMetric(QStyle::PM_MenuButtonIndicator, option, widget); size -= QSize(pm, 0); pm -= 2; bool verticalBar = inVerticalToolBar(option, widget); if (verticalBar) { size += QSize(0, pm); } else { size += QSize(pm, 0); } } return size; } /*-----------------------------------------------------------------------*/ void SkulptureStyle::Private::updateToolBarOrientation(Qt::Orientation /*orientation */) { QToolBar *toolbar = static_cast(sender()); QList toolbuttons = toolbar->findChildren(); bool changed = false; Q_FOREACH (QToolButton *toolbutton, toolbuttons) { if (toolbutton->popupMode() == QToolButton::MenuButtonPopup) { // ### this hack forces Qt to invalidate the size hint Qt::ToolButtonStyle oldstyle = toolbutton->toolButtonStyle(); Qt::ToolButtonStyle newstyle; if (oldstyle == Qt::ToolButtonIconOnly) { newstyle = Qt::ToolButtonTextOnly; } else { newstyle = Qt::ToolButtonIconOnly; } toolbutton->setToolButtonStyle(newstyle); toolbutton->setToolButtonStyle(oldstyle); changed = true; } } if (changed) { // ### Qt does not update dragged toolbars... toolbar->updateGeometry(); } } /* * skulpture_p.cpp * */ #include "skulpture_p.h" #include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) #include #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) #include #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) #include #endif /*-----------------------------------------------------------------------*/ struct StyleSetting { enum Type { Bool, Char, Frame, Alignment, Orientation, Pixels, Points, Milliseconds, Color, Size, Parent, VarParent, Value }; const char * const label; int id; int type; int value; }; static const struct StyleSetting styleHintSettings[] = { /* entries are stricly sorted in Qt order for future lookup table */ { "General/EtchDisabledText", QStyle::SH_EtchDisabledText, StyleSetting::Bool, 1 }, /// { "General/DitherDisabledText", QStyle::SH_DitherDisabledText, StyleSetting::Bool, 0 }, { "ScrollBar/MiddleClickAbsolutePosition", QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, StyleSetting::Bool, 1 }, // { "ScrollBar/ScrollWhenPointerLeavesControl", QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl, StyleSetting::Parent, 0 }, // { "TabWidget/SelectMouseType", QStyle::SH_TabBar_SelectMouseType, StyleSetting::Parent, 0 }, /// { "TabWidget/TabBarAlignment", QStyle::SH_TabBar_Alignment, StyleSetting::Alignment, Qt::AlignCenter }, // { "ItemView/HeaderArrowAlignment", QStyle::SH_Header_ArrowAlignment, StyleSetting::Parent, 0 }, { "Slider/SnapToValue", QStyle::SH_Slider_SnapToValue, StyleSetting::Bool, 1 }, // { "Slider/SloppyKeyEvents", QStyle::SH_Slider_SloppyKeyEvents, StyleSetting::Parent, 0 }, // { "ProgressDialog/CenterCancelButton", QStyle::SH_ProgressDialog_CenterCancelButton, StyleSetting::Parent, 0 }, // { "ProgressDialog/TextLabelAlignment", QStyle::SH_ProgressDialog_TextLabelAlignment, StyleSetting::Parent, 0 }, { "PrintDialog/RightAlignButtons", QStyle::SH_PrintDialog_RightAlignButtons, StyleSetting::Bool, 1 }, // { "Window/SpaceBelowMenuBar", QStyle::SH_MainWindow_SpaceBelowMenuBar, StyleSetting::Parent, 0 }, { "FontDialog/SelectAssociatedText", QStyle::SH_FontDialog_SelectAssociatedText, StyleSetting::Bool, 1 }, { "Menu/AllowActiveAndDisabled", QStyle::SH_Menu_AllowActiveAndDisabled, StyleSetting::Bool, 1 }, // { "Menu/SpaceActivatesItem", QStyle::SH_Menu_SpaceActivatesItem, StyleSetting::Parent, 0 }, // ### dynamic { "Menu/SubMenuPopupDelay", QStyle::SH_Menu_SubMenuPopupDelay, StyleSetting::Milliseconds, 100 }, /// { "ItemView/FrameOnlyAroundContents", QStyle::SH_ScrollView_FrameOnlyAroundContents, StyleSetting::Bool, 0 }, { "Menu/AltKeyNavigation", QStyle::SH_MenuBar_AltKeyNavigation, StyleSetting::Bool, 1 }, { "ComboBox/ListMouseTracking", QStyle::SH_ComboBox_ListMouseTracking, StyleSetting::Bool, 1 }, { "Menu/MouseTracking", QStyle::SH_Menu_MouseTracking, StyleSetting::Bool, 1 }, { "Menu/BarMouseTracking", QStyle::SH_MenuBar_MouseTracking, StyleSetting::Bool, 1 }, // { "ItemView/ChangeHighlightOnFocus", QStyle::SH_ItemView_ChangeHighlightOnFocus, StyleSetting::Parent, 0 }, // { "Window/ShareActivation", QStyle::SH_Widget_ShareActivation, StyleSetting::Parent, 0 }, // { "MDI/Workspace/FillSpaceOnMaximize", QStyle::SH_Workspace_FillSpaceOnMaximize, StyleSetting::Parent, 0 }, // { "ComboBox/Popup", QStyle::SH_ComboBox_Popup, StyleSetting::Parent, 0 }, /// { "MDI/TitleBar/NoBorder", QStyle::SH_TitleBar_NoBorder, StyleSetting::Bool, 0 }, #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) /// { "Slider/StopMouseOverSlider", QStyle::SH_Slider_StopMouseOverSlider, StyleSetting::Bool, 1 }, #else /// { "Slider/StopMouseOverSlider", QStyle::SH_ScrollBar_StopMouseOverSlider, StyleSetting::Bool, 1 }, #endif // { "General/BlinkCursorWhenTextSelected", QStyle::SH_BlinkCursorWhenTextSelected, StyleSetting::Parent, 0 }, // { "General/FullWidthSelection", QStyle::SH_RichText_FullWidthSelection, StyleSetting::Bool, 1 }, // { "Menu/Scrollable", QStyle::SH_Menu_Scrollable, StyleSetting::Parent, 0 }, // { "GroupBox/TextLabelVerticalAlignment", QStyle::SH_GroupBox_TextLabelVerticalAlignment, StyleSetting::Parent, 0 }, // ### dynamic { "GroupBox/TextLabelColor", QStyle::SH_GroupBox_TextLabelColor, StyleSetting::Color, 0xFF000000 }, // { "Menu/SloppySubMenus", QStyle::SH_Menu_SloppySubMenus, StyleSetting::Parent, 0 }, // ### dynamic { "ItemView/GridLineColor", QStyle::SH_Table_GridLineColor, StyleSetting::Color, 0xFFD0D0D0 }, // ### dynamic { "LineEdit/PasswordCharacter", QStyle::SH_LineEdit_PasswordCharacter, StyleSetting::Char, 10039 }, // { "Dialog/DefaultButton", QStyle::SH_DialogButtons_DefaultButton, StyleSetting::Parent, 0 }, // { "ToolBox/SelectedPageTitleBold", QStyle::SH_ToolBox_SelectedPageTitleBold, StyleSetting::Bool, 1 }, // { "TabWidget/TabBarPreferNoArrows", QStyle::SH_TabBar_PreferNoArrows, StyleSetting::Parent, 0 }, // { "ScrollBar/LeftClickAbsolutePosition", QStyle::SH_ScrollBar_LeftClickAbsolutePosition, StyleSetting::Parent, 0 }, // { "ItemView/Compat/ExpansionSelectMouseType", QStyle::SH_Q3ListViewExpand_SelectMouseType, StyleSetting::Parent, 0 }, // ### dynamic { "General/UnderlineShortcut", QStyle::SH_UnderlineShortcut, StyleSetting::Bool, 0 }, // { "SpinBox/AnimateButton", QStyle::SH_SpinBox_AnimateButton, StyleSetting::Parent, 0 }, // { "SpinBox/KeyPressAutoRepeatRate", QStyle::SH_SpinBox_KeyPressAutoRepeatRate, StyleSetting::Parent, 0 }, // { "SpinBox/ClickAutoRepeatRate", QStyle::SH_SpinBox_ClickAutoRepeatRate, StyleSetting::Parent, 0 }, // { "Menu/FillScreenWithScroll", QStyle::SH_Menu_FillScreenWithScroll, StyleSetting::Parent, 0 }, // { "ToolTip/Opacity", QStyle::SH_ToolTipLabel_Opacity, StyleSetting::Parent, 0 }, // { "Menu/DrawMenuBarSeparator", QStyle::SH_DrawMenuBarSeparator, StyleSetting::Parent, 0 }, // { "MDI/TitleBar/ModifyNotification", QStyle::SH_TitleBar_ModifyNotification, StyleSetting::Parent, 0 }, // { "Button/FocusPolicy", QStyle::SH_Button_FocusPolicy, StyleSetting::Parent, 0 }, // { "Menu/DismissOnSecondClick", QStyle::SH_MenuBar_DismissOnSecondClick, StyleSetting::Parent, 0 }, // { "MessageBox/UseBorderForButtonSpacing", QStyle::SH_MessageBox_UseBorderForButtonSpacing, StyleSetting::Parent, 0 }, { "MDI/TitleBar/AutoRaise", QStyle::SH_TitleBar_AutoRaise, StyleSetting::Bool, 1 }, { "ToolBar/PopupDelay", QStyle::SH_ToolButton_PopupDelay, StyleSetting::Milliseconds, 250 }, // ### dynamic { "General/FocusFrameMask", QStyle::SH_FocusFrame_Mask, StyleSetting::Parent, 0 }, // ### dynamic { "General/RubberBandMask", QStyle::SH_RubberBand_Mask, StyleSetting::Parent, 0 }, // ### dynamic { "General/WindowFrameMask", QStyle::SH_WindowFrame_Mask, StyleSetting::Parent, 0 }, // { "SpinBox/DisableControlsOnBounds", QStyle::SH_SpinControls_DisableOnBounds, StyleSetting::Parent, 0 }, // { "Dial/BackgroundRole", QStyle::SH_Dial_BackgroundRole, StyleSetting::Parent, 0 }, // { "ComboBox/LayoutDirection", QStyle::SH_ComboBox_LayoutDirection, StyleSetting::Parent, 0 }, // { "ItemView/EllipsisLocation", QStyle::SH_ItemView_EllipsisLocation, StyleSetting::Parent, 0 }, // { "ItemView/ShowDecorationSelected", QStyle::SH_ItemView_ShowDecorationSelected, StyleSetting::Parent, 0 }, // ### from KDE { "ItemView/ActivateItemOnSingleClick", QStyle::SH_ItemView_ActivateItemOnSingleClick, StyleSetting::Bool, 1 }, // { "ScrollBar/ContextMenu", QStyle::SH_ScrollBar_ContextMenu, StyleSetting::Parent, 0 }, // { "ScrollBar/RollBetweenButtons", QStyle::SH_ScrollBar_RollBetweenButtons, StyleSetting::Parent, 0 }, #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) // { "Slider/AbsoluteSetButtons", QStyle::SH_Slider_AbsoluteSetButtons, StyleSetting::Parent, 0 }, // { "Slider/PageSetButtons", QStyle::SH_Slider_PageSetButtons, StyleSetting::Parent, 0 }, // { "Menu/KeyboardSearch", QStyle::SH_Menu_KeyboardSearch, StyleSetting::Parent, 0 }, // { "TabWidget/ElideMode", QStyle::SH_TabBar_ElideMode, StyleSetting::Parent, 0 }, #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) // { "Dialog/ButtonLayout", QStyle::SH_DialogButtonLayout, StyleSetting::Value, QDialogButtonBox::KdeLayout }, #else { "Dialog/ButtonLayout", QStyle::SH_DialogButtonLayout, StyleSetting::Value, QDialogButtonBox::KdeLayout }, #endif // { "ComboBox/PopupFrameStyle", QStyle::SH_ComboBox_PopupFrameStyle, StyleSetting::Parent, 0 }, { "MessageBox/AllowTextInteraction", QStyle::SH_MessageBox_TextInteractionFlags, StyleSetting::Bool, 1 }, // ### from KDE { "Dialog/ButtonsHaveIcons", QStyle::SH_DialogButtonBox_ButtonsHaveIcons, StyleSetting::Bool, 0 }, // { "General/SpellCheckUnderlineStyle", QStyle::SH_SpellCheckUnderlineStyle, StyleSetting::Parent, 0 }, { "MessageBox/CenterButtons", QStyle::SH_MessageBox_CenterButtons, StyleSetting::Bool, 0 }, // { "Menu/SelectionWrap", QStyle::SH_Menu_SelectionWrap, StyleSetting::Parent, 0 }, // { "ItemView/MovementWithoutUpdatingSelection", QStyle::SH_ItemView_MovementWithoutUpdatingSelection, StyleSetting::Parent, 0 }, #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) // ### dynamic { "General/ToolTipMask", QStyle::SH_ToolTip_Mask, StyleSetting::Parent, 0 }, // { "General/FocusFrameAboveWidget", QStyle::SH_FocusFrame_AboveWidget, StyleSetting::Parent, 0 }, // { "General/FocusIndicatorTextCharFormat", QStyle::SH_TextControl_FocusIndicatorTextCharFormat, StyleSetting::Parent, 0 }, // { "Dialog/WizardStyle", QStyle::SH_WizardStyle, StyleSetting::Value, QWizard::ModernStyle }, { "ItemView/ArrowKeysNavigateIntoChildren", QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, StyleSetting::Bool, 1 }, // ### dynamic { "General/MenuMask", QStyle::SH_Menu_Mask, StyleSetting::Parent, 0 }, #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) // { "Menu/FlashTriggeredItem", QStyle::SH_Menu_FlashTriggeredItem, StyleSetting::Parent, 0 }, // { "Menu/FadeOutOnHide", QStyle::SH_Menu_FadeOutOnHide, StyleSetting::Parent, 0 }, // { "SpinBox/ClickAutoRepeatThreshold", QStyle::SH_SpinBox_ClickAutoRepeatThreshold, StyleSetting::Parent, 0 }, // { "ItemView/PaintAlternatingRowColorsForEmptyArea", QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea, StyleSetting::Parent, 0 }, // { "FormLayout/WrapPolicy", QStyle::SH_FormLayoutWrapPolicy, StyleSetting::Value, QFormLayout::DontWrapRows }, // { "TabWidget/DefaultTabPosition", QStyle::SH_TabWidget_DefaultTabPosition, StyleSetting::Parent, 0 }, // { "ToolBar/Movable", QStyle::SH_ToolBar_Movable, StyleSetting::Parent, 0 }, { "FormLayout/FieldGrowthPolicy", QStyle::SH_FormLayoutFieldGrowthPolicy, StyleSetting::Value, QFormLayout::ExpandingFieldsGrow }, // { "FormLayout/FormAlignment", QStyle::SH_FormLayoutFormAlignment, StyleSetting::Alignment, Qt::AlignLeft | Qt::AlignTop }, { "FormLayout/LabelAlignment", QStyle::SH_FormLayoutLabelAlignment, StyleSetting::Alignment, Qt::AlignRight | Qt::AlignTop }, #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) // { "ItemView/DrawDelegateFrame", QStyle::SH_, StyleSetting::Parent, 0 }, // { "TabWidget/CloseButtonPosition", QStyle::SH_TabBar_CloseButtonPosition, StyleSetting::Parent, 0 }, // { "DockWidget/ButtonsHaveFrame", QStyle::SH_DockWidget_ButtonsHaveFrame, StyleSetting::Parent, 0 }, #endif { 0, -1, 0, 0 } }; extern int getRubberBandMask(QStyleHintReturnMask *mask, const QStyleOption *option, const QWidget *widget); extern int getWindowFrameMask(QStyleHintReturnMask *mask, const QStyleOptionTitleBar *option, const QWidget *widget); int SkulptureStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { // return ParentStyle::styleHint(hint, option, widget, returnData); // TODO implement caching const StyleSetting *setting = &styleHintSettings[0]; QVariant value; switch (hint) { case QStyle::SH_Menu_SubMenuPopupDelay: { return d->subMenuDelay; } case QStyle::SH_TabBar_Alignment: { return d->centerTabs ? Qt::AlignHCenter : Qt::AlignLeft; } #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) case QStyle::SH_Slider_StopMouseOverSlider: { #else case QStyle::SH_ScrollBar_StopMouseOverSlider: { #endif // this works around a bug with Qt 4.4.2 return qobject_cast(widget) != 0; } case QStyle::SH_ItemView_ActivateItemOnSingleClick: { if (d->useSingleClickToActivateItems != -1) { return d->useSingleClickToActivateItems; } // use platform setting break; } #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) case QStyle::SH_DialogButtonBox_ButtonsHaveIcons: { // ### use KDE setting return 0; } #endif #if 1 case QStyle::SH_GroupBox_TextLabelColor: { QPalette palette; if (option) { palette = option->palette; } else if (widget) { palette = widget->palette(); } return palette.color(QPalette::WindowText).rgba(); } #endif case QStyle::SH_Table_GridLineColor: { QPalette palette; if (option) { palette = option->palette; } else if (widget) { palette = widget->palette(); } #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) return palette.color(QPalette::Base).darker(120).rgba(); #else return palette.color(QPalette::Base).dark(120).rgba(); #endif } case QStyle::SH_LineEdit_PasswordCharacter: { QFontMetrics fm = option ? option->fontMetrics : (widget ? widget->fontMetrics() : QFontMetrics(QFont())); for (int i = 0; i < d->passwordCharacters.length(); ++i) { if (fm.inFont(d->passwordCharacters.at(i))) { return d->passwordCharacters.at(i).unicode(); } } return int('*'); } case QStyle::SH_UnderlineShortcut: { if (d->hideShortcutUnderlines) { return (d->shortcut_handler->underlineShortcut(widget)); } return true; } case QStyle::SH_RubberBand_Mask: { QStyleHintReturnMask *mask = qstyleoption_cast(returnData); if (mask) { return getRubberBandMask(mask, option, widget); } return 0; } case QStyle::SH_WindowFrame_Mask: { QStyleHintReturnMask *mask = qstyleoption_cast(returnData); const QStyleOptionTitleBar *titleBarOption = qstyleoption_cast(option); if (mask && titleBarOption) { return getWindowFrameMask(mask, titleBarOption, widget); } return 0; } default: break; } while (setting->label) { if (setting->id == int(hint)) { break; } ++setting; } if (setting->label) { value = setting->value; switch (setting->type) { case StyleSetting::Parent: value = ParentStyle::styleHint(hint, option, widget, returnData); break; case StyleSetting::Bool: value = setting->value != 0; break; case StyleSetting::Char: value = QString(QChar(setting->value)); break; case StyleSetting::Color: value = QChar('#', 0) + QString::number(value.toInt() - qRgba(0, 0, 0, 255), 16); break; } } else { value = ParentStyle::styleHint(hint, option, widget, returnData); setting = 0; } #if 1 if (setting && d->settings && setting->type != StyleSetting::Parent && !d->settings->contains(QLatin1String(setting->label))) { d->settings->setValue(QLatin1String(setting->label), value); } #endif if (setting) { if (d->settings) { value = d->settings->value(QLatin1String(setting->label), value); } switch (setting->type) { case StyleSetting::Color: value = qRgba(0, 0, 0, 255) + QLocale::c().toInt(value.toString().mid(1), 0, 16); break; case StyleSetting::Bool: value = value.toBool(); break; case StyleSetting::Char: QString s = value.toString(); if (s.size() == 1) { return s.at(0).unicode(); } return setting->value; } } return value.toInt(); } /*-----------------------------------------------------------------------*/ /* * Read color out of current settings group * * color - where to store the resulting color * s - Settings * colorName - name of color, such as "checkMark", first letter should be not be capitalized * n - for multiple color entries, returns the "n"th color (n = 1, 2, ...) otherwise use n = 0. * * This will do the following: * * 1. check if "customColor" is set to "false" -> return false with "color" unmodified * 2. read color entry from "Color" * 3. read color opacity from "ColorOpacity" * 4. return true with "color" modified accordingly * */ static bool readSettingsColor(QColor &color, const QSettings &s, const QString &colorName, int n = 0) { QString cName = colorName + QLatin1String("Color"); if (n > 0) { cName += QString::number(n); } if (s.value(QLatin1String("custom") + cName.at(0).toUpper() + cName.mid(1), true).toBool() == false) { return false; } QString val = s.value(cName).toString(); if (!val.isEmpty()) { QColor c = QColor(val); if (c.isValid()) { color = c; int opacity = s.value(cName + QLatin1String("Opacity"), -1).toInt(); if (opacity >= 0 && opacity <= 255) { color.setAlpha(opacity); } return true; } } return false; } /*-----------------------------------------------------------------------*/ /* * Read gradient out of current settings group * * gradient - where to store the resulting gradient (only the color stops are modified) * s - Settings * gradientName - name of gradient, such as "activeTabTop", first letter should be not be capitalized * * This returns true with "gradient" colors modified accordingly, or false, if no color was found. * * Limitations: * * Maximum number of gradients per background: 9 * Maximum number of colors per gradient: 2 * */ #define MIN_STOP 0 // must be 0 #define MAX_STOP 100 static inline qreal topToStop(int v) { if (v <= MIN_STOP) { return qreal(0.00000); } else if (v >= MAX_STOP) { return qreal(0.99999); } return v / qreal(MAX_STOP) - qreal(0.00001); } static inline qreal bottomToStop(int v) { if (v <= 0) { return qreal(0.00001); } else if (v >= MAX_STOP) { return qreal(1.00000); } return v / qreal(MAX_STOP) + qreal(0.00001); } static bool readSettingsGradient(QGradient &gradient, const QSettings &s, const QString &gradientName) { QColor background(s.value(gradientName + QLatin1String("background")).toString()); if (!background.isValid()) { return false; } bool hasTop = false; bool hasBottom = false; int numGradients = s.value(gradientName + QLatin1String("numGradients"), 0).toInt(); numGradients = qMin(numGradients, 9); // single digit limit for (int i = 1; i <= numGradients; ++i) { QString gradientPrefix = gradientName + QChar('g', 0) + QChar('0' + i, 0); int top = s.value(gradientPrefix + QLatin1String("Top"), -1).toInt(); int bottom = s.value(gradientPrefix + QLatin1String("Bottom"), -1).toInt(); if (top == MIN_STOP) { hasTop = true; } if (bottom == MAX_STOP) { hasBottom = true; } if (top >= 0 && bottom >= 0) { QColor c[9 + 1]; int k = 0; for (int n = 1; n <= 9; ++n) { // single digit limit if (readSettingsColor(c[n], s, gradientPrefix, n)) { ++k; } else { // force continous color numbering break; } } // k colors are found, spread lineary between top ... bottom if (k > 1) { // FIXME blindly assumes k == 2 for now gradient.setColorAt(topToStop(top), c[1]); gradient.setColorAt(bottomToStop(bottom), c[2]); } else if (k == 1) { gradient.setColorAt(topToStop(top), c[1]); gradient.setColorAt(bottomToStop(bottom), c[1]); } } } // FIXME does not detect "holes" between gradients // that are to be "filled" with background if (!hasTop) { gradient.setColorAt(0, background); } if (!hasBottom) { gradient.setColorAt(1, background); } return true; } /*-----------------------------------------------------------------------*/ /* * Read domino settings out of current settings group * */ void SkulptureStyle::Private::readDominoSettings(const QSettings &s) { static const char * const gradientName[] = { "tabTop", "tabBottom", "activeTabTop", "activeTabBottom", "btn", "checkItem", "header", "scrollBar", "scrollBarGroove" }; static const char * const colorName[] = { "checkMark", "groupBoxBackground", "popupMenu", "selMenuItem", "toolTip" }; for (uint i = 0; i < array_elements(gradientName); ++i) { QGradient gradient; if (readSettingsGradient(gradient, s, QLatin1String(gradientName[i]) + QLatin1String("Surface_"))) { #if 0 printf("domino: gradient[%s]=", gradientName[i]); QGradientStops stops = gradient.stops(); for (int i = 0; i < stops.size(); ++i) { QGradientStop stop = stops.at(i); QColor color = stop.second; printf("(%.6g=#%2x%2x%2x/a=#%2x)", stop.first, color.red(), color.green(), color.blue(), color.alpha()); } printf("\n"); #endif // only save stops from the gradient // dominoGradientStops[i] = gradient.stops(); } } for (uint i = 0; i < array_elements(colorName); ++i) { QColor color; if (readSettingsColor(color, s, QLatin1String(colorName[i]))) { #if 0 printf("domino: color[%s]=#%2x%2x%2x/a=#%2x\n", colorName[i], color.red(), color.green(), color.blue(), color.alpha()); #endif // dominoCustomColors[i] = color; } } animateProgressBars = s.value(QLatin1String("animateProgressBar"), animateProgressBars).toBool(); centerTabs = s.value(QLatin1String("centerTabs"), centerTabs).toBool(); #if 0 readSettingsColor(buttonContourColor, s, QLatin1String("buttonContour")); readSettingsColor(buttonDefaultContourColor, s, QLatin1String("buttonDefaultContour")); readSettingsColor(buttonMouseOverContourColor, s, QLatin1String("buttonMouseOverContour")); readSettingsColor(buttonPressedContourColor, s, QLatin1String("buttonPressedContour")); readSettingsColor(indicatorButtonColor, s, QLatin1String("indicatorButton")); readSettingsColor(indicatorColor, s, QLatin1String("indicator")); readSettingsColor(rubberBandColor, s, QLatin1String("rubberBand")); readSettingsColor(textEffectButtonColor, s, QLatin1String("textEffectButton")); readSettingsColor(textEffectColor, s, QLatin1String("textEffect")); highlightToolBtnIcon = s.value(QLatin1String("highlightToolBtnIcon"), highlightToolBtnIcon).toBool(); indentPopupMenuItems = s.value(QLatin1String("indentPopupMenuItems"), indentPopupMenuItems).toBool(); smoothScrolling = s.value(QLatin1String("smoothScrolling"), smoothScrolling).toBool(); tintGroupBoxBackground = s.value(QLatin1String("tintGroupBoxBackground"), tintGroupBoxBackground).toBool(); indicateFocus = s.value(QLatin1String("indicateFocus"), indicateFocus).toBool(); drawButtonSunkenShadow = s.value(QLatin1String("drawButtonSunkenShadow"), drawButtonSunkenShadow).toBool(); drawFocusUnderline = s.value(QLatin1String("drawFocusUnderline"), drawFocusUnderline).toBool(); drawPopupMenuGradient = s.value(QLatin1String("drawPopupMenuGradient"), drawPopupMenuGradient).toBool(); drawTextEffect = s.value(QLatin1String("drawTextEffect"), drawTextEffect).toBool(); drawToolButtonAsButton = s.value(QLatin1String("drawToolButtonAsButton"), drawToolButtonAsButton).toBool(); drawTriangularExpander = s.value(QLatin1String("drawTriangularExpander"), drawTriangularExpander).toBool(); #endif } /*-----------------------------------------------------------------------*/ void SkulptureStyle::Private::readSettings(const QSettings &s) { // defaults animateProgressBars = true; verticalArrowMode = SkulptureMode; horizontalArrowMode = SkulptureMode; hideShortcutUnderlines = true; centerTabs = false; makeDisabledWidgetsTransparent = true; transparentPlacesPanel = false; forceSpacingAndMargins = false; visualizeLayouts = false; useIconColumnForCheckIndicators = false; useSelectionColorForCheckedIndicators = false; useSelectionColorForSelectedMenuItems = false; useSingleClickToActivateItems = runtimeQtVersion() >= QT_VERSION_CHECK(4, 6, 0) ? -1 : 1; expensiveShadows = true; allowTabulations = false; dialogMargins = -1; horizontalSpacing = -1; labelSpacing = -1; menuBarSize = -1; menuItemSize = -1; pushButtonSize = -1; scrollBarSize = -1; scrollBarLength = -1; sliderSize = -1; sliderLength = -1; tabBarSize = -1; toolButtonSize = -1; verticalSpacing = -1; widgetMargins = -1; widgetSize = -1; textShift = 0; buttonGradient = 0; buttonRoundness = 0; passwordCharacters = QString(QChar(ushort(10039))); textCursorWidth = 0; subMenuDelay = 100; // legacy settings import: domino 0.4 QString dominoConfigFile = s.value(QLatin1String("LegacyImport/DominoConfiguration")).toString(); if (!dominoConfigFile.isEmpty()) { QSettings s(dominoConfigFile, QSettings::IniFormat); s.beginGroup(QLatin1String("Settings")); readDominoSettings(s); s.endGroup(); } // native settings animateProgressBars = s.value(QLatin1String("ProgressBar/AnimateProgressBars"), animateProgressBars).toBool(); if (s.contains(QLatin1String("ScrollBar/AllowScrollBarSliderToCoverArrows")) && !s.contains(QLatin1String("ScrollBar/VerticalArrowMode"))) { verticalArrowMode = s.value(QLatin1String("ScrollBar/AllowScrollBarSliderToCoverArrows"), true).toBool() ? SkulptureMode : WindowsMode; } else { QString mode = s.value(QLatin1String("ScrollBar/VerticalArrowMode"), QLatin1String("Covered")).toString(); if (mode == QLatin1String("Top")) { verticalArrowMode = NextMode; } else if (mode == QLatin1String("Bottom")) { verticalArrowMode = PlatinumMode; } else if (mode == QLatin1String("BottomTop") || mode == QLatin1String("Bottom/Top")) { verticalArrowMode = WindowsMode; } else if (mode == QLatin1String("KDEMode")) { verticalArrowMode = KDEMode; } else if (mode == QLatin1String("Covered")) { verticalArrowMode = SkulptureMode; } else if (mode == QLatin1String("None")) { verticalArrowMode = NoArrowsMode; } else { verticalArrowMode = SkulptureMode; } } if (s.contains(QLatin1String("ScrollBar/AllowScrollBarSliderToCoverArrows")) && !s.contains(QLatin1String("ScrollBar/HorizontalArrowMode"))) { horizontalArrowMode = s.value(QLatin1String("ScrollBar/AllowScrollBarSliderToCoverArrows"), true).toBool() ? SkulptureMode : WindowsMode; } else { QString mode = s.value(QLatin1String("ScrollBar/HorizontalArrowMode"), QLatin1String("Covered")).toString(); if (mode == QLatin1String("Left")) { horizontalArrowMode = NextMode; } else if (mode == QLatin1String("Right")) { horizontalArrowMode = PlatinumMode; } else if (mode == QLatin1String("RightLeft") || mode == QLatin1String("Right/Left")) { horizontalArrowMode = WindowsMode; } else if (mode == QLatin1String("KDEMode")) { horizontalArrowMode = KDEMode; } else if (mode == QLatin1String("Covered")) { horizontalArrowMode = SkulptureMode; } else if (mode == QLatin1String("None")) { horizontalArrowMode = NoArrowsMode; } else { horizontalArrowMode = SkulptureMode; } } hideShortcutUnderlines = s.value(QLatin1String("General/HideShortcutUnderlines"), hideShortcutUnderlines).toBool(); makeDisabledWidgetsTransparent = s.value(QLatin1String("General/MakeDisabledWidgetsTransparent"), makeDisabledWidgetsTransparent).toBool(); transparentPlacesPanel = s.value(QLatin1String("Views/TransparentPlacesPanel"), transparentPlacesPanel).toBool(); forceSpacingAndMargins = s.value(QLatin1String("Layout/ForceSpacingAndMargins"), forceSpacingAndMargins).toBool(); visualizeLayouts = s.value(QLatin1String("Layout/VisualizeLayouts"), visualizeLayouts).toBool(); useIconColumnForCheckIndicators = s.value(QLatin1String("Menus/UseIconColumnForCheckIndicators"), useIconColumnForCheckIndicators).toBool(); useSelectionColorForCheckedIndicators = s.value(QLatin1String("General/UseSelectionColorForCheckedIndicators"), useSelectionColorForCheckedIndicators).toBool(); useSelectionColorForSelectedMenuItems = s.value(QLatin1String("Menus/UseSelectionColorForSelectedMenuItems"), useSelectionColorForSelectedMenuItems).toBool(); if (s.contains(QLatin1String("General/UseSingleClickToActivateItems"))) { bool singleClick = s.value(QLatin1String("General/UseSingleClickToActivateItems"), true).toBool(); useSingleClickToActivateItems = singleClick ? 1 : 0; } expensiveShadows = s.value(QLatin1String("General/ExpensiveShadows"), expensiveShadows).toBool(); allowTabulations = s.value(QLatin1String("General/AllowTabulations"), allowTabulations).toBool(); dialogMargins = s.value(QLatin1String("Layout/DialogMargins"), dialogMargins).toInt(); horizontalSpacing = s.value(QLatin1String("Layout/HorizontalSpacing"), horizontalSpacing).toInt(); labelSpacing = s.value(QLatin1String("Layout/LabelSpacing"), labelSpacing).toInt(); menuBarSize = s.value(QLatin1String("Layout/MenuBarSize"), menuBarSize).toInt(); menuItemSize = s.value(QLatin1String("Layout/MenuItemSize"), menuItemSize).toInt(); pushButtonSize = s.value(QLatin1String("Layout/PushButtonSize"), pushButtonSize).toInt(); scrollBarSize = s.value(QLatin1String("Layout/ScrollBarSize"), scrollBarSize).toInt(); scrollBarLength = s.value(QLatin1String("Layout/ScrollBarLength"), scrollBarLength).toInt(); sliderSize = s.value(QLatin1String("Layout/SliderSize"), sliderSize).toInt(); sliderLength = s.value(QLatin1String("Layout/SliderLength"), sliderLength).toInt(); tabBarSize = s.value(QLatin1String("Layout/TabBarSize"), tabBarSize).toInt(); toolButtonSize = s.value(QLatin1String("Layout/ToolButtonSize"), toolButtonSize).toInt(); verticalSpacing = s.value(QLatin1String("Layout/VerticalSpacing"), verticalSpacing).toInt(); widgetMargins = s.value(QLatin1String("Layout/WidgetMargins"), widgetMargins).toInt(); widgetSize = s.value(QLatin1String("Layout/WidgetSize"), widgetSize).toInt(); textShift = s.value(QLatin1String("General/TextShift"), textShift).toInt(); buttonGradient = s.value(QLatin1String("General/ButtonGradientIntensity"), buttonGradient).toInt(); buttonRoundness = s.value(QLatin1String("General/ButtonRoundness"), buttonRoundness).toInt(); passwordCharacters = s.value(QLatin1String("General/PasswordCharacters"), passwordCharacters).toString(); styleSheetFileName = s.value(QLatin1String("General/StyleSheetFileName"), QString()).toString(); textCursorWidth = s.value(QLatin1String("General/TextCursorWidth"), (double) textCursorWidth).toDouble(); subMenuDelay = s.value(QLatin1String("Menus/SubMenuDelay"), subMenuDelay).toInt(); // apply defaults if (widgetSize < 0) { widgetSize = 2; } if (pushButtonSize < 0) { pushButtonSize = 2; } if (tabBarSize < 0) { tabBarSize = 2; } if (menuItemSize < 0) { menuItemSize = 2; } } int SkulptureStyle::skulpturePrivateMethod(SkulptureStyle::SkulpturePrivateMethod id, void *data) { switch (id) { case SPM_SupportedMethods: { return SPM_SetSettingsFileName; } case SPM_SetSettingsFileName: { SkMethodDataSetSettingsFileName *md = (SkMethodDataSetSettingsFileName *) data; if (md && md->version >= 1) { QSettings s(md->fileName, QSettings::IniFormat); if (s.status() == QSettings::NoError) { d->readSettings(s); return 1; } } return 0; } default: return 0; } } /*-----------------------------------------------------------------------*/ void paintNothing(QPainter */*painter*/, const QStyleOption */*option*/) { // } void paintDefault(QPainter */*painter*/, const QStyleOption */*option*/) { // } /*-----------------------------------------------------------------------*/ void paintCommandButtonPanel(QPainter *painter, const QStyleOptionButton *option, const QWidget *widget); void paintPushButtonBevel(QPainter *painter, const QStyleOptionButton *option, const QWidget *widget, const QStyle *style); void paintTabWidgetFrame(QPainter *painter, const QStyleOptionTabWidgetFrame *option, const QWidget *widget); void paintIndicatorCheckBox(QPainter *painter, const QStyleOptionButton *option); void paintIndicatorItemViewItemCheck(QPainter *painter, const QStyleOption *option); void paintQ3CheckListIndicator(QPainter *painter, const QStyleOptionQ3ListView *option, const QWidget *widget, const QStyle *style); void paintQ3CheckListExclusiveIndicator(QPainter *painter, const QStyleOptionQ3ListView *option, const QWidget *widget, const QStyle *style); void paintIndicatorRadioButton(QPainter *painter, const QStyleOptionButton *option); void paintIndicatorSpinDown(QPainter *painter, const QStyleOption *option); void paintIndicatorSpinUp(QPainter *painter, const QStyleOption *option); void paintIndicatorSpinMinus(QPainter *painter, const QStyleOption *option); void paintIndicatorSpinPlus(QPainter *painter, const QStyleOption *option); void paintIndicatorArrowDown(QPainter *painter, const QStyleOption *option); void paintIndicatorArrowLeft(QPainter *painter, const QStyleOption *option); void paintIndicatorArrowRight(QPainter *painter, const QStyleOption *option); void paintIndicatorArrowUp(QPainter *painter, const QStyleOption *option); void paintHeaderSortIndicator(QPainter *painter, const QStyleOptionHeader *option); void paintStyledFrame(QPainter *painter, const QStyleOptionFrame *frame, const QWidget *widget, const QStyle *style); void paintFrameLineEdit(QPainter *painter, const QStyleOptionFrame *frame); void paintPanelLineEdit(QPainter *painter, const QStyleOptionFrame *frame, const QWidget *widget, const QStyle *style); void paintFrameDockWidget(QPainter *painter, const QStyleOptionFrame *frame); void paintFrameWindow(QPainter *painter, const QStyleOptionFrame *frame); void paintToolBarSeparator(QPainter *painter, const QStyleOptionToolBar *option); void paintToolBarHandle(QPainter *painter, const QStyleOptionToolBar *option); void paintScrollArea(QPainter *painter, const QStyleOption *option); void paintPanelToolBar(QPainter *painter, const QStyleOptionToolBar *option); void paintIndicatorMenuCheckMark(QPainter *painter, const QStyleOptionMenuItem *option, const QWidget *widget, const QStyle *style); void paintFrameGroupBox(QPainter *painter, const QStyleOptionFrame *option); void paintFrameFocusRect(QPainter *painter, const QStyleOptionFocusRect *option, const QWidget *widget); void paintPanelButtonTool(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style); void paintSizeGrip(QPainter *painter, const QStyleOption *option); void paintScrollAreaCorner(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style); #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) void paintPanelItemViewItem(QPainter *painter, const QStyleOptionViewItemV4 *option, const QWidget *widget, const QStyle *style); #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) void paintIndicatorTabClose(QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style); #endif void paintMenuBarEmptyArea(QPainter *painter, const QStyleOption *option); void paintPanelMenuBar(QPainter *painter, const QStyleOptionFrame *frame); void paintMenuBarItem(QPainter *painter, const QStyleOptionMenuItem *option, const QWidget *widget, const QStyle *style); void paintFrameMenu(QPainter *painter, const QStyleOptionFrame *frame); void paintMenuItem(QPainter *painter, const QStyleOptionMenuItem *option, const QWidget *widget, const QStyle *style); void paintTabBarTabShape(QPainter *painter, const QStyleOptionTab *option, const QWidget *widget, const QStyle *style); void paintTabBarTabLabel(QPainter *painter, const QStyleOptionTab *option, const QWidget *widget, const QStyle *style); void paintFrameTabBarBase(QPainter *painter, const QStyleOptionTabBarBase *option, const QWidget *widget); #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) void paintToolBoxTabShape(QPainter *painter, const QStyleOptionToolBoxV2 *option); void paintToolBoxTabLabel(QPainter *painter, const QStyleOptionToolBox *option, const QWidget *widget, const QStyle *style); #else void paintToolBoxTabShape(QPainter *painter, const QStyleOptionToolBox *option); #endif void paintHeaderEmptyArea(QPainter *painter, const QStyleOption *option); void paintHeaderSection(QPainter *painter, const QStyleOptionHeader *option, const QWidget *widget, const QStyle *style); void paintHeaderLabel(QPainter *painter, const QStyleOptionHeader *option, const QWidget *widget, const QStyle *style); void paintIndicatorBranch(QPainter *painter, const QStyleOption *option); void paintScrollBarSlider(QPainter *painter, const QStyleOptionSlider *option); void paintScrollBarAddLine(QPainter *painter, const QStyleOptionSlider *option); void paintScrollBarSubLine(QPainter *painter, const QStyleOptionSlider *option); void paintScrollBarFirst(QPainter *painter, const QStyleOptionSlider *option); void paintScrollBarLast(QPainter *painter, const QStyleOptionSlider *option); void paintScrollBarPage(QPainter *painter, const QStyleOptionSlider *option); void paintProgressBarGroove(QPainter *painter, const QStyleOptionProgressBar *option); void paintProgressBarContents(QPainter *painter, const QStyleOptionProgressBarV2 *option, const QWidget *widget, const QStyle *style); void paintProgressBarLabel(QPainter *painter, const QStyleOptionProgressBarV2 *option, const QWidget *widget, const QStyle *style); void paintSplitter(QPainter *painter, const QStyleOption *option); void paintDockWidgetTitle(QPainter *painter, const QStyleOptionDockWidget *option, const QWidget *widget, const QStyle *style); void paintRubberBand(QPainter *paint, const QStyleOptionRubberBand *option); void paintComboBoxLabel(QPainter *painter, const QStyleOptionComboBox *option, const QWidget *widget, const QStyle *style); void paintToolButtonLabel(QPainter *painter, const QStyleOptionToolButton *option, const QWidget *widget, const QStyle *style); /*-----------------------------------------------------------------------*/ SkulptureStyle::Private::Private() { init(); } SkulptureStyle::Private::~Private() { delete shortcut_handler; delete settings; } int runtimeQtVersion() { const char *vs = qVersion(); int v = 0; int vp = 0; while (true) { char c = *vs++; if (c >= '0' && c <= '9') { vp *= 10; vp += c - '0'; } else if (c == '.') { v = (v | vp) << 8; } else { return v | vp; } } } void SkulptureStyle::Private::init() { shortcut_handler = new ShortcutHandler(this); timer = 0; updatingShadows = false; oldEdit = 0; #if 0 settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("SkulptureStyle"), QLatin1String("")); #else settings = 0; #endif QSettings s(QSettings::IniFormat, QSettings::UserScope, QLatin1String("SkulptureStyle"), QLatin1String("")); readSettings(s); register_draw_entries(); } void SkulptureStyle::Private::register_draw_entries() { for (uint i = 0; i < sizeof(draw_primitive_entry) / sizeof(Private::DrawElementEntry); ++i) { draw_primitive_entry[i].func = 0; } for (uint i = 0; i < sizeof(draw_element_entry) / sizeof(Private::DrawElementEntry); ++i) { draw_element_entry[i].func = 0; } /* entries are stricly sorted in Qt order for future lookup table */ #define register_primitive(pe, f, so) draw_primitive_entry[QStyle::PE_ ## pe].type = QStyleOption::SO_ ## so; draw_primitive_entry[QStyle::PE_ ## pe].func = (drawElementFunc *) paint ## f; /* PRIMITIVE ELEMENT */ // Qt 3.x compatibility //### register_primitive(Q3CheckListController, Nothing, Default); register_primitive(Q3CheckListExclusiveIndicator, Q3CheckListExclusiveIndicator, Default); register_primitive(Q3CheckListIndicator, Q3CheckListIndicator, Default); register_primitive(Q3DockWindowSeparator, ToolBarSeparator, Default); //### register_primitive(Q3Separator, Q3Separator, Default); // Qt 4.0 Frames register_primitive(Frame, StyledFrame, Frame); register_primitive(FrameDefaultButton, Nothing, Button); register_primitive(FrameDockWidget, FrameDockWidget, Frame); register_primitive(FrameFocusRect, FrameFocusRect, FocusRect); register_primitive(FrameGroupBox, FrameGroupBox, Frame); register_primitive(FrameLineEdit, FrameLineEdit, Frame); register_primitive(FrameMenu, FrameMenu, Default); // ### Qt 4.3 calls FrameMenu with SO_ToolBar for a toolbar #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) register_primitive(FrameStatusBarItem, Nothing, Default); #else register_primitive(FrameStatusBar, Nothing, Default); #endif register_primitive(FrameTabWidget, TabWidgetFrame, TabWidgetFrame); register_primitive(FrameWindow, FrameWindow, Frame); register_primitive(FrameButtonBevel, PanelButtonTool, Default); register_primitive(FrameButtonTool, PanelButtonTool, Default); register_primitive(FrameTabBarBase, FrameTabBarBase, TabBarBase); // Qt 4.0 Panels register_primitive(PanelButtonCommand, CommandButtonPanel, Button); register_primitive(PanelButtonBevel, PanelButtonTool, Default); register_primitive(PanelButtonTool, PanelButtonTool, Default); register_primitive(PanelMenuBar, PanelMenuBar, Frame); register_primitive(PanelToolBar, PanelToolBar, Frame); register_primitive(PanelLineEdit, PanelLineEdit, Frame); // Qt 4.0 Indicators register_primitive(IndicatorArrowDown, IndicatorArrowDown, Default); register_primitive(IndicatorArrowLeft, IndicatorArrowLeft, Default); register_primitive(IndicatorArrowRight, IndicatorArrowRight, Default); register_primitive(IndicatorArrowUp, IndicatorArrowUp, Default); register_primitive(IndicatorBranch, IndicatorBranch, Default); register_primitive(IndicatorButtonDropDown, PanelButtonTool, Default); #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) register_primitive(IndicatorItemViewItemCheck, IndicatorItemViewItemCheck, Default); #else register_primitive(IndicatorViewItemCheck, IndicatorItemViewItemCheck, Default); #endif register_primitive(IndicatorCheckBox, IndicatorCheckBox, Button); register_primitive(IndicatorDockWidgetResizeHandle, Splitter, Default); register_primitive(IndicatorHeaderArrow, HeaderSortIndicator, Header); register_primitive(IndicatorMenuCheckMark, IndicatorMenuCheckMark, MenuItem); // register_primitive(IndicatorProgressChunk, , ); register_primitive(IndicatorRadioButton, IndicatorRadioButton, Button); register_primitive(IndicatorSpinDown, IndicatorSpinDown, Default); register_primitive(IndicatorSpinMinus, IndicatorSpinMinus, Default); register_primitive(IndicatorSpinPlus, IndicatorSpinPlus, Default); register_primitive(IndicatorSpinUp, IndicatorSpinUp, Default); register_primitive(IndicatorToolBarHandle, ToolBarHandle, ToolBar); register_primitive(IndicatorToolBarSeparator, ToolBarSeparator, Default); // register_primitive(PanelTipLabel, , ); // register_primitive(IndicatorTabTear, , ); // Qt 4.2 additions #if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) register_primitive(PanelScrollAreaCorner, ScrollAreaCorner, Default); // ### register_primitive(Widget, , ); #endif // Qt 4.3 additions #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) // TODO register_primitive(IndicatorColumnViewArrow, , ); #endif // Qt 4.4 additions #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) // register_primitive(IndicatorItemViewItemDrop, , ); register_primitive(PanelItemViewItem, PanelItemViewItem, ViewItem); // register_primitive(PanelItemViewRow, , ); // register_primitive(PanelStatusBar, , ); #endif // Qt 4.5 additions #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) register_primitive(IndicatorTabClose, IndicatorTabClose, Default); // register_primitive(PanelMenu, , ); #endif #define register_element(ce, f, so) draw_element_entry[QStyle::CE_ ## ce].type = QStyleOption::SO_ ## so; draw_element_entry[QStyle::CE_ ## ce].func = (drawElementFunc *) paint ## f; /* CONTROL ELEMENT */ // Qt 4.0 Buttons // register_element(PushButton, , ); register_element(PushButtonBevel, PushButtonBevel, Button); // register_element(PushButtonLabel, , ); // register_element(CheckBox, , ); // register_element(CheckBoxLabel, , ); // register_element(RadioButton, , ); // register_element(RadioButtonLabel, , ); // Qt 4.0 Controls // register_element(TabBarTab, , ); register_element(TabBarTabShape, TabBarTabShape, Tab); register_element(TabBarTabLabel, TabBarTabLabel, Tab); // register_element(ProgressBar, , ProgressBar); register_element(ProgressBarGroove, ProgressBarGroove, ProgressBar); register_element(ProgressBarContents, ProgressBarContents, ProgressBar); register_element(ProgressBarLabel, ProgressBarLabel, ProgressBar); // Qt 4.0 Menus register_element(MenuItem, MenuItem, MenuItem); // register_element(MenuScroller, , ); // register_element(MenuVMargin, , ); // register_element(MenuHMargin, , ); // register_element(MenuTearoff, , ); register_element(MenuEmptyArea, Nothing, Default); register_element(MenuBarItem, MenuBarItem, MenuItem); register_element(MenuBarEmptyArea, MenuBarEmptyArea, Default); // Qt 4.0 more Controls register_element(ToolButtonLabel, ToolButtonLabel, ToolButton); // register_element(Header, , ); register_element(HeaderSection, HeaderSection, Header); register_element(HeaderLabel, HeaderLabel, Header); // register_element(Q3DockWindowEmptyArea, , ); // register_element(ToolBoxTab, , ); register_element(SizeGrip, SizeGrip, Default); register_element(Splitter, Splitter, Default); register_element(RubberBand, RubberBand, RubberBand); register_element(DockWidgetTitle, DockWidgetTitle, DockWidget); // Qt 4.0 ScrollBar register_element(ScrollBarAddLine, ScrollBarAddLine, Slider); register_element(ScrollBarSubLine, ScrollBarSubLine, Slider); register_element(ScrollBarAddPage, ScrollBarPage, Slider); register_element(ScrollBarSubPage, ScrollBarPage, Slider); register_element(ScrollBarSlider, ScrollBarSlider, Slider); register_element(ScrollBarFirst, ScrollBarFirst, Slider); register_element(ScrollBarLast, ScrollBarLast, Slider); // Qt 4.0 even more Controls // register_element(FocusFrame, , ); register_element(ComboBoxLabel, ComboBoxLabel, ComboBox); // Qt 4.1 additions //#if (QT_VERSION >= QT_VERSION_CHECK(4, 1, 0)) register_element(ToolBar, PanelToolBar, ToolBar); //#endif // Qt 4.3 additions #if (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) register_element(ToolBoxTabShape, ToolBoxTabShape, ToolBox); register_element(ToolBoxTabLabel, ToolBoxTabLabel, ToolBox); register_element(HeaderEmptyArea, HeaderEmptyArea, Default); register_element(ColumnViewGrip, Splitter, Default); #endif // Qt 4.4 additions #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) // register_element(ItemViewItem, , ); #endif } /*-----------------------------------------------------------------------*/ #include "skulpture_p.moc" skulpture-0.2.4/src/skulpture.h0000600000175000001440000001140311074247131015422 0ustar pepousers/* * Skulpture - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2007, 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef SKULPTURE_H #define SKULPTURE_H 1 #include /*-----------------------------------------------------------------------*/ // Skulpture is a subclass of QCommonStyle in order to // ease transition to KStyle later class SkulptureStyle : public QCommonStyle { Q_OBJECT typedef QCommonStyle ParentStyle; public: SkulptureStyle(); virtual ~SkulptureStyle(); QPalette standardPalette() const; void polish(QPalette &palette); void polish(QWidget *widget); void unpolish(QWidget *widget); void polish(QApplication *application); void unpolish(QApplication *application); void drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const; void drawItemText(QPainter * painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const; QRect itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap & pixmap) const; QRect itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text ) const; int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const; int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const; QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const; QSize sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &contentsSize, 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 &position, const QWidget *widget) const; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) 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; public: // internal enum SkulpturePrivateMethod { SPM_SupportedMethods = 0, SPM_SetSettingsFileName = 1 }; public Q_SLOTS: int skulpturePrivateMethod(SkulpturePrivateMethod id, void *data = 0); protected Q_SLOTS: //#if (QT_VERSION >= 0x040100) QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; //#endif #if (QT_VERSION >= 0x040300) int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const; #endif private: void init(); class Private; Private * const d; }; /*-----------------------------------------------------------------------*/ #endif // SKULPTURE_H skulpture-0.2.4/src/skulpture_p.h0000600000175000001440000002374311333436274015761 0ustar pepousers/* * skulpture_p.h - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2007-2009 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef SKULPTURE_PRIVATE_H #define SKULPTURE_PRIVATE_H 1 /*-----------------------------------------------------------------------*/ #include class QWidget; class ShortcutHandler : public QObject { Q_OBJECT enum TabletCursorState { DefaultCursor, TabletCursor, BlankCursor }; public: explicit ShortcutHandler(QObject *parent = 0); virtual ~ShortcutHandler(); bool underlineShortcut(const QWidget *widget) const; protected: bool eventFilter(QObject *watched, QEvent *event); private: void init() { } private: QList alt_pressed; TabletCursorState tabletCursorState; }; /*-----------------------------------------------------------------------*/ #if (QT_VERSION < 0x040300) #define QT_VERSION_CHECK(maj, min, rel) ((maj << 16) + (min << 8) + (rel)) #endif /*-----------------------------------------------------------------------*/ enum ArrowPlacementMode { NoArrowsMode, // (*) SkulptureMode, // (<*>) WindowsMode, // <(*)> KDEMode, // <(*)<> PlatinumMode, // (*)<> NextMode // <>(*) }; /*-----------------------------------------------------------------------*/ #include "skulpture.h" #include #include #include #include class QPainter; class QSettings; class QTextEdit; class QPlainTextEdit; class QAbstractScrollArea; class QLineEdit; #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) class QFormLayout; #endif class QMenu; class SkulptureStyle::Private : public QObject { Q_OBJECT public: Private(); ~Private(); SkulptureStyle *q; void setAnimated(QWidget *widget, bool animated); bool isAnimated(QWidget *widget); private: QList animations; int timer; public: void readSettings(const QSettings &s); void readDominoSettings(const QSettings &s); QSettings *settings; bool animateProgressBars; bool hideShortcutUnderlines; bool centerTabs; // from domino bool makeDisabledWidgetsTransparent; bool transparentPlacesPanel; bool forceSpacingAndMargins; bool visualizeLayouts; bool useIconColumnForCheckIndicators; bool useSelectionColorForCheckedIndicators; bool useSelectionColorForSelectedMenuItems; int useSingleClickToActivateItems; bool expensiveShadows; bool allowTabulations; ArrowPlacementMode verticalArrowMode; ArrowPlacementMode horizontalArrowMode; int dialogMargins; int horizontalSpacing; int labelSpacing; int menuBarSize; int menuItemSize; int pushButtonSize; int scrollBarSize; int scrollBarLength; int sliderSize; int sliderLength; int tabBarSize; int toolButtonSize; int verticalSpacing; int widgetMargins; int widgetSize; int textShift; int buttonGradient; int buttonRoundness; int subMenuDelay; QString passwordCharacters; QString styleSheetFileName; qreal textCursorWidth; enum Settings { Style, Metric, Icon }; typedef void (drawElementFunc)( QPainter *painter, const QStyleOption *option, const QWidget *widget, const QStyle *style ); struct DrawElementEntry { int type; drawElementFunc *func; }; void register_settings(const char *label, ...); QSignalMapper mapper; #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) struct DrawElementEntry draw_primitive_entry[QStyle::PE_PanelMenu + 1]; #elif (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) struct DrawElementEntry draw_primitive_entry[QStyle::PE_PanelStatusBar + 1]; #elif (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) struct DrawElementEntry draw_primitive_entry[QStyle::PE_IndicatorColumnViewArrow + 1]; #elif (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) struct DrawElementEntry draw_primitive_entry[QStyle::PE_Widget + 1]; #else struct DrawElementEntry draw_primitive_entry[QStyle::PE_IndicatorTabTear + 1]; #endif #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) struct DrawElementEntry draw_element_entry[QStyle::CE_ItemViewItem + 1]; #elif (QT_VERSION >= QT_VERSION_CHECK(4, 3, 0)) struct DrawElementEntry draw_element_entry[QStyle::CE_ColumnViewGrip + 1]; #else struct DrawElementEntry draw_element_entry[QStyle::CE_ToolBar + 1]; #endif ShortcutHandler *shortcut_handler; void register_draw_entries(); void installFrameShadow(QWidget *widget); void removeFrameShadow(QWidget *widget); void updateFrameShadow(QWidget *widget); void updateTextEditMargins(QTextEdit *edit); void removeCursorLine(QAbstractScrollArea *edit); void updateCursorLine(QAbstractScrollArea *edit, const QRect &cursorRect); void paintCursorLine(QAbstractScrollArea *edit); void handleCursor(QTextEdit *edit); void handleCursor(QPlainTextEdit *edit); int verticalTextShift(const QFontMetrics &fontMetrics); int textLineHeight(const QStyleOption *option, const QWidget *widget); void polishLayout(QLayout *layout); #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) void polishFormLayout(QFormLayout *layout); #endif QList > postEventWidgets; void addPostEventWidget(QWidget *widget); QAbstractScrollArea *oldEdit; int oldCursorTop; int oldCursorWidth; int oldCursorHeight; int oldHeight; QPalette oldPalette; bool updatingShadows; QLineEdit *hoverLineEdit; QLineEdit *focusLineEdit; QRect lineEditHoverCursorRect; struct MenuInfo { QPointer menu; QPointer lastAction; QPointer visibleSubMenu; QPointer lastSubMenuAction; int eventCount; QPoint lastPos; int delayTimer; }; QHash menuHash; bool menuEventFilter(QMenu *menu, QEvent *event); protected: void timerEvent(QTimerEvent *event); bool eventFilter(QObject *watched, QEvent *event); protected Q_SLOTS: void textEditSourceChanged(QWidget *); void updateToolBarOrientation(Qt::Orientation); void processPostEventWidgets(); private: void init(); }; /*-----------------------------------------------------------------------*/ class FrameShadow : public QWidget { Q_OBJECT public: enum ShadowArea { Left, Top, Right, Bottom }; public: explicit FrameShadow(QWidget *parent = 0); explicit FrameShadow(ShadowArea area, QWidget *parent = 0); virtual ~FrameShadow(); void setShadowArea(ShadowArea area) { area_ = area; } ShadowArea shadowArea() const { return area_; } void updateGeometry(); protected: bool event(QEvent *e); void paintEvent(QPaintEvent *); private: void init(); private: ShadowArea area_; }; /*-----------------------------------------------------------------------*/ class WidgetShadow : public QWidget { Q_OBJECT public: explicit WidgetShadow(QWidget *parent = 0); void setWidget(QWidget *w) { widget_ = w; } QWidget *widget() const { return widget_; } void updateGeometry(); void updateZOrder(); public: bool event(QEvent *e); private: void init(); private: QWidget *widget_; }; /*-----------------------------------------------------------------------*/ struct SkMethodData { int version; }; struct SkMethodDataSetSettingsFileName : public SkMethodData { // in version 1 QString fileName; }; /*-----------------------------------------------------------------------*/ class QPainterPath; QColor shaded_color(const QColor &color, int shade); QColor blend_color(const QColor &c0, const QColor &c1, qreal blend); QGradient path_edge_gradient(const QRectF &rect, const QStyleOption *option, const QPainterPath &path, const QColor &color2, const QColor &color1); void paintThinFrame(QPainter *painter, const QRect &rect, const QPalette &palette, int dark, int light, QPalette::ColorRole bgrole = QPalette::Window); enum RecessedFrame { RF_Small, RF_Large, RF_None }; void paintRecessedFrame(QPainter *painter, const QRect &rect, const QPalette &palette, enum RecessedFrame rf, QPalette::ColorRole bgrole = QPalette::Window); void paintRecessedFrameShadow(QPainter *painter, const QRect &rect, enum RecessedFrame rf); int runtimeQtVersion(); /*-----------------------------------------------------------------------*/ // FIXME #if (QT_VERSION < QT_VERSION_CHECK(4, 3, 0)) #define lighter light #define darker dark #endif /*-----------------------------------------------------------------------*/ #define array_elements(a) (sizeof(a) / sizeof(a[0])) /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/src/sk_factory.h0000644000175000001440000001054711115152434015545 0ustar pepousers/* * skulpture_factory.h - Classical Three-Dimensional Artwork for Qt 4 * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef SKULPTURE_FACTORY_H #define SKULPTURE_FACTORY_H 1 /*-----------------------------------------------------------------------*/ #include #include #include class AbstractFactory { public: typedef qint8 Code; typedef const Code *Description; static const int MinVar = 1; static const int MaxVar = 9; public: enum OpCode { /* Values */ MinVal = -100, MaxVal = 100, GetVar = 100, Add = 110, Sub, Mul, Div, Min, Max, Mix, Cond, /* Colors */ RGB = 0, RGBA, RGBAf, Blend, Palette, Shade, Darker, Lighter, /* Conditions */ EQ = 0, NE, LT, GE, GT, LE, Or, And, Not, FactoryVersion, OptionVersion, OptionType, OptionComplex, OptionState, OptionRTL, /* Instructions */ SetVar = 100, /* Shape */ Move = 121, Line, Quad, Cubic, Close, /* Gradient */ ColorAt = 121, /* Frame */ /* Panel */ /* Primitive */ /* Control */ Begin = 118, Else = 119, End = 120, If = 126, While = 127, Nop = 0 }; protected: AbstractFactory() : p(0), opt(0) { } virtual ~AbstractFactory() { } protected: void setDescription(Description description) { p = description; } void setOption(const QStyleOption *option) { opt = option; } void setVar(int n, qreal value) { var[n] = value; } qreal getVar(int n) const { return var[n]; } void create(); protected: virtual void executeCode(Code code) QT_FASTCALL; virtual void skipCode(Code code) QT_FASTCALL; virtual int version() QT_FASTCALL { return 0; } protected: qreal evalValue() QT_FASTCALL; QColor evalColor() QT_FASTCALL; void skipValue() QT_FASTCALL; void skipColor() QT_FASTCALL; private: bool evalCondition() QT_FASTCALL; void skipCondition() QT_FASTCALL; private: Description p; const QStyleOption *opt; qreal var[MaxVar + 1]; }; /*-----------------------------------------------------------------------*/ class ShapeFactory : public AbstractFactory { public: static QPainterPath createShape(Description description, qreal var[]); static QPainterPath createShape(Description description); protected: ShapeFactory() : AbstractFactory() { } virtual ~ShapeFactory() { } void clear() { path = QPainterPath(); } const QPainterPath &getPath() const { return path; } protected: virtual void executeCode(Code code) QT_FASTCALL; virtual void skipCode(Code code) QT_FASTCALL; private: QPainterPath path; }; #define Pvalue(v) int(100 * (v) + 0.5) #define Pmove(x,y) ShapeFactory::Move, Pvalue(x), Pvalue(y) #define Pline(x,y) ShapeFactory::Line, Pvalue(x), Pvalue(y) #define Pquad(x,y,a,b) ShapeFactory::Quad, Pvalue(x), Pvalue(y), Pvalue(a), Pvalue(b) #define Pcubic(x,y,a,b,c,d) ShapeFactory::Cubic, Pvalue(x), Pvalue(y), Pvalue(a), Pvalue(b), Pvalue(c), Pvalue(d) #define Pend ShapeFactory::Close, ShapeFactory::End #define Pclose ShapeFactory::Close /*-----------------------------------------------------------------------*/ class GradientFactory : public AbstractFactory { public: static QGradient createGradient(Description description, qreal var[]); static QGradient createGradient(Description description); protected: GradientFactory() : AbstractFactory() { } virtual ~GradientFactory() { } protected: void clear() { gradient.setStops(QGradientStops()); } const QGradient &getGradient() const { return gradient; } protected: virtual void executeCode(Code code) QT_FASTCALL; virtual void skipCode(Code code) QT_FASTCALL; private: QGradient gradient; }; /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/src/skulpture.themerc0000600000175000001440000000257010731274506016634 0ustar pepousers[Misc] Name=Sculpture Name[ar]=نحت Name[an]=Escultura Name[bg]=Скулптура Name[br]=Kizellañ Name[bs]=Skulptura Name[ca]=Escultura Name[co]=Scultura Name[cs]=Socha Name[cy]=Cerfluniaeth Name[da]=Skulptur Name[de]=Skulptur Name[el]=Γλυπτική Name[eo]=Skulpturo Name[es]=Escultura Name[et]=Skulptuur Name[fi]=Kuvanveisto Name[fr]=Sculpture Name[he]=פיסול Name[hr]=Skulptura Name[hu]=Szobrászat Name[ia]=Sculptura Name[id]=Patung Name[it]=Scultura Name[io]=Skulto Name[ja]=彫刻 Name[ka]=ქანდაკება Name[lv]=Tēlniecība Name[lt]=Skulptūra Name[mk]=Вајарство Name[mt]=Skultura Name[nb]=Skulptur Name[nl]=Sculptuur Name[oc]=Escultura Name[pl]=Rzeźba Name[pt]=Escultura Name[ro]=Sculptură Name[ru]=Скульптура Name[sh]=Vajarstvo Name[sk]=Sochárstvo Name[sl]=Kiparstvo Name[sr]=Вајарство Name[sv]=Skulptur Name[sw]=Bombwe Name[tl]=Eskultura Name[tr]=Heykel Name[uk]=Скульптура Name[yi]=סקאלפטור Name[zh]=雕塑 Comment=Classical three-dimensional art Comment[de]=Dreidimensionale klassische Kunst Comment[eo]=Tri-dimensia formo arta Comment[es]=Arte de modelar Comment[fr]=Artistique en trois dimensions Comment[it]=Arte di dare forma Comment[nb]=Tredimensjonalt kunstverk Comment[nl]=Driedimensionale kunstwerk Comment[sv]=Konstverk i tre dimensioner ConfigPage=kstyle_skulpture_config [KDE] WidgetStyle=Skulpture skulpture-0.2.4/BUGS0000600000175000001440000000131511333632500013104 0ustar pepousers=== Known Bugs === While it is better to fix bugs instead of documenting them, this list still gives an overview of some quirks I am aware of. If you think you found a bug not listed, please report it to: Christoph Feck *** Icon Sizes *** Skulpture does not respect the "Small" and "Dialog" (large) icon sizes from System Settings in KDE 4.4. Instead, they always depend on the font size. *** Message Box Icons *** Skulpture does not show icons in standard message boxes with Qt versions earlier than Qt 4.5. *** Style Sheets *** Skulpture currently only supports a limited set of styling options using Qt style sheets. In particular, it only supports solid colors in the palette. skulpture-0.2.4/AUTHORS0000600000175000001440000000004510760371042013474 0ustar pepousersChristoph Feck skulpture-0.2.4/VERSION0000600000175000001440000000000611333666743013505 0ustar pepousers0.2.4 skulpture-0.2.4/Skulpture.qss0000644000175000001440000000231211113135772015162 0ustar pepousers/* * Sample Skulpture Style Sheet * * NOTE: This feature is considered experimental! * * Add the following entry to ~/.config/SkulptureStyle.ini * * [%General] * StyleSheetFileName=/path/to/Skulpture.qss * * For an overview, see http://doc.trolltech.com/latest/stylesheet.html * */ QProgressBar { selection-background-color: rgb(190, 180, 90); selection-color: rgb(130, 0, 0); } QGroupBox { font-weight: bold; color: rgba(0, 100, 0, 200); } QGroupBox:disabled { font-weight: bold; color: rgba(0, 100, 0, 80); } KTitleWidget > QFrame { background-color: rgb(180, 200, 210); } /*QTabWidget { background-color: rgb(200, 200, 120); }*/ /*KonqFrameTabs > QTabBar { background-color: rgb(200, 200, 120); }*/ /*QToolBar { background-color: rgb(80, 100, 120); color: rgb(30, 40, 220); }*/ /*QMenuBar { background-color: rgb(180, 200, 220); color: rgb(0, 0, 180); }*/ QMenuBar:selected:!disabled { background-color: rgb(100, 200, 40); color: rgb(250, 220, 150); } QMenu { background-color: rgb(100, 200, 150); color: rgb(0, 80, 0); } QMenu::item:selected:!disabled { background-color: rgb(70, 140, 220); color: rgb(230, 230, 230); } skulpture-0.2.4/kwin-client/0000700000175000001440000000000011333667516014662 5ustar pepousersskulpture-0.2.4/kwin-client/CMakeLists.txt0000600000175000001440000000105311117566534017421 0ustar pepousersproject (kwin-skulpture) set (kwin_skulpture_SOURCES kwin_skulpture.cpp) kde4_add_plugin (kwin3_skulpture ${kwin_skulpture_SOURCES}) if (KDE4WORKSPACE_FOUND) target_link_libraries (kwin3_skulpture ${KDE4_KDEUI_LIBS} ${KDE4WORKSPACE_KDECORATIONS_LIBS}) else (KDE4WORKSPACE_FOUND) target_link_libraries (kwin3_skulpture ${KDE4_KDEUI_LIBS} kdecorations) endif (KDE4WORKSPACE_FOUND) install (TARGETS kwin3_skulpture DESTINATION ${PLUGIN_INSTALL_DIR}) install (FILES skulpture.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin) add_subdirectory (config) skulpture-0.2.4/kwin-client/skulpture.desktop0000600000175000001440000000201310751365120020276 0ustar pepousers[Desktop Entry] Name=Sculpture Name[ar]=نحت Name[an]=Escultura Name[bg]=Скулптура Name[br]=Kizellañ Name[bs]=Skulptura Name[ca]=Escultura Name[co]=Scultura Name[cs]=Socha Name[cy]=Cerfluniaeth Name[da]=Skulptur Name[de]=Skulptur Name[el]=Γλυπτική Name[eo]=Skulpturo Name[es]=Escultura Name[et]=Skulptuur Name[fi]=Kuvanveisto Name[fr]=Sculpture Name[he]=פיסול Name[hr]=Skulptura Name[hu]=Szobrászat Name[ia]=Sculptura Name[id]=Patung Name[it]=Scultura Name[io]=Skulto Name[ja]=彫刻 Name[ka]=ქანდაკება Name[lv]=Tēlniecība Name[lt]=Skulptūra Name[mk]=Вајарство Name[mt]=Skultura Name[nb]=Skulptur Name[nl]=Sculptuur Name[oc]=Escultura Name[pl]=Rzeźba Name[pt]=Escultura Name[ro]=Sculptură Name[ru]=Скульптура Name[sh]=Vajarstvo Name[sk]=Sochárstvo Name[sl]=Kiparstvo Name[sr]=Вајарство Name[sv]=Skulptur Name[sw]=Bombwe Name[tl]=Eskultura Name[tr]=Heykel Name[uk]=Скульптура Name[yi]=סקאלפטור Name[zh]=雕塑 X-KDE-Library=kwin3_skulpture skulpture-0.2.4/kwin-client/config/0000700000175000001440000000000011256277460016126 5ustar pepousersskulpture-0.2.4/kwin-client/config/CMakeLists.txt0000600000175000001440000000053611115142744020662 0ustar pepousersset (kwin_skulpture_config_SOURCES kwin_skulpture_config.cpp) kde4_add_ui_files(kwin_skulpture_config_SOURCES kwin_skulpture_dialog.ui) kde4_add_plugin (kwin_skulpture_config ${kwin_skulpture_config_SOURCES}) target_link_libraries (kwin_skulpture_config ${KDE4_KDEUI_LIBS}) install (TARGETS kwin_skulpture_config DESTINATION ${PLUGIN_INSTALL_DIR}) skulpture-0.2.4/kwin-client/config/kwin_skulpture_dialog.ui0000644000175000001440000002477111126046004023077 0ustar pepousers KWinSkulptureDialog true 0 Frame Fill window frames using titlebar colors false Fill only active window frames Border size: (default) pixels -1 -1 at bottom: (default) pixels -1 -1 Qt::Horizontal When selected, an additional dark border is drawn around the window decoration borders. This increases the contrast on window managers that do not add shadows. Add extra border for better contrast Title Title bar margin: (default) pixels -1 -1 Vertical text shift: -9 9 for maximized windows: -9 9 Qt::Horizontal 0 0 Horizontal alignment: Left true Center Right Qt::Horizontal 0 0 false Center on full window width true Symbols Symbol size factor: 0.500000000000000 2.000000000000000 0.100000000000000 1.000000000000000 Use application icon instead of menu symbol true Icon size: (default) pixels cm_UseTitleBarBorderColors toggled(bool) cm_DrawOnlyActiveFrames setEnabled(bool) cm_UseApplicationIcon toggled(bool) label_2 setEnabled(bool) cm_UseApplicationIcon toggled(bool) cm_IconSize setEnabled(bool) cm_TitleAlign_Left toggled(bool) cm_CenterFullWidth setDisabled(bool) cm_TitleAlign_Center toggled(bool) cm_CenterFullWidth setEnabled(bool) cm_TitleAlign_Right toggled(bool) cm_CenterFullWidth setDisabled(bool) skulpture-0.2.4/kwin-client/config/configmanager.h0000600000175000001440000001506711125517746021111 0ustar pepousers/* * configmanager.h - Skulpture window decoration for KDE * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef CONFIGMANAGER_H #define CONFIGMANAGER_H 1 /*-----------------------------------------------------------------------*/ #include #include #include #include #include class ConfigManager { public: ConfigManager() { /* */ } ~ConfigManager() { /* */ } public: void addWidgets(QWidget *parent) { typedef QList WidgetList; WidgetList widgets = parent->findChildren(QRegExp(QLatin1String("^cm_"))); for (WidgetList::const_iterator i = widgets.constBegin(); i != widgets.constEnd(); ++i) { QWidget *widget = *i; items.append(ConfigItem(widget, QVariant())); items.last().configDefault = items.last().value(); } } void connectConfigChanged(QObject *receiver, const char slot[]) const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { item->connectValueChanged(receiver, slot); } } void save(KConfigGroup &configGroup) const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { QVariant value = item->value(); if (!value.isNull()) { if (value == item->configDefault) { configGroup.deleteEntry(item->configLabel()); } else { configGroup.writeEntry(item->configLabel(), value); } } } } void load(const KConfigGroup &configGroup) const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { item->setValue(((ConfigItem) *item).configSaved = configGroup.readEntry(item->configLabel(), item->configDefault.isNull() ? QString() : item->configDefault)); } } bool hasChanged() const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { if (item->configSaved != item->value()) { return true; } } return false; } void defaults() const { for (ItemList::const_iterator item = items.constBegin(); item != items.constEnd(); ++item) { item->setValue(item->configDefault); } } private: class ConfigItem { public: ConfigItem(QWidget *widget, const QVariant &def = QVariant()) : configWidget(widget), configDefault(def) { /* */ } public: void setValue(const QVariant &value) const; QVariant value() const; void connectValueChanged(QObject *receiver, const char slot[]) const; QString configLabel() const; QString radioLabel() const; public: QWidget *configWidget; QVariant configDefault; QVariant configSaved; }; private: typedef QList ItemList; private: ItemList items; }; void ConfigManager::ConfigItem::setValue(const QVariant &value) const { if (QCheckBox *widget = qobject_cast(configWidget)) { widget->setChecked(value.toBool()); } else if (QSpinBox *widget = qobject_cast(configWidget)) { widget->setValue(value.toInt()); } else if (QDoubleSpinBox *widget = qobject_cast(configWidget)) { widget->setValue(value.toDouble()); } else if (QRadioButton *widget = qobject_cast(configWidget)) { widget->setChecked(value.toString() == radioLabel()); } } QVariant ConfigManager::ConfigItem::value() const { if (QCheckBox *widget = qobject_cast(configWidget)) { return widget->isChecked(); } else if (QSpinBox *widget = qobject_cast(configWidget)) { return widget->value(); } else if (QDoubleSpinBox *widget = qobject_cast(configWidget)) { return widget->value(); } else if (QRadioButton *widget = qobject_cast(configWidget)) { return widget->isChecked() ? radioLabel() : QVariant(); } return QVariant(); } void ConfigManager::ConfigItem::connectValueChanged(QObject *receiver, const char slot[]) const { if (QCheckBox *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(toggled(bool)), receiver, slot); } else if (QSpinBox *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(valueChanged(int)), receiver, slot); } else if (QDoubleSpinBox *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(valueChanged(double)), receiver, slot); } else if (QRadioButton *widget = qobject_cast(configWidget)) { QObject::connect(widget, SIGNAL(toggled(bool)), receiver, slot); } } QString ConfigManager::ConfigItem::configLabel() const { QString cmName = configWidget->objectName().mid(3); if (qobject_cast(configWidget)) { int index = cmName.lastIndexOf(QChar('_', 0)); cmName = cmName.left(index); } return cmName; } QString ConfigManager::ConfigItem::radioLabel() const { QString cmName = configWidget->objectName().mid(3); int index = cmName.lastIndexOf(QChar('_', 0)); return cmName.mid(index + 1); } /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/kwin-client/config/kwin_skulpture_config.cpp0000600000175000001440000000502411116104405023227 0ustar pepousers/* * kwin_skulpture_config.cpp - Skulpture window decoration for KDE * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "kwin_skulpture_config.h" #include #include #include #include /*-----------------------------------------------------------------------*/ extern "C" KDE_EXPORT QObject *allocate_config(KConfig *conf, QWidget *parent) { return new SkulptureConfig(conf, parent); } /*-----------------------------------------------------------------------*/ SkulptureConfig::SkulptureConfig(KConfig *config, QWidget *parent) : QObject(parent) { Q_UNUSED(config); init(parent); } void SkulptureConfig::init(QWidget *parent) { skulptureConfig = new KConfig(QLatin1String("kwinskulpturerc")); KGlobal::locale()->insertCatalog(QLatin1String("kwin_clients")); ui = new SkulptureConfigUi(parent); configManager.addWidgets(ui); load(KConfigGroup(skulptureConfig, "General")); configManager.connectConfigChanged(this, SLOT(slotSelectionChanged())); } SkulptureConfig::~SkulptureConfig() { delete skulptureConfig; delete ui; } void SkulptureConfig::load(const KConfigGroup &configGroup) { Q_UNUSED(configGroup); configManager.load(KConfigGroup(skulptureConfig, "General")); } void SkulptureConfig::save(KConfigGroup &configGroup) { Q_UNUSED(configGroup); KConfigGroup skulptureConfigGroup(skulptureConfig, "General"); configManager.save(skulptureConfigGroup); skulptureConfig->sync(); } void SkulptureConfig::defaults() { configManager.defaults(); } void SkulptureConfig::slotSelectionChanged() { if (configManager.hasChanged()) { Q_EMIT changed(); } } /*-----------------------------------------------------------------------*/ #include "kwin_skulpture_config.moc" skulpture-0.2.4/kwin-client/config/kwin_skulpture_config.h0000600000175000001440000000420211126044132022672 0ustar pepousers/* * kwin_skulpture_config.h - Skulpture window decoration for KDE * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef KWIN_SKULPTURE_CONFIG_H #define KWIN_SKULPTURE_CONFIG_H 1 /*-----------------------------------------------------------------------*/ #include "ui_kwin_skulpture_dialog.h" class SkulptureConfigUi : public QWidget, public Ui::KWinSkulptureDialog { Q_OBJECT public: explicit SkulptureConfigUi(QWidget *parent = 0) : QWidget(parent) { setupUi(this); verticalLayout->setMargin(0); cm_BorderSize->updateGeometry(); cm_BottomBorderSize->updateGeometry(); } }; /*-----------------------------------------------------------------------*/ #include "configmanager.h" class SkulptureConfig : public QObject { Q_OBJECT public: explicit SkulptureConfig(KConfig *config, QWidget *parent = 0); virtual ~SkulptureConfig(); public Q_SLOTS: void load(const KConfigGroup &configGroup); void save(KConfigGroup &configGroup); void defaults(); Q_SIGNALS: void changed(); protected Q_SLOTS: void slotSelectionChanged(); private: void init(QWidget *parent); private: ConfigManager configManager; KConfig *skulptureConfig; SkulptureConfigUi *ui; }; /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/kwin-client/kwin_skulpture.cpp0000600000175000001440000004354611333667451020470 0ustar pepousers/* * kwin_skulpture.cpp - Skulpture window decoration for KDE * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "kwin_skulpture.h" #include #include #include #include #include #include #include #include #include #include #include #include /*-----------------------------------------------------------------------*/ /** * The Skulpture window decoration for KDE actually is a wrapper. * It uses Qt's MDI window decoration. As such, it is very lightweight. * */ extern "C" KDE_EXPORT KDecorationFactory *create_factory() { return new SkulptureDecorationFactory(); } /*-----------------------------------------------------------------------*/ /* * When KWin is already running, it doesn't notice that * a new style has been installed, and QStyleFactory will * not find the new style. * * This function works around this Qt problem by manually * loading the style. * */ static QStyle *loadStyle(const QString &styleName) { QLibrary library; Q_FOREACH (const QString &path, QCoreApplication::libraryPaths()) { library.setFileName(path + QLatin1String("/styles/") + styleName); if (library.load()) { QString libName = library.fileName(); library.unload(); QPluginLoader plugin(libName); QStyleFactoryInterface *factory = qobject_cast(plugin.instance()); if (factory) { return factory->create(styleName); } } } return 0; } /*-----------------------------------------------------------------------*/ QtMdiDecorationButton::QtMdiDecorationButton(ButtonType type, KCommonDecoration *parent) : KCommonDecorationButton(type, parent) { init(); } void QtMdiDecorationButton::init() { const QtMdiDecoration *deco = (const QtMdiDecoration *) decoration(); if (deco->onScreen() >= 0) { setAttribute(Qt::WA_PaintOnScreen, deco->onScreen() == 0 ? false : true); } setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); setFocusPolicy(Qt::NoFocus); setAttribute(Qt::WA_OpaquePaintEvent, false); setAttribute(Qt::WA_Hover, true); } QtMdiDecorationButton::~QtMdiDecorationButton() { /* */ } void QtMdiDecorationButton::reset(unsigned long /*changed*/) { /* NOTE: must be implemented, because it is declared pure */ } void QtMdiDecorationButton::initStyleOption(QStyleOptionButton &opt) { const QtMdiDecoration *deco = (const QtMdiDecoration *) decoration(); const bool isActive = deco->isActive(); QFont font = deco->options()->font(isActive); opt.init(this); font.setPointSizeF(font.pointSizeF() * deco->symbolSize); opt.fontMetrics = QFontMetrics(font); if (isDown()) { opt.state |= QStyle::State_Selected; } else { opt.state &= ~QStyle::State_Selected; } if (isActive) { opt.state |= QStyle::State_Active; } else { opt.state &= ~QStyle::State_Active; } opt.palette.setColor(QPalette::Window, deco->options()->color(KCommonDecoration::ColorTitleBar, isActive)); } void QtMdiDecorationButton::paintEvent(QPaintEvent */* event */) { const QtMdiDecoration *deco = (const QtMdiDecoration *) decoration(); QPainter painter(this); QStyleOptionButton opt; initStyleOption(opt); const int iconSize = deco->iconSize > 0 ? deco->iconSize : parentWidget()->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, this); QIcon::Mode iconMode = QIcon::Normal; if (isDown()) { iconMode = QIcon::Selected; } else if (opt.state & QStyle::State_MouseOver) { iconMode = QIcon::Active; } QStyle::StandardPixmap sp; switch (type()) { case OnAllDesktopsButton: sp = QStyle::StandardPixmap(QStyle::SP_CustomBase + (deco->isOnAllDesktops() ? 2 : 1)); break; case MenuButton: sp = QStyle::SP_TitleBarMenuButton; break; case AboveButton: sp = QStyle::StandardPixmap(QStyle::SP_CustomBase + (deco->keepAbove() ? 6 : 4)); break; case BelowButton: sp = QStyle::StandardPixmap(QStyle::SP_CustomBase + (deco->keepBelow() ? 7 : 5)); break; case HelpButton: sp = QStyle::SP_TitleBarContextHelpButton; break; case MinButton: sp = QStyle::SP_TitleBarMinButton; break; case MaxButton: sp = deco->maximizeMode() == KDecoration::MaximizeFull ? QStyle::SP_TitleBarNormalButton : QStyle::SP_TitleBarMaxButton; break; case ShadeButton: sp = deco->isShade() ? QStyle::SP_TitleBarUnshadeButton : QStyle::SP_TitleBarShadeButton; break; case CloseButton: sp = QStyle::SP_TitleBarCloseButton; break; default: sp = QStyle::SP_CustomBase; break; } opt.palette.setColor(QPalette::Text, deco->options()->color(KCommonDecoration::ColorFont, opt.state & QStyle::State_Active)); const int shift = opt.state & QStyle::State_Selected ? 1 : 0; const bool useIcon = (sp == QStyle::SP_TitleBarMenuButton) && deco->useIcon(); const QIcon icon = useIcon ? deco->icon().pixmap(iconSize, iconSize, iconMode) : parentWidget()->style()->standardIcon(sp, &opt, this); painter.setOpacity(opt.state & QStyle::State_Active ? 1.0 : 0.7); icon.paint(&painter, rect().adjusted(shift, shift, shift, shift), Qt::AlignCenter, iconMode); } /*-----------------------------------------------------------------------*/ QtMdiDecoration::QtMdiDecoration(KDecorationBridge *bridge, KDecorationFactory *factory, QStyle *s) : KCommonDecoration(bridge, factory), style(s) { /* */ } QtMdiDecoration::~QtMdiDecoration() { /* */ } QString QtMdiDecoration::visibleName() const { return i18n("Sculpture"); } void QtMdiDecoration::initStyleOption(QStyleOption &opt) { opt.init(widget()); opt.fontMetrics = QFontMetrics(options()->font(isActive())); if (isActive()) { opt.state |= QStyle::State_Active; } else { opt.state &= ~QStyle::State_Active; } } bool QtMdiDecoration::decorationBehaviour(DecorationBehaviour behaviour) const { switch (behaviour) { case DB_MenuClose: case DB_WindowMask: case DB_ButtonHide: return true; default: return KCommonDecoration::decorationBehaviour(behaviour); } } void QtMdiDecoration:: updateWindowShape() { QStyleOptionTitleBar option; initStyleOption(option); QStyleHintReturnMask mask; if ((widget()->style())->styleHint(QStyle::SH_WindowFrame_Mask, &option, widget(), &mask)) { setMask(mask.region); } else { setMask(QRegion(widget()->rect())); } } int QtMdiDecoration::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *button) const { bool border = !(maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows()); switch (lm) { case LM_BorderLeft: case LM_BorderRight: return border ? borderWidth : 0; case LM_BorderBottom: return border ? borderHeight : 0; case LM_TitleBorderLeft: case LM_TitleBorderRight: return borderWidth > 0 && border ? 4 : 0; case LM_TitleEdgeLeft: case LM_TitleEdgeRight: return borderWidth > 0 && border ? 8 : 0; case LM_TitleEdgeTop: return borderWidth > 0 && border ? 2 : 0; case LM_TitleEdgeBottom: return 1; case LM_TitleHeight: return titleHeight + 2; case LM_ButtonHeight: return borderWidth > 0 && border ? titleHeight : titleHeight + 3; case LM_ButtonWidth: return titleHeight; case LM_ButtonSpacing: return 0; case LM_ExplicitButtonSpacer: return 2; case LM_ButtonMarginTop: return 0; #if KDE_IS_VERSION(4,3,0) case LM_OuterPaddingLeft: case LM_OuterPaddingTop: case LM_OuterPaddingRight: case LM_OuterPaddingBottom: return 0; #endif } return KCommonDecoration::layoutMetric(lm, respectWindowState, button); } KCommonDecorationButton *QtMdiDecoration::createButton(ButtonType type) { return new QtMdiDecorationButton(type, this); } void QtMdiDecoration::init() { QWidget wid; KConfig configFile(QLatin1String("kwinskulpturerc")); KConfigGroup conf(&configFile, "General"); QString styleName = conf.readEntry("QtStyle", QString()); if (!styleName.isEmpty()) { style = loadStyle(styleName); if (!style) { style = QStyleFactory::create(styleName); } } if (style) { wid.setStyle(style); } if (wid.style()) { QStyleOptionTitleBar option; option.init(&wid); option.fontMetrics = QFontMetrics(options()->font(true)); borderWidth = wid.style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, &option, 0); titleHeight = wid.style()->pixelMetric(QStyle::PM_TitleBarHeight, &option, 0); noBorder = wid.style()->styleHint(QStyle::SH_TitleBar_NoBorder, &option, 0); autoRaise = wid.style()->styleHint(QStyle::SH_TitleBar_AutoRaise, &option, 0); } else { borderWidth = 4; titleHeight = 20; noBorder = false; autoRaise = false; } coloredFrame = conf.readEntry("UseTitleBarBorderColors", false); contrastFrame = conf.readEntry("UseExtraContrastBorder", false); showIcon = conf.readEntry("UseApplicationIcon", true); onlyActiveFrame = conf.readEntry("DrawOnlyActiveFrames", false); paintOnScreen = -1; if (conf.hasKey("PaintOnScreen")) { paintOnScreen = conf.readEntry("PaintOnScreen", false) ? 1 : 0; } textShift = conf.readEntry("TextShift", 0); textShiftMaximized = conf.readEntry("TextShiftMaximized", 0); QChar c = QChar('l', 0); QString align = conf.readEntry("TitleAlign", QString()); if (!align.isEmpty()) { c = align.at(0).toLower(); } switch (c.toAscii()) { case 'c': titleAlignment = Qt::AlignHCenter; break; case 'r': titleAlignment = Qt::AlignRight; break; default: titleAlignment = Qt::AlignLeft; break; } centerFullWidth = conf.readEntry("CenterFullWidth", true); iconSize = conf.readEntry("IconSize", -1); symbolSize = conf.readEntry("SymbolSize", 1.0); if (conf.readEntry("TitleHeight", -1) >= 0) { titleHeight = QFontMetrics(options()->font(true)).height() + conf.readEntry("TitleHeight", 8) - 4; } if (conf.readEntry("BorderSize", -1) >= 0) { borderWidth = conf.readEntry("BorderSize", borderWidth); } borderHeight = borderWidth; if (conf.readEntry("BottomBorderSize", -1) >= 0) { borderHeight = conf.readEntry("BottomBorderSize", borderWidth); } if (contrastFrame) { borderWidth += 1; borderHeight += 1; } KCommonDecoration::init(); if (wid.style()) widget()->setStyle(wid.style()); widget()->setAutoFillBackground(false); widget()->setAttribute(Qt::WA_NoSystemBackground, true); widget()->setAttribute(Qt::WA_OpaquePaintEvent, true); if (paintOnScreen >= 0) { widget()->setAttribute(Qt::WA_PaintOnScreen, paintOnScreen == 0 ? false : true); } } void QtMdiDecoration::paintEvent(QPaintEvent */*event */) { bool border = !(maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows()); // QWidget *w = widget(); QStylePainter painter(widget()); // draw the title bar QStyleOptionTitleBar option; initStyleOption(option); option.titleBarState = option.state; option.subControls = QStyle::SC_TitleBarLabel; // | QStyle::SC_TitleBarSysMenu; if (noBorder) { option.rect.setHeight(titleHeight); } else { option.rect.adjust(4, 4, -4, -4); option.rect.setHeight(titleHeight); } if (!border || borderWidth == 0) { option.rect.adjust(-6, 0, 6, 0); } option.text = QString(); #if 0 option.icon = decoration()->icon(); option.titleBarFlags = Qt::WindowSystemMenuHint; #else option.titleBarFlags = 0; #endif // option.palette = options()->palette(ColorTitleBar, isActive()); if (coloredFrame && border && (!onlyActiveFrame || isActive())) { painter.fillRect(widget()->rect(), options()->color(ColorTitleBar, isActive())); } else { painter.fillRect(widget()->rect(), option.palette.color(QPalette::Window)); if (borderHeight >= borderWidth + 2) { QPalette palette; palette.setCurrentColorGroup(QPalette::Disabled); qDrawShadeLine(&painter, 1, widget()->rect().bottom() + qMax(2, borderWidth) - borderHeight, widget()->rect().right(), widget()->rect().bottom() + qMax(borderWidth, 2) - borderHeight, palette); } } QFont font = options()->font(isActive()); painter.setFont(font); option.palette.setColor(QPalette::Highlight, options()->color(ColorTitleBar, true)); option.palette.setColor(QPalette::HighlightedText, options()->color(ColorFont, true)); option.palette.setColor(QPalette::Window, options()->color(ColorTitleBar, false)); option.palette.setColor(QPalette::WindowText, options()->color(ColorFont, false)); // option.rect = painter.style()->subControlRect(QStyle::CC_TitleBar, &option, QStyle::SC_TitleBarCloseButton, widget()); painter.drawComplexControl(QStyle::CC_TitleBar, option); // draw the title caption // TODO use MDI code painter.save(); border = borderWidth > 0 && border; int captionWidth = width() - buttonsLeftWidth() - buttonsRightWidth() - (border ? 16 : 4); option.text = option.fontMetrics.elidedText(caption(), Qt::ElideMiddle, captionWidth); QRect labelRect = QRect((border ? 8 : 2) + buttonsLeftWidth(), 0, captionWidth, titleHeight + 4); Qt::Alignment alignment = titleAlignment; if (titleAlignment & Qt::AlignHCenter && centerFullWidth) { if (labelRect.left() > (width() - option.fontMetrics.boundingRect(option.text).width()) >> 1) { alignment = Qt::AlignLeft; } else if (labelRect.right() < (width() + option.fontMetrics.boundingRect(option.text).width()) >> 1) { alignment = Qt::AlignRight; } else { labelRect = QRect(0, 0, width(), titleHeight + 4); } } if (border) { labelRect.adjust(0, -textShift, 0, -textShift); } else { labelRect.adjust(0, -textShiftMaximized, 0, -textShiftMaximized); } painter.setPen(QColor(0, 0, 0, 25)); painter.drawText(labelRect.adjusted(1, 1, 1, 1), alignment | Qt::AlignVCenter | Qt::TextSingleLine, option.text); QColor color = options()->color(ColorFont, isActive()); if (!(option.state & QStyle::State_Active)) { color.setAlpha((color.alpha() * 180) >> 8); } painter.setPen(color); painter.drawText(labelRect, alignment | Qt::AlignVCenter | Qt::TextSingleLine, option.text); painter.restore(); // draw the frame if (border) { QStyleOptionFrame frameOptions; initStyleOption(frameOptions); if (coloredFrame) { frameOptions.palette.setColor(QPalette::Window, options()->color(ColorTitleBar, isActive())); } frameOptions.lineWidth = borderWidth; if (contrastFrame) { QBrush outerLineFill = QColor(170, 170, 170); // QBrush outerLineFill = Qt::red; painter.fillRect(frameOptions.rect.adjusted(0, 0, 0, -frameOptions.rect.height() + 1), outerLineFill); painter.fillRect(frameOptions.rect.adjusted(0, frameOptions.rect.height() - 1, 0, 0), outerLineFill); painter.fillRect(frameOptions.rect.adjusted(0, 0, -frameOptions.rect.width() + 1, 0), outerLineFill); painter.fillRect(frameOptions.rect.adjusted(frameOptions.rect.width() - 1, 0, 0, 0), outerLineFill); frameOptions.rect.adjust(1, 1, -1, -1); } QRegion region = widget()->rect(); region -= widget()->rect().adjusted(borderWidth, borderWidth, -borderWidth, -borderWidth); painter.setClipRegion(region); painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions); } } /*-----------------------------------------------------------------------*/ SkulptureDecorationFactory::SkulptureDecorationFactory() { style = loadStyle(QLatin1String("skulpture")); } SkulptureDecorationFactory::~SkulptureDecorationFactory() { /* */ } KDecoration *SkulptureDecorationFactory::createDecoration(KDecorationBridge *bridge) { return (new QtMdiDecoration(bridge, this, style))->decoration(); } bool SkulptureDecorationFactory::reset(unsigned long changed) { resetDecorations(changed); return true; } bool SkulptureDecorationFactory::supports(Ability ability) const { switch (ability) { case AbilityAnnounceButtons: case AbilityButtonMenu: case AbilityButtonHelp: case AbilityButtonShade: case AbilityButtonMinimize: case AbilityButtonMaximize: case AbilityButtonClose: case AbilityButtonSpacer: return true; // the following three are only supported with Skulpture Qt style case AbilityButtonOnAllDesktops: case AbilityButtonAboveOthers: case AbilityButtonBelowOthers: return true; case AbilityAnnounceColors: case AbilityColorTitleBack: case AbilityColorTitleFore: return true; default: return false; } } /*-----------------------------------------------------------------------*/ #include "kwin_skulpture.moc" skulpture-0.2.4/kwin-client/kwin_skulpture.h0000600000175000001440000000662211333667022020121 0ustar pepousers/* * kwin_skulpture.h - Skulpture window decoration for KDE * * Copyright (c) 2008 Christoph Feck * * 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef KWIN_SKULPTURE_H #define KWIN_SKULPTURE_H 1 /*-----------------------------------------------------------------------*/ #include class QStyleOptionButton; class QtMdiDecorationButton : public KCommonDecorationButton { Q_OBJECT public: QtMdiDecorationButton(ButtonType type, KCommonDecoration *parent); virtual ~QtMdiDecorationButton(); virtual void reset(unsigned long changed); protected: virtual void paintEvent(QPaintEvent *event); protected: void initStyleOption(QStyleOptionButton &opt); private: void init(); }; /*-----------------------------------------------------------------------*/ class QStyleOption; class QtMdiDecoration : public KCommonDecoration { Q_OBJECT public: QtMdiDecoration(KDecorationBridge *bridge, KDecorationFactory *factory, QStyle *style = 0); virtual ~QtMdiDecoration(); public: virtual QString visibleName() const; virtual bool decorationBehaviour(DecorationBehaviour behaviour) const; virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton *button = 0) const; virtual void updateWindowShape(); virtual void init(); virtual KCommonDecorationButton *createButton(ButtonType type); virtual void paintEvent(QPaintEvent *event); bool useIcon() const { return showIcon; } int onScreen() const { return paintOnScreen; } int iconSize; qreal symbolSize; protected: void initStyleOption(QStyleOption &opt); private: /* cached style hints and pixel metrics */ bool coloredFrame : 1; bool contrastFrame : 1; bool noBorder : 1; bool autoRaise : 1; bool showIcon: 1; bool onlyActiveFrame : 1; bool centerFullWidth : 1; int paintOnScreen; int textShift; int textShiftMaximized; Qt::Alignment titleAlignment; int titleHeight; int borderWidth; int borderHeight; QStyle *style; }; /*-----------------------------------------------------------------------*/ #include class SkulptureDecorationFactory : public KDecorationFactory { public: SkulptureDecorationFactory(); virtual ~SkulptureDecorationFactory(); public: virtual KDecoration *createDecoration(KDecorationBridge *bridge); virtual bool reset(unsigned long changed); virtual bool supports(Ability ability) const; private: QStyle *style; }; /*-----------------------------------------------------------------------*/ #endif skulpture-0.2.4/uninstall.sh0000700000175000001440000000052610643267201014777 0ustar pepousers#! /bin/sh if [ -f install_manifest.txt ] ; then echo "The following files will be removed:" cat install_manifest.txt echo "Press RETURN to abort, or enter root's password to remove them." su -c "xargs rm -v < install_manifest.txt" && rm -f install_manifest.txt else echo "Cannot find install_manifest.txt, maybe not yet installed?" fi skulpture-0.2.4/color-schemes/0000700000175000001440000000000011333556030015165 5ustar pepousersskulpture-0.2.4/color-schemes/SkulptureVanilla.colors0000644000175000001440000000421111333563701021730 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=215,214,210 BackgroundNormal=220,219,214 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=235,216,108 BackgroundNormal=240,221,110 DecorationFocus=85,85,85 DecorationHover=243,66,143 ForegroundActive=191,92,0 ForegroundInactive=106,96,35 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Tooltip] BackgroundAlternate=249,236,149 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=250,248,244 BackgroundNormal=250,249,249 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Window] BackgroundAlternate=211,210,206 BackgroundNormal=215,214,209 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [General] Name=Skulpture-Vanilla [WM] activeBackground=144,98,13 activeForeground=255,255,255 inactiveBackground=201,200,195 inactiveForeground=46,52,54 skulpture-0.2.4/color-schemes/SkulptureMint.colors0000644000175000001440000000420011333563701021247 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=211,220,209 BackgroundNormal=217,220,213 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=80,126,65 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=142,191,81 BackgroundNormal=147,194,85 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=103,134,59 ForegroundLink=80,126,65 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Tooltip] BackgroundAlternate=250,242,149 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=159,107,33 ForegroundLink=80,126,65 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=245,250,245 BackgroundNormal=250,250,250 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=80,126,65 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Window] BackgroundAlternate=208,215,204 BackgroundNormal=213,215,209 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=80,126,65 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [General] Name=Skulpture-Mint [WM] activeBackground=74,115,47 activeForeground=255,255,255 inactiveBackground=198,201,194 inactiveForeground=46,52,54 skulpture-0.2.4/color-schemes/CMakeLists.txt0000600000175000001440000000020511005513503017716 0ustar pepousersfile (GLOB skulpture_COLORSCHEMES *.colors) install (FILES ${skulpture_COLORSCHEMES} DESTINATION ${DATA_INSTALL_DIR}/color-schemes) skulpture-0.2.4/color-schemes/SkulptureStone.colors0000644000175000001440000000421111333563701021432 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=187,187,187 BackgroundNormal=192,192,192 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=185,65,115 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=250,250,250 BackgroundNormal=255,255,255 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=191,174,63 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Tooltip] BackgroundAlternate=250,237,150 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=220,220,220 BackgroundNormal=224,224,224 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Window] BackgroundAlternate=171,171,171 BackgroundNormal=176,176,176 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=187,66,116 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [General] Name=Skulpture-Stone [WM] activeBackground=16,16,16 activeForeground=240,240,240 inactiveBackground=128,128,128 inactiveForeground=208,208,208 skulpture-0.2.4/color-schemes/SkulptureStrawberry.colors0000644000175000001440000000420711333563701022513 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=217,215,208 BackgroundNormal=217,220,213 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=62,130,56 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=230,121,150 BackgroundNormal=233,126,155 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=152,82,102 ForegroundLink=62,130,56 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Tooltip] BackgroundAlternate=255,235,144 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=62,130,56 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=250,245,243 BackgroundNormal=250,250,250 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=62,130,56 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Window] BackgroundAlternate=213,210,205 BackgroundNormal=213,215,209 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=62,130,56 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [General] Name=Skulpture-Strawberry [WM] activeBackground=115,55,79 activeForeground=255,255,255 inactiveBackground=198,201,194 inactiveForeground=46,52,54 skulpture-0.2.4/color-schemes/SkulptureBeton.colors0000600000175000001440000000420711333563701021406 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=194,194,194 BackgroundNormal=205,205,205 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=123,57,0 ForegroundInactive=144,144,144 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=126,153,202 BackgroundNormal=128,155,206 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=123,57,0 ForegroundInactive=85,85,255 ForegroundLink=64,91,158 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Tooltip] BackgroundAlternate=255,235,85 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=123,57,0 ForegroundInactive=144,144,144 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=226,226,226 BackgroundNormal=230,230,230 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=123,57,0 ForegroundInactive=144,144,144 ForegroundLink=62,77,120 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Window] BackgroundAlternate=186,189,183 BackgroundNormal=200,200,200 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=123,57,0 ForegroundInactive=144,144,144 ForegroundLink=98,103,167 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [General] Name=Skulpture-Beton [WM] activeBackground=124,159,211 activeForeground=0,0,0 inactiveBackground=147,147,147 inactiveForeground=52,52,52 skulpture-0.2.4/color-schemes/SkulptureChocolate.colors0000644000175000001440000000422611333563701022251 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=217,215,210 BackgroundNormal=217,220,213 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=116,98,6 BackgroundNormal=121,102,7 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=224,153,87 ForegroundInactive=159,149,111 ForegroundLink=232,82,144 ForegroundNegative=255,122,102 ForegroundNeutral=141,173,199 ForegroundNormal=230,230,230 ForegroundPositive=118,191,117 ForegroundVisited=105,146,170 [Colors:Tooltip] BackgroundAlternate=241,229,145 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=250,244,246 BackgroundNormal=250,250,250 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=173,2,2 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=155,153,103 [Colors:Window] BackgroundAlternate=213,208,205 BackgroundNormal=213,215,209 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=232,82,144 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=40,155,46 [General] Name=Skulpture-Chocolate [WM] activeBackground=79,52,7 activeForeground=255,255,255 inactiveBackground=198,201,194 inactiveForeground=46,52,54 skulpture-0.2.4/color-schemes/SkulptureIce.colors0000644000175000001440000000420011333563701021040 0ustar pepousers[ColorEffects:Disabled] Color=48,43,30 ColorAmount=0.125 ColorEffect=2 ContrastAmount=0.5 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [ColorEffects:Inactive] Color=227,170,0 ColorAmount=0.025 ColorEffect=2 ContrastAmount=0.25 ContrastEffect=1 IntensityAmount=0.05 IntensityEffect=0 [Colors:Button] BackgroundAlternate=210,215,220 BackgroundNormal=215,220,220 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=51,81,126 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Selection] BackgroundAlternate=135,170,217 BackgroundNormal=145,177,217 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=92,113,138 ForegroundLink=51,81,126 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Tooltip] BackgroundAlternate=250,236,153 BackgroundNormal=255,242,153 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=144,97,30 ForegroundLink=51,81,126 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=64,48,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:View] BackgroundAlternate=240,245,255 BackgroundNormal=250,250,255 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=51,81,126 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [Colors:Window] BackgroundAlternate=204,210,215 BackgroundNormal=210,215,215 DecorationFocus=85,85,85 DecorationHover=243,195,0 ForegroundActive=191,92,0 ForegroundInactive=117,80,25 ForegroundLink=51,81,126 ForegroundNegative=191,3,3 ForegroundNeutral=43,116,199 ForegroundNormal=0,0,0 ForegroundPositive=0,137,43 ForegroundVisited=100,74,155 [General] Name=Skulpture-Ice [WM] activeBackground=42,70,136 activeForeground=255,255,255 inactiveBackground=190,195,201 inactiveForeground=46,52,54 skulpture-0.2.4/COPYING0000600000175000001440000010451311023571545013467 0ustar pepousers GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . skulpture-0.2.4/PACKAGING0000600000175000001440000000175211115156603013640 0ustar pepousers=== Packaging Notes === *** Packaging *** Skulpture is currently released as a source tarball only. If you want to create a binary package for Skulpture, please include the following files. Recommended name for the package is something like "kde4-style-skulpture"; package name and paths may be different for your distribution. Documentation text files: * README, AUTHORS, COPYING, NEWS, NOTES, BUGS Installed configuration files: * /usr/share/kde4/apps/kstyle/themes/skulpture.themerc * /usr/share/kde4/apps/kwin/skulpture.desktop * /usr/share/kde4/apps/skulpture/pics/skulpture.png * /usr/share/kde4/apps/skulpture/skulptureui.rc * /usr/share/kde4/apps/color-schemes/Skulpture*.colors (multiple files) Installed binary files: * /usr/lib/qt4/plugins/styles/libskulpture.so * /usr/lib/kde4/kstyle_skulpture_config.so * /usr/lib/kde4/kwin3_skulpture.so * /usr/lib/kde4/kwin_skulpture_config.so You may wish to contact the author, so that he can add binary packages to the website. skulpture-0.2.4/NOTES.html0000600000175000001440000001255611333640042014210 0ustar pepousers Skulpture

Release Notes

Release Notes for Version 0.2

Double Click in Item Views

Under KDE 4.4, Skulpture respects the system setting for the double click mode from KDE. For older versions, you have to set the mode manually in ~/.config/SkulptureStyle.ini:

    [%General]
    UseSingleClickToActivateItems=false

KWin Important Change

Starting with version 0.2.4, the Skulpture KWin window decoration defaults to painting "on screen", because the previous method could cause problems, depending on the KWin version. If you do not use compositing, or if you otherwise experience performance or rendering regressions, you can enable the old method by using this option in ~/.kde/share/config/kwinskulpturerc:

    [General]
    PaintOnScreen=false

Disabling Shadows

Skulpture features rendering of real shadows inside sunken views. For views that are usually full-screen, such as Konsole, KWrite, or Konqueror, the shadows can degrade scrolling performance. To disable shadows in those views, use the following option in ~/.config/SkulptureStyle.ini:

    [%General]
    ExpensiveShadows=false

Slider Sizes

Due to changes in version 0.2.1, you will have to reconfigure slider sizes. Changing the scroll bar length only affects the minimum length the slider is going to have; it will usually be larger as its size grows proportionally to the amount of data visible.

Skulpture Requires Qt 4.4 on KDE

If you want to build Skulpture with the KDE configuration dialog and window decoration, you need Qt 4.4 or newer. The installation script does not check this; you will just get a compilation error, if you want to compile with an older version.

KDE Color Schemes

When running under KDE, Skulpture respects more colors from the KDE system settings. You may need to change the "Alternate Background" or other colors, as previous versions of Skulpture ignored some of them.

You can force using the Window colors for disabled widgets using the "Make disabled widgets transparent" option.

Vertical Text Shift

Setting an odd value for the text shift (-3, -1, +1, +3, etc.) results in widgets that are one pixel larger compared to even text shift values. This is intentional.

Layout Properties

Skulpture allows configuring several layout attributes, such as element dimensions and spacing between elements. Not all applications query these values from the style, so with some applications you might not get the desired effect. Please report this to the developers of the application in question.

You can set a global strut (e.g. 12 pixels) with qtconfig to get usable spin box controls with very small widgets.

Password Character

You can specifiy multiple password characters; the first one that is part of the widget font is used. Under KDE, use the KCharSelect program to find a suitable character.

Settings Preview

You can place the preview in a different position using the following option in ~/.config/SkulptureStyle.ini:

    [ConfigDialog]
    PreviewPosition={Top | Bottom | Left | Right | InTab | Hidden | Auto}

Starting with KDE 4.1, a bug in "System Settings" prevents the dialog from using alien widgets, resulting in annoying flicker. To work around this problem, please use "kcmshell4 style" instead of "systemsettings".


Release Notes for Version 0.1

KWin Buttons

The Skulpture KWin window decoration now supports more buttons. KDE may add a "sticky" button, which pins a window so that it is visible on all screens. If you want to remove that button, you can configure the buttons with the "System Settings" application.

Skulpture Color Schemes

This version of Skulpture comes with experimental KDE 4 color schemes. The "vanilla" flavour is considered the default color scheme, although Skulpture should work with other color schemes, too. Any feedback is appreciated.

Title Bar Colors

The Skulpture window decorations (KWin and MDI) now respect the colors from KDE System Settings. If you prefer a dark title bar as in Skulpture 0.0.4, you have to change the window title bar colors accordingly. You must select "Apply Colors to non-KDE Applications" for this to work for MDI colors, too.

Settings Preview

There is now a preview area in the style configuration page, so that you can see the effect of each option immediately. Known issues:

  • The window decoration colors in the preview do not reflect the colors KDE uses for its windows; they reflect the MDI window title bar coloring. See section above for title bar colors.
  • Whenever a setting is changed, a temporary file is updated on disk.
  • Updating the preview, when a setting is changed, may cause some flicker.
  • For the current range of available options, the preview is too excessive. Expect more options in future versions.
skulpture-0.2.4/install.sh0000700000175000001440000001335311117604732014437 0ustar pepousers#! /bin/sh ############################################################################ # # Skulpture User Installation Script # # Copyright (c) 2008 Christoph Feck # # 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 3 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ############################################################################ # # Version 1.0.3 (10-Dec-2008) # # Search in these directories for KDE4 # (in addition to standard KDEDIRS) KDE4_PATH=/opt/kde4:/usr/lib/kde4:/usr/local/kde4 # Default build type # Options are: Release, Debug, RelWithDebugInfo, MinSizeRel BUILD_TYPE=Release # Name of log file LOG=install_log.txt ############################################################################ # Welcome user LANG=C echo -e "Skulpture User Installation Script" echo > $LOG "-- Skulpture install log started:" `date +%F-%H:%M:%S` echo >> $LOG "-- Directory is:" $PWD echo >> $LOG "-- System is:" `uname -a` echo >> $LOG "-- PATH is:" $PATH echo >> $LOG "-- KDEDIRS is:" $KDEDIRS echo >> $LOG "-- KDE4_PATH is:" $KDE4_PATH ERROR=0 # Make sure cmake is installed CMAKE=`which 2> /dev/null cmake || echo "-"` echo >> $LOG "-- Found cmake:" $CMAKE if test ! -x $CMAKE ; then echo echo "ERROR: Required command \"cmake\" not found" echo " You need CMake 2.4 or newer. (http://www.cmake.org/)" ERROR=1 else $CMAKE --version >> $LOG fi # Make sure make is installed MAKE=`which 2> /dev/null make || echo "-"` if test ! -x $MAKE ; then MAKE=`which 2> /dev/null gmake || echo "-"` fi echo >> $LOG "-- Found make:" $MAKE if test ! -x $MAKE ; then echo echo "ERROR: Required command \"make\" not found" echo " You need make 3.80 or newer. (http://www.gnu.org/software/make/)" ERROR=1 else $MAKE --version >> $LOG fi # Make sure a C++ compiler is installed CC=`which 2> /dev/null c++ || echo "-"` if test ! -x $CC ; then CC=`which 2> /dev/null g++ || echo "-"` if test ! -x $CC ; then CC=`which 2> /dev/null CC || echo "-"` fi fi echo >> $LOG "-- Found c++:" $CC if test ! -x $CC ; then echo echo "ERROR: Required command \"c++\" not found" echo " You need a C++ compiler, e.g. GCC 4.1 or newer. (http://gcc.gnu.org/)" ERROR=1 else $CC --version >> $LOG fi # Come back after requirements are installed if test $ERROR = 1 ; then echo " Install the required commands and run this script again." fi # Make sure we are in the right directory if test ! -e ./CMakeLists.txt -o ! -x ./install.sh -o ! -d ./src -o ! -e ./src/skulpture.cpp; then echo echo "ERROR: This install script does not support out-of-source builds" echo " You need to \"cd\" to the directory containing this script." echo >> $LOG "ERROR: not in source directory" ERROR=1 fi # Add Skulpture version information to log echo -n >> $LOG "-- Skulpture version is: " cat >> $LOG ./VERSION # Look up kde4-config in KDE 4 binary path PATH=$PATH:`echo $KDEDIRS:$KDE4_PATH | sed 's|:|/bin:|g' | sed 's|/bin/bin|/bin|g'`/bin KDE4_CONFIG=`which kde4-config 2> /dev/null || echo "-"` # Set default install prefix (we get this from kde4-config) if test -x $KDE4_CONFIG ; then $KDE4_CONFIG --version >> $LOG KDE_PREFIX=`$KDE4_CONFIG --prefix` echo >> $LOG "-- Found KDE4:" $KDE_PREFIX # Make sure we have KWin decoration headers if test ! -e $KDE_PREFIX/include/kwinglobals.h ; then echo echo "WARNING: Optional header \"kwinglobals.h\" not found" echo " You need the kdebase-workspace header files to build" echo " the Skulpture window decoration." echo echo " If you are using binary packages, install package" echo " \"kdebase-workspace-dev\" and run this script again." echo >> $LOG "WARNING: kwinglobals.h not found" fi else echo >> $LOG "WARNING: KDE4 not found" echo >> $LOG "-- tried with PATH: " $PATH echo echo "WARNING: Optional command \"kde4-config\" not found" echo " You need KDE 4.0 or newer (http://www.kde.org/)" echo " to build the Skulpture KDE components." echo echo " If you have KDE4 installed, add the location" echo " of the KDE4 /bin directory to your PATH and run" echo " this script again." echo >> $LOG "WARNING: kde4-config not found" fi # If there are no errors, let's build if test $ERROR = 1 ; then echo -n "Installation FAILED" else echo -e "\nConfiguring (running \"$CMAKE .\") ..." && echo "-- Looking for Qt / KDE ..." && rm -rf ./CMakeCache.txt ./lib && $CMAKE -DCMAKE_INSTALL_PREFIX=$KDE_PREFIX -DCMAKE_BUILD_TYPE=$BUILD_TYPE . 2>> $LOG >> $LOG && grep -i "Found\ \(KDE\ \|Qt\)" $LOG && echo -e "\nBuilding (running \"$MAKE\") ..." && echo "-- This may take a while ..." && $MAKE 2>> $LOG >> $LOG && echo -e "\nInstalling (running \"sudo $MAKE install\") ..." && sudo $MAKE install 2>> $LOG >> $LOG && grep "\-\- Installing" $LOG && echo -n -e "\nInstallation done" || (tail -n 10 $LOG && echo -n -e "Installation FAILED.\nPlease report any build failures") fi # Build summary echo >> $LOG "-- Skulpture install log finished:" `date +%F-%H:%M:%S` echo ", log written to: \"$LOG\"" skulpture-0.2.4/configure0000700000175000001440000000013511273223051014325 0ustar pepousers#! /bin/sh cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` -DCMAKE_BUILD_TYPE=Release . skulpture-0.2.4/NOTES0000600000175000001440000001144511333640011013235 0ustar pepousers=== Release Notes === === RELEASE NOTES FOR VERSION 0.2 === *** Double Click in Item Views *** Under KDE 4.4, Skulpture respects the system setting for the double click mode from KDE. For older versions, you have to set the mode manually in ~/.config/SkulptureStyle.ini: [%General] UseSingleClickToActivateItems=false *** KWin Important Change *** Starting with version 0.2.4, the Skulpture KWin window decoration defaults to painting "on screen", because the previous method could cause problems, depending on the KWin version. If you do not use compositing, or if you otherwise experience performance or rendering regressions, you can enable the old method by using this option in ~/.kde/share/config/kwinskulpturerc: [General] PaintOnScreen=false *** Disabling Shadows *** Skulpture features rendering of real shadows inside sunken views. For views that are usually full-screen, such as Konsole, KWrite, or Konqueror, the shadows can degrade scrolling performance. To disable shadows in those views, use the following option in ~/.config/SkulptureStyle.ini: [%General] ExpensiveShadows=false *** Slider Sizes *** Due to changes in version 0.2.1, you will have to reconfigure slider sizes. Changing the scroll bar length only affects the minimum length the slider is going to have; it will usually be larger as its size grows proportionally to the amount of data visible. *** Skulpture Requires Qt 4.4 on KDE *** If you want to build Skulpture with the KDE configuration dialog and window decoration, you need Qt 4.4 or newer. The installation script does not check this; you will just get a compilation error, if you want to compile with an older version. *** KDE Color Schemes *** When running under KDE, Skulpture respects more colors from the KDE system settings. You may need to change the "Alternate Background" or other colors, as previous versions of Skulpture ignored some of them. You can force using the Window colors for disabled widgets using the "Make disabled widgets transparent" option. *** Vertical Text Shift *** Setting an odd value for the text shift (-3, -1, +1, +3, etc.) results in widgets that are one pixel larger compared to even text shift values. This is intentional. *** Layout Properties *** Skulpture allows configuring several layout attributes, such as element dimensions and spacing between elements. Not all applications query these values from the style, so with some applications you might not get the desired effect. Please report this to the developers of the application in question. You can set a global strut (e.g. 12 pixels) with qtconfig to get usable spin box controls with very small widgets. *** Password Character *** You can specifiy multiple password characters; the first one that is part of the widget font is used. Under KDE, use the KCharSelect program to find a suitable character. *** Settings Preview *** You can place the preview in a different position using the following option in ~/.config/SkulptureStyle.ini: [ConfigDialog] PreviewPosition={Top | Bottom | Left | Right | InTab | Hidden | Auto} Starting with KDE 4.1, a bug in "System Settings" prevents the dialog from using alien widgets, resulting in annoying flicker. To work around this problem, please use "kcmshell4 style" instead of "systemsettings". === RELEASE NOTES FOR VERSION 0.1 === *** KWin Buttons *** The Skulpture KWin window decoration now supports more buttons. KDE may add a "sticky" button, which pins a window so that it is visible on all screens. If you want to remove that button, you can configure the buttons with the "System Settings" application. *** Skulpture Color Schemes *** This version of Skulpture comes with experimental KDE 4 color schemes. The "vanilla" flavour is considered the default color scheme, although Skulpture should work with other color schemes, too. Any feedback is appreciated. *** Title Bar Colors *** The Skulpture window decorations (KWin and MDI) now respect the colors from KDE System Settings. If you prefer a dark title bar as in Skulpture 0.0.4, you have to change the window title bar colors accordingly. You must select "Apply Colors to non-KDE Applications" for this to work for MDI colors, too. *** Settings Preview *** There is now a preview area in the style configuration page, so that you can see the effect of each option immediately. Known issues: * The window decoration colors in the preview do not reflect the colors KDE uses for its windows; they reflect the MDI window title bar coloring. See section above for title bar colors. * Whenever a setting is changed, a temporary file is updated on disk. * Updating the preview, when a setting is changed, may cause some flicker. * For the current range of available options, the preview is too excessive. Expect more options in future versions. skulpture-0.2.4/config.h.cmake0000644000175000001440000000011511066264333015133 0ustar pepousers#ifndef __CONFIG_H__ #define __CONFIG_H__ #cmakedefine KDE4_FOUND 1 #endif