[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: shutdown dialog patch
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-12-17 21:34:47
Message-ID: 200812172234.47106.notmart () gmail ! com
[Download RAW message or body]

On Wednesday 17 December 2008, Aaron J. Seigo wrote:
> 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 =)

i think it would look cuter if the moon is not sticked to the left edge of the 
dialog, but with its x/y positions mostly the same, like the attached patch, 
just 2 lines changed
http://imagebin.ca/view/ISibBhpI.html

or maybe a bit better with the moon a bit bigger then the button...
anyways think you should put up the current one or this, we'll find room for 
improvement later :)

> 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



["nicemoon.diff" (text/x-patch)]

Index: shutdowndlg.cpp
===================================================================
--- shutdowndlg.cpp	(revision 898242)
+++ 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,27 @@
     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;
+        const int extraspace = (height() - m_pictureWidth - \
bottomLayout->sizeHint().height()); +        buttonMainLayout->insertSpacing(0, \
m_pictureWidth + extraspace); +        resize(width() + m_pictureWidth + extraspace, \
height()); +        //kDebug() << width();
+    }
+
+    KDialog::centerOnScreen(this);
 }
 
 void KSMShutdownDlg::automaticallyDoTimeout()
@@ -535,10 +541,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 +554,28 @@
         } else {
           button = m_btnReboot;
         }
+
         r.moveTop(button->geometry().top() - 10);
+        r.moveLeft(r.top());
         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 898242)
+++ shutdowndlg.h	(working copy)
@@ -133,6 +133,7 @@
     KSMPushButton *m_btnReboot;
     KSMPushButton *btnBack;
     int m_automaticallyDoSeconds;
+    int m_pictureWidth;
 
 private Q_SLOTS:
     void automaticallyDoTimeout();



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic