| 239 | } |
| 240 | |
| 241 | void App::loadStyleSheet( std::string cssPath, bool updateCurrentStyleSheet ) { |
| 242 | if ( NULL == mUISceneNode ) |
| 243 | return; |
| 244 | CSS::StyleSheetParser parser; |
| 245 | |
| 246 | loadBaseStyleSheet(); |
| 247 | |
| 248 | if ( NULL != mUISceneNode && !cssPath.empty() && parser.loadFromFile( cssPath ) ) { |
| 249 | if ( mUseDefaultTheme ) { |
| 250 | mUISceneNode->combineStyleSheet( parser.getStyleSheet() ); |
| 251 | } else { |
| 252 | mUISceneNode->setStyleSheet( parser.getStyleSheet() ); |
| 253 | } |
| 254 | |
| 255 | if ( updateCurrentStyleSheet ) { |
| 256 | mCurrentStyleSheet = cssPath; |
| 257 | |
| 258 | std::string folder( FileSystem::fileRemoveFileName( cssPath ) ); |
| 259 | |
| 260 | bool keepWatch = false; |
| 261 | |
| 262 | for ( auto& directory : mFileWatcher->directories() ) { |
| 263 | if ( directory == folder ) |
| 264 | keepWatch = true; |
| 265 | } |
| 266 | |
| 267 | if ( !keepWatch ) { |
| 268 | if ( mStyleSheetWatch != 0 ) |
| 269 | mFileWatcher->removeWatch( mStyleSheetWatch ); |
| 270 | |
| 271 | mStyleSheetWatch = mFileWatcher->addWatch( folder, mListener ); |
| 272 | } |
| 273 | |
| 274 | if ( !mSplitter->isDocumentOpen( cssPath ) ) { |
| 275 | SceneManager::instance()->setCurrentUISceneNode( mAppUISceneNode ); |
| 276 | mSplitter->loadFileFromPathInNewTab( cssPath ); |
| 277 | SceneManager::instance()->setCurrentUISceneNode( mUISceneNode ); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | void App::tryUpdateWatch( const std::string& file ) { |
| 284 | std::string folder( FileSystem::fileRemoveFileName( file ) ); |
nothing calls this directly
no test coverage detected