├── .gitignore ├── CHANGELOG ├── LICENSE ├── README.md ├── octopkg-mainwindow.png ├── octopkg.desktop ├── octopkg.pro ├── release-languages.sh ├── resources.qrc ├── resources ├── images │ ├── applications-internet.png │ ├── binary.png │ ├── cachecleaner.png │ ├── cloud.png │ ├── collapse.png │ ├── commit.png │ ├── drive-harddisk.png │ ├── edit-copy.png │ ├── editfile.png │ ├── esf-clear.png │ ├── esf-search.png │ ├── exit.png │ ├── expand.png │ ├── fast_forward.png │ ├── find.png │ ├── folder.png │ ├── folder_gnome.png │ ├── foreign_green.png │ ├── foreign_red.png │ ├── install_item.png │ ├── installed.png │ ├── locker-key.png │ ├── mirror-check.png │ ├── newer.png │ ├── noninstalled.png │ ├── octopi.png │ ├── octopi_green.png │ ├── octopi_red.png │ ├── octopi_transparent.png │ ├── octopi_yellow.png │ ├── outdated.png │ ├── refresh.png │ ├── remove_item.png │ ├── rollback.png │ ├── rss.png │ ├── show_groups.png │ ├── stop_small_red.png │ ├── terminal.png │ ├── toinstall.png │ ├── toremove.png │ ├── unlock.png │ ├── unrequired.png │ └── window_close.png └── styles │ ├── branch-closed.png │ ├── branch-closed_BW.png │ ├── branch-end.png │ ├── branch-more.png │ ├── branch-open.png │ ├── branch-open_BW.png │ └── vline.png ├── src ├── QtSolutions │ ├── QtLockedFile │ ├── QtSingleApplication │ ├── qtlocalpeer.cpp │ ├── qtlocalpeer.h │ ├── qtlockedfile.cpp │ ├── qtlockedfile.h │ ├── qtlockedfile_unix.cpp │ ├── qtlockedfile_win.cpp │ ├── qtsingleapplication.cpp │ ├── qtsingleapplication.h │ ├── qtsingleapplication.pri │ ├── qtsinglecoreapplication.cpp │ ├── qtsinglecoreapplication.h │ └── qtsinglecoreapplication.pri ├── argumentlist.cpp ├── argumentlist.h ├── constants.h ├── globals.cpp ├── globals.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow_events.cpp ├── mainwindow_help.cpp ├── mainwindow_init.cpp ├── mainwindow_news.cpp ├── mainwindow_refresh.cpp ├── mainwindow_searchbar.cpp ├── mainwindow_transaction.cpp ├── model │ ├── packagemodel.cpp │ └── packagemodel.h ├── package.cpp ├── package.h ├── packagerepository.cpp ├── packagerepository.h ├── packagetreeview.cpp ├── packagetreeview.h ├── searchbar.cpp ├── searchbar.h ├── searchlineedit.cpp ├── searchlineedit.h ├── settingsmanager.cpp ├── settingsmanager.h ├── strconstants.cpp ├── strconstants.h ├── terminal.cpp ├── terminal.h ├── transactiondialog.cpp ├── transactiondialog.h ├── treeviewpackagesitemdelegate.cpp ├── treeviewpackagesitemdelegate.h ├── ui │ ├── octopkgtabinfo.cpp │ └── octopkgtabinfo.h ├── uihelper.h ├── unixcommand.cpp ├── unixcommand.h ├── utils.cpp ├── utils.h ├── wmhelper.cpp └── wmhelper.h └── ui ├── mainwindow.ui └── transactiondialog.ui /.gitignore: -------------------------------------------------------------------------------- 1 | bin/octopkg 2 | build 3 | qmake_qmake_qm_files.* 4 | ui_passworddialog.h 5 | .qmake 6 | .qtc_clangd/ 7 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.4.2 (dev) 2 | BugFix: The act of moving the mouse over the package list was triggering many 3 | pkg executions. 4 | BugFix: Use xdg-open to open files when available if user is running XFCE. 5 | BugFix: Remote pkg search was not finding all entries (thanks to bsduck). 6 | Added internet check before pkg actions. 7 | 8 | 0.4.1 (2024/08/18) 9 | BugFix: Added C.UTF-8 default language set for executeCommand function. 10 | BugFix: Clean the local cache always produced a postponed crash after some 11 | specific install transactions. 12 | BugFix: Modified code to find pkg db in DragonFlyBSD. 13 | BugFix: Added reference to new LGPL v2.1 license. 14 | Added support to NomadBSD. 15 | Improvement: Show a "Collecting transaction data..." msg before presenting the transaction 16 | dialog, as it can be quite slow on some systems. 17 | 18 | 0.4.0 (2024/05/23) 19 | BugFix: When clicking on a outdated pkg inside Output tab, do not go to the Info 20 | tab if the pkg is not shown in the list. 21 | BugFix: Update FreeBSD pkg wiki site (thanks to eduardo). 22 | BugFix: Files tab expand all items by default. 23 | BugFix: Files tab was not being refreshed when switching to remote search. 24 | Updated license to LGPL v2.1. 25 | Show "Installed on" column while searching for remote pkgs. 26 | Now using the unified qt-sudo project (https://github.com/aarnt/qt-sudo) for privilege escalation. 27 | 28 | 0.3.3 (2023/09/08) 29 | BugFix: openFile always left a running file manager even after program close. 30 | Synced octopkg-doas with LXQt-sudo 1.3.0 version. 31 | Added a stop button next to the progress bar to cancel running transaction. 32 | Make the project compatible with both Qt5 and Qt6. 33 | 34 | 0.3.2 (2022/12/31) 35 | BugFix: WM testing code now uses ps -aux. 36 | BugFix: Test also if doas.conf is available at startup. 37 | BugFix: Disable Info/Files tab refresh while typing in filter/search line edit. 38 | BugFix: Updated FreeBSD rss url. 39 | BugFix: Package search did not work correctly when query string contained a "+" sign. 40 | BugFix: Refresh of Info/File tabs and focus/key navigation improvements. 41 | Synced octopkg-doas with LXQt-sudo 1.1.0 version. 42 | Changed "Sync database" option name to "Check updates". 43 | Actions tab shows a counter feedback for inserts (with a plus signal) and 44 | removals (with a minus signal) and does not steal focus anymore. 45 | Added support for "^" and "$" characters in remote searches. 46 | 47 | 0.3.1 (2020/10/29) 48 | Added "Installed On" column on installed package list. 49 | Make locate work with "search by file", giving suggestions on a popup window. 50 | Make code compatible with Qt 5.15 version. 51 | BugFix: updated install dir of octopkg-doas to /usr/local/lib/octopkg. 52 | BugFix: removed "/" char option when "Search by File" was selected before searching 53 | for a remote pkg. 54 | 55 | 0.3.0 (2020/07/18) 56 | BugFix in GhostBSD repo guessing; 57 | BugFix: Package list does not flashes at program startup anymore. 58 | BugFix: Do not offer to open "LSB relocatable" files at File tab. 59 | BugFix: anchor output when pkg list is empty. 60 | BugFix: TransactionDialog was size constrained. 61 | BugFix: Use of "ReInstall" and "Update" texts instead of just generic "Install" text 62 | on package list context menus. 63 | BugFix: DragonFlyBSD support updated! 64 | BugFix: Let exit menu and close button enabled for cancelling running actions. 65 | BugFix: Sort by icon column works better now. 66 | BugFix: Use a more aggressive UI lockdown approach during actions. 67 | Faster startup time thanks to deferred retrieval of outdated packages. 68 | Added option to create backup boot environments before upgrades when root is on ZFS. 69 | Added support to HardenedBSD. 70 | Added GNOME desktop support. 71 | Added Lumina desktop support. 72 | Added Info option on package list context menu. 73 | Added lock/unlock actions on installed packages. 74 | Changed some ui icons. 75 | List of installed packages is shown by default. Remote ones are only a click away. 76 | Added plasma5 support. 77 | Added a custom doas tool to execute actions: octopkg-doas, a lxqt-sudo clone. 78 | Abort show file content when file list is greater than 1MB of text. 79 | Changed F12 key behaviour to F11. 80 | Added the option to terminate the current transaction being executed, by pressing 81 | "Ctrl+Z". 82 | Added "pkg clean" support (Ctrl+Shift+C and menu item). 83 | Added "Ctrl+R" shortcut to search for remote packages. 84 | Now the size of TransactionDialog is saved between calls. 85 | Now tab Files shows progress bar while building pkg list. 86 | Maximization of lower panel now hides tabbar. 87 | 88 | 0.2.0 (2015/07/25) 89 | BugFix: anchor navigation fixes. 90 | BugFix: the name of some dependencies were not being shown correctly. 91 | BugFix: list of dependencies was not sorted. 92 | BugFix: outdated pkg list was not sorted. 93 | BugFix: When user closed searchbar inside a QTextBrowser, cursor position was reseted. 94 | BugFix: Do not refresh pkg lists while clicking remote/local buttons. 95 | BugFix: Fix gksu "-- f parameter" execution error. 96 | BugFix: When trying to install a Ports pkg not available in database, shows error 97 | (thanks to asxbsd). 98 | BugFix: List of outdated packages not being retrieved in some cases. 99 | Let user removes any automatic installed package. 100 | Remove commands now use -R option. 101 | Added DragonFlyBSD support. 102 | Added GhostBSD support (thanks to ringo32 and rkramerbsd). 103 | Added search feature also in Information tab. 104 | Heavily threaded version, minimizing interface freezing. 105 | 106 | 0.1.0 (2015/06/30) 107 | Initial Proof of Concept release. 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## This is OctoPkg, a powerful pkgng front end using Qt libs. 2 | 3 | ![Main window](https://raw.githubusercontent.com/aarnt/octopkg/master/octopkg-mainwindow.png) 4 | 5 | **OctoPkg** is a Qt based GUI front end to the [pkg](https://wiki.freebsd.org/pkg) package manager, derived from [Octopi](http://tintaescura.com/projects/octopi). 6 | It consists of a lxqt-sudo clone called [qt-sudo](https://github.com/aarnt/qt-sudo/) used to gain root privileges and a package browser application used 7 | to search, install, remove and update packages. 8 | The project is compatible with [FreeBSD](https://www.freebsd.org/), [DragonFly BSD](https://www.dragonflybsd.org/), [GhostBSD](https://ghostbsd.org/), [HardenedBSD](https://hardenedbsd.org/) and [NomadBSD](https://nomadbsd.org/). 9 | 10 | ### You can use pkg to install the latest OctoPkg version available in your BSD: 11 | 12 | ``` 13 | # pkg install octopkg 14 | ``` 15 | 16 | ### Follow the steps bellow to compile the latest source code (you'll need curl, git and qt6 packages): 17 | 18 | ``` 19 | $ git clone https://github.com/aarnt/octopkg 20 | $ cd octopkg 21 | $ qmake6 22 | $ make 23 | # make install 24 | ``` 25 | 26 | ### In order to run OctoPkg: 27 | 28 | ``` 29 | $ octopkg 30 | ``` 31 | 32 | Remember: OctoPkg needs doas or sudo tool to work. 33 | 34 | 35 | Enjoy! 36 | -------------------------------------------------------------------------------- /octopkg-mainwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/octopkg-mainwindow.png -------------------------------------------------------------------------------- /octopkg.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Categories=System;Tools; 3 | Comment[en_US]=Add or remove software installed on the system 4 | Comment=Add or remove software installed on the system 5 | Comment[af]=Voeg by of verwyder sagteware geïnstalleer op die stelsel 6 | Comment[ar]=أضف أو أزل البرمجيات المثبتة على النظام 7 | Comment[as]=ব্যৱস্থাপ্ৰণালীত সংস্থাপিত চালনাজ্ঞান উন্নয়ন কৰক 8 | Comment[ast]=Amestar o quitar software instaláu nel sistema 9 | Comment[be]=Дадаць ці выдаліць апраграмаванне, усталяванае ў сістэме 10 | Comment[bg]=Инсталиране и деинсталиране на софтуер към системата 11 | Comment[bn]=সিস্টেমে সফ্টওয়্যার যোগ করুন অথবা ইনস্টল করা সফ্টওয়্যার অপসারণ 12 | Comment[bn_IN]=সিস্টেমে সফ্টওয়্যার যোগ করুন অথবা ইনস্টল করা সফ্টওয়্যার সরিয়ে ফেলুন 13 | Comment[ca@valencia]=Afig o suprimeix programari instal·lat en el sistema 14 | Comment[ca]=Afegeix o suprimeix programari instal·lat en el sistema 15 | Comment[cs]=Přidat nebo odebrat software instalovaný v systému 16 | Comment[da]=Tilføj eller fjern software installeret på systemet 17 | Comment[de]=Auf dem System installierte Software aktualisieren oder neue Software hinzufügen 18 | Comment[el]=Προσθαφαίρεση λογισμικού στο σύστημα 19 | Comment[en@shaw]=𐑨𐑛 𐑹 𐑮𐑦𐑥𐑵𐑝 𐑕𐑪𐑓𐑑𐑢𐑺 𐑦𐑯𐑕𐑑𐑷𐑤𐑛 𐑪𐑯 𐑞 𐑕𐑦𐑕𐑑𐑩𐑥 20 | Comment[en_GB]=Add or remove software installed on the system 21 | Comment[eo]=Aldoni aŭ forigi instalitan pogramaron sur via sistemo 22 | Comment[es]=Añadir o quitar software instalado en el sistema 23 | Comment[et]=Arvutisse paigaldatud tarkvara lisamine ja eemaldamine 24 | Comment[eu]=Gehitu edo kendu sisteman instalatutako softwarea 25 | Comment[fa]=حذف یا افزودن نرم‌افزارهای نصب شده بر روی این سیستم 26 | Comment[fi]=Lisää tai poista järjestelmään asennettuja ohjelmistoja 27 | Comment[fr]=Ajouter ou supprimer des logiciels installés sur le système 28 | Comment[gl]=Engadir e eliminar o software instalado no sistema 29 | Comment[gu]=સિસ્ટમ પર સ્થાપિત થયેલ સોફ્ટવેરને ઉમેરો અથવા દૂર કરો 30 | Comment[he]=הוספה או הסרה של יישומי המערכת 31 | Comment[hi]=सिस्टम पर संस्थापित सॉफ्टवेयर जोड़ें या हटाएँ 32 | Comment[hu]=Szoftverek rendszerre telepítése vagy eltávolítása 33 | Comment[id]=Tambah atau hapus perangkat lunak yang terpasang pada sistem 34 | Comment[it]=Aggiunge o rimuove software installato sul sistema 35 | Comment[ja]=システムにインストールされたパッケージの追加と削除 36 | Comment[kn]=ಗಣಕಕ್ಕೆ ತಂತ್ರಾಂಶವನ್ನು ಸೇರಿಸು ಅಥವ ಅನುಸ್ಥಾಪಿತಗೊಂಡಿರುವುದನ್ನು ತೆಗೆದು ಹಾಕು 37 | Comment[ko]=시스템에 설치하는 소프트웨어를 추가하거나 제거합니다 38 | Comment[lt]=Įdiegti ar šalinti sistemoje įdiegtą programinę įrangą 39 | Comment[lv]=Pievienot vai izņemt programmatūru sistēmā 40 | Comment[mk]=Инсталирајте или избришете софтвер на системот 41 | Comment[ml]=സിസ്റ്റത്തില്‍ ഇന്‍സ്റ്റോള്‍ ചെയ്തിരിക്കുന്ന സോഫ്റ്റ്‌വെയര്‍ ചേര്‍ക്കുക അല്ലെങ്കില്‍ നീക്കം ചെയ്യുക 42 | Comment[mr]=प्रणालीवर प्रतिष्ठापीत सॉफ्टवेअर समावेष करा किंवा काढूण टाका 43 | Comment[ms]=Menambah atau memadam perisian yang dipasang pada sistem 44 | Comment[nb]=Legg til eller fjern programvare på systemet 45 | Comment[nl]=Software installeren op, of verwijderen van het systeem 46 | Comment[nn]=Legg til eller fjern programvare som er installert på systemet 47 | Comment[or]=ତନ୍ତ୍ରରେ ସ୍ଥାପିତ ସଫ୍ଟୱେରରେ ଯୋଗକରନ୍ତୁ କିମ୍ବା କାଢ଼ି ଦିଅନ୍ତୁ 48 | Comment[pa]=ਸਿਸਟਮ ਉੱਤੇ ਸਾਫਟਵੇਅਰ ਇੰਸਟਾਲ ਕਰੋ ਜਾਂ ਇੰਸਟਾਲ ਕੀਤੇ ਹਟਾਓ 49 | Comment[pl]=Instalowanie lub usuwanie oprogramowania zainstalowanego w systemie 50 | Comment[pt]=Adicionar ou remover software instalado no sistema 51 | Comment[pt_BR]=Adicione ou remova programas instalados no sistema 52 | Comment[ro]=Adăugați sau ștergeți programe instalate pe sistem 53 | Comment[ru]=Установка и удаление программ, установленных в системе 54 | Comment[sk]=Pridať alebo odstrániť softvér nainštalovaný v systéme 55 | Comment[sl]=Nameščanje in odstranjevanje programske opreme sistema 56 | Comment[sr@latin]=Dodajte ili uklonite programe instalirane na ovom sistemu 57 | Comment[sr]=Додајте или уклоните програме инсталиране на овом систему 58 | Comment[sv]=Lägg till eller ta bort programvara installerad på systemet 59 | Comment[ta]=கணினியில் நிறுவப்பட்ட மென்பொருளை சேர்க்கவும் அல்லது நீக்கவும் 60 | Comment[te]=ఈ వ్యవస్థ నందు స్థాపించిన సాఫ్ట్‍వేర్‌ను జతచేయి లేదా తీసివేయి 61 | Comment[th]=เพิ่มหรือลบซอฟต์แวร์ที่ติดตั้งในระบบ 62 | Comment[tr]=Sisteminizde yüklü yazılımları ekleyin veya kaldırın 63 | Comment[ug]=سىستېمىڭىزغا ئورنىتىلغان يۇمشاق دېتاللارنى قوشىدۇ ياكى ئۆچۈرىدۇ 64 | Comment[uk]=Встановлення та вилучення програм у системі 65 | Comment[vi]=Thêm hoặc gỡ phần mềm cài đặt trên hệ thống 66 | Comment[zh_CN]=添加或删除系统中安装的软件 67 | Comment[zh_HK]=加入或移除系統上安裝的軟件 68 | Comment[zh_TW]=加入或移除系統上安裝的軟體 69 | Exec=/usr/local/bin/octopkg 70 | Name[en_US]=OctoPkg 71 | Name=OctoPkg 72 | Icon=octopi 73 | MimeType= 74 | GenericName[en_US]=Add/Remove Software 75 | GenericName=Add/Remove Software 76 | GenericName[af]=Voeg by/verwyder sagteware 77 | GenericName[ar]=إضافة وإزالة البرمجيات 78 | GenericName[as]=চালনাজ্ঞান যোগ কৰক/আঁতৰাই দিয়ক 79 | GenericName[ast]=Amestar/Quitar software 80 | GenericName[be]=Дадаць/выдаліць апраграмаванне 81 | GenericName[bg]=Инсталиране/деинсталиране на софтуер 82 | GenericName[bn]=সফ্টওয়্যার যোগ/অপসারণ 83 | GenericName[bn_IN]=সফ্টওয়্যার যোগ/অপসারণ করুন 84 | GenericName[ca@valencia]=Afig/Suprimeix programari 85 | GenericName[ca]=Afegeix/Suprimeix programari 86 | GenericName[cs]=Přidat/odebrat software 87 | GenericName[da]=Tilføj/fjern software 88 | GenericName[de]=Software hinzufügen/entfernen 89 | GenericName[el]=Προσθαφαίρεση λογισμικού 90 | GenericName[en@shaw]=𐑨𐑛/𐑮𐑦𐑥𐑵𐑝 𐑕𐑪𐑓𐑑𐑢𐑺 91 | GenericName[en_GB]=Add/Remove Software 92 | GenericName[eo]=Aldoni/forigi instalitan pogramaron 93 | GenericName[es]=Añadir/Quitar software 94 | GenericName[et]=Tarkvara lisamine ja eemaldamine 95 | GenericName[eu]=Gehitu/Kendu softwarea 96 | GenericName[fa]=افزودن/حذف نرم‌افزار 97 | GenericName[fi]=Lisää tai poista ohjelmistoja 98 | GenericName[fr]=Ajouter/supprimer des logiciels 99 | GenericName[ga]=Cuir Leis/Bain Bogearraí 100 | GenericName[gl]=Engadir ou eliminar programas 101 | GenericName[gu]=સોફ્ટવેરને ઉમેરો/દૂર કરો 102 | GenericName[he]=הוספת/הסרת תכנה 103 | GenericName[hi]=सॉफ्टवेयर जोड़ें/हटायें 104 | GenericName[hu]=Szoftver telepítése/eltávolítása 105 | GenericName[id]=Tambah/Hapus Piranti Lunak 106 | GenericName[it]=Aggiungi/Rimuovi software 107 | GenericName[ja]=ソフトウェアの追加と削除 108 | GenericName[kn]=ತಂತ್ರಾಂಶವನ್ನು ಸೇರಿಸು ಅಥವ ತೆಗೆ 109 | GenericName[ko]=소프트웨어 추가/제거 110 | GenericName[lt]=Įdiegti ar šalinti programinę įrangą 111 | GenericName[lv]=Pievienot/Izņemt programmatūru 112 | GenericName[mk]=Инсталирај/избриши софтвер 113 | GenericName[ml]=സോഫ്റ്റ്‌വെയര്‍ ചേര്‍ക്കുക/നീക്കം ചെയ്യുക 114 | GenericName[mr]=सॉफ्टवेअर जोडा/काढून टाका 115 | GenericName[ms]=Menambah/Memadam perisian 116 | GenericName[nb]=Legg til/fjern programvare 117 | GenericName[nl]=Software installeren/verwijderen 118 | GenericName[nn]=Legg til/fjern programvare 119 | GenericName[or]=ସଫ୍ଟୱେର ଯୋଗ/ଅପସାରଣ କରନ୍ତୁ 120 | GenericName[pa]=ਸਾਫਟਵੇਅਰ ਸ਼ਾਮਲ/ਹਟਾਓ 121 | GenericName[pl]=Dodanie/usuwanie oprogramowania 122 | GenericName[pt]=Adicionar/Remover Software 123 | GenericName[pt_BR]=Adicionar/remover programas 124 | GenericName[ro]=Adăugare sau ștergere programe 125 | GenericName[ru]=Установка и удаление программ 126 | GenericName[sk]=Pridať/odstrániť softvér 127 | GenericName[sl]=Upravljanje programske opreme 128 | GenericName[sr@latin]=Dodaj-ukloni programe 129 | GenericName[sr]=Додај-уклони програме 130 | GenericName[sv]=Lägg till/Ta bort programvara 131 | GenericName[ta]=மென்பொருளை சேர்த்தல்/நீக்குதல் 132 | GenericName[te]=సాఫ్ట్‍వేర్ జతచేయి/తీసివేయి 133 | GenericName[th]=เพิ่ม/ลบซอฟต์แวร์ 134 | GenericName[tr]=Yazılım Ekle/Kaldır 135 | GenericName[ug]=يۇمشاق دېتالنى قوش/ئۆچۈر 136 | GenericName[uk]=Встановлення та вилучення програм 137 | GenericName[vi]=Thêm/Gỡ phần mềm 138 | GenericName[zh_CN]=添加/删除软件 139 | GenericName[zh_HK]=加入或移除軟件 140 | GenericName[zh_TW]=加入或移除軟體 141 | Path= 142 | StartupNotify=true 143 | Terminal=false 144 | TerminalOptions= 145 | Type=Application 146 | X-DBUS-ServiceName= 147 | X-DBUS-StartupType= 148 | X-KDE-SubstituteUID=false 149 | X-KDE-Username= 150 | -------------------------------------------------------------------------------- /octopkg.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-06-04T20:45:08 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network xml widgets 8 | DEFINES += OCTOPKG_EXTENSIONS 9 | CONFIG += qt warn_on debug 10 | LIBS += -L/usr/local/lib 11 | INCLUDEPATH += /usr/local/include 12 | QMAKE_CXXFLAGS += -std=c++17 13 | TEMPLATE = app 14 | DESTDIR += bin 15 | OBJECTS_DIR += build 16 | MOC_DIR += build 17 | UI_DIR += build 18 | 19 | HEADERS += src/QtSolutions/qtsingleapplication.h \ 20 | src/packagetreeview.h \ 21 | src/QtSolutions/qtlocalpeer.h \ 22 | src/constants.h \ 23 | src/mainwindow.h \ 24 | src/strconstants.h \ 25 | src/searchlineedit.h \ 26 | src/argumentlist.h \ 27 | src/settingsmanager.h \ 28 | src/uihelper.h \ 29 | src/package.h \ 30 | src/unixcommand.h \ 31 | src/wmhelper.h \ 32 | src/treeviewpackagesitemdelegate.h \ 33 | src/searchbar.h \ 34 | src/transactiondialog.h \ 35 | src/globals.h \ 36 | src/packagerepository.h \ 37 | src/model/packagemodel.h \ 38 | src/ui/octopkgtabinfo.h \ 39 | src/utils.h 40 | 41 | SOURCES += src/QtSolutions/qtsingleapplication.cpp \ 42 | src/packagetreeview.cpp \ 43 | src/QtSolutions/qtlocalpeer.cpp \ 44 | src/main.cpp\ 45 | src/mainwindow.cpp \ 46 | src/strconstants.cpp \ 47 | src/searchlineedit.cpp \ 48 | src/argumentlist.cpp \ 49 | src/settingsmanager.cpp \ 50 | src/package.cpp \ 51 | src/unixcommand.cpp \ 52 | src/wmhelper.cpp \ 53 | src/treeviewpackagesitemdelegate.cpp \ 54 | src/mainwindow_init.cpp \ 55 | src/mainwindow_transaction.cpp \ 56 | src/mainwindow_events.cpp \ 57 | src/mainwindow_help.cpp \ 58 | src/searchbar.cpp \ 59 | src/mainwindow_searchbar.cpp \ 60 | src/transactiondialog.cpp \ 61 | src/mainwindow_news.cpp \ 62 | src/mainwindow_refresh.cpp \ 63 | src/globals.cpp \ 64 | src/packagerepository.cpp \ 65 | src/model/packagemodel.cpp \ 66 | src/ui/octopkgtabinfo.cpp \ 67 | src/utils.cpp 68 | 69 | FORMS += ui/mainwindow.ui \ 70 | ui/transactiondialog.ui 71 | 72 | RESOURCES += resources.qrc 73 | #TRANSLATIONS += resources/translations/octopkg_pt_BR.ts 74 | 75 | isEmpty(PREFIX) { 76 | PREFIX = /usr/local 77 | } 78 | 79 | isEmpty(DATADIR) { 80 | DATADIR = $$PREFIX/share 81 | } 82 | 83 | isEmpty(BINDIR) { 84 | BINDIR = $$PREFIX/bin 85 | } 86 | 87 | target.path = $$BINDIR 88 | bin.path = $$BINDIR 89 | 90 | desktop.path = $$DATADIR/applications 91 | desktop.files += octopkg.desktop 92 | 93 | icon.path = $$DATADIR/icons 94 | icon.files += resources/images/octopi.png 95 | 96 | INSTALLS += target bin desktop icon 97 | -------------------------------------------------------------------------------- /release-languages.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | # Helper for Qt5 libs to generate all Octopkg translations 3 | 4 | TRANSLATIONS=./resources/translations/* 5 | 6 | for f in $TRANSLATIONS 7 | do 8 | lrelease-qt5 $f 9 | done 10 | -------------------------------------------------------------------------------- /resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/styles/branch-closed_BW.png 4 | resources/styles/branch-closed.png 5 | resources/styles/branch-end.png 6 | resources/styles/branch-more.png 7 | resources/styles/branch-open_BW.png 8 | resources/styles/branch-open.png 9 | resources/styles/vline.png 10 | resources/images/drive-harddisk.png 11 | resources/images/applications-internet.png 12 | resources/images/cloud.png 13 | resources/images/octopi_transparent.png 14 | resources/images/octopi_red.png 15 | resources/images/octopi_yellow.png 16 | resources/images/octopi_green.png 17 | resources/images/esf-search.png 18 | resources/images/esf-clear.png 19 | resources/images/installed.png 20 | resources/images/noninstalled.png 21 | resources/images/toinstall.png 22 | resources/images/toremove.png 23 | resources/images/folder.png 24 | resources/images/binary.png 25 | resources/images/outdated.png 26 | resources/images/unrequired.png 27 | resources/images/locker-key.png 28 | resources/images/unlock.png 29 | resources/images/commit.png 30 | resources/images/refresh.png 31 | resources/images/fast_forward.png 32 | resources/images/exit.png 33 | resources/images/rollback.png 34 | resources/images/editfile.png 35 | resources/images/edit-copy.png 36 | resources/images/collapse.png 37 | resources/images/expand.png 38 | resources/images/terminal.png 39 | resources/images/window_close.png 40 | resources/images/folder_gnome.png 41 | resources/images/install_item.png 42 | resources/images/remove_item.png 43 | resources/images/find.png 44 | resources/images/rss.png 45 | resources/images/newer.png 46 | resources/images/foreign_green.png 47 | resources/images/foreign_red.png 48 | resources/images/show_groups.png 49 | resources/images/mirror-check.png 50 | resources/images/cachecleaner.png 51 | resources/images/stop_small_red.png 52 | 53 | 54 | -------------------------------------------------------------------------------- /resources/images/applications-internet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/applications-internet.png -------------------------------------------------------------------------------- /resources/images/binary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/binary.png -------------------------------------------------------------------------------- /resources/images/cachecleaner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/cachecleaner.png -------------------------------------------------------------------------------- /resources/images/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/cloud.png -------------------------------------------------------------------------------- /resources/images/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/collapse.png -------------------------------------------------------------------------------- /resources/images/commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/commit.png -------------------------------------------------------------------------------- /resources/images/drive-harddisk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/drive-harddisk.png -------------------------------------------------------------------------------- /resources/images/edit-copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/edit-copy.png -------------------------------------------------------------------------------- /resources/images/editfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/editfile.png -------------------------------------------------------------------------------- /resources/images/esf-clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/esf-clear.png -------------------------------------------------------------------------------- /resources/images/esf-search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/esf-search.png -------------------------------------------------------------------------------- /resources/images/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/exit.png -------------------------------------------------------------------------------- /resources/images/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/expand.png -------------------------------------------------------------------------------- /resources/images/fast_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/fast_forward.png -------------------------------------------------------------------------------- /resources/images/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/find.png -------------------------------------------------------------------------------- /resources/images/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/folder.png -------------------------------------------------------------------------------- /resources/images/folder_gnome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/folder_gnome.png -------------------------------------------------------------------------------- /resources/images/foreign_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/foreign_green.png -------------------------------------------------------------------------------- /resources/images/foreign_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/foreign_red.png -------------------------------------------------------------------------------- /resources/images/install_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/install_item.png -------------------------------------------------------------------------------- /resources/images/installed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/installed.png -------------------------------------------------------------------------------- /resources/images/locker-key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/locker-key.png -------------------------------------------------------------------------------- /resources/images/mirror-check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/mirror-check.png -------------------------------------------------------------------------------- /resources/images/newer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/newer.png -------------------------------------------------------------------------------- /resources/images/noninstalled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/noninstalled.png -------------------------------------------------------------------------------- /resources/images/octopi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/octopi.png -------------------------------------------------------------------------------- /resources/images/octopi_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/octopi_green.png -------------------------------------------------------------------------------- /resources/images/octopi_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/octopi_red.png -------------------------------------------------------------------------------- /resources/images/octopi_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/octopi_transparent.png -------------------------------------------------------------------------------- /resources/images/octopi_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/octopi_yellow.png -------------------------------------------------------------------------------- /resources/images/outdated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/outdated.png -------------------------------------------------------------------------------- /resources/images/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/refresh.png -------------------------------------------------------------------------------- /resources/images/remove_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/remove_item.png -------------------------------------------------------------------------------- /resources/images/rollback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/rollback.png -------------------------------------------------------------------------------- /resources/images/rss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/rss.png -------------------------------------------------------------------------------- /resources/images/show_groups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/show_groups.png -------------------------------------------------------------------------------- /resources/images/stop_small_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/stop_small_red.png -------------------------------------------------------------------------------- /resources/images/terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/terminal.png -------------------------------------------------------------------------------- /resources/images/toinstall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/toinstall.png -------------------------------------------------------------------------------- /resources/images/toremove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/toremove.png -------------------------------------------------------------------------------- /resources/images/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/unlock.png -------------------------------------------------------------------------------- /resources/images/unrequired.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/unrequired.png -------------------------------------------------------------------------------- /resources/images/window_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/images/window_close.png -------------------------------------------------------------------------------- /resources/styles/branch-closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/branch-closed.png -------------------------------------------------------------------------------- /resources/styles/branch-closed_BW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/branch-closed_BW.png -------------------------------------------------------------------------------- /resources/styles/branch-end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/branch-end.png -------------------------------------------------------------------------------- /resources/styles/branch-more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/branch-more.png -------------------------------------------------------------------------------- /resources/styles/branch-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/branch-open.png -------------------------------------------------------------------------------- /resources/styles/branch-open_BW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/branch-open_BW.png -------------------------------------------------------------------------------- /resources/styles/vline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarnt/octopkg/db480d0ac154f505b35feee6534ee88f610bba7a/resources/styles/vline.png -------------------------------------------------------------------------------- /src/QtSolutions/QtLockedFile: -------------------------------------------------------------------------------- 1 | #include "qtlockedfile.h" 2 | -------------------------------------------------------------------------------- /src/QtSolutions/QtSingleApplication: -------------------------------------------------------------------------------- 1 | #include "qtsingleapplication.h" 2 | -------------------------------------------------------------------------------- /src/QtSolutions/qtlocalpeer.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | 41 | #include "qtlocalpeer.h" 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 48 | #include 49 | #endif 50 | 51 | #if defined(Q_OS_WIN) 52 | #include 53 | #include 54 | typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); 55 | static PProcessIdToSessionId pProcessIdToSessionId = 0; 56 | #endif 57 | #if defined(Q_OS_UNIX) 58 | #include //needed by GCC-4.7 compilers 59 | #include 60 | #endif 61 | 62 | namespace QtLP_Private { 63 | #include "qtlockedfile.cpp" 64 | #if defined(Q_OS_WIN) 65 | #include "qtlockedfile_win.cpp" 66 | #else 67 | #include "qtlockedfile_unix.cpp" 68 | #endif 69 | } 70 | 71 | const char* QtLocalPeer::ack = "ack"; 72 | 73 | QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) 74 | : QObject(parent), id(appId) 75 | { 76 | QString prefix = id; 77 | if (id.isEmpty()) { 78 | id = QCoreApplication::applicationFilePath(); 79 | #if defined(Q_OS_WIN) 80 | id = id.toLower(); 81 | #endif 82 | prefix = id.section(QLatin1Char('/'), -1); 83 | } 84 | prefix.remove(QRegularExpression("[^a-zA-Z]")); 85 | prefix.truncate(6); 86 | 87 | QByteArray idc = id.toUtf8(); 88 | 89 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 90 | quint16 idNum = qChecksum(QByteArrayView(idc.constData(), idc.size()), Qt::ChecksumIso3309); 91 | #else 92 | quint16 idNum = qChecksum(idc.constData(), idc.size()); 93 | #endif 94 | 95 | socketName = QLatin1String("qtsingleapp-") + prefix + 96 | QLatin1Char('-') + QString::number(idNum, 16); 97 | 98 | #if defined(Q_OS_WIN) 99 | if (!pProcessIdToSessionId) { 100 | QLibrary lib("kernel32"); 101 | pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); 102 | } 103 | if (pProcessIdToSessionId) { 104 | DWORD sessionId = 0; 105 | pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); 106 | socketName += QLatin1Char('-') + QString::number(sessionId, 16); 107 | } 108 | #else 109 | socketName += QLatin1Char('-') + QString::number(::getuid(), 16); 110 | #endif 111 | 112 | server = new QLocalServer(this); 113 | QString lockName = QDir(QDir::tempPath()).absolutePath() 114 | + QLatin1Char('/') + socketName 115 | + QLatin1String("-lockfile"); 116 | lockFile.setFileName(lockName); 117 | lockFile.open(QIODevice::ReadWrite); 118 | } 119 | 120 | 121 | 122 | bool QtLocalPeer::isClient() 123 | { 124 | if (lockFile.isLocked()) 125 | return false; 126 | 127 | if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) 128 | return true; 129 | 130 | bool res = server->listen(socketName); 131 | #if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) 132 | // ### Workaround 133 | if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { 134 | QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); 135 | res = server->listen(socketName); 136 | } 137 | #endif 138 | if (!res) 139 | qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); 140 | QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); 141 | return false; 142 | } 143 | 144 | 145 | bool QtLocalPeer::sendMessage(const QString &message, int timeout) 146 | { 147 | if (!isClient()) 148 | return false; 149 | 150 | QLocalSocket socket; 151 | bool connOk = false; 152 | for(int i = 0; i < 2; i++) { 153 | // Try twice, in case the other instance is just starting up 154 | socket.connectToServer(socketName); 155 | connOk = socket.waitForConnected(timeout/2); 156 | if (connOk || i) 157 | break; 158 | int ms = 250; 159 | #if defined(Q_OS_WIN) 160 | Sleep(DWORD(ms)); 161 | #else 162 | struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; 163 | nanosleep(&ts, NULL); 164 | #endif 165 | } 166 | if (!connOk) 167 | return false; 168 | 169 | QByteArray uMsg(message.toUtf8()); 170 | QDataStream ds(&socket); 171 | ds.writeBytes(uMsg.constData(), uMsg.size()); 172 | bool res = socket.waitForBytesWritten(timeout); 173 | if (res) { 174 | res &= socket.waitForReadyRead(timeout); // wait for ack 175 | if (res) 176 | res &= (socket.read(qstrlen(ack)) == ack); 177 | } 178 | return res; 179 | } 180 | 181 | 182 | void QtLocalPeer::receiveConnection() 183 | { 184 | QLocalSocket* socket = server->nextPendingConnection(); 185 | if (!socket) 186 | return; 187 | 188 | while (socket->bytesAvailable() < (int)sizeof(quint32)) 189 | socket->waitForReadyRead(); 190 | QDataStream ds(socket); 191 | QByteArray uMsg; 192 | quint32 remaining; 193 | ds >> remaining; 194 | uMsg.resize(remaining); 195 | int got = 0; 196 | char* uMsgBuf = uMsg.data(); 197 | do { 198 | got = ds.readRawData(uMsgBuf, remaining); 199 | remaining -= got; 200 | uMsgBuf += got; 201 | } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); 202 | if (got < 0) { 203 | qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); 204 | delete socket; 205 | return; 206 | } 207 | QString message(QString::fromUtf8(uMsg)); 208 | socket->write(ack, qstrlen(ack)); 209 | socket->waitForBytesWritten(1000); 210 | delete socket; 211 | emit messageReceived(message); //### (might take a long time to return) 212 | } 213 | -------------------------------------------------------------------------------- /src/QtSolutions/qtlocalpeer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTLOCALPEER_H 41 | #define QTLOCALPEER_H 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | #include "qtlockedfile.h" 48 | 49 | class QtLocalPeer : public QObject 50 | { 51 | Q_OBJECT 52 | 53 | public: 54 | QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); 55 | bool isClient(); 56 | bool sendMessage(const QString &message, int timeout); 57 | QString applicationId() const 58 | { return id; } 59 | 60 | Q_SIGNALS: 61 | void messageReceived(const QString &message); 62 | 63 | protected Q_SLOTS: 64 | void receiveConnection(); 65 | 66 | protected: 67 | QString id; 68 | QString socketName; 69 | QLocalServer* server; 70 | QtLP_Private::QtLockedFile lockFile; 71 | 72 | private: 73 | static const char* ack; 74 | }; 75 | 76 | #endif // QTLOCALPEER_H 77 | -------------------------------------------------------------------------------- /src/QtSolutions/qtlockedfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #include "qtlockedfile.h" 41 | 42 | /*! 43 | \class QtLockedFile 44 | 45 | \brief The QtLockedFile class extends QFile with advisory locking 46 | functions. 47 | 48 | A file may be locked in read or write mode. Multiple instances of 49 | \e QtLockedFile, created in multiple processes running on the same 50 | machine, may have a file locked in read mode. Exactly one instance 51 | may have it locked in write mode. A read and a write lock cannot 52 | exist simultaneously on the same file. 53 | 54 | The file locks are advisory. This means that nothing prevents 55 | another process from manipulating a locked file using QFile or 56 | file system functions offered by the OS. Serialization is only 57 | guaranteed if all processes that access the file use 58 | QLockedFile. Also, while holding a lock on a file, a process 59 | must not open the same file again (through any API), or locks 60 | can be unexpectedly lost. 61 | 62 | The lock provided by an instance of \e QtLockedFile is released 63 | whenever the program terminates. This is true even when the 64 | program crashes and no destructors are called. 65 | */ 66 | 67 | /*! \enum QtLockedFile::LockMode 68 | 69 | This enum describes the available lock modes. 70 | 71 | \value ReadLock A read lock. 72 | \value WriteLock A write lock. 73 | \value NoLock Neither a read lock nor a write lock. 74 | */ 75 | 76 | /*! 77 | Constructs an unlocked \e QtLockedFile object. This constructor 78 | behaves in the same way as \e QFile::QFile(). 79 | 80 | \sa QFile::QFile() 81 | */ 82 | QtLockedFile::QtLockedFile() 83 | : QFile() 84 | { 85 | #ifdef Q_OS_WIN 86 | wmutex = 0; 87 | rmutex = 0; 88 | #endif 89 | m_lock_mode = NoLock; 90 | } 91 | 92 | /*! 93 | Constructs an unlocked QtLockedFile object with file \a name. This 94 | constructor behaves in the same way as \e QFile::QFile(const 95 | QString&). 96 | 97 | \sa QFile::QFile() 98 | */ 99 | QtLockedFile::QtLockedFile(const QString &name) 100 | : QFile(name) 101 | { 102 | #ifdef Q_OS_WIN 103 | wmutex = 0; 104 | rmutex = 0; 105 | #endif 106 | m_lock_mode = NoLock; 107 | } 108 | 109 | /*! 110 | Opens the file in OpenMode \a mode. 111 | 112 | This is identical to QFile::open(), with the one exception that the 113 | Truncate mode flag is disallowed. Truncation would conflict with the 114 | advisory file locking, since the file would be modified before the 115 | write lock is obtained. If truncation is required, use resize(0) 116 | after obtaining the write lock. 117 | 118 | Returns true if successful; otherwise false. 119 | 120 | \sa QFile::open(), QFile::resize() 121 | */ 122 | bool QtLockedFile::open(OpenMode mode) 123 | { 124 | if (mode & QIODevice::Truncate) { 125 | qWarning("QtLockedFile::open(): Truncate mode not allowed."); 126 | return false; 127 | } 128 | return QFile::open(mode); 129 | } 130 | 131 | /*! 132 | Returns \e true if this object has a in read or write lock; 133 | otherwise returns \e false. 134 | 135 | \sa lockMode() 136 | */ 137 | bool QtLockedFile::isLocked() const 138 | { 139 | return m_lock_mode != NoLock; 140 | } 141 | 142 | /*! 143 | Returns the type of lock currently held by this object, or \e 144 | QtLockedFile::NoLock. 145 | 146 | \sa isLocked() 147 | */ 148 | QtLockedFile::LockMode QtLockedFile::lockMode() const 149 | { 150 | return m_lock_mode; 151 | } 152 | 153 | /*! 154 | \fn bool QtLockedFile::lock(LockMode mode, bool block = true) 155 | 156 | Obtains a lock of type \a mode. The file must be opened before it 157 | can be locked. 158 | 159 | If \a block is true, this function will block until the lock is 160 | aquired. If \a block is false, this function returns \e false 161 | immediately if the lock cannot be aquired. 162 | 163 | If this object already has a lock of type \a mode, this function 164 | returns \e true immediately. If this object has a lock of a 165 | different type than \a mode, the lock is first released and then a 166 | new lock is obtained. 167 | 168 | This function returns \e true if, after it executes, the file is 169 | locked by this object, and \e false otherwise. 170 | 171 | \sa unlock(), isLocked(), lockMode() 172 | */ 173 | 174 | /*! 175 | \fn bool QtLockedFile::unlock() 176 | 177 | Releases a lock. 178 | 179 | If the object has no lock, this function returns immediately. 180 | 181 | This function returns \e true if, after it executes, the file is 182 | not locked by this object, and \e false otherwise. 183 | 184 | \sa lock(), isLocked(), lockMode() 185 | */ 186 | 187 | /*! 188 | \fn QtLockedFile::~QtLockedFile() 189 | 190 | Destroys the \e QtLockedFile object. If any locks were held, they 191 | are released. 192 | */ 193 | -------------------------------------------------------------------------------- /src/QtSolutions/qtlockedfile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTLOCKEDFILE_H 41 | #define QTLOCKEDFILE_H 42 | 43 | #include 44 | #ifdef Q_OS_WIN 45 | #include 46 | #endif 47 | 48 | #if defined(Q_WS_WIN) 49 | # if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) 50 | # define QT_QTLOCKEDFILE_EXPORT 51 | # elif defined(QT_QTLOCKEDFILE_IMPORT) 52 | # if defined(QT_QTLOCKEDFILE_EXPORT) 53 | # undef QT_QTLOCKEDFILE_EXPORT 54 | # endif 55 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) 56 | # elif defined(QT_QTLOCKEDFILE_EXPORT) 57 | # undef QT_QTLOCKEDFILE_EXPORT 58 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) 59 | # endif 60 | #else 61 | # define QT_QTLOCKEDFILE_EXPORT 62 | #endif 63 | 64 | namespace QtLP_Private { 65 | 66 | class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile 67 | { 68 | public: 69 | enum LockMode { NoLock = 0, ReadLock, WriteLock }; 70 | 71 | QtLockedFile(); 72 | QtLockedFile(const QString &name); 73 | ~QtLockedFile(); 74 | 75 | bool open(OpenMode mode); 76 | 77 | bool lock(LockMode mode, bool block = true); 78 | bool unlock(); 79 | bool isLocked() const; 80 | LockMode lockMode() const; 81 | 82 | private: 83 | #ifdef Q_OS_WIN 84 | Qt::HANDLE wmutex; 85 | Qt::HANDLE rmutex; 86 | QVector rmutexes; 87 | QString mutexname; 88 | 89 | Qt::HANDLE getMutexHandle(int idx, bool doCreate); 90 | bool waitMutex(Qt::HANDLE mutex, bool doBlock); 91 | 92 | #endif 93 | LockMode m_lock_mode; 94 | }; 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /src/QtSolutions/qtlockedfile_unix.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "qtlockedfile.h" 46 | 47 | bool QtLockedFile::lock(LockMode mode, bool block) 48 | { 49 | if (!isOpen()) { 50 | qWarning("QtLockedFile::lock(): file is not opened"); 51 | return false; 52 | } 53 | 54 | if (mode == NoLock) 55 | return unlock(); 56 | 57 | if (mode == m_lock_mode) 58 | return true; 59 | 60 | if (m_lock_mode != NoLock) 61 | unlock(); 62 | 63 | struct flock fl; 64 | fl.l_whence = SEEK_SET; 65 | fl.l_start = 0; 66 | fl.l_len = 0; 67 | fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; 68 | int cmd = block ? F_SETLKW : F_SETLK; 69 | int ret = fcntl(handle(), cmd, &fl); 70 | 71 | if (ret == -1) { 72 | if (errno != EINTR && errno != EAGAIN) 73 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 74 | return false; 75 | } 76 | 77 | 78 | m_lock_mode = mode; 79 | return true; 80 | } 81 | 82 | 83 | bool QtLockedFile::unlock() 84 | { 85 | if (!isOpen()) { 86 | qWarning("QtLockedFile::unlock(): file is not opened"); 87 | return false; 88 | } 89 | 90 | if (!isLocked()) 91 | return true; 92 | 93 | struct flock fl; 94 | fl.l_whence = SEEK_SET; 95 | fl.l_start = 0; 96 | fl.l_len = 0; 97 | fl.l_type = F_UNLCK; 98 | int ret = fcntl(handle(), F_SETLKW, &fl); 99 | 100 | if (ret == -1) { 101 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 102 | return false; 103 | } 104 | 105 | m_lock_mode = NoLock; 106 | return true; 107 | } 108 | 109 | QtLockedFile::~QtLockedFile() 110 | { 111 | if (isOpen()) 112 | unlock(); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /src/QtSolutions/qtlockedfile_win.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #include "qtlockedfile.h" 41 | #include 42 | #include 43 | 44 | #define MUTEX_PREFIX "QtLockedFile mutex " 45 | // Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS 46 | #define MAX_READERS MAXIMUM_WAIT_OBJECTS 47 | 48 | Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) 49 | { 50 | if (mutexname.isEmpty()) { 51 | QFileInfo fi(*this); 52 | mutexname = QString::fromLatin1(MUTEX_PREFIX) 53 | + fi.absoluteFilePath().toLower(); 54 | } 55 | QString mname(mutexname); 56 | if (idx >= 0) 57 | mname += QString::number(idx); 58 | 59 | Qt::HANDLE mutex; 60 | if (doCreate) { 61 | QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, 62 | { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); 63 | if (!mutex) { 64 | qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); 65 | return 0; 66 | } 67 | } 68 | else { 69 | QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, 70 | { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); 71 | if (!mutex) { 72 | if (GetLastError() != ERROR_FILE_NOT_FOUND) 73 | qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); 74 | return 0; 75 | } 76 | } 77 | return mutex; 78 | } 79 | 80 | bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) 81 | { 82 | Q_ASSERT(mutex); 83 | DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); 84 | switch (res) { 85 | case WAIT_OBJECT_0: 86 | case WAIT_ABANDONED: 87 | return true; 88 | break; 89 | case WAIT_TIMEOUT: 90 | break; 91 | default: 92 | qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); 93 | } 94 | return false; 95 | } 96 | 97 | 98 | 99 | bool QtLockedFile::lock(LockMode mode, bool block) 100 | { 101 | if (!isOpen()) { 102 | qWarning("QtLockedFile::lock(): file is not opened"); 103 | return false; 104 | } 105 | 106 | if (mode == NoLock) 107 | return unlock(); 108 | 109 | if (mode == m_lock_mode) 110 | return true; 111 | 112 | if (m_lock_mode != NoLock) 113 | unlock(); 114 | 115 | if (!wmutex && !(wmutex = getMutexHandle(-1, true))) 116 | return false; 117 | 118 | if (!waitMutex(wmutex, block)) 119 | return false; 120 | 121 | if (mode == ReadLock) { 122 | int idx = 0; 123 | for (; idx < MAX_READERS; idx++) { 124 | rmutex = getMutexHandle(idx, false); 125 | if (!rmutex || waitMutex(rmutex, false)) 126 | break; 127 | CloseHandle(rmutex); 128 | } 129 | bool ok = true; 130 | if (idx >= MAX_READERS) { 131 | qWarning("QtLockedFile::lock(): too many readers"); 132 | rmutex = 0; 133 | ok = false; 134 | } 135 | else if (!rmutex) { 136 | rmutex = getMutexHandle(idx, true); 137 | if (!rmutex || !waitMutex(rmutex, false)) 138 | ok = false; 139 | } 140 | if (!ok && rmutex) { 141 | CloseHandle(rmutex); 142 | rmutex = 0; 143 | } 144 | ReleaseMutex(wmutex); 145 | if (!ok) 146 | return false; 147 | } 148 | else { 149 | Q_ASSERT(rmutexes.isEmpty()); 150 | for (int i = 0; i < MAX_READERS; i++) { 151 | Qt::HANDLE mutex = getMutexHandle(i, false); 152 | if (mutex) 153 | rmutexes.append(mutex); 154 | } 155 | if (rmutexes.size()) { 156 | DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), 157 | TRUE, block ? INFINITE : 0); 158 | if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { 159 | if (res != WAIT_TIMEOUT) 160 | qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); 161 | m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky 162 | unlock(); 163 | return false; 164 | } 165 | } 166 | } 167 | 168 | m_lock_mode = mode; 169 | return true; 170 | } 171 | 172 | bool QtLockedFile::unlock() 173 | { 174 | if (!isOpen()) { 175 | qWarning("QtLockedFile::unlock(): file is not opened"); 176 | return false; 177 | } 178 | 179 | if (!isLocked()) 180 | return true; 181 | 182 | if (m_lock_mode == ReadLock) { 183 | ReleaseMutex(rmutex); 184 | CloseHandle(rmutex); 185 | rmutex = 0; 186 | } 187 | else { 188 | foreach(Qt::HANDLE mutex, rmutexes) { 189 | ReleaseMutex(mutex); 190 | CloseHandle(mutex); 191 | } 192 | rmutexes.clear(); 193 | ReleaseMutex(wmutex); 194 | } 195 | 196 | m_lock_mode = QtLockedFile::NoLock; 197 | return true; 198 | } 199 | 200 | QtLockedFile::~QtLockedFile() 201 | { 202 | if (isOpen()) 203 | unlock(); 204 | if (wmutex) 205 | CloseHandle(wmutex); 206 | } 207 | -------------------------------------------------------------------------------- /src/QtSolutions/qtsingleapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTSINGLEAPPLICATION_H 41 | #define QTSINGLEAPPLICATION_H 42 | 43 | #include 44 | 45 | class QtLocalPeer; 46 | 47 | #if defined(Q_WS_WIN) 48 | # if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) 49 | # define QT_QTSINGLEAPPLICATION_EXPORT 50 | # elif defined(QT_QTSINGLEAPPLICATION_IMPORT) 51 | # if defined(QT_QTSINGLEAPPLICATION_EXPORT) 52 | # undef QT_QTSINGLEAPPLICATION_EXPORT 53 | # endif 54 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) 55 | # elif defined(QT_QTSINGLEAPPLICATION_EXPORT) 56 | # undef QT_QTSINGLEAPPLICATION_EXPORT 57 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) 58 | # endif 59 | #else 60 | # define QT_QTSINGLEAPPLICATION_EXPORT 61 | #endif 62 | 63 | class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication 64 | { 65 | Q_OBJECT 66 | 67 | public: 68 | QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); 69 | QtSingleApplication(const QString &id, int &argc, char **argv); 70 | 71 | #if QT_VERSION < 0x050000 72 | QtSingleApplication(int &argc, char **argv, Type type); 73 | #endif 74 | 75 | #if defined(Q_WS_X11) 76 | QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 77 | QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 78 | QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 79 | #endif 80 | 81 | bool isRunning(); 82 | QString id() const; 83 | void setActivationWindow(QWidget* aw, bool activateOnMessage = true); 84 | QWidget* activationWindow() const; 85 | 86 | // Obsolete: 87 | void initialize(bool dummy = true) 88 | { isRunning(); Q_UNUSED(dummy) } 89 | 90 | public Q_SLOTS: 91 | bool sendMessage(const QString &message, int timeout = 5000); 92 | void activateWindow(const QString &message); 93 | 94 | 95 | Q_SIGNALS: 96 | void messageReceived(const QString &message); 97 | 98 | 99 | private: 100 | void sysInit(const QString &appId = QString()); 101 | QtLocalPeer *peer; 102 | QWidget *actWin; 103 | }; 104 | 105 | #endif // QTSINGLEAPPLICATION_H 106 | -------------------------------------------------------------------------------- /src/QtSolutions/qtsingleapplication.pri: -------------------------------------------------------------------------------- 1 | include(../common.pri) 2 | INCLUDEPATH += $$PWD 3 | DEPENDPATH += $$PWD 4 | QT *= network 5 | 6 | qtsingleapplication-uselib:!qtsingleapplication-buildlib { 7 | LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME 8 | } else { 9 | SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp 10 | HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h 11 | } 12 | 13 | win32 { 14 | contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT 15 | else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT 16 | } 17 | -------------------------------------------------------------------------------- /src/QtSolutions/qtsinglecoreapplication.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | 41 | #include "qtsinglecoreapplication.h" 42 | #include "qtlocalpeer.h" 43 | 44 | /*! 45 | \class QtSingleCoreApplication qtsinglecoreapplication.h 46 | \brief A variant of the QtSingleApplication class for non-GUI applications. 47 | 48 | This class is a variant of QtSingleApplication suited for use in 49 | console (non-GUI) applications. It is an extension of 50 | QCoreApplication (instead of QApplication). It does not require 51 | the QtGui library. 52 | 53 | The API and usage is identical to QtSingleApplication, except that 54 | functions relating to the "activation window" are not present, for 55 | obvious reasons. Please refer to the QtSingleApplication 56 | documentation for explanation of the usage. 57 | 58 | A QtSingleCoreApplication instance can communicate to a 59 | QtSingleApplication instance if they share the same application 60 | id. Hence, this class can be used to create a light-weight 61 | command-line tool that sends commands to a GUI application. 62 | 63 | \sa QtSingleApplication 64 | */ 65 | 66 | /*! 67 | Creates a QtSingleCoreApplication object. The application identifier 68 | will be QCoreApplication::applicationFilePath(). \a argc and \a 69 | argv are passed on to the QCoreAppliation constructor. 70 | */ 71 | 72 | QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) 73 | : QCoreApplication(argc, argv) 74 | { 75 | peer = new QtLocalPeer(this); 76 | connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); 77 | } 78 | 79 | 80 | /*! 81 | Creates a QtSingleCoreApplication object with the application 82 | identifier \a appId. \a argc and \a argv are passed on to the 83 | QCoreAppliation constructor. 84 | */ 85 | QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) 86 | : QCoreApplication(argc, argv) 87 | { 88 | peer = new QtLocalPeer(this, appId); 89 | connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); 90 | } 91 | 92 | 93 | /*! 94 | Returns true if another instance of this application is running; 95 | otherwise false. 96 | 97 | This function does not find instances of this application that are 98 | being run by a different user (on Windows: that are running in 99 | another session). 100 | 101 | \sa sendMessage() 102 | */ 103 | 104 | bool QtSingleCoreApplication::isRunning() 105 | { 106 | return peer->isClient(); 107 | } 108 | 109 | 110 | /*! 111 | Tries to send the text \a message to the currently running 112 | instance. The QtSingleCoreApplication object in the running instance 113 | will emit the messageReceived() signal when it receives the 114 | message. 115 | 116 | This function returns true if the message has been sent to, and 117 | processed by, the current instance. If there is no instance 118 | currently running, or if the running instance fails to process the 119 | message within \a timeout milliseconds, this function return false. 120 | 121 | \sa isRunning(), messageReceived() 122 | */ 123 | 124 | bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) 125 | { 126 | return peer->sendMessage(message, timeout); 127 | } 128 | 129 | 130 | /*! 131 | Returns the application identifier. Two processes with the same 132 | identifier will be regarded as instances of the same application. 133 | */ 134 | 135 | QString QtSingleCoreApplication::id() const 136 | { 137 | return peer->applicationId(); 138 | } 139 | 140 | 141 | /*! 142 | \fn void QtSingleCoreApplication::messageReceived(const QString& message) 143 | 144 | This signal is emitted when the current instance receives a \a 145 | message from another instance of this application. 146 | 147 | \sa sendMessage() 148 | */ 149 | -------------------------------------------------------------------------------- /src/QtSolutions/qtsinglecoreapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTSINGLECOREAPPLICATION_H 41 | #define QTSINGLECOREAPPLICATION_H 42 | 43 | #include 44 | 45 | class QtLocalPeer; 46 | 47 | class QtSingleCoreApplication : public QCoreApplication 48 | { 49 | Q_OBJECT 50 | 51 | public: 52 | QtSingleCoreApplication(int &argc, char **argv); 53 | QtSingleCoreApplication(const QString &id, int &argc, char **argv); 54 | 55 | bool isRunning(); 56 | QString id() const; 57 | 58 | public Q_SLOTS: 59 | bool sendMessage(const QString &message, int timeout = 5000); 60 | 61 | 62 | Q_SIGNALS: 63 | void messageReceived(const QString &message); 64 | 65 | 66 | private: 67 | QtLocalPeer* peer; 68 | }; 69 | 70 | #endif // QTSINGLECOREAPPLICATION_H 71 | -------------------------------------------------------------------------------- /src/QtSolutions/qtsinglecoreapplication.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h 4 | SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp 5 | 6 | QT *= network 7 | 8 | win32:contains(TEMPLATE, lib):contains(CONFIG, shared) { 9 | DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport) 10 | } 11 | -------------------------------------------------------------------------------- /src/argumentlist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "argumentlist.h" 3 | 4 | /** 5 | Obtain the command line arguments from the currently 6 | running QApplication */ 7 | 8 | ArgumentList::ArgumentList() { 9 | if (qApp != NULL) /* a global pointer to the current qApplication */ 10 | *this = qApp->arguments(); 11 | } 12 | 13 | void ArgumentList::argsToStringlist(int argc, char * argv []) { 14 | for (int i=0; i < argc; ++i) { 15 | *this += argv[i]; 16 | } 17 | } 18 | 19 | bool ArgumentList::getSwitch (QString option) { 20 | QMutableStringListIterator itr(*this); 21 | while (itr.hasNext()) { 22 | if (option == itr.next()) { 23 | itr.remove(); 24 | return true; 25 | } 26 | } 27 | return false; 28 | } 29 | 30 | QString ArgumentList::getSwitchArg(QString option, QString defaultValue) { 31 | if (isEmpty()) 32 | return defaultValue; 33 | QMutableStringListIterator itr(*this); 34 | while (itr.hasNext()) { 35 | if (option == itr.next()) { 36 | itr.remove(); 37 | if (itr.hasNext()) { 38 | QString retval = itr.next(); 39 | itr.remove(); 40 | return retval; 41 | } 42 | else { 43 | //qDebug() << "Missing Argument for " << option; 44 | return QString(); 45 | } 46 | } 47 | } 48 | return defaultValue; 49 | } 50 | -------------------------------------------------------------------------------- /src/argumentlist.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGUMENTLIST_H 2 | #define ARGUMENTLIST_H 3 | 4 | #include 5 | 6 | 7 | /** @short a simple interface for processing command line arguments 8 | 9 | An object which provides a simple interface to the command 10 | line arguments of a program. The methods 11 | @ref getSwitch(QString) and @ref getSwitchArg(QString) 12 | allow you to process and remove the switches and switched 13 | arguments in the command line, so that the remaining 14 | entries in the stringlist can be processed as a 15 | uniform list. 16 |
17 | It also happens to be derived from 18 | QStringList, so you can use any of those 19 | methods on this object too. 20 |
21 | This helps you avoid entirely using the C arrays 22 | in your application. 23 | 24 |
25 | Usage.: 26 |
27 |
28 | int main(int argc, char** argv) {
29 | ArgumentList args(argc, argv);
30 | bool verbose = args.getSwitch("-v");
31 | // get all other switches
32 | QString outputfile = args.getSwitchArg("-o", "default.out");
33 | qout << args[0];  // prints the name of the executable
34 | qout << args[1]; // prints the first unswitched argument
35 | someObject.processEveryFile(args);
36 | }
37 | 
38 | 39 | @author S. Alan Ezust sae@mcs.suffolk.edu 40 | @since qt 3.2.1 41 | 42 | */ 43 | 44 | class ArgumentList : public QStringList { 45 | public: 46 | /** 47 | retrieve argument list from the qApp->argc() and argv() methods. 48 | Only works if a @ref QApplication(argc, argv) was already created. 49 | */ 50 | ArgumentList(); 51 | 52 | /** 53 | @param argc number of arguments 54 | @param argv an array of command line arguments, as supplied 55 | to main(). 56 | @see argsToStringList() 57 | */ 58 | 59 | ArgumentList(int argc, char* argv[]) { 60 | argsToStringlist(argc, argv); 61 | } 62 | 63 | ArgumentList(const QStringList& argumentList): 64 | QStringList(argumentList) {} 65 | 66 | 67 | /** 68 | finds and removes a switch from the string list, if it exists. 69 | @param option the switch to search for 70 | @return true if the switch was found 71 | */ 72 | bool getSwitch(QString option); 73 | 74 | /** 75 | finds/removes a switch and its accompanying argument 76 | from the string list, if the switch is found. Does nothing if the 77 | switch is not found. 78 | @param option the switch to search for 79 | @param defaultReturnValue the return value if option is not found in the stringlist 80 | @return the argument following option, or defaultValue if the option 81 | is not found. 82 | */ 83 | QString getSwitchArg(QString option, 84 | QString defaultRetVal=QString()); 85 | private: 86 | /** 87 | (Re)loads argument lists into this object. This function is private because 88 | it is part of the implementation of the class and not intended to be used by 89 | client code. 90 | */ 91 | void argsToStringlist(int argc, char* argv[]); 92 | }; 93 | #endif 94 | -------------------------------------------------------------------------------- /src/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTANTS_H 2 | #define CONSTANTS_H 3 | 4 | #include 5 | 6 | #if defined(__DragonFly__) 7 | const QString ctn_PKG_BIN = QStringLiteral("/usr/local/sbin/pkg"); 8 | #else 9 | const QString ctn_PKG_BIN = QStringLiteral("/usr/sbin/pkg"); 10 | #endif 11 | 12 | const QString ctn_OCTOPKG_DOAS = QStringLiteral("/usr/local/bin/qt-sudo"); 13 | const QString ctn_OCTOPKG_DOAS_PARAMS = QStringLiteral("-d"); 14 | 15 | #endif // CONSTANTS_H 16 | -------------------------------------------------------------------------------- /src/globals.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "globals.h" 22 | #include "mainwindow.h" 23 | 24 | #include 25 | #include 26 | 27 | /* 28 | * Given a packageName, returns its description 29 | */ 30 | QString showPackageDescription(QString pkgName) 31 | { 32 | MainWindow *mw = MainWindow::returnMainWindow(); 33 | const PackageRepository::PackageData*const package = mw->getFirstPackageFromRepo(pkgName); 34 | 35 | if (package == NULL) { 36 | return ""; 37 | } 38 | 39 | QString description = package->comment.trimmed(); 40 | 41 | if (description.isEmpty()) 42 | { 43 | return ""; 44 | } 45 | 46 | int space = description.indexOf(" "); 47 | QString desc = description.mid(space+1).trimmed(); 48 | int size = desc.size(); 49 | 50 | if (desc.size() > 120) 51 | { 52 | desc.chop(size - 120); 53 | desc = desc + " ..."; 54 | } 55 | 56 | return desc; 57 | } 58 | 59 | /* 60 | * Starts the non blocking search for Pacman packages... 61 | */ 62 | QList * searchPkgPackages() 63 | { 64 | return Package::getPackageList(""); 65 | } 66 | 67 | /* 68 | * Starts the non blocking search for Locked Pkg packages... 69 | */ 70 | QSet *searchLockedPkgPackages() 71 | { 72 | return Package::getLockedPackageList(); 73 | } 74 | 75 | /* 76 | * Starts the non blocking search for Unrequired Pacman packages... 77 | */ 78 | QSet *searchUnrequiredPacmanPackages() 79 | { 80 | return Package::getUnrequiredPackageList(); 81 | } 82 | 83 | /* 84 | * Starts the non blocking search for a Pacman package that owns the given file... 85 | */ 86 | QString searchPacmanPackagesByFile(const QString &file) 87 | { 88 | QString result; 89 | 90 | if (!file.isEmpty()) 91 | { 92 | result = UnixCommand::getPackageByFilePath(file); 93 | } 94 | else 95 | result = ""; 96 | 97 | return result; 98 | } 99 | 100 | /* 101 | * Starts the non blocking search for Pacman packages... 102 | */ 103 | GroupMemberPair searchPacmanPackagesFromGroup(QString groupName) 104 | { 105 | return std::make_pair(groupName, Package::getPackagesOfGroup(groupName)); 106 | } 107 | 108 | /* 109 | * Starts the non blocking search for AUR packages... 110 | */ 111 | QList * searchRemotePackages(QString searchString) 112 | { 113 | return Package::getRemotePackageList(searchString); 114 | } 115 | 116 | /* 117 | * Starts the non blocking search for RSS distro news... 118 | */ 119 | QString getLatestDistroNews() 120 | { 121 | return utils::retrieveDistroNews(true); 122 | } 123 | 124 | /* 125 | * Starts the non blocking search for outdated pkgs 126 | */ 127 | QMap *getOutdatedList() 128 | { 129 | return Package::getOutdatedStringList(); 130 | } 131 | 132 | /* 133 | * Starts the non blocking 'pkg upgrade -n' 134 | */ 135 | TransactionInfo getTargetUpgradeList(const QString& pkgName) 136 | { 137 | return Package::getTargetUpgradeList(pkgName); 138 | } 139 | -------------------------------------------------------------------------------- /src/globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef MAINWINDOW_GLOBALS_H 22 | #define MAINWINDOW_GLOBALS_H 23 | 24 | #include "strconstants.h" 25 | #include "model/packagemodel.h" 26 | 27 | #include 28 | 29 | typedef std::pair GroupMemberPair; 30 | 31 | inline QFutureWatcher g_fwToolTip; 32 | inline QFutureWatcher g_fwToolTipInfo; 33 | inline QFutureWatcher *> g_fwPkg; 34 | inline QFutureWatcher *> g_fwLockedPkg; 35 | inline QFutureWatcher *> g_fwUnrequiredPacman; 36 | inline QFutureWatcher g_fwPacmanGroup; 37 | inline QFutureWatcher *> g_fwRemote; 38 | inline QFutureWatcher *> g_fwRemoteMeta; 39 | inline QFutureWatcher *> g_fwOutdatedList; 40 | inline QFutureWatcher g_fwDistroNews; 41 | inline QFutureWatcher g_fwPackageOwnsFile; 42 | inline QFutureWatcher g_fwTargetUpgradeList; 43 | 44 | QString showPackageDescription(QString pkgName); 45 | TransactionInfo getTargetUpgradeList(const QString &pkgName); 46 | QList * searchPkgPackages(); 47 | QSet * searchLockedPkgPackages(); 48 | QSet * searchUnrequiredPacmanPackages(); 49 | QList * searchRemotePackages(QString searchString); 50 | QString searchPacmanPackagesByFile(const QString &file); 51 | GroupMemberPair searchPacmanPackagesFromGroup(QString groupName); 52 | QMap * getOutdatedList(); 53 | QString getLatestDistroNews(); 54 | 55 | #endif // MAINWINDOW_GLOBALS_H 56 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "mainwindow.h" 22 | #include "argumentlist.h" 23 | #include "strconstants.h" 24 | #include "unixcommand.h" 25 | #include "constants.h" 26 | #include 27 | 28 | #include "QtSolutions/qtsingleapplication.h" 29 | #include 30 | //#include 31 | #include 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 36 | QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 37 | #endif 38 | 39 | ArgumentList *argList = new ArgumentList(argc, argv); 40 | QString packagesToInstall; 41 | QtSingleApplication app( StrConstants::getApplicationName(), argc, argv ); 42 | 43 | if (app.isRunning()) 44 | { 45 | app.sendMessage("RAISE"); 46 | delete argList; 47 | return 0; 48 | } 49 | 50 | if(!QFile::exists("/bin/sh")) 51 | { 52 | QMessageBox::critical( 0, StrConstants::getApplicationName(), StrConstants::getErrorNoSHFound()); 53 | delete argList; 54 | return 1; 55 | } 56 | 57 | bool doas = (QFile::exists(QStringLiteral("/usr/local/bin/doas")) && 58 | QFile::exists(QStringLiteral("/usr/local/etc/doas.conf"))); 59 | bool sudo = QFile::exists(QStringLiteral("/usr/local/bin/sudo")); 60 | 61 | if (!doas && !sudo) 62 | { 63 | QMessageBox::critical( 0, StrConstants::getApplicationName(), StrConstants::getErrorNoDoasSudoFound()); 64 | delete argList; 65 | return 1; 66 | } 67 | 68 | if(!QFile::exists(ctn_OCTOPKG_DOAS)) 69 | { 70 | QMessageBox::critical( 0, StrConstants::getApplicationName(), StrConstants::getOctoPKGDoasNotFound()); 71 | delete argList; 72 | return 1; 73 | } 74 | 75 | //This sends a message just to enable the socket-based QtSingleApplication engine 76 | app.sendMessage("RAISE"); 77 | 78 | /*QTranslator appTranslator; 79 | appTranslator.load(":/resources/translations/octopkg_" + 80 | QLocale::system().name()); 81 | app.installTranslator(&appTranslator);*/ 82 | 83 | if (argList->getSwitch("-help")){ 84 | std::cout << StrConstants::getApplicationCliHelp().toLatin1().data() << std::endl; 85 | delete argList; 86 | return(0); 87 | } 88 | else if (argList->getSwitch("-version")){ 89 | std::cout << "\n" << StrConstants::getApplicationName().toLatin1().data() << 90 | " " << StrConstants::getApplicationVersion().toLatin1().data() << "\n" << std::endl; 91 | delete argList; 92 | return(0); 93 | } 94 | 95 | if (UnixCommand::isRootRunning()){ 96 | QMessageBox::critical( 0, StrConstants::getApplicationName(), StrConstants::getErrorRunningWithRoot()); 97 | delete argList; 98 | return (-2); 99 | } 100 | 101 | MainWindow w; 102 | app.setActivationWindow(&w); 103 | app.setQuitOnLastWindowClosed(false); 104 | 105 | if (argList->getSwitch("-d")) 106 | { 107 | //If user chooses to switch debug info on... 108 | w.turnDebugInfoOn(); 109 | } 110 | 111 | if (!packagesToInstall.isEmpty()) 112 | { 113 | QStringList packagesToInstallList = 114 | packagesToInstall.split(",", Qt::SkipEmptyParts); 115 | w.setPackagesToInstallList(packagesToInstallList); 116 | } 117 | 118 | w.show(); 119 | QResource::registerResource("./resources.qrc"); 120 | 121 | return app.exec(); 122 | } 123 | -------------------------------------------------------------------------------- /src/mainwindow_help.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 2013 Manuel Tortosa 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | 22 | /* 23 | * This is MainWindow's Help related code 24 | */ 25 | 26 | #include "strconstants.h" 27 | #include "mainwindow.h" 28 | #include "ui_mainwindow.h" 29 | #include "searchbar.h" 30 | //#include "constants.h" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /* 38 | * Initialize the Help tab with basic information about using OctoPkg 39 | */ 40 | void MainWindow::initTabHelpUsage() 41 | { 42 | QWidget *tabHelpUsage = new QWidget(); 43 | QGridLayout *gridLayoutX = new QGridLayout(tabHelpUsage); 44 | gridLayoutX->setSpacing(0); 45 | gridLayoutX->setContentsMargins(0, 0, 0, 0); 46 | 47 | QTextBrowser *text = new QTextBrowser(tabHelpUsage); 48 | text->setObjectName("textBrowser"); 49 | text->setReadOnly(true); 50 | text->setFrameShape(QFrame::NoFrame); 51 | text->setFrameShadow(QFrame::Plain); 52 | text->setOpenExternalLinks(true); 53 | gridLayoutX->addWidget(text, 0, 0, 1, 1); 54 | 55 | QString iconPath = "OctoPkg") + 60 | QString("

") + tr("A Qt5-based pkgng front-end,") + " " + 61 | tr("licensed under the terms of") + " "; 62 | 63 | html += 64 | QString("LGPL v2.1.

") + 65 | QString("

") + strForMoreInfo + " " + 66 | QString("https://tintaescura.com/projects/octopkg.


"); 67 | 68 | html += tr("Package classification:") + 69 | QString("
  • ") + iconPath + "installed.png\"/> " + 70 | tr("An installed package") + QString("
  • ") + 71 | QString("
  • ") + iconPath + "unrequired.png\"/> " + 72 | tr("An explicitly installed package") + 73 | QString("
  • ") + iconPath + "locker-key.png\"/> " + 74 | tr("A locked installed package") + 75 | QString("
  • ") + 76 | QString("") + 77 | QString("
  • ") + iconPath + "noninstalled.png\"/> " + 78 | tr("A non installed package") + 79 | QString("
  • ") + 80 | QString("
  • ") + iconPath + "outdated.png\"/> " + 81 | tr("An outdated package") + 82 | QString("
  • ") + 83 | QString("
") + 84 | 85 | tr("Basic usage help:") + 86 | QString("
  • ") + 87 | tr("Position the mouse over a package to see its description") + 88 | QString("
  • ") + 89 | tr("Double click an installed package to see its contents") + 90 | QString("
  • ") + 91 | tr("Right click package to install/reinstall or remove it") + 92 | QString("
") + 93 | 94 | tr("Alt+key sequences:") + 95 | QString("
  • ") + 96 | tr("Alt+1 to switch to 'Info' tab") + 97 | QString("
  • ") + 98 | tr("Alt+2 to switch to 'Files' tab") + 99 | QString("
  • ") + 100 | tr("Alt+3 to switch to 'Actions' tab") + 101 | QString("
  • ") + 102 | tr("Alt+4 to switch to 'Output' tab") + 103 | QString("
  • ") + 104 | tr("Alt+5 to switch to 'News' tab") + 105 | QString("
  • ") + 106 | tr("Alt+6 or 'F1' to show this help page") + 107 | QString("
  • ") + 108 | tr("Alt+\"Left key\" to go to previous clicked anchor") + 109 | QString("
  • ") + 110 | tr("Alt+\"Right key\" to go to next clicked anchor") + 111 | QString("
  • ") + 112 | tr("Alt+\"Home key\" to go to first clicked anchor") + 113 | QString("
  • ") + 114 | tr("Alt+\"End key\" to go to last clicked anchor") + 115 | QString("
") + 116 | 117 | tr("Control+key sequences:") + 118 | QString("
  • ") + 119 | tr("Ctrl+K or 'File/Check updates' to search for latest package updates") + 120 | QString("
  • ") + 121 | tr("Ctrl+U or 'File/Install updates' to install available package updates") + 122 | QString("
  • ") + 123 | tr("Ctrl+L to find a package in the package list") + 124 | QString("
  • ") + 125 | // tr("Ctrl+I to view installed packages") + 126 | //QString("
  • ") + 127 | tr("Ctrl+I to install a new package") + 128 | QString("
  • ") + 129 | tr("Ctrl+P to go to the package list") + 130 | QString("
  • ") + 131 | tr("Ctrl+F to search for text inside tab Files, News and Usage") + 132 | //QString("
  • ") + 133 | // tr("Ctrl+N or 'View/Non installed' to show/hide non installed packages") + 134 | QString("
  • ") + 135 | tr("Ctrl+M or 'Actions/Apply' to start installation/removal of selected packages") + 136 | QString("
  • ") + 137 | tr("Ctrl+E or 'Actions/Cancel' to clear the selection of \"to be removed\" and \"to be installed\" packages") + 138 | QString("
  • ") + 139 | tr("Ctrl+G or 'File/Get latest BSD news' to retrieve latest RSS based BSD news") + 140 | QString("
  • ") + 141 | tr("Ctrl+Q or 'File/Exit' to exit the application") + 142 | QString("
") + 143 | 144 | tr("Control+shift+key sequences:") + 145 | QString("
  • ") + 146 | tr("Ctrl+Shift+C or 'File/Clean the local cache' to clean the local package cache (pkg clean)") + 147 | /*QString("
  • ") + 148 | tr("Ctrl+Shift+G to display all package groups") + 149 | QString("
  • ") +*/ 150 | QString("
") + 151 | tr("F+key sequences:") + 152 | QString("
  • ") + 153 | tr("F1 to show this help page") + 154 | QString("
  • ") + 155 | tr("F4 to open a Terminal whitin the selected directory at Files tab") + 156 | QString("
  • ") + 157 | tr("F6 to open a File Manager whitin the selected directory at Files tab") + 158 | QString("
  • ") + 159 | tr("F10 to maximize/demaximize package list view") + 160 | QString("
  • ") + 161 | tr("F11 to maximize/demaximize Tab's view") + 162 | QString("

"); 163 | 164 | text->setText(html); 165 | int tindex = ui->twProperties->addTab(tabHelpUsage, StrConstants::getHelpUsage() ); 166 | ui->twProperties->setTabText(ui->twProperties->indexOf(tabHelpUsage), StrConstants::getHelpUsage()); 167 | 168 | SearchBar *searchBar = new SearchBar(this); 169 | connect(searchBar, SIGNAL(textChanged(QString)), this, SLOT(searchBarTextChangedInTextBrowser(QString))); 170 | connect(searchBar, SIGNAL(closed()), this, SLOT(searchBarClosedInTextBrowser())); 171 | connect(searchBar, SIGNAL(findNext()), this, SLOT(searchBarFindNextInTextBrowser())); 172 | connect(searchBar, SIGNAL(findPrevious()), this, SLOT(searchBarFindPreviousInTextBrowser())); 173 | gridLayoutX->addWidget(searchBar, 1, 0, 1, 1); 174 | 175 | text->show(); 176 | ui->twProperties->setCurrentIndex(tindex); 177 | text->setFocus(); 178 | } 179 | 180 | /* 181 | * Slot to position twProperties at Help tab 182 | */ 183 | void MainWindow::onHelpUsage() 184 | { 185 | changeTabWidgetPropertiesIndex(ctn_TABINDEX_HELPUSAGE); 186 | } 187 | 188 | /* 189 | * Slot to open author's Paypal donation page 190 | */ 191 | void MainWindow::onHelpDonate() 192 | { 193 | const QString url="http://sourceforge.net/donate/index.php?group_id=186459"; 194 | QDesktopServices::openUrl(QUrl(url)); 195 | } 196 | 197 | /* 198 | * Slot which opens the About dialog 199 | */ 200 | void MainWindow::onHelpAbout() 201 | { 202 | QString aboutText = "" + StrConstants::getApplicationName() + QLatin1String("
"); 203 | aboutText += StrConstants::getVersion() + QLatin1String(": ") + StrConstants::getApplicationVersion() + 204 | QLatin1String(" - ") + StrConstants::getQtVersion() + QLatin1String("
"); 205 | aboutText += StrConstants::getURL() + QLatin1String(": ") + 206 | QStringLiteral("https://tintaescura.com/projects/octopkg
"); 207 | aboutText += StrConstants::getLicenses() + QLatin1String(": ") + 208 | QStringLiteral("LGPL v2.1
"); 209 | aboutText += QStringLiteral("© Alexandre Albuquerque Arnt

"); 210 | aboutText += QStringLiteral("pkgng
"); 211 | aboutText += StrConstants::getVersion() + QLatin1String(": ") + UnixCommand::getPkgNGVersion() + QStringLiteral("
"); 212 | aboutText += StrConstants::getURL() + QLatin1String(": ") + 213 | QStringLiteral("https://wiki.freebsd.org/pkg
"); 214 | aboutText += QStringLiteral("© FreeBSD"); 215 | 216 | QMessageBox::about(this, StrConstants::getHelpAbout(), aboutText); 217 | } 218 | -------------------------------------------------------------------------------- /src/mainwindow_news.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 2013 Manuel Tortosa 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | 22 | /* 23 | * This is MainWindow's Distro news related code 24 | */ 25 | 26 | #include "ui_mainwindow.h" 27 | #include "mainwindow.h" 28 | #include "strconstants.h" 29 | #include "searchbar.h" 30 | //#include "uihelper.h" 31 | #include "globals.h" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | /* 38 | * This is the high level method that orquestrates the Distro RSS News printing in tabNews 39 | * 40 | * boolean parameter searchForLatestNews: 41 | * controls whether this method tries to connect to the remote RSS News Feed (default is true) 42 | * boolean parameter gotoNewsTab: 43 | * controls whether this method must set the mainwindow focus to NewsTab (default is true) 44 | */ 45 | void MainWindow::refreshDistroNews(bool searchForLatestNews, bool gotoNewsTab) 46 | { 47 | if (!isHidden() && !isInternetAvailable()) return; 48 | 49 | ui->actionGetNews->setEnabled(false); 50 | m_gotoNewsTab = gotoNewsTab; 51 | 52 | if (searchForLatestNews) 53 | { 54 | BSDFlavour bsd = UnixCommand::getBSDFlavour(); 55 | 56 | if (gotoNewsTab) 57 | { 58 | clearTabOutput(); 59 | } 60 | 61 | if (gotoNewsTab && bsd == ectn_DRAGONFLYBSD) 62 | { 63 | writeToTabOutputExt("" + 64 | StrConstants::getSearchingForBSDNews().arg("DragonFlyBSD") + ""); 65 | } 66 | else if (gotoNewsTab && bsd == ectn_FREEBSD) 67 | { 68 | writeToTabOutputExt("" + 69 | StrConstants::getSearchingForBSDNews().arg("FreeBSD") + ""); 70 | } 71 | else if (gotoNewsTab && bsd == ectn_GHOSTBSD) 72 | { 73 | writeToTabOutputExt("" + 74 | StrConstants::getSearchingForBSDNews().arg("GhostBSD") + ""); 75 | } 76 | else if (gotoNewsTab && bsd == ectn_HARDENEDBSD) 77 | { 78 | writeToTabOutputExt("" + 79 | StrConstants::getSearchingForBSDNews().arg("HardenedBSD") + ""); 80 | } 81 | 82 | /* 83 | * Here, we retrieve BSD's latest news without 84 | * blocking OctoPkg main interface. 85 | */ 86 | QFuture f; 87 | f = QtConcurrent::run(getLatestDistroNews); 88 | g_fwDistroNews.setFuture(f); 89 | connect(&g_fwDistroNews, SIGNAL(finished()), this, SLOT(postRefreshDistroNews())); 90 | } 91 | else 92 | { 93 | QString distroRSSXML = utils::retrieveDistroNews(searchForLatestNews); 94 | showDistroNews(distroRSSXML, false); 95 | } 96 | } 97 | 98 | /* 99 | * After we have the multithreaded RSS distro news, we parse and show it! 100 | */ 101 | void MainWindow::postRefreshDistroNews() 102 | { 103 | showDistroNews(g_fwDistroNews.result(), true); 104 | } 105 | 106 | /* 107 | * At last we have to just show the retrivied news html 108 | */ 109 | void MainWindow::showDistroNews(QString distroRSSXML, bool searchForLatestNews) 110 | { 111 | QString html; 112 | 113 | if (distroRSSXML.length() >= 200) 114 | { 115 | if (distroRSSXML.at(0)=='*') 116 | { 117 | /* If this is an updated RSS, we must warn the user! 118 | And if the main window is hidden... */ 119 | if (isHidden()) 120 | { 121 | show(); 122 | } 123 | 124 | ui->twProperties->setTabText(ctn_TABINDEX_NEWS, "** " + StrConstants::getTabNewsName() + " **"); 125 | if (m_gotoNewsTab) 126 | { 127 | ui->twProperties->setCurrentIndex(ctn_TABINDEX_NEWS); 128 | } 129 | } 130 | else 131 | { 132 | if(searchForLatestNews) 133 | { 134 | ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName()); 135 | } 136 | } 137 | 138 | //First, we have to parse the raw RSS XML... 139 | html = utils::parseDistroNews(); 140 | } 141 | else 142 | { 143 | if(searchForLatestNews) 144 | ui->twProperties->setTabText(ctn_TABINDEX_NEWS, StrConstants::getTabNewsName()); 145 | 146 | html = distroRSSXML; 147 | } 148 | 149 | //Now that we have the html table code, let's put it into TextBrowser's News tab 150 | QTextBrowser *text = ui->twProperties->widget(ctn_TABINDEX_NEWS)->findChild("textBrowser"); 151 | if (text) 152 | { 153 | text->clear(); 154 | text->setHtml(html); 155 | } 156 | 157 | if (m_gotoNewsTab) 158 | { 159 | clearTabOutput(); 160 | } 161 | 162 | if (searchForLatestNews && m_gotoNewsTab) 163 | { 164 | changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS); 165 | } 166 | 167 | ui->actionGetNews->setEnabled(true); 168 | } 169 | 170 | /* 171 | * This SLOT is called every time the user clicks a url inside newsTab textBrowser 172 | */ 173 | void MainWindow::onTabNewsSourceChanged(QUrl newSource) 174 | { 175 | if(newSource.isRelative()) 176 | { 177 | //If the user clicked a relative and impossible to display link... 178 | QTextBrowser *text = ui->twProperties->widget(ctn_TABINDEX_NEWS)->findChild("textBrowser"); 179 | if (text) 180 | { 181 | disconnect(text, SIGNAL(sourceChanged(QUrl)), this, SLOT(onTabNewsSourceChanged(QUrl))); 182 | text->setHtml(utils::parseDistroNews()); 183 | connect(text, SIGNAL(sourceChanged(QUrl)), this, SLOT(onTabNewsSourceChanged(QUrl))); 184 | } 185 | } 186 | } 187 | 188 | /* 189 | * This is the TextBrowser News tab, which shows the latest news from Distro news feed 190 | */ 191 | void MainWindow::initTabNews() 192 | { 193 | QString aux(StrConstants::getTabNewsName()); 194 | QWidget *tabNews = new QWidget(); 195 | QGridLayout *gridLayoutX = new QGridLayout(tabNews); 196 | gridLayoutX->setSpacing(0); 197 | gridLayoutX->setContentsMargins(0, 0, 0, 0); 198 | 199 | QTextBrowser *text = new QTextBrowser(tabNews); 200 | text->setObjectName("textBrowser"); 201 | text->setReadOnly(true); 202 | text->setFrameShape(QFrame::NoFrame); 203 | text->setFrameShadow(QFrame::Plain); 204 | text->setOpenExternalLinks(true); 205 | gridLayoutX->addWidget(text, 0, 0, 1, 1); 206 | text->show(); 207 | 208 | int tindex = ui->twProperties->insertTab(ctn_TABINDEX_NEWS, tabNews, QApplication::translate ( 209 | "MainWindow", aux.toUtf8(), 0/*, QApplication::UnicodeUTF8*/ ) ); 210 | ui->twProperties->setTabText(ui->twProperties->indexOf(tabNews), QApplication::translate( 211 | "MainWindow", aux.toUtf8(), 0/*, QApplication::UnicodeUTF8*/)); 212 | 213 | SearchBar *searchBar = new SearchBar(this); 214 | connect(searchBar, SIGNAL(textChanged(QString)), this, SLOT(searchBarTextChangedInTextBrowser(QString))); 215 | connect(searchBar, SIGNAL(closed()), this, SLOT(searchBarClosedInTextBrowser())); 216 | connect(searchBar, SIGNAL(findNext()), this, SLOT(searchBarFindNextInTextBrowser())); 217 | connect(searchBar, SIGNAL(findPrevious()), this, SLOT(searchBarFindPreviousInTextBrowser())); 218 | 219 | gridLayoutX->addWidget(searchBar, 1, 0, 1, 1); 220 | 221 | connect(text, SIGNAL(sourceChanged(QUrl)), this, SLOT(onTabNewsSourceChanged(QUrl))); 222 | 223 | text->show(); 224 | ui->twProperties->setCurrentIndex(tindex); 225 | text->setFocus(); 226 | } 227 | -------------------------------------------------------------------------------- /src/mainwindow_searchbar.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | /* 22 | * This is MainWindow's searchbar slots related code 23 | */ 24 | 25 | #include "ui_mainwindow.h" 26 | #include "mainwindow.h" 27 | #include "searchbar.h" 28 | 29 | #include 30 | #include 31 | 32 | /* 33 | * Every time the user changes the text to search inside a textBrowser... 34 | */ 35 | void MainWindow::searchBarTextChangedInTextBrowser(const QString textToSearch) 36 | { 37 | qApp->processEvents(); 38 | QTextBrowser *tb = ui->twProperties->currentWidget()->findChild("textBrowser"); 39 | QList extraSelections; 40 | 41 | if (tb){ 42 | static int limit = 100; 43 | 44 | SearchBar *sb = ui->twProperties->currentWidget()->findChild("searchbar"); 45 | if (textToSearch.isEmpty() || textToSearch.length() < 2){ 46 | sb->getSearchLineEdit()->initStyleSheet(); 47 | tb->setExtraSelections(extraSelections); 48 | QTextCursor tc = tb->textCursor(); 49 | tc.clearSelection(); 50 | tb->setTextCursor(tc); 51 | tb->moveCursor(QTextCursor::Start); 52 | if (sb && sb->isHidden()) tb->setFocus(); 53 | return; 54 | } 55 | 56 | if (textToSearch.length() < 2) return; 57 | 58 | tb->setExtraSelections(extraSelections); 59 | tb->moveCursor(QTextCursor::Start); 60 | QColor color = QColor(Qt::yellow).lighter(130); 61 | 62 | while(tb->find(textToSearch)){ 63 | QTextEdit::ExtraSelection extra; 64 | extra.format.setBackground(color); 65 | extra.cursor = tb->textCursor(); 66 | extraSelections.append(extra); 67 | 68 | if (limit > 0 && extraSelections.count() == limit) 69 | break; 70 | } 71 | 72 | if (extraSelections.count()>0){ 73 | tb->setExtraSelections(extraSelections); 74 | tb->setTextCursor(extraSelections.at(0).cursor); 75 | QTextCursor tc = tb->textCursor(); 76 | tc.clearSelection(); 77 | tb->setTextCursor(tc); 78 | positionInFirstMatch(); 79 | } 80 | else sb->getSearchLineEdit()->setNotFoundStyle(); 81 | } 82 | } 83 | 84 | /* 85 | * Every time the user changes the text to search inside a treeView... 86 | */ 87 | void MainWindow::searchBarTextChangedInTreeView(const QString textToSearch) 88 | { 89 | m_foundFilesInPkgFileList->clear(); 90 | m_indFoundFilesInPkgFileList = 0; 91 | 92 | QTreeView *tvPkgFileList = 93 | ui->twProperties->widget(ctn_TABINDEX_FILES)->findChild("tvPkgFileList"); 94 | if (tvPkgFileList) 95 | { 96 | QStandardItemModel *sim = qobject_cast(tvPkgFileList->model()); 97 | if (!sim) return; 98 | SearchBar *sb = ui->twProperties->currentWidget()->findChild("searchbar"); 99 | 100 | if (!sb) 101 | return; 102 | else 103 | sb->getSearchLineEdit()->initStyleSheet(); 104 | 105 | if (textToSearch.isEmpty()) return; 106 | 107 | m_foundFilesInPkgFileList = utils::findFileInTreeView(textToSearch, sim); 108 | 109 | if (m_foundFilesInPkgFileList->count() > 0) 110 | { 111 | tvPkgFileList->setCurrentIndex(m_foundFilesInPkgFileList->at(0)); 112 | tvPkgFileList->scrollTo(m_foundFilesInPkgFileList->at(0)); 113 | sb->getSearchLineEdit()->setFoundStyle(); 114 | } 115 | else 116 | { 117 | tvPkgFileList->setCurrentIndex(sim->index(0,0)); 118 | sb->getSearchLineEdit()->setNotFoundStyle(); 119 | } 120 | } 121 | } 122 | 123 | /* 124 | * Every time the user presses Enter, Return, F3 or clicks Find Next inside a textBrowser... 125 | */ 126 | void MainWindow::searchBarFindNextInTextBrowser() 127 | { 128 | QTextBrowser *tb = ui->twProperties->currentWidget()->findChild("textBrowser"); 129 | SearchBar *sb = ui->twProperties->currentWidget()->findChild("searchbar"); 130 | 131 | if (tb && sb && !sb->getTextToSearch().isEmpty()){ 132 | if (!tb->find(sb->getTextToSearch())){ 133 | tb->moveCursor(QTextCursor::Start); 134 | tb->find(sb->getTextToSearch()); 135 | } 136 | } 137 | } 138 | 139 | /* 140 | * Every time the user presses Shift+F3 or clicks Find Previous inside a textBrowser... 141 | */ 142 | void MainWindow::searchBarFindPreviousInTextBrowser() 143 | { 144 | QTextBrowser *tb = ui->twProperties->currentWidget()->findChild("textBrowser"); 145 | SearchBar *sb = ui->twProperties->currentWidget()->findChild("searchbar"); 146 | 147 | if (tb && sb && !sb->getTextToSearch().isEmpty()){ 148 | if (!tb->find(sb->getTextToSearch(), QTextDocument::FindBackward)){ 149 | tb->moveCursor(QTextCursor::End); 150 | tb->find(sb->getTextToSearch(), QTextDocument::FindBackward); 151 | } 152 | } 153 | } 154 | 155 | /* 156 | * Every time the user presses Enter, Return, F3 or clicks Find Next inside a treeView... 157 | */ 158 | void MainWindow::searchBarFindNextInTreeView() 159 | { 160 | QTreeView *tvPkgFileList = 161 | ui->twProperties->widget(ctn_TABINDEX_FILES)->findChild("tvPkgFileList"); 162 | 163 | if (tvPkgFileList && tvPkgFileList->model()->rowCount() > 0 && m_foundFilesInPkgFileList->count() > 0) 164 | { 165 | if (m_indFoundFilesInPkgFileList+1 < m_foundFilesInPkgFileList->count()) 166 | { 167 | m_indFoundFilesInPkgFileList = m_indFoundFilesInPkgFileList + 1; 168 | } 169 | else 170 | { 171 | m_indFoundFilesInPkgFileList = 0; 172 | } 173 | 174 | tvPkgFileList->setCurrentIndex( 175 | m_foundFilesInPkgFileList->at(m_indFoundFilesInPkgFileList)); 176 | tvPkgFileList->scrollTo( 177 | m_foundFilesInPkgFileList->at(m_indFoundFilesInPkgFileList)); 178 | } 179 | } 180 | 181 | /* 182 | * Every time the user presses Shift+F3 or clicks Find Previous inside a treeView... 183 | */ 184 | void MainWindow::searchBarFindPreviousInTreeView() 185 | { 186 | QTreeView *tvPkgFileList = 187 | ui->twProperties->widget(ctn_TABINDEX_FILES)->findChild("tvPkgFileList"); 188 | 189 | if (tvPkgFileList && tvPkgFileList->model()->rowCount() > 0 && m_foundFilesInPkgFileList->count() > 0) 190 | { 191 | if (m_indFoundFilesInPkgFileList == 0) 192 | { 193 | m_indFoundFilesInPkgFileList = m_foundFilesInPkgFileList->count()-1; 194 | } 195 | else 196 | m_indFoundFilesInPkgFileList -= 1; 197 | 198 | tvPkgFileList->setCurrentIndex( 199 | m_foundFilesInPkgFileList->at(m_indFoundFilesInPkgFileList)); 200 | tvPkgFileList->scrollTo( 201 | m_foundFilesInPkgFileList->at(m_indFoundFilesInPkgFileList)); 202 | } 203 | } 204 | 205 | /* 206 | * Every time the user presses ESC or clicks the close button inside a textBrowser... 207 | */ 208 | void MainWindow::searchBarClosedInTextBrowser() 209 | { 210 | QTextBrowser *tb = ui->twProperties->currentWidget()->findChild("textBrowser"); 211 | QTextCursor tc = tb->textCursor(); 212 | searchBarTextChangedInTextBrowser(""); 213 | tc.clearSelection(); 214 | tb->setTextCursor(tc); 215 | 216 | if (tb) 217 | tb->setFocus(); 218 | } 219 | 220 | /* 221 | * Every time the user presses ESC or clicks the close button inside a treeView... 222 | */ 223 | void MainWindow::searchBarClosedInTreeView() 224 | { 225 | searchBarTextChangedInTreeView(""); 226 | QTreeView *tb = ui->twProperties->currentWidget()->findChild("tvPkgFileList"); 227 | if (tb) tb->setFocus(); 228 | } 229 | 230 | /* 231 | * Helper to position in the first result when searching inside a textBrowser 232 | */ 233 | void MainWindow::positionInFirstMatch() 234 | { 235 | QTextBrowser *tb = ui->twProperties->currentWidget()->findChild("textBrowser"); 236 | SearchBar *sb = ui->twProperties->currentWidget()->findChild("searchbar"); 237 | 238 | if (tb && sb && sb->isVisible() && !sb->getTextToSearch().isEmpty()){ 239 | tb->moveCursor(QTextCursor::Start); 240 | if (tb->find(sb->getTextToSearch())) 241 | sb->getSearchLineEdit()->setFoundStyle(); 242 | else 243 | sb->getSearchLineEdit()->setNotFoundStyle(); 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /src/model/packagemodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2014 Thomas Binkau 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef OCTOPI_PACKAGEMODEL_H 22 | #define OCTOPI_PACKAGEMODEL_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/package.h" 29 | #include "src/packagerepository.h" 30 | 31 | class PackageModel : public QAbstractItemModel, public PackageRepository::IDependency 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | // Column indices for Package's treeview 37 | static const int ctn_PACKAGE_ICON_COLUMN = 0; 38 | static const int ctn_PACKAGE_NAME_COLUMN = 1; 39 | static const int ctn_PACKAGE_VERSION_COLUMN = 2; 40 | //static const int ctn_PACKAGE_ORIGIN_COLUMN = 3; 41 | static const int ctn_PACKAGE_SIZE_COLUMN = 3; 42 | static const int ctn_PACKAGE_INSTALLEDON_COLUMN = 4; 43 | // Pseudo Column indices for additional filter criterias 44 | static const int ctn_PACKAGE_DESCRIPTION_FILTER_NO_COLUMN = 5; 45 | 46 | public: 47 | explicit PackageModel(const PackageRepository& repo, QObject* parent = 0); 48 | 49 | signals: 50 | 51 | public slots: 52 | 53 | // QAbstractItemModel interface 54 | public: 55 | virtual QModelIndex index(int row, int column, const QModelIndex& parent) const /*override*/; 56 | virtual QModelIndex parent(const QModelIndex& child) const /*override*/; 57 | virtual int rowCount(const QModelIndex& parent) const /*override*/; 58 | virtual int columnCount(const QModelIndex& parent) const /*override*/; 59 | virtual QVariant data(const QModelIndex& index, int role) const /*override*/; 60 | virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const /*override*/; 61 | virtual void sort(int column, Qt::SortOrder order) /*override*/; 62 | 63 | void clear(); 64 | 65 | // IDependency interface 66 | public: 67 | virtual void beginResetRepository() /*override*/; 68 | virtual void endResetRepository() /*override*/; 69 | 70 | // Getter 71 | public: 72 | int getPackageCount() const; 73 | int getInstalledPackagesCount() const; 74 | bool isFiltered() const; 75 | 76 | const PackageRepository::PackageData* getData(const QModelIndex& index) const; 77 | 78 | // Setter 79 | public: 80 | void applyFilter(ViewOptions pkgViewOptions, const QString& repo, const QString& group); 81 | void applyFilter(bool packagesNotInstalled, const QString& group); 82 | void applyFilter(const int filterColumn); 83 | void applyFilter(const QString& filterExp); 84 | void applyFilter(const int filterColumn, const QString& filterExp); 85 | 86 | void setShowColumnInstalledOn(bool value); 87 | 88 | private: 89 | const QIcon& getIconFor(const PackageRepository::PackageData& package) const; 90 | void sort(); 91 | 92 | private: 93 | int m_installedPackagesCount; 94 | bool m_showColumnInstalledOn; 95 | const PackageRepository& m_packageRepo; 96 | QList m_listOfPackages; // should be provided sorted by name (by repo) 97 | QList m_columnSortedlistOfPackages; // sorted by column 98 | 99 | // Filter / Sort attributes 100 | Qt::SortOrder m_sortOrder; 101 | int m_sortColumn; 102 | bool m_filterPackagesInstalled; 103 | bool m_filterPackagesNotInstalled; 104 | QString m_filterPackagesNotInThisGroup; 105 | QString m_filterPackagesNotInThisRepo; 106 | int m_filterColumn; 107 | QRegularExpression m_filterRegExp; 108 | 109 | // Cache 110 | QIcon m_iconNotInstalled; 111 | QIcon m_iconInstalled; 112 | QIcon m_iconInstalledUnrequired; 113 | QIcon m_iconNewer; 114 | QIcon m_iconOutdated; 115 | QIcon m_iconLocked; 116 | //QIcon m_iconForeign; 117 | //QIcon m_iconForeignOutdated; 118 | }; 119 | 120 | #endif // OCTOPI_PACKAGEMODEL_H 121 | -------------------------------------------------------------------------------- /src/package.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef PACKAGE_H 22 | #define PACKAGE_H 23 | 24 | #include "settingsmanager.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | const QString ctn_TEMP_ACTIONS_FILE ( QDir::homePath() + QDir::separator() + ".config/octopkg" + QDir::separator() + ".qt_temp_" ); 36 | const QString ctn_PACMAN_DATABASE_DIR = "/var/lib/pacman"; 37 | const QString ctn_PKGNG_DRAGONFLYBSD_CORE_DB_FILE = "/var/db/pkg/repo-Avalon.sqlite"; 38 | const QString ctn_PKGNG_FREEBSD_CORE_DB_FILE = "/var/db/pkg/repo-FreeBSD.sqlite"; 39 | const QString ctn_PKGNG_HARDENEDBSD_CORE_DB_FILE = "/var/db/pkg/repo-HardenedBSD.sqlite"; 40 | const QString ctn_PKGNG_GHOSTBSD_CORE_DB_FILE = "/var/db/pkg/repo-GhostBSD.sqlite"; 41 | const QString ctn_PKGNG_PCBSD_CORE_DB_FILE = "/var/db/pkg/repo-pcbsd-major.sqlite"; 42 | const QString ctn_PKGNG_NOMADBSD_CORE_DB_FILE = "/var/db/pkg/local.sqlite"; 43 | const QString ctn_PKGNG_FAKE_REPOSITORY = "_WWW"; 44 | 45 | enum PackageStatus { ectn_LOCKED, ectn_INSTALLED, ectn_NON_INSTALLED, ectn_OUTDATED, ectn_NEWER }; 46 | 47 | enum ViewOptions { ectn_ALL_PKGS, ectn_INSTALLED_PKGS, ectn_NON_INSTALLED_PKGS }; 48 | 49 | struct PackageListData{ 50 | QString name; 51 | QString repository; 52 | QString origin; 53 | QString version; 54 | QString categories; 55 | QString www; 56 | QString comment; 57 | QString description; 58 | QString outatedVersion; 59 | double installedSize; 60 | double downloadSize; 61 | QString installedOn; 62 | QString license; 63 | int popularity; //votes 64 | PackageStatus status; 65 | 66 | PackageListData() : name(""), 67 | downloadSize(0.0), 68 | popularity(0), 69 | status(ectn_NON_INSTALLED){ 70 | } 71 | 72 | PackageListData(QString n, QString v) 73 | : name(n), 74 | version(v), 75 | downloadSize(0.0), 76 | popularity(0), 77 | status(ectn_NON_INSTALLED){ 78 | } 79 | 80 | PackageListData(QString n, QString v, QString dSize) 81 | : name(n), 82 | version(v), 83 | downloadSize(QString(dSize).toDouble()), 84 | popularity(0), 85 | status(ectn_NON_INSTALLED){ 86 | } 87 | 88 | PackageListData(QString n, QString r, QString v, PackageStatus pkgStatus, QString outVersion="") 89 | : name(n), 90 | repository(r), 91 | version(v), 92 | outatedVersion(outVersion.trimmed()), 93 | downloadSize(0.0), 94 | popularity(0), 95 | status(pkgStatus){ 96 | } 97 | 98 | PackageListData(QString n, QString r, QString v, QString d, PackageStatus pkgStatus, QString outVersion="") 99 | : name(n), 100 | repository(r), 101 | version(v), 102 | description(d), 103 | outatedVersion(outVersion.trimmed()), 104 | downloadSize(0.0), 105 | popularity(0), 106 | status(pkgStatus){ 107 | } 108 | 109 | PackageListData(QString n, QString o, QString v, QString c, PackageStatus pkgStatus, double iSize, double dSize, QString iDate) 110 | : name(n), 111 | repository(""), 112 | origin(o), 113 | version(v), 114 | comment(c), 115 | installedSize(iSize), 116 | downloadSize(dSize), 117 | installedOn(iDate), 118 | status(pkgStatus){ 119 | } 120 | }; 121 | 122 | struct TransactionInfo{ 123 | QStringList *packages; 124 | QString sizeToInstall; 125 | QString sizeToDownload; 126 | }; 127 | 128 | struct OutdatedPackageInfo{ 129 | QString oldVersion; 130 | QString newVersion; 131 | }; 132 | 133 | struct PackageInfoData{ 134 | QString name; 135 | QString repository; 136 | QString version; 137 | QString url; 138 | QString license; 139 | QString group; 140 | QString provides; 141 | QString requiredBy; 142 | QString optionalFor; 143 | QString dependsOn; 144 | QString optDepends; 145 | QString conflictsWith; 146 | QString replaces; 147 | QString packager; 148 | QString maintainer; 149 | QString arch; 150 | QString description; 151 | QString comment; 152 | QString installedOn; 153 | double downloadSize; 154 | double installedSize; 155 | QString downloadSizeAsString; 156 | QString installedSizeAsString; 157 | QString options; 158 | }; 159 | 160 | class Result; 161 | 162 | class Package{ 163 | private: 164 | static Result verifyPreReleasePackage(const QStringList &versao1, 165 | const QStringList &versao2, const QString &pacote); 166 | 167 | static QString extractFieldFromInfo(const QString &field, const QString &pkgInfo); 168 | static double simplePow(int base, int exp); 169 | static void navigateThroughDirs(QStringList parts, QStringList& auxList, int ind); 170 | 171 | public: 172 | static int rpmvercmp(const char *a, const char *b); 173 | static QSet* getLockedPackageList(); 174 | static QSet* getUnrequiredPackageList(); 175 | static QMap *getOutdatedStringList(); 176 | static QStringList * getPackageGroups(); 177 | static QStringList * getPackagesOfGroup(const QString &groupName); 178 | static TransactionInfo getTargetUpgradeList(const QString &pkgName = ""); 179 | static QStringList * getTargetRemovalList(const QString &pkgName); 180 | static QList * parsePackageTuple(const QStringList &packageTuples, QStringList &packageCache); 181 | static QList *getPackageList(const QString &packageName = ""); 182 | 183 | //Remote package methods 184 | static QList * getRemotePackageList(const QString& searchString); 185 | static PackageInfoData getInformation(const QString &pkgName, bool foreignPackage = false); 186 | static double getDownloadSizeDescription(const QString &pkgName); 187 | static QString getInformationDescription(const QString &pkgName, bool foreignPackage = false); 188 | static QString getInformationInstalledSize(const QString &pkgName, bool foreignPackage = false); 189 | static QString getDependencies(const QString &pkgName); 190 | static QStringList getContents(const QString &pkgName, bool isInstalled); 191 | static QStringList getOptionalDeps(const QString &pkgName); 192 | static QString getName(const QString &pkgInfo); 193 | static QString getVersion(const QString &pkgInfo); 194 | static QString getRepository(const QString &pkgInfo); 195 | static QString getURL(const QString &pkgInfo); 196 | static QString getLicense(const QString &pkgInfo); 197 | static QString getGroup(const QString &pkgInfo); 198 | static QString getProvides(const QString &pkgInfo); 199 | static QString getDependsOn(const QString &pkgInfo); 200 | static QString getOptDepends(const QString &pkgInfo); 201 | static QString getConflictsWith(const QString &pkgInfo); 202 | static QString getReplaces(const QString &pkgInfo); 203 | static QString getRequiredBy(const QString &pkgInfo); 204 | static QString getOptionalFor(const QString &pkgInfo); 205 | static QString getPackager(const QString &pkgInfo); 206 | static QString getMaintainer(const QString &pkgInfo); 207 | static QString getArch(const QString &pkgInfo); 208 | static QString getDescription(const QString &pkgInfo); 209 | static QString getComment(const QString &pkgInfo); 210 | static QString getInstalledOn(const QString &pkgInfo); 211 | static double getDownloadSize(const QString &pkgInfo); 212 | static QString getDownloadSizeAsString(const QString &pkgInfo); 213 | static double getInstalledSize(const QString &pkgInfo); 214 | static QString getInstalledSizeAsString(const QString &pkgInfo); 215 | static QString getOptions(const QString &pkgInfo); 216 | 217 | static QString kbytesToSize(float Bytes ); 218 | static double strToKBytes(QString size); 219 | static double strToKBytes2(QString size); 220 | static QString makeAnchorOfDependencies(const QString &deps); 221 | static QString makeURLClickable(const QString &information); 222 | static QString getBaseName( const QString& pkgName ); 223 | static QString parseSearchString( QString searchStr, bool exactMatch = false ); 224 | static bool hasPkgNGDatabase(); 225 | static bool isForbidden(const QString pkgName); 226 | }; 227 | 228 | #endif 229 | -------------------------------------------------------------------------------- /src/packagerepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Thomas Binkau 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef OCTOPI_PACKAGEREPOSITORY_H 22 | #define OCTOPI_PACKAGEREPOSITORY_H 23 | 24 | #include 25 | #include 26 | 27 | #include "package.h" 28 | 29 | /* 30 | * @brief Central data storage for package data 31 | */ 32 | class PackageRepository 33 | { 34 | public: 35 | class PackageData; 36 | typedef QList TListOfPackages; 37 | 38 | public: 39 | //////////////////////// 40 | /* 41 | * @brief The IDependency class used for notification of dependent models 42 | */ 43 | class IDependency { 44 | public: 45 | virtual void beginResetRepository() = 0; 46 | virtual void endResetRepository() = 0; 47 | }; 48 | 49 | //////////////////////// 50 | /* 51 | * @brief Holds data of one package + a few convenience functions 52 | */ 53 | class PackageData { 54 | public: 55 | /** 56 | * @brief PackageData constructor 57 | * @param package = parsed data from pacman (e.g.) 58 | * @param isRequired = false if package is not required by other packages installed, or true otherwise 59 | */ 60 | PackageData(const PackageListData& package, const bool isRequired /*, const bool isManagedByAUR*/); 61 | 62 | inline bool installed() const { 63 | return status != ectn_NON_INSTALLED; 64 | } 65 | 66 | inline bool outdated() const { 67 | return status == ectn_OUTDATED || status == ectn_NEWER; 68 | } 69 | 70 | public: 71 | /*const*/ bool required; 72 | //const bool managedByAUR; // AUR packages must not be in any group 73 | /*const*/ QString name; 74 | /*const*/ QString repository; 75 | /*const*/ QString origin; 76 | /*const*/ QString version; 77 | /*const*/ QString description; 78 | /*const*/ QString outdatedVersion; 79 | /*const*/ double downloadSize; 80 | /*const*/ double installedSize; 81 | QString installedOn; 82 | /*const*/ PackageStatus status; 83 | /*const*/ QString comment; 84 | /*const*/ QString www; 85 | /*const*/ QString categories; 86 | //const int popularity; // -1 for non AUR 87 | //const QString popularityString; 88 | }; 89 | 90 | //////////////////////// 91 | /* 92 | * @brief The Group class holds name and members of a package group 93 | */ 94 | class Group { 95 | public: 96 | Group(const QString& name); 97 | 98 | const QString& getName(); 99 | bool memberListEquals(const QStringList& packagelist); 100 | void addPackage(PackageData& package); 101 | void invalidateList(); 102 | 103 | const TListOfPackages* getPackageList() const; 104 | 105 | private: 106 | QString name; 107 | TListOfPackages* m_listOfPackages; // WEAK ptr PackageData* 108 | }; 109 | 110 | public: 111 | PackageRepository(); 112 | 113 | void registerDependency(IDependency& depends); 114 | void setAURData(const QList*const listOfForeignPackages, const QSet& unrequiredPackages); 115 | void setData(const QList*const listOfPackages, const QSet& unrequiredPackages); 116 | void checkAndSetGroups(const QStringList& listOfGroups); 117 | void checkAndSetMembersOfGroup(const QString& group, const QStringList& members); 118 | void markOutdatedPackages(const QStringList& outdatedStringList); 119 | 120 | const TListOfPackages& getPackageList() const; 121 | const TListOfPackages& getPackageList(const QString& group) const; 122 | PackageData* getFirstPackageByName(const QString name) const; 123 | PackageData* getFirstPackageByNameEx(const QString name); 124 | 125 | private: 126 | std::vector m_dependingModels; 127 | TListOfPackages m_listOfPackages; // sorted qlist of all packages 128 | TListOfPackages m_listOfAURPackages; // sorted qlist of all AUR packages 129 | QList m_listOfGroups; // sorted list of all pacman package groups 130 | bool memberListOfGroupsEquals(const QStringList& listOfGroups); 131 | }; 132 | 133 | #endif // OCTOPI_PACKAGEREPOSITORY_H 134 | -------------------------------------------------------------------------------- /src/packagetreeview.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2020 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "packagetreeview.h" 22 | #include 23 | #include 24 | #include 25 | 26 | #include "settingsmanager.h" 27 | #include "model/packagemodel.h" 28 | #include "treeviewpackagesitemdelegate.h" 29 | 30 | /* 31 | * This widget is the main package list tree view widget for Octopi 32 | */ 33 | 34 | PackageTreeView::PackageTreeView(QWidget *parent):QTreeView(parent) 35 | { 36 | } 37 | 38 | /* 39 | * The necessary initialization settings 40 | */ 41 | void PackageTreeView::init() 42 | { 43 | //ui->tvPackages->setAlternatingRowColors(true); 44 | setItemDelegate(new TreeViewPackagesItemDelegate(this)); 45 | setContextMenuPolicy(Qt::CustomContextMenu); 46 | setSelectionMode(QAbstractItemView::ExtendedSelection); 47 | setEditTriggers(QAbstractItemView::NoEditTriggers); 48 | setVerticalScrollMode(QAbstractItemView::ScrollPerItem); 49 | setAllColumnsShowFocus(true); 50 | setSortingEnabled(true); 51 | setIndentation(0); 52 | header()->setSortIndicatorShown(true); 53 | header()->setSectionsClickable(true); 54 | header()->setSectionsMovable(false); 55 | header()->setSectionResizeMode(QHeaderView::Interactive); 56 | header()->setDefaultAlignment(Qt::AlignLeft); 57 | } 58 | 59 | /* 60 | * Here we get all column sizes from the current Octopi Settings store 61 | */ 62 | void PackageTreeView::resizePackageView() 63 | { 64 | setColumnWidth(PackageModel::ctn_PACKAGE_ICON_COLUMN, 65 | SettingsManager::getPackageIconColumnWidth()); 66 | setColumnWidth(PackageModel::ctn_PACKAGE_NAME_COLUMN, 67 | SettingsManager::getPackageNameColumnWidth()); 68 | setColumnWidth(PackageModel::ctn_PACKAGE_VERSION_COLUMN, 69 | SettingsManager::getPackageVersionColumnWidth()); 70 | setColumnWidth(PackageModel::ctn_PACKAGE_SIZE_COLUMN, 71 | SettingsManager::getPackageSizeColumnWidth()); 72 | } 73 | 74 | /* 75 | * Whenever user clicks left mouse button in the first column... 76 | */ 77 | void PackageTreeView::mouseReleaseEvent(QMouseEvent *event) 78 | { 79 | QTreeView::mouseReleaseEvent(event); 80 | 81 | if ((event->button() == Qt::LeftButton) && (columnAt(event->pos().x()) == PackageModel::ctn_PACKAGE_ICON_COLUMN)) 82 | { 83 | emit customContextMenuRequested(event->pos()); 84 | } 85 | } 86 | 87 | /* 88 | * Whenever focus enters this widget 89 | */ 90 | /*void PackageTreeView::focusInEvent(QFocusEvent *event) 91 | { 92 | Q_UNUSED(event) 93 | 94 | QModelIndex maux = currentIndex(); 95 | scrollTo(maux, QAbstractItemView::PositionAtCenter); 96 | setCurrentIndex(maux); 97 | }*/ 98 | -------------------------------------------------------------------------------- /src/packagetreeview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2020 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef PACKAGETREEVIEW_H 22 | #define PACKAGETREEVIEW_H 23 | 24 | #include 25 | #include 26 | 27 | class PackageTreeView : public QTreeView 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit PackageTreeView(QWidget *parent = nullptr); 33 | void init(); 34 | void resizePackageView(); 35 | 36 | protected: 37 | virtual void mouseReleaseEvent(QMouseEvent *event); 38 | //virtual void focusInEvent(QFocusEvent *event); 39 | 40 | }; 41 | 42 | #endif // PACKAGETREEVIEW_H 43 | -------------------------------------------------------------------------------- /src/searchbar.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2006 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "searchbar.h" 22 | #include "searchlineedit.h" 23 | #include "uihelper.h" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* 34 | * The QWidget that holds the SearchLineEdit control and has that firefox's search sexy look! 35 | */ 36 | 37 | SearchBar::SearchBar(QWidget *parent) : 38 | QWidget(parent) 39 | { 40 | init(); 41 | } 42 | 43 | /* 44 | * Obligatory initialization code. 45 | */ 46 | void SearchBar::init() 47 | { 48 | setVisible(false); 49 | setObjectName("searchbar"); 50 | QHBoxLayout *layout = new QHBoxLayout(this); 51 | layout->setSpacing(0); 52 | layout->setContentsMargins(4, 4, 4, 4); 53 | 54 | setStyleSheet("QWidget#searchbar{" 55 | "border-top-width: .6px;" 56 | "border-top-style: solid;" 57 | "border-top-color: darkgray;}"); 58 | 59 | m_searchLineEdit = new SearchLineEdit(this); 60 | m_searchLineEdit->setMinimumWidth(300); 61 | QToolButton *m_previousButton = new QToolButton(this); 62 | QToolButton *m_nextButton = new QToolButton(this); 63 | m_previousButton->setToolButtonStyle(Qt::ToolButtonTextOnly); 64 | m_nextButton->setToolButtonStyle(Qt::ToolButtonTextOnly); 65 | 66 | QAction *m_previousAction = new QAction(this); 67 | QAction *m_nextAction = new QAction(this); 68 | 69 | m_previousAction->setText("< " + tr("Previous")); 70 | m_previousButton->setAutoRaise(true); 71 | m_previousAction->setShortcut(QKeySequence(Qt::SHIFT | Qt::Key_F3)); 72 | m_nextAction->setText(tr("Next") + " >"); 73 | m_nextButton->setAutoRaise(true); 74 | m_nextAction->setShortcut(Qt::Key_F3); 75 | m_previousButton->setDefaultAction(m_previousAction); 76 | m_nextButton->setDefaultAction(m_nextAction); 77 | 78 | QToolButton *tbClose = new QToolButton(); 79 | tbClose->setIcon(IconHelper::getIconClose()); 80 | 81 | tbClose->setAutoRaise(true); 82 | tbClose->setStyleSheet("QToolButton{ font-size: 16px; font-family: verdana; border-radius: 4px; } " 83 | "QToolButton:hover{ background-color: palette(light); }" 84 | "QToolButton::pressed{ background-color: palette(mid); }"); 85 | 86 | tbClose->setToolTip(tr("Close")); 87 | tbClose->setShortcut(Qt::Key_Escape); 88 | 89 | layout->addWidget(tbClose, 0, Qt::AlignLeft); 90 | layout->addSpacing(4); 91 | layout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft); 92 | layout->addSpacing(2); 93 | layout->addWidget(m_previousButton, 1, Qt::AlignLeft); 94 | layout->addWidget(m_nextButton, 20, Qt::AlignLeft); 95 | 96 | setLayout(layout); 97 | m_searchLineEdit->setFocus(); 98 | 99 | connect(tbClose, SIGNAL(clicked()), this, SLOT(close())); 100 | connect(m_searchLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString))); 101 | connect(m_previousAction, SIGNAL(triggered()), this, SIGNAL(findPrevious())); 102 | connect(m_nextAction, SIGNAL(triggered()), this, SIGNAL(findNext())); 103 | } 104 | 105 | /* 106 | * Whenever the user presses the escape or clicks the close icon... 107 | */ 108 | void SearchBar::close() 109 | { 110 | hide(); 111 | disconnect(m_searchLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString))); 112 | m_searchLineEdit->setText(""); 113 | connect(m_searchLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString))); 114 | emit closed(); 115 | } 116 | 117 | /* 118 | * Helper method to clean SearchLineEdit's content 119 | */ 120 | void SearchBar::clear() 121 | { 122 | m_searchLineEdit->setText(""); 123 | } 124 | 125 | /* 126 | * Overriden in order to get stylesheets working in QWidget derived classes 127 | */ 128 | void SearchBar::paintEvent(QPaintEvent *) 129 | { 130 | QStyleOption styleOption; 131 | styleOption.initFrom(this); 132 | QPainter painter(this); 133 | style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this); 134 | } 135 | 136 | /* 137 | * Overriden in order to respond to ENTER and RETURN key presses to find next itens 138 | */ 139 | void SearchBar::keyPressEvent(QKeyEvent *ke) 140 | { 141 | if(!m_searchLineEdit->text().isEmpty() && (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)) 142 | { 143 | findNext(); 144 | } 145 | } 146 | 147 | /* 148 | * Whenever SearchBar needs to be brought to UI... 149 | */ 150 | void SearchBar::show() 151 | { 152 | setVisible(true); 153 | m_searchLineEdit->selectAll(); 154 | m_searchLineEdit->setFocus(); 155 | } 156 | -------------------------------------------------------------------------------- /src/searchbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2006 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef SEARCHBAR_H 22 | #define SEARCHBAR_H 23 | 24 | #include "searchlineedit.h" 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | class SearchBar : public QWidget 32 | { 33 | Q_OBJECT 34 | 35 | private: 36 | SearchLineEdit *m_searchLineEdit; 37 | 38 | protected: 39 | virtual void paintEvent(QPaintEvent *); 40 | virtual void keyPressEvent(QKeyEvent *); 41 | 42 | public: 43 | explicit SearchBar(QWidget *parent = 0); 44 | 45 | void init(); 46 | inline SearchLineEdit *getSearchLineEdit(){ return m_searchLineEdit; } 47 | inline QString getTextToSearch(){ return m_searchLineEdit->text(); } 48 | inline bool hasFocus(){ return m_searchLineEdit->hasFocus(); } 49 | inline void initSearchLineEdit(){ m_searchLineEdit->initStyleSheet(); } 50 | 51 | signals: 52 | void closed(); 53 | void textChanged(QString text); 54 | void findNext(); 55 | void findPrevious(); 56 | 57 | public slots: 58 | void show(); 59 | void close(); 60 | 61 | void clear(); 62 | 63 | }; 64 | 65 | #endif // SEARCHBAR_H 66 | -------------------------------------------------------------------------------- /src/searchlineedit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Source code extracted from: 3 | http://www.jakepetroules.com/2011/07/10/creating-a-windows-explorer-style-search-box-in-qt 4 | 5 | Written by Jake Petroules 6 | Adapted to suit QTGZManager 7 | */ 8 | 9 | #include "searchlineedit.h" 10 | #include "strconstants.h" 11 | #include "wmhelper.h" 12 | #include "uihelper.h" 13 | //#include "iostream" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | //#include 23 | 24 | SearchLineEdit::SearchLineEdit(QWidget *parent, bool hasSLocate) : 25 | QLineEdit(parent){ 26 | 27 | m_hasLocate = hasSLocate; 28 | m_completerModel = new QStringListModel(this); 29 | m_completer = new QCompleter(m_completerModel, this); 30 | m_completer->setCaseSensitivity(Qt::CaseInsensitive); 31 | m_completer->setCompletionMode(QCompleter::PopupCompletion); 32 | m_completer->setCompletionColumn(0); 33 | m_completer->setMaxVisibleItems(10); 34 | 35 | setCompleter(m_completer); 36 | 37 | // Create the search button and set its icon, cursor, and stylesheet 38 | this->m_SearchButton = new QToolButton(this); 39 | this->m_SearchButton->setFocusPolicy(Qt::NoFocus); 40 | 41 | // Increase button size a bit for kde 42 | if (WMHelper::isKDERunning()) 43 | this->m_SearchButton->setFixedSize(18, 18); 44 | else 45 | this->m_SearchButton->setFixedSize(16, 16); 46 | 47 | this->m_SearchButton->setCursor(Qt::ArrowCursor); 48 | this->m_SearchButton->setStyleSheet(this->buttonStyleSheetForCurrentState()); 49 | 50 | m_defaultValidator = new QRegularExpressionValidator(QRegularExpression("[a-zA-Z0-9_\\-\\$\\^\\*\\+\\(\\)\\[\\]\\.\\s]+"), this); 51 | m_aurValidator = new QRegularExpressionValidator(QRegularExpression("[a-zA-Z0-9_\\-\\s\\+\\$\\^]+"), this); 52 | m_fileValidator = new QRegularExpressionValidator(QRegularExpression("[a-zA-Z0-9_\\-\\/\\.]+"), this); 53 | 54 | setValidator(m_defaultValidator); 55 | 56 | // Update the search button when the text changes 57 | QObject::connect(this, SIGNAL(textChanged(QString)), SLOT(updateSearchButton(QString))); 58 | 59 | // Some stylesheet and size corrections for the text box 60 | this->setPlaceholderText(StrConstants::getFind()); 61 | this->setStyleSheet(this->styleSheetForCurrentState()); 62 | this->setFocusPolicy(Qt::StrongFocus); 63 | } 64 | 65 | /* 66 | * Refreshes the validator used in QLineEdit depending on the options choosed by the user 67 | */ 68 | void SearchLineEdit::setRefreshValidator(ValidatorType validatorType) 69 | { 70 | if (validatorType == ectn_AUR_VALIDATOR) 71 | { 72 | m_completerModel->setStringList(QStringList()); 73 | setValidator(m_aurValidator); 74 | } 75 | else if (validatorType == ectn_FILE_VALIDATOR) 76 | setValidator(m_fileValidator); 77 | else if (validatorType == ectn_DEFAULT_VALIDATOR) 78 | { 79 | m_completerModel->setStringList(QStringList()); 80 | setValidator(m_defaultValidator); 81 | } 82 | 83 | //If the current string is not valid anymore, let's erase it! 84 | int pos = 0; 85 | QString search = text(); 86 | if (this->validator()->validate(search, pos) == QValidator::Invalid) 87 | setText(""); 88 | } 89 | 90 | /* 91 | * Refreshes completer data used in QLineEdit if slocate is installed 92 | */ 93 | void SearchLineEdit::refreshCompleterData() 94 | { 95 | if (m_hasLocate) 96 | { 97 | QStringList sl = UnixCommand::getFilePathSuggestions(text()); 98 | 99 | if (sl.count() > 0) 100 | { 101 | m_completerModel->setStringList(sl); 102 | } 103 | } 104 | } 105 | 106 | void SearchLineEdit::resizeEvent(QResizeEvent *event) 107 | { 108 | Q_UNUSED(event); 109 | this->m_SearchButton->move(5, (this->rect().height() - this->m_SearchButton->height()) / 2); 110 | } 111 | 112 | void SearchLineEdit::keyPressEvent(QKeyEvent *event) 113 | { 114 | if (event->key() == Qt::Key_U && event->modifiers() == Qt::ControlModifier) 115 | { 116 | event->ignore(); 117 | } 118 | else 119 | { 120 | return QLineEdit::keyPressEvent(event); 121 | } 122 | } 123 | 124 | void SearchLineEdit::updateSearchButton(const QString &text) 125 | { 126 | if (!text.isEmpty()){ 127 | // We have some text in the box - set the button to clear the text 128 | QObject::connect(this->m_SearchButton, SIGNAL(clicked()), SLOT(clear())); 129 | } 130 | else{ 131 | // The text box is empty - make the icon do nothing when clicked 132 | QObject::disconnect(this->m_SearchButton, SIGNAL(clicked()), this, SLOT(clear())); 133 | } 134 | 135 | this->m_SearchButton->setStyleSheet(this->buttonStyleSheetForCurrentState()); 136 | } 137 | 138 | QString SearchLineEdit::styleSheetForCurrentState() 139 | { 140 | int frameWidth = 1; 141 | QString style; 142 | style += "QLineEdit {"; 143 | 144 | if (this->text().isEmpty()) 145 | { 146 | style += "font-family: 'MS Sans Serif';"; 147 | style += "font-style: italic;"; 148 | } 149 | else 150 | { 151 | QFont font(QApplication::font()); 152 | font.setItalic(true); 153 | setFont(font); 154 | } 155 | 156 | style += "padding-left: 20px;"; 157 | style += QString("padding-right: %1px;").arg(this->m_SearchButton->sizeHint().width() + frameWidth + 1); 158 | style += "border-width: 3px;}"; 159 | //style += "border-image: url(:/resources/images/esf-border.png) 3 3 3 3 stretch;"; 160 | //style += "background-color: rgba(255, 255, 255, 255);"; //204);"; 161 | //style += "color: black;}"; 162 | 163 | return style; 164 | } 165 | 166 | void SearchLineEdit::setFoundStyle(){ 167 | QString style; 168 | style += "QLineEdit {"; 169 | 170 | style += "font-family: 'MS Sans Serif';"; 171 | style += "font-style: italic;"; 172 | style += "padding-left: 20px;"; 173 | style += QString("padding-right: %1px;").arg(this->m_SearchButton->sizeHint().width() + 2); 174 | style += "border-width: 3px;}"; 175 | //style += "border-image: url(:/resources/images/esf-border.png) 3 3 3 3 stretch;"; 176 | //style += "color: black; "; 177 | //style += "background-color: rgb(255, 255, 200);"; 178 | //style += "border-color: rgb(206, 204, 197);}"; 179 | setStyleSheet(style); 180 | 181 | /*else 182 | // setPalette() must be called after setStyleSheet() 183 | { 184 | style += "padding-left: 20px;}"; 185 | setStyleSheet(style); 186 | 187 | QPalette palette(QApplication::palette()); 188 | palette.setColor(QPalette::Base, QColor(255, 255, 200)); 189 | palette.setColor(QPalette::Text, Qt::darkGray); // give more contrast to text 190 | setPalette(palette); 191 | }*/ 192 | } 193 | 194 | void SearchLineEdit::setNotFoundStyle(){ 195 | QString style; 196 | style += "QLineEdit {"; 197 | style += "font-family: 'MS Sans Serif';"; 198 | style += "font-style: italic;"; 199 | style += "padding-left: 20px;"; 200 | style += QString("padding-right: %1px;").arg(this->m_SearchButton->sizeHint().width() + 2); 201 | style += "border-width: 3px;}"; 202 | //style += "border-image: url(:/resources/images/esf-border.png) 3 3 3 3 stretch;"; 203 | //style += "color: white; "; 204 | //style += "background-color: lightgray;"; //rgb(255, 108, 108); //palette(mid);"; //rgb(207, 135, 142);"; 205 | //style += "border-color: rgb(206, 204, 197);}"; 206 | setStyleSheet(style); 207 | } 208 | 209 | QString SearchLineEdit::buttonStyleSheetForCurrentState() const 210 | { 211 | // When using KDE avoid stylesheet customization 212 | if (WMHelper::isKDERunning()) { 213 | this->text().isEmpty() ? this->m_SearchButton->setIcon(IconHelper::getIconSearch()) 214 | : this->m_SearchButton->setIcon(IconHelper::getIconClear()); 215 | 216 | if (!this->text().isEmpty()) 217 | this->m_SearchButton->setToolTip(StrConstants::getClear()); 218 | else 219 | this->m_SearchButton->setToolTip(""); 220 | 221 | this->m_SearchButton->setAutoRaise(true); 222 | return QString(); 223 | } 224 | 225 | QString style; 226 | style += "QToolButton {"; 227 | style += "border: none; margin: 0; padding: 0;"; 228 | style += QString("background-image: url(:/resources/images/esf-%1.png);").arg(this->text().isEmpty() ? "search" : "clear"); 229 | style += "}"; 230 | 231 | if (!this->text().isEmpty()) 232 | { 233 | style += "QToolButton:pressed { background-image: url(:/resources/images/esf-clear.png); }"; 234 | this->m_SearchButton->setToolTip(StrConstants::getClear()); 235 | } 236 | else this->m_SearchButton->setToolTip(""); 237 | 238 | return style; 239 | } 240 | -------------------------------------------------------------------------------- /src/searchlineedit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Code extracted from 3 | http://www.jakepetroules.com/2011/07/10/creating-a-windows-explorer-style-search-box-in-qt 4 | 5 | Written by Jake Petroules 6 | Adapted to suit QTGZManager 7 | */ 8 | 9 | #ifndef SEARCHLINEEDIT_H 10 | #define SEARCHLINEEDIT_H 11 | 12 | #include 13 | 14 | class QToolButton; 15 | class QValidator; 16 | class QCompleter; 17 | class QStringListModel; 18 | 19 | enum ValidatorType { ectn_AUR_VALIDATOR, ectn_FILE_VALIDATOR, ectn_DEFAULT_VALIDATOR }; 20 | 21 | class SearchLineEdit : public QLineEdit 22 | { 23 | Q_OBJECT 24 | 25 | private: 26 | bool m_hasLocate; 27 | QStringListModel *m_completerModel; 28 | QCompleter *m_completer; 29 | QValidator *m_defaultValidator; 30 | QValidator *m_aurValidator; 31 | QValidator *m_fileValidator; 32 | QToolButton *m_SearchButton; 33 | QString styleSheetForCurrentState(); 34 | QString buttonStyleSheetForCurrentState() const; 35 | 36 | private slots: 37 | void updateSearchButton(const QString &text); 38 | 39 | protected: 40 | virtual void resizeEvent(QResizeEvent *event); 41 | virtual void keyPressEvent(QKeyEvent *event); 42 | 43 | public: 44 | explicit SearchLineEdit(QWidget *parent = NULL, bool hasSLocate = false); 45 | 46 | inline void initStyleSheet(){ setStyleSheet(styleSheetForCurrentState()); } 47 | void setRefreshValidator(ValidatorType validatorType); 48 | void refreshCompleterData(); 49 | 50 | public slots: 51 | void setFoundStyle(); 52 | void setNotFoundStyle(); 53 | }; 54 | 55 | #endif // SEARCHLINEEDIT_H 56 | -------------------------------------------------------------------------------- /src/settingsmanager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef SETTINGSMANAGER_H 22 | #define SETTINGSMANAGER_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | const QString ctn_ORGANIZATION("octopkg"); 30 | const QString ctn_APPLICATION("octopkg"); 31 | const QString ctn_KEY_CURRENT_TAB_INDEX("Current_Tab_Index"); 32 | const QString ctn_KEY_WINDOW_SIZE("Window_Size"); 33 | const QString ctn_KEY_TRANSACTION_WINDOW_SIZE("Transaction_Window_Size"); 34 | const QString ctn_KEY_PANEL_ORGANIZING("Panel_Organizing"); 35 | const QString ctn_KEY_PACKAGE_LIST_ORDERED_COL("PackageList_Ordered_Col"); 36 | const QString ctn_KEY_PACKAGE_LIST_SORT_ORDER("PackageList_Sort_Order"); 37 | //const QString ctn_KEY_SKIP_MIRRORCHECK_ON_STARTUP("Skip_Mirror_Check_At_Startup"); 38 | const QString ctn_KEY_SPLITTER_HORIZONTAL_STATE("Splitter_Horizontal_State"); 39 | const QString ctn_KEY_SHOW_GROUPS_PANEL("Show_Groups_Panel"); 40 | const QString ctn_KEY_PACKAGE_ICON_COLUMN_WIDTH("Package_Icon_Column_Width"); 41 | const QString ctn_KEY_PACKAGE_NAME_COLUMN_WIDTH("Package_Name_Column_Width"); 42 | const QString ctn_KEY_PACKAGE_VERSION_COLUMN_WIDTH("Package_Version_Column_Width"); 43 | const QString ctn_KEY_PACKAGE_SIZE_COLUMN_WIDTH("Package_Size_Column_Width"); 44 | const QString ctn_KEY_TERMINAL("Terminal"); 45 | const QString ctn_AUTOMATIC("automatic"); 46 | 47 | //Notifier related 48 | const QString ctn_KEY_LAST_SYNC_DB_TIME("LastSyncDbTime"); 49 | const QString ctn_KEY_SYNC_DB_INTERVAL("SyncDbInterval"); 50 | const QString ctn_KEY_SYNC_DB_HOUR("SyncDbHour"); 51 | 52 | //CacheCleaner related 53 | const QString ctn_KEEP_NUM_INSTALLED("Keep_Num_Installed"); 54 | const QString ctn_KEEP_NUM_UNINSTALLED("Keep_Num_Uninstalled"); 55 | 56 | enum SaveSettingsReason { ectn_PACKAGELIST, ectn_CURRENTTABINDEX, ectn_NORMAL=30, 57 | ectn_MAXIMIZE_PACKAGES=40, ectn_MAXIMIZE_PROPERTIES=50, ectn_GROUPS=5 }; 58 | 59 | class SettingsManager 60 | { 61 | 62 | private: 63 | 64 | static SettingsManager *m_pinstance; 65 | QSettings *m_SYSsettings; 66 | 67 | SettingsManager(const SettingsManager&); 68 | SettingsManager& operator= (const SettingsManager&); 69 | SettingsManager(); 70 | virtual ~SettingsManager(); 71 | QSettings* getSYSsettings() { return m_SYSsettings; } 72 | 73 | public: 74 | 75 | static SettingsManager* instance(); 76 | static QString getTerminal(); 77 | 78 | static QString getOctoPkgConfPath() 79 | { 80 | return QDir::homePath() + 81 | QDir::separator() + ".config/octopkg/octopkg.conf"; 82 | } 83 | 84 | static int getCurrentTabIndex(); 85 | static int getPanelOrganizing(); 86 | static int getPackageListOrderedCol(); 87 | static int getPackageListSortOrder(); 88 | static int getPackageIconColumnWidth(); 89 | static int getPackageNameColumnWidth(); 90 | static int getPackageVersionColumnWidth(); 91 | static int getPackageSizeColumnWidth(); 92 | 93 | //Notifier related 94 | static int getSyncDbHour(); 95 | static int getSyncDbInterval(); 96 | static QDateTime getLastSyncDbTime(); 97 | 98 | //static bool getSkipMirrorCheckAtStartup(); 99 | static bool getShowGroupsPanel(); 100 | static QByteArray getWindowSize(); 101 | static QByteArray getTransactionWindowSize(); 102 | static QByteArray getSplitterHorizontalState(); 103 | //static bool isValidTerminalSelected(); 104 | 105 | //CacheCleaner related 106 | static int getKeepNumInstalledPackages(); 107 | static int getKeepNumUninstalledPackages(); 108 | 109 | static void setCurrentTabIndex(int newValue); 110 | static void setPanelOrganizing(int newValue); 111 | static void setPackageListOrderedCol(int newValue); 112 | static void setPackageListSortOrder(int newValue); 113 | static void setShowGroupsPanel(int newValue); 114 | static void setWindowSize(QByteArray newValue); 115 | static void setTransactionWindowSize(QByteArray newValue); 116 | static void setSplitterHorizontalState(QByteArray newValue); 117 | 118 | static void setSyncDbHour(int newValue); 119 | static void setSyncDbInterval(int newValue); 120 | static void setLastSyncDbTime(QDateTime newValue); 121 | 122 | static void setTerminal(QString newValue); 123 | static void setKeepNumInstalledPackages(int newValue); 124 | static void setKeepNumUninstalledPackages(int newValue); 125 | 126 | static void setPackageIconColumnWidth(int newValue); 127 | static void setPackageNameColumnWidth(int newValue); 128 | static void setPackageVersionColumnWidth(int newValue); 129 | static void setPackageSizeColumnWidth(int newValue); 130 | }; 131 | 132 | #endif // SETTINGSMANAGER_H 133 | -------------------------------------------------------------------------------- /src/strconstants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef STRCONSTANTS_H 22 | #define STRCONSTANTS_H 23 | 24 | class QString; 25 | 26 | class StrConstants{ 27 | public: 28 | 29 | static QString getApplicationName(); 30 | static QString getApplicationVersion(); 31 | static QString getQtVersion(); 32 | static QString getApplicationCliHelp(); 33 | static QString getAll(); 34 | static QString getDragonFlyBSDNews(); 35 | static QString getFreeBSDNews(); 36 | static QString getGhostBSDNews(); 37 | static QString getHardenedBSDNews(); 38 | static QString getNewsErrorMessage(); 39 | static QString getIncompatibleBSDFlavourError(); 40 | static QString getInternetUnavailableError(); 41 | static QString getDisplayAllCategories(); 42 | static QString getHelpUsage(); 43 | static QString getHelpAbout(); 44 | static QString getName(); 45 | static QString getVersion(); 46 | static QString getOutdatedVersion(); 47 | static QString getAvailableVersion(); 48 | static QString getNoDescriptionAvailabe(); 49 | static QString getURL(); 50 | static QString getOrigin(); 51 | static QString getLicenses(); 52 | static QString getCategory(); 53 | static QString getCategories(); 54 | static QString getProvides(); 55 | static QString getDependencies(); 56 | static QString getDependsOn(); 57 | static QString getRequiredBy(); 58 | static QString getOptionalFor(); 59 | static QString getOptionalDeps(); 60 | static QString getConflictsWith(); 61 | static QString getReplaces(); 62 | static QString getOptions(); 63 | static QString getSize(); 64 | static QString getDownloadSize(); 65 | static QString getInstalledSize(); 66 | static QString getPackager(); 67 | static QString getMaintainer(); 68 | static QString getPackage(); 69 | static QString getPackages(); 70 | static QString getArchitecture(); 71 | static QString getInstalledOn(); 72 | static QString getDescription(); 73 | static QString getAttention(); 74 | static QString getAutomaticSuCommand(); 75 | static QString getPassword(); 76 | static QString getTabInfoName(); 77 | static QString getTabFilesName(); 78 | static QString getTabTransactionName(); 79 | static QString getTabOutputName(); 80 | static QString getTabNewsName(); 81 | static QString getContentsOf(); 82 | static QString getFind(); 83 | static QString getClear(); 84 | static QString getOutdatedInstalledVersion(); 85 | static QString getNewerInstalledVersion(); 86 | static QString getBuildingPackageList(); 87 | static QString getSearchingForBSDNews(); 88 | static QString getOneOutdatedPackage(); 89 | static QString getOutdatedPackages(int outdatedPackagesCount); 90 | static QString getNewVersionAvailable(); 91 | static QString getTotalPackages(int packageCount); 92 | static QString getSelectedPackages(int selectedCount); 93 | static QString getNumberInstalledPackages(int installedPackagesCount); 94 | static QString getNumberOutdatedPackages(int outdatedPackagesCount); 95 | static QString getNumberAvailablePackages(int availablePackagesCount); 96 | static QString getCleaningPackageCache(); 97 | static QString getRemovingPacmanTransactionLockFile(); 98 | static QString getLineEditTextLocal(); 99 | static QString getLineEditTextRemote(); 100 | static QString getRemotePackageSearchTip(); 101 | static QString getSyncing(); 102 | static QString getPressAnyKey(); 103 | static QString getSyncDatabase(); 104 | static QString getCheckUpdates(); 105 | static QString getIsUpToDate(); 106 | static QString getLockingPackage(); 107 | static QString getUnlockingPackage(); 108 | static QString getSystemUpgrade(); 109 | static QString getInstallingPackages(); 110 | static QString getRemovingPackages(); 111 | static QString getRemovingAndInstallingPackages(); 112 | static QString getChooseATerminal(); 113 | static QString getCollectingTransactionData(); 114 | static QString getRunningCommandInTerminal(); 115 | static QString getCommandFinishedOK(); 116 | static QString getCommandFinishedWithErrors(); 117 | static QString geRetrievingPackage(); 118 | static QString getTotalDownloadSize(); 119 | static QString getRetrievePackage(); 120 | static QString getRemovePackage(); 121 | static QString getRetrievePackages(int retrievePackagesCount); 122 | static QString getRemovePackages(int removePackagesCount); 123 | static QString getWarnHoldPkgFound(); 124 | static QString getNoNewUpdatesAvailable(); 125 | static QString getOneNewUpdate(); 126 | static QString getNewUpdates(int newUpdatesCount); 127 | static QString getConfirmationQuestion(); 128 | static QString getWarning(); 129 | static QString getConfirmation(); 130 | static QString getThereHasBeenATransactionError(); 131 | static QString getConfirmExecuteTransactionInTerminal(); 132 | static QString getCleanCacheConfirmation(); 133 | static QString getRemovePacmanTransactionLockFileConfirmation(); 134 | static QString getCancelTransactionConfirmation(); 135 | static QString getPkgNotAvailable(); 136 | static QString getEnterAdministratorsPassword(); 137 | static QString getErrorNoSuCommand(); 138 | static QString getYoullNeedSuFrontend(); 139 | static QString getOctoPKGDoasNotFound(); 140 | static QString getErrorNoPkgFound(); 141 | static QString getErrorNoDoasSudoFound(); 142 | static QString getErrorNoSHFound(); 143 | static QString getErrorRunningWithRoot(); 144 | static QString getThereIsARunningTransaction(); 145 | static QString getThereArePendingActions(); 146 | static QString getDoYouReallyWantToQuit(); 147 | static QString getExecutingCommand(); 148 | static QString getRunInTerminal(); 149 | static QString getNeedsAppRestart(); 150 | static QString getWarnNeedsAppRestart(); 151 | static QString getFileChooserTitle(); 152 | static QString getThisIsNotATextFile(); 153 | static QString getTransactionInstallText(); 154 | static QString getTransactionRemoveText(); 155 | static QString getRemove(); 156 | static QString getInstall(); 157 | static QString getInstallPkg(); 158 | static QString getReinstall(); 159 | static QString getUpdate(); 160 | static QString getLock(); 161 | static QString getUnlock(); 162 | static QString getRemoveItem(); 163 | static QString getRemoveItems(); 164 | static QString getPressCtrlAToSelectAll(); 165 | static QString getFilterLocalPackages(); 166 | static QString getSearchForPackages(); 167 | static QString getSearchStringIsShort(); 168 | static QString getCopyFullPath(); 169 | static QString getNotifierSetupDialogTitle(); 170 | static QString getNotiferSetupDialogGroupBoxTitle(); 171 | static QString getOnceADay(); 172 | static QString getOnceADayAt(); 173 | static QString getOnceADayAtDesc(); 174 | static QString getOnceEvery(); 175 | static QString getOnceEveryDesc(); 176 | static QString getSetInterval(); 177 | static QString getError(); 178 | static QString getForeignToolGroup(); 179 | static QString getStop(); 180 | 181 | //Style Sheets --------------------------------- 182 | 183 | static QString getToolBarCSS(); 184 | static QString getTreeViewCSS(); 185 | }; 186 | 187 | #endif // STRCONSTANTS_H 188 | -------------------------------------------------------------------------------- /src/terminal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef TERMINAL_H 22 | #define TERMINAL_H 23 | 24 | #include "utils.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class Terminal : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | private: 35 | QString m_selectedTerminal; 36 | QProcess *m_process; 37 | utils::ProcessWrapper *m_processWrapper; 38 | 39 | public: 40 | Terminal(QObject *parent, const QString& selectedTerminal); 41 | virtual ~Terminal(); 42 | 43 | void openTerminal(const QString& dirName); 44 | void openRootTerminal(); 45 | void runCommandInTerminal(const QStringList& commandList); 46 | void runCommandInTerminalAsNormalUser(const QStringList& commandList); 47 | 48 | static QStringList getListOfAvailableTerminals(); 49 | 50 | signals: 51 | void started(); 52 | void finished(int, QProcess::ExitStatus); 53 | void startedTerminal(); 54 | void finishedTerminal(int, QProcess::ExitStatus); 55 | }; 56 | 57 | #endif // TERMINAL_H 58 | -------------------------------------------------------------------------------- /src/transactiondialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2013 Manuel Tortosa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 18 | ***************************************************************************/ 19 | 20 | #include "transactiondialog.h" 21 | #include "uihelper.h" 22 | #include "strconstants.h" 23 | //#include "unixcommand.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /* 32 | * This is the dialog used to show the transaction summary 33 | */ 34 | 35 | TransactionDialog::TransactionDialog(QWidget* parent) : 36 | QDialog(parent), 37 | ui(new Ui::TransactionDialog) 38 | { 39 | ui->setupUi(this); 40 | 41 | ui->actionRunInTerminal->setIcon(IconHelper::getIconTerminal()); 42 | m_runInTerminalButton = 43 | new QPushButton(IconHelper::getIconTerminal(), StrConstants::getRunInTerminal()); 44 | 45 | //ui->buttonBox->addButton(m_runInTerminalButton, QDialogButtonBox::AcceptRole); 46 | QPushButton *yesButton = ui->buttonBox->button(QDialogButtonBox::Yes); 47 | QPushButton *noButton = ui->buttonBox->button(QDialogButtonBox::No); 48 | 49 | if (!UnixCommand::isRootOnZFS()) 50 | { 51 | ui->cbCreateBootEnv->setVisible(false); 52 | } 53 | 54 | noButton->setFocus(); 55 | 56 | connect(m_runInTerminalButton, SIGNAL(clicked()), this, 57 | SLOT(slotRunInTerminal())); 58 | connect(yesButton, SIGNAL(clicked()), this, SLOT(slotYes())); 59 | connect(noButton, SIGNAL(clicked()), this, SLOT(reject())); 60 | 61 | setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | 62 | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); 63 | 64 | //removeYesButton(); 65 | } 66 | 67 | void TransactionDialog::setText(const QString text) 68 | { 69 | ui->text->setText(text); 70 | } 71 | 72 | void TransactionDialog::setInformativeText(const QString text) 73 | { 74 | ui->informativeText->setText(text); 75 | } 76 | 77 | void TransactionDialog::setDetailedText(const QString detailedtext) 78 | { 79 | ui->detailedText->setText(detailedtext); 80 | 81 | //We must search for a 'pacman-version-number' pkg to force terminal upgrade use 82 | /*if (detailedtext.contains(QRegularExpression("pacman-[0-9]+"))) 83 | { 84 | removeYesButton(); 85 | }*/ 86 | } 87 | 88 | bool TransactionDialog::isBootEnvChecked() 89 | { 90 | return (!ui->cbCreateBootEnv->isHidden() && ui->cbCreateBootEnv->isChecked()); 91 | } 92 | 93 | void TransactionDialog::uncheckBootEnv() 94 | { 95 | ui->cbCreateBootEnv->setChecked(false); 96 | } 97 | 98 | void TransactionDialog::disableBootEnv() 99 | { 100 | ui->cbCreateBootEnv->setChecked(false); 101 | ui->cbCreateBootEnv->setVisible(false); 102 | } 103 | 104 | /* 105 | * Useful when you don't want to rely on pacman's -noconfirm option 106 | */ 107 | void TransactionDialog::removeYesButton() 108 | { 109 | QPushButton *yesButton = ui->buttonBox->button(QDialogButtonBox::Yes); 110 | ui->buttonBox->removeButton(yesButton); 111 | } 112 | 113 | void TransactionDialog::reject() 114 | { 115 | done(QDialogButtonBox::No); 116 | } 117 | 118 | void TransactionDialog::slotRunInTerminal() 119 | { 120 | done(QDialogButtonBox::AcceptRole); 121 | } 122 | 123 | void TransactionDialog::done(int p) 124 | { 125 | //Let's save the dialog size value before closing it. 126 | QByteArray windowSize=saveGeometry(); 127 | SettingsManager::setTransactionWindowSize(windowSize); 128 | QDialog::done(p); 129 | } 130 | 131 | void TransactionDialog::slotYes() 132 | { 133 | done(QDialogButtonBox::Yes); 134 | } 135 | 136 | int TransactionDialog::exec() 137 | { 138 | //Let's restore the dialog size saved... 139 | restoreGeometry(SettingsManager::getTransactionWindowSize()); 140 | return QDialog::exec(); 141 | } 142 | -------------------------------------------------------------------------------- /src/transactiondialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 20013 Manuel Tortosa * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 18 | ***************************************************************************/ 19 | 20 | #ifndef TRANSACTIONDIALOG_H 21 | #define TRANSACTIONDIALOG_H 22 | 23 | #include "ui_transactiondialog.h" 24 | #include 25 | 26 | const int ctn_RUN_IN_TERMINAL(328); 27 | 28 | class QPushButton; 29 | 30 | class TransactionDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | TransactionDialog(QWidget * parent); 36 | virtual ~TransactionDialog(){} 37 | void setText(const QString text); 38 | void setInformativeText(const QString text); 39 | void setDetailedText(const QString detailedtext); 40 | bool isBootEnvChecked(); 41 | void uncheckBootEnv(); 42 | void disableBootEnv(); 43 | void removeYesButton(); 44 | 45 | public slots: 46 | virtual void reject(); 47 | virtual void done(int p); 48 | virtual int exec(); 49 | 50 | private slots: 51 | void slotRunInTerminal(); 52 | void slotYes(); 53 | 54 | private: 55 | Ui::TransactionDialog *ui; 56 | QPushButton *m_runInTerminalButton; 57 | }; 58 | 59 | #endif // TRANSACTIONDIALOG_H 60 | -------------------------------------------------------------------------------- /src/treeviewpackagesitemdelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "treeviewpackagesitemdelegate.h" 22 | #include "globals.h" 23 | #include "uihelper.h" 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | QPoint gPoint; 34 | 35 | TreeViewPackagesItemDelegate::TreeViewPackagesItemDelegate(QObject *parent): 36 | QStyledItemDelegate(parent) 37 | { 38 | } 39 | 40 | /* 41 | * Called every time user positions mouse over package's treeview items 42 | */ 43 | bool TreeViewPackagesItemDelegate::helpEvent ( QHelpEvent *event, QAbstractItemView*, 44 | const QStyleOptionViewItem&, const QModelIndex &index ) 45 | { 46 | static QString lastShownPackage; 47 | 48 | if (this->parent()->objectName() == "tvPackages") 49 | { 50 | QTreeView* tvPackages = qobject_cast(this->parent()); 51 | PackageModel* sim = qobject_cast(tvPackages->model()); 52 | if (sim == NULL || sim->getPackageCount() == 0) return false; 53 | 54 | const PackageRepository::PackageData*const si = sim->getData(index); 55 | if (si != NULL) 56 | { 57 | gPoint = tvPackages->mapToGlobal(event->pos()); 58 | 59 | if (lastShownPackage != si->name) 60 | { 61 | //QDateTime now = QDateTime::currentDateTime(); 62 | //qDebug() << now.time().toString(QLatin1String("hh:mm:ss.zzz")) << ": Tooltip for " << si->name; 63 | QFuture f; 64 | disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip())); 65 | f = QtConcurrent::run(showPackageDescription, si->name); 66 | g_fwToolTip.setFuture(f); 67 | connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip())); 68 | } 69 | 70 | lastShownPackage = si->name; 71 | } 72 | else return false; 73 | } 74 | else if (this->parent()->objectName() == "tvTransaction") 75 | { 76 | QTreeView* tvTransaction = qobject_cast(this->parent()); 77 | QStandardItemModel *sim = qobject_cast(tvTransaction->model()); 78 | if (sim->rowCount() == 0) return false; 79 | 80 | QStandardItem *si = sim->itemFromIndex(index); 81 | 82 | if (si) 83 | { 84 | //If it's really a package in the Transaction treeview... 85 | QString pkgName=si->text(); 86 | 87 | if (si->icon().pixmap(22, 22).toImage() == 88 | IconHelper::getIconToInstall().pixmap(22, 22).toImage() || 89 | si->icon().pixmap(22, 22).toImage() == 90 | IconHelper::getIconToRemove().pixmap(22, 22).toImage()) 91 | { 92 | gPoint = tvTransaction->mapToGlobal(event->pos()); 93 | 94 | if (lastShownPackage != pkgName) 95 | { 96 | QFuture f; 97 | disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip())); 98 | f = QtConcurrent::run(showPackageDescription, pkgName); 99 | g_fwToolTip.setFuture(f); 100 | connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip())); 101 | } 102 | } 103 | else 104 | { 105 | QToolTip::hideText(); 106 | } 107 | 108 | lastShownPackage = pkgName; 109 | } 110 | } 111 | 112 | return true; 113 | } 114 | 115 | /* 116 | * When the tooltip QFuture method is finished, we show the selected tooltip to the user 117 | */ 118 | void TreeViewPackagesItemDelegate::execToolTip() 119 | { 120 | if (g_fwToolTip.result().trimmed().isEmpty()) 121 | return; 122 | 123 | gPoint.setX(gPoint.x() + 25); 124 | gPoint.setY(gPoint.y() + 25); 125 | 126 | QToolTip::showText(gPoint, g_fwToolTip.result()); 127 | } 128 | -------------------------------------------------------------------------------- /src/treeviewpackagesitemdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef TREEVIEWPACKAGESITEMDELEGATE_H 22 | #define TREEVIEWPACKAGESITEMDELEGATE_H 23 | 24 | #include "package.h" 25 | #include 26 | #include 27 | 28 | class TreeViewPackagesItemDelegate : public QStyledItemDelegate 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | TreeViewPackagesItemDelegate(QObject *parent); 34 | 35 | public slots: 36 | 37 | bool helpEvent ( QHelpEvent * event, QAbstractItemView*, 38 | const QStyleOptionViewItem&, const QModelIndex &index ); 39 | 40 | void execToolTip(); 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/ui/octopkgtabinfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2014 Thomas Binkau 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "octopkgtabinfo.h" 22 | #include "src/strconstants.h" 23 | #include "src/package.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | /* 30 | * The OctopiTabInfo class provides functionality for the Tab "Info" 31 | */ 32 | 33 | /** 34 | * @brief OctopiTabInfo::anchorBegin for navigation 35 | */ 36 | const QString OctopkgTabInfo::anchorBegin("anchorBegin"); 37 | 38 | OctopkgTabInfo::OctopkgTabInfo() 39 | { 40 | } 41 | 42 | /** 43 | * This function has been extracted from src/mainwindow_refresh.cpp void MainWindow::refreshTabInfo(QString pkgName) 44 | */ 45 | QString OctopkgTabInfo::formatTabInfo(const PackageRepository::PackageData& package, 46 | const QMap& outdatedPkgList) 47 | { 48 | PackageInfoData pid = Package::getInformation(package.name); 49 | 50 | QString version = StrConstants::getVersion(); 51 | QString url = StrConstants::getURL(); 52 | QString licenses = StrConstants::getLicenses(); 53 | QString groups = StrConstants::getCategories(); 54 | QString downloadSize = StrConstants::getDownloadSize(); 55 | QString installedSize = StrConstants::getInstalledSize(); 56 | QString maintainer = StrConstants::getMaintainer(); 57 | QString architecture = StrConstants::getArchitecture(); 58 | QString installedOn = StrConstants::getInstalledOn(); 59 | QString options = StrConstants::getOptions(); 60 | QString dependencies = StrConstants::getDependencies(); 61 | 62 | //Let's put package description in UTF-8 format 63 | QString pkgDescription; 64 | 65 | if (!pid.comment.isEmpty()) 66 | pkgDescription = pid.comment; 67 | else 68 | { 69 | int ind = package.comment.indexOf(" "); 70 | pkgDescription = package.comment.right(package.comment.size() - ind).trimmed(); 71 | } 72 | 73 | QString html; 74 | html += ""; 75 | html += ""; 76 | html += "

" + package.name + "

"; 77 | html += pkgDescription; 78 | html += ""; 79 | html += ""; 80 | 81 | if (package.repository.isEmpty() && pid.url != "UNKNOWN") 82 | html += ""; 83 | else if (!package.repository.isEmpty()) 84 | html += ""; 85 | 86 | if (package.outdated()) 87 | { 88 | if (package.status != ectn_NEWER) 89 | { 90 | const OutdatedPackageInfo opi = outdatedPkgList.value(package.name); 91 | html += ""; 93 | } 94 | /*else 95 | { 96 | QString newerVersion = package.outdatedVersion; 97 | html += ""; 100 | }*/ 101 | } 102 | else 103 | { 104 | html += ""; 105 | } 106 | 107 | //This is needed as packager names could be encoded in different charsets, resulting in an error 108 | QString packagerName = pid.maintainer; 109 | packagerName = packagerName.replace("<", "<"); 110 | packagerName = packagerName.replace(">", ">"); 111 | 112 | if(! pid.license.isEmpty()) 113 | html += ""; 114 | 115 | if(! pid.installedOn.isEmpty()) 116 | html += ""; 123 | } 124 | else 125 | { 126 | if(! package.categories.isEmpty()) 127 | html += ""; 128 | } 129 | 130 | if(package.downloadSize != 0) 131 | html += ""; 132 | 133 | if(! pid.installedSizeAsString.isEmpty() && pid.installedSizeAsString != "0.00B") 134 | html += ""; 135 | 136 | if (!packagerName.isEmpty()) 137 | html += ""; 138 | 139 | if (!pid.arch.isEmpty()) 140 | html += ""; 141 | 142 | QString dependenciesList = Package::getDependencies(package.name); 143 | 144 | if ( !dependenciesList.isEmpty()) 145 | { 146 | html += "
"; 147 | if (! pid.options.isEmpty()) html += "
"; 148 | } 149 | 150 | if(! pid.options.isEmpty()) 151 | { 152 | if (dependenciesList.isEmpty()) html += "
"; 153 | 154 | html += ""; 155 | } 156 | 157 | html += "
" + url + "" + pid.url + "
" + url + "" + Package::makeURLClickable(package.www) + "
" + version + "" + opi.oldVersion + " " + 92 | StrConstants::getNewVersionAvailable().arg(opi.newVersion) + "
" + version + "" + package.version + " " 98 | + StrConstants::getNewerInstalledVersion().arg(newerVersion) + 99 | "
" + version + "" + package.version + "
" + licenses + "" + pid.license + "
" + installedOn + "" + pid.installedOn; 117 | 118 | //Show this info only if there's something to show 119 | if (package.repository.isEmpty()) 120 | { 121 | if(! pid.group.contains("None")) 122 | html += "
" + groups + "" + pid.group + "
" + groups + "" + package.categories + "
" + downloadSize + "" + Package::kbytesToSize(package.downloadSize) + "
" + installedSize + "" + pid.installedSizeAsString + "
" + maintainer + "" + packagerName + "
" + architecture + "" + pid.arch + "
" + dependencies + "" + dependenciesList + "
" + options + "" + pid.options + "

"; 158 | 159 | return html; 160 | } 161 | -------------------------------------------------------------------------------- /src/ui/octopkgtabinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2014 Thomas Binkau 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef OCTOPITABINFO_H 22 | #define OCTOPITABINFO_H 23 | 24 | #include "src/packagerepository.h" 25 | #include "src/package.h" 26 | 27 | /** 28 | * @brief The OctopiTabInfo class provides functionality for the Tab "Info" 29 | * 30 | * PackageName 31 | * 32 | * packagedescription 33 | * 34 | * site/URL www.example.org 35 | * Version 1.2.3.4 36 | * Licence GPL 37 | * Depends abcde fg 38 | * Opt.Dep abcde: why\n 39 | * fg: why 40 | * Download 5kb 41 | * Install 10kb 42 | * Packager notme@any.where 43 | * Arch any 44 | * Build 1.1.2000 45 | */ 46 | 47 | class OctopkgTabInfo 48 | { 49 | public: 50 | OctopkgTabInfo(); 51 | 52 | /** 53 | * @brief formats TabInfo as HTML 54 | * @param package (the package to show details for) 55 | * @param outdatedAURPackagesNameVersion 56 | * @return html 57 | * 58 | * This function has been extracted from src/mainwindow_refresh.cpp void MainWindow::refreshTabInfo(QString pkgName) 59 | */ 60 | static QString formatTabInfo(const PackageRepository::PackageData& package, const QMap &outdatedRemotePackagesNameVersion); 61 | 62 | static const QString anchorBegin; 63 | }; 64 | 65 | #endif // OCTOPITABINFO_H 66 | -------------------------------------------------------------------------------- /src/unixcommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef UNIXCOMMAND_H 22 | #define UNIXCOMMAND_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "package.h" 31 | #include "utils.h" 32 | 33 | const QString ctn_MIRROR_CHECK_APP("mirror-check"); 34 | 35 | enum CommandExecuting { ectn_NONE, ectn_CLEAN_CACHE, ectn_MIRROR_CHECK, 36 | ectn_CHECK_UPDATES, ectn_SYSTEM_UPGRADE, ectn_INSTALL, 37 | ectn_REMOVE, ectn_REMOVE_INSTALL, 38 | ectn_LOCK, ectn_UNLOCK, 39 | ectn_RUN_SYSTEM_UPGRADE_IN_TERMINAL, 40 | ectn_RUN_IN_TERMINAL, ectn_LOCAL_PKG_REFRESH }; 41 | 42 | enum BSDFlavour { ectn_DRAGONFLYBSD, ectn_FREEBSD, ectn_GHOSTBSD, ectn_HARDENEDBSD, ectn_NOMADBSD, ectn_UNKNOWN }; 43 | 44 | enum Language { ectn_LANG_ENGLISH, ectn_LANG_USER_DEFINED }; 45 | 46 | //Forward class declarations. 47 | class QString; 48 | //class QStringList; 49 | class Terminal; 50 | 51 | class UnixCommand : public QObject{ 52 | Q_OBJECT 53 | 54 | private: 55 | QString m_readAllStandardOutput; 56 | QString m_readAllStandardError; 57 | QString m_errorString; 58 | Terminal *m_terminal; 59 | QProcess *m_process; 60 | static QFile *m_temporaryFile; 61 | 62 | public: 63 | UnixCommand(QObject *parent); 64 | 65 | inline QProcess * getProcess(){ return m_process; } 66 | 67 | //Returns the BSD Flavour where OctoPkg is running on 68 | static BSDFlavour getBSDFlavour(); 69 | 70 | //Delegations from Package class (due to QProcess use) 71 | static QString runCurlCommand(const QStringList ¶ms); 72 | 73 | static QByteArray performQuery(const QStringList args); 74 | static QByteArray performQuery(const QString &args); 75 | static int cancelProcess(); 76 | static QByteArray getRemotePackageList(const QString &searchString, bool useCommentSearch = true); 77 | static QByteArray getLockedPackageList(); 78 | static QByteArray getUnrequiredPackageList(); 79 | static QByteArray getOutdatedPackageList(); 80 | static QByteArray getForeignPackageList(); 81 | static QByteArray getDependenciesList(const QString &pkgName); 82 | static QByteArray getPackageList(const QString &pkgName = ""); 83 | static QByteArray getPackageInformation(const QString &pkgName, bool foreignPackage); 84 | static QByteArray getPackageContentsUsingPkg(const QString &pkgName); 85 | static bool isPkgfileInstalled(); 86 | 87 | static QString getPackageByFilePath(const QString &filePath); 88 | static QStringList getFilePathSuggestions(const QString &file); 89 | static QByteArray getPackageGroups(); 90 | static QByteArray getPackagesFromGroup(const QString &groupName); 91 | static QByteArray getInstalledPackages(); 92 | static QByteArray getTargetUpgradeList(const QString &pkgName = ""); 93 | static QByteArray getTargetRemovalList(const QString &pkgName); 94 | 95 | //static QString getSystemArchitecture(); 96 | static bool hasInternetConnection(); 97 | static bool doInternetPingTest(); 98 | static bool isTextFile( const QString& fileName ); //fileName is Path + Name 99 | static bool isLSBRelated(const QString& fileName); 100 | static QString getPkgNGVersion(); 101 | static bool hasTheExecutable( const QString& exeName ); 102 | static bool isAppRunning(const QString &appName, bool justOneInstance = false); 103 | 104 | static bool isRootRunning(){ 105 | int uid = geteuid(); 106 | return (uid == 0); //Returns TRUE if root is running OctoPkg 107 | } 108 | 109 | static QFile* getTemporaryFile(){ 110 | quint32 gen = QRandomGenerator::global()->generate(); 111 | m_temporaryFile = new QFile(ctn_TEMP_ACTIONS_FILE + QString::number(gen)); 112 | m_temporaryFile->open(QIODevice::ReadWrite|QIODevice::Text); 113 | m_temporaryFile->setPermissions(QFile::Permissions(QFile::ExeOwner|QFile::ReadOwner)); 114 | 115 | return m_temporaryFile; 116 | } 117 | 118 | static void removeTemporaryFile(){ 119 | if (m_temporaryFile != 0){ 120 | m_temporaryFile->close(); 121 | m_temporaryFile->remove(); 122 | delete m_temporaryFile; 123 | m_temporaryFile = 0; 124 | } 125 | } 126 | 127 | static QString getShell(); 128 | static bool isRootOnZFS(); 129 | 130 | static void execCommandAsNormalUser(const QString &pCommand); 131 | static void execCommand(const QString &pCommand); 132 | static QByteArray getCommandOutput(const QString &pCommand); 133 | static void removeTemporaryFiles(); 134 | 135 | void runCommandInTerminal(const QStringList& commandList); 136 | void runCommandInTerminalAsNormalUser(const QStringList& commandList); 137 | void terminateCommand(); 138 | void executeCommand(const QString &pCommand, Language lang=ectn_LANG_ENGLISH); 139 | void executeCommand(QStringList ¶ms); 140 | void executeCommandAsNormalUser(const QString &pCommand); 141 | 142 | QString readAllStandardOutput(); 143 | QString readAllStandardError(); 144 | QString errorString(); 145 | 146 | public slots: 147 | void processReadyReadStandardOutput(); 148 | void processReadyReadStandardError(); 149 | 150 | signals: 151 | void started(); 152 | void readyReadStandardOutput(); 153 | void finished ( int, QProcess::ExitStatus ); 154 | void readyReadStandardError(); 155 | 156 | //ProcessWrapper signals 157 | void startedTerminal(); 158 | void finishedTerminal(int, QProcess::ExitStatus); 159 | }; 160 | 161 | #endif // UNIXCOMMAND_H 162 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef UTILS_H 22 | #define UTILS_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace utils{ 31 | 32 | QString showFullPathOfItem( const QModelIndex &index ); 33 | QList * findFileInTreeView( const QString& name, const QStandardItemModel *sim); 34 | QString retrieveDistroNews(bool searchForLatestNews); 35 | QString parseDistroNews(); 36 | 37 | } //namespace utils 38 | 39 | #endif // UTILS_H 40 | -------------------------------------------------------------------------------- /src/wmhelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of OctoPkg, an open-source GUI for pkgng. 3 | * Copyright (C) 2015 Alexandre Albuquerque Arnt 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #ifndef WMHELPER_H 22 | #define WMHELPER_H 23 | 24 | #include 25 | 26 | const QString ctn_NO_SU_COMMAND("none"); 27 | const QString ctn_ROOT_SH("/bin/sh -c "); 28 | 29 | const QString ctn_QSUDO("qsudo"); 30 | 31 | const QString ctn_KDESU("kdesu"); 32 | 33 | const QString ctn_KDE_DESKTOP("kwin"); 34 | const QString ctn_KDE_X11_DESKTOP("kwin_x11"); 35 | const QString ctn_KDE_WAYLAND_DESKTOP("kwin_wayland"); 36 | const QString ctn_KDE_EDITOR("kwrite"); 37 | const QString ctn_KDE_FILE_MANAGER("kfmclient"); 38 | const QString ctn_KDE_TERMINAL("konsole"); 39 | const QString ctn_KDE4_OPEN("kde-open"); 40 | const QString ctn_KDE5_OPEN("kde-open5"); 41 | const QString ctn_KDE4_FILE_MANAGER("dolphin"); 42 | const QString ctn_KDE4_EDITOR("kate"); 43 | 44 | const QString ctn_TDESU("tdesu"); 45 | const QString ctn_TDE_DESKTOP("twin"); 46 | const QString ctn_TDE_EDITOR("kwrite"); 47 | const QString ctn_TDE_FILE_MANAGER("kfmclient"); 48 | const QString ctn_TDE_TERMINAL("konsole"); 49 | 50 | const QString ctn_GKSU_1("/usr/libexec/gksu"); 51 | const QString ctn_GKSU_2("gksu"); 52 | 53 | const QString ctn_ANTERGOS_FILE_MANAGER("nautilus"); 54 | 55 | const QString ctn_ARCHBANG_EDITOR("medit"); 56 | const QString ctn_ARCHBANG_FILE_MANAGER("spacefm"); 57 | 58 | const QString ctn_MOOOS_EDITOR("subl3"); 59 | const QString ctn_RXVT_TERMINAL("urxvt"); 60 | 61 | const QString ctn_XFCE_DESKTOP("xfdesktop"); 62 | const QString ctn_XFCE_EDITOR("mousepad"); 63 | const QString ctn_XFCE_EDITOR_ALT("leafpad"); 64 | const QString ctn_XFCE_FILE_MANAGER("thunar"); 65 | const QString ctn_XFCE_TERMINAL("xfce4-terminal"); 66 | 67 | const QString ctn_OPENBOX_DESKTOP("openbox"); 68 | const QString ctn_LXDE_DESKTOP("lxsession"); 69 | const QString ctn_LXDE_TERMINAL("lxterminal"); 70 | const QString ctn_LXDE_FILE_MANAGER("pcmanfm"); 71 | 72 | const QString ctn_GNOME_EDITOR(QStringLiteral("gedit")); 73 | const QString ctn_GNOME_FILE_MANAGER(QStringLiteral("nautilus")); 74 | const QString ctn_GNOME_TERMINAL(QStringLiteral("gnome-terminal")); 75 | 76 | const QString ctn_XDG_OPEN(QStringLiteral("xdg-open")); 77 | 78 | const QString ctn_LXQT_DESKTOP("lxqt-session"); 79 | const QString ctn_LXQT_TERMINAL("qterminal"); 80 | const QString ctn_LXQT_FILE_MANAGER("pcmanfm-qt"); 81 | const QString ctn_LXQT_EDITOR("juffed"); 82 | const QString ctn_LXQT_EDITOR_ALT("featherpad"); 83 | 84 | const QString ctn_LUMINA_DESKTOP("lumina-desktop"); 85 | const QString ctn_LUMINA_EDITOR("lumina-textedit"); 86 | const QString ctn_LUMINA_FILE_MANAGER("lumina-fm"); 87 | const QString ctn_LUMINA_OPEN("lumina-open"); 88 | 89 | const QString ctn_MATE_DESKTOP("mate-session"); 90 | const QString ctn_MATE_EDITOR("mate-open"); 91 | const QString ctn_MATE_FILE_MANAGER("caja"); 92 | const QString ctn_MATE_TERMINAL("mate-terminal"); 93 | 94 | const QString ctn_CINNAMON_DESKTOP("gnome-session"); 95 | const QString ctn_CINNAMON_EDITOR("gedit"); 96 | const QString ctn_CINNAMON_FILE_MANAGER("nemo"); 97 | const QString ctn_CINNAMON_TERMINAL("gnome-terminal"); 98 | 99 | const QString ctn_RAZORQT_DESKTOP("razor-session"); 100 | const QString ctn_PEK_TERMINAL("sakura"); 101 | const QString ctn_XTERM("xterm"); 102 | 103 | enum EditOptions { ectn_EDIT_AS_ROOT, ectn_EDIT_AS_NORMAL_USER }; 104 | 105 | /* 106 | * This class exposes some services of the underlying Window Manager being used 107 | */ 108 | 109 | class WMHelper 110 | { 111 | public: 112 | static bool isKDERunning(); 113 | static bool isTDERunning(); 114 | static bool isXFCERunning(); 115 | static bool isOPENBOXRunning(); 116 | static bool isLXDERunning(); 117 | static bool isLXQTRunning(); 118 | static bool isMATERunning(); 119 | static bool isCinnamonRunning(); 120 | static bool isLuminaRunning(); 121 | 122 | static QString getKDEOpenHelper(); 123 | static QString getXFCEEditor(); 124 | static QString getSUCommand(); 125 | static void openFile(const QString& fileName); //fileName is Path + Name 126 | static void editFile(const QString& fileName , EditOptions opt = ectn_EDIT_AS_ROOT); //fileName is Path + Name 127 | static void openDirectory( const QString& dirName ); 128 | static void openTerminal( const QString& dirName ); 129 | }; 130 | 131 | #endif // WMHELPER_H 132 | -------------------------------------------------------------------------------- /ui/transactiondialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TransactionDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 490 10 | 362 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | QLayout::SetMinimumSize 22 | 23 | 24 | 10 25 | 26 | 27 | 10 28 | 29 | 30 | 10 31 | 32 | 33 | 10 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 10 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 0 50 | 0 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | 61 | 0 62 | 0 63 | 64 | 65 | 66 | padding-top: 6px; padding-left: 18px; 67 | 68 | 69 | Create boot environment backup 70 | 71 | 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | Qt::Vertical 80 | 81 | 82 | QSizePolicy::Maximum 83 | 84 | 85 | 86 | 20 87 | 50 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 10 99 | 100 | 101 | 102 | 103 | 104 | 105 | Qt::Vertical 106 | 107 | 108 | QSizePolicy::Fixed 109 | 110 | 111 | 112 | 20 113 | 2 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 0 123 | 0 124 | 125 | 126 | 127 | QDialogButtonBox::No|QDialogButtonBox::Yes 128 | 129 | 130 | 131 | 132 | 133 | 134 | Qt::Vertical 135 | 136 | 137 | QSizePolicy::Fixed 138 | 139 | 140 | 141 | 20 142 | 5 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 0 152 | 150 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | :/resources/images/terminal.png:/resources/images/terminal.png 162 | 163 | 164 | Run in terminal 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | --------------------------------------------------------------------------------