1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "progressloggergui.h"
22 ProgressLoggerGui::ProgressLoggerGui(QWidget
* parent
): ProgressloggerInterface(parent
)
24 downloadProgress
= new QDialog(parent
);
25 downloadProgress
->setModal(true);
26 dp
.setupUi(downloadProgress
);
27 dp
.listProgress
->setAlternatingRowColors(true);
31 void ProgressLoggerGui::addItem(const QString
&text
)
33 addItem(text
, LOGNOICON
);
36 void ProgressLoggerGui::addItem(const QString
&text
, int flag
)
38 QListWidgetItem
* item
= new QListWidgetItem(text
);
45 item
->setIcon(QIcon(":/icons/go-next.png"));
48 item
->setIcon(QIcon(":/icons/dialog-information.png"));
51 item
->setIcon(QIcon(":/icons/dialog-warning.png"));
54 item
->setIcon(QIcon(":/icons/dialog-error.png"));
58 dp
.listProgress
->addItem(item
);
59 dp
.listProgress
->scrollToItem(item
);
62 void ProgressLoggerGui::setProgress(int value
, int max
)
64 // set maximum first to avoid setting a value outside of the max range.
65 // If the current value is outside of the valid range QProgressBar
66 // calls reset() internally.
68 setProgressValue(value
);
72 void ProgressLoggerGui::setProgressValue(int value
)
74 dp
.progressBar
->setValue(value
);
77 void ProgressLoggerGui::setProgressMax(int max
)
79 dp
.progressBar
->setMaximum(max
);
82 int ProgressLoggerGui::getProgressMax()
84 return dp
.progressBar
->maximum();
87 void ProgressLoggerGui::setProgressVisible(bool b
)
89 dp
.progressBar
->setVisible(b
);
93 /** Set logger into "running" state -- the reporting process is still running.
94 * Display "Abort" and emit the aborted() signal on button press.
96 void ProgressLoggerGui::setRunning()
98 dp
.buttonAbort
->setText(tr("&Abort"));
99 dp
.buttonAbort
->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
101 // make sure to not close the window on button press.
102 disconnect(dp
.buttonAbort
, SIGNAL(clicked()), downloadProgress
, SLOT(close()));
103 // emit aborted() once button is pressed but not closed().
104 disconnect(dp
.buttonAbort
, SIGNAL(clicked()), this, SIGNAL(closed()));
105 connect(dp
.buttonAbort
, SIGNAL(clicked()), this, SIGNAL(aborted()));
110 /** Set logger into "finished" state -- the reporting process is finished.
111 * Display "Ok". Don't emit aborted() as there is nothing running left.
112 * Close logger on button press and emit closed().
114 void ProgressLoggerGui::setFinished()
116 dp
.buttonAbort
->setText(tr("&Ok"));
117 dp
.buttonAbort
->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
119 // close the window on button press.
120 connect(dp
.buttonAbort
, SIGNAL(clicked()), downloadProgress
, SLOT(close()));
121 // emit closed() once button is pressed but not aborted().
122 disconnect(dp
.buttonAbort
, SIGNAL(clicked()), this, SIGNAL(aborted()));
123 connect(dp
.buttonAbort
, SIGNAL(clicked()), this, SIGNAL(closed()));
127 void ProgressLoggerGui::close()
129 downloadProgress
->close();
132 void ProgressLoggerGui::show()
134 downloadProgress
->show();