From kde-commits Fri Oct 25 12:25:18 2013 From: Konstantinos Smanis Date: Fri, 25 Oct 2013 12:25:18 +0000 To: kde-commits Subject: [kcm-grub2] /: Do not prompt for password if the only request is for VBE resolutions. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138270392709401 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_resolutionsEmpt= y); ui->kcombobox_gfxpayload->setCurrentIndex(ui->kcombobox_gfxpayload->fi= ndData(grubGfxpayloadLinux)); + ui->toolButton_refreshGfxpayload->setVisible(HAVE_HD && m_resolutionsE= mpty); = QString grubColorNormal =3D 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 installDlg =3D new InstallDialog(this); - installDlg->exec(); - delete installDlg; -} void KCMGRUB2::slotGrubGfxmodeChanged() { if (ui->kcombobox_gfxmode->currentIndex() =3D=3D 0) { @@ -620,6 +616,11 @@ void KCMGRUB2::slotGrubGfxpayloadLinuxChanged() m_dirtyBits.setBit(grubGfxpayloadLinuxDirty); Q_EMIT changed(true); } +void KCMGRUB2::slotResolutionsRefresh() +{ + m_resolutionsForceRead =3D 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 installDlg =3D 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 =3D true; + m_resolutionsForceRead =3D false; = QTreeView *view =3D 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-refre= sh"))); + ui->toolButton_refreshGfxpayload->setIcon(KIcon(QLatin1String("view-re= fresh"))); + 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("@a= ction:inmenu 'Open' is an adjective here, not a verb. 'Open Firmware' is a = former IEEE standard.", "Open Firmware Console"))->setData(QLatin1String("o= fconsole")); ui->kpushbutton_terminalOutputSuggestions->menu()->addAction(i18nc("@a= ction:inmenu", "Graphics Mode Output"))->setData(QLatin1String("gfxterm")); ui->kpushbutton_terminalOutputSuggestions->menu()->addAction(i18nc("@a= ction:inmenu", "VGA Text Output (Coreboot)"))->setData(QLatin1String("vga_t= ext")); + + 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(slotG= rubDisableOsProberChanged())); = connect(ui->kcombobox_gfxmode, SIGNAL(activated(int)), this, SLOT(slot= GrubGfxmodeChanged())); + connect(ui->toolButton_refreshGfxmode, SIGNAL(clicked(bool)), this, SL= OT(slotResolutionsRefresh())); connect(ui->kcombobox_gfxpayload, SIGNAL(activated(int)), this, SLOT(s= lotGrubGfxpayloadLinuxChanged())); + 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 |=3D MemtestFile; } #if HAVE_HD - operations |=3D Vbe; + if (m_resolutionsEmpty) { + operations |=3D Vbe; + } #endif if (QFileInfo(QString::fromUtf8(GRUB_LOCALE)).isReadable()) { m_locales =3D QDir(QString::fromUtf8(GRUB_LOCALE)).entryList(QStri= ngList() << QLatin1String("*.mo"), QDir::Files).replaceInStrings(QRegExp(QL= atin1String("\\.mo$")), QString()); @@ -997,7 +1014,8 @@ void KCMGRUB2::readAll() operations |=3D Locales; } = - if (operations) { + //Do not prompt for password if only the VBE operation is required, un= less 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)(operatio= ns)); @@ -1049,6 +1067,8 @@ void KCMGRUB2::readAll() } if (operations.testFlag(Vbe)) { m_resolutions =3D reply.data().value(QLatin1String("gfxmodes")= ).toStringList(); + m_resolutionsEmpty =3D false; + m_resolutionsForceRead =3D false; } if (operations.testFlag(Locales)) { m_locales =3D reply.data().value(QLatin1String("locales")).toS= tringList(); 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 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 @@ - - - QComboBox::AdjustToContents - - + + + + + QComboBox::AdjustToContents + + + + + + + Probe for supported VBE r= esolutions. + + + true + + + + @@ -286,11 +300,25 @@ - - - QComboBox::AdjustToContents - - + + + + + QComboBox::AdjustToContents + + + + + + + Probe for supported VBE r= esolutions. + + + true + + + +