|
|
@ -123,40 +123,96 @@ void KPassivePopup::setView( const TQString &caption, const TQString &text,
|
|
|
|
setView( standardView( caption, text, icon, this ) );
|
|
|
|
setView( standardView( caption, text, icon, this ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQVBox * KPassivePopup::standardView( const TQString& caption,
|
|
|
|
static void truncateStringToFit(TQString &string, TQFont font, int max_width) {
|
|
|
|
|
|
|
|
bool truncated = false;
|
|
|
|
|
|
|
|
TQFontMetrics fm(font);
|
|
|
|
|
|
|
|
while (fm.width(string) > max_width) {
|
|
|
|
|
|
|
|
string.truncate(string.length() - 1);
|
|
|
|
|
|
|
|
truncated = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (truncated) {
|
|
|
|
|
|
|
|
string += " ...";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQVBox * KPassivePopup::standardView(const TQString& caption,
|
|
|
|
const TQString& text,
|
|
|
|
const TQString& text,
|
|
|
|
const TQPixmap& icon,
|
|
|
|
const TQPixmap& icon,
|
|
|
|
TQWidget *parent )
|
|
|
|
TQWidget *parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQVBox *vb = new TQVBox( parent ? parent : this );
|
|
|
|
TQString sizedCaption = caption;
|
|
|
|
vb->setSpacing( KDialog::spacingHint() );
|
|
|
|
TQString sizedText = text;
|
|
|
|
|
|
|
|
|
|
|
|
TQHBox *hb=0;
|
|
|
|
|
|
|
|
if ( !icon.isNull() ) {
|
|
|
|
|
|
|
|
hb = new TQHBox( vb );
|
|
|
|
|
|
|
|
hb->setMargin( 0 );
|
|
|
|
|
|
|
|
hb->setSpacing( KDialog::spacingHint() );
|
|
|
|
|
|
|
|
ttlIcon = new TQLabel( hb, "title_icon" );
|
|
|
|
|
|
|
|
ttlIcon->setPixmap( icon );
|
|
|
|
|
|
|
|
ttlIcon->setAlignment( AlignLeft );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !caption.isEmpty() ) {
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
ttl = new TQLabel( caption, hb ? hb : vb, "title_label" );
|
|
|
|
int max_width;
|
|
|
|
TQFont fnt = ttl->font();
|
|
|
|
|
|
|
|
fnt.setBold( true );
|
|
|
|
NETRootInfo info( tqt_xdisplay(),
|
|
|
|
ttl->setFont( fnt );
|
|
|
|
NET::NumberOfDesktops |
|
|
|
|
ttl->setAlignment( Qt::AlignHCenter );
|
|
|
|
NET::CurrentDesktop |
|
|
|
|
if ( hb )
|
|
|
|
NET::WorkArea,
|
|
|
|
hb->setStretchFactor( ttl, 10 ); // enforce centering
|
|
|
|
-1, false );
|
|
|
|
}
|
|
|
|
info.activate();
|
|
|
|
|
|
|
|
NETRect workArea = info.workArea(info.currentDesktop());
|
|
|
|
|
|
|
|
max_width = workArea.size.width / 3;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if ( !text.isEmpty() ) {
|
|
|
|
TQVBox *vb = new TQVBox( parent ? parent : this );
|
|
|
|
msg = new TQLabel( text, vb, "msg_label" );
|
|
|
|
vb->setSpacing( KDialog::spacingHint() );
|
|
|
|
msg->setAlignment( AlignLeft );
|
|
|
|
|
|
|
|
}
|
|
|
|
TQHBox *hb=0;
|
|
|
|
|
|
|
|
if ( !icon.isNull() ) {
|
|
|
|
|
|
|
|
hb = new TQHBox( vb );
|
|
|
|
|
|
|
|
hb->setMargin( 0 );
|
|
|
|
|
|
|
|
hb->setSpacing( KDialog::spacingHint() );
|
|
|
|
|
|
|
|
ttlIcon = new TQLabel( hb, "title_icon" );
|
|
|
|
|
|
|
|
ttlIcon->setPixmap( icon );
|
|
|
|
|
|
|
|
ttlIcon->setAlignment( AlignLeft );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !sizedCaption.isEmpty() ) {
|
|
|
|
|
|
|
|
ttl = new TQLabel( sizedCaption, hb ? hb : vb, "title_label" );
|
|
|
|
|
|
|
|
TQFont fnt = ttl->font();
|
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
|
|
|
|
truncateStringToFit(sizedCaption, fnt, max_width);
|
|
|
|
|
|
|
|
ttl->setText(sizedCaption);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fnt.setBold( true );
|
|
|
|
|
|
|
|
ttl->setFont( fnt );
|
|
|
|
|
|
|
|
ttl->setAlignment( Qt::AlignHCenter );
|
|
|
|
|
|
|
|
if ( hb ) {
|
|
|
|
|
|
|
|
hb->setStretchFactor( ttl, 10 ); // enforce centering
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !sizedText.isEmpty() ) {
|
|
|
|
|
|
|
|
msg = new TQLabel( sizedText, vb, "msg_label" );
|
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
|
|
|
|
TQStringList textLines = TQStringList::split("\n", sizedText, true);
|
|
|
|
|
|
|
|
for (TQStringList::Iterator it = textLines.begin(); it != textLines.end(); ++it) {
|
|
|
|
|
|
|
|
truncateStringToFit(*it, msg->font(), max_width);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Limit message to 5 lines of text
|
|
|
|
|
|
|
|
if (textLines.count() > 5) {
|
|
|
|
|
|
|
|
int count = 3;
|
|
|
|
|
|
|
|
TQStringList truncatedLines;
|
|
|
|
|
|
|
|
for (TQStringList::Iterator it = textLines.begin(); it != textLines.end(); ++it) {
|
|
|
|
|
|
|
|
truncatedLines.append(*it);
|
|
|
|
|
|
|
|
if (count > 5) {
|
|
|
|
|
|
|
|
truncatedLines.append("...");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
textLines = truncatedLines;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sizedText = textLines.join("\n");
|
|
|
|
|
|
|
|
msg->setText(sizedText);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
msg->setAlignment( AlignLeft );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return vb;
|
|
|
|
return vb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KPassivePopup::setView( const TQString &caption, const TQString &text )
|
|
|
|
void KPassivePopup::setView( const TQString &caption, const TQString &text )
|
|
|
@ -194,27 +250,33 @@ void KPassivePopup::mouseReleaseEvent( TQMouseEvent *e )
|
|
|
|
|
|
|
|
|
|
|
|
void KPassivePopup::show()
|
|
|
|
void KPassivePopup::show()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( size() != sizeHint() )
|
|
|
|
TQSize desiredSize = sizeHint();
|
|
|
|
resize( sizeHint() );
|
|
|
|
|
|
|
|
|
|
|
|
if (size() != desiredSize) {
|
|
|
|
if ( d->fixedPosition.isNull() )
|
|
|
|
resize(desiredSize);
|
|
|
|
positionSelf();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if( d->popupStyle == Balloon )
|
|
|
|
if (d->fixedPosition.isNull()) {
|
|
|
|
setAnchor( d->fixedPosition );
|
|
|
|
positionSelf();
|
|
|
|
else
|
|
|
|
}
|
|
|
|
move( d->fixedPosition );
|
|
|
|
else {
|
|
|
|
}
|
|
|
|
if( d->popupStyle == Balloon ) {
|
|
|
|
TQFrame::show();
|
|
|
|
setAnchor(d->fixedPosition);
|
|
|
|
|
|
|
|
}
|
|
|
|
int delay = hideDelay;
|
|
|
|
else {
|
|
|
|
if ( delay < 0 ) {
|
|
|
|
move(d->fixedPosition);
|
|
|
|
delay = DEFAULT_POPUP_TIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TQFrame::show();
|
|
|
|
if ( delay > 0 ) {
|
|
|
|
|
|
|
|
hideTimer->start( delay );
|
|
|
|
int delay = hideDelay;
|
|
|
|
}
|
|
|
|
if ( delay < 0 ) {
|
|
|
|
|
|
|
|
delay = DEFAULT_POPUP_TIME;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( delay > 0 ) {
|
|
|
|
|
|
|
|
hideTimer->start( delay );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KPassivePopup::show(const TQPoint &p)
|
|
|
|
void KPassivePopup::show(const TQPoint &p)
|
|
|
@ -346,13 +408,14 @@ void KPassivePopup::setAnchor(const TQPoint &anchor)
|
|
|
|
|
|
|
|
|
|
|
|
void KPassivePopup::paintEvent( TQPaintEvent* pe )
|
|
|
|
void KPassivePopup::paintEvent( TQPaintEvent* pe )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( d->popupStyle == Balloon )
|
|
|
|
if( d->popupStyle == Balloon ) {
|
|
|
|
{
|
|
|
|
TQPainter p;
|
|
|
|
TQPainter p;
|
|
|
|
p.begin( this );
|
|
|
|
p.begin( this );
|
|
|
|
p.drawPolygon( d->surround );
|
|
|
|
p.drawPolygon( d->surround );
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
else {
|
|
|
|
TQFrame::paintEvent( pe );
|
|
|
|
TQFrame::paintEvent( pe );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KPassivePopup::updateMask()
|
|
|
|
void KPassivePopup::updateMask()
|
|
|
|