Seite 1 von 1

PopupDialog soll blinken auf der taskleiste

Verfasst: 14. Mai 2007 15:43
von defenderLQ
hi

ich habe rausgefunden das wenn eine nachricht kommt
das es das dialog wieder hervor rufen kann.

aber wie kann man das dialog auf der taskleiste blinken lassen statt
es in den vordergrund kommt?

Code: Alles auswählen

include <QtGui>

#include "rshare.h"
#include "PopupChatDialog.h"
#include "config/gconfig.h"

#include <QTextCodec>
#include <QTextEdit>
#include <QToolBar>
#include <QTextCursor>
#include <QTextList>


/* Define the format used for displaying the date and time */
#define DATETIME_FMT  "MMM dd hh:mm:ss"

#include <sstream>


/** Default constructor */
PopupChatDialog::PopupChatDialog(std::string id, std::string name, 
				QWidget *parent, Qt::WFlags flags)
  : QMainWindow(parent, flags), dialogId(id), dialogName(name),
    lastChatTime(0), lastChatName("")
{
  /* Invoke Qt Designer generated QObject setup routine */
  ui.setupUi(this);

  GConfig config;
  config.loadWidgetInformation(this);

  connect(ui.lineEdit, SIGNAL(returnPressed( ) ), this, SLOT(sendChat( ) ));


  // Create the status bar
  std::ostringstream statusstr;
  statusstr << "Chatting with: " << dialogName << " !!! " << id;
  statusBar()->showMessage(QString::fromStdString(statusstr.str()));
  ui.textBrowser->setOpenExternalLinks ( false );

}



/** 
 Overloads the default show() slot so we can set opacity*/

void PopupChatDialog::show()
{

  if(!this->isVisible()) {
    QMainWindow::show();
  } else {
    QMainWindow::activateWindow();
    setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
    QMainWindow::raise();
  }
  
}

void PopupChatDialog::closeEvent (QCloseEvent * event)
{
    hide();
    event->ignore();
}


void PopupChatDialog::updateChat()
{
	/* get chat off queue */

	/* write it out */

}



void PopupChatDialog::addChatMsg(ChatInfo *ci)
{
        QTextBrowser *msgWidget = ui.textBrowser;

	QString currenttxt = msgWidget->toHtml();

	/* determine how many spaces to add */
	int n = msgWidget->width();
	/* now spaces = (width - txt width) / (pixel / space)
	 */

	std::cerr << "Width is : " << n << std::endl;
	n -= 256; /* 220 pixels for name */
	if (n > 0)
	{
		n = 2 + n / 10;
	}
	else
	{
		n = 1;
	}

	std::cerr << "Space count : " << n << std::endl;

	std::string spaces(" ");


	/* add in lines at the bottom */
	std::ostringstream out;
	int ts = time(NULL);
	if ((ci->name == lastChatName) && (ts - lastChatTime < 60))
	{
			/* no name */
	}
	else
	{
		for(int i = 0; i < n; i++)
		{
			out << spaces; 
		}

		out << "[" << ci->name << " Said @" << ts << "]" << std::endl;
		out << "<br>" << std::endl;

	}
	out << ci -> msg << std::endl;
	lastChatTime = ts;
	lastChatName = ci->name;

	QString extra = QString::fromStdString(out.str());
	currenttxt += extra;

	msgWidget->setHtml(currenttxt);

	std::cerr << " Added Text: " << std::endl;
	std::cerr << out.str() << std::endl;
	QScrollBar *qsb =  msgWidget->verticalScrollBar();
	qsb -> setValue(qsb->maximum());
}


void PopupChatDialog::sendChat()
{
        QLineEdit *lineWidget = ui.lineEdit;

        ChatInfo ci;

	{
          rsiface->lockData(); /* Lock Interface */
          const RsConfig &conf = rsiface->getConfig();

	  ci.rsid = conf.ownId;
	  ci.name = conf.ownName;

          rsiface->unlockData(); /* Unlock Interface */
	}

        ci.msg = lineWidget->text().toStdString();
        ci.chatflags = RS_CHAT_PRIVATE;

	addChatMsg(&ci);

        /* put proper destination */
	ci.rsid = dialogId;
	ci.name = dialogName;

        rsicontrol -> ChatSend(ci);
        lineWidget -> setText(QString(""));

        /* redraw send list */
}


Code: Alles auswählen

void PopupChatDialog::show()
{

  if(!this->isVisible()) {
    QMainWindow::show();
  } else {
    QMainWindow::activateWindow();
    setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
    QMainWindow::raise();
  }
  
}

Verfasst: 14. Mai 2007 19:48
von upsala
Das ist Sache des Windowmanagers. Ich denke nicht, daß man mit Qt darauf Einfluß hat...

Verfasst: 16. Mai 2007 00:00
von defenderLQ
hi

wie ich sehe es macht manchmal hervorrufen oder auch
blinken auf der taskleiste..

ist also immer unterschiedlich muss nichts einbauen es macht schon vorn selber... :D