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

List:       kde-commits
Subject:    [kcm-grub2] /: Do not prompt for password if the only request is for VBE resolutions.
From:       Konstantinos Smanis <konstantinos.smanis () gmail ! com>
Date:       2013-10-25 12:25:18
Message-ID: E1VZgS6-0003Sd-La () scm ! kde ! org
[Download RAW message or body]

Git commit aa8180a97090f30fec138ec1c3129ec4d54c4195 by Konstantinos Smanis.
Committed on 25/10/2013 at 12:20.
Pushed by ksmanis into branch 'master'.

Do not prompt for password if the only request is for VBE resolutions.

In the above case provide additional buttons that can probe for the VBE
supported resolutions.

If other requests are made along with VBE resolutions (e.g. menu file,
config file, locales etc.) we can't avoid the password dialog so fetch
them all together.

Also if the VBE resolutions are fetched, the helper won't be queried for
them again.

M  +29   -9    src/kcm_grub2.cpp
M  +4    -1    src/kcm_grub2.h
M  +38   -10   ui/kcm_grub2.ui

http://commits.kde.org/kcm-grub2/aa8180a97090f30fec138ec1c3129ec4d54c4195

diff --git a/src/kcm_grub2.cpp b/src/kcm_grub2.cpp
index 1752903..5832960 100644
--- a/src/kcm_grub2.cpp
+++ b/src/kcm_grub2.cpp
@@ -212,7 +212,9 @@ void KCMGRUB2::load()
     sortResolutions();
     showResolutions();
     ui->kcombobox_gfxmode->setCurrentIndex(ui->kcombobox_gfxmode->findData(grubGfxmode));
 +    ui->toolButton_refreshGfxmode->setVisible(HAVE_HD && m_resolutionsEmpty);
     ui->kcombobox_gfxpayload->setCurrentIndex(ui->kcombobox_gfxpayload->findData(grubGfxpayloadLinux));
 +    ui->toolButton_refreshGfxpayload->setVisible(HAVE_HD && m_resolutionsEmpty);
 
     QString grubColorNormal = \
unquoteWord(m_settings.value(QLatin1String("GRUB_COLOR_NORMAL")));  if \
(!grubColorNormal.isEmpty()) { @@ -570,12 +572,6 @@ void \
KCMGRUB2::slotGrubDisableOsProberChanged()  \
m_dirtyBits.setBit(grubDisableOsProberDirty);  Q_EMIT changed(true);
 }
-void KCMGRUB2::slotInstallBootloader()
-{
-    QPointer<InstallDialog> installDlg = new InstallDialog(this);
-    installDlg->exec();
-    delete installDlg;
-}
 void KCMGRUB2::slotGrubGfxmodeChanged()
 {
     if (ui->kcombobox_gfxmode->currentIndex() == 0) {
@@ -620,6 +616,11 @@ void KCMGRUB2::slotGrubGfxpayloadLinuxChanged()
     m_dirtyBits.setBit(grubGfxpayloadLinuxDirty);
     Q_EMIT changed(true);
 }
+void KCMGRUB2::slotResolutionsRefresh()
+{
+    m_resolutionsForceRead = true;
+    load();
+}
 void KCMGRUB2::slotGrubColorNormalChanged()
 {
     m_dirtyBits.setBit(grubColorNormalDirty);
@@ -717,6 +718,12 @@ void KCMGRUB2::slotGrubDisableLinuxUuidChanged()
     m_dirtyBits.setBit(grubDisableLinuxUuidDirty);
     Q_EMIT changed(true);
 }
+void KCMGRUB2::slotInstallBootloader()
+{
+    QPointer<InstallDialog> installDlg = new InstallDialog(this);
+    installDlg->exec();
+    delete installDlg;
+}
 
 void KCMGRUB2::slotUpdateSuggestions()
 {
@@ -784,6 +791,8 @@ void KCMGRUB2::setupObjects()
     setNeedsAuthorization(true);
 
     m_dirtyBits.resize(lastDirtyBit);
+    m_resolutionsEmpty = true;
+    m_resolutionsForceRead = false;
 
     QTreeView *view = new QTreeView(ui->kcombobox_default);
     view->setHeaderHidden(true);
@@ -791,10 +800,12 @@ void KCMGRUB2::setupObjects()
     view->setRootIsDecorated(false);
     ui->kcombobox_default->setView(view);
 
-    ui->kpushbutton_install->setIcon(KIcon(QLatin1String("system-software-update")));
  ui->kpushbutton_remove->setIcon(KIcon(QLatin1String("list-remove")));
     ui->kpushbutton_remove->setVisible(HAVE_QAPT || HAVE_QPACKAGEKIT);
 
+    ui->toolButton_refreshGfxmode->setIcon(KIcon(QLatin1String("view-refresh")));
+    ui->toolButton_refreshGfxpayload->setIcon(KIcon(QLatin1String("view-refresh")));
+
     QPixmap black(16, 16), transparent(16, 16);
     black.fill(Qt::black);
     transparent.fill(Qt::transparent);
@@ -887,6 +898,8 @@ void KCMGRUB2::setupObjects()
     ui->kpushbutton_terminalOutputSuggestions->menu()->addAction(i18nc("@action:inmenu \
'Open' is an adjective here, not a verb. 'Open Firmware' is a former IEEE standard.", \
                "Open Firmware Console"))->setData(QLatin1String("ofconsole"));
     ui->kpushbutton_terminalOutputSuggestions->menu()->addAction(i18nc("@action:inmenu", \
                "Graphics Mode Output"))->setData(QLatin1String("gfxterm"));
     ui->kpushbutton_terminalOutputSuggestions->menu()->addAction(i18nc("@action:inmenu", \
"VGA Text Output (Coreboot)"))->setData(QLatin1String("vga_text")); +
+    ui->kpushbutton_install->setIcon(KIcon(QLatin1String("system-software-update")));
  }
 void KCMGRUB2::setupConnections()
 {
@@ -912,7 +925,9 @@ void KCMGRUB2::setupConnections()
     connect(ui->checkBox_osProber, SIGNAL(clicked(bool)), this, \
SLOT(slotGrubDisableOsProberChanged()));  
     connect(ui->kcombobox_gfxmode, SIGNAL(activated(int)), this, \
SLOT(slotGrubGfxmodeChanged())); +    connect(ui->toolButton_refreshGfxmode, \
                SIGNAL(clicked(bool)), this, SLOT(slotResolutionsRefresh()));
     connect(ui->kcombobox_gfxpayload, SIGNAL(activated(int)), this, \
SLOT(slotGrubGfxpayloadLinuxChanged())); +    \
connect(ui->toolButton_refreshGfxpayload, SIGNAL(clicked(bool)), this, \
SLOT(slotResolutionsRefresh()));  
     connect(ui->kcombobox_normalForeground, SIGNAL(activated(int)), this, \
                SLOT(slotGrubColorNormalChanged()));
     connect(ui->kcombobox_normalBackground, SIGNAL(activated(int)), this, \
SLOT(slotGrubColorNormalChanged())); @@ -989,7 +1004,9 @@ void KCMGRUB2::readAll()
         operations |= MemtestFile;
     }
 #if HAVE_HD
-    operations |= Vbe;
+    if (m_resolutionsEmpty) {
+        operations |= Vbe;
+    }
 #endif
     if (QFileInfo(QString::fromUtf8(GRUB_LOCALE)).isReadable()) {
         m_locales = QDir(QString::fromUtf8(GRUB_LOCALE)).entryList(QStringList() << \
QLatin1String("*.mo"), \
QDir::Files).replaceInStrings(QRegExp(QLatin1String("\\.mo$")), QString()); @@ -997,7 \
+1014,8 @@ void KCMGRUB2::readAll()  operations |= Locales;
     }
 
-    if (operations) {
+    //Do not prompt for password if only the VBE operation is required, unless \
forced. +    if (operations && ((operations & (~Vbe)) || m_resolutionsForceRead)) {
         Action loadAction(QLatin1String("org.kde.kcontrol.kcmgrub2.load"));
         loadAction.setHelperID(QLatin1String("org.kde.kcontrol.kcmgrub2"));
         loadAction.addArgument(QLatin1String("operations"), (int)(operations));
@@ -1049,6 +1067,8 @@ void KCMGRUB2::readAll()
         }
         if (operations.testFlag(Vbe)) {
             m_resolutions = \
reply.data().value(QLatin1String("gfxmodes")).toStringList(); +            \
m_resolutionsEmpty = false; +            m_resolutionsForceRead = false;
         }
         if (operations.testFlag(Locales)) {
             m_locales = reply.data().value(QLatin1String("locales")).toStringList();
diff --git a/src/kcm_grub2.h b/src/kcm_grub2.h
index 92b39ab..bc57d30 100644
--- a/src/kcm_grub2.h
+++ b/src/kcm_grub2.h
@@ -60,9 +60,9 @@ private Q_SLOTS:
     void slotGrubDisableRecoveryChanged();
     void slotMemtestChanged();
     void slotGrubDisableOsProberChanged();
-    void slotInstallBootloader();
     void slotGrubGfxmodeChanged();
     void slotGrubGfxpayloadLinuxChanged();
+    void slotResolutionsRefresh();
     void slotGrubColorNormalChanged();
     void slotGrubColorHighlightChanged();
     void slowGrubBackgroundChanged();
@@ -78,6 +78,7 @@ private Q_SLOTS:
     void slotGrubSerialCommandChanged();
     void slotGrubInitTuneChanged();
     void slotGrubDisableLinuxUuidChanged();
+    void slotInstallBootloader();
 
     void slotUpdateSuggestions();
     void slotTriggeredSuggestion(QAction *action);
@@ -135,6 +136,8 @@ private:
     bool m_memtestOn;
     QHash<QString, QString> m_devices;
     QStringList m_resolutions;
+    bool m_resolutionsEmpty;
+    bool m_resolutionsForceRead;
     QStringList m_locales;
 };
 
diff --git a/ui/kcm_grub2.ui b/ui/kcm_grub2.ui
index 1d84e8c..1c3238a 100644
--- a/ui/kcm_grub2.ui
+++ b/ui/kcm_grub2.ui
@@ -272,11 +272,25 @@
            </widget>
           </item>
           <item row="0" column="1">
-           <widget class="KComboBox" name="kcombobox_gfxmode">
-            <property name="sizeAdjustPolicy">
-             <enum>QComboBox::AdjustToContents</enum>
-            </property>
-           </widget>
+           <layout class="QHBoxLayout" name="horizontalLayout_8">
+            <item>
+             <widget class="KComboBox" name="kcombobox_gfxmode">
+              <property name="sizeAdjustPolicy">
+               <enum>QComboBox::AdjustToContents</enum>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QToolButton" name="toolButton_refreshGfxmode">
+              <property name="toolTip">
+               <string comment="@info:tooltip">Probe for supported VBE \
resolutions.</string> +              </property>
+              <property name="autoRaise">
+               <bool>true</bool>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
           <item row="1" column="0">
            <widget class="QLabel" name="label_gfxpayload">
@@ -286,11 +300,25 @@
            </widget>
           </item>
           <item row="1" column="1">
-           <widget class="KComboBox" name="kcombobox_gfxpayload">
-            <property name="sizeAdjustPolicy">
-             <enum>QComboBox::AdjustToContents</enum>
-            </property>
-           </widget>
+           <layout class="QHBoxLayout" name="horizontalLayout_9">
+            <item>
+             <widget class="KComboBox" name="kcombobox_gfxpayload">
+              <property name="sizeAdjustPolicy">
+               <enum>QComboBox::AdjustToContents</enum>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QToolButton" name="toolButton_refreshGfxpayload">
+              <property name="toolTip">
+               <string comment="@info:tooltip">Probe for supported VBE \
resolutions.</string> +              </property>
+              <property name="autoRaise">
+               <bool>true</bool>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </widget>


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

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