diff --git a/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchAdvisor.cpp b/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchAdvisor.cpp index e8ec1a0965..876001b044 100644 --- a/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchAdvisor.cpp +++ b/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchAdvisor.cpp @@ -1,57 +1,59 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "CustomViewerWorkbenchAdvisor.h" #include "CustomViewerWorkbenchWindowAdvisor.h" #include "berryIQtStyleManager.h" #include "org_mitk_example_gui_customviewer_Activator.h" const std::string CustomViewerWorkbenchAdvisor::DEFAULT_PERSPECTIVE_ID = "org.mitk.example.viewerperspective"; // //! [WorkbenchAdvisorCreateWindowAdvisor] berry::WorkbenchWindowAdvisor* CustomViewerWorkbenchAdvisor::CreateWorkbenchWindowAdvisor(berry::IWorkbenchWindowConfigurer::Pointer configurer) { wwAdvisor.reset(new CustomViewerWorkbenchWindowAdvisor(configurer)); return wwAdvisor.data(); } // //! [WorkbenchAdvisorCreateWindowAdvisor] CustomViewerWorkbenchAdvisor::~CustomViewerWorkbenchAdvisor() { } // //! [WorkbenchAdvisorInit] void CustomViewerWorkbenchAdvisor::Initialize(berry::IWorkbenchConfigurer::Pointer configurer) { berry::QtWorkbenchAdvisor::Initialize(configurer); ctkPluginContext* pluginContext = org_mitk_example_gui_customviewer_Activator::GetPluginContext(); ctkServiceReference serviceReference = pluginContext->getServiceReference(); //always granted by org.blueberry.ui.qt Q_ASSERT(serviceReference); berry::IQtStyleManager* styleManager = pluginContext->getService(serviceReference); Q_ASSERT(styleManager); QString styleName = "CustomStyle"; - styleManager->AddStyle("D:/Plattformprojekt/MITK/Examples/Plugins/org.mitk.example.gui.customviewer/resources/customstyle.qss", styleName); - styleManager->SetStyle("D:/Plattformprojekt/MITK/Examples/Plugins/org.mitk.example.gui.customviewer/resources/customstyle.qss"); + styleManager->AddStyle(":/customstyle.qss", styleName); + styleManager->SetStyle(":/customstyle.qss"); + //styleManager->AddStyle("/home/me/customstyle.qss", styleName); + //styleManager->SetStyle("/home/me/customstyle.qss"); } // //! [WorkbenchAdvisorInit] std::string CustomViewerWorkbenchAdvisor::GetInitialWindowPerspectiveId() { return DEFAULT_PERSPECTIVE_ID; -} \ No newline at end of file +} diff --git a/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchWindowAdvisor.cpp b/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchWindowAdvisor.cpp index 63e1c9115f..c6aa944a97 100644 --- a/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchWindowAdvisor.cpp +++ b/Examples/Plugins/org.mitk.example.gui.customviewer/src/internal/CustomViewerWorkbenchWindowAdvisor.cpp @@ -1,165 +1,165 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "CustomViewerWorkbenchWindowAdvisor.h" #include "org_mitk_example_gui_customviewer_Activator.h" #include "QtPerspectiveSwitcherTabBar.h" #include #include #include #include #include #include #include #include #include #include CustomViewerWorkbenchWindowAdvisor::CustomViewerWorkbenchWindowAdvisor(berry::IWorkbenchWindowConfigurer::Pointer configurer) : berry::WorkbenchWindowAdvisor(configurer) { } CustomViewerWorkbenchWindowAdvisor::~CustomViewerWorkbenchWindowAdvisor() { } void CustomViewerWorkbenchWindowAdvisor::PostWindowCreate() { //for stylesheet customization //static_cast(this->GetWindowConfigurer()->GetWindow()->GetShell()->GetControl())->dumpObjectTree(); } // //! [CustomViewerWorkbenchWindowAdvisorPreWindowOpen] void CustomViewerWorkbenchWindowAdvisor::PreWindowOpen() { berry::IWorkbenchWindowConfigurer::Pointer configurer = this->GetWindowConfigurer(); configurer->SetTitle("Spartan Viewer"); configurer->SetShowMenuBar(false); configurer->SetShowCoolBar(false); configurer->SetShowPerspectiveBar(false); configurer->SetShowStatusLine(false); } // //! [CustomViewerWorkbenchWindowAdvisorPreWindowOpen] // //! [WorkbenchWindowAdvisorCreateWindowContentsHead] void CustomViewerWorkbenchWindowAdvisor::CreateWindowContents(berry::Shell::Pointer shell) { //the all containing main window QMainWindow* mainWindow = static_cast(shell->GetControl()); // //! [WorkbenchWindowAdvisorCreateWindowContentsHead] mainWindow->setVisible(true); //the widgets QWidget* CentralWidget = new QWidget(mainWindow); CentralWidget->setObjectName("CentralWidget"); CentralWidget->setVisible(true); QtPerspectiveSwitcherTabBar* PerspectivesTabBar = new QtPerspectiveSwitcherTabBar(this->GetWindowConfigurer()->GetWindow()); PerspectivesTabBar->setObjectName("PerspectivesTabBar"); PerspectivesTabBar->addTab("Image Viewer"); PerspectivesTabBar->addTab("DICOM-Manager"); PerspectivesTabBar->setVisible(true); PerspectivesTabBar->setDrawBase(false); QPushButton* StyleUpdateButton = new QPushButton("Update Style", mainWindow); StyleUpdateButton->setMaximumWidth(100); StyleUpdateButton->setObjectName("StyleUpdateButton"); QObject::connect(StyleUpdateButton, SIGNAL( clicked() ), this, SLOT( UpdateStyle() )); QToolButton* OpenFileButton = new QToolButton(mainWindow); OpenFileButton->setMaximumWidth(100); OpenFileButton->setObjectName("FileOpenButton"); OpenFileButton->setText("Open File"); QObject::connect(OpenFileButton, SIGNAL( clicked() ), this, SLOT( OpenFile() )); QWidget* PageComposite = new QWidget(CentralWidget); PageComposite->setObjectName("PageComposite"); PageComposite->setVisible(true); //the layouts QVBoxLayout* CentralWidgetLayout = new QVBoxLayout(CentralWidget); CentralWidgetLayout->contentsMargins(); CentralWidgetLayout->setContentsMargins(9,9,9,9); CentralWidgetLayout->setSpacing(0); CentralWidgetLayout->setObjectName("CentralWidgetLayout"); QHBoxLayout* PerspectivesLayer = new QHBoxLayout(mainWindow); PerspectivesLayer->setObjectName("PerspectivesLayer"); QHBoxLayout* PageCompositeLayout = new QHBoxLayout(PageComposite); PageCompositeLayout->setContentsMargins(0,0,0,0); PageCompositeLayout->setSpacing(0); PageComposite->setLayout(PageCompositeLayout); // //! [WorkbenchWindowAdvisorCreateWindowContents] //all glued together mainWindow->setCentralWidget(CentralWidget); CentralWidgetLayout->addLayout(PerspectivesLayer); CentralWidgetLayout->addWidget(PageComposite); CentralWidget->setLayout(CentralWidgetLayout); PerspectivesLayer->addWidget(PerspectivesTabBar); PerspectivesLayer->addSpacing(300); PerspectivesLayer->addWidget(OpenFileButton); //for style customization convenience /*PerspectivesLayer->addSpacing(10); PerspectivesLayer->addWidget(StyleUpdateButton);*/ //for correct initial layout, see also bug#1654 CentralWidgetLayout->activate(); CentralWidgetLayout->update(); this->GetWindowConfigurer()->CreatePageComposite(static_cast(PageComposite)); // //! [WorkbenchWindowAdvisorCreateWindowContents] } // //! [WorkbenchWindowAdvisorUpdateStyle] void CustomViewerWorkbenchWindowAdvisor::UpdateStyle() { ctkPluginContext* pluginContext = org_mitk_example_gui_customviewer_Activator::GetPluginContext(); ctkServiceReference serviceReference = pluginContext->getServiceReference(); //granted by org.blueberry.ui.qt Q_ASSERT(serviceReference); berry::IQtStyleManager* styleManager = pluginContext->getService(serviceReference); Q_ASSERT(styleManager); - styleManager->SetStyle("D:/Plattformprojekt/MITK/Examples/Plugins/org.mitk.example.gui.customviewer/resources/customstyle.qss"); + styleManager->SetStyle("/home/me/customstyle.qss"); } // //! [WorkbenchWindowAdvisorUpdateStyle] // //! [WorkbenchWindowAdvisorOpenFile] void CustomViewerWorkbenchWindowAdvisor::OpenFile() { // Ask the user for a list of files to open QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Open", /*d->getLastFileOpenPath()*/ QString(), mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); if (fileNames.empty()) return; mitk::WorkbenchUtil::LoadFiles(fileNames, this->GetWindowConfigurer()->GetWindow(), false); // //! [WorkbenchWindowAdvisorOpenFile] // //! [WorkbenchWindowAdvisorOpenFilePerspActive] berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); std::string perspectiveId = "org.mitk.example.viewerperspective"; window->GetWorkbench()->ShowPerspective(perspectiveId, berry::IWorkbenchWindow::Pointer(window)); // //! [WorkbenchWindowAdvisorOpenFilePerspActive] -} \ No newline at end of file +}