├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── COPYING ├── INSTALL.sh ├── MISSINGLIST.md ├── README.md ├── SLSK_img.png ├── TODO.md ├── img ├── SLSK_BG.png ├── SLSK_BG_transparent.png └── SLSK_icon.png ├── src ├── SteamLinuxGames.db ├── SteamLinuxSwissKnife.pro ├── db.cpp ├── db.h ├── main.cpp ├── mainmenu.cpp ├── mainmenu.h ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── progressmenu.cpp ├── progressmenu.h ├── sqlite3.c └── sqlite3.h └── svg ├── SLSK_BG_vector.svg └── SLSK_icon_vector.svg /.gitignore: -------------------------------------------------------------------------------- 1 | *.pro.user 2 | *.o 3 | Makefile* -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ### 2017-12-11 - Database update 4 | * 2 games added to the database: 5 | - HITMAN™ 6 | - Super Crate Box 7 | 8 | ### 2017-12-10 - Initial release [v1.0.0] 9 | * 133 games added to the database: 10 | - 1001 Spikes 11 | - 140 12 | - A Story About My Uncle 13 | - (incomplete) Absolute Drift 14 | - (incomplete) Action Henk 15 | - (incomplete) AdVenture Capitalist 16 | - Amnesia: The Dark Descent 17 | - Another World - 20th Edition Anniversary 18 | - Antichamber 19 | - Audiosurf 2 20 | - BattleBlock Theater 21 | - Beat Hazard 22 | - BioShock Infinite 23 | - Bleed 24 | - Blocks That Matter 25 | - Borderlands 2 26 | - Braid 27 | - Capsized 28 | - Cave Story+ 29 | - (incomplete) Chroma Squad 30 | - (incomplete) Circa Infinity 31 | - Closure 32 | - Counter-Strike: Global Offensive 33 | - Counter-Strike: Source 34 | - Crypt of the NecroDancer 35 | - (incomplete) Dark Echo 36 | - DeadCore 37 | - Devil Daggers 38 | - DiRT Showdown 39 | - Distance 40 | - Don't Starve 41 | - (incomplete) Don't Starve Together 42 | - Drunken Robot Pornography 43 | - (incomplete) Dungeon Souls 44 | - (incomplete) Dungeons 2 45 | - Dust: An Elysian Tail 46 | - FTL: Faster Than Light 47 | - Fistful of Frags 48 | - Floating Point 49 | - Freedom Planet 50 | - Garry's Mod 51 | - (incomplete) GoNNER 52 | - Grow Home 53 | - Gunpoint 54 | - Half-Life 55 | - Half-Life 2 56 | - Half-Life 2: Episode One 57 | - Half-Life 2: Episode Two 58 | - Half-Life 2: Lost Coast 59 | - Heavy Bullets 60 | - (incomplete) Hero Siege 61 | - Hotline Miami 62 | - Hotline Miami 2: Wrong Number 63 | - Human Resource Machine 64 | - (incomplete) INK 65 | - Indie Game: The Movie 66 | - Insanely Twisted Shadow Planet 67 | - Jazzpunk: Director's Cut 68 | - (incomplete) Jotun 69 | - Killing Floor 70 | - Knights of Pen and Paper +1 71 | - (incomplete) Krautscape 72 | - LIMBO 73 | - LUFTRAUSERS 74 | - (incomplete) LYNE 75 | - Left 4 Dead 2 76 | - Little Inferno 77 | - (incomplete) Magicite 78 | - (incomplete) Mushroom 11 79 | - NOT A HERO 80 | - No Time To Explain Remastered 81 | - Oddworld: New 'n' Tasty 82 | - (incomplete) Oh...Sir! The Insult Simulator 83 | - (incomplete) One More Dungeon 84 | - Orbital Gear 85 | - Outland 86 | - (incomplete) PACMAN-256 87 | - PAYDAY 2 88 | - Papers, Please 89 | - (incomplete) Paranautical Activity: Deluxe Atonement Edition 90 | - (incomplete) Pixel Piracy 91 | - Plague Inc: Evolved 92 | - Please, Don't Touch Anything 93 | - Pony Island 94 | - Portal 95 | - Portal 2 96 | - Race The Sun 97 | - (incomplete) Reigns 98 | - (incomplete) Retro City Rampage DX 99 | - Rex Rocket 100 | - Risk of Rain 101 | - (incomplete) Robot Roller-Derby Disco Dodgeball 102 | - Rogue Legacy 103 | - (incomplete) SCS deORBIT 104 | - (incomplete) SWARMRIDERS 105 | - Saints Row 2 106 | - Saints Row IV 107 | - Saints Row: Gat out of Hell 108 | - Saints Row: The Third 109 | - Savant - Ascent 110 | - Shadow Warrior 111 | - Shank 112 | - (incomplete) ShellShock Live 113 | - Skyborn 114 | - (incomplete) Spriter Pro 115 | - Starbound 116 | - Stealth Bastard Deluxe 117 | - SteamWorld Dig 118 | - (incomplete) Super Crate Box 119 | - Super Meat Boy 120 | - (incomplete) Super Win The Game 121 | - System Shock 2 122 | - Team Fortress 2 123 | - Teeworlds 124 | - Terraria 125 | - Tetrobot and Co. 126 | - The Binding of Isaac: Rebirth 127 | - The Cave 128 | - The Stanley Parable 129 | - They Bleed Pixels 130 | - Thomas Was Alone 131 | - (incomplete) Trip to Vinelands 132 | - (incomplete) UBERMOSH 133 | - (incomplete) UBERMOSH Vol. 3 134 | - (incomplete) UBERMOSH: BLACK 135 | - Unepic 136 | - UniBall 137 | - Unturned 138 | - VVVVVV 139 | - WAKFU 140 | - Waveform 141 | - World of Goo 142 | - (incomplete) You Have To Win The Game 143 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to SLSK 2 | 3 | First of all, thank you very much for considering contributing to SLSK, your help makes all the difference :) 4 | 5 | # Table of Contents 6 | 7 | [A few words of comfort](#a-few-words-of-comfort) 8 | 9 | [So how do I contribute?](#so-how-do-i-contribute) 10 | 11 | * [Documentation](#documentation) 12 | 13 | * [Improving code / UI](#improving-code--ui) 14 | 15 | * [Improving the database](#improving-the-database) 16 | 17 | * [Guidelines for adding entries](#guidelines-for-adding-entries) 18 | 19 | * [Changelog and Versioning](#changelog-and-versioning) 20 | 21 | [Closing words](#closing-words) 22 | 23 | # A few words of comfort 24 | 25 | *Make yourself at home.* Even though this might be considered a small hobby project, you are invited to take part of it if you so desire. 26 | 27 | *Any help is welcome.* Whether it be a shoutout for a bug you just found or a mass addition of entries in the database, I appreciate your 28 | time and effort, and again, thank you very much for your help. 29 | 30 | And of course, the usual: *be friendly and polite*, but don't feel afraid to share your opinions if you need to, and, most importantly, 31 | *don't be ashamed to ask for help*. Who knows, maybe your neighbor Github user has actually found that pesky save path you spent days 32 | searching for ;) 33 | 34 | # So how do I contribute? 35 | 36 | First of all, make sure you have installed the [dependencies required](README.md#getting-started) for this project. 37 | 38 | In short, there are some ways you can help contributing to this project, which will be explained below. Contributing is not limited to these only, 39 | but they are essentially the main ones. 40 | 41 | ## Documentation 42 | 43 | I'll be honest here: in the beginning, *I made SLSK with little to no planning. At all.* That also meant little to no documentation, aside from 44 | commenting the code. I admit I'm to blame, at least partially. Whilist coding it, I thought "meh, it's such a small project, maybe it'll stay 45 | simple like this, just add a thing here and there...". Heh, and then it became a monster. So this, along with the fact I was in the middle of 46 | learning C++ and software engineering in college, while learning Qt at home and building SLSK, *all from scratch and at the same time*, 47 | kinda left me without a solid ground and made me keep taking shots in the dark. 48 | 49 | That said. This is literally the first program I've ever built and finished, so I'm paying the toll. I'll be glad to help with (and accept help to) 50 | properly document this program if it is really needed even for a small project like this one, according to the community's needs. All I need 51 | is a little guidance because I'm a little clueless on *what* exactly to document. I'll be sure to give my best during my free time between college 52 | and other things I have to take care of. To give you a head start, it's all commented in the code. If you have any doubts, don't be afraid to ask. 53 | 54 | ## Improving code / UI 55 | 56 | Ah, now we're getting to the fun part. Both the code and the UI were made using the Qt Creator IDE. Using it is not obligatory, but highly 57 | recommended so we can keep a standard. 58 | 59 | * About the code: 60 | * Please try to keep the code *well commented*. It doesn't need to be a car manual, but let us know what your code does so documenting 61 | gets easier (especially when you manage to reduce parts of the code) 62 | * Also, try to keep the code *well formatted*. It's OK if it gets kinda big, as long as it's functional and stable enough so it doesn't crash the 63 | program, we can always reduce it later 64 | * Still regarding the point above, reduce code as you like but *don't reduce it too much* so it gets unreadable - I know we as programmers 65 | are always itching to do things like [this](https://en.wikipedia.org/wiki/Minification_(programming\)#Example), but remember that 66 | readability counts a lot, so reduce with moderation 67 | * About the UI: 68 | * If you feel the UI needs a tweak here and there, let us know first so we can discuss about it (bring your mockups / screenshots as well!) 69 | * You may tweak the UI in whichever way you want, but please try to make it clean and minimalistic. Remember, *less is more* 70 | * Also, try to make it easy for the eyes - not wanting to start a flame war between light/dark themes here, but please consider those poor 71 | folks who are trying to backup their stuff in their pitch black rooms at 1:00 AM (not me, but you get the drill) :( 72 | 73 | If you don't feel like coding or tweaking the UI, it's all fine - you can add your ideas to the [TODO](TODO.md) list, which has a section for optional 74 | suggestions. 75 | 76 | ## Improving the database 77 | 78 | An SQLite database is included with the program. This is the most important part of the whole project, without it we just have a pretty but 79 | useless shell made in Qt. You can use CLI tools to tweak the database if you feel more comfortable that way, but using a GUI editor like 80 | `sqlitebrowser` is also highly recommended. 81 | 82 | Each registered Linux Steam game in the database (from now on referred as an "entry") has the following columns: 83 | 84 | * **AppID (PRIMARY KEY)** - The game's AppID on Steam (http://store.steampowered.com/app/`AppID-goes-here`) 85 | * **SteamName** - The game's name as it appears on the Steam store 86 | * **GameFolder** - The game folder's name (exactly how it is named inside `steamapps/common`) 87 | * **SavePath1** - The full path of the folder where the game stores its save files 88 | * **SaveFolder1** - The name of the folder where the game stores its save files (last folder in the path - after the last "/") 89 | * **ConfigPath1** - The full path of the folder where the game stores its configurations 90 | * **ConfigFolder1** - The name of the folder where the game stores its configurations (last folder in the path - after the last "/") 91 | * **SavePath2** - A second (optional) path for the save folder, if the game has more than one save location 92 | * **SaveFolder2** - A second (optional) save folder 93 | * **ConfigPath2** - A second (optional) path for the config folder, if the game has more than one config location 94 | * **ConfigFolder2** - A second (optional) config folder 95 | * **SavePath3** - A third (optional) path for the save folder 96 | * **SaveFolder3** - A third (optional) save folder 97 | * **ConfigPath3** - A third (optional) path for the config folder 98 | * **ConfigFolder3** - A third (optional) config folder 99 | 100 | Adding an entry to the database requires a few guidelines which will help both the program on filtering and working in general, and 101 | whoever wants to take a quick look at the database to know where there is missing information. 102 | 103 | ### Guidelines for adding entries 104 | 105 | #### 1. **Field labels** 106 | 107 | All fields except for AppID, SteamName and GameFolder **must** make use of the following labels when applicable: 108 | 109 | * **$STEAMUSER** - shortcut to `~/.local/share/Steam/userdata/7656*` *(including the wildcard)* 110 | * **$STEAMAPPS** - shortcut to `~/.local/share/Steam/steamapps/common/` 111 | * **[N/A]** - game naturally doesn't have saves/configs 112 | * **[CLOUD-ONLY]** - saves/configs only exist in the cloud or in the game's server, out of reach 113 | * **[UNKNOWN]** - saves/configs are in an unknown location 114 | 115 | So, giving a few examples on when to use each one of these labels: 116 | 117 | * Some games like Saints Row The Third, Bioshock Infinite and PAYDAY 2 store their saves inside a folder with the user's STEAMID, 118 | which is inside the Steam folder (like `~/.local/share/Steam/userdata/7656*/`), so the SavePath/ConfigPath is written 119 | like **$STEAMUSER/``** 120 | * Half-Life 2 has its saves stored in `~/.local/share/Steam/steamapps/common/Half-Life 2/hl2/save`, so it's SavePath in the database 121 | is written like **$STEAMAPPS/hl2/save** 122 | * CS:GO has no save files at all due to its multiplayer-only nature, but has config files in `$STEAMAPPS/csgo/cfg`, so its ConfigPath 123 | stays like that, but its SavePath is labeled **[N/A]** (this also applies to the second and third SavePath/ConfigPath fields, when there's 124 | no second or third path for saves/configs) 125 | * Killing Floor has its save games hosted exclusively in the Steam Cloud and thus unreachable from our computers, so its SavePath 126 | is labeled **[CLOUD-ONLY]**, while its config files are in `~/.killingfloor` 127 | * The idea is that all games store their saves and configs somewhere, no matter where. *But*, sometimes it's really hard to find those 128 | paths, and that's where the **[UNKNOWN]** label comes in. This will be explained further below 129 | 130 | #### 2. **Path structures** 131 | 132 | Game saves and configs are usually structured in one of the following ways (not definitive, but these patterns were sure detected 133 | when searching locally for paths): 134 | 135 | * **Case 1** - saves/configs consist of *a single file* (e.g. `game/save.dat` - Crypt of the NecroDancer, Knights of Pen and Paper, etc) 136 | * **Case 2** - saves/configs consist of *multiple files with the same extension* (e.g. `game/*.cfg` - System Shock 2) 137 | * **Case 3** - saves/configs consist of *a single folder with lots of different files* (e.g. `game/save` - most common case for the majority 138 | of games) 139 | * **Case 4** - saves/configs consist of *multiple folders*, like one folder per save slot (e.g. `game/save_*` - again, System Shock 2) 140 | 141 | That said, depending on how the SavePath/ConfigPath ends, the SaveFolder/ConfigFolder field(s) will change. 142 | If the SavePath/ConfigPath ends in: 143 | 144 | * *A single file or multiple files (Cases 1 and 2)* - put the **parent folder** of the path (in both cases, `game`) 145 | * *A single folder or multiple folders (Cases 3 and 4)* - put the **last folder** of the path (`save` and `save_*`, respectively) 146 | 147 | **NOTE:** if the config files happen to be *in the same folder as the save files*, or vice-versa, copy-paste the same path and folder for both. 148 | Yes, this means duplicates may occur, but that's intentional. Also, *please* use `~` to indicate the user's home folder, people recognize it 149 | easily and it's shorter than `$HOME`, plus the GUI tool needs it to do some work. 150 | 151 | #### 3. [UNKNOWN] paths 152 | 153 | **NOTE: this is exclusively for paths labeled as [UNKNOWN], it doesn't apply to games with paths labeled as [N/A] or [CLOUD-ONLY].** 154 | 155 | If you want to add a game to the database but can't find its save/config paths, or you're not sure where the save/config files are located, 156 | don't worry - we might find those paths sooner or later, but we need to know that you can't find them. That makes it easier to keep looking 157 | for information about that game's paths (whether they actually exist or not). We keep a file called MISSINGLIST for games that meet 158 | this criteria, kind of like a "wanted list" or "bounty list" if you like catchy names. Here's how to proceed if you end up in this situation: 159 | 160 | 1. Add the game normally to the database using the **[UNKNOWN]** label in the respective missing fields 161 | 2. Include the game in the CHANGELOG normally, but mark it as "(incomplete)", like this: 162 | * (incomplete) GameName 163 | 3. Write the game's name in the MISSINGLIST, specifying which paths are unknown - only save path, only config path, or both - like this: 164 | * GameName (save and config) 165 | 4. Once the paths are found, or if it's proven that there are no paths - **[N/A]** - or that the missing information is **[CLOUD-ONLY]**: 166 | * update the database accordingly 167 | * add the game in the CHANGELOG but without the "(incomplete)" before it (more details below in Changelog and Versioning) 168 | * remove the game's name from the MISSINGLIST 169 | 170 | ## Changelog and Versioning 171 | 172 | Even though the main focus of the project is the database, there's also the GUI tool which may need improvements as time passes. 173 | When contributing, versioning applies only to the *core program* (be it code or UI). Database updates do not count for versioning, but 174 | they still appear on the Changelog. SLSK uses the standard [Semantic Versioning](https://semver.org/) - MAJOR.MINOR.PATCH, no big 175 | surprises here. In short, there may be Core updates and Database updates. The former applies to the core program, but *can* also include 176 | database updates (as seen below), while the latter applies *exclusively* to database changes. 177 | 178 | Database entries can be commited directly to master branch, but changes to core program *must* go to a separate dev branch. Fix bugs and 179 | add features as you may desire, adding tags in commit titles regarding whether you're fixing/adding things in UI, code or docs (respectively, 180 | **[ui]**, **[code]** and **[docs]**), but test the dev branch to make sure it's stable enough before submitting a pull request, as this will be 181 | considered a version increment. 182 | 183 | ### Example of changelog entry for database additions only: 184 | 185 | #### YYYY-MM-DD - Database update 186 | * X games added to the database: 187 | * this game 188 | * that other game 189 | * (incomplete) awesome game 190 | * ... 191 | 192 | ### Example of changelog entry for core program versioning: 193 | 194 | #### YYYY-MM-DD - Core update [vX.Y.Z] 195 | * Added this neat feature 196 | * Fixed those pesky bugs 197 | * X games added to the database: 198 | * not-so-awesome game 199 | * ... 200 | * X games completed in the database 201 | * awesome game 202 | * ... 203 | 204 | # Closing words 205 | 206 | This is it for now. It's a really simple project so there's not much specific detail, except for the database entries. If you have any doubts, don't be 207 | afraid and ask away so I can improve this file ;) -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /INSTALL.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ========================================================================= 4 | # ---[SLSK - Build/Install Script]--- 5 | # Copyright (C) 2017 Supremist (aka supremesonicbrazil) 6 | # This file is part of Steam Linux Swiss Knife (or SLSK for short). 7 | # Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 8 | # accompanying COPYING file for more details. 9 | # ========================================================================= 10 | 11 | # Checking if running as sudo 12 | if [ $UID = 0 ] 13 | then 14 | # Compiling from source code in a temporary folder 15 | mkdir bin 16 | qmake -o ./bin/Makefile ./src/SteamLinuxSwissKnife.pro 17 | cd bin 18 | make 19 | cd .. 20 | 21 | # Moving and copying stuff to the right places 22 | rm -r /opt/SLSK 23 | mkdir /opt/SLSK 24 | mv ./bin/SteamLinuxSwissKnife /opt/SLSK/SteamLinuxSwissKnife 25 | cp ./src/SteamLinuxGames.db /opt/SLSK/SteamLinuxGames.db 26 | cp -r ./img /opt/SLSK/img 27 | rm -r ./bin 28 | 29 | # Creating desktop entry 30 | echo '[Desktop Entry] 31 | Version=1.0 32 | Name=Steam Linux Swiss Knife 33 | Comment=Backup automation for Steam games, saves and configs 34 | Exec=/opt/SLSK/SteamLinuxSwissKnife 35 | Icon=/opt/SLSK/img/SLSK_icon.png 36 | Terminal=false 37 | Type=Application 38 | Categories=Utility;Application;' > ./Steam\ Linux\ Swiss\ Knife.desktop 39 | 40 | # Setting desktop shortcut as executable 41 | chmod +x ./Steam\ Linux\ Swiss\ Knife.desktop 42 | 43 | # Finishing 44 | clear 45 | echo "Done! Steam Linux Swiss Knife was successfully installed in '/opt/SLSK'." 46 | echo "If you want to uninstall it anytime, just do a 'sudo rm -r /opt/SLSK'." 47 | echo "Enjoy!" 48 | echo "--------------------------------------------------------------------------------" 49 | else 50 | echo "Please run this script as sudo." 51 | echo "Aborting..." 52 | echo "--------------------------------------------------------------------------------" 53 | exit 54 | fi -------------------------------------------------------------------------------- /MISSINGLIST.md: -------------------------------------------------------------------------------- 1 | # LIST OF INCOMPLETE GAMES 2 | 3 | * Absolute Drift (save and config) 4 | * Action Henk (save and config) 5 | * AdVenture Capitalist (save and config) 6 | * Chroma Squad (config) 7 | * Circa Infinity (save and config) 8 | * Dark Echo (save and config) 9 | * Don't Starve Together (config) 10 | * Dungeon Souls (save and config) 11 | * Dungeons 2 (config) 12 | * GoNNER (save) 13 | * Hero Siege (config) 14 | * INK (config) 15 | * Jotun (save and config) 16 | * Krautscape (save and config) 17 | * LYNE (save and config) 18 | * Magicite (config) 19 | * Mushroom 11 (config) 20 | * Oh...Sir! The Insult Simulator (save and config) 21 | * One More Dungeon (save) 22 | * PAC-MAN 256 (save and config) 23 | * Paranautical Activity: Deluxe Atonement Edition (config) 24 | * Pixel Piracy (config) 25 | * Reigns (save and config) 26 | * Retro City Rampage DX (save and config) 27 | * Robot Roller-Derby Disco Dodgeball (config) 28 | * SCS deORBIT (save and config) 29 | * SWARMRIDERS (save and config) 30 | * ShellShock Live (config) 31 | * Spriter Pro (config) 32 | * Super Win The Game (save and config) 33 | * Trip to Vinelands (save and config) 34 | * UBERMOSH (save and config) 35 | * UBERMOSH Vol. 3 (save and config) 36 | * UBERMOSH: BLACK (save and config) 37 | * You Have To Win The Game (save and config) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Steam Linux Swiss Knife (SLSK) 2 | 3 | Steam Linux Swiss Knife is an open-source program that aims to automate the backup and restore of Steam games, their saves and 4 | configs, centralizing paths in a local and extremely lightweight database. 5 | 6 | ![screenshot](https://github.com/supremesonicbrazil/SLSK/blob/master/SLSK_img.png) 7 | 8 | # Table of Contents 9 | 10 | [Summary](#summary) 11 | 12 | * [Main features](#main-features) 13 | 14 | [Getting started](#getting-started) 15 | 16 | * [Installation](#installation) 17 | * [How to use](#how-to-use) 18 | 19 | [FAQ](#faq) 20 | 21 | [How to contribute](#how-to-contribute) 22 | 23 | [Special thanks](#special-thanks) 24 | 25 | [Donations](#donations) 26 | 27 | [License / Copyright](#license--copyright) 28 | 29 | ## Summary 30 | 31 | There's little reliable information on the internet about save/config locations on Linux, and when it does show up, it's often "hit-or-miss". 32 | Many players are getting tired of having to manually backup their games, which can be even more frustrating when there's too many of 33 | them sitting at the library. Some of us just want to "set it and forget it". Problem is, while Windows users have GameSave Manager, there 34 | is no alternative to Linux, and GSM is certainly not going to be ported at all due to its structure. 35 | 36 | This is why Steam Linux Swiss Knife was made: to provide a way to unify information about save/config paths of Linux Steam games into 37 | one open, lightweight database which everyone is invited to add this info to it as they see fit; and to use this database for automating 38 | backups of Linux Steam games, saves and configurations. These goals will be easier to accomplish due to SLSK's open-source nature: new 39 | releases come every day, and considering it's pretty much inefficient for only one person to buy 2000+ Linux Steam games solely for path 40 | documentation purposes, SLSK provides a solid base for anyone to contribute with this documentation. Plus, although most games follow 41 | (or at least should follow) the XDG Base Directory Specifications for writing saves/configs (e.g. ~/.local/share, ~/.config, etc.), there is a 42 | good amount of games ignoring this, writing saves and configs in other specific (and sometimes unknown and/or inadequate) locations 43 | of the system. Some of them may not even have save files, or configurations may be stored exclusively via cloud. Regardless, it is up to us 44 | to find that out and contribute so others can be helped. 45 | 46 | So far, there are **135** games registered in SLSK's database, of which **35** have incomplete path information. 47 | 48 | ### Main features 49 | 50 | * **Store known paths for saves and configurations of Linux Steam games** 51 | * **Automate the backup and restore of Linux Steam games, saves and configs with an optional GUI tool** 52 | 53 | ## Getting started 54 | 55 | Before downloading or cloning SLSK, please make sure you have the following dependencies installed: 56 | 57 | * `g++` (for C++11) 58 | * `qt5-default` and `qt5-qmake` (minimum Qt 5.5+) 59 | 60 | ### Installation 61 | 62 | 1. Download the repository, or clone it with `git clone https://github.com/supremesonicbrazil/SLSK` 63 | 2. Open a terminal inside the repo's root directory (or `cd` to it) 64 | 3. `sudo chmod +x INSTALL.sh && sudo ./INSTALL.sh` 65 | 4. Drag the desktop entry to wherever you like and run it 66 | 67 | ### How to use 68 | 69 | 1. Set a backup folder by clicking the `...` button (below the Start button) 70 | 2. Scan for content by clicking any of the scan buttons, according to your preference: 71 | * Backup Saves, Configs or Games (unlocked by default) 72 | * Restore Saves, Configs or Games (locked by default until a backup folder is set and respective folders are detected in it) 73 | 3. Mark which games you want to backup or restore in the list 74 | 4. Press the Start button to initiate the backup or restore process 75 | 76 | ## FAQ 77 | 78 | * **So it's basically a GameSave Manager for Linux?** 79 | 80 | Yep, but it does a bit more. GSM only manages saves, SLSK manages saves, configs *and* games, plus it's open-source. 81 | 82 | * **Will you expand this to non-Steam games (GOG, Itch.io, repo games, etc.)?** 83 | 84 | For the time being, no. It's definitely not impossible, but this is just not the main focus now. 85 | 86 | * **Will you do a version for Windows/Mac?** 87 | 88 | No. Windows already has GSM, and I'm not familiar with Mac. I don't want to compete with GSM, I want to fill a niche it hasn't filled for years. 89 | 90 | * **Will I be VAC banned if I use this?** 91 | 92 | SLSK uses no login methods and no API whatsoever, it's all local file scanning so relax ;) 93 | 94 | * **Can I use part of your program in a project of mine (code, database entries, etc.)? Why not build this into `insert-open-source-project-here`?** 95 | 96 | This is more of a personal project that I want to share with people. Nothing stops you (or `insert-open-source-project-here`'s devs) from 97 | incorporating parts of this project into whatever you like. Seriously, not only I give you full permission to use parts of this project, I also 98 | strongly encourage you to do so. It's open-source after all. Everything from the code up to the database entries, use whatever your heart 99 | desires to use. If you need help, get in touch so I can give you a hand to the best of my abilities :) 100 | 101 | Just keep in mind two things: first, this project is under GNU GPL v3 - besides helping to avoid license incompatibilities, if you happen to 102 | improve on whichever part you used, please contribute back, it'll mean a lot to us. 103 | 104 | Second, [*please* **don't** do this](http://i0.kym-cdn.com/photos/images/original/001/079/173/ed2.png). Seriously, it's not cool and 105 | people will hate you if they find out, please keep the original credits, even if it's just a tiny mention somewhere :( 106 | 107 | * **But what about `insert-similar-project-name-here`? Y'know this guy's doing this and that, looks pretty much the same...** 108 | 109 | *I know.* Even if there's a thousand alternatives popping up every second, the objective for each one is different, even if a bit slightly. 110 | My objective with SLSK is not to create another standard, but rather try to *adapt* to those standards. 111 | 112 | Let's be honest - unless saves/configs are being written inside the own game's folder, which IMO would be the best of both worlds, every 113 | dev making Linux games (especially those who came from Windows - not criticizing, just trying to raise attention) should at the very least be 114 | following the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html), that way 115 | our lives would get easier and the whole paradigm of "Linux is too hard to use" would start to crack down like it has been since the past few 116 | years. Until then, all we can do is keep on educating the following generations of new users, while giving them a little support so they can 117 | walk on their own later, like we do with a toddler, and I believe this was one way I found to help with this re-education. Once people start 118 | coming more towards Linux, among other things they *will* miss their GameSave Manager for sure (I was missing it myself, hence this 119 | project was born), and having a native alternative that acts in a similar way (but probably improved) will weaken their resistance to change, 120 | at least gaming-wise. 121 | 122 | * **Why "Swiss Knife"?** 123 | 124 | Internal joke. That was the best way I found to describe what I wanted while in the planning phase - a project that has everything I need: 125 | information, automation and ease of use, all in a single package, like a swiss knife - so I decided to put that nickname on it. Fun fact, I 126 | actually borrowed a swiss knife from my dad so I could sketch the icons :) 127 | 128 | ## How to contribute 129 | 130 | See [CONTRIBUTING.md](CONTRIBUTING.md) for more details. 131 | 132 | ## Special thanks 133 | 134 | * [/r/linux_gaming](https://www.reddit.com/r/linux_gaming) (for being such an awesome and supportive community) 135 | 136 | ## Donations 137 | 138 | Wanna buy me a beer? Donations are welcome: 139 | 140 | * Bitcoin (BTC): 1MKwZku5DixVCuidtitSTYAJkykpHEhTLk 141 | * Bitcoin Cash (BCH): 1P71dzRC6ch7n4QvVAKaFYwTXNRZW4hzPb 142 | * Decred (DCR): DskAzj4ANSH85PDwgBhBUnYkRcHmafXGTdn 143 | * Ethereum Classic (ETC): 0x7829205e7798A351f70Ff642CB732f58015F1941 144 | * Ethereum (ETH): 0xC1a41a4e9e04052AfC351DA5751283cA725454EF 145 | * Litecoin (LTC): Li6swpBAi3fr6qYamNhWUnk4pJH2Q94YYZ 146 | 147 | Using a currency that's not listed here? Please let me know! I'll be glad to add it here if possible :) 148 | 149 | ## License / Copyright 150 | 151 | **Copyright (C) 2017 Supremist (aka supremesonicbrazil)** 152 | 153 | Reddit: [/u/TheSupremist](https://www.reddit.com/user/TheSupremist/) 154 | 155 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the accompanying [COPYING](COPYING) file for more details. 156 | -------------------------------------------------------------------------------- /SLSK_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyformat99/SLSK/8308596d2d794f96c2868895f5f224ffd891fe80/SLSK_img.png -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | ### TASKS 2 | 3 | * Move paths in database to a text file so it's easier to maintain (and also not obligatory to actually download SLSK just for taking a quick look) 4 | * Generate the database *during* installation instead of bundling it in the repo (using the text file above) 5 | * Fix INSTALL.sh according to issue #2 6 | * $STEAMAPPS path is hardcoded, it shouldn't (issue #3) 7 | 8 | ### BUGS 9 | 10 | * MainMenu::CheckTotalSize(): Total size of operation is not completely accurate (may miss by a margin of a couple MB from what was tested) 11 | 12 | ### SUGGESTIONS 13 | 14 | * Filter list - possible methods: 15 | * Using Steam's own library categories (libraryfolders.vdf) - easier, no changing in database, but not sure if it's possible 16 | * Fixed filters (by size, genre, publisher/developer, year, name, etc.) - would require changing database structure 17 | * Clean up if backup process is manually cancelled (restore might be way more complicated) 18 | * Find a way to optionally compress content (which format?) 19 | * Prep up a CLI version if demand skyrockets 20 | -------------------------------------------------------------------------------- /img/SLSK_BG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyformat99/SLSK/8308596d2d794f96c2868895f5f224ffd891fe80/img/SLSK_BG.png -------------------------------------------------------------------------------- /img/SLSK_BG_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyformat99/SLSK/8308596d2d794f96c2868895f5f224ffd891fe80/img/SLSK_BG_transparent.png -------------------------------------------------------------------------------- /img/SLSK_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyformat99/SLSK/8308596d2d794f96c2868895f5f224ffd891fe80/img/SLSK_icon.png -------------------------------------------------------------------------------- /src/SteamLinuxGames.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyformat99/SLSK/8308596d2d794f96c2868895f5f224ffd891fe80/src/SteamLinuxGames.db -------------------------------------------------------------------------------- /src/SteamLinuxSwissKnife.pro: -------------------------------------------------------------------------------- 1 | #=================================================================================== 2 | # ---[SLSK - Qt QMake Profile / Project File]--- 3 | # Copyright (C) 2017 Supremist (aka supremesonicbrazil) 4 | # This file is part of Steam Linux Swiss Knife (or SLSK for short). 5 | # Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 6 | # accompanying COPYING file for more details. 7 | #=================================================================================== 8 | 9 | #------------------------------------------------- 10 | # 11 | # Project created by QtCreator 2017-10-30T11:03:39 12 | # 13 | #------------------------------------------------- 14 | 15 | QT += core gui 16 | 17 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 18 | 19 | TARGET = SteamLinuxSwissKnife 20 | TEMPLATE = app 21 | 22 | 23 | SOURCES += main.cpp\ 24 | mainwindow.cpp \ 25 | mainmenu.cpp \ 26 | db.cpp \ 27 | sqlite3.c \ 28 | progressmenu.cpp 29 | 30 | HEADERS += mainwindow.h \ 31 | mainmenu.h \ 32 | db.h \ 33 | sqlite3.h \ 34 | progressmenu.h 35 | 36 | FORMS += mainwindow.ui 37 | 38 | CONFIG += c++11 39 | 40 | LIBS += -ldl 41 | -------------------------------------------------------------------------------- /src/db.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Database functionalities]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | //----------------------------------------------------------------------------------------------------------- 12 | // INCLUDED LIBRARIES 13 | //----------------------------------------------------------------------------------------------------------- 14 | 15 | // Standard C++/Qt libs 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | // Program-specific/external libs 29 | #include "db.h" 30 | #include "mainmenu.h" 31 | #include "progressmenu.h" 32 | #include "sqlite3.h" 33 | 34 | //----------------------------------------------------------------------------------------------------------- 35 | // VARIABLES 36 | //----------------------------------------------------------------------------------------------------------- 37 | 38 | sqlite3 *conn; // Database connection handler 39 | sqlite3_stmt *stmt; // Database statement handler 40 | QString UserFolder = QDir(QDir::homePath() + QString::fromStdString("/.local/share/Steam/userdata")).entryList( // Steam userdata folder (w/ user ID) 41 | QDir::Dirs | QDir::NoDotAndDotDot).value(0); 42 | std::string DBPath = "/opt/SLSK/SteamLinuxGames.db"; // Database raw path 43 | std::string DB::SteamPath = QDir::homePath().toStdString() + "/.local/share/Steam/steamapps/common"; // Steamapps raw path 44 | std::string DB::UserPath = QDir::homePath().toStdString() + "/.local/share/Steam/userdata/" + UserFolder.toStdString(); // Steam userdata raw path 45 | 46 | //----------------------------------------------------------------------------------------------------------- 47 | // FUNCTIONS 48 | //----------------------------------------------------------------------------------------------------------- 49 | 50 | // Checks if a game exists in the database 51 | bool DB::CheckGameOnDB(QString foldername){ 52 | // Variables 53 | bool game_exists; // Flag for whether a game exists in the DB or not 54 | std::string query = "SELECT SteamName FROM RegisteredGames WHERE GameFolder = '" + foldername.toStdString() + "'"; // String for query 55 | 56 | sqlite3_open_v2(DBPath.c_str(), &conn, SQLITE_OPEN_READONLY, NULL); // Opening database 57 | sqlite3_prepare_v2(conn, query.c_str(), -1, &stmt, 0); // Querying 58 | 59 | // Checking game - if the query returns a row, then obviously the game exists 60 | if (sqlite3_step(stmt) == SQLITE_ROW){ game_exists = true; } 61 | else { game_exists = false; } 62 | 63 | sqlite3_finalize(stmt); sqlite3_close_v2(conn); // Closing statement and database 64 | return game_exists; // Returning the flag 65 | } 66 | 67 | // Fetches a game's individual info in the database, returns "NONE" if info doesn't exist 68 | std::string DB::FetchGameInfo(std::string query){ 69 | // Variables 70 | std::string result; // String for result 71 | 72 | sqlite3_open_v2(DBPath.c_str(), &conn, SQLITE_OPEN_READONLY, NULL); // Opening database 73 | sqlite3_prepare_v2(conn, query.c_str(), -1, &stmt, 0); // Querying 74 | 75 | // Fetches the info if the row exists, if it doesn't then we put "NONE" inside the result variable 76 | if (sqlite3_step(stmt) == SQLITE_ROW){ result = reinterpret_cast(sqlite3_column_text(stmt, 0)); } 77 | else { result = "NONE"; } 78 | 79 | sqlite3_finalize(stmt); sqlite3_close_v2(conn); // Closing statement and database 80 | return result; // Returning result 81 | } 82 | 83 | // Fetches a whole column from the database (ONLY USED FOR SAVE AND CONFIG OPTIONS) 84 | QStringList DB::FetchAllInfo(char op, int n){ 85 | QStringList List; // Setting list 86 | std::string query; // Setting query 87 | 88 | // Creating query according to option 89 | if (op == 'S'){ query = "SELECT SavePath" + std::to_string(n) + " FROM RegisteredGames"; } 90 | else if (op == 'C'){ query = "SELECT ConfigPath" + std::to_string(n) + " FROM RegisteredGames"; } 91 | 92 | sqlite3_open_v2(DBPath.c_str(), &conn, SQLITE_OPEN_READONLY, NULL); // Opening database 93 | sqlite3_prepare_v2(conn, query.c_str(), -1, &stmt, 0); // Querying 94 | 95 | // Appending each entry individually in the result list 96 | while (sqlite3_step(stmt) == SQLITE_ROW){ List << reinterpret_cast(sqlite3_column_text(stmt, 0)); } 97 | 98 | sqlite3_finalize(stmt); sqlite3_close_v2(conn); // Closing statement and database 99 | return List; // Returning list 100 | } 101 | 102 | 103 | // Replaces specific labels/aliases from the database - $STEAMAPPS, $STEAMUSER and ~ (home) 104 | void DB::ReplaceLabels(std::string &string){ 105 | /* Checking if the path has ANY of the special labels - "[N/A]", "[UNKNOWN]" or "[CLOUD-ONLY]" - if yes, 106 | rename it to "SKIP" so the program ignores it */ 107 | if (string != "[N/A]" && string != "[UNKNOWN]" && string != "[CLOUD-ONLY]"){ 108 | // If "$STEAMAPPS" is found, replace that with the Steam path for that game 109 | if (string.find("$STEAMAPPS") == 0){ string.replace(0, 10, DB::SteamPath + "/" + ProgressMenu::CurrentFolder); } 110 | 111 | // If "$STEAMUSER" is found, replace that with a fixed path in Steam that represents the user's ID 112 | else if (string.find("$STEAMUSER") == 0){ string.replace(0, 10, DB::UserPath); } 113 | 114 | // If the shortcut for the home folder ("~") is found, replace that with the absolute home path 115 | else if (string.find("~") == 0){ string.replace(0, 1, QDir::homePath().toStdString()); } 116 | } else { 117 | string = "SKIP"; // Replacing path with "SKIP" 118 | } 119 | } 120 | 121 | // Overload of ReplaceLabels for QStrings - see above 122 | void DB::ReplaceLabels(QString &string){ 123 | if (string != "[N/A]" && string != "[UNKNOWN]" && string != "[CLOUD-ONLY]"){ 124 | if (string.contains("$STEAMAPPS")){ string.replace("$STEAMAPPS", QString::fromStdString(DB::SteamPath + "/" + ProgressMenu::CurrentFolder)); } 125 | else if (string.contains("$STEAMUSER")){ string.replace("$STEAMUSER", QString::fromStdString(DB::UserPath)); } 126 | else if (string.contains("~")){ string.replace("~", QDir::homePath()); } 127 | } else { 128 | string = "SKIP"; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/db.h: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Database functionalities (header file)]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | #ifndef DB_H 12 | #define DB_H 13 | 14 | #include 15 | #include 16 | #include 17 | #include "sqlite3.h" 18 | 19 | class DB { 20 | public: 21 | DB(); 22 | static std::string SteamPath; 23 | static std::string UserPath; 24 | static bool CheckGameOnDB(QString foldername); 25 | static std::string FetchGameInfo(std::string query); 26 | static QStringList FetchAllInfo(char op, int n); 27 | static void ReplaceLabels(std::string &string); 28 | static void ReplaceLabels(QString &string); 29 | }; 30 | 31 | #endif // DB_H 32 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - main.cpp]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | //----------------------------------------------------------------------------------------------------------- 12 | // INCLUDED LIBRARIES 13 | //----------------------------------------------------------------------------------------------------------- 14 | 15 | // Standard C++/Qt libs 16 | #include 17 | #include 18 | #include 19 | 20 | // Program-specific libs 21 | #include "mainmenu.h" 22 | #include "progressmenu.h" 23 | #include "mainwindow.h" 24 | #include "ui_mainwindow.h" 25 | 26 | //----------------------------------------------------------------------------------------------------------- 27 | // STARTUP 28 | //----------------------------------------------------------------------------------------------------------- 29 | 30 | QApplication *App; // Pointer for application 31 | MainWindow *Window; // Pointer for main window 32 | 33 | // The main man 34 | int main(int argc, char *argv[]){ 35 | QApplication a(argc, argv); App = &a; // Creating a new application 36 | MainWindow w; Window = &w; // Creating the main window 37 | 38 | // Program only opens if the database is present 39 | if (QDir("/opt/SLSK").exists("SteamLinuxGames.db")){ 40 | Window->show(); // Show the UI 41 | MainMenu::LockUnlock(); // Lock some buttons 42 | return App->exec(); // Execute the program 43 | 44 | // If database is not found, show an error dialog and return error code 1 45 | } else { 46 | QMessageBox err; 47 | err.critical(0, "Error", "Database is missing"); 48 | err.setFixedSize(500,200); 49 | return 1; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/mainmenu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Main Menu functionalities]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | //----------------------------------------------------------------------------------------------------------- 12 | // INCLUDED LIBRARIES 13 | //----------------------------------------------------------------------------------------------------------- 14 | 15 | // Standard C++/Qt libs 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | // Program-specific/external libs 29 | #include "mainmenu.h" 30 | #include "progressmenu.h" 31 | #include "mainwindow.h" 32 | #include "ui_mainwindow.h" 33 | #include "db.h" 34 | 35 | //----------------------------------------------------------------------------------------------------------- 36 | // VARIABLES 37 | //----------------------------------------------------------------------------------------------------------- 38 | 39 | // Chars for process mode (B = backup | R = restore) and option (S = saves | C = configs | G = games) 40 | char MainMenu::ProcessMode = 0, MainMenu::ProcessOp = 0; 41 | 42 | // Strings for folder paths 43 | QString FolderName, GameName, CurrentScanSave, CurrentScanConfig, CurrentScanGame, CurrentScanManifest; 44 | std::string MainMenu::BackupFolder = ""; 45 | 46 | double TotalSize; // Double for total size of operation 47 | 48 | //----------------------------------------------------------------------------------------------------------- 49 | // FUNCTIONS 50 | //----------------------------------------------------------------------------------------------------------- 51 | 52 | /* Enables/Disables buttons on the screen, as in: 53 | 1) Start Button - User has set a backup folder AND has checked at least ONE item in the list 54 | 2) Mark/Unmark All - Game list has at least ONE valid item 55 | 3) Restore Scan Buttons - User has set a backup folder AND, for each scanning button, its respective subfolder exists */ 56 | void MainMenu::LockUnlock(){ 57 | // Block for 1) 58 | if (Window->ui->BackupEntry->text() == "" || !MainMenu::OneItemChecked()){ Window->ui->StartBtn->setDisabled(true); } 59 | else { Window->ui->StartBtn->setDisabled(false); } 60 | 61 | // Block for 2) 62 | if (Window->ui->GameList->count() == 0 || Window->ui->GameList->item(0)->text() == "No content found."){ 63 | Window->ui->MarkAllBtn->setDisabled(true); Window->ui->UnmarkAllBtn->setDisabled(true); 64 | } else { 65 | Window->ui->MarkAllBtn->setDisabled(false); Window->ui->UnmarkAllBtn->setDisabled(false); 66 | } 67 | 68 | // Block for 3) 69 | if (Window->ui->BackupEntry->text() == ""){ 70 | Window->ui->RestoreScanSaveBtn->setDisabled(true); 71 | Window->ui->RestoreScanConfigBtn->setDisabled(true); 72 | Window->ui->RestoreScanGameBtn->setDisabled(true); 73 | } else { 74 | if (QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamSaves")).exists()){ // Scan for Saves 75 | Window->ui->RestoreScanSaveBtn->setDisabled(false); 76 | } else { 77 | Window->ui->RestoreScanSaveBtn->setDisabled(true); 78 | } 79 | 80 | if (QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamConfigs")).exists()){ // Scan for Configs 81 | Window->ui->RestoreScanConfigBtn->setDisabled(false); 82 | } else { 83 | Window->ui->RestoreScanConfigBtn->setDisabled(true); 84 | } 85 | 86 | if (QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamGames")).exists() && // Scan for Games 87 | QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamManifests")).exists()){ 88 | Window->ui->RestoreScanGameBtn->setDisabled(false); 89 | } else { 90 | Window->ui->RestoreScanGameBtn->setDisabled(true); 91 | } 92 | } 93 | } 94 | 95 | // Switches current process mode and option 96 | void MainMenu::SwitchMode(char mode, char op){ 97 | // Set text on screen accordingly 98 | if (mode == 'B'){ 99 | Window->ui->CurrentMode->setText("Backup"); 100 | switch (op){ 101 | case 'S': Window->ui->CurrentOp->setText("Saves"); break; 102 | case 'C': Window->ui->CurrentOp->setText("Configs"); break; 103 | case 'G': Window->ui->CurrentOp->setText("Games"); break; 104 | } 105 | } else if (mode == 'R'){ 106 | Window->ui->CurrentMode->setText("Restore"); 107 | switch (op){ 108 | case 'S': Window->ui->CurrentOp->setText("Saves"); break; 109 | case 'C': Window->ui->CurrentOp->setText("Configs"); break; 110 | case 'G': Window->ui->CurrentOp->setText("Games"); break; 111 | } 112 | } 113 | MainMenu::ProcessMode = mode; MainMenu::ProcessOp = op; // Set new process mode and option 114 | } 115 | 116 | // Read the last backup date of chosen option 117 | void MainMenu::ReadBackupDate(char op){ 118 | // Setting file name according to option 119 | QString filename; 120 | switch (op){ 121 | case 'S': filename = Window->ui->BackupEntry->text() + "/LastSaveBackup.txt"; break; 122 | case 'C': filename = Window->ui->BackupEntry->text() + "/LastConfigBackup.txt"; break; 123 | case 'G': filename = Window->ui->BackupEntry->text() + "/LastGameBackup.txt"; break; 124 | } 125 | 126 | // Opening the file and reading content 127 | QFile file(filename); QString date, time; 128 | file.open(QIODevice::ReadOnly); 129 | QTextStream stream(&file); 130 | date = stream.readLine(); time = stream.readLine(); 131 | file.close(); 132 | 133 | Window->ui->LastBackupLabel->setText("Backup date:\n" + date + "\n" + time); // Display the content in the UI 134 | } 135 | 136 | 137 | // Functions that scan folders for content 138 | // For Backup Mode - scans Steam folder 139 | void MainMenu::BackupScan(){ 140 | Window->ui->GameList->clear(); // Clearing the list beforehand 141 | Window->ui->ScanningLabel->setVisible(true); // Showing the scan message 142 | App->processEvents(); // Updating GUI 143 | 144 | // Starting scan process based on option: 145 | // Saves 146 | if (MainMenu::ProcessOp == 'S'){ 147 | for (int ct = 1; ct <= 3; ct++){ 148 | QStringList SaveList = DB::FetchAllInfo('S', ct); // Fill a list with save paths 149 | bool GameAdded = false; // Bool for knowing if a game has been added to the list 150 | 151 | // Iterate through each save path 152 | foreach (QString SavePath, SaveList){ 153 | // If save path is valid: 154 | if (SavePath != "[N/A]" && SavePath != "[UNKNOWN]" && SavePath != "[CLOUD-ONLY]"){ 155 | // Fetch its respective game folder 156 | ProgressMenu::CurrentFolder = DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames WHERE SavePath" + std::to_string(ct) + " = '" + SavePath.toStdString() + "'"); 157 | DB::ReplaceLabels(SavePath); // Replace path labels 158 | 159 | // If path happens to end in a file or has a wildcard, convert path to its parent directory 160 | if (QFileInfo(SavePath).isFile() || SavePath.contains('*')){ SavePath = QFileInfo(SavePath).dir().path(); } 161 | 162 | // If the folder exists in the system: 163 | if (QDir(SavePath).exists()){ 164 | // Check if said game has been added to the list previously 165 | for (int ct2 = 0; ct2 < Window->ui->GameList->count(); ct2++){ 166 | if (Window->ui->GameList->item(ct2)->text() == QString::fromStdString(ProgressMenu::CurrentFolder)){ GameAdded = true; } 167 | } 168 | 169 | if (GameAdded == false){ Window->ui->GameList->addItem(QString::fromStdString(ProgressMenu::CurrentFolder)); } // If it hasn't, add it to the list 170 | } 171 | } 172 | } 173 | } 174 | 175 | // Configs 176 | } else if (MainMenu::ProcessOp == 'C'){ 177 | for (int ct = 1; ct <= 3; ct++){ 178 | QStringList ConfigList = DB::FetchAllInfo('C', ct); // Fill a list with config paths 179 | bool GameAdded = false; // Bool for knowing if a game has been added to the list 180 | 181 | // Iterate through each config path 182 | foreach (QString ConfigPath, ConfigList){ 183 | // If config path is valid: 184 | if (ConfigPath != "[N/A]" && ConfigPath != "[UNKNOWN]" && ConfigPath != "[CLOUD-ONLY]"){ 185 | // Fetch its respective game folder 186 | ProgressMenu::CurrentFolder = DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames WHERE ConfigPath" + std::to_string(ct) + " = '" + ConfigPath.toStdString() + "'"); 187 | DB::ReplaceLabels(ConfigPath); // Replace path labels 188 | 189 | // If path happens to end in a file or has a wildcard, convert path to its parent directory 190 | if (QFileInfo(ConfigPath).isFile() || ConfigPath.contains('*')){ ConfigPath = QFileInfo(ConfigPath).dir().path(); } 191 | 192 | // If the folder exists in the system: 193 | if (QDir(ConfigPath).exists()){ 194 | // Check if said game has been added to the list previously 195 | for (int ct2 = 0; ct2 < Window->ui->GameList->count(); ct2++){ 196 | if (Window->ui->GameList->item(ct2)->text() == QString::fromStdString(ProgressMenu::CurrentFolder)){ GameAdded = true; } 197 | } 198 | 199 | if (GameAdded == false){ Window->ui->GameList->addItem(QString::fromStdString(ProgressMenu::CurrentFolder)); } // If it hasn't, add it to the list 200 | } 201 | } 202 | } 203 | } 204 | 205 | // Games 206 | } else if (MainMenu::ProcessOp == 'G'){ 207 | // Setting game iterator and manifest path 208 | QDirIterator GameIterator(QString::fromStdString(DB::SteamPath), QDir::Dirs | QDir::NoDotAndDotDot); 209 | std::string ManifestPath = DB::SteamPath; 210 | ManifestPath.erase(ManifestPath.end() - 7, ManifestPath.end()); // Removing "/common" 211 | 212 | // Iterating through each game folder in steamapps: 213 | while (GameIterator.hasNext()){ 214 | GameIterator.next(); // Go to next one 215 | 216 | // (Re)set manifest iterator and iterate through each appmanifest: 217 | QDirIterator ManifestIterator(QString::fromStdString(ManifestPath), QDir::Files); 218 | while (ManifestIterator.hasNext()){ 219 | ManifestIterator.next(); // Go to next one 220 | 221 | // If the manifest's AppID matches the game's AppID, add the game to the list 222 | if (ManifestIterator.fileName().contains(QString::fromStdString(DB::FetchGameInfo("SELECT AppID FROM " 223 | "RegisteredGames WHERE GameFolder = '" + GameIterator.fileName().toStdString() + "'")))){ 224 | Window->ui->GameList->addItem(GameIterator.fileName()); 225 | } 226 | } 227 | } 228 | } 229 | 230 | ProgressMenu::CurrentFolder = ""; // Cleaning folder variable 231 | Window->ui->LastBackupLabel->setText(""); // Finally, erase content from last backup label... 232 | Window->ui->ScanningLabel->setVisible(false); // ...hide the scan message... 233 | Window->ui->TotalSizeLabel->setText(""); // ...and the total size message 234 | } 235 | 236 | // For Restore Mode - scans backup subfolders 237 | void MainMenu::RestoreScan(){ 238 | Window->ui->GameList->clear(); // Clearing the list beforehand 239 | Window->ui->ScanningLabel->setVisible(true); // Showing the scan message 240 | App->processEvents(); // Updating GUI 241 | bool done = false; // Setting boolean for scanning 242 | 243 | // Starting scan process based on option: 244 | // Saves 245 | if (MainMenu::ProcessOp == 'S' && QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamSaves")).exists()){ 246 | // Setting save iterator 247 | QDirIterator SaveIterator(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamSaves"), QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot); 248 | 249 | // Fetching content 250 | while (!done){ 251 | if (SaveIterator.hasNext()){ 252 | SaveIterator.next(); // Iterate to the next save folder 253 | 254 | for (int ct = 1; ct <= 3; ct++){ 255 | // Search for the respective game folder 256 | CurrentScanSave = QString::fromStdString(DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames " 257 | "WHERE SaveFolder" + std::to_string(ct) + " = '" + SaveIterator.fileName().toStdString() + "'")); 258 | 259 | // Quick fix for multiple save directories 260 | if (CurrentScanSave == "NONE"){ 261 | CurrentScanSave = QString::fromStdString(DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames " 262 | "WHERE SaveFolder" + std::to_string(ct) + " = '" + DB::FetchGameInfo("SELECT SaveFolder" + std::to_string(ct) + 263 | " FROM RegisteredGames WHERE SavePath" + std::to_string(ct) + " LIKE '%" + SaveIterator.fileName().toStdString() + "%'") + "'")); 264 | } 265 | 266 | // If game folder is found and game exists on database, add game to the list and exit inner loop 267 | if (CurrentScanSave != "NONE" && DB::CheckGameOnDB(CurrentScanSave) == true){ 268 | Window->ui->GameList->addItem(CurrentScanSave); ct = 4; 269 | } 270 | } 271 | } else { done = true; } // Exit outer loop if there are no more folders left 272 | } 273 | 274 | // Configs 275 | } else if (MainMenu::ProcessOp == 'C' && QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamConfigs")).exists()){ 276 | // Setting config iterator 277 | QDirIterator ConfigIterator(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamConfigs"), QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot); 278 | 279 | // Fetching content 280 | while (!done){ 281 | if (ConfigIterator.hasNext()){ 282 | ConfigIterator.next(); // Iterate to the next config folder 283 | 284 | for (int ct = 1; ct <= 3; ct++){ 285 | // Search for the respective folder 286 | CurrentScanConfig = QString::fromStdString(DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames " 287 | "WHERE ConfigFolder" + std::to_string(ct) + " = '" + ConfigIterator.fileName().toStdString() + "'")); 288 | 289 | // If game folder is found and game exists on database, add game to the list and exit inner loop 290 | if (CurrentScanConfig != "NONE" && DB::CheckGameOnDB(CurrentScanConfig) == true){ 291 | Window->ui->GameList->addItem(CurrentScanConfig); ct = 4; 292 | } 293 | } 294 | } else { done = true; } // Exit outer loop if there are no more folders left 295 | } 296 | 297 | // Games 298 | } else if (ProcessOp == 'G' && QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamGames")).exists() && 299 | QDir(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamManifests")).exists()){ 300 | // Setting game iterator 301 | QDirIterator GameIterator(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamGames"), QDir::Dirs | QDir::NoDotAndDotDot); 302 | 303 | // Fetching content 304 | while (!done){ 305 | if (GameIterator.hasNext()){ 306 | GameIterator.next(); // Iterate to the next game folder 307 | bool foundmanifest = false; // Setting flag for when the correct manifest is found 308 | 309 | // (Re)setting manifest iterator every loop 310 | QDirIterator ManifestIterator(Window->ui->BackupEntry->text() + QString::fromStdString("/SteamManifests"), QDir::Files | QDir::NoDotAndDotDot); 311 | 312 | // Fetching respective manifest 313 | while (ManifestIterator.hasNext() && !foundmanifest){ 314 | // Iterate to the next manifest file 315 | ManifestIterator.next(); 316 | 317 | // Search for repective folder 318 | CurrentScanManifest = QString::fromStdString(DB::FetchGameInfo("SELECT AppID FROM RegisteredGames " 319 | "WHERE GameFolder = '" + GameIterator.fileName().toStdString() + "'")); 320 | 321 | /* If game folder is found, exists in database and its respective manifest is found, 322 | add game to list and exit inner loop */ 323 | if (CurrentScanManifest != "NONE" && DB::CheckGameOnDB(GameIterator.fileName()) == true && 324 | ManifestIterator.fileName().contains(CurrentScanManifest)){ 325 | Window->ui->GameList->addItem(GameIterator.fileName()); 326 | foundmanifest = true; 327 | } 328 | 329 | } 330 | } else { done = true; } // Exit outer loop if there are no more folders left 331 | } 332 | } 333 | MainMenu::ReadBackupDate(MainMenu::ProcessOp); // Finally, scan for the backup date and time... 334 | Window->ui->ScanningLabel->setVisible(false); // ...hide the scan message... 335 | Window->ui->TotalSizeLabel->setText(""); // ...and the total size message 336 | } 337 | 338 | // Function that organizes game list 339 | void MainMenu::OrganizeGameList(){ 340 | // If there's no items in the list, display a message 341 | if (Window->ui->GameList->count() == 0){ Window->ui->GameList->addItem("No content found."); } 342 | else { 343 | /* For each game in the list: 344 | 1) - Switch folder name with proper game name 345 | 2) - Spawn a checkbox 346 | 3) - Set the checkbox as unchecked */ 347 | for (int ct = 0; ct < Window->ui->GameList->count(); ct++){ 348 | FolderName = Window->ui->GameList->item(ct)->text(); 349 | GameName = QString::fromStdString(DB::FetchGameInfo("SELECT SteamName FROM RegisteredGames WHERE " 350 | "GameFolder = '" + FolderName.toStdString() + "'")); 351 | Window->ui->GameList->item(ct)->setText(GameName); // 1) 352 | Window->ui->GameList->item(ct)->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); // 2) 353 | Window->ui->GameList->item(ct)->setCheckState(Qt::Unchecked); // 3) 354 | } 355 | Window->ui->GameList->sortItems(Qt::AscendingOrder); // Finally, order the game list in alphabetical order 356 | } 357 | } 358 | 359 | // Checks/Unchecks all games in the list 360 | void MainMenu::CheckUncheck(bool check){ 361 | // Iterate through each item in the list... 362 | for (int ct = 0; ct < Window->ui->GameList->count(); ct++){ 363 | if (check == true){ Window->ui->GameList->item(ct)->setCheckState(Qt::Checked); } // ...if unchecked, check... 364 | else { Window->ui->GameList->item(ct)->setCheckState(Qt::Unchecked); } // ...if checked, uncheck 365 | } 366 | } 367 | 368 | // Checks if at least one item in the list was checked before starting backup/restore 369 | bool MainMenu::OneItemChecked(){ 370 | bool CheckConfirmed = false; // Setting flag for when one checked item is found 371 | 372 | // Iterate through each item in the list - if one item is checked... 373 | for (int ct = 0; ct < Window->ui->GameList->count(); ct++) 374 | if (Window->ui->GameList->item(ct)->checkState() == Qt::Checked){ CheckConfirmed = true; } // ...change flag to "true" 375 | 376 | return CheckConfirmed; // Returning the flag 377 | } 378 | 379 | // Removes items that are not checked from the list (for backup/restore process) 380 | void MainMenu::RemoveUnchecked(){ 381 | for (int ct = 0; ct < Window->ui->GameList->count(); ct++){ // Iterate through each item in the list and if it is unchecked... 382 | if (Window->ui->GameList->item(ct)->checkState() == Qt::Unchecked){ Window->ui->GameList->takeItem(ct); ct--; } // ...remove it from list and update counter 383 | } 384 | } 385 | 386 | // Calculates total size of checked items 387 | void MainMenu::CheckTotalSize(){ 388 | TotalSize = 0; QDir CurrentDir; QString CurrentPath; // Reset total size value and create temps for path handling 389 | for (int ct = 0; ct < Window->ui->GameList->count(); ct++){ // For each game in the list: 390 | if (Window->ui->GameList->item(ct)->checkState() == Qt::Checked){ // If item is checked: 391 | if (ProcessMode == 'B'){ // Filter by mode and option 392 | switch (ProcessOp){ 393 | case 'S': 394 | for (int ct2 = 1; ct2 <= 3; ct2++){ 395 | // Find the respective path, replacing its labels 396 | CurrentPath = QString::fromStdString(DB::FetchGameInfo("SELECT SavePath" + std::to_string(ct2) + " FROM RegisteredGames" 397 | " WHERE SteamName = '" + Window->ui->GameList->item(ct)->text().toStdString() + "'")); 398 | DB::ReplaceLabels(CurrentPath); // Replace path labels 399 | CurrentDir.setPath(CurrentPath); CurrentDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); // Set the temp dir 400 | if (CurrentDir.exists()){ // If dir exists: 401 | QDirIterator PathIterator(CurrentDir, QDirIterator::Subdirectories); // Iterate through it... 402 | while (PathIterator.hasNext()){ 403 | PathIterator.next(); TotalSize += (double)(QFileInfo(PathIterator.filePath()).size()) / (double)1024; // ...and add each file's size to the total (in KB) 404 | } 405 | } 406 | } 407 | break; 408 | case 'C': 409 | for (int ct2 = 1; ct2 <= 3; ct2++){ 410 | CurrentPath = QString::fromStdString(DB::FetchGameInfo("SELECT ConfigPath" + std::to_string(ct2) + " FROM RegisteredGames" 411 | " WHERE SteamName = '" + Window->ui->GameList->item(ct)->text().toStdString() + "'")); 412 | DB::ReplaceLabels(CurrentPath); 413 | CurrentDir.setPath(CurrentPath); CurrentDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 414 | if (CurrentDir.exists()){ 415 | QDirIterator PathIterator(CurrentDir, QDirIterator::Subdirectories); 416 | while (PathIterator.hasNext()){ 417 | PathIterator.next(); TotalSize += (double)(QFileInfo(PathIterator.filePath()).size()) / (double)1024; 418 | } 419 | } 420 | } 421 | break; 422 | case 'G': 423 | CurrentPath = QString::fromStdString(DB::SteamPath + "/" + DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames" 424 | " WHERE SteamName = '" + Window->ui->GameList->item(ct)->text().toStdString() + "'")); 425 | DB::ReplaceLabels(CurrentPath); 426 | CurrentDir.setPath(CurrentPath); CurrentDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 427 | if (CurrentDir.exists()){ 428 | QDirIterator PathIterator(CurrentDir, QDirIterator::Subdirectories); 429 | while (PathIterator.hasNext()){ 430 | PathIterator.next(); TotalSize += (double)(QFileInfo(PathIterator.filePath()).size()) / (double)1024; 431 | } 432 | } 433 | break; 434 | } 435 | } else if (ProcessMode == 'R'){ 436 | switch (ProcessOp){ 437 | case 'S': 438 | for (int ct2 = 1; ct2 <= 3; ct2++){ 439 | CurrentPath = Window->ui->BackupEntry->text() + QString::fromStdString("/SteamSaves/") + 440 | QString::fromStdString(DB::FetchGameInfo("SELECT SaveFolder" + std::to_string(ct2) + " FROM RegisteredGames" 441 | " WHERE SteamName = '" + Window->ui->GameList->item(ct)->text().toStdString() + "'")); 442 | DB::ReplaceLabels(CurrentPath); 443 | CurrentDir.setPath(CurrentPath); CurrentDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 444 | if (CurrentDir.exists()){ 445 | QDirIterator PathIterator(CurrentDir, QDirIterator::Subdirectories); 446 | while (PathIterator.hasNext()){ 447 | PathIterator.next(); TotalSize += (double)(QFileInfo(PathIterator.filePath()).size()) / (double)1024; 448 | } 449 | } 450 | } 451 | break; 452 | case 'C': 453 | for (int ct2 = 1; ct2 <= 3; ct2++){ 454 | // Find the respective path, replacing its labels 455 | CurrentPath = Window->ui->BackupEntry->text() + QString::fromStdString("/SteamConfigs/") + 456 | QString::fromStdString(DB::FetchGameInfo("SELECT ConfigFolder" + std::to_string(ct2) + " FROM RegisteredGames" 457 | " WHERE SteamName = '" + Window->ui->GameList->item(ct)->text().toStdString() + "'")); 458 | DB::ReplaceLabels(CurrentPath); 459 | CurrentDir.setPath(CurrentPath); CurrentDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 460 | if (CurrentDir.exists()){ 461 | QDirIterator PathIterator(CurrentDir, QDirIterator::Subdirectories); 462 | while (PathIterator.hasNext()){ 463 | PathIterator.next(); TotalSize += (double)(QFileInfo(PathIterator.filePath()).size()) / (double)1024; 464 | } 465 | } 466 | } 467 | break; 468 | case 'G': 469 | CurrentPath = Window->ui->BackupEntry->text() + QString::fromStdString("/SteamGames/") + 470 | QString::fromStdString(DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames WHERE SteamName = '" + 471 | Window->ui->GameList->item(ct)->text().toStdString() + "'")); 472 | DB::ReplaceLabels(CurrentPath); 473 | CurrentDir.setPath(CurrentPath); CurrentDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 474 | if (CurrentDir.exists()){ 475 | QDirIterator PathIterator(CurrentDir, QDirIterator::Subdirectories); 476 | while (PathIterator.hasNext()){ 477 | PathIterator.next(); TotalSize += (double)(QFileInfo(PathIterator.filePath()).size()) / (double)1024; 478 | } 479 | } 480 | break; 481 | } 482 | } 483 | } 484 | } 485 | 486 | // Display total value as KB by default 487 | Window->ui->TotalSizeLabel->setText("Total size:\n" + QString::number(TotalSize, 'f', 2) + " KB"); 488 | // If it exceeds 1024KB, convert to MB 489 | if (TotalSize > 1024){ 490 | TotalSize = TotalSize / (double)1024; 491 | Window->ui->TotalSizeLabel->setText("Total size:\n" + QString::number(TotalSize, 'f', 2) + " MB"); 492 | } 493 | // If it exceeds 1024MB, convert to GB (stops here) 494 | if (TotalSize > 1024){ 495 | TotalSize = TotalSize / (double)1024; 496 | Window->ui->TotalSizeLabel->setText("Total size:\n" + QString::number(TotalSize, 'f', 2) + " GB"); 497 | } 498 | } 499 | 500 | // Checks if there's enough space on target path before starting the process 501 | bool MainMenu::CheckDiskSpace(){ 502 | double TotalBytes = 0.00; bool HasSpace = false; 503 | 504 | // Converting total size to bytes for comparison 505 | if (Window->ui->TotalSizeLabel->text().contains("GB")){ TotalBytes = TotalSize * (1024 * 1024 * 1024); } 506 | else if (Window->ui->TotalSizeLabel->text().contains("MB")){ TotalBytes = TotalSize * (1024 * 1024); } 507 | else if (Window->ui->TotalSizeLabel->text().contains("KB")){ TotalBytes = TotalSize * 1024; } 508 | 509 | // Checking if free space in target path is bigger than the total of bytes needed for process 510 | if (ProcessMode == 'B'){ 511 | if (QStorageInfo(Window->ui->BackupEntry->text()).bytesFree() > TotalBytes){ HasSpace = true; } else { HasSpace = false; } 512 | } else if (ProcessMode == 'R'){ 513 | if (QStorageInfo::root().bytesFree() > TotalBytes){ HasSpace = true; } else { HasSpace = false; } 514 | } 515 | return HasSpace; 516 | } 517 | -------------------------------------------------------------------------------- /src/mainmenu.h: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Main Menu functionalities header file]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | #ifndef MAINMENU_H 12 | #define MAINMENU_H 13 | 14 | #include 15 | #include "mainwindow.h" 16 | 17 | extern QApplication *App; 18 | extern MainWindow *Window; 19 | 20 | class MainMenu { 21 | public: 22 | static char ProcessMode, ProcessOp; 23 | static std::string BackupFolder; 24 | 25 | static void LockUnlock(); 26 | static void SwitchMode(char mode, char op); 27 | static void BackupScan(); 28 | static void RestoreScan(); 29 | static void OrganizeGameList(); 30 | static void CheckUncheck(bool check); 31 | static bool OneItemChecked(); 32 | static void RemoveUnchecked(); 33 | static void CheckTotalSize(); 34 | static bool CheckDiskSpace(); 35 | 36 | private: 37 | static void ReadBackupDate(char op); 38 | }; 39 | 40 | #endif // MAINMENU_H 41 | -------------------------------------------------------------------------------- /src/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Main Window/UI]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | //----------------------------------------------------------------------------------------------------------- 12 | // INCLUDED LIBRARIES 13 | //----------------------------------------------------------------------------------------------------------- 14 | 15 | // Standard C++/Qt libs 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // Program-specific libs 23 | #include "mainmenu.h" 24 | #include "progressmenu.h" 25 | #include "mainwindow.h" 26 | #include "ui_mainwindow.h" 27 | 28 | //----------------------------------------------------------------------------------------------------------- 29 | // CONSTRUCTOR / DECONSTRUCTOR / OBJECTS / REIMPLEMENTATIONS 30 | //----------------------------------------------------------------------------------------------------------- 31 | 32 | // Pointer for non-GUI thread 33 | ProgressThread *MainWindow::CopyThread = new ProgressThread(); 34 | 35 | // Reimplementation of QMainWindow::closeEvent, so it stops the backup/restore process if it's running 36 | void MainWindow::closeEvent(QCloseEvent *){ ProgressMenu::StopProcess = true; } 37 | 38 | // Constructor 39 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ 40 | ui->setupUi(this); // Create the UI 41 | 42 | // Set the main menu as visible 43 | ui->MainWidget->setVisible(true); ui->ProgressWidget->setVisible(false); ui->ResultsWidget->setVisible(false); 44 | ui->ScanningLabel->setVisible(false); ui->TotalSizeLabel->setText(""); 45 | 46 | // Set signal/slot connections for thread 47 | QObject::connect(CopyThread, SIGNAL(StartProgressBars(int)), SLOT(StartProgressBars(int))); // Connection for setting progress bars 48 | QObject::connect(CopyThread, SIGNAL(UpdateCopyingLabel(QString)), SLOT(UpdateCopyingLabel(QString))); // Connection for updating copying label 49 | QObject::connect(CopyThread, SIGNAL(UpdateCurrentProgress(int)), SLOT(UpdateCurrentProgress(int))); // Connection for updating current progress 50 | QObject::connect(CopyThread, SIGNAL(UpdateHeaderLabel(char)), SLOT(UpdateHeaderLabel(char))); // Connection for updating header label 51 | QObject::connect(CopyThread, SIGNAL(UpdateGameLabel(QString)), SLOT(UpdateGameLabel(QString))); // Connection for updating current game label 52 | QObject::connect(CopyThread, SIGNAL(UpdateTotalProgress(int)), SLOT(UpdateTotalProgress(int))); // Connection for updating total progress 53 | QObject::connect(CopyThread, SIGNAL(UpdateResultsScreen(char, char, QString)), SLOT(UpdateResultsScreen(char, char, QString))); // Connection for bringing results screen 54 | 55 | // Set signal/slot connections for GUI 56 | QObject::connect(ui->GameList, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(UpdateTotalSize())); // Connection for calculating total size 57 | } 58 | 59 | // Deconstructor 60 | MainWindow::~MainWindow(){ delete ui; ProgressMenu::StopProcess = true; } 61 | 62 | //----------------------------------------------------------------------------------------------------------- 63 | // GUI SLOTS 64 | //----------------------------------------------------------------------------------------------------------- 65 | 66 | // Initializes the progress bars 67 | void MainWindow::StartProgressBars(int TotalGames){ 68 | Window->ui->CurrentProgress->setRange(0, 100); Window->ui->CurrentProgress->setValue(0); // Set current progress to 0 69 | Window->ui->TotalProgress->setRange(0, TotalGames); Window->ui->TotalProgress->setValue(0); // Set total progress to 0 70 | } 71 | 72 | // Updates the current file label 73 | void MainWindow::UpdateCopyingLabel(QString text){ Window->ui->CurrentFileLabel->setText(text); } 74 | 75 | // Updates the current progress bar 76 | void MainWindow::UpdateCurrentProgress(int value){ Window->ui->CurrentProgress->setValue(value); } 77 | 78 | // Sets the header label on progress menu 79 | void MainWindow::UpdateHeaderLabel(char mode){ 80 | if (mode == 'B'){ Window->ui->ProgressHeaderLabel->setText("Backup in progress... sit back and enjoy the ride."); } 81 | else if (mode == 'R'){ Window->ui->ProgressHeaderLabel->setText("Restore in progress... sit back and enjoy the ride."); } 82 | } 83 | 84 | // Updates the current game label 85 | void MainWindow::UpdateGameLabel(QString text){ Window->ui->CurrentGameLabel->setText(text); } 86 | 87 | // Updates the total progress bar 88 | void MainWindow::UpdateTotalProgress(int value){ 89 | Window->ui->TotalProgress->setValue(value); 90 | Window->ui->CurrentProgress->setValue(0); 91 | } 92 | 93 | // Updates and brings the results screen when process is done 94 | void MainWindow::UpdateResultsScreen(char mode, char op, QString CurrentSubFolder){ 95 | // Set header label accordingly... 96 | if (mode == 'B'){ 97 | Window->ui->ResultsHeaderLabel->setText("Backup complete!"); 98 | switch (op){ 99 | case 'S': Window->ui->ResultsPathLabel->setText(QString::fromStdString("Your saves are in:\n") + CurrentSubFolder); break; 100 | case 'C': Window->ui->ResultsPathLabel->setText(QString::fromStdString("Your configs are in:\n") + CurrentSubFolder); break; 101 | case 'G': Window->ui->ResultsPathLabel->setText(QString::fromStdString("Your games are in:\n") + CurrentSubFolder); break; 102 | } 103 | } else if (mode == 'R'){ 104 | Window->ui->ResultsHeaderLabel->setText("Restore complete!"); 105 | switch (op){ 106 | case 'S': Window->ui->ResultsPathLabel->setText(QString::fromStdString("Saves successfully restored.")); break; 107 | case 'C': Window->ui->ResultsPathLabel->setText(QString::fromStdString("Configs successfully restored.")); break; 108 | case 'G': Window->ui->ResultsPathLabel->setText(QString::fromStdString("Games successfully restored.")); break; 109 | } 110 | } 111 | 112 | // ...and bring it up 113 | Window->ui->ProgressWidget->setVisible(false); 114 | Window->ui->ResultsWidget->setVisible(true); 115 | } 116 | 117 | // Updates total size label 118 | void MainWindow::UpdateTotalSize(){ 119 | if (MainMenu::OneItemChecked()){ // If at least one item has been checked: 120 | Window->ui->TotalSizeLabel->setText("Calculating\nsize..."); // Update size label 121 | Window->ui->StartBtn->setDisabled(true); // Disable the Start button for calculation 122 | App->processEvents(); // Let the UI settle in 123 | MainMenu::CheckTotalSize(); // Check total size of operation 124 | Window->ui->StartBtn->setDisabled(false); // Enable the Start button again 125 | } else { // If no item has been checked: 126 | Window->ui->TotalSizeLabel->setText(""); // "Hide" the size label 127 | Window->ui->StartBtn->setDisabled(true); // Disable the Start button 128 | } 129 | } 130 | 131 | //----------------------------------------------------------------------------------------------------------- 132 | // FUNCTION CALLS - MAIN MENU 133 | //----------------------------------------------------------------------------------------------------------- 134 | 135 | /* For every Scan button - each one will switch mode and option to its liking, scan the respective folder, organize the 136 | game list and lock/unlock UI buttons accordingly */ 137 | void MainWindow::on_BackupScanSaveBtn_clicked(){ // Backup Saves 138 | MainMenu::SwitchMode('B', 'S'); 139 | Window->ui->StartBtn->setDisabled(true); 140 | MainMenu::BackupScan(); 141 | Window->ui->StartBtn->setDisabled(false); 142 | MainMenu::OrganizeGameList(); MainMenu::LockUnlock(); 143 | } 144 | 145 | void MainWindow::on_BackupScanConfigBtn_clicked(){ // Backup Configs 146 | MainMenu::SwitchMode('B', 'C'); 147 | Window->ui->StartBtn->setDisabled(true); 148 | MainMenu::BackupScan(); 149 | Window->ui->StartBtn->setDisabled(false); 150 | MainMenu::OrganizeGameList(); MainMenu::LockUnlock(); 151 | } 152 | 153 | void MainWindow::on_BackupScanGameBtn_clicked(){ // Backup Games 154 | MainMenu::SwitchMode('B', 'G'); 155 | Window->ui->StartBtn->setDisabled(true); 156 | MainMenu::BackupScan(); 157 | Window->ui->StartBtn->setDisabled(false); 158 | MainMenu::OrganizeGameList(); MainMenu::LockUnlock(); 159 | } 160 | 161 | void MainWindow::on_RestoreScanSaveBtn_clicked(){ // Restore Saves 162 | MainMenu::SwitchMode('R', 'S'); 163 | Window->ui->StartBtn->setDisabled(true); 164 | MainMenu::RestoreScan(); 165 | Window->ui->StartBtn->setDisabled(false); 166 | MainMenu::OrganizeGameList(); MainMenu::LockUnlock(); 167 | } 168 | 169 | void MainWindow::on_RestoreScanConfigBtn_clicked(){ // Restore Configs 170 | MainMenu::SwitchMode('R', 'C'); 171 | Window->ui->StartBtn->setDisabled(true); 172 | MainMenu::RestoreScan(); 173 | Window->ui->StartBtn->setDisabled(false); 174 | MainMenu::OrganizeGameList(); MainMenu::LockUnlock(); 175 | } 176 | 177 | void MainWindow::on_RestoreScanGameBtn_clicked(){ // Restore Games 178 | MainMenu::SwitchMode('R', 'G'); 179 | Window->ui->StartBtn->setDisabled(true); 180 | MainMenu::RestoreScan(); 181 | Window->ui->StartBtn->setDisabled(false); 182 | MainMenu::OrganizeGameList(); MainMenu::LockUnlock(); 183 | } 184 | 185 | // For Mark/Unmark All buttons - check/uncheck all items in the list and lock/unlock UI buttons accordingly 186 | void MainWindow::on_MarkAllBtn_clicked(){ MainMenu::CheckUncheck(true); MainMenu::LockUnlock(); } 187 | void MainWindow::on_UnmarkAllBtn_clicked(){ MainMenu::CheckUncheck(false); MainMenu::LockUnlock(); } 188 | 189 | // For Change Folder button - open a file dialog for choosing a backup folder, locking/unlocking UI buttons accordingly 190 | void MainWindow::on_ChangeFolderBtn_clicked(){ 191 | QString NewFolder = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); 192 | if (NewFolder != ""){ ui->BackupEntry->setText(NewFolder); } 193 | MainMenu::LockUnlock(); 194 | } 195 | 196 | // For Start button - start the backup/restore process (it will only be enabled when user has set a backup folder AND checked at least ONE game) 197 | void MainWindow::on_StartBtn_clicked(){ 198 | MainMenu::BackupFolder = ui->BackupEntry->text().toStdString(); // Set backup folder to static variable 199 | if (MainMenu::CheckDiskSpace() == true){ // If target path has enough space: 200 | MainMenu::RemoveUnchecked(); // Remove unchecked items from list 201 | ui->MainWidget->setVisible(false); // Hide the main menu 202 | ui->ProgressWidget->setVisible(true); // Show the progress menu 203 | App->processEvents(); // Let the UI settle in 204 | QThread *thread = new QThread(); // Create a new thread 205 | CopyThread->moveToThread(thread); // Move backup/restore process pointer to new thread 206 | QObject::connect(thread, SIGNAL(started()), CopyThread, SLOT(Start())); // Connect respective signal and slot 207 | thread->start(); // Start the thread 208 | } else { // If there's not enough space, display an error message 209 | QMessageBox err; 210 | err.critical(0, "Error", "Not enough space on device"); 211 | err.setFixedSize(500,200); 212 | } 213 | } 214 | 215 | //----------------------------------------------------------------------------------------------------------- 216 | // FUNCTION CALLS - PROGRESS MENU 217 | //----------------------------------------------------------------------------------------------------------- 218 | 219 | // For Cancel button - start the countdown/cancel the process 220 | void MainWindow::on_CancelBtn_clicked(){ 221 | // Cancel button is foolproof - so it starts a countdown first in case of an accidental click instead of cancelling 222 | if (!ProgressMenu::CancelCheck){ ProgressMenu::CancelCheck = true; ProgressMenu::CancelCountdown(); } 223 | 224 | // The button needs to be clicked again to confirm the cancelling 225 | else { 226 | ProgressMenu::CancelCheck = false; ProgressMenu::StopProcess = true; 227 | Window->ui->ProgressWidget->setVisible(false); 228 | Window->ui->MainWidget->setVisible(true); 229 | MainMenu::LockUnlock(); 230 | } 231 | } 232 | 233 | //----------------------------------------------------------------------------------------------------------- 234 | // FUNCTION CALLS - RESULTS MENU 235 | //----------------------------------------------------------------------------------------------------------- 236 | 237 | // For Back to menu button - hide this menu and bring up the main menu 238 | void MainWindow::on_MenuBtn_clicked(){ 239 | Window->ui->ResultsWidget->setVisible(false); 240 | Window->ui->MainWidget->setVisible(true); 241 | MainMenu::LockUnlock(); 242 | } 243 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Main Window/UI (header file)]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | #ifndef MAINWINDOW_H 12 | #define MAINWINDOW_H 13 | 14 | #include 15 | #include 16 | 17 | namespace Ui { class MainWindow; } 18 | 19 | class MainWindow : public QMainWindow { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit MainWindow(QWidget *parent = 0); 24 | ~MainWindow(); 25 | Ui::MainWindow *ui; 26 | void closeEvent(QCloseEvent *); 27 | static ProgressThread *CopyThread; 28 | 29 | public slots: 30 | static void StartProgressBars(int TotalGames); 31 | static void UpdateCopyingLabel(QString text); 32 | static void UpdateCurrentProgress(int value); 33 | static void UpdateHeaderLabel(char mode); 34 | static void UpdateGameLabel(QString text); 35 | static void UpdateTotalProgress(int value); 36 | static void UpdateResultsScreen(char mode, char op, QString CurrentSubFolder); 37 | static void UpdateTotalSize(); 38 | 39 | private slots: 40 | void on_BackupScanSaveBtn_clicked(); 41 | void on_BackupScanConfigBtn_clicked(); 42 | void on_BackupScanGameBtn_clicked(); 43 | void on_RestoreScanSaveBtn_clicked(); 44 | void on_RestoreScanConfigBtn_clicked(); 45 | void on_RestoreScanGameBtn_clicked(); 46 | void on_MarkAllBtn_clicked(); 47 | void on_UnmarkAllBtn_clicked(); 48 | void on_ChangeFolderBtn_clicked(); 49 | void on_StartBtn_clicked(); 50 | void on_CancelBtn_clicked(); 51 | void on_MenuBtn_clicked(); 52 | }; 53 | 54 | #endif // MAINWINDOW_H 55 | -------------------------------------------------------------------------------- /src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1024 10 | 768 11 | 12 | 13 | 14 | 15 | 1024 16 | 768 17 | 18 | 19 | 20 | 21 | 1024 22 | 768 23 | 24 | 25 | 26 | Steam Linux Swiss Knife 27 | 28 | 29 | 30 | ../img/SLSK_icon.png../img/SLSK_icon.png 31 | 32 | 33 | background-color: rgb(150, 150, 150); 34 | 35 | 36 | 37 | 38 | 39 | 0 40 | 0 41 | 1021 42 | 771 43 | 44 | 45 | 46 | 47 | 48 | 10 49 | 420 50 | 120 51 | 40 52 | 53 | 54 | 55 | 56 | Sans Serif 57 | 12 58 | 59 | 60 | 61 | background-color: rgb(200, 200, 200); 62 | 63 | 64 | Scan for 65 | Games 66 | 67 | 68 | 69 | 70 | 71 | 640 72 | 20 73 | 151 74 | 31 75 | 76 | 77 | 78 | 79 | Sans Serif 80 | 12 81 | 75 82 | true 83 | 84 | 85 | 86 | color: rgb(255, 255, 255); 87 | 88 | 89 | Current Option: 90 | 91 | 92 | Qt::AlignCenter 93 | 94 | 95 | 96 | 97 | 98 | 10 99 | 620 100 | 120 101 | 31 102 | 103 | 104 | 105 | 106 | Sans Serif 107 | 12 108 | 109 | 110 | 111 | background-color: rgb(200, 200, 200); 112 | 113 | 114 | Mark All 115 | 116 | 117 | 118 | 119 | 120 | 10 121 | 60 122 | 121 123 | 51 124 | 125 | 126 | 127 | 128 | Sans Serif 129 | 12 130 | 131 | 132 | 133 | color: rgb(255, 255, 255); 134 | 135 | 136 | Backup 137 | options 138 | 139 | 140 | Qt::AlignCenter 141 | 142 | 143 | 144 | 145 | 146 | 157 147 | 20 148 | 141 149 | 31 150 | 151 | 152 | 153 | 154 | Sans Serif 155 | 12 156 | 75 157 | true 158 | 159 | 160 | 161 | color: rgb(255, 255, 255); 162 | 163 | 164 | Current Mode: 165 | 166 | 167 | Qt::AlignCenter 168 | 169 | 170 | 171 | 172 | 173 | 10 174 | 210 175 | 120 176 | 40 177 | 178 | 179 | 180 | 181 | Sans Serif 182 | 12 183 | 184 | 185 | 186 | background-color: rgb(200, 200, 200); 187 | 188 | 189 | Scan for 190 | Games 191 | 192 | 193 | 194 | 195 | 196 | 10 197 | 270 198 | 121 199 | 51 200 | 201 | 202 | 203 | 204 | Sans Serif 205 | 12 206 | 207 | 208 | 209 | color: rgb(255, 255, 255); 210 | 211 | 212 | Restore 213 | options 214 | 215 | 216 | Qt::AlignCenter 217 | 218 | 219 | 220 | 221 | true 222 | 223 | 224 | 225 | 140 226 | 700 227 | 821 228 | 31 229 | 230 | 231 | 232 | 233 | Sans Serif 234 | 12 235 | 236 | 237 | 238 | background-color: rgb(200, 200, 200); 239 | color: rgb(0, 0, 0); 240 | 241 | 242 | true 243 | 244 | 245 | 246 | 247 | 248 | 10 249 | 660 250 | 120 251 | 31 252 | 253 | 254 | 255 | 256 | Sans Serif 257 | 12 258 | 259 | 260 | 261 | background-color: rgb(200, 200, 200); 262 | 263 | 264 | Unmark All 265 | 266 | 267 | 268 | 269 | 270 | 800 271 | 20 272 | 111 273 | 31 274 | 275 | 276 | 277 | 278 | Sans Serif 279 | 12 280 | 75 281 | true 282 | 283 | 284 | 285 | color: rgb(0, 255, 255); 286 | 287 | 288 | None 289 | 290 | 291 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 292 | 293 | 294 | 295 | 296 | 297 | 10 298 | 700 299 | 121 300 | 31 301 | 302 | 303 | 304 | 305 | Sans Serif 306 | 12 307 | 308 | 309 | 310 | color: rgb(255, 255, 255); 311 | 312 | 313 | Backup folder: 314 | 315 | 316 | Qt::AlignCenter 317 | 318 | 319 | 320 | 321 | 322 | 10 323 | 320 324 | 120 325 | 40 326 | 327 | 328 | 329 | 330 | Sans Serif 331 | 12 332 | 333 | 334 | 335 | background-color: rgb(200, 200, 200); 336 | 337 | 338 | Scan for 339 | Saves 340 | 341 | 342 | 343 | 344 | 345 | 300 346 | 20 347 | 111 348 | 31 349 | 350 | 351 | 352 | 353 | Sans Serif 354 | 12 355 | 75 356 | true 357 | 358 | 359 | 360 | color: rgb(0, 255, 255); 361 | 362 | 363 | None 364 | 365 | 366 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 367 | 368 | 369 | 370 | 371 | 372 | 970 373 | 700 374 | 41 375 | 31 376 | 377 | 378 | 379 | 380 | Sans Serif 381 | 12 382 | 383 | 384 | 385 | background-color: rgb(200, 200, 200); 386 | 387 | 388 | ... 389 | 390 | 391 | 392 | 393 | 394 | 10 395 | 370 396 | 120 397 | 40 398 | 399 | 400 | 401 | 402 | Sans Serif 403 | 12 404 | 405 | 406 | 407 | background-color: rgb(200, 200, 200); 408 | 409 | 410 | Scan for 411 | Configs 412 | 413 | 414 | 415 | 416 | 417 | 10 418 | 160 419 | 120 420 | 40 421 | 422 | 423 | 424 | 425 | Sans Serif 426 | 12 427 | 428 | 429 | 430 | background-color: rgb(200, 200, 200); 431 | 432 | 433 | Scan for 434 | Configs 435 | 436 | 437 | 438 | 439 | 440 | 140 441 | 50 442 | 741 443 | 641 444 | 445 | 446 | 447 | 448 | Sans Serif 449 | 12 450 | 50 451 | false 452 | false 453 | false 454 | true 455 | 456 | 457 | 458 | background-color: rgb(235, 235, 235); 459 | background-image: url("/opt/SLSK/img/SLSK_BG_transparent.png"); 460 | background-position: center; 461 | background-repeat: no-repeat; 462 | background-attachment: fixed; 463 | 464 | 465 | QFrame::NoFrame 466 | 467 | 468 | QFrame::Sunken 469 | 470 | 471 | 1 472 | 473 | 474 | 0 475 | 476 | 477 | Qt::ScrollBarAlwaysOff 478 | 479 | 480 | true 481 | 482 | 483 | QAbstractItemView::NoEditTriggers 484 | 485 | 486 | QAbstractItemView::SingleSelection 487 | 488 | 489 | QAbstractItemView::SelectItems 490 | 491 | 492 | 5 493 | 494 | 495 | QListView::ListMode 496 | 497 | 498 | false 499 | 500 | 501 | false 502 | 503 | 504 | 505 | 506 | 507 | 10 508 | 110 509 | 120 510 | 40 511 | 512 | 513 | 514 | 515 | Sans Serif 516 | 12 517 | 518 | 519 | 520 | background-color: rgb(200, 200, 200); 521 | 522 | 523 | Scan for 524 | Saves 525 | 526 | 527 | 528 | 529 | 530 | 890 531 | 630 532 | 121 533 | 61 534 | 535 | 536 | 537 | 538 | Sans Serif 539 | 18 540 | 75 541 | false 542 | true 543 | 544 | 545 | 546 | background-color: rgb(200, 200, 200); 547 | 548 | 549 | Start! 550 | 551 | 552 | 553 | 554 | 555 | 10 556 | 540 557 | 121 558 | 81 559 | 560 | 561 | 562 | 563 | Sans Serif 564 | 12 565 | 566 | 567 | 568 | color: rgb(255, 255, 255); 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 140 578 | 730 579 | 751 580 | 31 581 | 582 | 583 | 584 | 585 | Sans Serif 586 | 12 587 | 588 | 589 | 590 | color: rgb(255, 255, 255); 591 | 592 | 593 | SLSK v1.0.0 - Copyright © 2017 Supremist (aka supremesonicbrazil) 594 | 595 | 596 | Qt::AlignCenter 597 | 598 | 599 | 600 | 601 | 602 | 330 603 | 290 604 | 381 605 | 151 606 | 607 | 608 | 609 | 610 | Sans Serif 611 | 18 612 | 75 613 | true 614 | 615 | 616 | 617 | color: rgb(255, 255, 255); 618 | 619 | 620 | Scanning, please wait... 621 | (this may take a while) 622 | 623 | 624 | Qt::AlignCenter 625 | 626 | 627 | 628 | 629 | 630 | 890 631 | 580 632 | 121 633 | 51 634 | 635 | 636 | 637 | 638 | Sans Serif 639 | 12 640 | 75 641 | true 642 | 643 | 644 | 645 | color: rgb(255, 255, 255); 646 | 647 | 648 | Total size: 649 | 9999.99 GB 650 | 651 | 652 | 653 | 654 | 655 | 656 | 0 657 | 0 658 | 1021 659 | 771 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 100 669 | 190 670 | 821 671 | 81 672 | 673 | 674 | 675 | 676 | Sans Serif 677 | 16 678 | 50 679 | true 680 | false 681 | 682 | 683 | 684 | color: rgb(255, 255, 255); 685 | background-color: rgba(255, 255, 255, 0); 686 | 687 | 688 | Copying file: ????? 689 | 690 | 691 | Qt::AlignCenter 692 | 693 | 694 | true 695 | 696 | 697 | 698 | 699 | 700 | 100 701 | 500 702 | 821 703 | 71 704 | 705 | 706 | 707 | 708 | Sans Serif 709 | 18 710 | 711 | 712 | 713 | color: rgb(255, 255, 255); 714 | background-color: rgb(200, 200, 200); 715 | 716 | 717 | 100 718 | 719 | 720 | 24 721 | 722 | 723 | Qt::Horizontal 724 | 725 | 726 | false 727 | 728 | 729 | QProgressBar::TopToBottom 730 | 731 | 732 | %v/%m 733 | 734 | 735 | 736 | 737 | 738 | 100 739 | 660 740 | 691 741 | 71 742 | 743 | 744 | 745 | 746 | Sans Serif 747 | 16 748 | 50 749 | true 750 | false 751 | 752 | 753 | 754 | color: rgb(255, 255, 255); 755 | background-color: rgba(255, 255, 255, 0); 756 | 757 | 758 | 759 | 760 | 761 | Qt::AlignCenter 762 | 763 | 764 | true 765 | 766 | 767 | 768 | 769 | 770 | 100 771 | 270 772 | 821 773 | 71 774 | 775 | 776 | 777 | 778 | Sans Serif 779 | 18 780 | false 781 | 782 | 783 | 784 | color: rgb(255, 255, 255); 785 | background-color: rgb(200, 200, 200); 786 | 787 | 788 | 24 789 | 790 | 791 | 792 | 793 | 794 | 20 795 | 10 796 | 981 797 | 41 798 | 799 | 800 | 801 | 802 | Sans Serif 803 | 24 804 | 75 805 | true 806 | true 807 | 808 | 809 | 810 | color: rgb(255, 255, 255); 811 | background-color: rgba(255, 255, 255, 0); 812 | 813 | 814 | ??????? in progress... sit back and enjoy the ride. 815 | 816 | 817 | Qt::AlignCenter 818 | 819 | 820 | 821 | 822 | 823 | 100 824 | 430 825 | 821 826 | 61 827 | 828 | 829 | 830 | 831 | Sans Serif 832 | 16 833 | 50 834 | true 835 | false 836 | 837 | 838 | 839 | color: rgb(255, 255, 255); 840 | background-color: rgba(255, 255, 255, 0); 841 | 842 | 843 | Total progress so far: 844 | 845 | 846 | Qt::AlignCenter 847 | 848 | 849 | true 850 | 851 | 852 | 853 | 854 | 855 | 100 856 | 80 857 | 821 858 | 81 859 | 860 | 861 | 862 | 863 | Sans Serif 864 | 16 865 | 50 866 | true 867 | false 868 | 869 | 870 | 871 | color: rgb(255, 255, 255); 872 | background-color: rgba(255, 255, 255, 0); 873 | 874 | 875 | Current game: ????? 876 | 877 | 878 | Qt::AlignCenter 879 | 880 | 881 | true 882 | 883 | 884 | 885 | 886 | 887 | 820 888 | 660 889 | 171 890 | 71 891 | 892 | 893 | 894 | 895 | Sans Serif 896 | 24 897 | 75 898 | true 899 | 900 | 901 | 902 | background-color: rgb(200, 200, 200); 903 | 904 | 905 | Cancel 906 | 907 | 908 | 909 | 910 | 911 | 912 | 0 913 | 0 914 | 1021 915 | 771 916 | 917 | 918 | 919 | 920 | 921 | 50 922 | 560 923 | 921 924 | 61 925 | 926 | 927 | 928 | 929 | Sans Serif 930 | 16 931 | 50 932 | true 933 | false 934 | 935 | 936 | 937 | color: rgb(255, 255, 255); 938 | background-color: rgba(255, 255, 255, 0); 939 | 940 | 941 | You can close the window now or return by clicking the button below. 942 | 943 | 944 | Qt::AlignCenter 945 | 946 | 947 | true 948 | 949 | 950 | 951 | 952 | 953 | 50 954 | 460 955 | 911 956 | 111 957 | 958 | 959 | 960 | 961 | Sans Serif 962 | 16 963 | 50 964 | true 965 | false 966 | 967 | 968 | 969 | color: rgb(255, 255, 255); 970 | background-color: rgba(255, 255, 255, 0); 971 | 972 | 973 | Your ?????? are in: 974 | <<path>> 975 | 976 | 977 | Qt::AlignCenter 978 | 979 | 980 | true 981 | 982 | 983 | 984 | 985 | 986 | 40 987 | 10 988 | 951 989 | 41 990 | 991 | 992 | 993 | 994 | Sans Serif 995 | 24 996 | 75 997 | true 998 | true 999 | 1000 | 1001 | 1002 | color: rgb(255, 255, 255); 1003 | background-color: rgba(255, 255, 255, 0); 1004 | 1005 | 1006 | ??????? complete! 1007 | 1008 | 1009 | Qt::AlignCenter 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 400 1016 | 640 1017 | 221 1018 | 71 1019 | 1020 | 1021 | 1022 | 1023 | Sans Serif 1024 | 18 1025 | 75 1026 | true 1027 | 1028 | 1029 | 1030 | background-color: rgb(200, 200, 200); 1031 | 1032 | 1033 | Back to Menu 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 200 1040 | 80 1041 | 631 1042 | 351 1043 | 1044 | 1045 | 1046 | background-image: url("/opt/SLSK/img/SLSK_BG.png"); 1047 | background-position: center; 1048 | background-repeat: no-repeat; 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | ProgressWidget 1056 | ResultsWidget 1057 | MainWidget 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | -------------------------------------------------------------------------------- /src/progressmenu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Progress Menu functionalities]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | //----------------------------------------------------------------------------------------------------------- 12 | // INCLUDED LIBRARIES 13 | //----------------------------------------------------------------------------------------------------------- 14 | 15 | // Standard C++/Qt libs 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | // Program-specific/external libs 31 | #include "mainmenu.h" 32 | #include "progressmenu.h" 33 | #include "mainwindow.h" 34 | #include "ui_mainwindow.h" 35 | #include "db.h" 36 | 37 | //----------------------------------------------------------------------------------------------------------- 38 | // VARIABLES 39 | //----------------------------------------------------------------------------------------------------------- 40 | 41 | // Integers for the total number of games/files and the number of games/files that were successfully copied 42 | int TotalGames = 0, GamesDone = 0, TotalFiles = 0, FilesDone = 0; 43 | 44 | // Booleans for Cancel button and to stop the process 45 | bool ProgressMenu::CancelCheck = false, ProgressMenu::StopProcess = false; 46 | 47 | QDir BackupFolder; // Variable for backup folder directory 48 | 49 | // Strings for paths (from database) 50 | std::string CurrentSave[3] = {"", "", ""}, CurrentConfig[3] = {"", "", ""}, CurrentGame = "", CurrentAppID = ""; 51 | 52 | // Strings that help compose other paths 53 | std::string ProgressMenu::CurrentFolder = "", AppManifest = "", CurrentSubFolder = "", 54 | CurrentBackupPath = "", CurrentRestorePath = "", CurrentPathFolder = ""; 55 | 56 | //----------------------------------------------------------------------------------------------------------- 57 | // FUNCTIONS 58 | //----------------------------------------------------------------------------------------------------------- 59 | 60 | // Slot function for starting thread 61 | void ProgressThread::Start() { ProgressMenu::StartProcess(MainMenu::ProcessMode, MainMenu::ProcessOp, Window->ui->GameList); } 62 | 63 | /* Creates subfolders in backup folder in case they don't exist - "SteamSaves" for saves, "SteamConfigs" for 64 | configs, "SteamGames" and "SteamManifests" for games */ 65 | void ProgressMenu::SetBackupSubFolders(char op){ 66 | if (op == 'S'){ BackupFolder.mkpath("SteamSaves"); } 67 | else if (op == 'C') { BackupFolder.mkpath("SteamConfigs"); } 68 | else if (op == 'G'){ BackupFolder.mkpath("SteamGames"); BackupFolder.mkpath("SteamManifests"); } 69 | } 70 | 71 | // Writes the backup date in a text file 72 | void ProgressMenu::WriteBackupDate(char op){ 73 | // Setting file name according to option 74 | QString filename; 75 | switch (op){ 76 | case 'S': filename = QString::fromStdString(MainMenu::BackupFolder + "/LastSaveBackup.txt"); break; 77 | case 'C': filename = QString::fromStdString(MainMenu::BackupFolder + "/LastConfigBackup.txt"); break; 78 | case 'G': filename = QString::fromStdString(MainMenu::BackupFolder + "/LastGameBackup.txt"); break; 79 | } 80 | 81 | // Fetching current date and time 82 | int year = QDate::currentDate().year(), month = QDate::currentDate().month(), day = QDate::currentDate().day(), 83 | hour = QTime::currentTime().hour(), minute = QTime::currentTime().minute(), second = QTime::currentTime().second(); 84 | 85 | // Formatting current date and time 86 | QString date = QString::number(year) + "-"; 87 | if (month < 10){ date += "0"; } date += QString::number(month) + "-"; 88 | if (day < 10){ date += "0"; } date += QString::number(day) + " "; 89 | QString time; 90 | if (hour < 10){ time += "0"; } time += QString::number(hour) + ":"; 91 | if (minute < 10){ time += "0"; } time += QString::number(minute) + ":"; 92 | if (second < 10){ time += "0"; } time += QString::number(second); 93 | 94 | // Check if the file already exists - if yes, remove it and create a new blank one 95 | if (QFile(filename).exists()){ QFile::remove(filename); } 96 | QFile file(filename); 97 | 98 | // Opening the file and writing content 99 | file.open(QIODevice::ReadWrite); 100 | QTextStream stream(&file); stream << date << endl << time << endl; 101 | file.close(); 102 | } 103 | 104 | 105 | // Function that fetches all raw paths (and other info) from a game in the database for the backup/restore process 106 | void ProgressMenu::FetchPaths(QString Game){ 107 | // Fetch game folder 108 | CurrentFolder = DB::FetchGameInfo("SELECT GameFolder FROM RegisteredGames WHERE SteamName = \"" + Game.toStdString() + "\""); 109 | CurrentGame = DB::SteamPath + "/" + CurrentFolder; 110 | 111 | // Fetch appmanifest (erases "common" from Steam path and appends the appmanifest file) 112 | CurrentAppID = DB::SteamPath; CurrentAppID.erase(CurrentAppID.end() - 6, CurrentAppID.end()); 113 | AppManifest = "appmanifest_" + DB::FetchGameInfo("SELECT AppID FROM RegisteredGames WHERE SteamName = \"" + Game.toStdString() + "\"") + ".acf"; 114 | CurrentAppID += AppManifest; 115 | 116 | // Fetch save and config paths (all 3 possible paths) 117 | for (int ct = 0; ct < 3; ct++){ 118 | CurrentSave[ct] = DB::FetchGameInfo("SELECT SavePath" + std::to_string(ct + 1) + " FROM RegisteredGames WHERE SteamName = \"" + Game.toStdString() + "\""); 119 | CurrentConfig[ct] = DB::FetchGameInfo("SELECT ConfigPath" + std::to_string(ct + 1) + " FROM RegisteredGames WHERE SteamName = \"" + Game.toStdString() + "\""); 120 | } 121 | } 122 | 123 | // Functions that actually copies files over from the respective directories based on the following: 124 | // Mode - 'B'ackup/'R'estore 125 | // Option - 'S'ave/'C'onfig/'G'ame (appmanifest is copied separately from outside) 126 | // NOTES: path = origin path 127 | 128 | // For Backup Mode 129 | void ProgressMenu::Backup(char op, std::string path, int n){ 130 | // Setting paths for iterator based on option 131 | switch (op){ 132 | case 'S': CurrentSubFolder = MainMenu::BackupFolder + "/SteamSaves/"; 133 | CurrentPathFolder = DB::FetchGameInfo("SELECT SaveFolder" + std::to_string(n) + " FROM RegisteredGames " 134 | "WHERE SavePath" + std::to_string(n) + " = '" + path + "'"); break; 135 | case 'C': CurrentSubFolder = MainMenu::BackupFolder + "/SteamConfigs/"; 136 | CurrentPathFolder = DB::FetchGameInfo("SELECT ConfigFolder" + std::to_string(n) + " FROM RegisteredGames " 137 | "WHERE ConfigPath" + std::to_string(n) + " = '" + path + "'"); break; 138 | case 'G': CurrentSubFolder = MainMenu::BackupFolder + "/SteamGames/"; 139 | CurrentPathFolder = CurrentFolder; break; 140 | } 141 | 142 | // Replace any labels in the path and create it 143 | DB::ReplaceLabels(path); 144 | QDir PathDir(QString::fromStdString(path)); PathDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 145 | if (PathDir.dirName().contains('*')){ // If dir name has a wildcard: 146 | if (PathDir.dirName().contains('.')){ // If dir name contains a '.', it's a file (or multiple files) 147 | PathDir.setNameFilters(QStringList() << "*." + QFileInfo(PathDir.dirName()).completeSuffix()); // In this case, filter by file extension... 148 | PathDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); // ...and by files only... 149 | PathDir.cdUp(); // ...and move up to parent directory 150 | } else { // If it's not a file, it's multiple dirs 151 | PathDir.setNameFilters(QStringList() << PathDir.dirName()); // In this case, filter by directory name... 152 | PathDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); // ...and by dirs only... 153 | PathDir.cdUp(); CurrentPathFolder = PathDir.dirName().toStdString(); // ...move up to parent directory and set path folder correctly 154 | } 155 | } 156 | 157 | // Initialize the iterator, and while there are files to be copied and the process is permitted to continue: 158 | QDirIterator BackupIterator(PathDir, QDirIterator::Subdirectories); 159 | bool FilesCounted = false; // Bool for signaling if all files have been counted already 160 | while (BackupIterator.hasNext() && ProgressMenu::StopProcess == false){ 161 | BackupIterator.next(); // Iterate to the next one 162 | if (QFileInfo(BackupIterator.filePath()).isDir()){ // If next entry is a dir: 163 | QDir SubfolderDir(BackupIterator.filePath()); SubfolderDir.setFilter(QDir:: Files | QDir::NoDotAndDotDot); // Fetch the respective dir 164 | if (FilesCounted == false){ // If files haven't been counted yet: 165 | QDirIterator SubfolderCounter(SubfolderDir, QDirIterator::Subdirectories); // Create another iterator for counting files 166 | while (SubfolderCounter.hasNext()){ TotalFiles++; SubfolderCounter.next(); } // Count all files that will be backed up 167 | FilesCounted = true; // Update flag 168 | } 169 | 170 | // Create one more iterator for the dir and do the process with it instead 171 | QDirIterator SubfolderIterator(SubfolderDir, QDirIterator::Subdirectories); 172 | while (SubfolderIterator.hasNext() && ProgressMenu::StopProcess == false){ 173 | SubfolderIterator.next(); // Go to the next file 174 | emit MainWindow::CopyThread->UpdateCopyingLabel("Copying file: " + SubfolderIterator.fileName()); // Emit a signal to update the current file label accordingly 175 | 176 | // Create the path for current content 177 | CurrentBackupPath = CurrentSubFolder + CurrentPathFolder + 178 | SubfolderIterator.filePath().remove(BackupIterator.path()).remove( 179 | SubfolderIterator.fileName()).toStdString(); 180 | BackupFolder.mkpath(QString::fromStdString(CurrentBackupPath)); 181 | 182 | // Copy the content, deleting old copies beforehand if they already exist 183 | if (QFile::exists(QString::fromStdString(CurrentBackupPath) + SubfolderIterator.fileName())) 184 | QFile::remove(QString::fromStdString(CurrentBackupPath) + SubfolderIterator.fileName()); 185 | QFile::copy(SubfolderIterator.filePath(), QString::fromStdString(CurrentBackupPath) + SubfolderIterator.fileName()); 186 | 187 | // Update current progress 188 | FilesDone++; 189 | emit MainWindow::CopyThread->UpdateCurrentProgress((FilesDone/(double)TotalFiles) * 100); 190 | } 191 | } else { // If next entry is not a dir: 192 | if (FilesCounted == false){ // If files haven't been counted yet: 193 | QDirIterator BackupCounter(PathDir, QDirIterator::Subdirectories); // Create another iterator for counting files 194 | while (BackupCounter.hasNext()){ TotalFiles++; BackupCounter.next(); } // Count all files that will be backed up 195 | FilesCounted = true; // Update flag 196 | } 197 | emit MainWindow::CopyThread->UpdateCopyingLabel("Copying file: " + BackupIterator.fileName()); // Emit a signal to update the current file label accordingly 198 | 199 | // Create the path for current content 200 | CurrentBackupPath = CurrentSubFolder + CurrentPathFolder + 201 | BackupIterator.filePath().remove(PathDir.path()).remove( 202 | BackupIterator.fileName()).toStdString(); 203 | BackupFolder.mkpath(QString::fromStdString(CurrentBackupPath)); 204 | 205 | // Copy the content, deleting old copies beforehand if they already exist 206 | if (QFile::exists(QString::fromStdString(CurrentBackupPath) + BackupIterator.fileName())) 207 | QFile::remove(QString::fromStdString(CurrentBackupPath) + BackupIterator.fileName()); 208 | QFile::copy(BackupIterator.filePath(), QString::fromStdString(CurrentBackupPath) + BackupIterator.fileName()); 209 | 210 | // Update current progress 211 | FilesDone++; 212 | emit MainWindow::CopyThread->UpdateCurrentProgress((FilesDone/(double)TotalFiles) * 100); 213 | } 214 | } 215 | 216 | // Reset counters at the end 217 | TotalFiles = 0; FilesDone = 0; 218 | } 219 | 220 | // For Restore Mode 221 | void ProgressMenu::Restore(char op, std::string path, int n){ 222 | // Setting paths for iterator based on option 223 | switch (op){ 224 | case 'S': CurrentSubFolder = MainMenu::BackupFolder + "/SteamSaves/"; 225 | CurrentPathFolder = DB::FetchGameInfo("SELECT SaveFolder" + std::to_string(n) + " FROM RegisteredGames " 226 | "WHERE SavePath" + std::to_string(n) + " = '" + path + "'"); break; 227 | case 'C': CurrentSubFolder = MainMenu::BackupFolder + "/SteamConfigs/"; 228 | CurrentPathFolder = DB::FetchGameInfo("SELECT ConfigFolder" + std::to_string(n) + " FROM RegisteredGames " 229 | "WHERE ConfigPath" + std::to_string(n) + " = '" + path + "'"); break; 230 | case 'G': CurrentSubFolder = MainMenu::BackupFolder + "/SteamGames/"; 231 | CurrentPathFolder = CurrentFolder; break; 232 | } 233 | CurrentRestorePath = CurrentSubFolder + CurrentPathFolder; 234 | 235 | // Replace any labels in the path and create it 236 | DB::ReplaceLabels(path); 237 | QDir PathDir(QString::fromStdString(CurrentRestorePath)); PathDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); 238 | if (PathDir.dirName().contains('*')){ // If dir name has a wildcard: 239 | if (PathDir.dirName().contains('.')){ // If dir name contains a '.', it's a file (or multiple files) 240 | PathDir.setNameFilters(QStringList() << "*." + QFileInfo(PathDir.dirName()).completeSuffix()); // In this case, filter by file extension... 241 | PathDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); // ...and by files only... 242 | PathDir.cdUp(); // ...and move up to parent directory 243 | } else { // If it's not a file, it's multiple dirs 244 | PathDir.setNameFilters(QStringList() << PathDir.dirName()); // In this case, filter by directory name... 245 | PathDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); // ...and by dirs only... 246 | PathDir.cdUp(); CurrentPathFolder = PathDir.dirName().toStdString(); // ...move up to parent directory and set path folder correctly 247 | } 248 | } 249 | 250 | // Remove the last dir from the path if it has a wildcard 251 | if (QDir(QString::fromStdString(path)).dirName().contains('*')) 252 | path = QDir(QString::fromStdString(path)).path().remove(QDir(QString::fromStdString(path)).dirName()).toStdString(); 253 | 254 | // Initialize the iterator, and while there are files to be copied and the process is permitted to continue: 255 | QDirIterator RestoreIterator(PathDir, QDirIterator::Subdirectories); 256 | bool FilesCounted = false; // Bool for signaling if all files have been counted already 257 | while (RestoreIterator.hasNext() && ProgressMenu::StopProcess == false){ 258 | RestoreIterator.next(); // Iterate to the next one 259 | if (QFileInfo(RestoreIterator.filePath()).isDir()){ // If next entry is a dir: 260 | QDir SubfolderDir(RestoreIterator.filePath()); SubfolderDir.setFilter(QDir:: Files | QDir::NoDotAndDotDot); // Fetch the respective dir 261 | if (FilesCounted == false){ // If files haven't been counted yet: 262 | QDirIterator SubfolderCounter(SubfolderDir, QDirIterator::Subdirectories); // Create another iterator for counting files 263 | while (SubfolderCounter.hasNext()){ TotalFiles++; SubfolderCounter.next(); } // Count all files that will be backed up 264 | FilesCounted = true; // Update flag 265 | } 266 | 267 | // Create one more iterator for the dir and do the process with it instead 268 | QDirIterator SubfolderIterator(SubfolderDir, QDirIterator::Subdirectories); 269 | while (SubfolderIterator.hasNext() && ProgressMenu::StopProcess == false){ 270 | SubfolderIterator.next(); // Go to the next file 271 | emit MainWindow::CopyThread->UpdateCopyingLabel("Copying file: " + SubfolderIterator.fileName()); // Emit a signal to update the current file label accordingly 272 | 273 | // Create the path for current content if necessary... 274 | QString DestPath = QString::fromStdString(path).remove(QDir(QString::fromStdString(path)).dirName() + "/") + 275 | SubfolderIterator.filePath().remove(QString::fromStdString(CurrentSubFolder)).remove(SubfolderIterator.fileName()); 276 | QDir(QString::fromStdString(path)).mkpath(DestPath); 277 | 278 | // ...copy the content... 279 | QFile::copy(SubfolderIterator.filePath(), QDir(DestPath).path() + "/" + SubfolderIterator.fileName()); 280 | 281 | // ...and update current progress 282 | FilesDone++; 283 | emit MainWindow::CopyThread->UpdateCurrentProgress((FilesDone/(double)TotalFiles) * 100); 284 | } 285 | } else { // If next entry is not a dir: 286 | if (FilesCounted == false){ // If files haven't been counted yet: 287 | QDirIterator RestoreCounter(PathDir, QDirIterator::Subdirectories); // Create another iterator for counting files 288 | while (RestoreCounter.hasNext()){ TotalFiles++; RestoreCounter.next(); } // Count all files that will be backed up 289 | FilesCounted = true; // Update flag 290 | } 291 | 292 | emit MainWindow::CopyThread->UpdateCopyingLabel("Copying file: " + RestoreIterator.fileName()); // Emit a signal to update the current file label accordingly 293 | 294 | // Create the path for current content if necessary... 295 | QString DestPath = QString::fromStdString(path + RestoreIterator.filePath().remove( 296 | QString::fromStdString(CurrentRestorePath)).remove(RestoreIterator.fileName()).toStdString()); 297 | QDir(QString::fromStdString(path)).mkpath(DestPath); 298 | 299 | // ...copy the content... 300 | QFile::copy(RestoreIterator.filePath(), QDir(DestPath).path() + "/" + RestoreIterator.fileName()); 301 | 302 | // ...and update current progress 303 | FilesDone++; 304 | emit MainWindow::CopyThread->UpdateCurrentProgress((FilesDone/(double)TotalFiles) * 100); 305 | } 306 | } 307 | 308 | // Reset counters at the end 309 | TotalFiles = 0; FilesDone = 0; 310 | } 311 | 312 | // Starts the proper backup/restore process 313 | void ProgressMenu::StartProcess(char mode, char op, QListWidget* gamelist){ 314 | ProgressMenu::StopProcess = false; // Set the stop process bool to false... 315 | TotalGames = gamelist->count(); // ...count the total number of games... 316 | emit MainWindow::CopyThread->StartProgressBars(TotalGames); // ...emit a signal to set the progress bars... 317 | BackupFolder.setPath(QString::fromStdString(MainMenu::BackupFolder)); // ...set the backup folder's path... 318 | BackupFolder.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); // ...along with its filters... 319 | if (mode == 'B'){ ProgressMenu::SetBackupSubFolders(op); } // ...set its subfolders if on Backup Mode... 320 | emit MainWindow::CopyThread->UpdateHeaderLabel(mode); // ...and emit a signal to set header label accordingly 321 | 322 | // Creating a list with each game 323 | QStringList AllGames; 324 | for (int ct = 0; ct < TotalGames; ct++){ AllGames << gamelist->item(ct)->text(); } 325 | 326 | // For each game in the list, if the process is permitted to continue... 327 | foreach (QString Game, AllGames){ 328 | if (ProgressMenu::StopProcess == false){ 329 | emit MainWindow::CopyThread->UpdateGameLabel("Current game: " + Game); // ...emit a signal to update the current game label... 330 | ProgressMenu::FetchPaths(Game); // ...fetch all paths related to that game... 331 | 332 | // ...do the process: 333 | // For Backup 334 | if (mode == 'B'){ 335 | // Saves 336 | if (op == 'S'){ 337 | // Backup each save folder (if they exist) 338 | for (int ct = 0; ct < 3; ct++){ 339 | if (CurrentSave[ct] != "[N/A]" && CurrentSave[ct] != "[UNKNOWN]" && 340 | CurrentSave[ct] != "[CLOUD-ONLY]"){ 341 | ProgressMenu::Backup('S', CurrentSave[ct], ct + 1); 342 | } 343 | } 344 | 345 | // Configs 346 | } else if (op == 'C'){ 347 | // Backup each config folder (if they exist) 348 | for (int ct = 0; ct < 3; ct++){ 349 | if (CurrentConfig[ct] != "[N/A]" && CurrentConfig[ct] != "[UNKNOWN]" && 350 | CurrentConfig[ct] != "[CLOUD-ONLY]"){ 351 | ProgressMenu::Backup('C', CurrentConfig[ct], ct + 1); 352 | } 353 | } 354 | 355 | // Games 356 | } else if (op == 'G'){ 357 | // Backup the game folder and its manifest 358 | ProgressMenu::Backup('G', CurrentGame, 0); 359 | QFile::copy(QString::fromStdString(CurrentAppID), 360 | QString::fromStdString(MainMenu::BackupFolder + "/SteamManifests/" + AppManifest)); 361 | } 362 | 363 | // For Restore 364 | } else if (mode == 'R'){ 365 | // Saves 366 | if (op == 'S'){ 367 | // Restore each save folder (if they exist) 368 | for (int ct = 0; ct < 3; ct++){ 369 | if (CurrentSave[ct] != "[N/A]" && CurrentSave[ct] != "[UNKNOWN]" && 370 | CurrentSave[ct] != "[CLOUD-ONLY]"){ 371 | ProgressMenu::Restore('S', CurrentSave[ct], ct + 1); 372 | } 373 | } 374 | 375 | // Configs 376 | } else if (op == 'C') { 377 | // Restore each config folder (if they exist) 378 | for (int ct = 0; ct < 3; ct++){ 379 | if (CurrentConfig[ct] != "[N/A]" && CurrentConfig[ct] != "[UNKNOWN]" && 380 | CurrentConfig[ct] != "[CLOUD-ONLY]"){ 381 | ProgressMenu::Restore('C', CurrentConfig[ct], ct + 1); 382 | } 383 | } 384 | 385 | // Games 386 | } else if (op == 'G'){ 387 | // Restore the game folder and its manifest 388 | ProgressMenu::Restore('G', CurrentGame, 0); 389 | QFile::copy(QString::fromStdString(MainMenu::BackupFolder + "/SteamManifests/" + AppManifest), 390 | QString::fromStdString(CurrentAppID)); 391 | } 392 | } 393 | 394 | // ...and update progress bars accordingly 395 | GamesDone++; 396 | emit MainWindow::CopyThread->UpdateTotalProgress(GamesDone); 397 | } 398 | } 399 | 400 | TotalGames = 0; GamesDone = 0; // Reset counters 401 | 402 | // If process can continue (meaning it hasn't force stopped): 403 | if (ProgressMenu::StopProcess == false){ 404 | ProgressMenu::WriteBackupDate(op); // Write the current date and time on the database... 405 | emit MainWindow::CopyThread->UpdateResultsScreen(mode, op, QString::fromStdString(CurrentSubFolder)); // ...and emit a signal to bring the results screen 406 | } 407 | } 408 | 409 | // Delay for CancelCountdown, adapted from kshark27 on stackoverflow - https://stackoverflow.com/a/11487434 410 | void ProgressMenu::Delay(int sec){ 411 | QTime dieTime = QTime::currentTime().addSecs(sec); 412 | while (QTime::currentTime() < dieTime) 413 | QCoreApplication::processEvents(QEventLoop::AllEvents, 100); 414 | } 415 | 416 | // Countdown for foolproof Cancel button 417 | void ProgressMenu::CancelCountdown(){ 418 | int ct = 3; QString digit; // Setting time limit for cooldown (3 seconds) 419 | 420 | // Start the countdown 421 | while (ct > 0 && ProgressMenu::CancelCheck == true){ 422 | digit = QString::fromStdString(std::to_string(ct)); // Fetch new digit for label 423 | Window->ui->CancelWarningLabel->setText("Are you sure? Click again to confirm.\nIgnoring cancel request in " + digit + "..."); // Update label 424 | Delay(1); ct--; // Activate 1 second delay 425 | } 426 | 427 | // When countdown ends, resume process 428 | Window->ui->CancelWarningLabel->setText(""); 429 | ProgressMenu::CancelCheck = false; 430 | } 431 | -------------------------------------------------------------------------------- /src/progressmenu.h: -------------------------------------------------------------------------------- 1 | /* 2 | ========================================================================= 3 | ---[SLSK - Progress Menu functionalities (header file)]--- 4 | Copyright (C) 2017 Supremist (aka supremesonicbrazil) 5 | This file is part of Steam Linux Swiss Knife (or SLSK for short). 6 | Steam Linux Swiss Knife is available under the GNU GPL v3.0 license. See the 7 | accompanying COPYING file for more details. 8 | ========================================================================= 9 | */ 10 | 11 | #ifndef PROGRESSMENU_H 12 | #define PROGRESSMENU_H 13 | 14 | #include 15 | 16 | class ProgressThread : public QObject { 17 | Q_OBJECT 18 | 19 | public slots: 20 | static void Start(); 21 | 22 | signals: 23 | void StartProgressBars(int TotalGames); // Signal for setting progress bars 24 | void UpdateCopyingLabel(QString text); // Signal for updating copying label 25 | void UpdateCurrentProgress(int value); // Signal for updating current progress 26 | void UpdateHeaderLabel(char mode); // Signal for updating header label 27 | void UpdateGameLabel(QString text); // Signal for updating game label 28 | void UpdateTotalProgress(int value); // Signal for updating total progress 29 | void UpdateResultsScreen(char mode, char op, QString CurrentSubFolder); // Signal for bringing and updating results screen 30 | }; 31 | 32 | class ProgressMenu { 33 | public: 34 | static std::string CurrentFolder; 35 | static bool CancelCheck; 36 | static bool StopProcess; 37 | static void StartProcess(char mode, char op, QListWidget* gamelist); 38 | static void CancelCountdown(); 39 | 40 | private: 41 | static void SetBackupSubFolders(char op); 42 | static void FetchPaths(QString Game); 43 | static void Backup(char op, std::string path, int n); 44 | static void Restore(char op, std::string path, int n); 45 | static void Delay(int sec); 46 | static void WriteBackupDate(char op); 47 | }; 48 | 49 | #endif // PROGRESSMENU_H 50 | -------------------------------------------------------------------------------- /svg/SLSK_BG_vector.svg: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | 46 | 48 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 85 | 86 | 91 | 96 | 99 | 105 | 111 | 112 | 118 | 119 | -------------------------------------------------------------------------------- /svg/SLSK_icon_vector.svg: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | 47 | 49 | 57 | 61 | 65 | 69 | 73 | 77 | 81 | 85 | 86 | 94 | 98 | 102 | 106 | 110 | 114 | 118 | 122 | 123 | 131 | 135 | 139 | 143 | 147 | 151 | 155 | 159 | 160 | 168 | 172 | 176 | 180 | 184 | 188 | 192 | 196 | 197 | 198 | 201 | 204 | 210 | 214 | 218 | 224 | 230 | 231 | 237 | 238 | 244 | 245 | 251 | 254 | 258 | 264 | 270 | 271 | 277 | 278 | 284 | 287 | 292 | 297 | 300 | 306 | 312 | 313 | 319 | 320 | 321 | 322 | --------------------------------------------------------------------------------