void LxQtClock::activated(ActivationReason reason) { if (reason != ILxQtPanelPlugin::Trigger) return; if (!mCalendarDialog) { mCalendarDialog = new QDialog(mContent); //mCalendarDialog->setAttribute(Qt::WA_DeleteOnClose, true); mCalendarDialog->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::X11BypassWindowManagerHint); mCalendarDialog->setLayout(new QHBoxLayout(mCalendarDialog)); mCalendarDialog->layout()->setMargin(1); QCalendarWidget* cal = new QCalendarWidget(mCalendarDialog); cal->setFirstDayOfWeek(mFirstDayOfWeek); mCalendarDialog->layout()->addWidget(cal); mCalendarDialog->adjustSize(); QRect pos = calculatePopupWindowPos(mCalendarDialog->size()); mCalendarDialog->move(pos.topLeft()); mCalendarDialog->show(); } else { delete mCalendarDialog; mCalendarDialog = 0; } }
void MultiDelegate::setupCalenderWidget( QDateTimeEdit* editor) const { editor->setCalendarPopup(true); QCalendarWidget* calendar = editor->calendarWidget(); if (calendar) { calendar->setFirstDayOfWeek(Qt::Monday); calendar->setVerticalHeaderFormat( QCalendarWidget::ISOWeekNumbers); } }
void LXQtWorldClock::activated(ActivationReason reason) { switch (reason) { case ILXQtPanelPlugin::Trigger: case ILXQtPanelPlugin::MiddleClick: break; default: return; } if (!mPopup) { mPopup = new LXQtWorldClockPopup(mContent); connect(mPopup, SIGNAL(deactivated()), SLOT(deletePopup())); if (reason == ILXQtPanelPlugin::Trigger) { mPopup->setObjectName(QLatin1String("WorldClockCalendar")); mPopup->layout()->setContentsMargins(0, 0, 0, 0); QCalendarWidget *calendarWidget = new QCalendarWidget(mPopup); mPopup->layout()->addWidget(calendarWidget); QString timeZoneName = mActiveTimeZone; if (timeZoneName == QLatin1String("local")) timeZoneName = QString::fromLatin1(QTimeZone::systemTimeZoneId()); QTimeZone timeZone(timeZoneName.toLatin1()); calendarWidget->setFirstDayOfWeek(QLocale(QLocale::AnyLanguage, timeZone.country()).firstDayOfWeek()); calendarWidget->setSelectedDate(QDateTime::currentDateTime().toTimeZone(timeZone).date()); } else { mPopup->setObjectName(QLatin1String("WorldClockPopup")); mPopupContent = new QLabel(mPopup); mPopup->layout()->addWidget(mPopupContent); mPopupContent->setAlignment(mContent->alignment()); updatePopupContent(); } mPopup->adjustSize(); mPopup->setGeometry(calculatePopupWindowPos(mPopup->size())); willShowWindow(mPopup); mPopup->show(); } else { deletePopup(); } }
void BlDateSearch::s_searchFecha() { BL_FUNC_DEBUG QDialog *diag = new QDialog ( 0 ); diag->setModal ( true ); QCalendarWidget *calend = new QCalendarWidget ( diag ); /// Se pone el 1er dia del calendario a lunes. calend->setFirstDayOfWeek ( Qt::Monday ); /// Evitar fechas demasiado antiguas calend->setMinimumDate( QDate ( 1900, 1, 1 ) ); /// Si el campo estaba vacío, seleccionar una fecha imposible, pero mostrar el mes actual if ( m_textoFecha->text().isEmpty() ) { calend->setSelectedDate ( calend->minimumDate() ); calend->setCurrentPage ( QDate::currentDate().year(), QDate::currentDate().month() ); } /// Si ya hay una fecha en el campo, abrir el calendario con ese día seleccionado inicialmente else { calend->setSelectedDate ( blNormalizeDate ( m_textoFecha->text() ) ); } connect ( calend, SIGNAL ( activated ( const QDate & ) ), diag, SLOT ( accept() ) ); /// Creamos un layout donde estara el contenido de la ventana y la ajustamos al QDialog /// para que sea redimensionable y aparezca el titulo de la ventana. QHBoxLayout *layout = new QHBoxLayout; layout->addWidget ( calend ); layout->setMargin ( 0 ); layout->setSpacing ( 0 ); diag->setLayout ( layout ); diag->setWindowTitle ( _ ( "Seleccione fecha" ) ); diag->exec(); /// Si la fecha es imposible, significa que el usuario no ha seleccionado una fecha /// y su campo debe quedarse como estaba: vacío if ( calend->selectedDate() != QDate ( 1900, 1, 1 ) ) { m_textoFecha->setText ( calend->selectedDate().toString ( "dd/MM/yyyy" ) ); } /// Liberamos la memoria delete layout; delete calend; delete diag; emit ( valueChanged ( m_textoFecha->text() ) ); emit ( editingFinished () ); }