@@ -24,9 +24,14 @@ NotificationCard::NotificationCard(const NotificationData& notification, QWidget
2424 , m_actionIndicator(nullptr )
2525 , m_actionWidget(nullptr )
2626 , m_actionButtonsLayout(nullptr )
27+ , m_inputWidget(nullptr )
28+ , m_replyInput(nullptr )
29+ , m_sendButton(nullptr )
30+ , m_cancelButton(nullptr )
2731 , m_isHovered(false )
2832 , m_actionsVisible(false )
2933 , m_bodiesExpanded(false )
34+ , m_inputVisible(false )
3035{
3136 setupUI ();
3237
@@ -182,6 +187,10 @@ void NotificationCard::setupUI()
182187
183188 // Setup action buttons (initially hidden)
184189 setupActionButtons ();
190+
191+ // Setup input field (initially hidden)
192+ setupInputField ();
193+
185194 updateGeometry ();
186195}
187196
@@ -280,6 +289,104 @@ void NotificationCard::setupActionButtons()
280289 m_actionWidget->hide ();
281290}
282291
292+ void NotificationCard::setupInputField ()
293+ {
294+ // Create input widget container
295+ m_inputWidget = new QWidget (this );
296+ m_inputLayout = new QVBoxLayout (m_inputWidget);
297+ m_inputLayout->setContentsMargins (0 , 5 , 0 , 0 );
298+ m_inputLayout->setSpacing (6 );
299+
300+ // Create reply input field
301+ m_replyInput = new QLineEdit (m_inputWidget);
302+ m_replyInput->setPlaceholderText (" Type your reply..." );
303+ m_replyInput->setStyleSheet (
304+ " QLineEdit {"
305+ " background-color: rgba(60, 60, 60, 0.8);"
306+ " border: 1px solid rgba(255, 255, 255, 0.2);"
307+ " border-radius: 4px;"
308+ " color: white;"
309+ " font-size: 12px;"
310+ " padding: 6px 8px;"
311+ " }"
312+ " QLineEdit:focus {"
313+ " border: 1px solid rgba(70, 130, 180, 0.8);"
314+ " background-color: rgba(70, 70, 70, 0.9);"
315+ " }"
316+ );
317+
318+ // Connect return key to send
319+ connect (m_replyInput, &QLineEdit::returnPressed, this , &NotificationCard::onInputReturnPressed);
320+
321+ m_inputLayout->addWidget (m_replyInput);
322+
323+ // Create buttons layout
324+ m_inputButtonsLayout = new QHBoxLayout ();
325+ m_inputButtonsLayout->setSpacing (8 );
326+
327+ // Create send button
328+ m_sendButton = new QPushButton (" Send" , m_inputWidget);
329+ m_sendButton->setStyleSheet (
330+ " QPushButton {"
331+ " background-color: rgba(70, 130, 180, 0.8);"
332+ " border: 1px solid rgba(255, 255, 255, 0.2);"
333+ " border-radius: 4px;"
334+ " color: white;"
335+ " font-size: 11px;"
336+ " padding: 4px 12px;"
337+ " min-width: 50px;"
338+ " }"
339+ " QPushButton:hover {"
340+ " background-color: rgba(70, 130, 180, 1.0);"
341+ " border: 1px solid rgba(255, 255, 255, 0.4);"
342+ " }"
343+ " QPushButton:pressed {"
344+ " background-color: rgba(50, 110, 160, 1.0);"
345+ " }"
346+ );
347+
348+ // Create cancel button
349+ m_cancelButton = new QPushButton (" Cancel" , m_inputWidget);
350+ m_cancelButton->setStyleSheet (
351+ " QPushButton {"
352+ " background-color: rgba(120, 120, 120, 0.6);"
353+ " border: 1px solid rgba(255, 255, 255, 0.2);"
354+ " border-radius: 4px;"
355+ " color: white;"
356+ " font-size: 11px;"
357+ " padding: 4px 12px;"
358+ " min-width: 50px;"
359+ " }"
360+ " QPushButton:hover {"
361+ " background-color: rgba(140, 140, 140, 0.8);"
362+ " border: 1px solid rgba(255, 255, 255, 0.4);"
363+ " }"
364+ " QPushButton:pressed {"
365+ " background-color: rgba(100, 100, 100, 0.8);"
366+ " }"
367+ );
368+
369+ // Connect button signals
370+ connect (m_sendButton, &QPushButton::clicked, this , &NotificationCard::onSendButtonClicked);
371+ connect (m_cancelButton, &QPushButton::clicked, this , &NotificationCard::onCancelButtonClicked);
372+
373+ // Add buttons to layout
374+ m_inputButtonsLayout->addWidget (m_sendButton);
375+ m_inputButtonsLayout->addWidget (m_cancelButton);
376+ m_inputButtonsLayout->addStretch ();
377+
378+ // Create buttons container widget
379+ QWidget* buttonsWidget = new QWidget (m_inputWidget);
380+ buttonsWidget->setLayout (m_inputButtonsLayout);
381+ m_inputLayout->addWidget (buttonsWidget);
382+
383+ // Add input widget to main layout
384+ m_mainLayout->addWidget (m_inputWidget);
385+
386+ // Initially hidden
387+ m_inputWidget->hide ();
388+ }
389+
283390void NotificationCard::showActions ()
284391{
285392 if (m_actionWidget && !m_notificationData.actions .isEmpty ()) {
@@ -318,6 +425,33 @@ void NotificationCard::hideBodies()
318425 }
319426}
320427
428+ void NotificationCard::showInput (const QString& actionKey)
429+ {
430+ if (m_inputWidget) {
431+ m_currentActionKey = actionKey;
432+ m_replyInput->clear ();
433+ m_replyInput->setFocus ();
434+ m_inputWidget->show ();
435+ m_inputVisible = true ;
436+
437+ // Hide action buttons when showing input
438+ hideActions ();
439+
440+ updateCardHeight ();
441+ }
442+ }
443+
444+ void NotificationCard::hideInput ()
445+ {
446+ if (m_inputWidget) {
447+ m_inputWidget->hide ();
448+ m_inputVisible = false ;
449+ m_currentActionKey.clear ();
450+
451+ updateCardHeight ();
452+ }
453+ }
454+
321455void NotificationCard::onActionButtonClicked ()
322456{
323457 QPushButton* button = qobject_cast<QPushButton*>(sender ());
@@ -327,10 +461,10 @@ void NotificationCard::onActionButtonClicked()
327461 QString actionType = button->property (" actionType" ).toString ();
328462
329463 if (actionType == " remote_input" ) {
330- // For now, emit a signal to handle reply input
331- // In a full implementation, you'd show an input dialog
332- emit replyRequested (actionKey, " Quick reply from desktop" );
464+ // Show input field for reply
465+ showInput (actionKey);
333466 } else {
467+ // Regular action - emit signal immediately
334468 emit actionClicked (actionKey);
335469 }
336470}
@@ -347,12 +481,32 @@ bool NotificationCard::eventFilter(QObject *obj, QEvent *event)
347481 return QWidget::eventFilter (obj, event);
348482}
349483
484+ void NotificationCard::onSendButtonClicked ()
485+ {
486+ QString replyText = m_replyInput->text ().trimmed ();
487+ if (!replyText.isEmpty () && !m_currentActionKey.isEmpty ()) {
488+ emit replyRequested (m_currentActionKey, replyText);
489+ hideInput ();
490+ }
491+ }
492+
493+ void NotificationCard::onCancelButtonClicked ()
494+ {
495+ hideInput ();
496+ }
497+
498+ void NotificationCard::onInputReturnPressed ()
499+ {
500+ onSendButtonClicked ();
501+ }
502+
350503void NotificationCard::onActionIndicatorClicked ()
351504{
352- if (m_actionsVisible || m_bodiesExpanded) {
353- // Hide expanded content (actions and/or bodies )
505+ if (m_actionsVisible || m_bodiesExpanded || m_inputVisible ) {
506+ // Hide expanded content (actions, bodies, and/or input )
354507 hideActions ();
355508 hideBodies ();
509+ hideInput ();
356510 if (m_actionIndicator) {
357511 m_actionIndicator->setText (" ⌄" ); // Down arrow
358512 }
@@ -365,3 +519,10 @@ void NotificationCard::onActionIndicatorClicked()
365519 }
366520 }
367521}
522+
523+ void NotificationCard::updateCardHeight ()
524+ {
525+ // Let Qt handle the height automatically through layout system
526+ updateGeometry ();
527+ update ();
528+ }
0 commit comments