#include <iconpreviewarea.h>
Inheritance diagram for IconPreviewArea:
Definition at line 32 of file iconpreviewarea.h.
Public Member Functions | |
| IconPreviewArea (QWidget *parent=0) | |
| void | setIcon (const QIcon &icon) |
| void | setSize (const QSize &size) |
Private Types | |
| enum | |
Private Member Functions | |
| QLabel * | createHeaderLabel (const QString &text) |
| QLabel * | createPixmapLabel () |
| void | updatePixmapLabels () |
Private Attributes | |
| QIcon | icon |
| QSize | size |
| QLabel * | stateLabels [NumStates] |
| QLabel * | modeLabels [NumModes] |
| QLabel * | pixmapLabels [NumModes][NumStates] |
anonymous enum [private] |
| IconPreviewArea::IconPreviewArea | ( | QWidget * | parent = 0 |
) |
Definition at line 28 of file iconpreviewarea.cpp.
References QGridLayout::addWidget(), createHeaderLabel(), createPixmapLabel(), i, j, modeLabels, NumModes, NumStates, pixmapLabels, QWidget::setLayout(), and stateLabels.
00029 : QWidget(parent) 00030 { 00031 QGridLayout *mainLayout = new QGridLayout; 00032 setLayout(mainLayout); 00033 00034 stateLabels[0] = createHeaderLabel(tr("Off")); 00035 stateLabels[1] = createHeaderLabel(tr("On")); 00036 Q_ASSERT(NumStates == 2); 00037 00038 modeLabels[0] = createHeaderLabel(tr("Normal")); 00039 modeLabels[1] = createHeaderLabel(tr("Active")); 00040 modeLabels[2] = createHeaderLabel(tr("Disabled")); 00041 modeLabels[3] = createHeaderLabel(tr("Selected")); 00042 Q_ASSERT(NumModes == 4); 00043 00044 for (int j = 0; j < NumStates; ++j) 00045 mainLayout->addWidget(stateLabels[j], j + 1, 0); 00046 00047 for (int i = 0; i < NumModes; ++i) { 00048 mainLayout->addWidget(modeLabels[i], 0, i + 1); 00049 00050 for (int j = 0; j < NumStates; ++j) { 00051 pixmapLabels[i][j] = createPixmapLabel(); 00052 mainLayout->addWidget(pixmapLabels[i][j], j + 1, i + 1); 00053 } 00054 } 00055 }
Here is the call graph for this function:
| void IconPreviewArea::setIcon | ( | const QIcon & | icon | ) |
Definition at line 57 of file iconpreviewarea.cpp.
References icon, and updatePixmapLabels().
Referenced by MainWindow::changeIcon().
00058 { 00059 this->icon = icon; 00060 updatePixmapLabels(); 00061 }
Here is the call graph for this function:
| void IconPreviewArea::setSize | ( | const QSize & | size | ) |
Definition at line 63 of file iconpreviewarea.cpp.
References QWidget::size(), and updatePixmapLabels().
Referenced by MainWindow::changeSize().
00064 { 00065 if (size != this->size) { 00066 this->size = size; 00067 updatePixmapLabels(); 00068 } 00069 }
Here is the call graph for this function:
Definition at line 71 of file iconpreviewarea.cpp.
References Qt::AlignCenter, and QLabel::setAlignment().
Referenced by IconPreviewArea().
00072 { 00073 QLabel *label = new QLabel(tr("<b>%1</b>").arg(text)); 00074 label->setAlignment(Qt::AlignCenter); 00075 return label; 00076 }
Here is the call graph for this function:
| QLabel * IconPreviewArea::createPixmapLabel | ( | ) | [private] |
Definition at line 78 of file iconpreviewarea.cpp.
References Qt::AlignCenter, QPalette::Base, QFrame::Box, QSizePolicy::Expanding, QLabel::setAlignment(), QWidget::setBackgroundRole(), QWidget::setEnabled(), QFrame::setFrameShape(), QWidget::setMinimumSize(), and QWidget::setSizePolicy().
Referenced by IconPreviewArea().
00079 { 00080 QLabel *label = new QLabel; 00081 label->setEnabled(false); 00082 label->setAlignment(Qt::AlignCenter); 00083 label->setFrameShape(QFrame::Box); 00084 label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 00085 label->setBackgroundRole(QPalette::Base); 00086 label->setMinimumSize(132, 132); 00087 return label; 00088 }
Here is the call graph for this function:
| void IconPreviewArea::updatePixmapLabels | ( | ) | [private] |
Definition at line 90 of file iconpreviewarea.cpp.
References QIcon::Active, QIcon::Disabled, i, icon, QPixmap::isNull(), j, QIcon::Normal, NumModes, NumStates, QIcon::Off, QIcon::On, QIcon::pixmap(), pixmapLabels, QIcon::Selected, QWidget::setEnabled(), QLabel::setPixmap(), and QWidget::size().
Referenced by setIcon(), and setSize().
00091 { 00092 for (int i = 0; i < NumModes; ++i) { 00093 QIcon::Mode mode; 00094 if (i == 0) { 00095 mode = QIcon::Normal; 00096 } else if (i == 1) { 00097 mode = QIcon::Active; 00098 } else if (i == 2) { 00099 mode = QIcon::Disabled; 00100 } else { 00101 mode = QIcon::Selected; 00102 } 00103 00104 for (int j = 0; j < NumStates; ++j) { 00105 QIcon::State state = (j == 0) ? QIcon::Off : QIcon::On; 00106 QPixmap pixmap = icon.pixmap(size, mode, state); 00107 pixmapLabels[i][j]->setPixmap(pixmap); 00108 pixmapLabels[i][j]->setEnabled(!pixmap.isNull()); 00109 } 00110 } 00111 }
Here is the call graph for this function:
QIcon IconPreviewArea::icon [private] |
QSize IconPreviewArea::size [private] |
Definition at line 50 of file iconpreviewarea.h.
QLabel* IconPreviewArea::stateLabels[NumStates] [private] |
QLabel* IconPreviewArea::modeLabels[NumModes] [private] |
QLabel* IconPreviewArea::pixmapLabels[NumModes][NumStates] [private] |
Definition at line 53 of file iconpreviewarea.h.
Referenced by IconPreviewArea(), and updatePixmapLabels().
1.5.1