1 /************************************************************************** 2 * Copyright (C) 2005-2020 by Oleksandr Shneyder * 3 * <o.shneyder@phoca-gmbh.de> * 4 * Copyright (C) 2016-2020 by Mihai Moldovan <ionic@ionic.de> * 5 * * 6 * This program is free software; you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation; either version 2 of the License, or * 9 * (at your option) any later version. * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. * 17 ***************************************************************************/ 18 19 #ifndef X2GOUTILS_H 20 #define X2GOUTILS_H 21 22 #include <QString> 23 #include <QFont> 24 #include <QMessageBox> 25 26 #ifndef UNUSED 27 #define UNUSED(x) do { (void) x; } while (0) 28 #endif 29 30 #ifndef MACPORTS_PREFIX 31 #define MACPORTS_PREFIX "/opt/local" 32 #endif 33 34 QString expandHome (QString path); 35 36 QString fixup_resource_URIs (const QString &res_path); 37 38 QString wrap_legacy_resource_URIs (const QString &res_path); 39 40 QString convert_to_rich_text (const QString &text, bool force = false); 41 42 void show_RichText_Generic_MsgBox (QMessageBox::Icon icon, const QString &main_text, const QString &informative_text, bool app_modal = false); 43 void show_RichText_WarningMsgBox (const QString &main_text, const QString &informative_text = "", bool app_modal = false); 44 void show_RichText_ErrorMsgBox (const QString &main_text, const QString &informative_text = "", bool app_modal = false); 45 46 QString git_changelog_extract_commit_sha (const QString &gitlog); 47 48 bool font_is_monospaced (const QFont &font); 49 50 #ifdef Q_OS_DARWIN 51 void show_XQuartz_not_found_error (); 52 void show_XQuartz_start_error (); 53 void show_XQuartz_generic_error (const QString &main_error, const QString &additional_info); 54 #endif /* defined (Q_OS_DARWIN) */ 55 56 #ifdef Q_OS_UNIX 57 /* 58 * Add a list of strings to a PATH value. 59 * 60 * If back is true (the default), each entry is (potentially) appended to the original 61 * PATH value, if not already existing within the original PATH value. 62 * Ex.: <orig_path>:<add_entry1>:<add_entry2>:... 63 * 64 * Otherwise, each entry is prepended to the original PATH value, if not already existing. 65 * Ex.: <add_entry1>:<add_entry2>:...:<orig_path> 66 */ 67 QString add_to_path (const QString &orig_path, const QStringList &add, const bool back = true); 68 69 /* 70 * Returns the first existing path that contains binary_name. 71 * Iff no component contains a binary called binary_name, an empty path is returned. 72 * 73 * Iff path is empty, (only) the current working dir is searched. 74 */ 75 QString find_binary (const QString &path, const QString &binary_name); 76 #endif /* defined (Q_OS_UNIX) */ 77 78 #endif /* !defined (X2GOUTILS_H) */ 79