UIBar* UIBar::create(int sizeType) { const char* foreImg = shortHpBarFore; const char* backImg = shortHpBarBack; switch (sizeType) { case 1: foreImg = shortHpBarFore; backImg = shortHpBarBack; break; case 2: foreImg = mediumHpBarFore; backImg = mediumHpBarBack; break; case 3: foreImg = longHpBarFore; backImg = longHpBarBack; break; case 4: foreImg = bossHpBarFore; backImg = bossHpBarBack; break; } UIBar* pBar = new UIBar(foreImg, backImg); if (pBar) pBar->autorelease(); return pBar; }
UIVMDesktop::UIVMDesktop(UIToolBar *pToolBar, QAction *pRefreshAction, QWidget *pParent) : QIWithRetranslateUI<QWidget>(pParent) { /* Prepare buttons: */ m_pHeaderBtn = new UITexturedSegmentedButton(2); m_pHeaderBtn->setIcon(Dtls, UIIconPool::iconSet(":/settings_16px.png")); m_pHeaderBtn->setIcon(Snap, UIIconPool::iconSet(":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png")); m_pHeaderBtn->animateClick(0); /* Prepare main layout: */ QVBoxLayout *pMainLayout = new QVBoxLayout(this); pMainLayout->setContentsMargins(0, 0, 0, 0); /* The header to select the different pages. * Has different styles on the different platforms. */ #ifdef USE_TOOLBAR if (pToolBar) { pToolBar->addWidget(new UIHorizontalSpacerWidget(this)); pToolBar->addWidget(m_pHeaderBtn); QWidget *pSpace = new QWidget(this); /* We need a little bit more space for the beta label. */ if (vboxGlobal().isBeta()) pSpace->setFixedSize(28, 1); else pSpace->setFixedSize(10, 1); pToolBar->addWidget(pSpace); pToolBar->updateLayout(); } else #else /* USE_TOOLBAR */ NOREF(pToolBar); #endif /* !USE_TOOLBAR */ { UIBar *pBar = new UIBar(this); pBar->setContentWidget(m_pHeaderBtn); pMainLayout->addWidget(pBar); } /* Create desktop pane: */ m_pDesktopPrivate = new UIVMDesktopPrivate(this, pRefreshAction); /* Create snapshot pane: */ m_pSnapshotsPane = new VBoxSnapshotsWgt(this); m_pSnapshotsPane->setContentsMargins(gsLeftMargin, gsTopMargin, gsRightMargin, gsBottomMargin); /* Add the pages: */ m_pStackedLayout = new QStackedLayout(pMainLayout); m_pStackedLayout->addWidget(m_pDesktopPrivate); m_pStackedLayout->addWidget(m_pSnapshotsPane); /* Connect the header buttons with the stack layout: */ connect(m_pHeaderBtn, SIGNAL(clicked(int)), m_pStackedLayout, SLOT(setCurrentIndex(int))); connect(m_pStackedLayout, SIGNAL(currentChanged(int)), this, SIGNAL(sigCurrentChanged(int))); /* Translate finally: */ retranslateUi(); }
UIVMDesktop::UIVMDesktop(UIToolBar *pToolBar, QAction *pRefreshAction, QWidget *pParent) : QIWithRetranslateUI<QWidget>(pParent) { /* Create container: */ QWidget *pContainer = new QWidget; { /* Create layout: */ QHBoxLayout *pLayout = new QHBoxLayout(pContainer); { /* Configure layout: */ pLayout->setContentsMargins(0, 0, 0, 0); /* Create segmented-button: */ m_pHeaderBtn = new UITexturedSegmentedButton(pContainer, 2); { /* Configure segmented-button: */ m_pHeaderBtn->setIcon(Dtls, UIIconPool::iconSet(":/vm_settings_16px.png", ":/vm_settings_disabled_16px.png")); m_pHeaderBtn->setIcon(Snap, UIIconPool::iconSet(":/snapshot_take_16px.png", ":/snapshot_take_disabled_16px.png")); /* Add segmented-buttons into layout: */ pLayout->addWidget(m_pHeaderBtn); } } } #ifdef Q_WS_MAC /* Cocoa stuff should be async... * Do not ask me why but otherwise * it conflicts with native handlers. */ QTimer::singleShot(0, this, SLOT(sltInit())); #else /* !Q_WS_MAC */ sltInit(); #endif /* !Q_WS_MAC */ /* Prepare main layout: */ QVBoxLayout *pMainLayout = new QVBoxLayout(this); pMainLayout->setContentsMargins(0, 0, 0, 0); /* The header to select the different pages. * Has different styles on the different platforms. */ #ifdef USE_TOOLBAR if (pToolBar) { pToolBar->addWidget(new UIHorizontalSpacerWidget(this)); pToolBar->addWidget(pContainer); QWidget *pSpace = new QWidget(this); /* We need a little bit more space for the beta label. */ if (vboxGlobal().isBeta()) pSpace->setFixedSize(28, 1); else pSpace->setFixedSize(10, 1); pToolBar->addWidget(pSpace); #ifdef Q_WS_MAC pToolBar->updateLayout(); #endif /* Q_WS_MAC */ } else #else /* USE_TOOLBAR */ NOREF(pToolBar); #endif /* !USE_TOOLBAR */ { UIBar *pBar = new UIBar(this); pBar->setContentWidget(pContainer); pMainLayout->addWidget(pBar); } /* Create desktop pane: */ m_pDesktopPrivate = new UIVMDesktopPrivate(this, pRefreshAction); /* Create snapshot pane: */ m_pSnapshotsPane = new VBoxSnapshotsWgt(this); m_pSnapshotsPane->setContentsMargins(gsLeftMargin, gsTopMargin, gsRightMargin, gsBottomMargin); /* Add the pages: */ m_pStackedLayout = new QStackedLayout(pMainLayout); m_pStackedLayout->addWidget(m_pDesktopPrivate); m_pStackedLayout->addWidget(m_pSnapshotsPane); /* Connect the header buttons with the stack layout: */ connect(m_pHeaderBtn, SIGNAL(clicked(int)), m_pStackedLayout, SLOT(setCurrentIndex(int))); connect(m_pStackedLayout, SIGNAL(currentChanged(int)), this, SIGNAL(sigCurrentChanged(int))); /* Translate finally: */ retranslateUi(); }