1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
/*
* Copyright 2014 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Martin Preisler <mpreisle@redhat.com>
*/
#ifndef SCAP_WORKBENCH_UTILS_H_
#define SCAP_WORKBENCH_UTILS_H_
#include "ForwardDecls.h"
#include <QString>
#include <QDir>
#include <QIcon>
#include <QUrl>
#include <QTemporaryFile>
#include <QTemporaryDir>
/**
* @brief Retrieves QDir representing the share directory
*
* For installed scap-workbench the output's path usually looks like this:
* "$INSTALL_PREFIX/share/scap-workbench", e.g.: /usr/share/scap-workbench
*
* If workbench has not been installed and is being run using the runwrapper.sh
* script, the path will be different and will point to the data location
* in the repository.
*
* Avoid using hardcoded paths in the codebase and always use paths relative
* to the share path.
*
* @exception nothrow This function is guaranteed to not throw any exceptions.
*/
const QDir& getShareDirectory();
/**
* @brief Retrieves QDir representing the doc directory
*
* For installed scap-workbench the output's path usually looks like this:
* "$INSTALL_PREFIX/share/doc/scap-workbench", e.g.: /usr/share/doc/scap-workbench
*
* If workbench has not been installed and is being run using the runwrapper.sh
* script, the path will be different and will point to the data location
* in the repository.
*
* Avoid using hardcoded paths in the codebase and always use paths relative
* to the doc path.
*
* @exception nothrow This function is guaranteed to not throw any exceptions.
*/
const QDir& getDocDirectory();
/**
* @brief Retrieves QDir representing the SSG directory
*
* For installed scap-workbench the output's path usually looks like this:
* "/$INSTALL_PREFIX/share/xml/scap/ssg", e.g.: /usr/share/xml/scap/ssg
*
* Avoid using hardcoded paths in the codebase and always use paths relative
* to the doc path.
*
* @exception nothrow This function is guaranteed to not throw any exceptions.
*/
const QDir& getSSGDirectory();
/**
* @brief Constructs a QIcon from image of given filename
*
* This function looks for the file in the icon folder in workbench's share path.
* Using this function to get an icon is preferable to constructing it manually.
*
* @exception nothrow This function is guaranteed to not throw any exceptions.
* @note This function will write a warning to stderr in case the icon cannot be loaded.
*/
QIcon getShareIcon(const QString& fileName);
QPixmap getSharePixmap(const QString& fileName);
/**
* @brief Retrieves the global application icon
*
* @exception nothrow This function is guaranteed to not throw any exceptions.
* @note This function will write a warning to stderr in case the icon cannot be loaded.
*/
const QIcon& getApplicationIcon();
/**
* @brief Retrieves the QDir representing the directory with translations
*
* @exception nothrow This function is guaranteed to not throw any exceptions.
*/
const QDir& getShareTranslationDirectory();
/**
* @brief Calls QDesktopServices::openUrl, shows a message box in case of failure
*
* @param url URL to open
*/
void openUrlGuarded(const QUrl& url);
/**
* @brief Retrieves path to setsid
*/
const QString& getSetSidPath();
class SpacelessQTemporaryFile: public QTemporaryFile {
public:
SpacelessQTemporaryFile ();
};
class SpacelessQTemporaryDir: public QTemporaryDir {
public:
SpacelessQTemporaryDir ();
};
#endif
|