Medical Imaging Interaction Toolkit  2018.4.99-064ad45c
Medical Imaging Interaction Toolkit
berryQtWorkbenchAdvisor.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "internal/berryQtGlobalEventFilter.h"
15 #include "berryWorkbenchPlugin.h"
16 #include "berryQtPreferences.h"
17 
18 #include <berryPlatform.h>
20 #include <berryIPreferences.h>
21 #include <berryIQtStyleManager.h>
22 
23 #include <QApplication>
24 #include <QString>
25 #include <QTextCodec>
26 
27 #include <Poco/File.h>
28 #include <Poco/FileStream.h>
29 
30 #include <vector>
31 
32 namespace berry
33 {
34 
36 {
37  WorkbenchAdvisor::Initialize(configurer);
38 
41  QString styleName = prefs->Get(QtPreferences::QT_STYLE_NAME, "");
42  QString fontName = prefs->Get(QtPreferences::QT_FONT_NAME, "Open Sans");
43  QString fontSize = prefs->Get(QtPreferences::QT_FONT_SIZE, "9");
44 
45  ctkServiceReference serviceRef = WorkbenchPlugin::GetDefault()->GetPluginContext()->getServiceReference<IQtStyleManager>();
46  if (serviceRef)
47  {
48  IQtStyleManager* styleManager = WorkbenchPlugin::GetDefault()->GetPluginContext()->getService<IQtStyleManager>(serviceRef);
49  styleManager->SetStyle(styleName);
50  styleManager->SetFont(fontName);
51  styleManager->SetFontSize(fontSize.toInt());
52  styleManager->UpdateWorkbenchFont();
53  }
54 
55  QObject* eventFilter = new QtGlobalEventFilter(qApp);
56  qApp->installEventFilter(eventFilter);
57 }
58 
59 }
ctkPluginContext * GetPluginContext()
void Initialize(IWorkbenchConfigurer::Pointer configurer) override
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
static const QString QT_FONT_NAME
static WorkbenchPlugin * GetDefault()
static const QString QT_STYLE_NAME
virtual void SetFont(const QString &fontName)=0
virtual void SetFontSize(const int fontSize)=0
virtual void SetStyle(const QString &fileName)=0
IPreferencesService * GetPreferencesService() const
static const QString QT_STYLES_NODE
virtual void Initialize(IWorkbenchConfigurer::Pointer configurer)
virtual void UpdateWorkbenchFont()=0
static const QString QT_FONT_SIZE