• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kio
kbuildsycocaprogressdialog.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18#include "kbuildsycocaprogressdialog.h"
19#include <ksycoca.h>
20#include <kprocess.h>
21#include <kstandarddirs.h>
22#include <klocale.h>
23#include <QtDBus/QtDBus>
24
25class KBuildSycocaProgressDialogPrivate
26{
27public:
28 KBuildSycocaProgressDialogPrivate( KBuildSycocaProgressDialog *parent )
29 : m_parent(parent)
30 {
31 }
32
33 void _k_slotProgress();
34 void _k_slotFinished();
35
36 KBuildSycocaProgressDialog *m_parent;
37 QTimer m_timer;
38 int m_timeStep;
39};
40
41void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent)
42{
43 KBuildSycocaProgressDialog dlg(parent,
44 i18n("Updating System Configuration"),
45 i18n("Updating system configuration."));
46
47 QDBusInterface kbuildsycoca("org.kde.kded", "/kbuildsycoca",
48 "org.kde.kbuildsycoca");
49 if (kbuildsycoca.isValid()) {
50 kbuildsycoca.callWithCallback("recreate", QVariantList(), &dlg, SLOT(_k_slotFinished()));
51 } else {
52 // kded not running, e.g. when using keditfiletype out of a KDE session
53 QObject::connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), &dlg, SLOT(_k_slotFinished()));
54 KProcess* proc = new KProcess(&dlg);
55 (*proc) << KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
56 proc->start();
57 }
58 dlg.exec();
59}
60
61KBuildSycocaProgressDialog::KBuildSycocaProgressDialog(QWidget *_parent,
62 const QString &_caption, const QString &text)
63 : QProgressDialog(_parent)
64 , d( new KBuildSycocaProgressDialogPrivate(this) )
65{
66 connect(&d->m_timer, SIGNAL(timeout()), this, SLOT(_k_slotProgress()));
67 setWindowTitle(_caption);
68 setModal(true);
69 setLabelText(text);
70 setRange(0, 20);
71 d->m_timeStep = 700;
72 d->m_timer.start(d->m_timeStep);
73 setAutoClose(false);
74}
75
76KBuildSycocaProgressDialog::~KBuildSycocaProgressDialog()
77{
78 delete d;
79}
80
81void KBuildSycocaProgressDialogPrivate::_k_slotProgress()
82{
83 const int p = m_parent->value();
84 if (p == 18)
85 {
86 m_parent->reset();
87 m_parent->setValue(1);
88 m_timeStep = m_timeStep * 2;
89 m_timer.start(m_timeStep);
90 }
91 else
92 {
93 m_parent->setValue(p+1);
94 }
95}
96
97void KBuildSycocaProgressDialogPrivate::_k_slotFinished()
98{
99 m_parent->setValue(20);
100 m_timer.stop();
101 QTimer::singleShot(1000, m_parent, SLOT(close()));
102}
103
104
105#include "kbuildsycocaprogressdialog.moc"
KBuildSycocaProgressDialog
Progress dialog while ksycoca is being rebuilt (by kbuildsycoca).
Definition: kbuildsycocaprogressdialog.h:32
KBuildSycocaProgressDialog::rebuildKSycoca
static void rebuildKSycoca(QWidget *parent)
Rebuild KSycoca and show a progress dialog while doing so.
Definition: kbuildsycocaprogressdialog.cpp:41
KProcess
KProcess::start
void start()
KStandardDirs::findExe
static QString findExe(const QString &appname, const QString &pathstr=QString(), SearchOptions options=NoSearchOptions)
KSycoca::self
static KSycoca * self()
QProgressDialog
QWidget
kbuildsycocaprogressdialog.h
timeout
int timeout
klocale.h
i18n
QString i18n(const char *text)
kprocess.h
kstandarddirs.h
ksycoca.h
KBUILDSYCOCA_EXENAME
#define KBUILDSYCOCA_EXENAME
close
KAction * close(const QObject *recvr, const char *slot, QObject *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal