diff options
author | Daniel Nicoletti <mirttex85-pk@yahoo.com.br> | 2008-07-04 22:55:31 -0300 |
---|---|---|
committer | Daniel Nicoletti <mirttex85-pk@yahoo.com.br> | 2008-07-04 22:55:31 -0300 |
commit | 8d7602dc26b223f6653d541544da58cc3b343756 (patch) | |
tree | 8757531e6ebd95b2f6bd9886359313d8d3a3f1cc | |
parent | ec8dcd1c5e1245b95513b796f16edcef619c54c8 (diff) |
I moved the Transaction files
-rwxr-xr-x | gui/Common/PkTransaction.cpp | 133 | ||||
-rwxr-xr-x | gui/Common/PkTransaction.h | 57 | ||||
-rw-r--r-- | gui/Common/PkTransaction.ui | 108 |
3 files changed, 298 insertions, 0 deletions
diff --git a/gui/Common/PkTransaction.cpp b/gui/Common/PkTransaction.cpp new file mode 100755 index 0000000..2892479 --- /dev/null +++ b/gui/Common/PkTransaction.cpp @@ -0,0 +1,133 @@ +/*************************************************************************** + * Copyright (C) 2008 by Daniel Nicoletti * + * dantti85-pk@yahoo.com.br * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * 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. * + ***************************************************************************/ + +#include <KLocale> +#include <KMessageBox> + +#include "../Common/PkStrings.h" +#include "PkTransaction.h" + +PkTransaction::PkTransaction( Transaction *trans, QString caption, QWidget *parent ) + : KDialog(parent), m_trans(trans) +{ + setupUi( mainWidget() ); + setCaption( caption ); + + connect( m_trans, SIGNAL( GotPackage(Package *) ), this, SLOT( currPackage(Package *) ) ); + connect( m_trans, SIGNAL( Finished(Exit::Value, uint) ), this, SLOT( Finished(Exit::Value, uint) ) ); + connect( m_trans, SIGNAL( AllowCancel(bool) ), this, SLOT( enableButtonCancel(bool) ) ); + connect( m_trans, SIGNAL( ErrorCode(Error::Value, const QString&) ), this, SLOT( ErrorCode(Error::Value, const QString&) ) ); + connect( m_trans, SIGNAL( ProgressChanged(uint, uint, uint, uint) ), this, SLOT( ProgressChanged(uint, uint, uint, uint) ) ); + connect( m_trans, SIGNAL( StatusChanged(Status::Value) ), this, SLOT( StatusChanged(Status::Value) ) ); + + // Set Cancel and custom buoton hide + setButtons( KDialog::Cancel | KDialog::User1 ); + setButtonText( KDialog::User1, i18n("Hide") ); + setButtonToolTip( KDialog::User1, i18n("Allows you to hide the window but keeps running transaction task") ); + enableButtonCancel(false); + + m_pbTimer = new QTimer(this); + connect(m_pbTimer, SIGNAL(timeout()), this, SLOT(updateProgress() )); + m_pbTimer->start(5); + setModal(true); + + // set wait msg + currentL->setText( i18n("Please Wait..." ) ); +} + +void PkTransaction::updateProgress() +{ + progressBar->setValue(progressBar->value() + 1); +} + +void PkTransaction::ProgressChanged(uint percentage, uint /*subpercentage*/, uint /*elapsed*/, uint /*remaining*/) +{ + m_pbTimer->stop(); + progressBar->setMaximum(100); + progressBar->setValue(percentage); +} + +void PkTransaction::currPackage(Package *p) +{ + packageL->setText( p->name() + " - " + p->version() + " (" + p->arch() + ")" ); + descriptionL->setText( p->summary() ); +} + +void PkTransaction::slotButtonClicked(int button) +{ + switch(button) { + case KDialog::Cancel : + m_trans->cancel(); + break; + case KDialog::User1 : + emit Finished(false); + KDialog::slotButtonClicked(KDialog::Close); + break; + case KDialog::Close : + emit Finished(true); + KDialog::slotButtonClicked(KDialog::Close); + break; + default : + KDialog::slotButtonClicked(button); + } +} + +PkTransaction::~PkTransaction() +{ + +} + +void PkTransaction::StatusChanged(Status::Value v) +{ + currentL->setText( PkStrings::StatusChanged(v) ); +} + +void PkTransaction::ErrorCode(Error::Value v, const QString &details) +{ + KMessageBox::detailedSorry( this, PkStrings::ErrorMessage(v), details, PkStrings::Error(v), KMessageBox::Notify ); +} + +void PkTransaction::Finished(Exit::Value status, uint /*runtime*/) +{ + qDebug() << "trans finished: " << status ; + switch(status) { + case Exit::Success : + qDebug() << "trans succes: "; + emit Finished(false); + KDialog::slotButtonClicked(KDialog::Close); + break; + case Exit::Failed : + qDebug() << "trans failed: "; + setButtons( KDialog::Close ); + break; + case Exit::Kill : + qDebug() << "trans quit: "; + break; + case Exit::Cancelled : + qDebug() << "trans cancelled: "; + setButtons( KDialog::Close ); + break; + case Exit::Unknown : + qDebug() << "trans quit: "; + break; + } +} + +#include "PkTransaction.moc" diff --git a/gui/Common/PkTransaction.h b/gui/Common/PkTransaction.h new file mode 100755 index 0000000..6d39f55 --- /dev/null +++ b/gui/Common/PkTransaction.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2008 by Daniel Nicoletti * + * dantti85-pk@yahoo.com.br * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * 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. * + ***************************************************************************/ + +#ifndef PKTRANSACTION_H +#define PKTRANSACTION_H + +#include <KDialog> + +#include "ui_PkTransaction.h" +#include <QPackageKit> + +using namespace PackageKit; + +class PkTransaction : public KDialog, Ui::PkTransaction +{ + Q_OBJECT +public: + PkTransaction( Transaction *trans, QString caption, QWidget *parent=0); + ~PkTransaction(); + +signals: + void Finished(bool error); + +private: + Transaction *m_trans; + QTimer *m_pbTimer; + +private slots: + void Finished(Exit::Value status, uint runtime); + void ErrorCode(Error::Value v, const QString &details); + void StatusChanged(Status::Value v); + void currPackage(Package *); + void updateProgress(); + void ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining); + +protected slots: + virtual void slotButtonClicked(int button); +}; + +#endif diff --git a/gui/Common/PkTransaction.ui b/gui/Common/PkTransaction.ui new file mode 100644 index 0000000..399644a --- /dev/null +++ b/gui/Common/PkTransaction.ui @@ -0,0 +1,108 @@ +<ui version="4.0" > + <class>PkTransaction</class> + <widget class="QWidget" name="PkTransaction" > + <property name="windowModality" > + <enum>Qt::NonModal</enum> + </property> + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>106</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize" > + <size> + <width>360</width> + <height>0</height> + </size> + </property> + <property name="windowTitle" > + <string>KPackageKit - Transaction</string> + </property> + <property name="locale" > + <locale country="UnitedStates" language="English" /> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" colspan="2" > + <widget class="QLabel" name="currentL" > + <property name="font" > + <font> + <pointsize>12</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="locale" > + <locale country="UnitedStates" language="English" /> + </property> + <property name="text" > + <string/> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2" > + <widget class="QProgressBar" name="progressBar" > + <property name="locale" > + <locale country="UnitedStates" language="English" /> + </property> + <property name="maximum" > + <number>0</number> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2" > + <widget class="QLabel" name="descriptionL" > + <property name="font" > + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text" > + <string/> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="packageL" > + <property name="text" > + <string/> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QLabel" name="timeL" > + <property name="text" > + <string/> + </property> + </widget> + </item> + <item row="4" column="0" colspan="2" > + <spacer name="verticalSpacer" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |