Parcourir la source

Renaming some more classes

Felix Turo il y a 2 ans
Parent
commit
3106aa37dd

+ 4 - 4
CMakeLists.txt

@@ -77,14 +77,14 @@ set(PROJECT_SOURCES
 
 
     # Classes
-    src/classes/astyle.h
-    src/classes/astyle.cpp
+    src/classes/style.h
+    src/classes/style.cpp
     src/classes/paths.h
     src/classes/paths.cpp
     src/classes/downloadhelper.h
     src/classes/downloadhelper.cpp
-    src/classes/arunguard.h
-    src/classes/arunguard.cpp
+    src/classes/runguard.h
+    src/classes/runguard.cpp
     src/classes/asettings.h
     src/classes/asettings.cpp
     src/classes/translator.h

+ 4 - 4
main.cpp

@@ -19,10 +19,10 @@
 #include "src/opl.h"
 #include "src/functions/log.h"
 #include "src/gui/dialogues/firstrundialog.h"
-#include "src/classes/arunguard.h"
+#include "src/classes/runguard.h"
 #include "src/classes/asettings.h"
 #include "src/classes/asettings.h"
-#include "src/classes/astyle.h"
+#include "src/classes/style.h"
 #include "src/functions/log.h"
 #include "src/classes/paths.h"
 #include <QApplication>
@@ -59,7 +59,7 @@ void init()
     LOG << "Reading Settings...";
     ASettings::setup();
     LOG << "Setting up application style...";
-    AStyle::setup();
+    OPL::Style::setup();
     // Translations to be done at a later stage
     //LOG << "Installing translator...";
     //ATranslator::installTranslator(OPL::Translations::English);
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
     QCoreApplication::setApplicationName(APPNAME);
 
     // Check for another instance already running
-    ARunGuard guard(QStringLiteral("opl_single_key"));
+    RunGuard guard(QStringLiteral("opl_single_key"));
     if ( !guard.tryToRun() ){
         LOG << "Another Instance of openPilotLog is already running. Exiting.";
         return 0;

+ 6 - 5
mainwindow.cpp

@@ -19,10 +19,11 @@
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
 #include "src/database/database.h"
-#include "src/classes/astyle.h"
+#include "src/classes/style.h"
 #include "src/gui/dialogues/firstrundialog.h"
 #include "src/gui/dialogues/newflightdialog.h"
 #include "src/gui/dialogues/newsimdialog.h"
+#include "src/gui/dialogues/newflightdialog.h"
 // Quick and dirty Debug area
 #include "src/classes/paths.h"
 void MainWindow::doDebugStuff()
@@ -44,7 +45,7 @@ MainWindow::MainWindow(QWidget *parent)
 {
     ui->setupUi(this);
     setupToolbar();
-    setActionIcons(AStyle::getStyleType());
+    setActionIcons(OPL::Style::getStyleType());
 
     // connect to the Database
     if (OPL::Paths::databaseFileInfo().size() == 0)
@@ -114,10 +115,10 @@ void MainWindow::setupToolbar()
     addToolBar(Qt::ToolBarArea::LeftToolBarArea, toolBar);
 }
 
-void MainWindow::setActionIcons(StyleType style)
+void MainWindow::setActionIcons(OPL::Style::StyleType style)
 {
     switch (style){
-    case StyleType::Light:
+    case OPL::Style::StyleType::Light:
         LOG << "Setting Light Icon theme";
         ui->actionHome->setIcon(QIcon(OPL::Assets::ICON_TOOLBAR_HOME));
         ui->actionNewFlight->setIcon(QIcon(OPL::Assets::ICON_TOOLBAR_NEW_FLIGHT));
@@ -129,7 +130,7 @@ void MainWindow::setActionIcons(StyleType style)
         ui->actionSettings->setIcon(QIcon(OPL::Assets::ICON_TOOLBAR_SETTINGS));
         ui->actionQuit->setIcon(QIcon(OPL::Assets::ICON_TOOLBAR_QUIT));
         break;
-    case StyleType::Dark:
+    case OPL::Style::StyleType::Dark:
         LOG << "Setting Dark Icon theme";
         ui->actionHome->setIcon(QIcon(OPL::Assets::ICON_TOOLBAR_HOME_DARK));
         ui->actionNewFlight->setIcon(QIcon(OPL::Assets::ICON_TOOLBAR_NEW_FLIGHT_DARK));

+ 3 - 8
mainwindow.h

@@ -37,12 +37,7 @@
 #include "src/gui/widgets/airportwidget.h"
 #include "src/gui/widgets/pilotswidget.h"
 #include "src/gui/widgets/debugwidget.h"
-#include "src/gui/dialogues/newtaildialog.h"
-#include "src/gui/dialogues/newpilotdialog.h"
-#include "src/gui/dialogues/newflightdialog.h"
-#include "src/classes/arunguard.h"
-#include "src/testing/atimer.h"
-#include "src/classes/astyle.h"
+#include "src/classes/style.h"
 #include "src/database/dbcompletiondata.h"
 
 enum Style {Light, Dark};
@@ -97,7 +92,7 @@ public:
 public slots:
     void onStyleChanged(SettingsWidget::SettingSignal signal){
         if (signal == SettingsWidget::MainWindow)
-            setActionIcons(AStyle::getStyleType());
+            setActionIcons(OPL::Style::getStyleType());
     }
 
 private slots:
@@ -146,7 +141,7 @@ private:
     bool airportDbIsDirty = false;
 
     void setupToolbar();
-    void setActionIcons(StyleType style = StyleType::Light);
+    void setActionIcons(OPL::Style::StyleType style = OPL::Style::StyleType::Light);
 
     void nope();
 

+ 6 - 6
src/classes/arunguard.cpp → src/classes/runguard.cpp

@@ -15,7 +15,7 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#include "arunguard.h"
+#include "runguard.h"
 
 #include <QCryptographicHash>
 
@@ -37,7 +37,7 @@ QString generateKeyHash(const QString &key, const QString &salt)
 }
 
 
-ARunGuard::ARunGuard(const QString &key )
+RunGuard::RunGuard(const QString &key )
     : key(key )
     , memLockKey(generateKeyHash(key, "_memLockKey" ))
     , sharedmemKey(generateKeyHash(key, "_sharedmemKey" ))
@@ -52,12 +52,12 @@ ARunGuard::ARunGuard(const QString &key )
     memLock.release();
 }
 
-ARunGuard::~ARunGuard()
+RunGuard::~RunGuard()
 {
     release();
 }
 
-bool ARunGuard::isAnotherRunning()
+bool RunGuard::isAnotherRunning()
 {
     if (sharedMem.isAttached())
         return false;
@@ -71,7 +71,7 @@ bool ARunGuard::isAnotherRunning()
     return isRunning;
 }
 
-bool ARunGuard::tryToRun()
+bool RunGuard::tryToRun()
 {
     if (isAnotherRunning())  // Extra check
         return false;
@@ -88,7 +88,7 @@ bool ARunGuard::tryToRun()
     return true;
 }
 
-void ARunGuard::release()
+void RunGuard::release()
 {
     memLock.acquire();
     if (sharedMem.isAttached())

+ 7 - 7
src/classes/arunguard.h → src/classes/runguard.h

@@ -15,8 +15,8 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#ifndef ARUNGUARD_H
-#define ARUNGUARD_H
+#ifndef RUNGUARD_H
+#define RUNGUARD_H
 
 #include <QObject>
 #include <QSharedMemory>
@@ -26,12 +26,12 @@
  * \brief The RunGuard class ensures only a single instance of the application
  * is running simultaneously.
  */
-class ARunGuard
+class RunGuard
 {
 
 public:
-    ARunGuard(const QString &key);
-    ~ARunGuard();
+    RunGuard(const QString &key);
+    ~RunGuard();
 
     bool isAnotherRunning();
     bool tryToRun();
@@ -45,8 +45,8 @@ private:
     QSharedMemory sharedMem;
     QSystemSemaphore memLock;
 
-    Q_DISABLE_COPY(ARunGuard)
+    Q_DISABLE_COPY(RunGuard)
 };
 
 
-#endif // ARUNGUARD_H
+#endif // RUNGUARD_H

+ 18 - 17
src/classes/astyle.cpp → src/classes/style.cpp

@@ -25,31 +25,30 @@
  * https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle
  *
  */
-#include "astyle.h"
 #include "src/opl.h"
+#include "style.h"
+#include "src/classes/asettings.h"
 #include <QStyle>
 #include <QStyleFactory>
 #include <QApplication>
 #include <QFont>
-#include "src/classes/asettings.h"
-#include "src/functions/log.h"
 
-const QString AStyle::defaultStyle = QLatin1String("Fusion");
+namespace OPL {
 
-const QStringList AStyle::styles = QStyleFactory::keys();
+const QStringList Style::styles = QStyleFactory::keys();
 
-const QList<StyleSheet> AStyle::styleSheets = {
+const QList<StyleSheet> Style::styleSheets = {
     {QLatin1String("Breeze"),      QLatin1String(":breeze_light.qss")},
     {QLatin1String("Breeze-Dark"), QLatin1String(":breeze_dark.qss")},
     {QLatin1String("QDarkStyle"),  QLatin1String(":qdarkstyle/qdarkstyle.qss")},
 };
 
-QString AStyle::currentStyle = defaultStyle;
-QLatin1String AStyle::DARK_PALETTE = QLatin1String("Dark-Palette");
+QString Style::currentStyle = defaultStyle;
+QLatin1String Style::DARK_PALETTE = QLatin1String("Dark-Palette");
 /*!
  * \brief Setup Application style by reading from openPilotLog.ini
  */
-void AStyle::setup()
+void Style::setup()
 {
     if (!ASettings::read(ASettings::Main::SetupComplete).toBool()) // Use system default for first run
         return;
@@ -64,7 +63,7 @@ void AStyle::setup()
     QString style_setting = ASettings::read(ASettings::Main::Style).toString();
 
     if (style_setting == DARK_PALETTE) {
-        AStyle::setStyle(AStyle::darkPalette());
+        Style::setStyle(Style::darkPalette());
         ASettings::write(ASettings::Main::Style, style_setting);
         return;
     }
@@ -84,7 +83,7 @@ void AStyle::setup()
     }
 }
 
-void AStyle::resetStyle()
+void Style::resetStyle()
 {
     qApp->setStyle(QStyleFactory::create(defaultStyle));
     qApp->setStyleSheet(QString());
@@ -92,7 +91,7 @@ void AStyle::resetStyle()
 
 }
 
-void AStyle::setStyle(const QString &style_key)
+void Style::setStyle(const QString &style_key)
 {
     resetStyle();
     LOG << "Setting style: " << style_key;
@@ -100,7 +99,7 @@ void AStyle::setStyle(const QString &style_key)
     currentStyle = style_key;
 }
 
-void AStyle::setStyle(const StyleSheet &style_sheet)
+void Style::setStyle(const StyleSheet &style_sheet)
 {
     resetStyle();
     LOG << "Setting stylesheet: " << style_sheet.styleSheetName;
@@ -108,7 +107,7 @@ void AStyle::setStyle(const StyleSheet &style_sheet)
     currentStyle = style_sheet.styleSheetName;
 }
 
-void AStyle::setStyle(const QPalette &palette)
+void Style::setStyle(const QPalette &palette)
 {
     resetStyle();
     LOG << "Setting Colour Palette...";
@@ -116,7 +115,7 @@ void AStyle::setStyle(const QPalette &palette)
     qApp->setPalette(palette);
 }
 
-StyleType AStyle::getStyleType()
+Style::StyleType Style::getStyleType()
 {
     const QStringList darkStyles = {
         QStringLiteral("Breeze-Dark"),
@@ -130,7 +129,7 @@ StyleType AStyle::getStyleType()
         return StyleType::Light;
 }
 
-QPalette AStyle::darkPalette()
+QPalette Style::darkPalette()
 {
     auto palette = QPalette();
     //palette.setColor(QPalette::Window, QColor(53, 53, 53));
@@ -175,7 +174,9 @@ QPalette AStyle::darkPalette()
 
 }
 
-const QString& AStyle::style()
+const QString& Style::style()
 {
     return currentStyle;
 }
+
+} // namespace OPL

+ 13 - 8
src/classes/astyle.h → src/classes/style.h

@@ -15,15 +15,15 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#ifndef ASTYLE_H
-#define ASTYLE_H
+#ifndef STYLE_H
+#define STYLE_H
 #include <QString>
 #include <QFileInfo>
 #include <QHash>
 #include <QTextStream>
 #include <QComboBox>
 
-enum class StyleType {Light, Dark};
+namespace OPL {
 
 /*!
  * \brief The StyleSheet struct holds the Display Name and File Name (in the
@@ -49,15 +49,18 @@ static inline QString read_stylesheet(const QString &stylesheet)
 /*!
  * \brief The AStyle class encapsulates style and stylesheet logic.
  */
-class AStyle
+class Style
 {
 private:
     static QString currentStyle;
     static QLatin1String DARK_PALETTE;
     static void resetStyle();
 public:
+
+    enum class StyleType {Light, Dark};
+
     static const QStringList styles;
-    static const QString defaultStyle;
+    static const inline QString defaultStyle = QStringLiteral("Fusion");
     static const QList<StyleSheet> styleSheets;
 
     static void setup();
@@ -71,8 +74,8 @@ public:
 
     static inline void loadStylesComboBox(QComboBox *combo_box){
         const QSignalBlocker blocker(combo_box);
-        combo_box->addItems(AStyle::styles);
-        for (const auto &style_sheet : AStyle::styleSheets) {
+        combo_box->addItems(Style::styles);
+        for (const auto &style_sheet : Style::styleSheets) {
             combo_box->addItem(style_sheet.styleSheetName);
         }
         combo_box->addItem(QStringLiteral("Dark-Palette"));
@@ -80,4 +83,6 @@ public:
     }
 };
 
-#endif // ASTYLE_H
+} // namespace OPL
+
+#endif // STYLE_H

+ 8 - 8
src/gui/dialogues/firstrundialog.cpp

@@ -25,7 +25,7 @@
 #include "src/classes/downloadhelper.h"
 #include "src/classes/asettings.h"
 #include "src/functions/adate.h"
-#include "src/classes/astyle.h"
+#include "src/classes/style.h"
 #include "src/classes/md5sum.h"
 #include <QErrorMessage>
 #include <QFileDialog>
@@ -49,8 +49,8 @@ FirstRunDialog::FirstRunDialog(QWidget *parent) :
 
     // Style combo box
     const QSignalBlocker style_blocker(ui->styleComboBox);
-    AStyle::loadStylesComboBox(ui->styleComboBox);
-    ui->styleComboBox->setCurrentText(AStyle::defaultStyle);
+    OPL::Style::loadStylesComboBox(ui->styleComboBox);
+    ui->styleComboBox->setCurrentText(OPL::Style::defaultStyle);
 
     // Prepare Date Edits
     const auto date_edits = this->findChildren<QDateEdit *>();
@@ -401,18 +401,18 @@ void FirstRunDialog::keyPressEvent(QKeyEvent *keyEvent)
 void FirstRunDialog::on_styleComboBox_currentTextChanged(const QString &new_style_setting)
 {
     if (new_style_setting == QLatin1String("Dark-Palette")) {
-        AStyle::setStyle(AStyle::darkPalette());
+        OPL::Style::setStyle(OPL::Style::darkPalette());
         return;
     }
-    for (const auto &style_name : AStyle::styles) {
+    for (const auto &style_name : OPL::Style::styles) {
         if (new_style_setting == style_name) {
-            AStyle::setStyle(style_name);
+            OPL::Style::setStyle(style_name);
             return;
         }
     }
-    for (const auto &style_sheet : AStyle::styleSheets) {
+    for (const auto &style_sheet : OPL::Style::styleSheets) {
         if (new_style_setting == style_sheet.styleSheetName) {
-            AStyle::setStyle(style_sheet);
+            OPL::Style::setStyle(style_sheet);
             return;
         }
     }

+ 13 - 13
src/gui/widgets/settingswidget.cpp

@@ -17,7 +17,7 @@
  */
 #include "settingswidget.h"
 #include "ui_settingswidget.h"
-#include "src/classes/astyle.h"
+#include "src/classes/style.h"
 #include "src/classes/asettings.h"
 #include "src/database/database.h"
 #include "src/database/row.h"
@@ -55,7 +55,7 @@ void SettingsWidget::changeEvent(QEvent *event)
 void SettingsWidget::setupComboBoxes(){
     {
         // Set up Combo Boxes
-        AStyle::loadStylesComboBox(ui->styleComboBox);
+        OPL::Style::loadStylesComboBox(ui->styleComboBox);
         OPL::GLOBALS->loadApproachTypes(ui->approachComboBox);
         OPL::GLOBALS->loadPilotFunctios(ui->functionComboBox);
         OPL::GLOBALS->fillViewNamesComboBox(ui->logbookViewComboBox);
@@ -146,7 +146,7 @@ void SettingsWidget::readSettings()
     ui->acftSortComboBox->setCurrentIndex(ASettings::read(ASettings::UserData::TailSortColumn).toInt());
     ui->pilotSortComboBox->setCurrentIndex(ASettings::read(ASettings::UserData::PilotSortColumn).toInt());
 
-    // Don't emit signals for style changes during setup
+    // Don't emit signals for OPL::Style changes during setup
     const QSignalBlocker style_blocker(ui->styleComboBox);
     const QSignalBlocker font_blocker_1(ui->fontSpinBox);
     const QSignalBlocker font_blocker_2(ui->fontComboBox);
@@ -386,23 +386,23 @@ void SettingsWidget::on_aboutPushButton_clicked()
 void SettingsWidget::on_styleComboBox_currentTextChanged(const QString& new_style_setting)
 {
     if (new_style_setting == QLatin1String("Dark-Palette")) {
-        AStyle::setStyle(AStyle::darkPalette());
+        OPL::Style::setStyle(OPL::Style::darkPalette());
         ASettings::write(ASettings::Main::Style, new_style_setting);
         emit settingChanged(MainWindow);
         return;
     }
-    for (const auto &style_name : AStyle::styles) {
+    for (const auto &style_name : OPL::Style::styles) {
         if (new_style_setting == style_name) {
-            AStyle::setStyle(style_name);
+            OPL::Style::setStyle(style_name);
             ASettings::write(ASettings::Main::Style, new_style_setting);
             emit settingChanged(MainWindow);
             return;
         }
     }
 
-    for (const auto &style_sheet : AStyle::styleSheets) {
+    for (const auto &style_sheet : OPL::Style::styleSheets) {
         if (new_style_setting == style_sheet.styleSheetName) {
-            AStyle::setStyle(style_sheet);
+            OPL::Style::setStyle(style_sheet);
             ASettings::write(ASettings::Main::Style, new_style_setting);
             emit settingChanged(MainWindow);
             return;
@@ -429,7 +429,7 @@ void SettingsWidget::on_fontSpinBox_valueChanged(int arg1)
 void SettingsWidget::on_fontCheckBox_stateChanged(int arg1)
 {
     if (usingStylesheet() && arg1 == Qt::Unchecked) {
-        WARN(tr("The style you have currently selected may not be fully compatible "
+        WARN(tr("The OPL::Style you have currently selected may not be fully compatible "
                 "with changing to a custom font while the application is running.<br><br>"
                 "Applying your changes may require restarting the application.<br>"));
     }
@@ -461,11 +461,11 @@ void SettingsWidget::on_fontCheckBox_stateChanged(int arg1)
 }
 
 /*!
- * \brief Determines if the user has selected a stylesheet or is using a Qt Style Factory Style
+ * \brief Determines if the user has selected a OPL::Stylesheet or is using a Qt OPL::Style Factory Style
  */
 bool SettingsWidget::usingStylesheet()
 {
-    for (const auto &style_sheet : AStyle::styleSheets) {
+    for (const auto &style_sheet : OPL::Style::styleSheets) {
         if (style_sheet.styleSheetName == ui->styleComboBox->currentText())
             return true;
     }
@@ -474,8 +474,8 @@ bool SettingsWidget::usingStylesheet()
 
 void SettingsWidget::on_resetStylePushButton_clicked()
 {
-    LOG << "Resetting style to default...";
-    ui->styleComboBox->setCurrentText(AStyle::defaultStyle);
+    LOG << "Resetting OPL::Style to default...";
+    ui->styleComboBox->setCurrentText(OPL::Style::defaultStyle);
     ui->fontCheckBox->setChecked(true);
 }