Width hight and positioning of the widget

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
feat/with_dbus-1-tqt
Emanoil Kotsev 3 months ago
parent f4e459e3d0
commit d24daeea97
No known key found for this signature in database
GPG Key ID: F1EEB8CD9FB16A50

@ -112,13 +112,13 @@ void NotificationsService::NotifyAsync(
TQ_UINT32 nId = id;
// if (nId != 0 && !mNotificationMap.contains(nId))
// tqDebug("Requested id %i is not valid", nId);
bool isNewWidget=false;
if (nId == 0 || !mNotificationMap.contains(nId)) // new notification
{
nId = ++mNotificationId;
isNewWidget = true;
mNotificationMap[nId] = new NotifyWidget(0, app_name.ascii(), nId);
mNotificationMap[nId]->setMinimumSize(200, 40);
connect(mNotificationMap[nId], TQ_SIGNAL(notificationClosed(TQ_UINT32, TQ_UINT32)),
this, TQ_SLOT(closeNotifyWidget(TQ_UINT32, TQ_UINT32)));
}
@ -199,24 +199,30 @@ void NotificationsService::NotifyAsync(
if(mNotificationMap[nId]->getUrgency() == 2)
timeout = 0; // critical notifications should never expire
mNotificationMap[nId]->setTimeout(timeout);
mNotificationMap[nId]->updateGeometry();
mNotificationMap[nId]->adjustSize();
mNotificationMap[nId]->raise();
mNotificationMap[nId]->setActiveWindow();
// make sure we display the new notification above the older one
// and if we reach the top of the screen we start at the bottom
TQDesktopWidget *d = TQApplication::desktop();
if (mNotificationMap.contains(nId-1) && mNotificationMap[nId-1] != 0) {
TQPoint pos = mNotificationMap[nId-1]->pos();
if(pos.y()-mNotificationMap[nId-1]->height() < 0)
pos.setY(d->height()-mNotificationMap[nId]->height());
pos.setX(d->width()-mNotificationMap[nId]->width());
mNotificationMap[nId]->move(pos.x(),pos.y()-mNotificationMap[nId-1]->height());
} else {
mNotificationMap[nId]->move( d->width()-mNotificationMap[nId]->width(),
d->height()-mNotificationMap[nId]->height());
if(isNewWidget) // new widget position
{
// make sure we display the new notification above the older one
// and if we reach the top of the screen we start at the bottom
TQDesktopWidget *d = TQApplication::desktop();
if (mNotificationMap.contains(nId-1) && mNotificationMap[nId-1] != 0) {
TQPoint pos = mNotificationMap[nId-1]->pos();
if(pos.y()-mNotificationMap[nId]->height() < 0)
pos.setY(d->height()-mNotificationMap[nId]->height());
else
pos.setY(pos.y()-mNotificationMap[nId]->height());
pos.setX(d->width()-mNotificationMap[nId]->width());
mNotificationMap[nId]->move(pos);
} else {
mNotificationMap[nId]->move( d->width()-mNotificationMap[nId]->width(),
d->height()-mNotificationMap[nId]->height());
}
mNotificationMap[nId]->show();
}
mNotificationMap[nId]->show();
NotifyAsyncReply(asyncCallId, nId);
}

@ -30,6 +30,7 @@
#define FADE_SPEED 5
#define EXPTIMEOUT 15000 //msec
#define NOTIFICATION_WIDTH 300
NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, TQ_INT32 id )
: TQWidget( parent, name, WStyle_Customize | TQt::WStyle_StaysOnTop | TQt::WStyle_NoBorder),
@ -50,7 +51,6 @@ NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, TQ_INT32 id )
mImageLabel = new TQLabel(this);
mImageLabel->setFrameStyle( TQFrame::NoFrame );
mTextLabel = new TQLabel(this);
mTextLabel->setTextFormat(TQt::RichText);
mTextLabel->setFrameStyle( TQFrame::NoFrame );
// TODO: give the user an option to configure the background
// mImageLabel[nId]->setPaletteBackgroundColor(TQt::black);
@ -231,8 +231,11 @@ void NotifyWidget::setTimeout(TQ_INT32 t) {
void NotifyWidget::setText(TQString t)
{
mTextLabel->setText(t);
mTextLabel->setMaximumWidth(NOTIFICATION_WIDTH);
mTextLabel->setAlignment(TQLabel::AlignTop);
mTextLabel->setTextFormat(TQt::RichText);
mTextLabel->setAutoResize(true);
mTextLabel->setText(t);
}
void NotifyWidget::mousePressEvent( TQMouseEvent *e )

Loading…
Cancel
Save