Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

This commit is contained in:
Roy Qu 2022-05-30 18:16:52 +08:00
commit 6609c47b63
10 changed files with 104 additions and 9 deletions

View File

@ -13,7 +13,15 @@ isEmpty(APP_VERSION) {
APP_VERSION=1.1.0 APP_VERSION=1.1.0
} }
macos: {
# This package needs to be installed via homebrew before we can compile it
INCLUDEPATH += \
/opt/homebrew/opt/icu4c/include
QT += gui-private
ICON = ../macos/RedPandaIDE.icns
}
win32: VERSION = $${APP_VERSION}.0 win32: VERSION = $${APP_VERSION}.0
else: VERSION = $${APP_VERSION} else: VERSION = $${APP_VERSION}
@ -32,7 +40,7 @@ gcc {
} }
msvc { msvc {
DEFINES += NOMINMAX DEFINES += NOMINMAX
} }
# You can make your code fail to compile if it uses deprecated APIs. # You can make your code fail to compile if it uses deprecated APIs.
@ -424,6 +432,7 @@ unix: {
settingsdialog/formatterpathwidget.ui \ settingsdialog/formatterpathwidget.ui \
settingsdialog/environmentprogramswidget.ui settingsdialog/environmentprogramswidget.ui
} }
linux: { linux: {
LIBS+= \ LIBS+= \
-lrt -lrt
@ -494,3 +503,16 @@ RESOURCES += qmake_qm_files
RESOURCES += iconsets_files RESOURCES += iconsets_files
RESOURCES += theme_files RESOURCES += theme_files
RESOURCES += colorscheme_files RESOURCES += colorscheme_files
macos: {
# Add needed executables into the main app bundle
bundled_executable.files = \
$$OUT_PWD/../astyle/astyle \
$$OUT_PWD/../consolepauser/consolepauser \
$$OUT_PWD/../redpanda-git-askpass/redpanda-git-askpass.app/Contents/MacOS/redpanda-git-askpass
bundled_executable.path = Contents/MacOS
# Also bundled templates
QMAKE_BUNDLE_DATA += bundled_executable
}

View File

@ -54,6 +54,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
mFontDummy = QFont("Consolas",12); mFontDummy = QFont("Consolas",12);
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
mFontDummy = QFont("terminal",14); mFontDummy = QFont("terminal",14);
#elif defined(Q_OS_MACOS)
mFontDummy = QFont("Menlo", 14);
#else #else
#error "Not supported!" #error "Not supported!"
#endif #endif

View File

@ -190,15 +190,21 @@ QString Settings::Dirs::appResourceDir() const
return appDir(); return appDir();
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
return includeTrailingPathDelimiter(PREFIX)+"share/"+APP_NAME; return includeTrailingPathDelimiter(PREFIX)+"share/"+APP_NAME;
#elif defined(Q_OS_MACOS)
// return QApplication::instance()->applicationDirPath();
return "";
#endif #endif
} }
QString Settings::Dirs::appLibexecDir() const QString Settings::Dirs::appLibexecDir() const
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
return appDir(); return appDir();
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
return includeTrailingPathDelimiter(PREFIX)+"libexec/"+APP_NAME; return includeTrailingPathDelimiter(PREFIX)+"libexec/"+APP_NAME;
#elif defined(Q_OS_MACOS)
return QApplication::instance()->applicationDirPath();
#endif #endif
} }
@ -1274,10 +1280,13 @@ void Settings::Editor::doLoad()
mRightEdgeWidth = intValue("right_edge_width",80); mRightEdgeWidth = intValue("right_edge_width",80);
mRightEdgeLineColor = colorValue("right_edge_line_color",Qt::yellow); mRightEdgeLineColor = colorValue("right_edge_line_color",Qt::yellow);
//Font //Editor font
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
mFontName = stringValue("font_name","consolas"); mFontName = stringValue("font_name","consolas");
mNonAsciiFontName = stringValue("non_ascii_font_name","consolas"); mNonAsciiFontName = stringValue("non_ascii_font_name","consolas");
#elif defined(Q_OS_MACOS)
mFontName = stringValue("font_name","Menlo");
mNonAsciiFontName = stringValue("non_ascii_font_name","PingFang SC");
#else #else
mFontName = stringValue("font_name","Dejavu Sans Mono"); mFontName = stringValue("font_name","Dejavu Sans Mono");
mNonAsciiFontName = stringValue("non_ascii_font_name","Dejavu Sans Mono"); mNonAsciiFontName = stringValue("non_ascii_font_name","Dejavu Sans Mono");
@ -2845,7 +2854,13 @@ void Settings::Environment::doLoad()
QString defaultLocaleName = QLocale::system().name(); QString defaultLocaleName = QLocale::system().name();
if (defaultLocaleName == "zh_CN") { if (defaultLocaleName == "zh_CN") {
QString fontName; QString fontName;
#ifdef Q_OS_WINDOWS
fontName = "Microsoft Yahei"; fontName = "Microsoft Yahei";
#elif defined(Q_OS_MACOS)
fontName = "PingFang SC";
#elif defined(Q_OS_LINUX)
fontName = "Noto Sans CJK";
#endif
QFont font(fontName); QFont font(fontName);
if (font.exactMatch()) { if (font.exactMatch()) {
defaultFontName = fontName; defaultFontName = fontName;
@ -2874,6 +2889,10 @@ void Settings::Environment::doLoad()
if (mTerminalPath.isEmpty()) if (mTerminalPath.isEmpty())
mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator"); mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator");
mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"astyle"; mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"astyle";
#elif defined(Q_OS_MACOS)
mTerminalPath = stringValue("terminal_path",
"/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal");
mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"astyle";
#endif #endif
mHideNonSupportFilesInFileView=boolValue("hide_non_support_files_file_view",true); mHideNonSupportFilesInFileView=boolValue("hide_non_support_files_file_view",true);
mOpenFilesInSingleInstance = boolValue("open_files_in_single_instance",false); mOpenFilesInSingleInstance = boolValue("open_files_in_single_instance",false);
@ -3222,6 +3241,8 @@ void Settings::Executor::doLoad()
mIgnoreSpacesWhenValidatingCases = boolValue("ignore_spaces_when_validating_cases",false); mIgnoreSpacesWhenValidatingCases = boolValue("ignore_spaces_when_validating_cases",false);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
mCaseEditorFontName = stringValue("case_editor_font_name","consolas"); mCaseEditorFontName = stringValue("case_editor_font_name","consolas");
#elif defined(Q_OS_MACOS)
mCaseEditorFontName = stringValue("case_editor_font_name", "Menlo");
#else #else
mCaseEditorFontName = stringValue("case_editor_font_name","Dejavu Sans Mono"); mCaseEditorFontName = stringValue("case_editor_font_name","Dejavu Sans Mono");
#endif #endif

View File

@ -50,6 +50,21 @@
#define CLANG_PROGRAM "clang" #define CLANG_PROGRAM "clang"
#define CLANG_CPP_PROGRAM "clang++" #define CLANG_CPP_PROGRAM "clang++"
#define LLDB_MI_PROGRAM "lldb-mi" #define LLDB_MI_PROGRAM "lldb-mi"
#elif defined(Q_OS_MACOS)
#define GCC_PROGRAM "gcc"
#define GPP_PROGRAM "g++"
#define GDB_PROGRAM "gdb"
#define GDB_SERVER_PROGRAM "gdbserver"
#define GDB32_PROGRAM "gdb32"
#define MAKE_PROGRAM "make"
#define WINDRES_PROGRAM ""
#define GPROF_PROGRAM "gprof"
#define CLEAN_PROGRAM "rm -rf"
#define CPP_PROGRAM "cpp"
#define GIT_PROGRAM "git"
#define CLANG_PROGRAM "clang"
#define CLANG_CPP_PROGRAM "clang++"
#define LLDB_MI_PROGRAM "lldb-mi"
#else #else
#error "Only support windows and linux now!" #error "Only support windows and linux now!"
#endif #endif
@ -85,7 +100,7 @@
# define DYNAMIC_LIB_EXT "dll" # define DYNAMIC_LIB_EXT "dll"
# define MAKEFILE_NAME "makefile.win" # define MAKEFILE_NAME "makefile.win"
# define ALL_FILE_WILDCARD "*.*" # define ALL_FILE_WILDCARD "*.*"
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
# define PATH_SENSITIVITY Qt::CaseSensitive # define PATH_SENSITIVITY Qt::CaseSensitive
# define PATH_SEPARATOR ":" # define PATH_SEPARATOR ":"
# define LINE_BREAKER "\n" # define LINE_BREAKER "\n"

View File

@ -27,6 +27,11 @@
#include <QSvgRenderer> #include <QSvgRenderer>
#include "../settings.h" #include "../settings.h"
#if defined(Q_OS_MACX)
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformtheme.h>
#endif
#define BEGIN_STYLE_PIXMAPCACHE(a) \ #define BEGIN_STYLE_PIXMAPCACHE(a) \
QRect rect = option->rect; \ QRect rect = option->rect; \
QPixmap internalPixmapCache; \ QPixmap internalPixmapCache; \

View File

@ -5,14 +5,20 @@ SUBDIRS += \
astyle \ astyle \
consolepauser consolepauser
# Add the dependencies so that the RedPandaIDE project can add the depended programs
# into the main app bundle
RedPandaIDE.depends = astyle consolepauser
win32: { win32: {
SUBDIRS += \ SUBDIRS += \
redpanda-win-git-askpass redpanda-win-git-askpass
RedPandaIDE.depends += redpanda-win-git-askpass
} }
linux: { unix: {
SUBDIRS += \ SUBDIRS += \
redpanda-git-askpass redpanda-git-askpass
RedPandaIDE.depends += redpanda-git-askpass
} }
APP_NAME = RedPandaCPP APP_NAME = RedPandaCPP
@ -20,7 +26,6 @@ APP_NAME = RedPandaCPP
APP_VERSION = 1.1.0 APP_VERSION = 1.1.0
linux: { linux: {
isEmpty(PREFIX) { isEmpty(PREFIX) {
PREFIX = /usr/local PREFIX = /usr/local
} }
@ -44,7 +49,6 @@ linux: {
desktop.path = $${PREFIX}/share/applications desktop.path = $${PREFIX}/share/applications
desktop.files += linux/redpandaide.desktop desktop.files += linux/redpandaide.desktop
INSTALLS += desktop INSTALLS += desktop
} }
win32: { win32: {

View File

@ -19,10 +19,15 @@ SOURCES += \
unix: { unix: {
SOURCES += \ SOURCES += \
main.unix.cpp main.unix.cpp
LIBS+= \
-lrt
} }
# macOS does not provide rt library, only use it for Linux
linux: {
LIBS+= \
-lrt
}
CONFIG += lrelease CONFIG += lrelease
CONFIG += embed_translations CONFIG += embed_translations

View File

@ -109,7 +109,9 @@ int ExecuteCommand(vector<string>& command,bool reInp) {
if (result) { if (result) {
printf("Failed to start command %s %s!\n",path_to_command.c_str(), file.c_str()); printf("Failed to start command %s %s!\n",path_to_command.c_str(), file.c_str());
printf("errno %d: %s\n",errno,strerror(errno)); printf("errno %d: %s\n",errno,strerror(errno));
printf("current dir: %s",get_current_dir_name()); char* current_dir = getcwd(nullptr, 0);
printf("current dir: %s",current_dir);
free(current_dir);
exit(-1); exit(-1);
} }
} else { } else {

BIN
macos/RedPandaIDE.icns Normal file

Binary file not shown.

19
macos/gen_macos_icns.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
input_icon="../RedPandaIDE/images/devcpp.png"
output_dir="RedPandaIDE.iconset"
mkdir $output_dir
sips -z 16 16 $input_icon --out "${output_dir}/icon_16x16.png"
sips -z 32 32 $input_icon --out "${output_dir}/icon_16x16@2x.png"
sips -z 32 32 $input_icon --out "${output_dir}/icon_32x32.png"
sips -z 64 64 $input_icon --out "${output_dir}/icon_32x32@2x.png"
sips -z 128 128 $input_icon --out "${output_dir}/icon_128x128.png"
sips -z 256 256 $input_icon --out "${output_dir}/icon_128x128@2x.png"
sips -z 256 256 $input_icon --out "${output_dir}/icon_256x256.png"
sips -z 512 512 $input_icon --out "${output_dir}/icon_256x256@2x.png"
iconutil -c icns $output_dir
rm -R $output_dir