Tools.
More...
#include <RabbitCommonTools.h>
|
| enum class | TranslationType { Application
, Library
, Plugin
} |
| |
|
| void | Init (QString szApplicationName=QCoreApplication::applicationName(), QString szApplicationDirPath=QCoreApplication::applicationDirPath(), QString szApplicationInstallRoot=QString(), const QString szLanguage=GetLanguage()) |
| | Initialize the resource, which is called only once at the beginning of the program,.
|
| |
| void | Init (int argc, char *argv[], QString szApplicationName=QString()) |
| | Init.
|
| |
| void | Clean () |
| |
| QSharedPointer< QTranslator > | InstallTranslator (const QString szName=QString(), TranslationType type=TranslationType::Application, const QString szPluginDir="plugins", const QString szLanguage=GetLanguage()) |
| | Install translation.
|
| |
| int | RemoveTranslator (QSharedPointer< QTranslator > translator) |
| |
Tools.
Definition at line 43 of file RabbitCommonTools.h.
◆ TranslationType
| enum class RabbitCommon::CTools::TranslationType |
|
strong |
◆ CTools()
| RabbitCommon::CTools::CTools |
( |
| ) |
|
|
private |
◆ ~CTools()
| RabbitCommon::CTools::~CTools |
( |
| ) |
|
|
privatevirtual |
◆ AndroidRequestPermission() [1/2]
| int RabbitCommon::CTools::AndroidRequestPermission |
( |
const QString & |
permission | ) |
|
|
static |
◆ AndroidRequestPermission() [2/2]
| int RabbitCommon::CTools::AndroidRequestPermission |
( |
const QStringList & |
permissions | ) |
|
|
static |
◆ Clean()
| void RabbitCommon::CTools::Clean |
( |
| ) |
|
- Note
- Free up the resource and call it only once before the program ends
Definition at line 417 of file RabbitCommonTools.cpp.
◆ CleanResource()
| void RabbitCommon::CTools::CleanResource |
( |
| ) |
|
|
private |
◆ EnableCoreDump()
| bool RabbitCommon::CTools::EnableCoreDump |
( |
bool |
bPrompt = true | ) |
|
|
static |
Enable core dump.
- Parameters
-
- Note
- It must be called first in the main function
Definition at line 552 of file RabbitCommonTools.cpp.
◆ executeByRoot()
| bool RabbitCommon::CTools::executeByRoot |
( |
const QString & |
program, |
|
|
const QStringList & |
arguments = QStringList() |
|
) |
| |
|
static |
◆ ExecuteWithAdministratorPrivilege()
| bool RabbitCommon::CTools::ExecuteWithAdministratorPrivilege |
( |
const QString & |
program, |
|
|
const QStringList & |
arguments = QStringList(), |
|
|
bool |
bDetached = true |
|
) |
| |
|
static |
◆ GenerateDesktopFile()
| int RabbitCommon::CTools::GenerateDesktopFile |
( |
const QString & |
szPath = QString(), |
|
|
const QString & |
szName = QString() |
|
) |
| |
|
static |
GenerateDesktopFile: Generate desktop file.
- Parameters
-
| szPath | the path of desktop file. |
| szName | the name of desktop file. Default: "org.Rabbit." + qApp->applicationName() + ".desktop" |
Definition at line 728 of file RabbitCommonTools.cpp.
◆ GetCurrentUser()
| QString RabbitCommon::CTools::GetCurrentUser |
( |
| ) |
|
|
static |
◆ GetHostName()
| QString RabbitCommon::CTools::GetHostName |
( |
| ) |
|
|
static |
◆ GetLanguage()
| QString RabbitCommon::CTools::GetLanguage |
( |
| ) |
|
|
static |
Get language Acquisition order:
- Environment Variable (LANG)
- The value set by SetLanguage().
- QLocale::system().name()
Definition at line 157 of file RabbitCommonTools.cpp.
◆ HasAdministratorPrivilege()
| bool RabbitCommon::CTools::HasAdministratorPrivilege |
( |
| ) |
|
|
static |
◆ Information()
| QString RabbitCommon::CTools::Information |
( |
| ) |
|
|
static |
◆ Init() [1/2]
| void RabbitCommon::CTools::Init |
( |
int |
argc, |
|
|
char * |
argv[], |
|
|
QString |
szApplicationName = QString() |
|
) |
| |
Init.
It can called before QApplication a(argc, argv); It is parse the application name and path from command line parameters.
- Parameters
-
| szApplicationName | Set if the application name is not same the program. |
- See also
- void Init()
Definition at line 307 of file RabbitCommonTools.cpp.
◆ Init() [2/2]
| void RabbitCommon::CTools::Init |
( |
QString |
szApplicationName = QCoreApplication::applicationName(), |
|
|
QString |
szApplicationDirPath = QCoreApplication::applicationDirPath(), |
|
|
QString |
szApplicationInstallRoot = QString(), |
|
|
const QString |
szLanguage = GetLanguage() |
|
) |
| |
Initialize the resource, which is called only once at the beginning of the program,.
- Note
- Be called after QApplication a(argc, argv) at the beginning of the main() function
int main(int argc, char* argv[]) {
QApplication a(argc, argv);
a.setApplicationName(......);
RabbitCommon::CTools::Instance->
Init();
......
}
- If you are called before QApplication a(argc, argv)
- you need to call:
- QCoreApplication::setApplicationName()
- CDir::Instance()->SetDirApplication()
- CDir::Instance()->SetDirApplicationInstallRoot()
int main(int argc, char* argv[]) {
QCoreApplication::setApplicationName(...);
CDir::Instance()->SetDirApplication(...);
CDir::Instance()->SetDirApplicationInstallRoot(...);
RabbitCommon::CTools::Instance->
Init();
QApplication a(argc, argv);
......
}
- Be called with the parameters
int main(int argc, char* argv[]) {
RabbitCommon::CTools::Instance->
Init(szName, szPath, szInstallRoot);
QApplication a(argc, argv);
......
}
- See also
- Init(int argc, char* argv[], QString szApplicationName)
Definition at line 325 of file RabbitCommonTools.cpp.
◆ InitResource()
| void RabbitCommon::CTools::InitResource |
( |
| ) |
|
|
private |
◆ InstallStartRun()
| int RabbitCommon::CTools::InstallStartRun |
( |
const QString & |
szName = QString(), |
|
|
const QString & |
szPath = QString(), |
|
|
bool |
bAllUser = false |
|
) |
| |
|
static |
InstallStartRun: auto run when startup.
- Parameters
-
| szName | The programe name
- Windows: is programe name
- Linux: the name of desktop file.
|
| szPath | |
| bAllUser |
- true: all user
- false: current user
|
Definition at line 639 of file RabbitCommonTools.cpp.
◆ InstallTranslator()
| QSharedPointer< QTranslator > RabbitCommon::CTools::InstallTranslator |
( |
const QString |
szName = QString(), |
|
|
TranslationType |
type = TranslationType::Application, |
|
|
const QString |
szPluginDir = "plugins", |
|
|
const QString |
szLanguage = GetLanguage() |
|
) |
| |
Install translation.
- Parameters
-
| szName | translation name |
| szLanguage | language |
| type | TranslationType |
| szPluginDir | plugin directory |
- Returns
- QSharedPointer<QTranslator>
- See also
- CDir::GetDirTranslations cmake/Translations.cmake
Definition at line 453 of file RabbitCommonTools.cpp.
◆ InstallTranslatorFile()
| QSharedPointer< QTranslator > RabbitCommon::CTools::InstallTranslatorFile |
( |
const QString |
szFile | ) |
|
|
private |
◆ Instance()
| CTools * RabbitCommon::CTools::Instance |
( |
| ) |
|
|
static |
◆ IsStartRun()
| bool RabbitCommon::CTools::IsStartRun |
( |
const QString & |
szName = QString(), |
|
|
bool |
bAllUser = false |
|
) |
| |
|
static |
◆ MarkDownToHtml()
| QString RabbitCommon::CTools::MarkDownToHtml |
( |
const QString & |
szText | ) |
|
|
static |
◆ RemoveStartRun()
| int RabbitCommon::CTools::RemoveStartRun |
( |
const QString & |
szName = QString(), |
|
|
bool |
bAllUser = false |
|
) |
| |
|
static |
◆ RemoveTranslator()
| int RabbitCommon::CTools::RemoveTranslator |
( |
QSharedPointer< QTranslator > |
translator | ) |
|
◆ SetLanguage()
| int RabbitCommon::CTools::SetLanguage |
( |
const QString |
szLanguage | ) |
|
|
static |
◆ StartWithAdministratorPrivilege()
| bool RabbitCommon::CTools::StartWithAdministratorPrivilege |
( |
bool |
bQuitOld = false | ) |
|
|
static |
Start program with administrator privilege.
- Parameters
-
| bQuitOld | true, quit the old program |
- Returns
Definition at line 597 of file RabbitCommonTools.cpp.
◆ Version()
| QString RabbitCommon::CTools::Version |
( |
| ) |
|
|
static |
◆ m_bShowMaxWindow
| bool RabbitCommon::CTools::m_bShowMaxWindow |
|
private |
◆ m_Initialized
| bool RabbitCommon::CTools::m_Initialized |
|
private |
◆ m_Translator
| QVector<QSharedPointer<QTranslator> > RabbitCommon::CTools::m_Translator |
|
private |
The documentation for this class was generated from the following files: