mainwindow.cpp
author jake
Wed, 27 Oct 2010 12:06:29 +0300
changeset 9 6967ff0a31f5
parent 6 ac3b45850c50
permissions -rw-r--r--
renderer updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
     1
#include "mainwindow.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     2
#include "ui_mainwindow.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     3
b856a9924bbc initial contribution
jake
parents:
diff changeset
     4
#include "widgetcreator.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     5
#include "renderercreator.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     6
#include "publishercreator.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     7
b856a9924bbc initial contribution
jake
parents:
diff changeset
     8
#include <QMessageBox>
b856a9924bbc initial contribution
jake
parents:
diff changeset
     9
#include <QDir>
b856a9924bbc initial contribution
jake
parents:
diff changeset
    10
#include <QTextStream>
b856a9924bbc initial contribution
jake
parents:
diff changeset
    11
#include <QTimer>
b856a9924bbc initial contribution
jake
parents:
diff changeset
    12
b856a9924bbc initial contribution
jake
parents:
diff changeset
    13
b856a9924bbc initial contribution
jake
parents:
diff changeset
    14
MainWindow::MainWindow(QWidget *parent) :
b856a9924bbc initial contribution
jake
parents:
diff changeset
    15
    QMainWindow(parent), ui(new Ui::MainWindow), iLayoutIndex( 0 ), iLayoutCount( -1 )
b856a9924bbc initial contribution
jake
parents:
diff changeset
    16
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    17
    ui->setupUi(this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    18
    iTimer = new QTimer(this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    19
    connect(iTimer, SIGNAL(timeout()), this, SLOT(updateLayout()));
b856a9924bbc initial contribution
jake
parents:
diff changeset
    20
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    21
b856a9924bbc initial contribution
jake
parents:
diff changeset
    22
MainWindow::~MainWindow()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    23
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    24
    delete ui;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    25
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    26
b856a9924bbc initial contribution
jake
parents:
diff changeset
    27
void MainWindow::changeEvent(QEvent *e)
b856a9924bbc initial contribution
jake
parents:
diff changeset
    28
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    29
    QMainWindow::changeEvent(e);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    30
    switch (e->type()) {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    31
    case QEvent::LanguageChange:
b856a9924bbc initial contribution
jake
parents:
diff changeset
    32
        ui->retranslateUi(this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    33
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    34
    default:
b856a9924bbc initial contribution
jake
parents:
diff changeset
    35
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    36
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    37
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    38
b856a9924bbc initial contribution
jake
parents:
diff changeset
    39
QString MainWindow::widgetName()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    40
{
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    41
    return ui->widgetName->text();
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
    42
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    43
b856a9924bbc initial contribution
jake
parents:
diff changeset
    44
QString MainWindow::widgetUid()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    45
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    46
    return ui->widgetUid->text().toLower();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    47
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    48
b856a9924bbc initial contribution
jake
parents:
diff changeset
    49
QCheckBox& MainWindow::rendererCheckBox()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    50
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    51
    return *ui->renderingCheckBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    52
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    53
b856a9924bbc initial contribution
jake
parents:
diff changeset
    54
QString MainWindow::rendererName()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    55
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    56
    return ui->rendererName->text();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    57
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    58
b856a9924bbc initial contribution
jake
parents:
diff changeset
    59
QString MainWindow::rendererUid()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    60
{
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    61
    return ui->rendererUid->text().toLower();
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
    62
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    63
b856a9924bbc initial contribution
jake
parents:
diff changeset
    64
void MainWindow::on_pushButton_clicked()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    65
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    66
    if( widgetName().isEmpty() || widgetUid().isEmpty() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
    67
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    68
        QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    69
        msgBox.setText("Widget name and UID must be given.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
    70
        msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    71
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    72
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    73
b856a9924bbc initial contribution
jake
parents:
diff changeset
    74
    bool ok;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    75
    uint uidVal = widgetUid().toUInt(&ok, 16 );
b856a9924bbc initial contribution
jake
parents:
diff changeset
    76
    if( widgetUid().length() != 10 || !widgetUid().startsWith( "0x",Qt::CaseInsensitive ) || !ok )
b856a9924bbc initial contribution
jake
parents:
diff changeset
    77
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    78
        QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    79
        msgBox.setText("UID must be in 4 byte hexadecimal format\n 0x11223344.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
    80
        msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    81
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    82
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    83
b856a9924bbc initial contribution
jake
parents:
diff changeset
    84
    if( uidVal >= 2147483648 ) //0x80000000
b856a9924bbc initial contribution
jake
parents:
diff changeset
    85
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    86
        QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    87
        msgBox.setText("UID must be less than\n 0x80000000.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
    88
        msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    89
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    90
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    91
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    92
    if (widgetLayout().length() == 0 && !rendererCheckBox().isChecked())
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    93
    {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    94
        QMessageBox msgBox;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    95
        msgBox.setText("Layout data not available yet.");
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    96
        msgBox.exec();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    97
        return;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    98
    }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
    99
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   100
    generateMainBuildFile();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   101
b856a9924bbc initial contribution
jake
parents:
diff changeset
   102
    PublisherCreator* publisherCreator = new PublisherCreator(*this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   103
    delete publisherCreator;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   104
    
b856a9924bbc initial contribution
jake
parents:
diff changeset
   105
    WidgetCreator* widgetCreator = new WidgetCreator(*this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   106
    delete widgetCreator;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   107
    
b856a9924bbc initial contribution
jake
parents:
diff changeset
   108
    if( ui->renderingCheckBox->isChecked() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   109
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   110
        if( rendererName().isEmpty() || rendererUid().isEmpty() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   111
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   112
            QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   113
            msgBox.setText("Renderer name and UID must be given.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   114
            msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   115
            return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   116
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   117
        if( rendererUid().length() != 10 || !rendererUid().startsWith( "0x",Qt::CaseInsensitive ))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   118
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   119
            QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   120
            msgBox.setText("UID must be in hexadecimal format\n 0x11223344.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   121
            msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   122
            return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   123
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   124
        RendererCreator * renderer = new RendererCreator(*this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   125
        delete renderer;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   126
    }
2
0c23d71853fe added copying of two png images into publishercreator.cpp
jake
parents: 0
diff changeset
   127
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   128
    QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   129
    msgBox.setText("Widget created.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   130
    msgBox.exec();
2
0c23d71853fe added copying of two png images into publishercreator.cpp
jake
parents: 0
diff changeset
   131
    return;
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   132
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   133
b856a9924bbc initial contribution
jake
parents:
diff changeset
   134
void MainWindow::generateMainBuildFile()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   135
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   136
    QDir dir;
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   137
    dir.mkpath( widgetName().toLower() + "/group");
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   138
    dir.setPath( widgetName().toLower() + "/group");
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   139
    QFile file( dir.filePath("bld.inf"));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   140
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   141
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   142
b856a9924bbc initial contribution
jake
parents:
diff changeset
   143
    QTextStream out(&file);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   144
    generateLicense( out );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   145
    
b856a9924bbc initial contribution
jake
parents:
diff changeset
   146
    //out << "#include \"../publisherif/group/bld.inf\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   147
    out << "#include \"../testpublisher/group/bld.inf\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   148
    out << "#include \"../widget/group/bld.inf\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   149
    if( ui->renderingCheckBox->isChecked() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   150
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   151
        out << "#include \"../renderingplugin/group/bld.inf\"\n\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   152
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   153
    out << "// End of File\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   154
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   155
b856a9924bbc initial contribution
jake
parents:
diff changeset
   156
void MainWindow::generateLicense( QTextStream& aStream )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   157
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   158
    aStream << "/*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   159
    aStream << "* Copyright (c) {Year(s)} {Copyright owner}.\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   160
    aStream << "* All rights reserved.\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   161
    aStream << "* This component and the accompanying materials are made available\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   162
    aStream << "* under the terms of the \"Eclipse Public License v1.0\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   163
    aStream << "* which accompanies this distribution, and is available\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   164
    aStream << "* at the URL \"http://www.symbianfoundation.org/legal/sfl-v10.html\".\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   165
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   166
    aStream << "* Initial Contributors:\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   167
    aStream << "* {Name} {Company} – Initial contribution\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   168
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   169
    aStream << "* Contributors:\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   170
    aStream << "* {Name} {Company} – {{Description of contribution}}\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   171
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   172
    aStream << "* Description:\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   173
    aStream << "* {{Description of the file}}\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   174
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   175
    aStream << "*/\n\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   176
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   177
b856a9924bbc initial contribution
jake
parents:
diff changeset
   178
QString MainWindow::widgetUidNoHex()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   179
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   180
    QString uid( widgetUid() );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   181
    if( uid.startsWith( "0x",Qt::CaseInsensitive ))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   182
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   183
        return uid.right(8);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   184
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   185
    else
b856a9924bbc initial contribution
jake
parents:
diff changeset
   186
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   187
        return uid;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   188
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   189
b856a9924bbc initial contribution
jake
parents:
diff changeset
   190
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   191
b856a9924bbc initial contribution
jake
parents:
diff changeset
   192
void MainWindow::replaceData( QString sourceFile, QString destFile, bool noHexUid )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   193
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   194
    QString path = QDir::currentPath();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   195
    QFile infile(sourceFile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   196
    if (!infile.open(QIODevice::ReadWrite | QIODevice::Text))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   197
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   198
b856a9924bbc initial contribution
jake
parents:
diff changeset
   199
    QTextStream in(&infile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   200
b856a9924bbc initial contribution
jake
parents:
diff changeset
   201
    QFile outfile(destFile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   202
    if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   203
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   204
b856a9924bbc initial contribution
jake
parents:
diff changeset
   205
    QTextStream out(&outfile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   206
b856a9924bbc initial contribution
jake
parents:
diff changeset
   207
    while (!in.atEnd())
b856a9924bbc initial contribution
jake
parents:
diff changeset
   208
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   209
        QString line = in.readLine();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   210
        line.replace(QString("#replace#"), widgetName());
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   211
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   212
        if( noHexUid )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   213
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   214
            line.replace(QString("#replaceuid#"), widgetUidNoHex());
b856a9924bbc initial contribution
jake
parents:
diff changeset
   215
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   216
        else
b856a9924bbc initial contribution
jake
parents:
diff changeset
   217
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   218
            line.replace(QString("#replaceuid#"), widgetUid());
b856a9924bbc initial contribution
jake
parents:
diff changeset
   219
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   220
        out << line << "\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   221
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   222
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   223
b856a9924bbc initial contribution
jake
parents:
diff changeset
   224
void MainWindow::on_renderingCheckBox_stateChanged(int state )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   225
{
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   226
    iTimer->stop();
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   227
    if( state == Qt::Unchecked )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   228
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   229
        ui->rendererName->setEnabled( false );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   230
        ui->rendererUid->setEnabled( false );
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   231
        ui->comboBox->setEnabled( true );
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   232
        updateLayout();
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   233
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   234
    else if ( state == Qt::Checked)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   235
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   236
        ui->rendererName->setEnabled( true );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   237
        ui->rendererUid->setEnabled( true);
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   238
        ui->comboBox->setEnabled( false );
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   239
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   240
b856a9924bbc initial contribution
jake
parents:
diff changeset
   241
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   242
b856a9924bbc initial contribution
jake
parents:
diff changeset
   243
QString MainWindow::widgetLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   244
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   245
    switch (iLayoutIndex)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   246
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   247
    case 0:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   248
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   249
            return QString( "feed" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   250
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   251
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   252
    case 1:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   253
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   254
            return QString( "text" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   255
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   256
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   257
    case 2:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   258
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   259
            return QString( "iconstext" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   260
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   261
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   262
    case 3:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   263
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   264
            return QString( "graphictext" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   265
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   266
        break;
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   267
    case 4:
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   268
        {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   269
            return QString( "graphiciconstext" );
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   270
        }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   271
        break;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   272
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   273
    };
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   274
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   275
    return QString( "" );
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   276
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   277
b856a9924bbc initial contribution
jake
parents:
diff changeset
   278
void MainWindow::on_comboBox_currentIndexChanged(int index)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   279
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   280
    iLayoutIndex = index;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   281
    iLayoutCount = 3;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   282
    updateLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   283
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   284
b856a9924bbc initial contribution
jake
parents:
diff changeset
   285
void MainWindow::updateLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   286
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   287
    switch (iLayoutIndex)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   288
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   289
    case 0:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   290
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   291
            iTimer->stop();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   292
            showFeedsLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   293
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   294
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   295
    case 1:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   296
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   297
            showTextLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   298
            iTimer->start(2000);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   299
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   300
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   301
    case 2:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   302
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   303
            showIconsTextLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   304
            iTimer->start(2000);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   305
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   306
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   307
    case 3:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   308
        {
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   309
            showGraphicsTextLayout();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   310
            iTimer->start(2000);
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   311
        }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   312
        break;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   313
    case 4:
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   314
        {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   315
            showGraphicsIconTextLayout();
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   316
            iTimer->start(2000);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   317
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   318
        break;
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   319
    case 5:
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   320
        {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   321
            iTimer->stop();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   322
            showGraphicsGridLayout();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   323
        }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   324
        break;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   325
    case 6:
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   326
        {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   327
            iTimer->stop();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   328
            showGraphicsGridTextLayout();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   329
        }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   330
        break;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   331
    case 7:
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   332
        {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   333
            iTimer->stop();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   334
            showWidgeImageLayout();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   335
        }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   336
        break;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   337
    case 8:
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   338
        {
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   339
            iTimer->stop();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   340
            showGraphicsCarouselLayout();
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   341
        }
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   342
        break;
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   343
    };
b856a9924bbc initial contribution
jake
parents:
diff changeset
   344
b856a9924bbc initial contribution
jake
parents:
diff changeset
   345
    if( iLayoutCount > 1)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   346
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   347
        iLayoutCount--;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   348
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   349
    else
b856a9924bbc initial contribution
jake
parents:
diff changeset
   350
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   351
        iLayoutCount = 3;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   352
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   353
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   354
b856a9924bbc initial contribution
jake
parents:
diff changeset
   355
void MainWindow::showFeedsLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   356
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   357
    ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/feeds_layout.jpg")));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   358
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   359
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   360
void MainWindow::showGraphicsGridLayout()
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   361
{
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   362
    ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/graphicsgrid_layout.jpg")));
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   363
}
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   364
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   365
void MainWindow::showGraphicsGridTextLayout()
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   366
{
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   367
    ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/graphicsgridtext_layout.jpg")));
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   368
}
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   369
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   370
void MainWindow::showWidgeImageLayout()
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   371
{
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   372
    ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/wideimage_layout.jpg")));
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   373
}
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   374
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   375
void MainWindow::showGraphicsCarouselLayout()
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   376
{
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   377
    ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/graphicscarousel_layout.jpg")));
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   378
}
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   379
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   380
void MainWindow::showTextLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   381
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   382
    QString imagePath(":/widgets/images/text_layout_");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   383
    QString cnt;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   384
    cnt.setNum( iLayoutCount );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   385
    imagePath.append( cnt );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   386
    imagePath.append( ".jpg" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   387
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   388
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   389
b856a9924bbc initial contribution
jake
parents:
diff changeset
   390
void MainWindow::showIconsTextLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   391
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   392
    QString imagePath(":/widgets/images/iconstext_layout_");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   393
    QString cnt;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   394
    cnt.setNum( iLayoutCount );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   395
    imagePath.append( cnt );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   396
    imagePath.append( ".jpg" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   397
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   398
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   399
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   400
void MainWindow::showGraphicsTextLayout()
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   401
{
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   402
    QString imagePath(":/widgets/images/graphicstext_layout_");
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
   403
    QString cnt;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   404
    cnt.setNum( iLayoutCount );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   405
    imagePath.append( cnt );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   406
    imagePath.append( ".jpg" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   407
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   408
}
6
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   409
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   410
void MainWindow::showGraphicsIconTextLayout()
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   411
{
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   412
    QString imagePath(":/widgets/images/graphicsiconstext_layout_");
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   413
    QString cnt;
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   414
    cnt.setNum( iLayoutCount );
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   415
    imagePath.append( cnt );
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   416
    imagePath.append( ".jpg" );
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   417
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   418
}
ac3b45850c50 New release 0.1.c
jake
parents: 2
diff changeset
   419