// =============================================================================
void MainWindow::printPreviewSpreadsheet() {
    ITimeTrackingWindow* curWindow = getActiveWindow();

    if(curWindow != NULL) {
        curWindow->printPreview();
    }
}
	//----------------------------------------------------------------------------
	void WorldViewWindowManager::frameStarted(const FrameEvent& _evt)
	{
		if(!mSaveWorldTool || !mSaveWorldTool->isActive())
		{
			unregisterFrameListener();
			if(getActiveWindow()->getWorld()->isChanged())
			{
				cancelWindowClosing();
			}
			else
			{
				WorldManager::getSingleton().destroyWorld(getActiveWindow()->getWorld());
				_processWindowClosing();
			}
		}
	}
	//---------------------------------------------------------------------------
	void WorldViewWindowManager::notifyMessageBoxChoice(MessageBoxButton _button)
	{
		switch(_button)
		{
			case MessageBoxButton::CANCEL:
			{
				cancelWindowClosing();
				break;
			}
			case MessageBoxButton::BUTTON1: // Save
			{
				if(!mSaveWorldTool)
				{
					ToolManager* toolMgr = ToolManagerList::getSingleton().getToolManager("EditorToolManager");
					mSaveWorldTool = toolMgr->getTool("SaveWorld");
				}
				if(mSaveWorldTool)
				{
					mSaveWorldTool->activateTool();
					registerFrameListener();
				}
				break;
			}
			case MessageBoxButton::BUTTON2: // Don't save
			{
				WorldManager::getSingleton().destroyWorld(getActiveWindow()->getWorld());
				_processWindowClosing();
				break;
			}
		}
	}
// =============================================================================
void MainWindow::updateTrackingActions() {
    bool userCurrentlyWorking = false;
    ITimeTrackingWindow* curWindow = getActiveWindow();
    if(curWindow != NULL) {
        bool started = curWindow->isStarted();
        bool stopped = curWindow->isStopped();
        userCurrentlyWorking = started && !stopped;
    }
    mTimeTrackingAction->setUserCurrentlyWorking(userCurrentlyWorking);
}
// =============================================================================
void MainWindow::updateActions() {

    ITimeTrackingWindow* curWindow = getActiveWindow();

    // TODO: Use here an observer: if any window started then the action should be false
    if(curWindow != NULL) {
        bool started = curWindow->isStarted();
        bool stopped = curWindow->isStopped();
        mStartAction->setEnabled(!started || stopped);
        mStopAction->setEnabled(started && !stopped);
    }
}
// get screenshot
void Core::screenShot(bool first)
{
    sleep(400); // delay for hide "fade effect" bug in the KWin with compositing
    _firstScreen = first;

    // Update date last crenshot, if it is  a first screen
    if (_firstScreen)
        _conf->updateLastSaveDate();

    switch(_conf->getTypeScreen())
    {
    case 0:
    {
        const QList<QScreen *> screens = qApp->screens();
        const QDesktopWidget *desktop = QApplication::desktop();
        const int screenNum = desktop->screenNumber(QCursor::pos());
        *_pixelMap = screens[screenNum]->grabWindow(desktop->winId());
        grabCursor(0, 0);

        checkAutoSave(first);
        _wnd->updatePixmap(_pixelMap);
        break;
    }
    case 1:
    {
        getActiveWindow();
        checkAutoSave(first);
        _wnd->updatePixmap(_pixelMap);
        break;
    }
    case 2:
    {
        _selector = new RegionSelect(_conf);
        connect(_selector, &RegionSelect::processDone, this, &Core::regionGrabbed);
        break;
    }
    case 3:
    {
        _selector = new RegionSelect(_conf, _lastSelectedArea);
        connect(_selector, &RegionSelect::processDone, this, &Core::regionGrabbed);
        break;
    }
    default:
        *_pixelMap = QPixmap::grabWindow(QApplication::desktop()->winId());
        break;
    }



    _wnd->updatePixmap(_pixelMap);
    _wnd->restoreFromShot();
}
Exemple #7
0
int CFrmSettings::drawGraph()
{
    int rc;
    if (createLayout() && renderLayout()) {
	getActiveWindow()->settingsSet = false;
	rc = QDialog::Accepted;
    } else
	rc = QDialog::Accepted;
    agreseterrors();

    return rc;
    /* return QDialog::Rejected; */
}
// =============================================================================
void MainWindow::exportSpreadsheet() {
    ITimeTrackingWindow* curWindow = getActiveWindow();

    if(curWindow != NULL) {
        QString path = QFileDialog::getSaveFileName(this, tr("Export a PDF file"),
                                     curWindow->getTrackingModel()->getDefaultFileName("", true /* export to PDF */),
                                     "PDF (*.pdf)");
        if(!path.isEmpty()) {
            if(!path.endsWith(".pdf")) path += ".pdf";
            curWindow->exportSheet(path);
        }
    }
}
GHOST_TSuccess GHOST_WindowManager::beginFullScreen(GHOST_IWindow *window,
		bool /*stereoVisual*/)
{
	GHOST_TSuccess success = GHOST_kFailure;
	GHOST_ASSERT(window, "GHOST_WindowManager::beginFullScreen(): invalid window");
	GHOST_ASSERT(window->getValid(), "GHOST_WindowManager::beginFullScreen(): invalid window");
	if (!getFullScreen()) {
		m_fullScreenWindow = window;
		m_activeWindowBeforeFullScreen = getActiveWindow();
		setActiveWindow(m_fullScreenWindow);
		m_fullScreenWindow->beginFullScreen();
		success = GHOST_kSuccess;
	}
	return success;
}
Exemple #10
0
/**
 * @brief this one gets the active application window.
 */
Window XfitMan::getActiveAppWindow() const
{
    Window window = getActiveWindow();
    if (window == 0)
        return 0;

    if (acceptWindow(window))
        return window;

    Window transFor = None;
    if (XGetTransientForHint(QX11Info::display(), window, &transFor))
        return transFor;

    return 0;
}
Exemple #11
0
int CFrmSettings::runSettings(MdiChild * m)
{
	if (this->loadGraph(m))
	    return drawGraph();


    if ((m) && (m == getActiveWindow())) {
	if (this->loadGraph(m))
	    return drawGraph();
	else
	    return QDialog::Rejected;
    }

    else
	return showSettings(m);

}
// =============================================================================
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;
}
Exemple #13
0
void Container::init()
{
    if (m_bInit)
        return;
    m_bInit = true;

    showBar();
    string windows = getWindows();
    while (!windows.empty()){
        unsigned long id = strtoul(getToken(windows, ',').c_str(), NULL, 10);
        Contact *contact = getContacts()->contact(id);
        if (contact == NULL)
            continue;
        addUserWnd(new UserWnd(id, getWndConfig(id), false));
    }
    if (m_tabBar->count() == 0)
        QTimer::singleShot(0, this, SLOT(close()));
    setWindows(NULL);
    clearWndConfig();
    m_tabBar->raiseTab(getActiveWindow());

    show();
}
Exemple #14
0
void CFrmSettings::doPreview(QString fileName)
{
    if (getActiveWindow()->previewFrm) {
	getActiveWindow()->parentFrm->mdiArea->
	    removeSubWindow(getActiveWindow()->previewFrm->subWindowRef);
	delete getActiveWindow()->previewFrm;
	getActiveWindow()->previewFrm = NULL;
    }

    if ((fileName.isNull()) || !(getActiveWindow()->loadPreview(fileName))) {	//create preview
	QString prevFile(buildTempFile());
	gvRenderFilename(gvc, graph, "png",
			 (char *) prevFile.toUtf8().constData());
	getActiveWindow()->loadPreview(prevFile);
#if 0
	if (!this->getActiveWindow()->loadPreview(prevFile))
	    QMessageBox::information(this, tr("GVEdit"),
				     tr
				     ("Preview file can not be opened."));
#endif
    }
}
Bool
addScreen (CompDisplay *display,
	   int	       screenNum)
{
    CompScreen   *s;
    Display	 *dpy = display->display;
    static char  data = 0;
    XColor	 black, dummy;
    Pixmap	 bitmap;
    XVisualInfo  templ;
    XVisualInfo  *visinfo;
    VisualID     visualIDs[MAX_DEPTH + 1];
    Window	 rootReturn, parentReturn;
    Window	 *children;
    unsigned int nchildren;
    int		 defaultDepth, nvisinfo, value, i;
    const char   *glxExtensions, *glExtensions;
    GLint	 stencilBits;

    s = malloc (sizeof (CompScreen));
    if (!s)
	return FALSE;

    s->windowPrivateIndices = 0;
    s->windowPrivateLen     = 0;

    if (display->screenPrivateLen)
    {
	s->privates = malloc (display->screenPrivateLen *
			      sizeof (CompPrivate));
	if (!s->privates)
	{
	    free (s);
	    return FALSE;
	}
    }
    else
	s->privates = 0;

    compScreenInitOptions (s);

    s->redrawTime = 1000 / s->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value.i;

    s->display = display;

    s->damage = XCreateRegion ();
    if (!s->damage)
	return FALSE;

    s->buttonGrab  = 0;
    s->nButtonGrab = 0;
    s->keyGrab     = 0;
    s->nKeyGrab    = 0;

    s->grabs    = 0;
    s->grabSize = 0;
    s->maxGrab  = 0;

    s->pendingDestroys = 0;

    s->screenNum = screenNum;
    s->colormap  = DefaultColormap (dpy, screenNum);
    s->root	 = XRootWindow (dpy, screenNum);

    if (testMode)
    {
	XSetWindowAttributes attrib;
	XWMHints	     *wmHints;
	XSizeHints	     *normalHints;
	XClassHint	     *classHint;
	int		     glx_attrib[] = {
	    GLX_RGBA,
	    GLX_RED_SIZE, 1,
	    GLX_STENCIL_SIZE, 2,
	    GLX_DOUBLEBUFFER,
	    None
	};

	visinfo = glXChooseVisual (dpy, screenNum, glx_attrib);
	if (!visinfo)
	{
	    int glx_attrib2[] = {
		GLX_RGBA,
		GLX_RED_SIZE, 1,
		GLX_DOUBLEBUFFER,
		None
	    };

	    visinfo = glXChooseVisual (dpy, screenNum, glx_attrib2);
	    if (!visinfo)
	    {
		fprintf (stderr, "%s: Couldn't find a double buffered "
			 "RGB visual.\n", programName);
		return FALSE;
	    }
	}

	attrib.colormap = XCreateColormap (dpy, s->root, visinfo->visual,
					   AllocNone);

	normalHints = XAllocSizeHints ();
	normalHints->flags = 0;
	normalHints->x = 0;
	normalHints->y = 0;
	normalHints->width = 800;
	normalHints->height = 600;

	classHint = XAllocClassHint ();
	classHint->res_name = "glxcompmgr";
	classHint->res_class = "Glxcompmgr";

	wmHints = XAllocWMHints ();
	wmHints->flags = InputHint;
	wmHints->input = TRUE;

	s->root = XCreateWindow (dpy, s->root, 0, 0,
				 normalHints->width, normalHints->height, 0,
				 visinfo->depth, InputOutput, visinfo->visual,
				 CWColormap, &attrib);

	XSetWMProtocols (dpy, s->root, &display->wmDeleteWindowAtom, 1);

	XmbSetWMProperties (dpy, s->root,
			    "glxcompmgr - Test mode", "glxcompmgr",
			    programArgv, programArgc,
			    normalHints, wmHints, classHint);

	s->fake[0] = XCreateWindow (dpy, s->root, 64, 32, 1, 1, 0,
				    visinfo->depth, InputOutput,
				    visinfo->visual,
				    CWColormap, &attrib);

	s->fake[1] = XCreateWindow (dpy, s->root, 256, 256, 1, 1, 0,
				    visinfo->depth, InputOutput,
				    visinfo->visual,
				    CWColormap, &attrib);

	XMapWindow (dpy, s->root);

	XFree (wmHints);
	XFree (classHint);
	XFree (normalHints);
    }
    else
	s->fake[0] = s->fake[1] = 0;

    s->escapeKeyCode = XKeysymToKeycode (display->display,
					 XStringToKeysym ("Escape"));

    s->allDamaged  = TRUE;
    s->next	   = 0;
    s->exposeRects = 0;
    s->sizeExpose  = 0;
    s->nExpose     = 0;

    s->rasterX = 0;
    s->rasterY = 0;

    s->windows = 0;
    s->reverseWindows = 0;

    s->stencilRef = 0x1;

    s->nextRedraw = 0;

    gettimeofday (&s->lastRedraw, 0);

    s->setScreenOption	        = setScreenOption;
    s->setScreenOptionForPlugin = setScreenOptionForPlugin;

    s->initPluginForScreen = initPluginForScreen;
    s->finiPluginForScreen = finiPluginForScreen;

    s->preparePaintScreen     = preparePaintScreen;
    s->donePaintScreen        = donePaintScreen;
    s->paintScreen	      = paintScreen;
    s->paintTransformedScreen = paintTransformedScreen;
    s->paintBackground        = paintBackground;
    s->paintWindow            = paintWindow;
    s->addWindowGeometry      = addWindowGeometry;
    s->drawWindowGeometry     = drawWindowGeometry;
    s->invisibleWindowMove    = invisibleWindowMove;
    s->damageWindowRect       = damageWindowRect;
    s->damageWindowRegion     = damageWindowRegion;

    s->getProcAddress = 0;

    if (s->root)
    {
	XSetWindowAttributes attrib;

	attrib.override_redirect = 1;
	s->grabWindow = XCreateWindow (dpy, s->root, -100, -100, 1, 1, 0,
				       CopyFromParent, CopyFromParent,
				       CopyFromParent, CWOverrideRedirect,
				       &attrib);

	XMapWindow (dpy, s->grabWindow);
    }

    if (!XGetWindowAttributes (dpy, s->root, &s->attrib))
	return FALSE;

    s->activeWindow = None;

    templ.visualid = XVisualIDFromVisual (s->attrib.visual);

    visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
    if (!nvisinfo)
    {
	fprintf (stderr, "%s: Couldn't get visual info for default visual\n",
		 programName);
	return FALSE;
    }

    defaultDepth = visinfo->depth;

    if (!XAllocNamedColor (dpy, s->colormap, "black", &black, &dummy))
    {
	fprintf (stderr, "%s: Couldn't allocate color\n", programName);
	return FALSE;
    }

    bitmap = XCreateBitmapFromData (dpy, s->root, &data, 1, 1);
    if (!bitmap)
    {
	fprintf (stderr, "%s: Couldn't create bitmap\n", programName);
	return FALSE;
    }

    s->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
					      &black, &black, 0, 0);
    if (!s->invisibleCursor)
    {
	fprintf (stderr, "%s: Couldn't create invisible cursor\n",
		 programName);
	return FALSE;
    }

    XFreePixmap (dpy, bitmap);
    XFreeColors (dpy, s->colormap, &black.pixel, 1, 0);

    glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);
    if (!value)
    {
	fprintf (stderr, "%s: Root visual is not a GL visual\n",
		 programName);
	return FALSE;
    }

    glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);
    if (!value)
    {
	fprintf (stderr,
		 "%s: Root visual is not a double buffered GL visual\n",
		 programName);
	return FALSE;
    }

    s->ctx = glXCreateContext (dpy, visinfo, NULL, TRUE);
    if (!s->ctx)
    {
	fprintf (stderr, "%s: glXCreateContext failed\n", programName);
	return FALSE;
    }

    XFree (visinfo);

    /* we don't want to allocate back, stencil or depth buffers for pixmaps
       so lets see if we can find an approriate visual without these buffers */
    for (i = 0; i <= MAX_DEPTH; i++)
    {
	int j, db, stencil, depth;

	visualIDs[i] = 0;

	db	= MAXSHORT;
	stencil = MAXSHORT;
	depth	= MAXSHORT;

	templ.depth = i;

	visinfo = XGetVisualInfo (dpy, VisualDepthMask, &templ, &nvisinfo);
	for (j = 0; j < nvisinfo; j++)
	{
	    glXGetConfig (dpy, &visinfo[j], GLX_USE_GL, &value);
	    if (!value)
		continue;

	    glXGetConfig (dpy, &visinfo[j], GLX_DOUBLEBUFFER, &value);
	    if (value > db)
		continue;

	    db = value;
	    glXGetConfig (dpy, &visinfo[j], GLX_STENCIL_SIZE, &value);
	    if (value > stencil)
		continue;

	    stencil = value;
	    glXGetConfig (dpy, &visinfo[j], GLX_DEPTH_SIZE, &value);
	    if (value > depth)
		continue;

	    depth = value;
	    visualIDs[i] = visinfo[j].visualid;
	}

	if (nvisinfo)
	    XFree (visinfo);
    }

    /* create contexts for supported depths */
    for (i = 0; i <= MAX_DEPTH; i++)
    {
	templ.visualid = visualIDs[i];
	s->glxPixmapVisuals[i] = XGetVisualInfo (dpy,
						 VisualIDMask,
						 &templ,
						 &nvisinfo);
    }

    if (!s->glxPixmapVisuals[defaultDepth])
    {
	fprintf (stderr, "%s: No GL visual for default depth, "
		 "this isn't going to work.\n", programName);
	return FALSE;
    }

    glXMakeCurrent (dpy, s->root, s->ctx);
    currentRoot = s->root;

    glxExtensions = glXQueryExtensionsString (s->display->display, screenNum);
    if (!testMode && !strstr (glxExtensions, "GLX_MESA_render_texture")
        && !strstr(glxExtensions, "GLX_EXT_texture_from_drawable")
        && !strstr(glxExtensions, "GLX_EXT_texture_from_pixmap"))
    {
	fprintf (stderr, "%s: GLX_MESA_render_texture is missing\n",
		 programName);
	return FALSE;
    }

    s->getProcAddress = (GLXGetProcAddressProc)
	getProcAddress (s, "glXGetProcAddressARB");
    s->bindTexImageExt = (GLXBindTexImageExtProc)
        getProcAddress (s, "glXBindTexImageEXT");
    s->bindTexImageMesa = (GLXBindTexImageMesaProc)
	getProcAddress (s, "glXBindTexImageMESA");
    s->releaseTexImage = (GLXReleaseTexImageProc)
	getProcAddress (s, "glXReleaseTexImageEXT");
    if (!s->releaseTexImage)
        s->releaseTexImage = (GLXReleaseTexImageProc)
            getProcAddress (s, "glXReleaseTexImageMESA");
    s->queryDrawable = (GLXQueryDrawableProc)
	getProcAddress (s, "glXQueryDrawable");

    if (!testMode && !s->bindTexImageExt && !s->bindTexImageMesa)
    {
	fprintf (stderr, "%s: glXBindTexImage{EXT,MESA} are missing\n",
                 programName);
	return FALSE;
    }

    if (!testMode && !s->releaseTexImage)
    {
	fprintf (stderr, "%s: glXReleaseTexImage{EXT,MESA} are missing\n",
		 programName);
	return FALSE;
    }

    if (!testMode && !s->queryDrawable)
    {
	fprintf (stderr, "%s: glXQueryDrawable is missing\n", programName);
	return FALSE;
    }

    s->textureRectangle = 0;
    glExtensions = (const char *) glGetString (GL_EXTENSIONS);
    if (strstr (glExtensions, "GL_NV_texture_rectangle")  ||
	strstr (glExtensions, "GL_EXT_texture_rectangle") ||
	strstr (glExtensions, "GL_ARB_texture_rectangle"))
	s->textureRectangle = 1;

    s->textureNonPowerOfTwo = 0;
    if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
	s->textureNonPowerOfTwo = 1;

    if (!(s->textureRectangle || s->textureNonPowerOfTwo))
    {
	fprintf (stderr, "%s: Support for non power of two textures missing\n",
		 programName);
	return FALSE;
    }

    s->textureEnvCombine = 0;
    if (strstr (glExtensions, "GL_ARB_texture_env_combine"))
	s->textureEnvCombine = 1;

    s->maxTextureUnits = 1;
    if (strstr (glExtensions, "GL_ARB_multitexture"))
    {
	s->activeTexture = (GLActiveTextureProc)
	    getProcAddress (s, "glActiveTexture");
	s->clientActiveTexture = (GLClientActiveTextureProc)
	    getProcAddress (s, "glClientActiveTexture");

	if (s->activeTexture && s->clientActiveTexture)
	    glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &s->maxTextureUnits);
    }

    initTexture (s, &s->backgroundTexture);

    s->desktopWindowCount = 0;

    glGetIntegerv (GL_STENCIL_BITS, &stencilBits);
    if (!stencilBits)
    {
	fprintf (stderr, "%s: No stencil buffer. Clipping of transformed "
		 "windows is not going to be correct when screen is "
		 "transformed.\n", programName);
    }

    glClearColor (0.0, 0.0, 0.0, 1.0);
    glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glEnable (GL_CULL_FACE);
    glDisable (GL_BLEND);
    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glColor4usv (defaultColor);
    glEnableClientState (GL_VERTEX_ARRAY);
    glEnableClientState (GL_TEXTURE_COORD_ARRAY);

    for (i = 1; i < s->maxTextureUnits; i++)
    {
	s->clientActiveTexture (GL_TEXTURE0_ARB + i);
	glEnableClientState (GL_TEXTURE_COORD_ARRAY);
    }

    if (s->maxTextureUnits > 1)
	s->clientActiveTexture (GL_TEXTURE0_ARB);

    s->activeWindow = getActiveWindow (display, s->root);

    reshape (s, s->attrib.width, s->attrib.height);

    s->next = display->screens;
    display->screens = s;

    screenInitPlugins (s);

    XSelectInput (dpy, s->root,
		  SubstructureNotifyMask |
		  StructureNotifyMask	 |
		  PropertyChangeMask	 |
		  ExposureMask		 |
		  ButtonPressMask	 |
		  ButtonReleaseMask	 |
		  ButtonMotionMask);

    XQueryTree (dpy, s->root,
		&rootReturn, &parentReturn,
		&children, &nchildren);

    for (i = 0; i < nchildren; i++)
    {
	if (children[i] == s->grabWindow)
	    continue;

	addWindow (s, children[i], i ? children[i - 1] : 0);
    }

    XFree (children);

    return TRUE;
}
Exemple #16
0
void Container::init()
{
	if (m_bInit)
		return;

    QFrame *frm = new QFrame(this, "container");
    setCentralWidget(frm);

    connect(CorePlugin::m_plugin, SIGNAL(modeChanged()), this, SLOT(modeChanged()));

    QVBoxLayout *lay = new QVBoxLayout(frm);
    m_wnds = new QWidgetStack(frm);
    m_wnds->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    lay->addWidget(m_wnds);

    m_tabSplitter = new Splitter(frm);
    m_tabSplitter->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
    m_tabBar = new UserTabBar(m_tabSplitter);
    m_tabBar->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
    m_tabBar->hide();

    m_bInit = true;

    m_status = new ContainerStatus(m_tabSplitter);
    lay->addWidget(m_tabSplitter);
    connect(m_tabBar, SIGNAL(selected(int)), this, SLOT(contactSelected(int)));
    connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), this, SLOT(toolbarChanged(QToolBar*)));
    connect(m_status, SIGNAL(sizeChanged(int)), this, SLOT(statusChanged(int)));
    m_accel = new QAccel(this);
    connect(m_accel, SIGNAL(activated(int)), this, SLOT(accelActivated(int)));
    setupAccel();
    showBar();

	for (list<UserWnd*>::iterator it = m_childs.begin(); it != m_childs.end(); ++it)
		addUserWnd((*it), false);
	m_childs.clear();

    string windows = getWindows();
    while (!windows.empty()){
        unsigned long id = strtoul(getToken(windows, ',').c_str(), NULL, 10);
        Contact *contact = getContacts()->contact(id);
        if (contact == NULL)
            continue;
        Buffer config;
        const char *cfg = getWndConfig(id);
        if (cfg && *cfg){
            config << "[Title]\n" << cfg;
            config.setWritePos(0);
            config.getSection();
        }
        addUserWnd(new UserWnd(id, &config, false, true), true);
    }

    if (m_tabBar->count() == 0)
        QTimer::singleShot(0, this, SLOT(close()));
    setWindows(NULL);
    clearWndConfig();
    m_tabBar->raiseTab(getActiveWindow());

    show();
}
// =============================================================================
void MainWindow::paste() {
    ITimeTrackingWindow* curWindow = getActiveWindow();
    if(curWindow != NULL) {
        curWindow->paste();
    }
}