demos/embedded/anomaly/src/ControlStrip.cpp
changeset 7 f7bc934e204c
parent 0 1918ee327afb
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the demos of the Qt Toolkit.
     7 ** This file is part of the demos of the Qt Toolkit.
     8 **
     8 **
    48     : QWidget(parent)
    48     : QWidget(parent)
    49 {
    49 {
    50     menuPixmap.load(":/images/edit-find.png");
    50     menuPixmap.load(":/images/edit-find.png");
    51     backPixmap.load(":/images/go-previous.png");
    51     backPixmap.load(":/images/go-previous.png");
    52     forwardPixmap.load(":/images/go-next.png");
    52     forwardPixmap.load(":/images/go-next.png");
       
    53     closePixmap.load(":/images/button-close.png");
    53 }
    54 }
    54 
    55 
    55 QSize ControlStrip::sizeHint() const
    56 QSize ControlStrip::sizeHint() const
    56 {
    57 {
    57     return minimumSizeHint();
    58     return minimumSizeHint();
    72         event->accept();
    73         event->accept();
    73         return;
    74         return;
    74     }
    75     }
    75 
    76 
    76     if (x > width() - h) {
    77     if (x > width() - h) {
       
    78         emit closeClicked();
       
    79         event->accept();
       
    80         return;
       
    81     }
       
    82 
       
    83     if ((x < width() - 2 * h) && (x > width() - 3 * h)) {
    77         emit forwardClicked();
    84         emit forwardClicked();
    78         event->accept();
    85         event->accept();
    79         return;
    86         return;
    80     }
    87     }
    81 
    88 
    82     if ((x < width() - 2 * h) && (x > width() - 3 * h)) {
    89     if ((x < width() - 3 * h) && (x > width() - 5 * h)) {
    83         emit backClicked();
    90         emit backClicked();
    84         event->accept();
    91         event->accept();
    85         return;
    92         return;
    86     }
    93     }
    87 }
    94 }
    93 
   100 
    94     QPainter p(this);
   101     QPainter p(this);
    95     p.fillRect(event->rect(), QColor(32, 32, 32, 192));
   102     p.fillRect(event->rect(), QColor(32, 32, 32, 192));
    96     p.setCompositionMode(QPainter::CompositionMode_SourceOver);
   103     p.setCompositionMode(QPainter::CompositionMode_SourceOver);
    97     p.drawPixmap(s, s, menuPixmap);
   104     p.drawPixmap(s, s, menuPixmap);
    98     p.drawPixmap(width() - 3 * h + s, s, backPixmap);
   105     p.drawPixmap(width() - h + s, s, closePixmap);
    99     p.drawPixmap(width() - h + s, s, forwardPixmap);
   106     p.drawPixmap(width() - 3 * h + s, s, forwardPixmap);
       
   107     p.drawPixmap(width() - 5 * h + s, s, backPixmap);
       
   108 
   100     p.end();
   109     p.end();
   101 }
   110 }