diff --git a/d2stringtablewidget.cpp b/d2stringtablewidget.cpp index a83a01b..21d298f 100644 --- a/d2stringtablewidget.cpp +++ b/d2stringtablewidget.cpp @@ -1,4 +1,5 @@ #include "d2stringtablewidget.h" +#include "qtcompat.h" #include #include @@ -26,7 +27,7 @@ void D2StringTableWidget::keyPressEvent(QKeyEvent *keyEvent) { switch (keyEvent->key()) { -#ifndef Q_OS_MAC +#ifndef OS_MACOS case Qt::Key_Enter: // Return (usual Enter) or Enter (on the numpad) #endif case Qt::Key_Return: // starts editing of the current selected cell @@ -34,7 +35,7 @@ void D2StringTableWidget::keyPressEvent(QKeyEvent *keyEvent) emit itemDoubleClicked(currentItem()); break; // in-place edit -#ifdef Q_OS_MAC +#ifdef OS_MACOS case Qt::Key_Enter: #endif case Qt::Key_F2: @@ -178,7 +179,7 @@ void D2StringTableWidget::changeRowHeaderDisplay() QString rowText = QString::number(row); if (_displayRowHex) rowText += QString(" (0x%2)").arg(row, 0, 16); -#ifdef Q_OS_MAC +#ifdef OS_MACOS rowText += " "; // fixes slight text truncation #endif rowLabels += rowText; diff --git a/main.cpp b/main.cpp index 6cd8783..7e3b4b1 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include #include "qtbleditor.h" +#include "qtcompat.h" int main(int argc, char *argv[]) { @@ -10,13 +11,13 @@ int main(int argc, char *argv[]) app.setOrganizationName("kambala"); app.setApplicationName("QTblEditor"); app.setApplicationVersion("1.5"); -#ifdef Q_OS_MAC +#ifdef OS_MACOS app.setAttribute(Qt::AA_DontShowIconsInMenus); #endif QString locale = QLocale::system().name(), translationsPath = -#ifdef Q_OS_MAC +#ifdef OS_MACOS qApp->applicationDirPath() + "/../Resources/" + #endif "Translations/" + locale; diff --git a/qtbleditor.cpp b/qtbleditor.cpp index 3670865..5d41540 100644 --- a/qtbleditor.cpp +++ b/qtbleditor.cpp @@ -24,7 +24,7 @@ #include #include -#ifdef Q_OS_MAC +#ifdef OS_MACOS #ifdef IS_QT5 #include #else @@ -79,7 +79,7 @@ QTblEditor::QTblEditor(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(par ui.actionRenderGreyAsWhite->setText(tr("Render %1 as white", "Arg is grey's color code").arg(colorStrings.at(2))); -#ifdef Q_OS_MAC +#ifdef OS_MACOS ui.actionInsertAfterCurrent->setShortcut(QKeySequence("+")); ui.actionAppendEntry->setShortcut(QKeySequence("Ctrl++")); ui.actionGoTo->setShortcut(QKeySequence("Ctrl+L")); @@ -109,7 +109,7 @@ QTblEditor::QTblEditor(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(par _keyHashLabel->setMinimumSize(_keyHashLabel->sizeHint()); _keyHashLabel->clear(); -#ifndef Q_OS_MAC +#ifndef OS_MACOS ui.statusBar->addWidget(new QLabel, 1); #endif ui.statusBar->addPermanentWidget(_keyHashLabel); @@ -238,7 +238,7 @@ int QTblEditor::openTableMsgBoxResult() openOptsDlg.setEscapeButton(openOptsDlg.addButton(QMessageBox::Cancel)); openOptsDlg.addButton(tr("Replace active"), QMessageBox::NoRole); openOptsDlg.setText(tr("How do you want to open the table?")); -#ifdef Q_OS_MAC +#ifdef OS_MACOS openOptsDlg.setWindowModality(Qt::WindowModal); #endif return openOptsDlg.exec(); @@ -989,7 +989,7 @@ bool QTblEditor::isDialogQuestionConfirmed(const QString &text) { QMessageBox confirmationDialog(QMessageBox::Question, qApp->applicationName(), text, QMessageBox::Yes | QMessageBox::No, this); confirmationDialog.setDefaultButton(QMessageBox::Yes); -#ifdef Q_OS_MAC +#ifdef OS_MACOS confirmationDialog.setWindowModality(Qt::WindowModal); #endif return confirmationDialog.exec() == QMessageBox::Yes; @@ -1162,7 +1162,7 @@ void QTblEditor::readSettings() // read custom colors from file QFile f(customColorsFilePath()); -#ifndef Q_OS_MAC +#ifndef OS_MACOS if (!f.exists()) // fallback for older versions f.setFileName(kCustomColorsFileName); #endif @@ -1399,7 +1399,7 @@ QString QTblEditor::restoreNewlines(const QString &s) QString QTblEditor::customColorsFilePath() const { -#ifdef Q_OS_MAC +#ifdef OS_MACOS #ifdef IS_QT5 QString basePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); #else diff --git a/qtcompat.h b/qtcompat.h index 4697d47..05593a7 100644 --- a/qtcompat.h +++ b/qtcompat.h @@ -3,6 +3,16 @@ #include +#if IS_QT5 +# ifdef Q_OS_MACOS +# define OS_MACOS +# endif +#else +# ifdef Q_OS_MAC +# define OS_MACOS +# endif +#endif // IS_QT5 + class QFont; class QLineEdit;