File indexing completed on 2024-04-28 05:32:13
0001 #ifndef oxygenqtsettings_h 0002 #define oxygenqtsettings_h 0003 /* 0004 * this file is part of the oxygen gtk engine 0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #include "oxygenanimationmodes.h" 0011 #include "oxygenapplicationname.h" 0012 #include "oxygengtkicons.h" 0013 #include "oxygengtkrc.h" 0014 #include "oxygenoption.h" 0015 #include "oxygenoptionmap.h" 0016 #include "oxygenpalette.h" 0017 #include "oxygenshadowconfiguration.h" 0018 #include "oxygensignal.h" 0019 #include "oxygenpathlist.h" 0020 #include "oxygenfontinfo.h" 0021 #include "pango/pango.h" 0022 0023 #include <gio/gio.h> 0024 0025 #include <iostream> 0026 #include <sstream> 0027 #include <map> 0028 #include <set> 0029 #include <string> 0030 #include <vector> 0031 0032 namespace Oxygen 0033 { 0034 0035 class QtSettings 0036 { 0037 0038 public: 0039 0040 //! constructor 0041 QtSettings( void ); 0042 0043 //! destructor 0044 virtual ~QtSettings( void ) 0045 { clearMonitoredFiles(); } 0046 0047 //! initialization flags 0048 enum Flags 0049 { 0050 AppName = 1<<0, 0051 Icons = 1<<1, 0052 Fonts = 1<<2, 0053 KdeGlobals = 1<<3, 0054 Oxygen = 1<<4, 0055 Colors = 1<<5, 0056 Extra = 1<<7, 0057 All = AppName|Icons|Fonts|KdeGlobals|Oxygen|Colors|Extra, 0058 Forced = 1<<6 0059 }; 0060 0061 //! sets whether wm shadows are supported 0062 bool isWMShadowsSupported( void ) const 0063 { return _wmShadowsSupported; } 0064 0065 //! returns user config dir 0066 std::string userConfigDir( void ) const 0067 { return _userConfigDir; } 0068 0069 //! initialize 0070 bool initialize( unsigned int flags = All ); 0071 0072 //! palette 0073 const Palette& palette( void ) const 0074 { return _palette; } 0075 0076 //! application name 0077 const ApplicationName& applicationName( void ) const 0078 { return _applicationName; } 0079 0080 //!@name oxygen style options 0081 //@{ 0082 0083 //! use effect to render active (mouse-over) icons 0084 bool useIconEffect( void ) const 0085 { return _useIconEffect; } 0086 0087 //! background gradient 0088 bool useBackgroundGradient( void ) const 0089 { return _useBackgroundGradient; } 0090 0091 //! background pixmap 0092 const std::string& backgroundPixmap( void ) const 0093 { return _backgroundPixmap; } 0094 0095 //! checkbox style 0096 enum CheckBoxStyle 0097 { 0098 CS_CHECK, 0099 CS_X 0100 }; 0101 0102 //! checkbox style 0103 CheckBoxStyle checkBoxStyle( void ) const 0104 { return _checkBoxStyle; } 0105 0106 //! tab style 0107 enum TabStyle 0108 { 0109 TS_SINGLE, 0110 TS_PLAIN 0111 }; 0112 0113 //! checkbox style 0114 TabStyle tabStyle( void ) const 0115 { return _tabStyle; } 0116 0117 //! 'add-line' buttons 0118 /*! corresponds to buttons located at the bottom (right) of vertical (horizontal) toolbars */ 0119 int scrollBarAddLineButtons( void ) const 0120 { return _scrollBarAddLineButtons; } 0121 0122 //! 'sub-line' buttons 0123 /*! corresponds to buttons located at the bottom (right) of vertical (horizontal) toolbars */ 0124 int scrollBarSubLineButtons( void ) const 0125 { return _scrollBarSubLineButtons; } 0126 0127 //! toolbar item separator 0128 bool toolBarDrawItemSeparator( void ) const 0129 { return _toolBarDrawItemSeparator; } 0130 0131 //! focus indicator in lists (not supported yet) 0132 bool viewDrawFocusIndicator( void ) const 0133 { return _viewDrawFocusIndicator; } 0134 0135 //! tree branch lines 0136 bool viewDrawTreeBranchLines( void ) const 0137 { return _viewDrawTreeBranchLines; } 0138 0139 //! transparent tooltips 0140 bool tooltipTransparent( void ) const 0141 { return _tooltipTransparent; } 0142 0143 //! styled frames in tooltips 0144 bool tooltipDrawStyledFrames( void ) const 0145 { return _tooltipDrawStyledFrames; } 0146 0147 //! arrow size 0148 enum ArrowSize 0149 { 0150 ArrowNormal, 0151 ArrowSmall, 0152 ArrowTiny 0153 }; 0154 0155 //! tree expander style 0156 bool viewDrawTriangularExpander( void ) const 0157 { return _viewDrawTriangularExpander; } 0158 0159 //! tree triangular expander size 0160 ArrowSize viewTriangularExpanderSize( void ) const 0161 { return _viewTriangularExpanderSize; } 0162 0163 //! true if views sort order indicator arrow direction must be inverted 0164 bool viewInvertSortIndicator( void ) const 0165 { return _viewInvertSortIndicator; } 0166 0167 //! menu highlight mode 0168 enum MenuHighlightMode 0169 { 0170 MM_DARK, 0171 MM_SUBTLE, 0172 MM_STRONG 0173 }; 0174 0175 MenuHighlightMode menuHighlightMode( void ) const 0176 { return _menuHighlightMode; } 0177 0178 //! window drag mode 0179 bool windowDragEnabled( void ) const 0180 { return _windowDragEnabled; } 0181 0182 //! window drag mode 0183 enum WindowDragMode 0184 { 0185 WD_MINIMAL, 0186 WD_FULL 0187 }; 0188 0189 //! window drag mode 0190 WindowDragMode windowDragMode( void ) const 0191 { return _windowDragMode; } 0192 0193 //! use window manager to handle move-resize 0194 bool useWMMoveResize( void ) const 0195 { return _useWMMoveResize; } 0196 0197 //! drag distance 0198 int startDragDist( void ) const 0199 { return _startDragDist; } 0200 0201 //! drag delay 0202 int startDragTime( void ) const 0203 { return _startDragTime; } 0204 0205 //@} 0206 0207 //!@name animation enable state 0208 //@{ 0209 0210 //! all animations 0211 bool animationsEnabled( void ) const 0212 { return _animationsEnabled; } 0213 0214 //! generic animations 0215 bool genericAnimationsEnabled( void ) const 0216 { return _genericAnimationsEnabled; } 0217 0218 //@} 0219 0220 //!@name animations type 0221 //@{ 0222 0223 AnimationType menuBarAnimationType( void ) const 0224 { return _menuBarAnimationType; } 0225 0226 AnimationType menuAnimationType( void ) const 0227 { return _menuAnimationType; } 0228 0229 AnimationType toolBarAnimationType( void ) const 0230 { return _toolBarAnimationType; } 0231 0232 //@} 0233 0234 //!@name animations duration 0235 //@{ 0236 0237 int genericAnimationsDuration( void ) const 0238 { return _genericAnimationsDuration; } 0239 0240 int menuBarAnimationsDuration( void ) const 0241 { return _menuBarAnimationsDuration; } 0242 0243 int menuBarFollowMouseAnimationsDuration( void ) const 0244 { return _menuBarFollowMouseAnimationsDuration; } 0245 0246 int menuAnimationsDuration( void ) const 0247 { return _menuAnimationsDuration; } 0248 0249 int menuFollowMouseAnimationsDuration( void ) const 0250 { return _menuFollowMouseAnimationsDuration; } 0251 0252 int toolBarAnimationsDuration( void ) const 0253 { return _toolBarAnimationsDuration; } 0254 0255 //@} 0256 0257 //!@name window decoration options 0258 //@{ 0259 0260 //! button size enumeration 0261 enum ButtonSize { 0262 ButtonSmall = 18, 0263 ButtonDefault = 20, 0264 ButtonLarge = 24, 0265 ButtonVeryLarge = 32, 0266 ButtonHuge = 48 0267 }; 0268 0269 //! button size 0270 ButtonSize buttonSize( void ) const 0271 { return _buttonSize; } 0272 0273 //! frame border enumeration 0274 enum FrameBorder { 0275 BorderNone = 0, 0276 BorderNoSide = 1, 0277 BorderTiny = 2, 0278 BorderDefault = 4, 0279 BorderLarge = 8, 0280 BorderVeryLarge = 12, 0281 BorderHuge = 18, 0282 BorderVeryHuge = 27, 0283 BorderOversized = 40 0284 }; 0285 0286 //! frame border 0287 FrameBorder frameBorder( void ) const 0288 { return _frameBorder; } 0289 0290 enum WindecoBlendType { 0291 SolidColor, 0292 RadialGradient, 0293 FollowStyleHint 0294 }; 0295 0296 WindecoBlendType windecoBlendType( void ) const 0297 { return _windecoBlendType; } 0298 0299 //! shadow configuration 0300 const ShadowConfiguration& shadowConfiguration( Palette::Group group ) const 0301 { 0302 switch( group ) 0303 { 0304 default: 0305 case Palette::Inactive: return _inactiveShadowConfiguration; 0306 case Palette::Active: return _activeShadowConfiguration; 0307 } 0308 } 0309 0310 int backgroundOpacity() const 0311 { 0312 return _backgroundOpacity; 0313 } 0314 0315 //! windeco font 0316 const FontInfo& WMFont( void ) const 0317 { return _WMFont; } 0318 0319 //! title alignment 0320 const PangoAlignment TitleAlignment( void ) const 0321 { return _titleAlignment; } 0322 0323 //@} 0324 0325 //! true if argb is enabled 0326 bool argbEnabled( void ) const 0327 { return _argbEnabled; } 0328 0329 //! true if argb is enabled 0330 bool widgetExplorerEnabled( void ) const 0331 { return _widgetExplorerEnabled; } 0332 0333 //! file monitor structure 0334 class FileMonitor 0335 { 0336 public: 0337 0338 //! constructor 0339 FileMonitor( void ): 0340 file( 0L ), 0341 monitor( 0L ) 0342 {} 0343 0344 //! gfile pointer 0345 GFile* file; 0346 GFileMonitor* monitor; 0347 Signal signal; 0348 }; 0349 0350 //! set of monitored files 0351 typedef std::map<std::string, FileMonitor> FileMap; 0352 0353 //! file monitors 0354 FileMap& monitoredFiles( void ) 0355 { return _monitoredFiles; } 0356 0357 protected: 0358 0359 //! read output from a command - replacement for not always working g_spawn_command_line_sync() 0360 bool runCommand( const std::string& command, char*& result ) const; 0361 0362 //! returns true if a given atom is supported 0363 bool isAtomSupported( const std::string& ) const; 0364 0365 //! kdeglobals settings 0366 /*! returns true if changed */ 0367 bool loadKdeGlobals( void ); 0368 0369 //! oxygen settings 0370 /*! returns true if changed */ 0371 bool loadOxygen( void ); 0372 0373 //! kde configuration path 0374 PathList kdeConfigPathList( void ) const; 0375 0376 //! kde icon path 0377 PathList kdeIconPathList( void ) const; 0378 0379 //! add icon theme to path list, accounting for theme inheritance (recursively) 0380 void addIconTheme( PathList&, const std::string& ); 0381 0382 //! init user config dir 0383 void initUserConfigDir( void ); 0384 0385 //! init application name 0386 void initApplicationName( void ) 0387 { _applicationName.initialize(); } 0388 0389 //! init argb support 0390 void initArgb( void ); 0391 0392 //! load kde icons 0393 void loadKdeIcons( void ); 0394 0395 //! default icon search path 0396 PathSet defaultIconSearchPath( void ) const; 0397 0398 //! load palette from kdeglobals 0399 void loadKdePalette( bool forced = false ); 0400 0401 //! update gtk colors 0402 /*! generates an RC string and pass it to gtk */ 0403 void generateGtkColors( void ); 0404 0405 //! add Html link colors to RC's current section 0406 void addLinkColors( const std::string& ); 0407 0408 //! load fonts from kdeglobals and pass to gtk 0409 void loadKdeFonts( void ); 0410 0411 //! extra kde globals options 0412 void loadKdeGlobalsOptions( void ); 0413 0414 //! oxygen options (from oxygenrc) 0415 void loadOxygenOptions( void ); 0416 0417 //! extra metrics options 0418 void loadExtraOptions( void ); 0419 0420 //! css shadows 0421 void setupCssShadows( const std::string&, bool enabled ); 0422 0423 //! sanitize path 0424 std::string sanitizePath( const std::string& ) const; 0425 0426 //! monitor file 0427 void monitorFile( const std::string& ); 0428 0429 //! clear monitored files 0430 void clearMonitoredFiles( void ); 0431 0432 private: 0433 0434 //! application 0435 /*! this is needed to deal with some application hacks */ 0436 ApplicationName _applicationName; 0437 0438 //! true if window manager shadows are supported 0439 /*! if true, disable CSD shadows */ 0440 bool _wmShadowsSupported; 0441 0442 //! kde global options 0443 OptionMap _kdeGlobals; 0444 0445 //! oxygen options 0446 OptionMap _oxygen; 0447 0448 //! user config directory 0449 std::string _userConfigDir; 0450 0451 //!@name icons 0452 //@{ 0453 0454 //! icon theme 0455 /*! todo: respect user settings here */ 0456 std::string _kdeIconTheme; 0457 0458 //! fallback icon theme 0459 /*! todo: respect user settings here */ 0460 std::string _kdeFallbackIconTheme; 0461 0462 //! loaded icon themes 0463 std::set<std::string> _iconThemes; 0464 0465 //@} 0466 0467 //! config path 0468 PathList _kdeConfigPathList; 0469 0470 //! icon path 0471 PathList _kdeIconPathList; 0472 0473 //! default icon path 0474 static const std::string _defaultKdeIconPath; 0475 0476 //! palette 0477 Palette _palette; 0478 0479 //!@name kde/oxygen style options 0480 //@{ 0481 0482 //! if true, inactive selection has different color from active 0483 bool _inactiveChangeSelectionColor; 0484 0485 //! active icon effect 0486 bool _useIconEffect; 0487 0488 //! background gradient 0489 bool _useBackgroundGradient; 0490 0491 //! background pixmap 0492 std::string _backgroundPixmap; 0493 0494 //! checkbox style 0495 CheckBoxStyle _checkBoxStyle; 0496 0497 //! checkbox style 0498 TabStyle _tabStyle; 0499 0500 //! 'add-line' buttons 0501 /*! corresponds to buttons located at the bottom (right) of vertical (horizontal) toolbars */ 0502 int _scrollBarAddLineButtons; 0503 0504 //! 'sub-line' buttons 0505 /*! corresponds to buttons located at the bottom (right) of vertical (horizontal) toolbars */ 0506 int _scrollBarSubLineButtons; 0507 0508 //! item separator 0509 bool _toolBarDrawItemSeparator; 0510 0511 //! transparent tooltips 0512 bool _tooltipTransparent; 0513 0514 //! framed tooltips 0515 bool _tooltipDrawStyledFrames; 0516 0517 //! focus indicator in views 0518 bool _viewDrawFocusIndicator; 0519 0520 //! true if tree lines should be drawn 0521 bool _viewDrawTreeBranchLines; 0522 0523 //! true if arrows are used for expanders 0524 bool _viewDrawTriangularExpander; 0525 0526 //! triangular expander size 0527 ArrowSize _viewTriangularExpanderSize; 0528 0529 //! true if views sort order indicator arrow direction must be inverted 0530 bool _viewInvertSortIndicator; 0531 0532 //! menu highlight mode 0533 MenuHighlightMode _menuHighlightMode; 0534 0535 //! window drag mode 0536 bool _windowDragEnabled; 0537 0538 //! window drag mode 0539 WindowDragMode _windowDragMode; 0540 0541 //! use window manager to handle window grab 0542 bool _useWMMoveResize; 0543 0544 //! drag distance 0545 int _startDragDist; 0546 0547 //! drag delay 0548 int _startDragTime; 0549 0550 //@} 0551 0552 //!@name animation options 0553 //@{ 0554 0555 //! all animations 0556 bool _animationsEnabled; 0557 0558 //! generic animations 0559 bool _genericAnimationsEnabled; 0560 0561 //! menubar animations 0562 AnimationType _menuBarAnimationType; 0563 0564 //! menu animations 0565 AnimationType _menuAnimationType; 0566 0567 //! toolbar animation type 0568 AnimationType _toolBarAnimationType; 0569 0570 //! generic animations 0571 int _genericAnimationsDuration; 0572 0573 //! menubar animations 0574 int _menuBarAnimationsDuration; 0575 0576 //! follow mouse animation 0577 int _menuBarFollowMouseAnimationsDuration; 0578 0579 //! menu animation 0580 int _menuAnimationsDuration; 0581 0582 //! follow mouse animation 0583 int _menuFollowMouseAnimationsDuration; 0584 0585 //! toolbar (follow-mouse) animation 0586 int _toolBarAnimationsDuration; 0587 0588 //@} 0589 0590 //!@name window decoration options 0591 //@{ 0592 0593 //! button size 0594 ButtonSize _buttonSize; 0595 0596 //! frame border 0597 FrameBorder _frameBorder; 0598 0599 //! Window decoration blend type 0600 WindecoBlendType _windecoBlendType; 0601 0602 //! active shadows 0603 ShadowConfiguration _activeShadowConfiguration; 0604 0605 //! inactive shadows 0606 ShadowConfiguration _inactiveShadowConfiguration; 0607 0608 //! oxygen-transparent background opacity 0609 int _backgroundOpacity; 0610 0611 //! windeco font 0612 FontInfo _WMFont; 0613 0614 //! title alignment 0615 PangoAlignment _titleAlignment; 0616 0617 //@} 0618 0619 //! true if argb is enabled 0620 bool _argbEnabled; 0621 0622 //! widget explorer 0623 bool _widgetExplorerEnabled; 0624 0625 //! initialization flags 0626 bool _initialized; 0627 bool _kdeColorsInitialized; 0628 bool _gtkColorsInitialized; 0629 0630 //! KDE running flags 0631 bool _KDESession; 0632 0633 //! gtk icons generator 0634 GtkIcons _icons; 0635 0636 //! gtkrc 0637 Gtk::RC _rc; 0638 0639 //! file monitors 0640 FileMap _monitoredFiles; 0641 0642 }; 0643 0644 } 0645 0646 #endif