bool FrameBuffer::setupSubWindow(FBNativeWindowType p_window, int p_x, int p_y, int p_width, int p_height, float zRot) { bool success = false; if (s_theFrameBuffer) { s_theFrameBuffer->m_lock.lock(); FrameBuffer *fb = s_theFrameBuffer; if (!fb->m_subWin) { // create native subwindow for FB display output fb->m_subWin = createSubWindow(p_window, &fb->m_subWinDisplay, p_x,p_y,p_width,p_height); if (fb->m_subWin) { fb->m_nativeWindow = p_window; // create EGLSurface from the generated subwindow fb->m_eglSurface = s_egl.eglCreateWindowSurface(fb->m_eglDisplay, fb->m_eglConfig, fb->m_subWin, NULL); if (fb->m_eglSurface == EGL_NO_SURFACE) { ERR("Failed to create surface\n"); destroySubWindow(fb->m_subWinDisplay, fb->m_subWin); fb->m_subWin = (EGLNativeWindowType)0; } else if (fb->bindSubwin_locked()) { // Subwin creation was successfull, // update viewport and z rotation and draw // the last posted color buffer. s_gl.glViewport(0, 0, p_width, p_height); fb->m_zRot = zRot; fb->post( fb->m_lastPostedColorBuffer, false ); fb->unbind_locked(); success = true; } } } s_theFrameBuffer->m_lock.unlock(); } return success; }
// ============================================================================= ITimeTrackingWindow* MainWindow::getCurrentMonthWindow(bool forceCreateNewWindow) { QList<QMdiSubWindow *> subWindowList = mMdiArea->subWindowList(); foreach(QMdiSubWindow * subWindow, subWindowList) { if(qobject_cast<TimeTrackingWindow*>(subWindow->widget())->isSheetOfCurMonth()) { return qobject_cast<TimeTrackingWindow*>(subWindow->widget()); } } if(forceCreateNewWindow == false && QMessageBox::question(NULL, tr("Sheet of current month is not open"), tr("The sheet of current month is not open, you can either open an existing sheet or apply a new one"), QMessageBox::Open, QMessageBox::Apply) == QMessageBox::Open) { openSpreadsheet(); } else { createSubWindow(); } ITimeTrackingWindow * timeTrackingWindow = getActiveWindow(); if(!timeTrackingWindow->isSheetOfCurMonth()) return NULL; return timeTrackingWindow; }
MainWindow::MainWindow() :mTimeTrackingAction(new TimeTrackingAction()), mMdiArea(NULL) { DEBUG_OBJ(""); setWindowIcon(QIcon(":/images/tt_icon.png")); DEBUG("Calling updateAllBalances"); IOFileAccesses::updateAllBalances(Misc::getUserName()); IOSettings settings; // First start do not allow access to perdiodic actions as the user needs to configure them if(!settings.readSettings(TimeTrackingSettings::getInstance())) { TimeTrackingSettings::getInstance()-> setEnablePeriodDefaultAction(false); } mMdiArea = new QMdiArea(); setCentralWidget(mMdiArea); ITimeTrackingWindow * curWindow = createSubWindow(); bool started = curWindow->isStarted(); bool stopped = curWindow->isStopped(); mTimeTrackingAction->setUserCurrentlyWorking(started && !stopped); connect(mMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateActions())); mRecentFileActions = new vector<QAction*>(MaxRecentFiles); // All initialisations createActions(); createMenus(); createToolBars(); mDialogTimeFollower.reset(new DialogTimeFollower(NULL, curWindow->getTrackingModel())); mDialogTimeFollower->show(); connect(mDialogTimeFollower.get(), SIGNAL(start()), mStartAction, SLOT(trigger())); connect(mDialogTimeFollower.get(), SIGNAL(stop()), mStopAction, SLOT(trigger())); connect(mDialogTimeFollower.get(), SIGNAL(pause()), mPauseAction, SLOT(trigger())); }
// ============================================================================= void MainWindow::openSpreadsheet() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Time tracking"), QDir::homePath(), tr("Time tracking files (*.xml)")); if (!fileName.isEmpty()) { fileName.remove(QRegExp("\\.\\w+$")); DEBUG("Opening file " + fileName); QStringList stringList = fileName.split('-'); if(stringList.size() != 3) { QMessageBox::warning(this, tr("Invalid filename"), "File " + fileName + " could not be loaded.", QMessageBox::Ok); } QString userName = stringList.at(0); QDate tmpDate(stringList.at(1).toInt(), stringList.at(2).toInt(), 1); createSubWindow(userName, tmpDate); } }