tSiriusRadioNotFoundDialog::tSiriusRadioNotFoundDialog( QWidget* pParent ) : tDialog( tDialog::Partial, pParent, DarkenOn ) { setWindowTitle( tr( "Error", "[title]" ) ); m_pText = new tTextEdit( this ); m_pText->setReadOnly( true ); m_pText->setFocusPolicy( Qt::NoFocus ); m_pText->setTextInteractionFlags( Qt::NoTextInteraction ); QFont f; f.setPixelSize(12); m_pText->setFont(f); m_pText->setText( tr( "The Sirius radio was not found.\n\nMost functions are inoperable until the radio is properly connected.\n\nPlease check the ethernet connection(s) and power to the Sirius module.\n") ); QFontMetrics fm( m_pText->currentFont() ); // find a suitable ratio for text QSize maxSize = tProductSettings::Instance().ScreenResolution() - QSize(80,160); // max size before scrolling // calc rect with min starting rect QRect brect = fm.boundingRect ( 0, 0, 260, 200, Qt::TextWordWrap, m_pText->toPlainText() ); // if height exceeds max, recalc rect with max starting rect if ( brect.height() > maxSize.height() ) { brect = fm.boundingRect ( 0, 0, maxSize.width(), maxSize.height(), Qt::TextWordWrap, m_pText->toPlainText() ); } // add margins for target - needs this for some reason. m_pText->setMinimumWidth( qMin( (brect.width() + 20), maxSize.width() ) ); m_pText->setMinimumHeight( qMin( (brect.height() + 20), maxSize.height() ) ); QGridLayout* pGridLayout = new QGridLayout( ); pGridLayout->addWidget( m_pText, 0, 0 ); setLayout( pGridLayout ); //I believe that the layout will delete this for us. // softkeys always have focus for all models CreateSoftKeys(); }
//want this mostly full screen, not a little wimpy panel, we have a lot of text to put in here! tWeatherTextViewerDialog::tWeatherTextViewerDialog( QString optionalLabel, tSiriusXmWeatherManager& siriusXmWeatherManager, QWidget* pParent ) : tDialog( tDialog::Full/*Partial*/, pParent ) , m_WeatherLayer( siriusXmWeatherManager ) { m_pLayout = new QVBoxLayout(); if( optionalLabel.isEmpty() == false ) { setWindowTitle( optionalLabel ); } m_pScrollableText = new tTextEdit(tr("Gathering information...", "Sirius informative message when gathering marine zone text")); m_pScrollableText->setReadOnly( true ); //don't ever let the user edit this!!! m_pScrollableText->setFocusPolicy( Qt::StrongFocus ); m_pScrollableText->setTextInteractionFlags( Qt::NoTextInteraction ); m_pLayout->addWidget( m_pScrollableText ); setLayout( m_pLayout ); m_pScrollableText->setFocus(); CreateSoftKeys(); }
tSunMoonDialog::tSunMoonDialog( tMCoord Position, QDateTime Date, QWidget* pParent ) : tDialog( tDialog::Full, pParent ), m_Date( Date ), m_Position( Position ) { //JR 2/17/10, NSW-4850, append the GMT offset to the title QString titleAppend; tDSTCalculator dstCalc(tPath::GMTDataDir(), m_Position.X(), m_Position.Y(), false); tDSTResults results; if(dstCalc.CalculateDST(QDateTime(), results, false, true, false, true)) { int minutes_offset = tSystemSettings::Instance()->LocalTimeOffset(); bool negative_offset = minutes_offset < 0; minutes_offset = negative_offset ? -minutes_offset : minutes_offset; int hours_offset = minutes_offset / 60; minutes_offset -= hours_offset * 60; titleAppend = " (GMT %1%2:%3)"; titleAppend = titleAppend.arg(negative_offset?QString("-"):QString("")).arg(hours_offset, 1, 10, QChar('0')).arg(minutes_offset, 2, 10, QChar('0')); } else { titleAppend = " (LST)"; } setWindowTitle( tr( "Sun and Moon", "[title]" ) + titleAppend); m_pMoonRiseTime = new QLabel( this ); m_pMoonSetTime = new QLabel( this ); m_pMoonPhase = new QLabel( this ); m_pSunRiseTime = new QLabel( this ); m_pSunSetTime = new QLabel( this ); RunCalculations(); // grab the sun and moon images QPixmap moonPixmap( tPath::ResourceFile("moon.PNG") ); QPixmap sunPixmap( tPath::ResourceFile("sun.PNG") ); if( tProductSettings::Instance().ScreenPixelWidth() <= 640 ) { moonPixmap = moonPixmap.scaledToWidth( moonPixmap.width() * 3 / 4, Qt::SmoothTransformation ); sunPixmap = sunPixmap.scaledToWidth( sunPixmap.width() * 3 / 4, Qt::SmoothTransformation ); } ProcessMoonPixmap( moonPixmap ); // make the moon info QLabel* pMoonRiseTitle = new QLabel( tr( "Rise", "Moon Rise" ), this ); QLabel* pMoonSetTitle = new QLabel( tr( "Set", "Moon Set" ), this ); QLabel* pMoonPhaseTitle = new QLabel( tr( "Phase", "Moon Phase" ), this ); QFrame* pMoonFrame = new QFrame( this ); m_pMoonImage = new QLabel( this ); m_pMoonImage->setPixmap( moonPixmap ); pMoonFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); pMoonFrame->setLineWidth( 1 ); // lay out the moon items QGridLayout* moonDataLayout = new QGridLayout(); moonDataLayout->setContentsMargins( 0, 0, 0, 0 ); moonDataLayout->setHorizontalSpacing( 10 ); moonDataLayout->setVerticalSpacing( 0 ); moonDataLayout->setColumnStretch( 0, 1 ); moonDataLayout->setRowMinimumHeight( 0, moonPixmap.height() / 2 ); moonDataLayout->setRowStretch( 1, 1 ); moonDataLayout->addWidget( pMoonRiseTitle, 2, 1 ); moonDataLayout->addWidget( m_pMoonRiseTime, 2, 2 ); moonDataLayout->addWidget( pMoonSetTitle, 3, 1 ); moonDataLayout->addWidget( m_pMoonSetTime, 3, 2 ); moonDataLayout->addWidget( pMoonPhaseTitle, 4, 1 ); moonDataLayout->addWidget( m_pMoonPhase, 4, 2 ); moonDataLayout->setRowStretch( 5, 1 ); moonDataLayout->setColumnStretch( 3, 1 ); pMoonFrame->setLayout( moonDataLayout ); QGridLayout* moonLayout = new QGridLayout(); moonLayout->setContentsMargins( 0, 0, 0, 0 ); moonLayout->addWidget( m_pMoonImage, 0, 0, 2, 1, Qt::AlignCenter ); moonLayout->addWidget( pMoonFrame, 1, 0, 2, 1 ); moonLayout->setRowMinimumHeight( 0, moonPixmap.height() / 2 ); // make the sun info QLabel* pSunRiseTitle = new QLabel( tr( "Rise", "Sun Rise" ), this ); QLabel* pSunSetTitle = new QLabel( tr( "Set", "Sun Set" ), this ); QLabel* pSunImage = new QLabel( this ); pSunImage->setPixmap( sunPixmap ); QFrame* pSunFrame = new QFrame( this ); pSunFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); pSunFrame->setLineWidth( 1 ); // lay out the sun items QGridLayout* sunDataLayout = new QGridLayout(); sunDataLayout->setContentsMargins( 0, 0, 0, 0 ); sunDataLayout->setHorizontalSpacing( 10 ); sunDataLayout->setVerticalSpacing( 0 ); sunDataLayout->setColumnStretch( 0, 1 ); sunDataLayout->setRowMinimumHeight( 0, sunPixmap.height() / 2 ); sunDataLayout->setRowStretch( 1, 1 ); sunDataLayout->addWidget( pSunRiseTitle, 2, 1 ); sunDataLayout->addWidget( m_pSunRiseTime, 2, 2 ); sunDataLayout->addWidget( pSunSetTitle, 3, 1 ); sunDataLayout->addWidget( m_pSunSetTime, 3, 2 ); sunDataLayout->setRowStretch( 4, 1 ); sunDataLayout->setColumnStretch( 3, 1 ); pSunFrame->setLayout( sunDataLayout ); QGridLayout* sunLayout = new QGridLayout(); sunLayout->setContentsMargins( 0, 0, 0, 0 ); sunLayout->addWidget( pSunImage, 0, 0, 2, 1, Qt::AlignCenter ); sunLayout->addWidget( pSunFrame, 1, 0, 2, 1 ); sunLayout->setRowMinimumHeight( 0, sunPixmap.height() / 2 ); // make the input boxes QLabel* pDateTitle = new QLabel( tr( "Date" ), this ); QLabel* pPositionTitle = new QLabel( tr( "Position" ), this ); m_pPositionEdit = new tPositionEdit( m_Position, this ); m_pPositionEdit->SetTitle( QString( tr("Position for Sun and Moon") ) ); m_pPositionEdit->setDisabled( false ); m_pDateLineEdit = new tDateLineEdit( m_Date.date(), tSystemSettings::Instance()->DateFormatString(), this ); m_pDateLineEdit->SetTitle( tr("Date for Sun and Moon") ); // lay out the input boxes QHBoxLayout* inputLayout = new QHBoxLayout(); inputLayout->setContentsMargins( 0, 0, 0, 0 ); inputLayout->addWidget( pDateTitle ); inputLayout->addWidget( m_pDateLineEdit ); inputLayout->addStretch(); inputLayout->addWidget( pPositionTitle ); inputLayout->addWidget( m_pPositionEdit ); // lay out all the items QGridLayout* pGridLayout = new QGridLayout( this ); QWidget* inputWidget = new QWidget(); inputWidget->setLayout( inputLayout ); pGridLayout->addWidget( inputWidget, 0, 0, 1, 2 ); QWidget* sunWidget = new QWidget(); sunWidget->setLayout( sunLayout ); sunWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); pGridLayout->addWidget( sunWidget, 1, 0 ); QWidget* moonWidget = new QWidget(); moonWidget->setLayout( moonLayout ); moonWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); pGridLayout->addWidget( moonWidget, 1, 1 ); pGridLayout->setAlignment( Qt::AlignCenter ); setLayout( pGridLayout ); // ensure the images appear on top m_pMoonImage->raise(); pSunImage->raise(); CreateSoftKeys(); Connect( m_pPositionEdit, SIGNAL( ValueChanged() ), this, SLOT( NewInputs() ) ); Connect( m_pDateLineEdit, SIGNAL( ValueChanged() ), this, SLOT( NewInputs() ) ); }
void TextEditor::CreateWindow ( QWidget* parent ) { setMainWidgetTitle ( APP_NAME ); ZWidget *myWidget = new ZWidget ( this, NULL, 0); QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 ); myWidget->setFixedWidth(880); //---------------------------------------------------------------------- pAIA = new ZAppInfoArea(myWidget, NULL, 0); pAIA ->setInputArea(); pAIA->setActArea(ZAppInfoArea::no_progress_meter); setAppInfoArea(pAIA); myVBoxLayout->addWidget ( pAIA, 0 ); //---------------------------------------------------------------------- m_pScrollPanel = new ZScrollPanel ( myWidget, NULL, 0, ZSkinService::clsZScrollPanel); m_pScrollPanel->setFixedWidth(880); // m_pScrollPanel->setFixedHeight(DISPLAY_HEIGHT - 35 ); m_pTextEdit = new ZMultiLineEditEx ( m_pScrollPanel->viewport(), false, 1, "ZMultiLineEdit" ); //m_pTextEdit->setCellHeight( DEFAULT_EDIT_CELL_HEIGHT.toInt() ); m_pTextEdit->setFontPercent( FUENTE.toFloat() ); //QFont f; f.setPixelSize(DEFAULT_EDIT_FONT_SIZE); //m_pTextEdit->setFont(f); m_pScrollPanel->addChild(m_pTextEdit, 0, 0); //our textedit handle center button QObject::connect( m_pTextEdit, SIGNAL( clicked() ), SLOT( slot_MarkBegin() ) ); m_pSoftKey = new ZSoftKey ( "CST_2" , this , this ); CreateMenu ( this ); CreateSoftKeys(this); setContentWidget ( myWidget ); QFile file; if ( qApp->argc() > 1 && file.exists ( qApp->argv() [1] ) ) { m_sFileName = QString(qApp->argv()[1]).utf8(); m_sFilePath = getFilePath(m_sFileName); load( m_sFileName ); } else { if ( qApp->argc() > 1 && file.exists ( qApp->argv() [2] ) ) { m_sFileName = QString(qApp->argv()[2]).utf8(); m_sFilePath = getFilePath(m_sFileName); load( m_sFileName ); } else { slot_newFile(); } } setSoftKey ( m_pSoftKey ); int y = 0; y = y + this->headerSize().height(); y = y + m_pSoftKey->height(); y = y + pAIA->height(); m_pScrollPanel->setFixedHeight(320-y); m_pTextEdit->setFixedHeight(320-y); }