[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/sysadmin/kpackagekit
From:       Trever Fischer <wm161 () wm161 ! net>
Date:       2009-02-03 19:02:09
Message-ID: 1233687729.592648.32432.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 920767 by tdfischer:

Added a "TransactionBar" widget to the common library.
Replaced the search status bar in the AddRm page with it.

KpkTransactionBar gives the user feedback for simple operations like
a search's progress or loading the list of repositories.

 M  +8 -111    AddRm/KpkAddRm.cpp  
 M  +0 -4      AddRm/KpkAddRm.h  
 M  +7 -33     AddRm/KpkAddRm.ui  
 M  +1 -1      Settings/CMakeLists.txt  
 M  +4 -0      Settings/KpkSettings.cpp  
 M  +11 -0     Settings/KpkSettings.ui  
 M  +4 -0      Updater/KpkUpdate.cpp  
 M  +10 -1     Updater/KpkUpdate.ui  
 M  +1 -0      libkpackagekit/CMakeLists.txt  
 A             libkpackagekit/KpkTransactionBar.cpp   [License: GPL (v2+) (wrong \
address)]  A             libkpackagekit/KpkTransactionBar.h   [License: GPL (v2+) \
(wrong address)]


--- trunk/playground/sysadmin/kpackagekit/AddRm/KpkAddRm.cpp #920766:920767
@@ -135,15 +135,13 @@
     filterMenu(m_client->getFilters());
     filtersTB->setIcon(m_filterIcon);
 
-    // connect the notify
-    connect(&m_notifyT, SIGNAL(timeout()), this, SLOT(notifyUpdate()));
-
     // set fucus on the search lineEdit
     searchKLE->setFocus(Qt::OtherFocusReason);
 
     // hides the description to have more space.
     descriptionDW->setVisible(false);
-    notifyF->hide();
+    
+    transactionBar->setBehaviors(KpkTransactionBar::AutoHide);
 }
 
 void KpkAddRm::actionFindNameK()
@@ -192,6 +190,7 @@
         this, SLOT( description(PackageKit::Package *) ) );
     connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
 	this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
+    transactionBar->addTransaction(t);
 }
 
 void KpkAddRm::getFiles(PackageKit::Package *p)
@@ -202,6 +201,7 @@
 	this, SLOT( files(PackageKit::Package *, const QStringList &) ) );
     connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
 	this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
+    transactionBar->addTransaction(t);
 }
 
 void KpkAddRm::getDepends(PackageKit::Package *p)
@@ -213,6 +213,7 @@
 	m_pkg_model_dep, SLOT( addPackage(PackageKit::Package *) ) );
     connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
 	this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
+    transactionBar->addTransaction(t);
 }
 
 void KpkAddRm::getRequires(PackageKit::Package *p)
@@ -224,6 +225,7 @@
 	m_pkg_model_req, SLOT( addPackage(PackageKit::Package *) ) );
     connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
 	this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
+    transactionBar->addTransaction(t);
 }
 
 void KpkAddRm::getInfoFinished(PackageKit::Transaction::ExitStatus status, uint \
runtime) @@ -242,19 +244,6 @@
     }
 }
 
-void KpkAddRm::statusChanged(PackageKit::Transaction::Status status)
-{
-    notifyF->show();
-    notifyL->setText( KpkStrings::status(status) );
-    busyPB->setMaximum(0);
-}
-
-void KpkAddRm::progressChanged(PackageKit::Transaction::ProgressInfo info)
-{
-    busyPB->setMaximum(100);
-    busyPB->setValue(info.percentage);
-}
-
 void KpkAddRm::errorCode(PackageKit::Client::ErrorType error, const QString \
&details)  {
     KMessageBox::detailedSorry( this, KpkStrings::errorMessage(error), details, \
KpkStrings::error(error), KMessageBox::Notify ); @@ -410,25 +399,14 @@
     }
 
     connectTransaction(m_pkClient_main);
-    statusChanged( m_pkClient_main->status() );
+    transactionBar->addTransaction(m_pkClient_main);
     // hides the description to have more space.
     descriptionDW->setVisible(false);
-    notifyF->hide();
     // cleans the models
     m_pkg_model_main->clear();
-    busyPB->setMaximum(0);
-    busyPB->setValue(0);
     m_mTransRuning = true;
-    setActionCancel(false);
 }
 
-void KpkAddRm::setActionCancel(bool enabled)
-{
-    m_currentAction->setText(i18n("&Cancel"));
-    m_currentAction->setIcon(m_cancelIcon);
-    m_currentAction->setEnabled(enabled);
-}
-
 void KpkAddRm::connectTransaction(Transaction *transaction)
 {
     connect( transaction, SIGNAL( package(PackageKit::Package *)),
@@ -437,14 +415,6 @@
 	this, SLOT( finished(PackageKit::Transaction::ExitStatus, uint)) );
     connect( transaction, SIGNAL( errorCode(PackageKit::Client::ErrorType, const \
QString&) ),  this, SLOT( errorCode(PackageKit::Client::ErrorType, const QString &) ) \
                );
-    connect( transaction, SIGNAL( message(PackageKit::Client::MessageType, const \
                QString&) ),
-	this, SLOT( message(PackageKit::Client::MessageType, const QString &) ) );
-    connect( transaction, SIGNAL( statusChanged(PackageKit::Transaction::Status) ),
-	this, SLOT( statusChanged(PackageKit::Transaction::Status) ) );
-    connect( transaction, SIGNAL( allowCancelChanged(bool) ),
-	m_currentAction, SLOT( setEnabled(bool) ) );
-    connect( transaction, SIGNAL( \
                progressChanged(PackageKit::Transaction::ProgressInfo) ),
-	this, SLOT( progressChanged(PackageKit::Transaction::ProgressInfo) ) );
 }
 
 void KpkAddRm::message(PackageKit::Client::MessageType message, const QString \
&details) @@ -470,83 +440,10 @@
 
 void KpkAddRm::finished(PackageKit::Transaction::ExitStatus status, uint runtime)
 {
-    notifyF->show();
-    QPalette teste;
-    busyPB->setMaximum(100);
-    busyPB->setValue(100);
+    Q_UNUSED(runtime)
     m_mTransRuning = false;
-    m_currentAction->setEnabled(true);
-    m_currentAction->setIcon(m_findIcon);
-    setActionsDefaults();
-    switch(status) {
-        case Transaction::Success :
-	    notifyL->setText(i18n("Search finished in %1", \
                KGlobal::locale()->formatDuration(runtime)) );
-            teste.setColor( QPalette::Normal, QPalette::Window, \
                QColor(0,255,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(100);
-	    break;
-	case Transaction::Failed :
-	    notifyL->setText(i18n("Search failed"));
-            teste.setColor(QPalette::Normal, QPalette::Window, QColor(255,0,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(50);
-	    break;
-	case Transaction::Cancelled :
-            notifyL->setText(i18n("Search canceled"));
-            teste.setColor( QPalette::Normal, QPalette::Window, \
                QColor(0,255,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(100);
-            break;
-	case Transaction::KeyRequired :
-            notifyL->setText(i18n("Search finished in \
                %1",KGlobal::locale()->formatDuration(runtime)) );
-            teste.setColor( QPalette::Normal, QPalette::Window, \
                QColor(0,255,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(100);
-            break;
-	case Transaction::EulaRequired :
-            notifyL->setText(i18n("Search finished in %1", \
                KGlobal::locale()->formatDuration(runtime)) );
-            teste.setColor( QPalette::Normal, QPalette::Window, \
                QColor(0,255,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(100);
-            break;
-	case Transaction::Killed :
-            notifyL->setText(i18n("Search killed"));
-            teste.setColor( QPalette::Normal, QPalette::Window, \
                QColor(0,255,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(100);
-            break;
-	case Transaction::UnknownExitStatus :
-            notifyL->setText(i18n("Search finished with unknown status"));
-            teste.setColor( QPalette::Normal, QPalette::Window, \
                QColor(0,255,0,150));
-            notifyL->setPalette(teste);
-            notifyL->setAutoFillBackground(true);
-            m_notifyT.start(100);
-            break;
-    }
 }
 
-void KpkAddRm::notifyUpdate()
-{
-    QPalette palleteN(notifyL->palette());
-    QColor colorN(palleteN.color(QPalette::Normal, QPalette::Window));
-    if ( colorN.alpha() <= 0 ) {
-        m_notifyT.stop();
-        notifyL->setAutoFillBackground(false);
-        notifyF->hide();
-    }
-    else {
-        colorN.setAlpha(colorN.alpha() - 5);
-        palleteN.setColor(QPalette::Normal, QPalette::Window, colorN);
-        notifyL->setPalette(palleteN);
-    }
-}
-
 void KpkAddRm::description(PackageKit::Package *p)
 {
     //format and show description
--- trunk/playground/sysadmin/kpackagekit/AddRm/KpkAddRm.h #920766:920767
@@ -71,10 +71,7 @@
     void finished(PackageKit::Transaction::ExitStatus status, uint runtime);
     void message(PackageKit::Client::MessageType message, const QString &details);
     void errorCode(PackageKit::Client::ErrorType error, const QString &detail);
-    void statusChanged(PackageKit::Transaction::Status status);
 
-    void notifyUpdate();
-    void progressChanged(PackageKit::Transaction::ProgressInfo info);
     void checkChanged();
 
     void packageViewSetRootIsDecorated(bool value);
@@ -99,7 +96,6 @@
     Client *m_client;
     Transaction *m_pkClient_main;
 
-    QTimer m_notifyT;
     QMenu *m_filtersQM;
     KIcon m_findIcon;
     KIcon m_cancelIcon;
--- trunk/playground/sysadmin/kpackagekit/AddRm/KpkAddRm.ui #920766:920767
@@ -236,40 +236,8 @@
       <property name="spacing" >
        <number>0</number>
       </property>
-      <item row="0" column="1" >
-       <widget class="QLabel" name="notifyL" >
-        <property name="sizePolicy" >
-         <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="autoFillBackground" >
-         <bool>false</bool>
-        </property>
-        <property name="text" >
-         <string>Notify</string>
-        </property>
-        <property name="wordWrap" >
-         <bool>true</bool>
-        </property>
-        <property name="indent" >
-         <number>5</number>
-        </property>
-       </widget>
-      </item>
       <item row="0" column="0" >
-       <widget class="QProgressBar" name="busyPB" >
-        <property name="sizePolicy" >
-         <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="maximum" >
-         <number>0</number>
-        </property>
-       </widget>
+       <widget class="KpkTransactionBar" native="1" name="transactionBar" />
       </item>
      </layout>
     </widget>
@@ -321,6 +289,12 @@
    <extends>QTextBrowser</extends>
    <header>ktextbrowser.h</header>
   </customwidget>
+  <customwidget>
+   <class>KpkTransactionBar</class>
+   <extends>QWidget</extends>
+   <header location="global" >KpkTransactionBar.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>searchKLE</tabstop>
--- trunk/playground/sysadmin/kpackagekit/Settings/CMakeLists.txt #920766:920767
@@ -8,6 +8,6 @@
 )
 
 kde4_add_plugin(kcm_kpk_settings ${kpk_settings_SRCS})
-target_link_libraries(kcm_kpk_settings ${KDE4_KDEUI_LIBS} ${QPACKAGEKIT_LIB})
+target_link_libraries(kcm_kpk_settings ${KDE4_KDEUI_LIBS} ${QPACKAGEKIT_LIB} \
kpackagekitlib)  
 install(TARGETS kcm_kpk_settings  DESTINATION ${PLUGIN_INSTALL_DIR} )
--- trunk/playground/sysadmin/kpackagekit/Settings/KpkSettings.cpp #920766:920767
@@ -25,6 +25,7 @@
 #include <KConfig>
 #include <KLocale>
 #include <KMessageBox>
+#include <KpkTransactionBar.h>
 
 using namespace PackageKit;
 
@@ -33,6 +34,7 @@
 {
     setupUi( this );
 
+    transactionBar->setBehaviors(KpkTransactionBar::AutoHide);
     Client::instance()->setLocale(KGlobal::locale()->language() + "." + \
KGlobal::locale()->encoding());  m_actions = Client::instance()->getActions();
 
@@ -80,6 +82,7 @@
     connect(m_trasaction, SIGNAL(finished(PackageKit::Transaction::ExitStatus, \
uint)),  m_originModel, SLOT(finished()));
     connect(m_originModel, SIGNAL(stateChanged()), this, SLOT(checkChanges()));
+    transactionBar->addTransaction(m_trasaction);
 }
 
 void KpkSettings::checkChanges()
@@ -140,6 +143,7 @@
         connect(m_trasaction, SIGNAL(finished(PackageKit::Transaction::ExitStatus, \
uint)),  m_originModel, SLOT(finished()));
         connect(m_originModel, SIGNAL(stateChanged()), this, SLOT(checkChanges()));
+        transactionBar->addTransaction(m_trasaction);
     }
 }
 
--- trunk/playground/sysadmin/kpackagekit/Settings/KpkSettings.ui #920766:920767
@@ -135,11 +135,22 @@
         </property>
        </widget>
       </item>
+      <item row="2" column="0" >
+       <widget class="KpkTransactionBar" native="1" name="transactionBar" />
+      </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KpkTransactionBar</class>
+   <extends>QWidget</extends>
+   <header location="global" >KpkTransactionBar.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>
--- trunk/playground/sysadmin/kpackagekit/Updater/KpkUpdate.cpp #920766:920767
@@ -28,6 +28,7 @@
 #include <solid/powermanagement.h>
 #include <solid/device.h>
 #include <solid/acadapter.h>
+#include <KpkTransactionBar.h>
 
 #define UNIVERSAL_PADDING 6
 
@@ -42,6 +43,7 @@
     updatePB->setIcon(KIcon("package-update"));
     refreshPB->setIcon(KIcon("view-refresh"));
     historyPB->setIcon(KIcon("view-history"));
+    transactionBar->setBehaviors(KpkTransactionBar::AutoHide);
 
     Client::instance()->setLocale(KGlobal::locale()->language() + "." + \
KGlobal::locale()->encoding());  
@@ -245,11 +247,13 @@
         m_pkg_model_updates->clear();
         m_pkg_model_updates->uncheckAll();
         m_updatesT = m_client->getUpdates();
+        transactionBar->addTransaction(m_updatesT);
         connect(m_updatesT, SIGNAL(package(PackageKit::Package *)),
                 m_pkg_model_updates, SLOT(addPackage(PackageKit::Package *)));
         connect(m_updatesT, SIGNAL(errorCode(PackageKit::Client::ErrorType, const \
                QString &)),
                 this, SLOT(errorCode(PackageKit::Client::ErrorType, const QString \
&)));  Transaction* t = m_client->getDistroUpgrades();
+        transactionBar->addTransaction(t);
         connect(t,
                  SIGNAL( distroUpgrade( PackageKit::Client::UpgradeType, const \
                QString&, const QString& ) ),
              this, SLOT( distroUpgrade(PackageKit::Client::UpgradeType, const \
                QString&, const QString& ) ) );
--- trunk/playground/sysadmin/kpackagekit/Updater/KpkUpdate.ui #920766:920767
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>449</width>
-    <height>410</height>
+    <height>423</height>
    </rect>
   </property>
   <property name="locale" >
@@ -119,6 +119,9 @@
     </widget>
    </item>
    <item>
+    <widget class="KpkTransactionBar" native="1" name="transactionBar" />
+   </item>
+   <item>
     <layout class="QHBoxLayout" name="horizontalLayout_2" >
      <item>
       <widget class="KPushButton" name="updatePB" >
@@ -161,6 +164,12 @@
    <extends>QWidget</extends>
    <header>ktitlewidget.h</header>
   </customwidget>
+  <customwidget>
+   <class>KpkTransactionBar</class>
+   <extends>QWidget</extends>
+   <header location="global" >KpkTransactionBar.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
--- trunk/playground/sysadmin/kpackagekit/libkpackagekit/CMakeLists.txt \
#920766:920767 @@ -6,6 +6,7 @@
   KpkLicenseAgreement.cpp
   KpkPackageModel.cpp
   KpkIcons.cpp
+  KpkTransactionBar.cpp
 )
 
 kde4_add_ui_files(libkpk_SRCS


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic