--- s10k/CommonUtils/util.cpp 2017/10/05 17:48:32 1073 +++ s10k/CommonUtils/util.cpp 2019/02/16 17:23:09 1109 @@ -1,5 +1,5 @@ /** - * Copyright (C) 2017 - Fábio Bento (random-guy) + * Copyright (C) 2017 - 2018 Fábio Bento (fabiobento512) * * This library is distributed under the MIT License. See notice at the end * of this file. @@ -68,7 +68,7 @@ bool rmDir(const QString &dirPath) QDir dir(dirPath); if (!dir.exists()) return true; - foreach(const QFileInfo &info, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { + for(const QFileInfo &info : dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { if (info.isDir()) { if (!rmDir(info.filePath())) return false; @@ -180,8 +180,13 @@ QString getAppPath(){ #endif } -bool backupFile(QString file){ - return QFile::copy(file,file+".bak"); +bool backupFile(const QString &file, QString newFilename){ + + if(newFilename.isEmpty()){ + newFilename = file; + } + + return QFile::copy(file, newFilename+".bak"); } } @@ -260,37 +265,31 @@ const char* boolToCstr(bool currentBoole #ifdef QT_GUI_LIB namespace Dialogs { -void showInfo(const QString &message){ +void showInfo(const QString &message, const bool richText){ QMessageBox msgBox; + if(richText){ + msgBox.setTextFormat(Qt::RichText); + } msgBox.setIcon(QMessageBox::Information); msgBox.setText(message); msgBox.exec(); } -void showRichInfo(const QString &message){ - QMessageBox msgBox; - msgBox.setTextFormat(Qt::RichText); - msgBox.setIcon(QMessageBox::Information); - msgBox.setText(message); - msgBox.exec(); -} - -void showWarning(const QString &message){ +void showWarning(const QString &message, const bool richText){ QMessageBox msgBox; + if(richText){ + msgBox.setTextFormat(Qt::RichText); + } msgBox.setIcon(QMessageBox::Warning); msgBox.setText(message); msgBox.exec(); } -void showError(const QString &message){ - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Critical); - msgBox.setText(message); - msgBox.exec(); -} - -void showRichError(const QString &message){ +void showError(const QString &message, const bool richText){ QMessageBox msgBox; + if(richText){ + msgBox.setTextFormat(Qt::RichText); + } msgBox.setIcon(QMessageBox::Critical); msgBox.setText(message); msgBox.exec(); @@ -333,7 +332,7 @@ namespace Validation { // Check if any string in the list is empty bool checkEmptySpaces(QStringList toCheck){ - foreach (QString current, toCheck){ + for (const QString ¤t : toCheck){ if(current.trimmed().isEmpty()){ return true; //There are empty spaces } @@ -342,7 +341,7 @@ bool checkEmptySpaces(QStringList toChec } bool checkIfIntegers(QStringList toCheck){ - foreach (QString current, toCheck){ + for (const QString ¤t : toCheck){ if(!isStringInteger(current)){ return true; // Some aren't valid integers } @@ -351,7 +350,7 @@ bool checkIfIntegers(QStringList toCheck } bool checkIfDoubles(QStringList toCheck){ - foreach (QString current, toCheck){ + for (const QString ¤t : toCheck){ if(!isStringDouble(current)){ return true; // Some aren't valid doubles } @@ -532,6 +531,15 @@ void deleteSelectedRows(QTableWidget *my #ifdef QT_GUI_LIB namespace StatusBar { +void showInfo(QStatusBar * const statusBar, const QString &message){ + + QPalette myPalete = QPalette(); + myPalete.setColor( QPalette::WindowText, QColor(0,38,255)); + statusBar->setPalette( myPalete ); + statusBar->showMessage(message,10000); //display by 10 seconds + +} + void showError(QStatusBar * const statusBar, const QString &message){ QPalette myPalete = QPalette(); @@ -557,7 +565,7 @@ void showSuccess(QStatusBar * const stat /** - * Copyright (c) 2017 - Fábio Bento (random-guy) + * Copyright (c) 2017 - 2018 Fábio Bento (fabiobento512) * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation