2 * Definitions for Qt4 based control panel
5 #include "controlpanel.h"
10 #ifndef CONTROLPANEL_DISABLED
16 ControlPanel::ControlPanel(RunArgs & args, QWidget * p) : QMainWindow(p),
17 m_view(args.view), m_doc(args.doc), m_screen(args.screen)
22 setWindowTitle("IPDF Control Panel");
24 setToolTip("This is the IPDF Control Panel.\nDo you feel in control?");
36 QMenu * ControlPanel::CreateMainMenu()
38 QMenu * main = menuBar()->addMenu("&Main");
41 QAction * quit = new QAction("&Quit", this);
42 main->addAction(quit);
43 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
47 QMenu * ControlPanel::CreateDocumentMenu()
49 QMenu * document = menuBar()->addMenu("&Document");
53 QMenu * ControlPanel::CreateViewMenu()
55 QMenu * view = menuBar()->addMenu("&View");
64 QMenu * ControlPanel::CreateScreenMenu()
66 QMenu * screen = menuBar()->addMenu("&Screen");
68 m_screen_gpu_rendering = new QAction("&GPU Rendering", this);
69 m_screen_gpu_rendering->setCheckable(true);
71 m_screen_cpu_rendering = new QAction("&CPU Rendering", this);
72 m_screen_cpu_rendering->setCheckable(true);
74 screen->addAction(m_screen_gpu_rendering);
75 screen->addAction(m_screen_cpu_rendering);
77 connect(m_screen_gpu_rendering, SIGNAL(triggered()), this, SLOT(SetGPURendering()));
78 connect(m_screen_cpu_rendering, SIGNAL(triggered()), this, SLOT(SetCPURendering()));
83 void ControlPanel::UpdateAll()
85 bool using_gpu_rendering = m_view.UsingGPURendering();
86 m_screen_gpu_rendering->setChecked(using_gpu_rendering);
87 m_screen_cpu_rendering->setChecked(!using_gpu_rendering);
90 void ControlPanel::SetGPURendering()
92 m_view.SetGPURendering(true);
96 void ControlPanel::SetCPURendering()
98 m_view.SetGPURendering(false);
102 ControlPanel * ControlPanel::g_panel = NULL;
104 int ControlPanel::Run(void * args)
106 ControlPanel::RunArgs * a = (ControlPanel::RunArgs*)args;
107 QApplication app(a->argc, a->argv);
108 g_panel = new ControlPanel(*a);
110 int result = app.exec();
111 a->screen.RequestQuit();
119 #endif //CONTROLPANEL_ENABLED