21 #include <tdeconfig.h>
22 #include <tdeapplication.h>
24 #include <kwhatsthismanager_p.h>
26 #include <kstaticdeleter.h>
27 #include <kiconloader.h>
28 #include <tdeglobalsettings.h>
32 #include <tqobjectlist.h>
33 #include <tqguardedptr.h>
34 #include <tqlineedit.h>
35 #include <tqvaluelist.h>
41 #include <tqpushbutton.h>
48 const int KDialog::mMarginSize = 11;
49 const int KDialog::mSpacingSize = 6;
51 template class TQPtrList<TQLayoutItem>;
54 : TQDialog(parent, name, modal, f), d(0)
56 KWhatsThisManager::init ();
64 if ( e->state() == 0 )
72 if(testWFlags((WFlags)(WType_Dialog | WShowModal)))
74 TQDialog::keyPressEvent(e);
90 if ( e->state() == ControlButton &&
91 (e->key() == Key_Return || e->key() == Key_Enter) )
124 TQString caption = kapp ? kapp->makeStdCaption( _caption ) : _caption;
131 TQDialog::setCaption( caption );
134 NETWinInfo info( tqt_xdisplay(), winId(), tqt_xrootwin(), 0 );
135 info.setName( caption.utf8().data() );
147 if( !w->childrenListObject().isEmpty() )
149 const TQObjectList l = w->childrenListObject();
150 TQObjectListIterator itr(l);
152 while ((o = itr.current()) != 0) {
153 if( o->isWidgetType() )
165 TQLayoutIterator it = lay->iterator();
167 while ( (child = it.current() ) )
174 lay->layout()->setMargin( margin );
175 lay->layout()->setSpacing( spacing );
179 static TQRect screenRect( TQWidget *w,
int screen )
181 TQDesktopWidget *desktop = TQApplication::desktop();
182 TDEConfig gc(
"kdeglobals",
false,
false);
183 gc.setGroup(
"Windows");
184 if (desktop->isVirtualDesktop() &&
185 gc.readBoolEntry(
"XineramaEnabled",
true) &&
186 gc.readBoolEntry(
"XineramaPlacementEnabled",
true)) {
187 if ( screen < 0 || screen >= desktop->numScreens() ) {
188 if ( screen == -1 ) {
189 screen = desktop->primaryScreen();
190 }
else if ( screen == -3 ) {
191 screen = desktop->screenNumber( TQCursor::pos() );
193 screen = desktop->screenNumber( w );
196 return desktop->availableGeometry(screen);
198 return desktop->geometry();
206 TQRect r = screenRect( w, screen );
208 w->move( r.center().x() - w->width()/2,
209 r.center().y() - w->height()/2 );
216 TQRect fg = w->frameGeometry();
217 if ( !fg.intersects( area ) )
220 TQRect scr = screenRect( w, screen );
221 TQRect avoid( area );
222 avoid.moveBy( -5, -5 );
223 avoid.rRight() += 10;
224 avoid.rBottom() += 10;
226 if ( TQMAX( fg.top(), avoid.top() ) <= TQMIN( fg.bottom(), avoid.bottom() ) )
229 int spaceAbove = TQMAX(0, avoid.top() - scr.top());
230 int spaceBelow = TQMAX(0, scr.bottom() - avoid.bottom());
231 if ( spaceAbove > spaceBelow )
232 if ( fg.height() <= spaceAbove )
233 fg.setY( avoid.top() - fg.height() );
237 if ( fg.height() <= spaceBelow )
238 fg.setY( avoid.bottom() );
243 if ( TQMAX( fg.left(), avoid.left() ) <= TQMIN( fg.right(), avoid.right() ) )
246 int spaceLeft = TQMAX(0, avoid.left() - scr.left());
247 int spaceRight = TQMAX(0, scr.right() - avoid.right());
248 if ( spaceLeft > spaceRight )
249 if ( fg.width() <= spaceLeft )
250 fg.setX( avoid.left() - fg.width() );
254 if ( fg.width() <= spaceRight )
255 fg.setX( avoid.right() );
260 w->move(fg.x(), fg.y());
264 class KDialogQueuePrivate
267 TQValueList< TQGuardedPtr<TQDialog> > queue;
273 KDialogQueue *KDialogQueue::_self=0;
275 KDialogQueue* KDialogQueue::self()
278 _self = ksdkdq.setObject(_self,
new KDialogQueue);
282 KDialogQueue::KDialogQueue() : d(new KDialogQueuePrivate)
287 KDialogQueue::~KDialogQueue()
294 void KDialogQueue::queueDialog(TQDialog *dialog)
296 KDialogQueue *_this =
self();
297 _this->d->queue.append(dialog);
298 TQTimer::singleShot(0, _this, TQ_SLOT(slotShowQueuedDialog()));
301 void KDialogQueue::slotShowQueuedDialog()
307 if(d->queue.isEmpty())
309 dialog = d->queue.first();
310 d->queue.pop_front();
319 if (!d->queue.isEmpty())
320 TQTimer::singleShot(20,
this, TQ_SLOT(slotShowQueuedDialog()));
322 ksdkdq.destructObject();
325 void KDialog::virtual_hook(
int,
void* )
328 KSMModalDialogHeader::KSMModalDialogHeader(TQWidget* parent)
329 : TQWidget( parent,
"", TQt::WDestructiveClose )
331 TQVBoxLayout* vbox =
new TQVBoxLayout(
this );
333 TQFrame* frame =
new TQFrame(
this );
334 frame->setFrameStyle( TQFrame::NoFrame );
335 frame->setLineWidth( 0 );
337 frame->setMinimumWidth(400);
338 vbox->addWidget( frame );
341 TQHBoxLayout* seperatorbox =
new TQHBoxLayout( 0 );
342 centerbox->setMargin(0);
343 seperatorbox->setMargin(0);
345 TQWidget* ticon =
new TQWidget( frame );
350 TQRgb backgroundRgb = ticon->paletteBackgroundColor().rgb();
351 TQImage correctedImage = trinityPixmap.convertToImage();
352 correctedImage = correctedImage.convertDepth(32);
353 correctedImage.setAlphaBuffer(
true);
354 int w = correctedImage.width();
355 int h = correctedImage.height();
356 for (
int y = 0; y < h; ++y) {
357 TQRgb *ls = (TQRgb *)correctedImage.scanLine( y );
358 for (
int x = 0; x < w; ++x) {
360 float alpha_adjust = tqAlpha( l )/255.0;
361 int r = int( (tqRed( l ) * alpha_adjust) + (tqRed( backgroundRgb ) * (1.0-alpha_adjust)) );
362 int g = int( (tqGreen( l ) * alpha_adjust) + (tqGreen( backgroundRgb ) * (1.0-alpha_adjust)) );
363 int b = int( (tqBlue( l ) * alpha_adjust) + (tqBlue( backgroundRgb ) * (1.0-alpha_adjust)) );
365 ls[x] = tqRgba( r, g, b, a );
368 trinityPixmap.convertFromImage(correctedImage);
370 ticon->setBackgroundPixmap(trinityPixmap);
371 ticon->setMinimumSize(trinityPixmap.size());
372 ticon->setMaximumSize(trinityPixmap.size());
373 ticon->resize(trinityPixmap.size());
374 centerbox->addWidget( ticon, AlignCenter );
376 TQWidget* swidget =
new TQWidget( frame );
377 swidget->resize(2, frame->sizeHint().width());
378 swidget->setBackgroundColor(TQt::black);
379 seperatorbox->addWidget( swidget, AlignCenter );
381 TQLabel*
label =
new TQLabel( i18n(
"Trinity Desktop Environment"), frame );
382 TQFont fnt =
label->font();
384 fnt.setPointSize( fnt.pointSize() * 3 / 2 );
385 label->setFont( fnt );
386 centerbox->addWidget( label, AlignCenter );
388 gbox->addLayout(centerbox, 0, 0);
389 gbox->addLayout(seperatorbox, 1, 0);
391 setFixedSize( sizeHint() );
394 KSMModalDialogHeader::~KSMModalDialogHeader()
398 KSMModalDialog::KSMModalDialog(TQWidget* parent)
399 : TQWidget( 0,
"systemmodaldialogclass", TQt::WStyle_Customize | TQt::WType_Dialog | TQt::WStyle_Title | TQt::WStyle_StaysOnTop | TQt::WDestructiveClose ), m_keepOnTopTimer(NULL), m_allowClose(false)
403 Atom kde_wm_system_modal_notification;
404 kde_wm_system_modal_notification = XInternAtom(tqt_xdisplay(),
"_TDE_WM_MODAL_SYS_NOTIFICATION", False);
405 XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (
unsigned char *)
"TRUE", 1L);
407 TQVBoxLayout* vbox =
new TQVBoxLayout(
this );
409 TQFrame* frame =
new TQFrame(
this );
410 frame->setFrameStyle( TQFrame::NoFrame );
411 frame->setLineWidth( style().pixelMetric( TQStyle::PM_DefaultFrameWidth, frame ) );
413 frame->setMinimumWidth(400);
414 vbox->addWidget( frame );
418 m_statusLabel =
new TQLabel( i18n(
"Pondering what to do next").append(
"..."), frame );
419 TQFont fnt = m_statusLabel->font();
420 fnt.setBold(
false );
421 fnt.setPointSize( fnt.pointSize() * 1 );
422 m_statusLabel->setFont( fnt );
423 m_gridlayout->addMultiCellWidget( m_statusLabel, 2, 2, 0, 2, AlignLeft | AlignVCenter );
426 centerbox->addWidget( theader, AlignCenter );
428 m_gridlayout->addLayout(centerbox, 0, 0);
430 m_buttonframe =
new TQFrame(
this );
431 m_buttonframe->setFrameStyle( TQFrame::NoFrame );
432 m_buttonframe->setLineWidth( style().pixelMetric( TQStyle::PM_DefaultFrameWidth, frame ) );
435 m_button1 =
new TQPushButton( m_buttonframe );
436 m_button2 =
new TQPushButton( m_buttonframe );
437 m_button3 =
new TQPushButton( m_buttonframe );
438 m_buttonbox->addWidget( m_button1 );
439 m_buttonbox->addWidget( m_button2 );
440 m_buttonbox->addWidget( m_button3 );
445 m_buttonframe->hide();
446 m_gridlayout->addMultiCellWidget( m_buttonframe, 3, 3, 0, 2, 0 );
448 setFixedSize( sizeHint() );
452 TQSize sh = sizeHint();
454 move(rect.x() + (rect.width() - sh.width())/2, rect.y() + (rect.height() - sh.height())/2);
460 void KSMModalDialog::keepMeOnTop()
462 if (!m_keepOnTopTimer) {
463 m_keepOnTopTimer =
new TQTimer();
464 connect(m_keepOnTopTimer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(keepMeOnTop()));
465 m_keepOnTopTimer->start(100, FALSE);
472 KSMModalDialog::~KSMModalDialog()
474 m_keepOnTopTimer->stop();
475 delete m_keepOnTopTimer;
478 void KSMModalDialog::setStatusMessage(TQString message)
481 m_statusLabel->setText(i18n(
"Pondering what to do next").append(
"..."));
484 m_statusLabel->setText(message);
488 void KSMModalDialog::closeSMDialog()
494 void KSMModalDialog::closeEvent(TQCloseEvent *e)
502 TQWidget::closeEvent(e);
505 void KSMModalDialog::setStartupPhase(TQString msg)
507 if (msg == TQString(
"dcop")) setStatusMessage(i18n(
"Starting DCOP").append(
"..."));
508 if (msg == TQString(
"kded")) setStatusMessage(i18n(
"Starting TDE daemon").append(
"..."));
509 if (msg == TQString(
"kcminit")) setStatusMessage(i18n(
"Starting services").append(
"..."));
510 if (msg == TQString(
"ksmserver")) setStatusMessage(i18n(
"Starting session").append(
"..."));
511 if (msg == TQString(
"wm started")) setStatusMessage(i18n(
"Initializing window manager").append(
"..."));
512 if (msg == TQString(
"kdesktop")) setStatusMessage(i18n(
"Loading desktop").append(
"..."));
513 if (msg == TQString(
"kicker")) setStatusMessage(i18n(
"Loading panels").append(
"..."));
514 if (msg == TQString(
"session ready")) setStatusMessage(i18n(
"Restoring applications").append(
"..."));
517 #include "kdialog.moc"
static int marginHint()
Return the number of pixels you shall use between a dialog edge and the outermost widget(s) according...
KDialog(TQWidget *parent=0, const char *name=0, bool modal=false, WFlags f=0)
Constructor.
virtual void keyPressEvent(TQKeyEvent *)
static void centerOnScreen(TQWidget *widget, int screen=-1)
Centers widget on the desktop, taking multi-head setups into account.
virtual void setPlainCaption(const TQString &caption)
Make a plain caption without any modifications.
virtual void polish()
If the dialog starts with focus in a TQLineEdit child, then call selectAll() on the child.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
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 setCaption(const TQString &caption)
Make a KDE compliant caption.
static void resizeLayout(TQWidget *widget, int margin, int spacing)
Resize every layout manager used in widget and its nested children.
static TQRect desktopGeometry(const TQPoint &point)
static TDEIconLoader * iconLoader()
TQPixmap loadIcon(const TQString &name, TDEIcon::Group group, int size=0, int state=TDEIcon::DefaultState, TQString *path_store=0L, bool canReturnNull=false) const
const TDEShortcut & close()
TQString label(StdAccel id)