From 2ed8d30538b7d88be130037f38a21d8ff82244cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yunusemre=20=C5=9Eent=C3=BCrk?= Date: Mon, 21 Jan 2019 16:43:46 +0300 Subject: [PATCH] Fix condition handling issues and bring back queue dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yunusemre Şentürk --- pardus-store.pro | 3 +- src/condition.h | 21 ++ src/main.cpp | 2 + translations/pardus-store.ts | 343 ++++++++++---------------------- translations/pardus-store_tr.qm | Bin 14273 -> 12746 bytes translations/pardus-store_tr.ts | 291 +++++++++++++-------------- ui/ApplicationDelegate.qml | 75 ++++--- ui/ApplicationDetail.qml | 14 +- ui/NavigationBar.qml | 107 +++++----- ui/QueueDialog.qml | 56 ++++-- ui/main.qml | 71 +++++-- 11 files changed, 470 insertions(+), 513 deletions(-) create mode 100644 src/condition.h diff --git a/pardus-store.pro b/pardus-store.pro index a76bcd0..c4bf29b 100644 --- a/pardus-store.pro +++ b/pardus-store.pro @@ -24,7 +24,8 @@ HEADERS += \ src/singleton.h \ src/dpkg-progress.h \ src/application.h \ - src/namfactory.h + src/namfactory.h \ + src/condition.h TARGET = pardus-store diff --git a/src/condition.h b/src/condition.h new file mode 100644 index 0000000..8d8b3f9 --- /dev/null +++ b/src/condition.h @@ -0,0 +1,21 @@ +#ifndef CONDITION_H +#define CONDITION_H + +#include + +class Condition : public QObject +{ + Q_OBJECT +public: + enum State { + Idle, + Installed, + Removed, + Downloading, + Installing, + Removing + }; + Q_ENUM(State) +}; + +#endif // CONDITION_H diff --git a/src/main.cpp b/src/main.cpp index a3e6db2..c93556d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include "src/condition.h" #include "src/helper.h" #include "src/iconprovider.h" #include "src/applicationlistmodel.h" @@ -18,6 +19,7 @@ int main(int argc, char *argv[]) if (!singleton.tryToRun()) { return 0; } + qmlRegisterType("ps.condition",1,0,"Condition"); qmlRegisterType("ps.helper",1,0,"Helper"); QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); QGuiApplication::setWindowIcon(QIcon(":/images/icon.svg")); diff --git a/translations/pardus-store.ts b/translations/pardus-store.ts index 65f9828..84f50f6 100644 --- a/translations/pardus-store.ts +++ b/translations/pardus-store.ts @@ -4,53 +4,37 @@ ApplicationDelegate - - Removing - - - - - Installing - - - - - - Downloading - - - - + GET - + INSTALL - + REMOVE - + OPEN - + Download size - + Non Free - + Click for details @@ -58,219 +42,199 @@ ApplicationDetail - - home - - - - + no screenshot found! - + Disclaimer - - + + ratings - + years - + months - + days - + hours - + minutes - + seconds - - Removing - - - - - Installing - - - - - Downloading - - - - + Reminder - + First, you have to install - + Then, you can vote. - + ok - - + + not enough rating - + Your rate - + This application served from Pardus non-free package repositories, so that the OS has nothing to do with the health of the application. Install with caution. - + remove - + install - + OPEN - + more - + website - + last applied review - + no changelog data found - + changelog history - + ago - + e-mail - + information - + version - + Download size - + type - + non-free - + open source - + category - + license - + Download count - + reviews - ratings - + coming soon - + what is new - + no description found @@ -304,64 +268,50 @@ Home - + welcome - - - - all - - - - - - - categories - - - - + Editor's Pick - - - + + + no valid data found - + Most Downloaded App - + Most Rated App - + dynamic survey - + Upgrading - + send - + update @@ -388,39 +338,22 @@ NavigationBar - - - categories - - - - - + all - + This section is under development - + Anonymus Account - - installed - - - - - removed - - - - + is @@ -432,19 +365,19 @@ queue - - - SearchBar - - categories + + remove - - all + + install + + + SearchBar Search an application @@ -453,11 +386,6 @@ Settings - - - settings - - enable animations @@ -556,8 +484,8 @@ main - - + + Store @@ -567,194 +495,127 @@ - home - - - - - - all - - categories - - - internet - - - - - office - - - - - development - - - - - reading - - - - - graphics - - - - - game - - - - - music - - - - - system - - - - - video - - - - - chat - - - - - others - - settings - + Fetching survey data. - + Informing - + Show this result to the maintainer. - + Fetching application list. - - removed - - - - - installed - - - - + Package process is complete - + Another application is using package manager. Please wait or discard the other application and try again. - + Pardus Store should be run with root privileges - + Pardus Store detected some broken sources for the package manager. - + Please fix it manually or use Pardus Store's settings. - - + Removing - - - + Downloading - + Installing - + Reason - + Suggestion - + Check your internet connection - + Gathering local details. - + Done. - + Correcting of system package manager sources list is done. You can now restart Pardus Store. - + + Installed + + + + + Removed + + + + Warning! - + can not be closed while a process is ongoing. diff --git a/translations/pardus-store_tr.qm b/translations/pardus-store_tr.qm index 4bae0b67baec8d4eed2c5f151969f239c85b9a7f..87358594363d30b09c5cd2a7d07fcc4f76821213 100644 GIT binary patch delta 1087 zcmX9+YfO`86n@(8*6-2}k#-Q;Fe+WESV}N}F2RLuP&YAQqf6XiI!wzL4Yx!zNS1Xt zmBl(k{4AN;IY@9|wrp&bO_@Wm3bAa{Wh~jU;AL{z-4O}FMA?q(ujhTwd){-N=Q(Gz zDeemvo%N^1??l4i*sK?-d%l`_3Siy^1O`aCPgo8ly_&$xF2X86?g7er0Sp1PHvqmB zc+ExmSAk%R@{c9ZHVm%hB%li+ z&hacDvru>3)k678de^sv7Q4QsVk_0{(g*Kdo}t4$W4)M44Hp>aw!eXFH}lDPB9PX` zOgGcJIl^-BC=tzOmC{{+t(Hx7`T!-we)RM(V6S1XrMylJW9+Q+962(_F6*}wv0_ds zQUS-mT)=*coH)*f4pKb(0XL9N_19`aZsw;GWZ49_961SO&GPINHPqSplpBPyo-gSj zC7Boa7q5Rzg--DM);}D}7kqS@?yGD0C1VDSEGBp=?-D_u&>HC@2Y(j!IOyHn9?~abfz@ON2pQ_^TjBvxM+ZFIg&oZ`hMYw-rf-w>CZjtZFlaSh7?} zH-vRhlJ#ST4{wU3@U-Dl{WK|X82(i4)cA^+p`4+Do5W{s(?5e{7N;|u?)%+yE;gi zN4}X#Bg<)5#7Q$Ltot8>(6=Zn%mbvjK`AbOxc%*lXJVX`RVtf)CF}T&iuV^HX1=X_ z$?T*hiX|}TH|0vVo2>R4tG9kf@w^1Ol8trE0ueuyK&Rh$uKNed>oi{cpp+cCXS~WC zCMS*=7a!bu9FUF}mzTB!=^mA9q#3T+t8O^3g&6*!b}TrFSX>R)&d{v6q=PRUXcqD)IFd_;Vp3Rx@PZ*;&ZrO_E{M)84KGbT1VrjAnI zyW8$K9n?YH#Yo`lyIPA{l0VK0Hy@s^+5a%!f8PNLJgA@!r6f7Ltyd-Kt~)` zCtyebN;83Hu4))BX=qumVfFzae1vqWHB7kycKjOJ|0me6x?r}0TT=t%G=bYfqCy6^ zv-yC{1nv%@(4e8M7<}O(z!(JII39>O5B{JG^wVRq^8?_;o0zqE4j>j_)_26qei>!M z8-UoK;Hx0>LI*-^w@9}e3-*2sSS$!Hyie}(1|qzZ2+_c2vsVI9_jJpSCj-fOy49H> zATB>D^GCwOq^QvJ8C0Mu>R#&=!VbOZF7b2D=o1cG0PNOK|AmI>Df+axZvaEH^xy0y zgU`LI@AA_=>netAk5D6Gn2{z_0x6#}mNW-oE@!qC><7{sm{Tze0evTPHEkC~T+j4G z%_Zz&rBP;JNH$xRvXP9YvGq&n`Ot^#HsvUFwx4YtK!vi3*(*PPNs(`5dm7h}UOdN~ zqr$rFTudjSbcq{ZN5+%G-P~K}zXsAza5Wcl_z4K!ne(Y*8|ovAwG3)gB0ZN_1Xh@bR^vABfv z6I+ZYD(k}3X{zypg=QZkY8XFKLrc4cIrAmqbR1>n)=>Yd6dl)0pW9Sv%ry0L?UV{n z9H$2C8nQ_mW~E9Kf2EP|7p0<0)R^^xv_~H#gU~Q}FJYJ-#}H;d8U#X9W*nq zhFRxKZa+^6e4^oym8M z`H}gh+9{OWFmv7QG&0;|Zg5?pv&HsX;-Gp-tKHBeZ=%wo->)>K=O~AmXB9tFrqpI+ z(7H{D&d!d^XAQdEm-&)KspgjTzEsx&?^g*5ts~WZ7NhuWgL`i_8RGg4-Jm*()k!r*g<*QCcji`dE}J zommNdK=$~m{&~(?ZAz(irdmN1ie!7hQ98~ZpfbZEE!HDOWvy*+#Ff&`MQStN)JLMT zSLsx$vNoq9tXB5Hi%MNFJh1mwW*nvV5Csj!V|RPizg5J-1(^)Gi5h~N?0O*gZ7@3J zD!Ibv_sHI-_8F)^HMQpL<1#M0NA49*>r=WdC^X9o7 zS_A+39}AHt=hh8W4LrsSmCAwOlY$}%s;xX8H;q&2NRRo?beG#k7OB}w2&xu(`|~`K b4^{_5vgc{}Dxx~chp&&wR=J(B?-B2Bg#XSU diff --git a/translations/pardus-store_tr.ts b/translations/pardus-store_tr.ts index f1ddf96..0fd3f4a 100644 --- a/translations/pardus-store_tr.ts +++ b/translations/pardus-store_tr.ts @@ -12,52 +12,48 @@ kuruluyor - Removing - Kaldırılıyor + Kaldırılıyor - Installing - Kuruluyor + Kuruluyor - - Downloading - İndiriliyor + İndiriliyor downloading indiriliyor - + GET KUR - + INSTALL YÜKLE - + REMOVE KALDIR - + OPEN - + Non Free Özgür Değil - + Click for details Detaylar için tıklayınız @@ -70,7 +66,7 @@ kur - + Download size İndirme boyutu @@ -82,153 +78,149 @@ ApplicationDetail - home - ana sayfa + ana sayfa screenshots ekran görüntüleri - + no screenshot found! ekran görüntüsü bulunamadı! - + Disclaimer Sorumluluk Reddi - + years yıl - + months ay - + days gün - + hours saat - + minutes dakika - + seconds saniye - Removing - Kaldırılıyor + Kaldırılıyor - Installing - Kuruluyor + Kuruluyor - Downloading - İndiriliyor + İndiriliyor - + Reminder Hatırlatma - + First, you have to install Önce, şu uygulamayı yüklemeniz gerekiyor - + Then, you can vote. Sonra, oy kullanabilirsiniz. - + ok tamam - - + + ratings oylama - - + + not enough rating yeterli oylama yok - + Your rate Oyunuz - + This application served from Pardus non-free package repositories, so that the OS has nothing to do with the health of the application. Install with caution. Bu uygulama Pardus non-free paket depolarından sunulmaktadır, dolayısıyla İŞLETİM SİSTEMİ nin uygulamanın sağlığı ile bir ilgisi yoktur. Dikkate alarak yükleyiniz. - + remove kaldır - + install kur - + OPEN - + more devamı - + website internet sitesi - + last applied review son yapılan yorum - + no changelog data found değişim verisi bulunamadı - + changelog history değişim tarihçesi - + ago önce @@ -237,52 +229,52 @@ Pardus paket yöneticisine e-posta gönder - + e-mail e-posta - + information malumat - + version versiyon - + Download size İndirme boyutu - + type tip - + non-free özgür değil - + open source açık kaynak - + category kategori - + license lisans - + Download count İndirme sayısı @@ -291,17 +283,17 @@ indirme sayısı - + reviews - ratings yorumlar - oylamalar - + coming soon pek yakında - + what is new yenilikler @@ -314,7 +306,7 @@ Tanım - + no description found tanım bulunamadı @@ -387,53 +379,47 @@ Pardus Mağaza' ya hoş geldiniz - + welcome hoş geldiniz - - - all - tümü + tümü - - - categories - kategoriler + kategoriler - + Editor's Pick Editörün Seçimi - - - + + + no valid data found geçerli veri bulunamadı - + Most Downloaded App En Çok İndirilen Uygulama - + Most Rated App Oylaması En Yüksek Uygulama - + dynamic survey dinamik anket - + Upgrading Güncelleniyor @@ -462,13 +448,13 @@ Gelecek hafta mağazaya hangi uygulama eklenmeli ? - + send gönder - + update güncelle @@ -495,39 +481,34 @@ NavigationBar - - categories - kategoriler + kategoriler - - + all tümü - + This section is under development Bu kısım geliştirme aşamasındadır - + Anonymus Account Anonim Kullanıcı - installed - kuruldu + kuruldu - removed - kaldırıldı + kaldırıldı - + is @@ -539,13 +520,22 @@ queue kuyruk + + + remove + kaldır + + + + install + kur + SearchBar - categories - kategoriler + kategoriler @@ -553,17 +543,15 @@ Bir uygulama arayın - all - tümü + tümü Settings - settings - ayarlar + ayarlar @@ -729,8 +717,8 @@ main - - + + Store Mağaza @@ -740,18 +728,13 @@ Bir şeyler rast gitmedi! - home ana sayfa - - - - all - tümü + tümü @@ -759,59 +742,48 @@ kategoriler - internet - internet + internet - office - ofis + ofis - development - geliştirme + geliştirme - reading - okuma + okuma - graphics - grafik + grafik - game - oyun + oyun - music - müzik + müzik - system - sistem + sistem - video - video + video - chat - konuşma + konuşma - others - diğer + diğer @@ -819,7 +791,7 @@ ayarlar - + Correcting of system package manager sources list is done. You can now restart Pardus Store. Sistem paketi yöneticisi kaynak listesi düzeltilmesi tamamlandı. Artık Pardus Mağaza' yı yeniden başlatabilirsiniz. @@ -828,7 +800,7 @@ Paket yöneticisi ön belleği güncelleniyor. - + Fetching application list. Uygulama listesi getiriliyor. @@ -837,31 +809,29 @@ kuyruk - removed - kaldırıldı + kaldırıldı - installed - kuruldu + kuruldu is - + Package process is complete Paket süreci tamamlandı - + Another application is using package manager. Please wait or discard the other application and try again. Başka bir uygulama paket yöneticisini kullanıyor. Lütfen bekleyiniz ya da diğer uygulamayı kapatıp yeniden deneyiniz. - + Pardus Store should be run with root privileges Pardus Mağaza root yetkileri ile çalıştırılmalıdır @@ -874,40 +844,37 @@ indiriliyor - + Check your internet connection İnternet bağlantınızı kontrol ediniz - - + Removing Kaldırılıyor - - - + Downloading İndiriliyor - + Installing Kuruluyor - + Gathering local details. Yerel detaylar toplanıyor. - + Fetching survey data. Anket verileri getiriliyor. - + Done. Tamamlandı. @@ -916,12 +883,12 @@ kaldırılıyor - + Pardus Store detected some broken sources for the package manager. Pardus Mağaza paket yöneticisinin kullandığı kaynakların bazılarının bozuk olduğunu tespit etti. - + Please fix it manually or use Pardus Store's settings. Lütfen elle düzeltin ya da Pardus Mağazanın ayarlarını kullanın. @@ -930,32 +897,42 @@ kuruluyor - + Reason Sebep - + Suggestion Öneri - + Informing Bilgilendirme - + Show this result to the maintainer. Bu sonucu geliştiriciye bildirin. - + + Installed + Kuruldu + + + + Removed + Kaldırıldı + + + Warning! Uyarı! - + can not be closed while a process is ongoing. bir süreç devam ederken kapatılamaz. diff --git a/ui/ApplicationDelegate.qml b/ui/ApplicationDelegate.qml index 53f6a29..1e2a9a3 100644 --- a/ui/ApplicationDelegate.qml +++ b/ui/ApplicationDelegate.qml @@ -2,6 +2,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Window 2.0 import QtQuick.Controls.Material 2.0 +import ps.condition 1.0 Item { width: gridView.cellWidth @@ -12,7 +13,7 @@ Item { property string applicationDelegatestate: delegatestate property int animationDuration: 330 property bool detailTextHovered: false - property string condition: processingCondition + property int condition: processingCondition property int percent: processingPercent property bool processing: isThereOnGoingProcess property bool installingFromHere @@ -27,6 +28,7 @@ Item { onTriggered: { inqueue = true processQueue.push(name + " " + installed) + updateQueue() if((processingPackageName !== name) && isThereOnGoingProcess) { delegatestate = "inqueue" stopButton.visible = true @@ -69,23 +71,55 @@ Item { onConditionChanged: { if(processingPackageName === name) { - if(condition === qsTr("Removing")) { - processBarItem.colorCircle = "#F44336" //Red + if(condition === Condition.Removing) { + processBarItem.colorCircle = getConditionColor(condition) stopButton.enabled = false stopButton.visible = false - } else if(condition === qsTr("Installing")) { - processBarItem.colorCircle = "#4CAF50" //Green + } else if(condition === Condition.Installing) { + processBarItem.colorCircle = getConditionColor(condition) stopButton.enabled = false stopButton.visible = true - } else if(condition === qsTr("Downloading")) { - processBarItem.colorCircle = "#03A9F4" //Blue + } else if(condition === Condition.Downloading) { + processBarItem.colorCircle = getConditionColor(condition) stopButton.enabled = true stopButton.visible = true } } } + function amIDisqueued() { + if(disqueuedAppName === name) { + disqueuedAppName = "" + inqueue = false + delegatestate = installed ? "installed" : "get" + + if(selectedAppName === name) { + selectedAppInqueue = inqueue + selectedAppInstalled = installed + } + } + } + + function tryToTerminate(appName) { + if(appName === name) { + if(condition === Condition.Downloading) { + terminateProcessCalled = true + if(helper.terminate()) { + inqueue = false + installed = false + updateQueue() + if(processQueue.length <= 1) { + queueDialog.close() + } + } else { + terminateProcessCalled = false + stopButton.enabled = false + } + } + } + } + function updateInQueue(appName) { if(appName !== "" && appName === name) { inqueue = true @@ -109,6 +143,8 @@ Item { } Component.onCompleted: { + terminateFromDialog.connect(tryToTerminate) + anApplicationDisQueued.connect(amIDisqueued) updateStatusOfAppFromDetail.connect(updateInQueue) confirmationRemoval.connect(operateRemoval) errorOccured.connect(errorHappened) @@ -239,18 +275,21 @@ Item { enabled: animate NumberAnimation { duration: animationDuration } } + Behavior on width { enabled: animate NumberAnimation { duration: animationDuration / 2 } } + Material.background: "#4CAF50" hoverEnabled: true property string lastprocessed: lastProcess onLastprocessedChanged: { - if(lastProcess.search(name) == 0) { - var s = lastProcess.split(" ") + if(lastprocessed.search(name) === 0) { + console.log(lastprocessed) + var s = lastprocessed.split(" ") if (s[1] === "true") { installed = false } else { @@ -325,7 +364,7 @@ Item { height: width anchors.centerIn: parent colorBackground: "#111111" - colorCircle: "#4CAF50" + colorCircle: "#03A9F4" thickness: 5 opacity: 0.0 visible: opacity > 0.0 @@ -357,21 +396,9 @@ Item { onClicked: { forceActiveFocus() if(delegatestate === "inqueue") { - var i = processQueue.indexOf(name) - disqueuedApplication = processQueue.splice(i, 1).toString() - inqueue = false - delegatestate = installed ? "installed" : "get" + disQueue(name) } else if (delegatestate === "process") { - if(condition === qsTr("Downloading")) { - terminateProcessCalled = true - if(helper.terminate()) { - inqueue = false - installed = false - } else { - terminateProcessCalled = false - enabled = false - } - } + tryToTerminate(name) } } } diff --git a/ui/ApplicationDetail.qml b/ui/ApplicationDetail.qml index 5d45d9e..ee3244f 100644 --- a/ui/ApplicationDetail.qml +++ b/ui/ApplicationDetail.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.0 import QtQuick.Window 2.0 import QtQuick.Controls.Material 2.0 import QtGraphicalEffects 1.0 +import ps.condition 1.0 Rectangle { id:appDetail @@ -45,6 +46,7 @@ Rectangle { if(name !== "" && name === selectedAppName && from === "detail") { updateStatusOfAppFromDetail(selectedAppName) processQueue.push(selectedAppName + " " + selectedAppInstalled) + updateQueue() } } @@ -504,7 +506,7 @@ Rectangle { ProgressBar { id: processButtonProgressBar property int percent: processingPercent - property string condition: processingCondition + property int condition: processingCondition property string progressColor width: parent.width @@ -556,13 +558,7 @@ Rectangle { onConditionChanged: { if(processingPackageName === selectedAppName) { - if(condition === qsTr("Removing")) { - progressColor = "#F44336" //Red - } else if(condition === qsTr("Installing")) { - progressColor = "#4CAF50" //Green - } else if(condition === qsTr("Downloading")) { - progressColor = "#03A9F4" //Blue - } + progressColor = getConditionColor(condition) } } @@ -687,7 +683,7 @@ Rectangle { height: ss.height radius: 5 } - } + } } MouseArea{ diff --git a/ui/NavigationBar.qml b/ui/NavigationBar.qml index 71dc4a4..13eea0f 100644 --- a/ui/NavigationBar.qml +++ b/ui/NavigationBar.qml @@ -1,7 +1,8 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 -import QtGraphicalEffects 1.0 +//import QtGraphicalEffects 1.0 +import ps.condition 1.0 Rectangle { id: navi @@ -275,8 +276,8 @@ Rectangle { height: width / 3 - 12 anchors { horizontalCenter: parent.horizontalCenter - bottom: processOutputLabel.top - bottomMargin: 6 + bottom: polContainer.top + bottomMargin: 3 } Rectangle { @@ -337,57 +338,71 @@ Rectangle { } - - Label { - id: processOutputLabel - property string packageName: "" - property string condition: "" - anchors { - bottom: parent.bottom - bottomMargin: 6 - horizontalCenter: parent.horizontalCenter - } - opacity: 1.0 - fontSizeMode: Text.VerticalFit - wrapMode: Text.WordWrap - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font.capitalization: Font.Capitalize - enabled: false - text: "" - - onTextChanged: { - opacity = 1.0 + Item { + id: polContainer + width: parent.width + height: 24 + anchors.bottom: parent.bottom + MouseArea { + anchors.fill: parent + hoverEnabled: true + onContainsMouseChanged: { + if(containsMouse && isThereOnGoingProcess) { + queueDialog.open() + } + } } - onConditionChanged: { - if(condition === qsTr("installed") || condition === qsTr("removed")) { - processOutputLabel.text = packageName + " " + qsTr("is") + " " + condition - } else { - processOutputLabel.text = condition + " " + packageName + Label { + id: processOutputLabel + property string packageName: "" + property int condition: Condition.Idle + anchors { + centerIn: parent + } + opacity: 1.0 + fontSizeMode: Text.VerticalFit + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.capitalization: Font.Capitalize + enabled: false + text: "" + + onTextChanged: { + opacity = 1.0 } - } - Behavior on opacity { - enabled: animate - NumberAnimation { - easing.type: Easing.OutExpo - duration: 200 + onConditionChanged: { + if (condition === Condition.Idle) { + processOutputLabel.text = "" + } else if(condition === Condition.Installed || condition === Condition.Removed) { + processOutputLabel.text = packageName + " " + qsTr("is") + " " + getConditionString(condition) + } else { + processOutputLabel.text = getConditionString(condition) + " " + packageName + } } - } - Timer { - id: outputTimer - interval: 8000 - repeat: true - running: true - onTriggered: { - if(!isThereOnGoingProcess) { - processOutputLabel.opacity = 0.0 - //processingPackageName = "" - //processingCondition = "" + Behavior on opacity { + enabled: animate + NumberAnimation { + easing.type: Easing.OutExpo + duration: 200 + } + } + + Timer { + id: outputTimer + interval: 8000 + repeat: true + running: true + onTriggered: { + if(!isThereOnGoingProcess) { + processOutputLabel.opacity = 0.0 + } } } } + } } diff --git a/ui/QueueDialog.qml b/ui/QueueDialog.qml index 39ddb3c..4f31eec 100644 --- a/ui/QueueDialog.qml +++ b/ui/QueueDialog.qml @@ -1,16 +1,17 @@ import QtQuick 2.3 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 +import ps.condition 1.0 Popup { - id: queue + id: dialogRoot closePolicy: Popup.CloseOnPressOutside - //Material.background: Material.primary + Material.background: backgroundColor Material.elevation: 3 - width: navigationBarWidth - 12 + width: navigationBarWidth z: 99 - x: 6 - y: parent.height - height - 100 + x: 0 + y: parent.height - height - 26 property alias repeater: repeaterQueue @@ -24,6 +25,13 @@ Popup { } } + MouseArea { + anchors.centerIn: parent + width: parent.width + 24 + height: parent.height + 24 + hoverEnabled: true + } + Label { id: queuePopupTitle text: qsTr("queue") @@ -44,22 +52,42 @@ Popup { Repeater { id: repeaterQueue model: processQueue + Item { width: parent.width height: 24 Label { id: nameLabel - color: "white" + color: textColor anchors.verticalCenter: parent.verticalCenter text: modelData.split(" ")[0] verticalAlignment: Text.AlignVCenter font.capitalization: Font.Capitalize + horizontalAlignment: Text.AlignLeft + anchors.left: parent.left + } + + Label { + id: dutyLabel + Material.foreground: textColor + Material.theme: dark ? Material.Dark : Material.Light + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignRight + font.capitalization: Font.Capitalize + enabled: false + anchors { + right: cancelBtn.left + rightMargin: 6 + } + text: index === 0 ? getConditionString(processingCondition) : (modelData.split(" ")[1] === "true" ? qsTr("remove") : qsTr("install")) + font.pointSize: 9 } Rectangle { id: cancelBtn - visible: index != 0 + visible: index !== 0 ? true : (processingCondition === Condition.Downloading) color: "#F44336" width: 24 height: width @@ -84,19 +112,11 @@ Popup { onPressAndHold: cancelBtn.color = "#EF9A9A" onReleased: cancelBtn.color = "#F44336" onClicked: { - var i = processQueue.indexOf(modelData) - disqueuedApplication = processQueue.splice(i, 1).toString() - var s = disqueuedApplication.split(" ") - var duty = s[1] - - if (duty === "true") { - duty = "false" + if(index === 0) { + terminateFromDialog(modelData.split(" ")[0]) } else { - duty = "true" + disQueue(modelData.split(" ")[0]) } - - lastProcess = (s[0] + " " + duty) - updateQueue() } } } diff --git a/ui/main.qml b/ui/main.qml index 7d863ce..f12de4d 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -4,7 +4,7 @@ import QtQuick.Window 2.0 import QtQuick.Controls.Material 2.0 import QtGraphicalEffects 1.0 import ps.helper 1.0 - +import ps.condition 1.0 ApplicationWindow { id: main @@ -31,10 +31,10 @@ ApplicationWindow { property string selectedMenu: "home" property string previousMenu: "" - property variant processQueue: [] + property variant processQueue: [] property variant menuList: {"home": qsTr("home"), "categories": qsTr("categories"), "settings": qsTr("settings")} property variant specialApplications: ["gnome-builder", "xfce4-terminal"] - property variant categories: [] + property variant categories: [] property alias processingPackageName: navigationBar.packageName property alias processingCondition: navigationBar.condition @@ -43,6 +43,9 @@ ApplicationWindow { property alias updateCache: helper.update property alias ratio: helper.ratio + signal anApplicationDisQueued() + signal terminateFromDialog(variant applicationName) + signal updateQueue() signal updateCacheFinished() signal updateStatusOfAppFromDetail(string appName) @@ -68,6 +71,7 @@ ApplicationWindow { property string selectedAppPrettyName property string selectedAppDelegatestate: "get" property string selectedAppExecute + property string disqueuedAppName property alias dark: helper.usedark property string backgroundColor: dark ? "#2B2B2B" : "#F0F0F0" @@ -124,21 +128,22 @@ ApplicationWindow { var s = processQueue[0].split(" ") var appName = s[0] var duty = s[1] - var dutyText = "" + var cond = Condition.Idle if (duty === "true") { - dutyText = qsTr("removed") + cond = Condition.Removed //qsTr("removed") } else { - dutyText = qsTr("installed") + cond = Condition.Installed //qsTr("installed") } processingPackageName = appName - processingCondition = dutyText + processingCondition = cond lastProcess = processQueue.shift() updateQueue() isThereOnGoingProcess = false + appName = getCorrectName(appName) systemNotify(appName, qsTr("Package process is complete"), (appName.charAt(0).toUpperCase() + appName.slice(1)) + - " " + dutyText + " (Pardus " + qsTr("Store") + ")") + " " + getConditionString(cond) + " (Pardus " + qsTr("Store") + ")") } else { if(!cacheIsUpToDate) { updateCacheFinished() @@ -167,18 +172,18 @@ ApplicationWindow { errorOccured() } else { terminateProcessCalled = false + processingCondition = Condition.Idle } } onProcessingStatus: { if(condition === "pmstatus") { - if(processingCondition === qsTr("Removing")) { - } else if(processingCondition === qsTr("Downloading")) { - processingCondition = qsTr("Installing") + if(processingCondition === Condition.Downloading) { + processingCondition = Condition.Installing //qsTr("Installing") } } else if (condition === "dlstatus") { - processingCondition = qsTr("Downloading") + processingCondition = Condition.Downloading } processingPercent = percent } @@ -255,7 +260,7 @@ ApplicationWindow { for(var i = 0; i < categorylist.length; i++){ categories.push(categorylist[i]) } - categoriesFilled() + categoriesFilled() } } @@ -335,12 +340,13 @@ ApplicationWindow { processingPackageName = appName isThereOnGoingProcess = true if (duty === "true") { - processingCondition = qsTr("Removing") + processingCondition = Condition.Removing //qsTr("Removing") helper.remove(appName) } else { - processingCondition = qsTr("Downloading") + processingCondition = Condition.Downloading //qsTr("Downloading") helper.install(appName) } + updateQueue() } } } @@ -379,7 +385,38 @@ ApplicationWindow { return appName.split("-")[1] } return appName - } + } + + function getConditionString(con) { + switch (con) { + case Condition.Installed: return qsTr("Installed") + case Condition.Removed: return qsTr("Removed") + case Condition.Downloading: return qsTr("Downloading") + case Condition.Installing: return qsTr("Installing") + case Condition.Removing: return qsTr("Removing") + default: return "" + } + } + + function getConditionColor(con) { + switch (con) { + case Condition.Downloading: return "#03A9F4" + case Condition.Installing: return "#4CAF50" + case Condition.Removing: return "#F44336" + default: return accentColor + } + } + + function disQueue(name) { + for(var i = 0; i < processQueue.length; i++) { + if(processQueue[i].split(" ")[0] === name) { + processQueue.splice(i, 1).toString() + disqueuedAppName = name + anApplicationDisQueued() + } + } + updateQueue() + } onClosing: { if(isThereOnGoingProcess) { @@ -426,7 +463,7 @@ ApplicationWindow { onUpdateQueue: { queueDialog.repeater.model = processQueue queueDialog.height = queueDialog.repeater.count * 34 + queueDialog.title.height + 26 - if(processQueue.length == 0) { + if(processQueue.length === 0) { queueDialog.close() } }