22 #include <kapplication.h> 24 #include <kwhatsthismanager_p.h> 26 #include <kstaticdeleter.h> 27 #include <kiconloader.h> 28 #include <kglobalsettings.h> 32 #include <tqobjectlist.h> 33 #include <tqguardedptr.h> 34 #include <tqlineedit.h> 35 #include <tqvaluelist.h> 47 const int KDialog::mMarginSize = 11;
48 const int KDialog::mSpacingSize = 6;
50 template class TQPtrList<TQLayoutItem>;
53 : TQDialog(parent, name, modal, f), d(0)
55 KWhatsThisManager::init ();
63 if ( e->state() == 0 )
71 if(testWFlags((WFlags)(WType_Dialog | WShowModal)))
73 TQDialog::keyPressEvent(e);
89 if ( e->state() == ControlButton &&
90 (e->key() == Key_Return || e->key() == Key_Enter) )
123 TQString caption = kapp ? kapp->makeStdCaption( _caption ) : _caption;
130 TQDialog::setCaption( caption );
133 NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
134 info.setName( caption.utf8().data() );
143 resizeLayout( TQT_TQLAYOUTITEM(w->layout()), margin, spacing );
146 if( !w->childrenListObject().isEmpty() )
148 const TQObjectList l = w->childrenListObject();
149 TQObjectListIterator itr(l);
151 while ((o = itr.current()) != 0) {
152 if( o->isWidgetType() )
164 TQLayoutIterator it = lay->iterator();
166 while ( (child = it.current() ) )
173 lay->layout()->setMargin( margin );
174 lay->layout()->setSpacing( spacing );
178 static TQRect screenRect( TQWidget *w,
int screen )
180 TQDesktopWidget *desktop = TQApplication::desktop();
181 KConfig gc(
"kdeglobals",
false,
false);
183 if (desktop->isVirtualDesktop() &&
186 if ( screen < 0 || screen >= desktop->numScreens() ) {
187 if ( screen == -1 ) {
188 screen = desktop->primaryScreen();
189 }
else if ( screen == -3 ) {
190 screen = desktop->screenNumber( TQCursor::pos() );
192 screen = desktop->screenNumber( w );
195 return desktop->availableGeometry(screen);
197 return desktop->geometry();
205 TQRect r = screenRect( w, screen );
207 w->move( r.center().x() - w->width()/2,
208 r.center().y() - w->height()/2 );
215 TQRect fg = w->frameGeometry();
216 if ( !fg.intersects( area ) )
219 TQRect scr = screenRect( w, screen );
220 TQRect avoid( area );
221 avoid.moveBy( -5, -5 );
222 avoid.rRight() += 10;
223 avoid.rBottom() += 10;
225 if ( QMAX( fg.top(), avoid.top() ) <= QMIN( fg.bottom(), avoid.bottom() ) )
228 int spaceAbove = QMAX(0, avoid.top() - scr.top());
229 int spaceBelow = QMAX(0, scr.bottom() - avoid.bottom());
230 if ( spaceAbove > spaceBelow )
231 if ( fg.height() <= spaceAbove )
232 fg.setY( avoid.top() - fg.height() );
236 if ( fg.height() <= spaceBelow )
237 fg.setY( avoid.bottom() );
242 if ( QMAX( fg.left(), avoid.left() ) <= QMIN( fg.right(), avoid.right() ) )
245 int spaceLeft = QMAX(0, avoid.left() - scr.left());
246 int spaceRight = QMAX(0, scr.right() - avoid.right());
247 if ( spaceLeft > spaceRight )
248 if ( fg.width() <= spaceLeft )
249 fg.setX( avoid.left() - fg.width() );
253 if ( fg.width() <= spaceRight )
254 fg.setX( avoid.right() );
259 w->move(fg.x(), fg.y());
263 class KDialogQueuePrivate
266 TQValueList< TQGuardedPtr<TQDialog> > queue;
272 KDialogQueue *KDialogQueue::_self=0;
274 KDialogQueue* KDialogQueue::self()
277 _self = ksdkdq.
setObject(_self,
new KDialogQueue);
281 KDialogQueue::KDialogQueue() : d(
new KDialogQueuePrivate)
286 KDialogQueue::~KDialogQueue()
293 void KDialogQueue::queueDialog(TQDialog *dialog)
295 KDialogQueue *_this =
self();
296 _this->d->queue.append(dialog);
297 TQTimer::singleShot(0, _this, TQT_SLOT(slotShowQueuedDialog()));
300 void KDialogQueue::slotShowQueuedDialog()
306 if(d->queue.isEmpty())
308 dialog = d->queue.first();
309 d->queue.pop_front();
318 if (!d->queue.isEmpty())
319 TQTimer::singleShot(20,
this, TQT_SLOT(slotShowQueuedDialog()));
324 void KDialog::virtual_hook(
int,
void* )
327 KSMModalDialogHeader::KSMModalDialogHeader(TQWidget* parent)
328 : TQWidget( parent,
"", Qt::WDestructiveClose )
330 TQVBoxLayout* vbox =
new TQVBoxLayout(
this );
332 TQFrame* frame =
new TQFrame(
this );
333 frame->setFrameStyle( TQFrame::NoFrame );
334 frame->setLineWidth( 0 );
336 frame->setMinimumWidth(400);
337 vbox->addWidget( frame );
340 TQHBoxLayout* seperatorbox =
new TQHBoxLayout( 0 );
341 centerbox->setMargin(0);
342 seperatorbox->setMargin(0);
344 TQWidget* ticon =
new TQWidget( frame );
349 TQRgb backgroundRgb = ticon->paletteBackgroundColor().rgb();
350 TQImage correctedImage = trinityPixmap.convertToImage();
351 correctedImage = correctedImage.convertDepth(32);
352 correctedImage.setAlphaBuffer(
true);
353 int w = correctedImage.width();
354 int h = correctedImage.height();
355 for (
int y = 0; y < h; ++y) {
356 TQRgb *ls = (TQRgb *)correctedImage.scanLine( y );
357 for (
int x = 0; x < w; ++x) {
359 float alpha_adjust = tqAlpha( l )/255.0;
360 int r = int( (tqRed( l ) * alpha_adjust) + (tqRed( backgroundRgb ) * (1.0-alpha_adjust)) );
361 int g = int( (tqGreen( l ) * alpha_adjust) + (tqGreen( backgroundRgb ) * (1.0-alpha_adjust)) );
362 int b = int( (tqBlue( l ) * alpha_adjust) + (tqBlue( backgroundRgb ) * (1.0-alpha_adjust)) );
364 ls[x] = tqRgba( r, g, b, a );
367 trinityPixmap.convertFromImage(correctedImage);
369 ticon->setBackgroundPixmap(trinityPixmap);
370 ticon->setMinimumSize(trinityPixmap.size());
371 ticon->setMaximumSize(trinityPixmap.size());
372 ticon->resize(trinityPixmap.size());
373 centerbox->addWidget( ticon, AlignCenter );
375 TQWidget* swidget =
new TQWidget( frame );
376 swidget->resize(2, frame->sizeHint().width());
377 swidget->setBackgroundColor(Qt::black);
378 seperatorbox->addWidget( swidget, AlignCenter );
380 TQLabel* label =
new TQLabel( i18n(
"Trinity Desktop Environment"), frame );
381 TQFont fnt = label->font();
383 fnt.setPointSize( fnt.pointSize() * 3 / 2 );
384 label->setFont( fnt );
385 centerbox->addWidget( label, AlignCenter );
387 gbox->addLayout(centerbox, 0, 0);
388 gbox->addLayout(seperatorbox, 1, 0);
390 setFixedSize( sizeHint() );
393 KSMModalDialogHeader::~KSMModalDialogHeader()
397 KSMModalDialog::KSMModalDialog(TQWidget* parent)
398 : TQWidget( 0,
"systemmodaldialogclass", Qt::WStyle_Customize | Qt::WType_Dialog | Qt::WStyle_Title | Qt::WStyle_StaysOnTop | Qt::WDestructiveClose ), m_keepOnTopTimer(NULL), m_allowClose(
false)
402 Atom kde_wm_system_modal_notification;
403 kde_wm_system_modal_notification = XInternAtom(qt_xdisplay(),
"_KDE_WM_MODAL_SYS_NOTIFICATION", False);
404 XChangeProperty(qt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (
unsigned char *)
"TRUE", 1L);
406 TQVBoxLayout* vbox =
new TQVBoxLayout(
this );
408 TQFrame* frame =
new TQFrame(
this );
409 frame->setFrameStyle( TQFrame::NoFrame );
410 frame->setLineWidth( style().pixelMetric( TQStyle::PM_DefaultFrameWidth, frame ) );
412 frame->setMinimumWidth(400);
413 vbox->addWidget( frame );
417 m_statusLabel =
new TQLabel( i18n(
"Pondering what to do next").append(
"..."), frame );
418 TQFont fnt = m_statusLabel->font();
419 fnt.setBold(
false );
420 fnt.setPointSize( fnt.pointSize() * 1 );
421 m_statusLabel->setFont( fnt );
422 gbox->addMultiCellWidget( m_statusLabel, 2, 2, 0, 0, AlignLeft | AlignVCenter );
425 centerbox->addWidget( theader, AlignCenter );
427 gbox->addLayout(centerbox, 0, 0);
429 setFixedSize( sizeHint() );
433 TQSize sh = sizeHint();
435 move(rect.x() + (rect.width() - sh.width())/2, rect.y() + (rect.height() - sh.height())/2);
441 void KSMModalDialog::keepMeOnTop()
443 if (!m_keepOnTopTimer) {
444 m_keepOnTopTimer =
new TQTimer();
445 connect(m_keepOnTopTimer, TQT_SIGNAL(timeout()),
this, TQT_SLOT(keepMeOnTop()));
446 m_keepOnTopTimer->start(100, FALSE);
453 KSMModalDialog::~KSMModalDialog()
455 m_keepOnTopTimer->stop();
456 delete m_keepOnTopTimer;
459 void KSMModalDialog::setStatusMessage(TQString message)
462 m_statusLabel->setText(i18n(
"Pondering what to do next").append(
"..."));
465 m_statusLabel->setText(message);
469 void KSMModalDialog::closeSMDialog()
475 void KSMModalDialog::closeEvent(TQCloseEvent *e)
483 TQWidget::closeEvent(e);
486 void KSMModalDialog::setStartupPhase(TQString msg)
488 if (msg == TQString(
"dcop")) setStatusMessage(i18n(
"Starting DCOP").append(
"..."));
489 if (msg == TQString(
"kded")) setStatusMessage(i18n(
"Starting TDE daemon").append(
"..."));
490 if (msg == TQString(
"kcminit")) setStatusMessage(i18n(
"Starting services").append(
"..."));
491 if (msg == TQString(
"ksmserver")) setStatusMessage(i18n(
"Starting session").append(
"..."));
492 if (msg == TQString(
"wm started")) setStatusMessage(i18n(
"Initializing window manager").append(
"..."));
493 if (msg == TQString(
"kdesktop")) setStatusMessage(i18n(
"Loading desktop").append(
"..."));
494 if (msg == TQString(
"kicker")) setStatusMessage(i18n(
"Loading panels").append(
"..."));
495 if (msg == TQString(
"session ready")) setStatusMessage(i18n(
"Restoring applications").append(
"..."));
498 #include "kdialog.moc" static int marginHint()
Return the number of pixels you shall use between a dialog edge and the outermost widget(s) according...
static TQRect desktopGeometry(const TQPoint &point)
static KIconLoader * iconLoader()
static bool avoidArea(TQWidget *widget, const TQRect &area, int screen=-1)
Places widget so that it doesn't cover a certain area of the screen.
virtual void setPlainCaption(const TQString &caption)
Make a plain caption without any modifications.
virtual void keyPressEvent(TQKeyEvent *)
KDialog(TQWidget *parent=0, const char *name=0, bool modal=false, WFlags f=0)
Constructor.
void setGroup(const TQString &group)
virtual void destructObject()
KDE_DEPRECATED type * setObject(type *obj, bool isArray=false)
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
static void resizeLayout(TQWidget *widget, int margin, int spacing)
Resize every layout manager used in widget and its nested children.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
static void centerOnScreen(TQWidget *widget, int screen=-1)
Centers widget on the desktop, taking multi-head setups into account.
TQPixmap loadIcon(const TQString &name, KIcon::Group group, int size=0, int state=KIcon::DefaultState, TQString *path_store=0L, bool canReturnNull=false) const
virtual void setCaption(const TQString &caption)
Make a KDE compliant caption.
virtual void polish()
If the dialog starts with focus in a TQLineEdit child, then call selectAll() on the child...