* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "viewpropsprogressinfo.h"
#include "applyviewpropsjob.h"
#include "viewproperties.h"
-#include <QLabel>
-#include <QProgressBar>
-#include <QTimer>
-#include <QVBoxLayout>
+#include <QtGui/QLabel>
+#include <QtGui/QProgressBar>
+#include <QtCore/QTimer>
+#include <QtGui/QBoxLayout>
#include <assert.h>
#include <klocale.h>
-#include <kurl.h>
#include <kio/jobclasses.h>
ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
const KUrl& dir,
- const ViewProperties* viewProps) :
+ const ViewProperties& viewProps) :
KDialog(parent),
m_dir(dir),
- m_viewProps(viewProps),
+ m_viewProps(0),
m_label(0),
m_progressBar(0),
m_dirSizeJob(0),
m_applyViewPropsJob(0),
m_timer(0)
{
- setCaption(i18n("Applying view properties"));
+ const QSize minSize = minimumSize();
+ setMinimumSize(QSize(320, minSize.height()));
+
+ setCaption(i18nc("@title:window", "Applying View Properties"));
setButtons(KDialog::Cancel);
+ m_viewProps = new ViewProperties(dir);
+ m_viewProps->setDirProperties(viewProps);
+
+ // the view properties are stored by the ViewPropsApplierJob, so prevent
+ // that the view properties are saved twice:
+ m_viewProps->setAutoSaveEnabled(false);
+
QWidget* main = new QWidget();
QVBoxLayout* topLayout = new QVBoxLayout();
- m_label = new QLabel(i18n("Counting folders: %1", 0), main);
+ m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), main);
m_progressBar = new QProgressBar(main);
+ m_progressBar->setMinimum(0);
+ m_progressBar->setMaximum(0);
+ m_progressBar->setValue(0);
topLayout->addWidget(m_label);
topLayout->addWidget(m_progressBar);
}
ViewPropsProgressInfo::~ViewPropsProgressInfo()
+{
+ delete m_viewProps;
+ m_viewProps = 0;
+}
+
+void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
{
m_timer->stop();
+ m_applyViewPropsJob = 0;
+ KDialog::closeEvent(event);
}
void ViewPropsProgressInfo::updateProgress()
{
if (m_dirSizeJob != 0) {
const int subdirs = m_dirSizeJob->totalSubdirs();
- m_label->setText(i18n("Counting folders: %1", subdirs));
+ m_label->setText(i18nc("@info:progress", "Counting folders: %1", subdirs));
}
- else {
- assert(m_applyViewPropsJob != 0);
+
+ if (m_applyViewPropsJob != 0) {
const int progress = m_applyViewPropsJob->progress();
m_progressBar->setValue(progress);
}
}
const int subdirs = m_dirSizeJob->totalSubdirs();
- m_label->setText(i18n("Folders: %1", subdirs));
+ m_label->setText(i18nc("@info:progress", "Folders: %1", subdirs));
m_progressBar->setMaximum(subdirs);
m_dirSizeJob = 0;
void ViewPropsProgressInfo::cancelApplying()
{
if (m_dirSizeJob != 0) {
- m_dirSizeJob->doKill();
+ m_dirSizeJob->kill();
}
- else {
- assert(m_applyViewPropsJob != 0);
- m_applyViewPropsJob->doKill();
+
+ if (m_applyViewPropsJob != 0) {
+ m_applyViewPropsJob->kill();
}
}