Git commit 63197074b17e042d2d99973488358a14afae8560 by Àlex Fiestas.
Committed on 17/12/2013 at 17:34.
Pushed by afiestas into branch 'master'.

[ksmserver] Port the shutdowndlg, HUGE hack just to make it work

Please, somebody else should properly port this, I have done the minimum
required work to allow the dialog to work.

CCMAIL: plasma-devel@kde.org

M  +19   -13   ksmserver/shutdowndlg.cpp
M  +4    -4    ksmserver/themes/contour/ContourButton.qml
M  +4    -4    ksmserver/themes/contour/main.qml
M  +5    -5    ksmserver/themes/default/ContextMenu.qml
M  +9    -9    ksmserver/themes/default/KSMButton.qml
M  +4    -4    ksmserver/themes/default/MenuItem.qml
M  +86   -86   ksmserver/themes/default/main.qml

http://commits.kde.org/kde-workspace/63197074b17e042d2d99973488358a14afae8560

diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp
index 6ad428d..00704e4 100644
--- a/ksmserver/shutdowndlg.cpp
+++ b/ksmserver/shutdowndlg.cpp
@@ -162,11 +162,12 @@ void KSMShutdownFeedback::logoutCanceled()
 ////////////
 
 Q_DECLARE_METATYPE(Solid::PowerManagement::SleepState)
+#include <QVBoxLayout>
 
 KSMShutdownDlg::KSMShutdownDlg( QWidget* parent,
                                 bool maysd, bool choose, 
KWorkSpace::ShutdownType sdtype,
                                 const QString& theme)
-  : QDialog( parent, Qt::Popup ) //krazy:exclude=qclasses
+  : QDialog( parent/*, Qt::Popup */) //krazy:exclude=qclasses
     // this is a WType_Popup on purpose. Do not change that! Not
     // having a popup here has severe side effects.
 {
@@ -181,8 +182,13 @@ KSMShutdownDlg::KSMShutdownDlg( QWidget* parent,
 
     KDialog::centerOnScreen(this, -3);
 
+     setMinimumSize(300, 200);
     //kDebug() << "Creating QML view";
-    m_view = new QQuickView(windowHandle());
+    QVBoxLayout *vbox = new QVBoxLayout(this);
+    m_view = new QQuickView( );
+    QWidget *windowContainer = QWidget::createWindowContainer(m_view, this);
+    vbox->addWidget(windowContainer);
+    windowContainer->setSizePolicy(QSizePolicy::Preferred, 
QSizePolicy::Preferred);
     QQmlContext *context = m_view->rootContext();
     context->setContextProperty(QStringLiteral("maysd"), maysd);
     context->setContextProperty(QStringLiteral("choose"), choose);
@@ -223,22 +229,23 @@ KSMShutdownDlg::KSMShutdownDlg( QWidget* parent,
     setModal( true );
 
     // window stuff
-    m_view->setFlags(Qt::X11BypassWindowManagerHint);
-//    m_view->setFrameShape(QFrame::NoFrame);
-//    m_view->setAttribute(Qt::WA_TranslucentBackground);
+//     setFlags(Qt::X11BypassWindowManagerHint);
+//     windowContainer->setFrameShape(QFrame::NoFrame);
+    windowContainer->setAttribute(Qt::WA_TranslucentBackground);
+    setAttribute(Qt::WA_TranslucentBackground);
     setAttribute(Qt::WA_TranslucentBackground);
     setStyleSheet(QStringLiteral("background:transparent;"));
-//    QPalette pal = m_view->palette();
-//    pal.setColor(backgroundRole(), Qt::transparent);
-//    m_view->setPalette(pal);
-//    m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-//    m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    QPalette pal = windowContainer->palette();
+    pal.setColor(backgroundRole(), Qt::transparent);
+    windowContainer->setPalette(pal);
+//    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+//    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     // engine stuff
     KDeclarative kdeclarative;
     kdeclarative.setDeclarativeEngine(m_view->engine());
     kdeclarative.initialize();
     kdeclarative.setupBindings();
-    m_view->installEventFilter(this);
+    windowContainer->installEventFilter(this);
 
     QString fileName = 
QStandardPaths::locate(QStandardPaths::GenericDataLocation, 
QStringLiteral("ksmserver/themes/%1/main.qml").arg(theme));
     if (QFile::exists(fileName)) {
@@ -253,8 +260,7 @@ KSMShutdownDlg::KSMShutdownDlg( QWidget* parent,
     connect(rootObject, SIGNAL(rebootRequested2(int)), SLOT(slotReboot(int)) );
     connect(rootObject, SIGNAL(cancelRequested()), SLOT(reject()));
     connect(rootObject, SIGNAL(lockScreenRequested()), SLOT(slotLockScreen()));
-    m_view->show();
-//    m_view->setFocus();
+
     adjustSize();
 }
 
diff --git a/ksmserver/themes/contour/ContourButton.qml 
b/ksmserver/themes/contour/ContourButton.qml
index ee82205..5176c6a 100644
--- a/ksmserver/themes/contour/ContourButton.qml
+++ b/ksmserver/themes/contour/ContourButton.qml
@@ -22,7 +22,7 @@ Inherits:
         PlasmaCore.FrameSvgItem
 
 Imports:
-        QtQuick 1.0
+        QtQuick 2.0
         org.kde.plasma.core
         org.kde.qtextracomponents
 
@@ -53,9 +53,9 @@ Signals:
         This handler is called when there is a click.
 **/
 
-import QtQuick 1.0
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.qtextracomponents 0.1
+import QtQuick 2.0
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.qtextracomponents 2.0
 
 PlasmaCore.FrameSvgItem {
     id: button
diff --git a/ksmserver/themes/contour/main.qml 
b/ksmserver/themes/contour/main.qml
index 1c18f00..4a543d9 100644
--- a/ksmserver/themes/contour/main.qml
+++ b/ksmserver/themes/contour/main.qml
@@ -17,10 +17,10 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-import QtQuick 1.0
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import org.kde.qtextracomponents 0.1
+import QtQuick 2.0
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.plasma.components 2.0 as PlasmaComponents
+import org.kde.qtextracomponents 2.0
 
 PlasmaCore.FrameSvgItem {
     id: shutdownUi
diff --git a/ksmserver/themes/default/ContextMenu.qml 
b/ksmserver/themes/default/ContextMenu.qml
index cd1d046..60b5f8e 100644
--- a/ksmserver/themes/default/ContextMenu.qml
+++ b/ksmserver/themes/default/ContextMenu.qml
@@ -18,9 +18,9 @@
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.0
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.plasma.components 2.0 as PlasmaComponents
 
 Item {
     id: root
@@ -60,7 +60,7 @@ Item {
     PlasmaCore.Dialog {
         id: dialog
         visible: false
-        windowFlags: Qt.Popup
+//         windowFlags: Qt.Popup
         onVisibleChanged: {
             if (visible) {
                 status = PlasmaComponents.DialogStatus.Open
@@ -73,7 +73,7 @@ Item {
             id: contentItem
 
             width: listView.width
-            height: Math.min(listView.contentHeight, 
theme.defaultFont.mSize.height * 25)
+            height: Math.min(listView.contentHeight, 
theme.mSize(theme.defaultFont).height * 25)
 
             ListView {
                 id: listView
diff --git a/ksmserver/themes/default/KSMButton.qml 
b/ksmserver/themes/default/KSMButton.qml
index a229987..7d5522a 100644
--- a/ksmserver/themes/default/KSMButton.qml
+++ b/ksmserver/themes/default/KSMButton.qml
@@ -21,7 +21,7 @@ Inherits:
         PlasmaCore.FrameSvgItem
 
 Imports:
-        QtQuick 1.1
+        QtQuick 2.0
         org.kde.plasma.core
         org.kde.qtextracomponents
 
@@ -70,9 +70,9 @@ Signals:
         This handler is called when there is a press and hold.
 **/
 
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.qtextracomponents 0.1
+import QtQuick 2.0
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.qtextracomponents 2.0
 
 PlasmaCore.FrameSvgItem {
     id: button
@@ -90,9 +90,9 @@ PlasmaCore.FrameSvgItem {
     signal pressed()
     signal pressAndHold()
 
-    PlasmaCore.Theme {
-        id: theme
-    }
+//     PlasmaCore.Theme {
+//         id: theme
+//     }
 
     PlasmaCore.SvgItem {
         id: background
@@ -111,11 +111,11 @@ PlasmaCore.FrameSvgItem {
         anchors {
             verticalCenter: parent.verticalCenter
             left: parent.left
-            leftMargin: theme.defaultFont.mSize.width
+            leftMargin: theme.mSize(theme.defaultFont).width
         }
 
         onPaintedWidthChanged: {
-            button.width = Math.max(button.width, 
theme.defaultFont.mSize.width + labelElement.width + 
2*theme.defaultFont.mSize.width + iconElement.width + 
theme.defaultFont.mSize.width)
+            button.width = Math.max(button.width, 
theme.mSize(theme.defaultFont).width + labelElement.width + 
2*theme.mSize(theme.defaultFont).width + iconElement.width + 
theme.mSize(theme.defaultFont).width)
         }
     }
 
diff --git a/ksmserver/themes/default/MenuItem.qml 
b/ksmserver/themes/default/MenuItem.qml
index 65adf0b..5eed717 100644
--- a/ksmserver/themes/default/MenuItem.qml
+++ b/ksmserver/themes/default/MenuItem.qml
@@ -38,10 +38,10 @@
 **
 ****************************************************************************/
 
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import org.kde.qtextracomponents 0.1
+import QtQuick 2.0
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.plasma.components 2.0 as PlasmaComponents
+import org.kde.qtextracomponents 2.0
 
 Item {
     id: root
diff --git a/ksmserver/themes/default/main.qml 
b/ksmserver/themes/default/main.qml
index 8924fac..09ea4c1 100644
--- a/ksmserver/themes/default/main.qml
+++ b/ksmserver/themes/default/main.qml
@@ -22,11 +22,11 @@
  . use 
kde-runtime/plasma/declarativeimports/plasmacomponents/qml/ContextMenu.qml
  instead of a custom ContextMenu component.
  */
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.0
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.plasma.components 2.0 as PlasmaComponents
 import "helper.js" as Helper
-
+import "."
 PlasmaCore.FrameSvgItem {
     id: shutdownUi
     property int realMarginTop: margins.top
@@ -51,9 +51,9 @@ PlasmaCore.FrameSvgItem {
     property variant lastButton: 0
     property int automaticallyDoSeconds: 30
 
-    PlasmaCore.Theme {
-        id: theme
-    }
+//     PlasmaCore.Theme {
+//         id: theme
+//     }
 
     /* This is not necessary for themes that follow the specification.
        Uncomment this and [1] below if the dialog appears without borders or 
background.
@@ -131,7 +131,7 @@ PlasmaCore.FrameSvgItem {
             }
         }
 
-        focusedButton.forceActiveFocus()
+//         focusedButton.forceActiveFocus()
         timer.running = true;
 
         // implement label accelerators in the buttons (the '&' in button's 
text).
@@ -186,7 +186,7 @@ PlasmaCore.FrameSvgItem {
 
     Text {
         id: automaticallyDoLabel
-        font.pointSize: theme.desktopFont.pointSize >= 10 ? 
theme.desktopFont.pointSize*0.9 : theme.desktopFont.pointSize
+//         font.pointSize: theme.desktopFont.pointSize >= 10 ? 
theme.desktopFont.pointSize*0.9 : theme.desktopFont.pointSize
         color: theme.textColor
         wrapMode: Text.WordWrap
         horizontalAlignment: Text.AlignRight
@@ -239,14 +239,14 @@ PlasmaCore.FrameSvgItem {
             Column {
                 spacing: 4
 
-                KSMButton {
+                PlasmaComponents.Button {
                     id: logoutButton
                     text: i18n("&Logout")
                     iconSource: "system-log-out"
                     anchors.right: parent.right
                     visible: (choose || sdtype == 
ShutdownType.ShutdownTypeNone)
-                    tabStopNext: shutdownButton
-                    tabStopBack: cancelButton
+//                     tabStopNext: shutdownButton
+//                     tabStopBack: cancelButton
 
                     onClicked: {
                         //console.log("main.qml: logoutRequested")
@@ -258,43 +258,43 @@ PlasmaCore.FrameSvgItem {
                     }
                 }
 
-                KSMButton {
+                PlasmaComponents.Button {
                     id: shutdownButton
                     text: i18n("&Turn Off Computer")
                     iconSource: "system-shutdown"
                     anchors.right: parent.right
                     visible: (choose || sdtype == 
ShutdownType.ShutdownTypeHalt)
-                    menu: spdMethods.StandbyState | spdMethods.SuspendState | 
spdMethods.HibernateState
-                    tabStopNext: rebootButton
-                    tabStopBack: logoutButton
+//                     menu: spdMethods.StandbyState | spdMethods.SuspendState 
| spdMethods.HibernateState
+//                     tabStopNext: rebootButton
+//                     tabStopBack: logoutButton
 
                     onClicked: {
                         //console.log("main.qml: haltRequested")
                         haltRequested()
                     }
 
-                    onPressAndHold: {
-                        if (!menu) {
-                            return
-                        }
-                        if (!contextMenu) {
-                            contextMenu = 
shutdownOptionsComponent.createObject(shutdownButton)
-                            if (spdMethods.StandbyState) {
-                                // 1 == Solid::PowerManagement::StandbyState
-                                contextMenu.append({itemIndex: 1, itemText: 
i18n("&Standby"), itemSubMenu: null, itemAllowAmpersand: false})
-                            }
-                            if (spdMethods.SuspendState) {
-                                // 2 == Solid::PowerManagement::SuspendState
-                                contextMenu.append({itemIndex: 2, itemText: 
i18n("Suspend to &RAM"), itemSubMenu: null, itemAllowAmpersand: false})
-                            }
-                            if (spdMethods.HibernateState) {
-                                // 4 == Solid::PowerManagement::HibernateState
-                                contextMenu.append({itemIndex: 4, itemText: 
i18n("Suspend to &Disk"), itemSubMenu: null, itemAllowAmpersand: false})
-                            }
-                            
contextMenu.clicked.connect(shutdownUi.suspendRequested)
-                        }
-                        contextMenu.open()
-                    }
+//                     onPressAndHold: {
+//                         if (!menu) {
+//                             return
+//                         }
+//                         if (!contextMenu) {
+//                             contextMenu = 
shutdownOptionsComponent.createObject(shutdownButton)
+//                             if (spdMethods.StandbyState) {
+//                                 // 1 == Solid::PowerManagement::StandbyState
+//                                 contextMenu.append({itemIndex: 1, itemText: 
i18n("&Standby"), itemSubMenu: null, itemAllowAmpersand: false})
+//                             }
+//                             if (spdMethods.SuspendState) {
+//                                 // 2 == Solid::PowerManagement::SuspendState
+//                                 contextMenu.append({itemIndex: 2, itemText: 
i18n("Suspend to &RAM"), itemSubMenu: null, itemAllowAmpersand: false})
+//                             }
+//                             if (spdMethods.HibernateState) {
+//                                 // 4 == 
Solid::PowerManagement::HibernateState
+//                                 contextMenu.append({itemIndex: 4, itemText: 
i18n("Suspend to &Disk"), itemSubMenu: null, itemAllowAmpersand: false})
+//                             }
+//                             
contextMenu.clicked.connect(shutdownUi.suspendRequested)
+//                         }
+//                         contextMenu.open()
+//                     }
 
                     onActiveFocusChanged: {
                         shutdownUi.focusedButton = shutdownButton
@@ -308,15 +308,15 @@ PlasmaCore.FrameSvgItem {
                     }
                 }
 
-                KSMButton {
+                PlasmaComponents.Button {
                     id: rebootButton
                     text: i18n("&Restart Computer")
                     iconSource: "system-reboot"
                     anchors.right: parent.right
                     visible: (choose || sdtype == 
ShutdownType.ShutdownTypeReboot)
-                    menu: rebootOptions["options"].length > 0
-                    tabStopNext: cancelButton
-                    tabStopBack: shutdownButton
+//                     menu: rebootOptions["options"].length > 0
+//                     tabStopNext: cancelButton
+//                     tabStopBack: shutdownButton
 
                     onClicked: {
                         //console.log("main.qml: rebootRequested")
@@ -377,46 +377,46 @@ PlasmaCore.FrameSvgItem {
                         menus[currentMenuId].append(itemData)
                     }
 
-                    onPressAndHold: {
-                        if (!menu) {
-                            return
-                        }
-                        if (!contextMenu) {
-                            var options = rebootOptions["options"]
-                            //console.log("bootManager == " + bootManager)
-
-                            if (bootManager === "Grub2" || bootManager === 
"Burg") {
-                                // javascript passes primitive types by value, 
I need this one passed by reference.
-                                function Index() { this.value = 0 }
-                                var index = new Index()
-                                var menus = {}
-                                var menuId = ""
-
-                                // starts backwards so that the top of the 
stack is the first menu entry.
-                                index.value = options.length - 1
-                                menus[menuId] = 
rebootOptionsComponent.createObject(rebootButton)
-                                
menus[menuId].clicked.connect(shutdownUi.rebootRequested2)
-                                findAndCreateMenu(index, options, menus, 
menuId)
-                                contextMenu = menus[menuId]
-                            } else {
-                                contextMenu = 
rebootOptionsComponent.createObject(rebootButton)
-
-                                for (var index = 0; index < options.length; 
++index) {
-                                    var itemData = new Object
-                                    itemData["itemIndex"] = index
-                                    itemData["itemText"] = options[index]
-                                    itemData["itemSubMenu"] = null
-                                    itemData["itemAllowAmpersand"] = true
-                                    if (index == rebootOptions["default"]) {
-                                        itemData["itemText"] += i18nc("default 
option in boot loader", " (default)")
-                                    }
-                                    contextMenu.append(itemData)
-                                }
-                                
contextMenu.clicked.connect(shutdownUi.rebootRequested2)
-                            }
-                        }
-                        contextMenu.open()
-                    }
+//                     onPressAndHold: {
+//                         if (!menu) {
+//                             return
+//                         }
+//                         if (!contextMenu) {
+//                             var options = rebootOptions["options"]
+//                             //console.log("bootManager == " + bootManager)
+//
+//                             if (bootManager === "Grub2" || bootManager === 
"Burg") {
+//                                 // javascript passes primitive types by 
value, I need this one passed by reference.
+//                                 function Index() { this.value = 0 }
+//                                 var index = new Index()
+//                                 var menus = {}
+//                                 var menuId = ""
+//
+//                                 // starts backwards so that the top of the 
stack is the first menu entry.
+//                                 index.value = options.length - 1
+//                                 menus[menuId] = 
rebootOptionsComponent.createObject(rebootButton)
+//                                 
menus[menuId].clicked.connect(shutdownUi.rebootRequested2)
+//                                 findAndCreateMenu(index, options, menus, 
menuId)
+//                                 contextMenu = menus[menuId]
+//                             } else {
+//                                 contextMenu = 
rebootOptionsComponent.createObject(rebootButton)
+//
+//                                 for (var index = 0; index < options.length; 
++index) {
+//                                     var itemData = new Object
+//                                     itemData["itemIndex"] = index
+//                                     itemData["itemText"] = options[index]
+//                                     itemData["itemSubMenu"] = null
+//                                     itemData["itemAllowAmpersand"] = true
+//                                     if (index == rebootOptions["default"]) {
+//                                         itemData["itemText"] += 
i18nc("default option in boot loader", " (default)")
+//                                     }
+//                                     contextMenu.append(itemData)
+//                                 }
+//                                 
contextMenu.clicked.connect(shutdownUi.rebootRequested2)
+//                             }
+//                         }
+//                         contextMenu.open()
+//                     }
 
                     onActiveFocusChanged: {
                         shutdownUi.focusedButton = rebootButton
@@ -431,14 +431,14 @@ PlasmaCore.FrameSvgItem {
                 }
             }
 
-            KSMButton {
+            PlasmaComponents.Button {
                 id: cancelButton
                 anchors.right: parent.right
                 text: i18n("&Cancel")
                 iconSource: "dialog-cancel"
-                smallButton: true
-                tabStopNext: logoutButton
-                tabStopBack: rebootButton
+//                 smallButton: true
+//                 tabStopNext: logoutButton
+//                 tabStopBack: rebootButton
 
                 onClicked: {
                     cancelRequested()

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

Reply via email to