Commit cd47861e authored by Artem Grinev's avatar Artem Grinev Committed by Artem Grinev
Browse files

Various UI improvements

parent 6494a5f7
......@@ -15,8 +15,11 @@ Window{
Pane {
anchors.fill: parent
id: item1
padding: 2
Pane{
anchors.topMargin: 4
anchors.top: parent.top
id:header
height: implicitHeight
width: implicitWidth
......@@ -76,7 +79,7 @@ Window{
Label {
id: label
text: qsTr("A Qt5 frontend for libpamac")
text: qsTr("A Qt5 frontend for libpamac\n(Work in progress)")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
......
......@@ -45,7 +45,7 @@ Pane {
var list = stackView.currentItem.updates.getReposUpdates();
var totalSize = 0;
for(var i =0;i<list.length;i++){
totalSize += ignoreWhenUpdate.indexOf(list[i].name)!=-1? list[i].downloadSize:0;
totalSize += ignoreWhenUpdate.indexOf(list[i].name)==-1?list[i].downloadSize:0;
}
if(totalSize==0){
return "";
......@@ -96,16 +96,7 @@ Pane {
}
]
RowLayout{
ItemDelegate{
MouseArea{
anchors.fill: parent
visible: sysUpgrade
enabled: sysUpgrade
hoverEnabled: true
}
id:detailsButton
checked:bottomPanel.state=="expanded"
checkable: true
......@@ -130,6 +121,11 @@ Pane {
width: parent.width
}
}
onClicked: {
if(!checked){
transaction.details = ""
}
}
}
......@@ -180,25 +176,32 @@ Pane {
Pane{
padding: 0
SideBar{
width: toBuild.length>0?undefined:0
// width: toBuild.length>0?170:0
width: 0
id:sideMenuPending
initialItem:SideMenuPending{
anchors{
left:parent.left
bottom: parent.bottom
top:parent.top
onCurrentIndexChanged: {
if(currentIndex==Database.Repos){
pendingPackageList.packageList = Database.findPackagesByName(toInstall.concat(toRemove));
} else{
pendingPackageList.packageListFuture = Database.getAurPackages(toBuild);
}
}
}
anchors{
left:parent.left
bottom: parent.bottom
top:parent.top
}
}
PackageList{
id:pendingPackageList
anchors.left: sideMenuPending.right
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
packageList: Database.findPackagesByName(toInstall.concat(toRemove))
}
}
},
......@@ -217,10 +220,14 @@ Pane {
if(totalPending!=0){
transaction.details = "";
}
}
else if(totalPending==0){
detailsButton.checked=false;
}
Connections{
target: transaction
onFinished:{
if(state!="expanded"){
transaction.details = "";
}
}
}
}
......@@ -98,7 +98,7 @@ ApplicationWindow {
width: 950
height: 550
objectName: "mainWindow"
title: qsTr("Pamac Qt - preview version")
title: qsTr("Pamac Qt - Beta version")
SystemPalette{id:systemPalette}
Item{
......@@ -127,20 +127,7 @@ ApplicationWindow {
font.pixelSize: Qt.application.font.pixelSize * 1.4
anchors.verticalCenter: parent.verticalCenter
// FileDialog{
// id:fileDialog
// title: qsTr("Install Local Packages")
// folder: shortcuts.home
// nameFilters: ["Alpm packages (*.pkg.tar.xz)"]
// onAccepted: {
// for(var i =0;i<fileUrls.length;i++){
// toLoad.push(fileUrls[i].toString());
// }
// tryLockAndRun(()=>{transaction.start([],[],toLoad,[],[],[])});
// }
// }
Menu {
onClosed: toolButton1.checked=false
......
......@@ -58,7 +58,7 @@ LoaderDelegate{
function packageAction(){
let el;
if(list.packageList.every(value=>JSUtils.qmlTypeOf(value,"LibQPamac::Package")))
if(JSUtils.qmlTypeOf(modelData,"LibQPamac::Package"))
if(installedVersion!=""){
el = toRemove.indexOf(name);
if(el!==-1){
......@@ -232,8 +232,14 @@ LoaderDelegate{
anchors.fill: parent
anchors.margins: 5
text: "Update"
checked: ignoreWhenUpdate.indexOf(name)!=undefined
onCheckedChanged: checked?ignoreWhenUpdate.push(name):ignoreWhenUpdate = ignoreWhenUpdate.filter(value=>value!==name)
checked: ignoreWhenUpdate.indexOf(name)==-1
onCheckedChanged: {
if(!checked){
ignoreWhenUpdate.push(name)
ignoreWhenUpdateChanged();
} else {
ignoreWhenUpdate = ignoreWhenUpdate.filter(value=>value!==name)}
}
}
}
}
......
......@@ -439,7 +439,7 @@ Page{
Label {
id: label7
height: aurEnabledCheckBox.height
text: qsTr("Enable AUR support")
text: qsTr("Enable AUR support (EXPERIMENTAL)")
verticalAlignment: Text.AlignVCenter
anchors.left: parent.left
anchors.leftMargin: 6
......
......@@ -6,6 +6,7 @@ import "../js/JSUtils.js" as Utils
Rectangle{
Rectangle{
anchors.left: parent.left
SequentialAnimation on x{
loops: Animation.Infinite
running: progressBar.indeterminate
......
......@@ -3,7 +3,7 @@ import QtQuick.Controls 2.12
ListView {
boundsBehavior: Flickable.StopAtBounds
model:["Description","Dependecies","Files"]
model:["Description","Dependencies","Files"]
delegate: MenuItemDelegate{
backgroundColor: systemPalette.alternateBase
id:packageInfoDelegate
......
......@@ -3,6 +3,7 @@ import QtQuick.Controls 2.12
import QPamac.Database 1.0
ListView{
boundsBehavior: Flickable.StopAtBounds
model:ListModel{
ListElement{
name:"Repository"
......@@ -13,17 +14,11 @@ ListView{
type: Database.AUR
}
}
delegate:MenuItemDelegate {
text: name
onClicked:{
currentIndex=index
if(index==Database.Repos){
mainView.packageList= Database.getPending(toInstall,toRemove);
} else{
mainView.packageList = undefined
}
}
}
ScrollBar.vertical: ScrollBar{
......
......@@ -106,7 +106,9 @@ ToolBar {
checked: stackView.currentItem.objectName=="updatesPage"
id:updatesButton
flat:true
icon.name: updatesCount<1?"update-none":"update-medium"
icon.name:stackView.currentItem.objectName=="updatesPage"?
"go-previous":
updatesCount<1?"update-none":"update-medium"
icon.height: 20
icon.width: 20
property int updatesCount:-1
......
......@@ -7,7 +7,6 @@ import "../js/JSUtils.js" as JSUtils
Page {
title: qsTr("Updates")
objectName: "updatesPage"
property var updates
......
......@@ -57,6 +57,7 @@ public:
Q_INVOKABLE GenericQmlFuture getRepoPackagesAsync(const QString &repo);
Q_INVOKABLE GenericQmlFuture getInstalledAppsAsync();
Q_INVOKABLE GenericQmlFuture getInstalledPackagesAsync(InstalledPackageTypes type);
Q_INVOKABLE GenericQmlFuture getAurPackages(const QStringList &nameList);
Q_INVOKABLE QStringList getPkgFiles(const QString &name);
......
......@@ -55,6 +55,7 @@ class Transaction : public QObject
Q_PROPERTY(QJSValue requestImportKey WRITE setRequestImportKey FINAL)
Q_PROPERTY(QJSValue requestChooseProvider WRITE setRequestChooseProvider FINAL)
Q_PROPERTY(QJSValue requestOptDepends WRITE setRequestOptDepends FINAL)
Q_PROPERTY(QJSValue requestEditBuildFiles WRITE setRequestEditBuildFiles FINAL)
public:
Transaction(QObject * parent = nullptr):QObject(parent){}
......@@ -90,6 +91,7 @@ public:
Q_INVOKABLE void startSysupgrade(bool forceRefresh,bool enableDowngrade,const QStringList& tempIgnore = QStringList(),const QStringList& overwriteFiles = QStringList());
public Q_SLOTS:
void setDatabase(Database* database);
......@@ -122,6 +124,13 @@ public Q_SLOTS:
}
}
void setRequestEditBuildFiles(const QJSValue &requestEditBuildFiles){
if(requestEditBuildFiles.isCallable()){
m_requestEditBuildFiles = requestEditBuildFiles;
}
}
Q_SIGNALS:
void getAuthorizationFinished(bool authorized);
void finished(bool success);
......@@ -180,6 +189,7 @@ private:
QJSValue m_requestOptDepends;
QJSValue m_requestImportKey;
QJSValue m_requestChooseProvider;
QJSValue m_requestEditBuildFiles;
};
} //namespace LibQPamac
......
......@@ -4,8 +4,8 @@
GAsyncReadyCallback asyncCallback(){
return ([](GObject* parent,GAsyncResult* result,void* lambdaPtr){
auto function = reinterpret_cast<std::function<void(GObject*,GAsyncResult*)>*>(lambdaPtr);
auto object = reinterpret_cast<GObject*>(parent);
auto function = reinterpret_cast<std::function<void(PamacDatabase*,GAsyncResult*)>*>(lambdaPtr);
auto object = reinterpret_cast<PamacDatabase*>(parent);
(*function)(object,result);
delete function;
});
......@@ -200,7 +200,9 @@ QVariantList Database::findPackagesByName(const QStringList &names)
for(auto& name: names){
Package pkg;
if((pkg = getInstalledPackage(name)).name().isEmpty()){
pkg = getSyncPackage(name);
if((pkg = getSyncPackage(name)).name().isEmpty()){
}
}
packages.append(QVariant::fromValue(pkg));
......@@ -276,4 +278,43 @@ GenericQmlFuture LibQPamac::Database::getInstalledPackagesAsync(Database::Instal
return GenericQmlFuture(future);
}
GenericQmlFuture Database::getAurPackages(const QStringList &nameList)
{
//method returns non usable values
auto list = Utils::qStringListToCStringVector(nameList);
QmlFutureImpl* future = new QmlFutureImpl;
pamac_database_get_aur_pkgs(handle,list.data(),list.size(),asyncCallback(),new std::function([=](PamacDatabase* object, GAsyncResult* result){
auto hashTable = pamac_database_get_aur_pkgs_finish(object,result);
QVariantList resultList;
g_hash_table_foreach(hashTable,[](void* keyPtr,void* valuePtr,void* funcPtr){
auto key = reinterpret_cast<char*>(keyPtr);
auto value = reinterpret_cast<PamacAURPackage*>(valuePtr);
auto func = reinterpret_cast<std::function<void(const QString&,const AURPackage&)>*>(funcPtr);
(*func)(QString::fromUtf8(key),AURPackage(value));
delete func;
delete key;
}, new std::function([&](const QString& key,const AURPackage& value){
resultList.push_back(QVariant::fromValue(value));
}));
future->setFuture(resultList);
}));
return GenericQmlFuture(future);
}
} // namespace LibQPamac
......@@ -169,7 +169,12 @@ void LibQPamac::Transaction::init()
auto engine = qmlEngine(this);
return gboolean(engine->fromScriptValue<bool>(this->m_requestImportKey.call({{QString::fromUtf8(pkgname),QString::fromUtf8(key),QString::fromUtf8(owner)}})));
});
PAMAC_TRANSACTION_GET_CLASS(m_handle)->ask_edit_build_files =
Utils::cify([=](PamacTransaction* self, PamacTransactionSummary* summary)->gboolean{
auto engine = qmlEngine(this);
return false;
});
g_signal_connect(static_cast<PamacTransaction*>(m_handle),"finished",
reinterpret_cast<GCallback>(+[](GObject* obj,bool success,Transaction* t){
Q_UNUSED(obj);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment