mainwindow.cpp
changeset 6 ac3b45850c50
parent 2 0c23d71853fe
equal deleted inserted replaced
5:480fe05ec121 6:ac3b45850c50
    36     }
    36     }
    37 }
    37 }
    38 
    38 
    39 QString MainWindow::widgetName()
    39 QString MainWindow::widgetName()
    40 {
    40 {
    41     return ui->widgetName->text().toLower();
    41     return ui->widgetName->text();
    42 }
    42 }
    43 
    43 
    44 QString MainWindow::widgetUid()
    44 QString MainWindow::widgetUid()
    45 {
    45 {
    46     return ui->widgetUid->text().toLower();
    46     return ui->widgetUid->text().toLower();
    56     return ui->rendererName->text();
    56     return ui->rendererName->text();
    57 }
    57 }
    58 
    58 
    59 QString MainWindow::rendererUid()
    59 QString MainWindow::rendererUid()
    60 {
    60 {
    61     return ui->rendererUid->text();
    61     return ui->rendererUid->text().toLower();
    62 }
    62 }
    63 
    63 
    64 void MainWindow::on_pushButton_clicked()
    64 void MainWindow::on_pushButton_clicked()
    65 {
    65 {
    66     if( widgetName().isEmpty() || widgetUid().isEmpty() )
    66     if( widgetName().isEmpty() || widgetUid().isEmpty() )
    83 
    83 
    84     if( uidVal >= 2147483648 ) //0x80000000
    84     if( uidVal >= 2147483648 ) //0x80000000
    85     {
    85     {
    86         QMessageBox msgBox;
    86         QMessageBox msgBox;
    87         msgBox.setText("UID must be less than\n 0x80000000.");
    87         msgBox.setText("UID must be less than\n 0x80000000.");
       
    88         msgBox.exec();
       
    89         return;
       
    90     }
       
    91 
       
    92     if (widgetLayout().length() == 0 && !rendererCheckBox().isChecked())
       
    93     {
       
    94         QMessageBox msgBox;
       
    95         msgBox.setText("Layout data not available yet.");
    88         msgBox.exec();
    96         msgBox.exec();
    89         return;
    97         return;
    90     }
    98     }
    91 
    99 
    92     generateMainBuildFile();
   100     generateMainBuildFile();
   124 }
   132 }
   125 
   133 
   126 void MainWindow::generateMainBuildFile()
   134 void MainWindow::generateMainBuildFile()
   127 {
   135 {
   128     QDir dir;
   136     QDir dir;
   129     dir.mkpath( widgetName() + "/group");
   137     dir.mkpath( widgetName().toLower() + "/group");
   130     dir.setPath( widgetName() + "/group");
   138     dir.setPath( widgetName().toLower() + "/group");
   131     QFile file( dir.filePath("bld.inf"));
   139     QFile file( dir.filePath("bld.inf"));
   132     if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
   140     if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
   133         return;
   141         return;
   134 
   142 
   135     QTextStream out(&file);
   143     QTextStream out(&file);
   198 
   206 
   199     while (!in.atEnd())
   207     while (!in.atEnd())
   200     {
   208     {
   201         QString line = in.readLine();
   209         QString line = in.readLine();
   202         line.replace(QString("#replace#"), widgetName());
   210         line.replace(QString("#replace#"), widgetName());
       
   211 
   203         if( noHexUid )
   212         if( noHexUid )
   204         {
   213         {
   205             line.replace(QString("#replaceuid#"), widgetUidNoHex());
   214             line.replace(QString("#replaceuid#"), widgetUidNoHex());
   206         }
   215         }
   207         else
   216         else
   212     }
   221     }
   213 }
   222 }
   214 
   223 
   215 void MainWindow::on_renderingCheckBox_stateChanged(int state )
   224 void MainWindow::on_renderingCheckBox_stateChanged(int state )
   216 {
   225 {
       
   226     iTimer->stop();
   217     if( state == Qt::Unchecked )
   227     if( state == Qt::Unchecked )
   218     {
   228     {
   219         ui->rendererName->setEnabled( false );
   229         ui->rendererName->setEnabled( false );
   220         ui->rendererUid->setEnabled( false );
   230         ui->rendererUid->setEnabled( false );
       
   231         ui->comboBox->setEnabled( true );
       
   232         updateLayout();
   221     }
   233     }
   222     else if ( state == Qt::Checked)
   234     else if ( state == Qt::Checked)
   223     {
   235     {
   224         ui->rendererName->setEnabled( true );
   236         ui->rendererName->setEnabled( true );
   225         ui->rendererUid->setEnabled( true);
   237         ui->rendererUid->setEnabled( true);
       
   238         ui->comboBox->setEnabled( false );
   226     }
   239     }
   227 
   240 
   228 }
   241 }
   229 
   242 
   230 QString MainWindow::widgetLayout()
   243 QString MainWindow::widgetLayout()
   249     case 3:
   262     case 3:
   250         {
   263         {
   251             return QString( "graphictext" );
   264             return QString( "graphictext" );
   252         }
   265         }
   253         break;
   266         break;
       
   267     case 4:
       
   268         {
       
   269             return QString( "graphiciconstext" );
       
   270         }
       
   271         break;
       
   272 
   254     };
   273     };
       
   274 
       
   275     return QString( "" );
   255 }
   276 }
   256 
   277 
   257 void MainWindow::on_comboBox_currentIndexChanged(int index)
   278 void MainWindow::on_comboBox_currentIndexChanged(int index)
   258 {
   279 {
   259     iLayoutIndex = index;
   280     iLayoutIndex = index;
   260     iLayoutCount = 3;
   281     iLayoutCount = 3;
   261     updateLayout();
   282     updateLayout();
   262 
       
   263 
       
   264 }
   283 }
   265 
   284 
   266 void MainWindow::updateLayout()
   285 void MainWindow::updateLayout()
   267 {
   286 {
   268     switch (iLayoutIndex)
   287     switch (iLayoutIndex)
   285             iTimer->start(2000);
   304             iTimer->start(2000);
   286         }
   305         }
   287         break;
   306         break;
   288     case 3:
   307     case 3:
   289         {
   308         {
   290             showGraphicTextLayout();
   309             showGraphicsTextLayout();
   291             iTimer->start(2000);
   310             iTimer->start(2000);
   292         }
   311         }
   293         break;
   312         break;
       
   313     case 4:
       
   314         {
       
   315             showGraphicsIconTextLayout();
       
   316             iTimer->start(2000);
       
   317         }
       
   318         break;
       
   319     case 5:
       
   320         {
       
   321             iTimer->stop();
       
   322             showGraphicsGridLayout();
       
   323         }
       
   324         break;
       
   325     case 6:
       
   326         {
       
   327             iTimer->stop();
       
   328             showGraphicsGridTextLayout();
       
   329         }
       
   330         break;
       
   331     case 7:
       
   332         {
       
   333             iTimer->stop();
       
   334             showWidgeImageLayout();
       
   335         }
       
   336         break;
       
   337     case 8:
       
   338         {
       
   339             iTimer->stop();
       
   340             showGraphicsCarouselLayout();
       
   341         }
       
   342         break;
   294     };
   343     };
   295 
   344 
   296     if( iLayoutCount > 1)
   345     if( iLayoutCount > 1)
   297     {
   346     {
   298         iLayoutCount--;
   347         iLayoutCount--;
   304 }
   353 }
   305 
   354 
   306 void MainWindow::showFeedsLayout()
   355 void MainWindow::showFeedsLayout()
   307 {
   356 {
   308     ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/feeds_layout.jpg")));
   357     ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/feeds_layout.jpg")));
       
   358 }
       
   359 
       
   360 void MainWindow::showGraphicsGridLayout()
       
   361 {
       
   362     ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/graphicsgrid_layout.jpg")));
       
   363 }
       
   364 
       
   365 void MainWindow::showGraphicsGridTextLayout()
       
   366 {
       
   367     ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/graphicsgridtext_layout.jpg")));
       
   368 }
       
   369 
       
   370 void MainWindow::showWidgeImageLayout()
       
   371 {
       
   372     ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/wideimage_layout.jpg")));
       
   373 }
       
   374 
       
   375 void MainWindow::showGraphicsCarouselLayout()
       
   376 {
       
   377     ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/graphicscarousel_layout.jpg")));
   309 }
   378 }
   310 
   379 
   311 void MainWindow::showTextLayout()
   380 void MainWindow::showTextLayout()
   312 {
   381 {
   313     QString imagePath(":/widgets/images/text_layout_");
   382     QString imagePath(":/widgets/images/text_layout_");
   326     imagePath.append( cnt );
   395     imagePath.append( cnt );
   327     imagePath.append( ".jpg" );
   396     imagePath.append( ".jpg" );
   328     ui->layoutGraphics->setPixmap(QPixmap(imagePath));
   397     ui->layoutGraphics->setPixmap(QPixmap(imagePath));
   329 }
   398 }
   330 
   399 
   331 void MainWindow::showGraphicTextLayout()
   400 void MainWindow::showGraphicsTextLayout()
   332 {
   401 {
   333     QString imagePath(":/widgets/images/graphictext_layout_");
   402     QString imagePath(":/widgets/images/graphicstext_layout_");
   334     QString cnt;
   403     QString cnt;
   335     cnt.setNum( iLayoutCount );
   404     cnt.setNum( iLayoutCount );
   336     imagePath.append( cnt );
   405     imagePath.append( cnt );
   337     imagePath.append( ".jpg" );
   406     imagePath.append( ".jpg" );
   338     ui->layoutGraphics->setPixmap(QPixmap(imagePath));
   407     ui->layoutGraphics->setPixmap(QPixmap(imagePath));
   339 }
   408 }
       
   409 
       
   410 void MainWindow::showGraphicsIconTextLayout()
       
   411 {
       
   412     QString imagePath(":/widgets/images/graphicsiconstext_layout_");
       
   413     QString cnt;
       
   414     cnt.setNum( iLayoutCount );
       
   415     imagePath.append( cnt );
       
   416     imagePath.append( ".jpg" );
       
   417     ui->layoutGraphics->setPixmap(QPixmap(imagePath));
       
   418 }
       
   419