hi all.. after some more bug reports about the shutdown dialog, i decided to take a swing at it.
the attached patch makes the dialog only as big as it needs to be and scales the image down nicely the fit. i'd like people to apply and test the patch and let me know what you think. you can test it by building the test app in workspace/ksmservert/tests/. you need to have KDE4_BUILD_TESTS set to true in your cmake build; if you don't, just do `make edit_cache` move down to that entry in the list that comes up, hit enter to toggle the option, 'c' to configure, 'q' to quit and then you can cd into the test dir and build it =) run it with: ./testsh and ./testsh -t reboot to see how it all looks and feels. you can also see a couple of screenshots here (though the margins were fixed after i took them): http://plasma.kde.org/media/shutudowndialog_all.png http://plasma.kde.org/media/shutudowndialog_reboot.png -- Aaron J. Seigo humru othro a kohnu se GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43 KDE core developer sponsored by Qt Software
Index: shutdowndlg.cpp =================================================================== --- shutdowndlg.cpp (revision 897756) +++ shutdowndlg.cpp (working copy) @@ -339,7 +339,8 @@ m_btnLogout(0), m_btnHalt(0), m_btnReboot(0), - m_automaticallyDoSeconds(30) + m_automaticallyDoSeconds(30), + m_pictureWidth(0) // this is a WType_Popup on purpose. Do not change that! Not // having a popup here has severe side effects. { @@ -361,8 +362,6 @@ m_svg->setImagePath("dialogs/shutdowndialog"); connect( m_svg, SIGNAL(repaintNeeded()), this, SLOT(update()) ); setModal( true ); - resize(400, 120); - KDialog::centerOnScreen(this); QVBoxLayout *mainLayout = new QVBoxLayout(); @@ -374,10 +373,6 @@ m_automaticallyDoLabel = new QLabel(this); mainLayout->addWidget(m_automaticallyDoLabel, 0, Qt::AlignRight); - if (m_svg->hasElement("picture")) { - buttonMainLayout->addSpacing(m_svg->elementRect("picture").toRect().right() + 12); - } - buttonMainLayout->addStretch(); buttonMainLayout->addLayout(buttonLayout); QHBoxLayout *bottomLayout = new QHBoxLayout(); @@ -388,8 +383,6 @@ QPalette palette; palette.setColor(QPalette::WindowText, fntColor); - buttonLayout->addSpacing(10); - m_btnLogout = new KSMPushButton( i18n("&Logout"), this ); m_btnLogout->setPixmap(KIconLoader::global()->loadIcon("system-log-out", KIconLoader::NoGroup, 32)); if ( sdtype == KWorkSpace::ShutdownTypeLogout ) @@ -460,36 +453,29 @@ if ( sdtype == KWorkSpace::ShutdownTypeLogout ) { m_btnReboot->setHidden(true); m_btnHalt->setHidden(true); - buttonLayout->addSpacing(70); } else if ( sdtype == KWorkSpace::ShutdownTypeHalt ) { m_btnReboot->setHidden(true); m_btnLogout->setHidden(true); - buttonLayout->addSpacing(70); } else if ( sdtype == KWorkSpace::ShutdownTypeReboot ) { m_btnHalt->setHidden(true); m_btnLogout->setHidden(true); - buttonLayout->addSpacing(70); } btnBack = new KSMPushButton(i18n("&Cancel"), this, true); btnBack->setPixmap(KIconLoader::global()->loadIcon( "dialog-cancel", KIconLoader::NoGroup, 16)); - //m_automaticallyDoLabel = new QLabel(this); m_automaticallyDoLabel->setPalette(palette); fnt.setPixelSize(11); m_automaticallyDoLabel->setFont(fnt); - //m_automaticallyDoLabel->setWordWrap(true); automaticallyDoTimeout(); QTimer *automaticallyDoTimer = new QTimer(this); connect(automaticallyDoTimer, SIGNAL(timeout()), this, SLOT(automaticallyDoTimeout())); automaticallyDoTimer->start(1000); - //bottomLayout->addWidget(m_automaticallyDoLabel, 1, Qt::AlignBottom); bottomLayout->addStretch(); - //buttonLayout->addWidget(m_automaticallyDoLabel); bottomLayout->addWidget(btnBack); connect(btnBack, SIGNAL(clicked()), SLOT(reject())); @@ -497,7 +483,26 @@ mainLayout->addSpacing(9); mainLayout->addLayout(bottomLayout); - setLayout( mainLayout ); + setLayout(mainLayout); + adjustSize(); + if (m_svg->hasElement("picture")) { + if (height() > width()) { + m_pictureWidth = width(); + } else { + m_svg->isValid(); + m_svg->resize(); + QRect pictRect = m_svg->elementRect("picture").toRect(); + m_pictureWidth = pictRect.width() * (buttonMainLayout->sizeHint().height() / qreal(pictRect.height())); + //kDebug() << "blurk!" << buttonMainLayout->sizeHint().height() << pictRect; + } + + //kDebug() << width() << m_pictureWidth; + buttonMainLayout->insertSpacing(0, m_pictureWidth); + resize(width() + m_pictureWidth, height()); + //kDebug() << width(); + } + + KDialog::centerOnScreen(this); } void KSMShutdownDlg::automaticallyDoTimeout() @@ -535,10 +540,11 @@ p.setClipRect(e->rect()); p.fillRect(QRect(0, 0, width(), height()), Qt::transparent); + m_svg->resize(size()); m_svg->paint(&p, QRect(0, 0, width(), height()), "background"); if (m_svg->hasElement("picture")) { - QRect r = m_svg->elementRect("picture").toRect(); + QRect r;// = m_svg->elementRect("picture").toRect(); KSMPushButton* button; if (m_btnLogout->isVisible()) { button = m_btnLogout; @@ -547,14 +553,27 @@ } else { button = m_btnReboot; } + r.moveTop(button->geometry().top() - 10); r.setBottom(btnBack->geometry().top()); + r.setWidth(m_pictureWidth); + + m_svg->resize(); QPixmap picture = m_svg->pixmap("picture"); - QRect sourceRect(QPoint(0, 0), r.size()); - sourceRect.moveCenter(picture.rect().center()); + //kDebug() << 1 << r << picture.size(); + if (r.width() < picture.width()) { + picture = picture.scaledToWidth(r.width(), Qt::SmoothTransformation); + } - p.drawPixmap(r, picture, sourceRect); + if (r.height() < picture.height()) { + picture = picture.scaledToHeight(r.height(), Qt::SmoothTransformation); + } + + //kDebug() << 2 << r << picture.size(); + QRect dest = picture.rect(); + dest.moveCenter(r.center()); + p.drawPixmap(dest, picture, picture.rect()); } } Index: shutdowndlg.h =================================================================== --- shutdowndlg.h (revision 897756) +++ shutdowndlg.h (working copy) @@ -133,6 +133,7 @@ KSMPushButton *m_btnReboot; KSMPushButton *btnBack; int m_automaticallyDoSeconds; + int m_pictureWidth; private Q_SLOTS: void automaticallyDoTimeout();
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel