UBDesktopPalette::UBDesktopPalette(QWidget *parent) : UBActionPalette(Qt::TopLeftCorner, parent) , mShowHideAction(0) , mDisplaySelectAction(0) { QList<QAction*> actions; mActionUniboard = new QAction(QIcon(":/images/toolbar/board.png"), tr("Show Uniboard"), this); connect(mActionUniboard, SIGNAL(triggered()), this, SIGNAL(uniboardClick())); actions << mActionUniboard; actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionMarker; #ifndef Q_WS_X11 actions << UBApplication::mainWindow->actionSelector; #endif actions << UBApplication::mainWindow->actionPointer; if (UBPlatformUtils::hasVirtualKeyboard()) { actions << UBApplication::mainWindow->actionVirtualKeyboard; connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(toggled(bool)), this, SIGNAL(showVirtualKeyboard(bool))); } mActionCustomSelect = new QAction(QIcon(":/images/toolbar/captureArea.png"), tr("Capture Part of the Screen"), this); connect(mActionCustomSelect, SIGNAL(triggered()), this, SIGNAL(customClick())); actions << mActionCustomSelect; mDisplaySelectAction = new QAction(QIcon(":/images/toolbar/captureScreen.png"), tr("Capture the Screen"), this); connect(mDisplaySelectAction, SIGNAL(triggered()), this, SIGNAL(screenClick())); actions << mDisplaySelectAction; QIcon showHideIcon; showHideIcon.addPixmap(QPixmap(":/images/toolbar/eyeOpened.png"), QIcon::Normal , QIcon::On); showHideIcon.addPixmap(QPixmap(":/images/toolbar/eyeClosed.png"), QIcon::Normal , QIcon::Off); mShowHideAction = new QAction(showHideIcon, "", this); mShowHideAction->setCheckable(true); connect(mShowHideAction, SIGNAL(triggered(bool)), this, SLOT(showHideClick(bool))); #ifndef Q_WS_X11 actions << mShowHideAction; #endif setActions(actions); setButtonIconSize(QSize(42, 42)); adjustSizeAndPosition(); // This palette can be minimized QIcon maximizeIcon; maximizeIcon.addPixmap(QPixmap(":/images/toolbar/stylusTab.png"), QIcon::Normal, QIcon::On); mMaximizeAction = new QAction(maximizeIcon, tr("Show the stylus palette"), this); connect(mMaximizeAction, SIGNAL(triggered()), this, SLOT(maximizeMe())); connect(this, SIGNAL(maximizeStart()), this, SLOT(maximizeMe())); connect(this, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(minimizeMe(eMinimizedLocation))); setMinimizePermission(true); }
/** * Initializes all the elements in the Victory screen. * @param game Pointer to the core game. */ VictoryState::VictoryState() : _screen(-1) { Options::baseXResolution = Screen::ORIGINAL_WIDTH; Options::baseYResolution = Screen::ORIGINAL_HEIGHT; _game->getScreen()->resetDisplay(false); const char *files[] = {"PICT1.LBM", "PICT2.LBM", "PICT3.LBM", "PICT6.LBM", "PICT7.LBM"}; _timer = new Timer(30000); _text[0] = new Text(195, 56, 5, 0); _text[1] = new Text(232, 64, 88, 136); _text[2] = new Text(254, 48, 66, 152); _text[3] = new Text(300, 200, 5, 0); _text[4] = new Text(310, 42, 5, 158); for (int i = 0; i < SCREENS; ++i) { Surface *screen = _game->getResourcePack()->getSurface(files[i]); _bg[i] = new InteractiveSurface(320, 200, 0, 0); setPalette(screen->getPalette()); add(_bg[i]); add(_text[i]); screen->blit(_bg[i]); _bg[i]->setVisible(false); _bg[i]->onMouseClick((ActionHandler)&VictoryState::screenClick); std::ostringstream ss; ss << "STR_VICTORY_" << i + 1; _text[i]->setText(tr(ss.str())); _text[i]->setColor(Palette::blockOffset(15)+9); _text[i]->setWordWrap(true); _text[i]->setVisible(false); } _game->getResourcePack()->playMusic("GMWIN"); centerAllSurfaces(); _timer->onTimer((StateHandler)&VictoryState::screenTimer); _timer->start(); screenClick(0); // Ironman is over if (_game->getSavedGame()->isIronman()) { std::string filename = CrossPlatform::sanitizeFilename(Language::wstrToFs(_game->getSavedGame()->getName())) + ".sav"; CrossPlatform::deleteFile(Options::getUserFolder() + filename); } }
SlideshowState::SlideshowState(const SlideshowHeader &slideshowHeader, const std::vector<SlideshowSlide> *slideshowSlides) : _slideshowHeader(slideshowHeader), _slideshowSlides(slideshowSlides), _curScreen(-1) { _wasLetterboxed = CutsceneState::initDisplay(); // pre-render and queue up all the frames for (std::vector<SlideshowSlide>::const_iterator it = _slideshowSlides->begin(); it != _slideshowSlides->end(); ++it) { InteractiveSurface *slide = new InteractiveSurface(Screen::ORIGINAL_WIDTH, Screen::ORIGINAL_HEIGHT, 0, 0); slide->loadImage(FileMap::getFilePath(it->imagePath)); slide->onMouseClick((ActionHandler)&SlideshowState::screenClick); slide->onKeyboardPress((ActionHandler)&SlideshowState::screenClick, Options::keyOk); slide->onKeyboardPress((ActionHandler)&SlideshowState::screenSkip, Options::keyCancel); slide->setVisible(false); _slides.push_back(slide); setPalette(slide->getPalette()); add(slide); // initialize with default rect; may get overridden by // category/id definition Text *caption = new Text(it->w, it->h, it->x, it->y); caption->setColor(it->color); caption->setText(tr(it->caption)); caption->setAlign(it->align); caption->setWordWrap(true); caption->setVisible(false); _captions.push_back(caption); add(caption); } centerAllSurfaces(); int transitionSeconds = _slideshowHeader.transitionSeconds; if (_slideshowSlides->front().transitionSeconds > 0) transitionSeconds = _slideshowSlides->front().transitionSeconds; _transitionTimer = new Timer(transitionSeconds * 1000); _transitionTimer->onTimer((StateHandler)&SlideshowState::screenTimer); _game->getMod()->playMusic(_slideshowHeader.musicId); _game->getCursor()->setVisible(false); screenClick(0); }
UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) : QObject(parent) , mTransparentDrawingView(0) , mTransparentDrawingScene(0) , mDesktopPalette(NULL) , mDesktopPenPalette(NULL) , mDesktopMarkerPalette(NULL) , mDesktopEraserPalette(NULL) , mWindowPositionInitialized(0) , mIsFullyTransparent(false) , mDesktopToolsPalettePositioned(false) , mPendingPenButtonPressed(false) , mPendingMarkerButtonPressed(false) , mPendingEraserButtonPressed(false) , mbArrowClicked(false) , mBoardStylusTool(UBDrawingController::drawingController()->stylusTool()) , mDesktopStylusTool(UBDrawingController::drawingController()->stylusTool()) { mTransparentDrawingView = new UBBoardView(UBApplication::boardController, 0); // deleted in UBDesktopAnnotationController::destructor mTransparentDrawingView->setAttribute(Qt::WA_TranslucentBackground, true); // !!!! Should be included into Windows after QT recompilation #ifdef Q_WS_MAC mTransparentDrawingView->setAttribute(Qt::WA_MacNoShadow, true); #endif mTransparentDrawingView->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Window); mTransparentDrawingView->setCacheMode(QGraphicsView::CacheNone); mTransparentDrawingView->resize(UBApplication::desktop()->width(), UBApplication::desktop()->height()); mTransparentDrawingView->setMouseTracking(true); mTransparentDrawingView->setAcceptDrops(true); QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}"; mTransparentDrawingView->setStyleSheet(backgroundStyle); mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingScene->setDrawingMode(true); mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); if (UBPlatformUtils::hasVirtualKeyboard()) { connect( UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); #ifdef Q_WS_X11 connect(UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask())); connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(refreshMask())); connect(mDesktopPalette,SIGNAL(refreshMask()), this, SLOT(refreshMask())); #endif } connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture())); connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture())); connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture())); connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize())); connect(mTransparentDrawingView, SIGNAL(resized(QResizeEvent*)), this, SLOT(onTransparentWidgetResized())); connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)) , this, SLOT(stylusToolChanged(int))); // Add the desktop associated palettes mDesktopPenPalette = new UBDesktopPenPalette(mTransparentDrawingView); connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized())); mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView); mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView); mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopMarkerPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopEraserPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); // Hack : the size of the property palettes is computed the first time the palette is visible // In order to prevent palette overlap on if the desktop palette is on the right of the // screen, a setVisible(true) followed by a setVisible(false) is done. mDesktopPenPalette->setVisible(true); mDesktopMarkerPalette->setVisible(true); mDesktopEraserPalette->setVisible(true); mDesktopPenPalette->setVisible(false); mDesktopMarkerPalette->setVisible(false); mDesktopEraserPalette->setVisible(false); connect(UBApplication::mainWindow->actionEraseDesktopAnnotations, SIGNAL(triggered()), this, SLOT(eraseDesktopAnnotations())); connect(&mHoldTimerPen, SIGNAL(timeout()), this, SLOT(penActionReleased())); connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased())); connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased())); #ifdef Q_WS_X11 connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask())); // connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask())); connect(UBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask())); #endif onDesktopPaletteMaximized(); }
/** * Shows the next screen on a timed basis. */ void VictoryState::screenTimer() { screenClick(0); }
/** * Shows the next screen on a timed basis. */ void SlideshowState::screenTimer() { screenClick(0); }