#include "generalwidget.h" #include #include "inline.h" #include "mabitimer.h" #include "sequence.h" #include "weather.h" #include "settings.h" #include "alertwidget.h" #include #include #include #include #include #include #include #include #include #include #include #include /// ÇÏ´Ü Ä«ÇǶóÀÌÆ® ÅؽºÆ®. static const wchar_t *comment = L"ÀÌ ÇÁ·Î±×·¥Àº ¸¶ºñ³ë±â ŸÀÓÁî(http://www.mabinogi.pe.kr)ÀÇ Á¤º¸¸¦ ¹ÙÅÁÀ¸·Î Á¦ÀÛÇÏ¿´½À´Ï´Ù."; /// Ç÷¹Å¸ÀÇ µîÀå ½Ã°£ Ç¥½Ã ÅؽºÆ®. static const wchar_t *fletaTime = L"¿¡¸°½Ã°¢ 09:00 ~ 11:00, 15:00 ~ 17:00, 19:00 ~ 21:00"; /// Ç÷¹Å¸ÀÇ µîÀå À§Ä¡ Ç¥½Ã ÅؽºÆ®. static const wchar_t *fletaLocation = L"À§Ä¡: ¼¾¸¶ÀÌ Æò¿ø Áß¾Ó »ï°Å¸® ±Ùó"; /** * ƯÁ¤ ³¯¾¾ ŸÀÔÀÌ ½ÃÀÛ µÇ´Â ½Ã°£À» ¾ò¾î¿Â´Ù. * @param weather CMabiWeatherÀÇ °´Ã¼. * @param wantType ãÀ» ³¯¾¾ÀÇ Å¸ÀÔ. * @param current ±âÁØ ½Ã°£. * @return ½ÃÀÛ µÇ´Â ½Ã°£. (Unix time) */ time_t findBeginWeather(Weather *weather, Weather::WeatherType wantType, time_t current) { const int step = 60 * 20; float weatherValue; Weather::WeatherType weatherType; current = current - (current % step); weatherValue = weather->weather(current); weatherType = weather->weatherType(weatherValue); if(Weather::compareWeatherType(weatherType, wantType) == 0) { do { current = current - step; weatherValue = weather->weather(current); weatherType = weather->weatherType(weatherValue); } while(Weather::compareWeatherType(weatherType, wantType) == 0); current = current + step; } else if(Weather::compareWeatherType(weatherType, wantType) > 0) { do { current = current - step; weatherValue = weather->weather(current); weatherType = weather->weatherType(weatherValue); } while(Weather::compareWeatherType(weatherType, wantType) < 0); current = current + step; } else { do { current = current + step; weatherValue = weather->weather(current); weatherType = weather->weatherType(weatherValue); } while(Weather::compareWeatherType(weatherType, wantType) < 0); } return current; } /** * ƯÁ¤ ³¯¾¾ ŸÀÔÀÌ ½ÃÀÛ ³¡³ª´Â ½Ã°£À» ¾ò¾î¿Â´Ù. * @param weather CMabiWeatherÀÇ °´Ã¼. * @param wantType ãÀ» ³¯¾¾ÀÇ Å¸ÀÔ. * @param current ±âÁØ ½Ã°£. * @return ³¡³ª´Â ½Ã°£. (Unix time) */ time_t findEndWeather(Weather *weather, Weather::WeatherType wantType, time_t current) { const int step = 60 * 20; float weatherValue; Weather::WeatherType weatherType; current = current - (current % step); weatherValue = weather->weather(current); weatherType = weather->weatherType(weatherValue); if(Weather::compareWeatherType(weatherType, wantType) == 0) { do { current = current + step; weatherValue = weather->weather(current); weatherType = weather->weatherType(weatherValue); } while(Weather::compareWeatherType(weatherType, wantType) == 0); } return current; } GeneralWidget::GeneralWidget(QWidget *parent) : QWidget(parent), sequence(MabiTimer::sequence()) { setObjectName("GeneralWidget"); setWindowTitle(QString::fromWCharArray(L"¿¡¸° Á¤º¸")); setWindowIcon(QIcon(":/icons/report.png")); setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground, true); realTime = new QDateTime; weatherArea = new QStringList; bDragging = false; lbBackground = new QLabel(this); glMainLayout = new QGridLayout; initWeather(); createLayout(); createLable(); createOption(); loadSettings(); // final setLayout(glMainLayout); glMainLayout->setSizeConstraint(QLayout::SetFixedSize); glMainLayout->setMargin(15); background.load(":/generalwidget/background.png"); QPalette palette = this->palette(); QColor color = Qt::white; color.setAlpha(0); palette.setColor(QPalette::Button, color); btClose->setPalette(palette); cbArbeit->setPalette(palette); cbWeather->setPalette(palette); MabiTimer::connectTimer(this, SLOT(updateAll())); } GeneralWidget::~GeneralWidget() { qDebug() << "destroyed: " << objectName(); saveSettings(); delete weatherArea; delete realTime; } void GeneralWidget::initWeather() { weatherArea->append(QString::fromWCharArray(L"Ƽ¸£ ÄÚ³×ÀÏ, µÎ°¥µå ¾ÆÀÏ")); weatherArea->append(QString::fromWCharArray(L"´ø¹ÙÆ°, °¡ÀÌ·¹Èå")); weatherArea->append(QString::fromWCharArray(L"¹ÝÈ£¸£")); weatherArea->append(QString::fromWCharArray(L"ÀÌ¸à ¸¶ÇÏ")); weatherArea->append(QString::fromWCharArray(L"¼¾¸¶ÀÌ Æò¿ø")); weatherArea->append(QString::fromWCharArray(L"ÄÉ¾È Ç×±¸")); weatherArea->append(QString::fromWCharArray(L"¶ó³ë Áö¿ª")); weatherArea->append(QString::fromWCharArray(L"ÄÜ´©½º Áö¿ª")); weatherArea->append(QString::fromWCharArray(L"Äí¸£Å¬·¹ Áö¿ª")); weatherArea->append(QString::fromWCharArray(L"ÀÚ¸£µò Áö¿ª")); weatherArea->append(QString::fromWCharArray(L"±×¸²ÀÚ ¼¼°è")); weatherArea->append(QString::fromWCharArray(L"Żƾ, Ÿ¶ó")); } void GeneralWidget::createLayout() { QLabel *lbComment; lbComment = new QLabel(QString::fromWCharArray(comment)); lbComment->setWordWrap(true); glMainLayout = new QGridLayout; glMainLayout->setVerticalSpacing(10); // static label glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"¿¡¸°½Ã°£:")), 0, 0, Qt::AlignTop); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"¹®°ÔÀÌÆ®:")), 1, 0, Qt::AlignTop); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"¾Æ¸£¹ÙÀÌÆ®:")), 2, 0, Qt::AlignVCenter); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"³¯¾¾:")), 3, 0, Qt::AlignVCenter); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"¿äÀÏÈ¿°ú:")), 5, 0, Qt::AlignTop); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"¾îµå¹ê½ºµå ¾ÆÀÌÅÛ:")), 6, 0, 1, -1, Qt::AlignTop); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"ÇÁ¶óÀ̽º:")), 8, 0, Qt::AlignTop); glMainLayout->addWidget(new QLabel(QString::fromWCharArray(L"Ç÷¹Å¸:")), 9, 0, Qt::AlignTop); glMainLayout->addWidget(lbComment, 10, 0, 1, -1, Qt::AlignTop); // time hbTimeLayout = new QHBoxLayout; hbTimeLayout->addWidget(new QLabel(QString::fromWCharArray(L"Çö½Ç½Ã°£:")), 0, Qt::AlignTop); glMainLayout->addLayout(hbTimeLayout, 0, 1, 1, 1, Qt::AlignTop); // gate vbGateLayout = new QVBoxLayout; glMainLayout->addLayout(vbGateLayout, 1, 1, 1, 1, Qt::AlignTop); // arbeit hbArbeitLayout = new QHBoxLayout; glMainLayout->addLayout(hbArbeitLayout, 2, 1, 1, -1, Qt::AlignVCenter); // weather hbWeatherLayout = new QHBoxLayout; glMainLayout->addLayout(hbWeatherLayout, 3, 1, 1, -1, Qt::AlignVCenter); // weekeffect vbEffectLayout = new QVBoxLayout; glMainLayout->addLayout(vbEffectLayout, 5, 1, 1, -1, Qt::AlignTop); // price vbPriceLayout = new QVBoxLayout; glMainLayout->addLayout(vbPriceLayout, 8, 1, 1, -1, Qt::AlignTop); // fleta vbFletaLayout = new QVBoxLayout; glMainLayout->addLayout(vbFletaLayout, 9, 1, 1, -1, Qt::AlignTop); // options hbOptionLayout = new QHBoxLayout; glMainLayout->addLayout(hbOptionLayout, 11, 0, 1, -1, Qt::AlignTop); // close button QImage close(":/generalwidget/close.png"); btClose = new QToolButton; btClose->setIcon(QPixmap::fromImage(close)); btClose->setIconSize(close.size() + QSize(5, 5)); //btClose->setContentsMargins(0, 0, 0, 0); glMainLayout->addWidget(btClose, 0, 2, 2, 1, Qt::AlignTop | Qt::AlignRight); connect(btClose, SIGNAL(clicked()), this, SLOT(close())); } void GeneralWidget::createLable() { QString loading(QString::fromWCharArray(L"loading...")); // dynamic label // time lbRealTime = new QLabel(loading); lbErinnTime = new QLabel(loading); hbTimeLayout->addWidget(lbRealTime, 0, Qt::AlignTop); hbTimeLayout->insertWidget(0, lbErinnTime, 0, Qt::AlignTop); hbTimeLayout->addStretch(); hbTimeLayout->setSpacing(15); // gate lbMoongate = new QLabel(loading); lbMoongateNext = new QLabel(loading); vbGateLayout->addWidget(lbMoongate); vbGateLayout->addWidget(lbMoongateNext); //gateLayout->addStretch(); vbGateLayout->setSpacing(2); // arbeit lbArbeit = new QLabel(loading); cbArbeit = new QComboBox; const int arbeitCount = sequence->arbeitSequence()->size(); const QList *arbeitList = sequence->arbeitSequence(); for(int i = 0; i < arbeitCount; i++) { cbArbeit->addItem(arbeitList->at(i).name); } hbArbeitLayout->addWidget(cbArbeit, 0, Qt::AlignVCenter); hbArbeitLayout->addWidget(lbArbeit, 0, Qt::AlignVCenter); hbArbeitLayout->setSpacing(15); // weather lbWeather = new QLabel(loading); cbWeather = new QComboBox; const int weatherCount = weatherArea->size(); for(int i = 0; i < weatherCount; i++) { cbWeather->addItem(weatherArea->at(i)); } hbWeatherLayout->addWidget(cbWeather, 0, Qt::AlignVCenter); hbWeatherLayout->setSpacing(2); glMainLayout->addWidget(lbWeather, 4, 1, 1, -1, Qt::AlignVCenter); // weekeffect lbWeekEffectName = new QLabel(loading); lbWeekEffectContent = new QLabel(loading); vbEffectLayout->addWidget(lbWeekEffectName); vbEffectLayout->addWidget(lbWeekEffectContent); //effectLayout->addStretch(); vbEffectLayout->setSpacing(10); lbWeekAdvanceItem = new QLabel(loading); glMainLayout->addWidget(lbWeekAdvanceItem, 7, 1, Qt::AlignTop); // price lbPrice = new QLabel(loading); lbPriceNext1 = new QLabel(loading); lbPriceNext2 = new QLabel(loading); vbPriceLayout->addWidget(lbPrice); vbPriceLayout->addWidget(lbPriceNext1); vbPriceLayout->addWidget(lbPriceNext2); vbPriceLayout->setSpacing(2); // fleta vbFletaLayout->addWidget(new QLabel(QString::fromWCharArray(fletaTime))); vbFletaLayout->addWidget(new QLabel(QString::fromWCharArray(fletaLocation))); vbFletaLayout->addStretch(); vbFletaLayout->setSpacing(2); } void GeneralWidget::createOption() { // options cbTopmost = new QCheckBox(QString::fromWCharArray(L"Ç×»ó À§")); slOpacity = new QSlider(Qt::Horizontal); slOpacity->setMinimum(20); slOpacity->setMaximum(100); slOpacity->setValue(100); hbOptionLayout->addWidget(cbTopmost); hbOptionLayout->addWidget(slOpacity, Qt::AlignRight); hbOptionLayout->addStretch(); hbOptionLayout->setSpacing(15); connect(cbTopmost, SIGNAL(clicked()), this, SLOT(toggleTopmost())); connect(slOpacity, SIGNAL(valueChanged(int)), this, SLOT(changeOpacity(int))); } void GeneralWidget::saveSettings() { Settings *settings = MabiTimer::settings(); if(settings) { settings->setArbeitIndex(cbArbeit->currentIndex()); settings->setWeatherIndex(cbWeather->currentIndex()); } else { qDebug() << "Settings object is null"; } } void GeneralWidget::loadSettings() { Settings *settings = MabiTimer::settings(); if(settings) { const int arbeit = settings->arbeitIndex(); const int weather = settings->weatherIndex(); if(cbArbeit->count() > arbeit) { cbArbeit->setCurrentIndex(arbeit); } if(cbWeather->count() > weather) { cbWeather->setCurrentIndex(weather); } } else { qDebug() << "Settings object is null"; } } void GeneralWidget::updateAll() { updateTime(); updateMoongate(); updateArbeit(); updateWeather(); updateWeekEffect(); updatePrice(); if(size() != glMainLayout->sizeHint()) { resize(glMainLayout->sizeHint()); } } void GeneralWidget::updateTime() { realTime->operator =(QDateTime::currentDateTime()); realTime->operator =(realTime->addSecs(MabiTimer::offsetSeconds())); QTime time = realTime->time(); lbRealTime->setText(sec2MinSec(time.hour() * 60 + time.minute())); lbErinnTime->setText(sec2MinSec(qRound(MabiTimer::erinnTime()->toTime_t() * 2 / 3))); } void GeneralWidget::updateMoongate() { const int moongateCount = sequence->moongateSequence()->size(); const QStringList *moongateSequence = sequence->moongateSequence(); int size = moongateCount; int midx0 = ((int)((realTime->toTime_t() - 540 - 6) / 2160)) % size; int midx1 = (midx0 + 1) % size; int midx2 = (midx1 + 1) % size; QString gateWait(moongateSequence->at(midx0)); QDateTime *erinnTime = MabiTimer::erinnTime(); if((erinnTime->toTime_t() > 546) && (erinnTime->toTime_t() <= 1626)) { gateWait.append(QString::fromWCharArray(L" - ´ë±â (")); gateWait.append(sec2MinSec(1626 - erinnTime->toTime_t())); gateWait.append(QString::fromWCharArray(L" ÈÄ ¿­¸²)")); } else { int waitTime = 546 - erinnTime->toTime_t(); if(waitTime < 0) { waitTime = waitTime + 2160; } gateWait.append(QString::fromWCharArray(L" - ¿­¸² (")); gateWait.append(sec2MinSec(waitTime)); gateWait.append(QString::fromWCharArray(L" ÈÄ ´ÝÈû)")); } QString gateNext; gateNext.append(QString::fromWCharArray(L" ¡æ ")); gateNext.append(moongateSequence->at(midx1)); gateNext.append(QString::fromWCharArray(L" ¡æ ")); gateNext.append(moongateSequence->at(midx2)); lbMoongate->setText(gateWait); lbMoongateNext->setText(gateNext); } void GeneralWidget::updateArbeit() { const int arbeitCount = sequence->arbeitSequence()->size(); const QList *arbeitSequence = sequence->arbeitSequence(); int idx = cbArbeit->currentIndex(); if(idx < 0 || idx >= arbeitCount) { cbArbeit->setCurrentIndex(0); idx = 0; } const Arbeit &arbeit = arbeitSequence->at(idx); QString message; QDateTime *erinnTime = MabiTimer::erinnTime(); if((erinnTime->toTime_t() > (uint)arbeit.begin) && (erinnTime->toTime_t() <= (uint)arbeit.end)) { message.append(QString(QString::fromWCharArray(L"ÁøÇà Áß ("))); message.append(sec2MinSec(arbeit.end - erinnTime->toTime_t())); message.append(QString(QString::fromWCharArray(L" ÈÄ Á¾·á)"))); } else { int waitTime = arbeit.begin - erinnTime->toTime_t(); if(waitTime < 0) { waitTime = waitTime + 2160; } message.append(QString(QString::fromWCharArray(L"´ë±â Áß ("))); message.append(sec2MinSec(waitTime)); message.append(QString(QString::fromWCharArray(L" ÈÄ ½ÃÀÛ)"))); } lbArbeit->setText(message); } void GeneralWidget::updateWeather() { if(cbWeather->currentIndex() < 0 || cbWeather->currentIndex() > cbWeather->count() || cbWeather->currentIndex() > MabiTimer::weatherCount()) { cbWeather->setCurrentIndex(0); } Weather *weather = MabiTimer::weather(cbWeather->currentIndex() + 1); time_t nowTime = time(NULL); time_t rainTime = findBeginWeather(weather, Weather::Rain, nowTime); time_t stormTime = findBeginWeather(weather, Weather::Storm, nowTime); float weatherValue = weather->weather(nowTime); float rainAmount = floorf(weather->rainAmount(weatherValue) * 20); time_t weatherEndTime = findEndWeather(weather, weather->weatherType(weatherValue), nowTime); QDateTime rainDateTime = QDateTime::fromTime_t(rainTime); QDateTime stormDateTime = QDateTime::fromTime_t(stormTime); QDateTime endDateTime = QDateTime::fromTime_t(weatherEndTime - nowTime); QString weatherString; endDateTime = endDateTime.toUTC(); weatherString.append(QString::fromWCharArray(L"ÇöÀç ³¯¾¾: ")); weatherString.append(Weather::weatherTypeToString(weather->weatherType(weatherValue))); if(rainAmount > 0) { weatherString.append(" (+"); weatherString.append(QString::number(rainAmount)); weatherString.append(")"); } weatherValue = weather->weather(weatherEndTime); rainAmount = floorf(weather->rainAmount(weatherValue) * 20); weatherString.append(" ("); weatherString.append(endDateTime.toString(QString::fromWCharArray(L"hh:mm:ss ÈÄ "))); weatherString.append(Weather::weatherTypeToString(weather->weatherType(weatherValue))); if(rainAmount > 0) { weatherString.append(" (+"); weatherString.append(QString::number(rainAmount)); weatherString.append(")"); } weatherString.append(")"); weatherValue = weather->weather(rainTime); rainAmount = floorf(weather->rainAmount(weatherValue) * 20); weatherString.append(QString::fromWCharArray(L"\nºñ¿Ã ³¯Â¥: ")); weatherString.append(rainDateTime.toString("MM/dd hh:mm:ss")); if(rainAmount > 0) { weatherString.append(" (+"); weatherString.append(QString::number(rainAmount)); weatherString.append(")"); } weatherString.append(QString::fromWCharArray(L"\nõµÕ ¿¹Á¤: ")); weatherString.append(stormDateTime.toString("MM/dd hh:mm:ss")); lbWeather->setText(weatherString); } void GeneralWidget::updateWeekEffect() { int idx = realTime->date().dayOfWeek() % 7; lbWeekEffectName->setText(sequence->weekdayEffectsName()->at(idx)); lbWeekEffectContent->setText(sequence->weekdayEffectsContent()->at(idx)); lbWeekAdvanceItem->setText(sequence->weekdayEffectsAdvance()->at(idx)); } void GeneralWidget::updatePrice() { const int priceCount = sequence->priceSequence()->size(); const QStringList *priceSequence = sequence->priceSequence(); int pidx0 = ((int)(realTime->toTime_t() / 2160)) % priceCount; int pidx1 = (pidx0 + 1) % priceCount; int pidx2 = (pidx1 + 1) % priceCount; QString message1(priceSequence->at(pidx0)); QString message2(QString::fromWCharArray(L"¡æ ")); QString message3(QString::fromWCharArray(L"¡æ ")); message1.append(QString::fromWCharArray(L" - ")); message1.append(sec2MinSec(2160 - MabiTimer::erinnTime()->toTime_t())); message1.append(QString::fromWCharArray(L" ÈÄ À̵¿")); message2.append(priceSequence->at(pidx1)); message3.append(priceSequence->at(pidx2)); lbPrice->setText(message1); lbPriceNext1->setText(message2); lbPriceNext2->setText(message3); } void GeneralWidget::toggleTopmost() { if(cbTopmost->isChecked()) { setWindowFlags(Qt::WindowStaysOnTopHint | windowFlags()); } else { setWindowFlags((Qt::WindowFlags)~Qt::WindowStaysOnTopHint & windowFlags()); } show(); } void GeneralWidget::changeOpacity(int opacity) { setWindowOpacity(((qreal)opacity) / 100); } void GeneralWidget::mouseMoveEvent(QMouseEvent *event) { if(bDragging && this == mouseGrabber()) { QDesktopWidget *desktop = QApplication::desktop(); const int screenN = desktop->screenNumber(event->globalPos()); const QRect screenR = desktop->availableGeometry(screenN); const QRect windowR = geometry(); const QPoint movePoint = event->pos() - dragPos; const QPoint margin(20, 20); QPoint destination = event->globalPos() - dragPos; QRect snapScreen(screenR.topLeft() + margin, screenR.bottomRight() - margin); QRect moveWindow(windowR.topLeft() + movePoint, windowR.bottomRight() + movePoint); if(snapScreen.contains(windowR) == false) { int topSY = moveWindow.top() - screenR.top(); int leftSX = moveWindow.left() - screenR.left(); int rightSX = screenR.right() - moveWindow.right(); int bottomSY = screenR.bottom() - moveWindow.bottom(); if(qAbs(topSY) < margin.y()) { destination.ry() = screenR.top(); } if(qAbs(leftSX) < margin.x()) { destination.rx() = screenR.left(); } if(qAbs(rightSX) < margin.x()) { destination.rx() = screenR.right() - moveWindow.width(); } if(qAbs(bottomSY) < margin.y()) { destination.ry() = screenR.bottom() - moveWindow.height(); } } move(destination); } } void GeneralWidget::mousePressEvent(QMouseEvent *event) { dragPos = event->pos(); if((event->buttons() & Qt::LeftButton) && !bDragging) { grabMouse(); bDragging = true; } } void GeneralWidget::mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); if(bDragging) { bDragging = false; releaseMouse(); } } void GeneralWidget::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); if(width() > 25 && height() > 25) { const int RADIUS = 10; QPixmap pixmap(size()); QPainter painter; int mWidth = width(); int mHeight = height(); int iWidth = background.width(); int iHeight = background.height(); pixmap.fill(QColor(Qt::transparent)); painter.begin(&pixmap); // corner painter.drawImage(QRectF(0, 0, RADIUS, RADIUS), background, QRectF(0, 0, RADIUS, RADIUS)); painter.drawImage(QRectF(mWidth - RADIUS, 0, RADIUS, RADIUS), background, QRectF(iWidth - RADIUS, 0, RADIUS, RADIUS)); painter.drawImage(QRectF(mWidth - RADIUS, mHeight - RADIUS, RADIUS, RADIUS), background, QRectF(iWidth - RADIUS, iHeight - RADIUS, RADIUS, RADIUS)); painter.drawImage(QRectF(0, mHeight - RADIUS, RADIUS, RADIUS), background, QRectF(0, iHeight - RADIUS, RADIUS, RADIUS)); // side painter.drawImage(QRectF(RADIUS, 0, mWidth - RADIUS * 2, RADIUS), background, QRectF(RADIUS, 0, iWidth - RADIUS * 2, RADIUS)); painter.drawImage(QRectF(mWidth - RADIUS, RADIUS, RADIUS, mHeight - RADIUS * 2), background, QRectF(iWidth - RADIUS, RADIUS, RADIUS, iHeight - RADIUS * 2)); painter.drawImage(QRectF(RADIUS, mHeight - RADIUS, mWidth - RADIUS * 2, RADIUS), background, QRectF(RADIUS, iHeight - RADIUS, iWidth - RADIUS * 2, RADIUS)); painter.drawImage(QRectF(0, RADIUS, RADIUS, mHeight - RADIUS * 2), background, QRectF(0, RADIUS, RADIUS, iHeight - RADIUS * 2)); // inner painter.drawImage(QRectF(RADIUS, RADIUS, mWidth - RADIUS * 2, mHeight - RADIUS * 2), background, QRectF(RADIUS, RADIUS, iWidth - RADIUS * 2, iHeight - RADIUS * 2)); // end draw painter.end(); lbBackground->setPixmap(pixmap); lbBackground->adjustSize(); } }